mirror of
https://github.com/block/buzz.git
synced 2026-12-01 13:42:45 +00:00
Three tests against the locked-spec DB seam at1fa3d837f("fix(db): resolve workflow schedule tenant from DB"). These exercise Theorem S1 (`docs/multi-tenant-relay.md:248` — "the claimed community never appears in this function — only the resolved one") and pin the two surrounding invariants that hold across the schema change. 1. claim_for_workflow_in_other_community_no_ops A workflow owned by community B and an unrelated community A. Caller invokes claim_scheduled_workflow_fire(workflow_id, scheduled_for) — no caller-supplied tenant, by the post-fix signature. Asserts the returned claim row's community_id equals B (the workflow owner), proving the SQL resolves tenant from the workflows row server-side (`INSERT ... SELECT w.community_id, w.id, $2 FROM workflows w WHERE w.id = $1`). This was RED on48c53a5d7(pre-fix the row came back as the caller's tenant) and is GREEN on1fa3d837f. 2. concurrent_same_window_claims_exactly_one_wins 8-task race on the same (workflow_id, scheduled_for). Asserts exactly one task returns Some. Pins the dedup boundary under the post-fix PK (workflow_id, scheduled_for) — workflow_id is globally unique, so community_id is a scoped/audit label only. 3. latest_after_prune_below_interval_breaks_anchor Insert a claim, backdate its claimed_at into the deep past, then prune below it. Asserts latest_scheduled_workflow_fire returns None — encoding the deployment-config rule from PLANS §5c that the janitor cutoff MUST exceed MAX(interval_secs) + safety margin across all enabled interval workflows in all communities (the prune primitive is process-global, see Mari [9] / Eva [6]). If latest_* ever becomes resilient to pruning, this test's assertion is the contract that has to be updated. Tests live in the existing crates/buzz-db/src/workflow.rs `mod tests` block alongside the other #[ignore = "requires Postgres"] tests, per repo convention. Validation against1fa3d837fwith Docker postgres up: - cargo fmt -p buzz-db --check ✓ - cargo clippy -p buzz-db --tests --no-deps -- -D warnings ✓ - cargo test -p buzz-db --lib workflow::tests:: -- --ignored ✓ 3/3 - 10/10 stable runs with default parallel test-threads ✓ Pre-existing test failures observed on1fa3d837funder --include-ignored --test-threads=1 (channel::tests::test_*_remove_bot, channel::tests::test_unarchive_expired_*, thread::tests::*) reproduce without these tests — not introduced here. Co-authored-by: Tyler <109685178+tlongwell-block@users.noreply.github.com> Signed-off-by: Tyler <109685178+tlongwell-block@users.noreply.github.com>