Skip to content

buzz-db: pin explicit FK-child cleanup and same-workflow fire links - #8317

Merged
TheSentinel454 merged 5 commits into
mainfrom
elrond/explicit-cascade-deletes-2
Nov 12, 2026
Merged

TheSentinel454 merged 5 commits into
mainfrom
elrond/explicit-cascade-deletes-2

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #8219 (merged); rebased onto main at 93ffc37cb (includes the rustls bump, #8319).

What

This closes the identified debt from #8212. Every remaining ON DELETE CASCADE / SET NULL foreign key was audited against every supported way its parent row gets removed, with FK actions retired in the per-test schema (test_support::retire_foreign_key_delete_actions). One production change was needed. The rest is already explicit and is now covered by tests.

Production change: attach_scheduled_workflow_run (store/workflow.rs) now links a scheduled fire only to a run of the same workflow (EXISTS on (community_id, workflow_id, id) in the existing admitted UPDATE). Before this, a fire for workflow B could reference a run of A. That FK is already NO ACTION, so the link would block A's explicit run delete. The only production caller (buzz-workflow cron tick) attaches the run it just created for the same workflow, so live behavior is unchanged. A mismatched attach now returns false like any other non-match, and the caller already treats that as best-effort.

FK audit (all 12 delete actions)

Child FK Action Parent removal path → handling
scheduled_workflow_fires → workflows CASCADE Workflow delete removes fires explicitly (#8212)
workflow_runs → workflows CASCADE Explicit (#8212)
workflow_approvals → workflows CASCADE Explicit (#8212)
workflow_approvals → workflow_runs CASCADE Explicit, including cross-workflow approvals (#8212)
join_policy_acceptances → relay_members CASCADE Explicit (#8212)
channel_members → channels CASCADE Single-channel removal is a soft delete. The community purge deletes members before channels. Pinned here.
personal_read_frontiers → personal_read_accounts CASCADE No single-account hard delete exists. The purge deletes frontiers before accounts. Pinned here.
personal_read_frontiers → channels CASCADE Same as above. Pinned here.
users.agent_owner_pubkey → users SET NULL The only production hard delete of users is the purge deleting all of a community's users in one statement. Pinned here (owner + owned agent). No single-user hard delete exists.
product_feedback → communities SET NULL Communities are tombstoned, never hard-deleted. The purge already nulls feedback community_id explicitly. Pinned here.
community_deletion_manifest_keys → community_deletion_requests CASCADE Requests are retained. mark_logically_verified deletes chunks explicitly, and the chunk guard trigger is unchanged. The existing lifecycle test now runs with FK actions retired.
community_deletion_executor_heartbeats → community_deletion_requests SET NULL Requests are retained, so this action is never reached. Pinned here: the heartbeat stays linked through the purge.

Audit method: searched crates/**/*.rs for DELETE FROM against each parent table. Every direct DELETE FROM communities / users hit is in #[cfg(test)] fixtures. Production removes rows only through the scoped purge loop in store/deletion.rs and the channel soft delete in store/channel.rs.

Not added: per-parent delete APIs. They would duplicate the community purge for parents that are never hard-deleted. I also left out a source-text "no hard delete" policy test, because it would pass without any production fix. If a single-user, channel, read-account, request or community hard delete is ever added, it has to clear agent_owner_pubkey (only that column) and delete these children explicitly first.

Tests

  • attach_rejects_run_from_another_workflow: a claim for B can't be linked to A's run, and the fire stays unlinked.
  • purge_removes_fk_children_explicitly_without_fk_actions: on the retired-FK schema, channel_members and personal_read_frontiers children are seeded through an admitted transaction, and then the production quiesce → fence → purge runs. Every child must be deleted explicitly, both users must be removed, feedback must survive with community_id = NULL, and the retained request's heartbeat (selected by executor_id) must stay linked. The quiesce barrier against open admitted writers is already pinned by begin_quiescing_waits_for_open_admitted_writer_note_update; this test does not re-claim it.
  • manifest_key_chunks_bind_freeze_execution_and_cleanup now retires FK actions first.

Each test was checked to fail when its production behavior is removed: dropping the EXISTS guard, dropping personal_read_frontiers from the purge order (23503), dropping feedback provenance clearing, and dropping the explicit manifest chunk delete. All four failed as expected.

What got simpler

The production change is one predicate. No new concepts or APIs. The FK audit is now settled, so the follow-up migration can drop all 12 actions at once. No new delete code was needed.

Identified debt (pre-existing, outside this diff): the cron tick in buzz-workflow/src/lib.rs logs only Err from attach_scheduled_workflow_run; an Ok(false) (no matching unlinked claim) leaves the fire unlinked without a trace.

Identified debt (unrelated, pre-existing): writer_pool_rejects_non_read_committed_database_default hangs with no active query on clean 177551dda as well (bounded after ~270 s on both checkouts).

Verification (Blox, at the exact tree of this commit)

Gate Result
cargo fmt --all -- --check pass
cargo clippy --workspace --all-targets -- -D warnings pass
cargo nextest run -p buzz-db --lib 166/166
scripts/postgres-test-run.sh -p buzz-admin / audit / deletion / push-gateway / relay / search / workflow all rc 0 (4, 7, 11, 11, 402, 20, 2)
scripts/postgres-test-run.sh -p buzz-db 510 pass, 2 fail: the pre-existing hang above, plus one 150 ms PoolTimedOut in routed_fallback_spends_one_acquire_budget_when_aurora_cache_is_cold (pool setup under full-lane load; it passed on the clean-baseline lane and passes in isolation at this tree, 1/1 in 1.7 s)

The new tests are selected by the postgres-ci nextest filter (test(/postgres_tests::/) or binary(/^postgres_/)) and not test(/(^|::)external_infra[^:]*::/).

TheSentinel454 pushed a commit that referenced this pull request Oct 14, 2026
Address review on #8317: the held-tx race scaffold could not fail without
the admission barrier (the FK key-share row lock blocked quiescing anyway),
so seed children in sequence and rename the test; the barrier stays pinned
by begin_quiescing_waits_for_open_admitted_writer_note_update. Select the
heartbeat by executor_id so a SET NULL regression fails the assertion, and
document why attach_scheduled_workflow_run rejects cross-workflow runs.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Base automatically changed from elrond/app-write-fence-admission to main October 14, 2026 14:58
TheSentinel454 pushed a commit that referenced this pull request Oct 14, 2026
Address review on #8317: the held-tx race scaffold could not fail without
the admission barrier (the FK key-share row lock blocked quiescing anyway),
so seed children in sequence and rename the test; the barrier stays pinned
by begin_quiescing_waits_for_open_admitted_writer_note_update. Select the
heartbeat by executor_id so a SET NULL regression fails the assertion, and
document why attach_scheduled_workflow_run rejects cross-workflow runs.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
@TheSentinel454
TheSentinel454 force-pushed the elrond/explicit-cascade-deletes-2 branch from e076bec to a793d89 Compare October 14, 2026 15:04
Elrond added 4 commits October 16, 2026 09:55
Audit every remaining ON DELETE CASCADE / SET NULL foreign key (BUZZ-320)
against the supported parent-removal paths, with FK actions retired in the
per-test schema:

- attach_scheduled_workflow_run now links a scheduled fire only to a run of
  the same workflow, so a cross-workflow link can never block an explicit
  run delete once FK actions are dropped.
- The community purge test seeds channel members, personal-read frontiers,
  owner/agent users, product feedback and an executor heartbeat, races a
  held child-insert transaction against quiescing, and requires explicit
  removal (or provenance clearing) of every child with no FK action.
- The manifest-key lifecycle test runs on the retired-FK schema.

FK constraints, actions, triggers and checks are unchanged; a later
migration drops the actions.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Address review on #8317: the held-tx race scaffold could not fail without
the admission barrier (the FK key-share row lock blocked quiescing anyway),
so seed children in sequence and rename the test; the barrier stays pinned
by begin_quiescing_waits_for_open_admitted_writer_note_update. Select the
heartbeat by executor_id so a SET NULL regression fails the assertion, and
document why attach_scheduled_workflow_run rejects cross-workflow runs.

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
@TheSentinel454
TheSentinel454 force-pushed the elrond/explicit-cascade-deletes-2 branch from a793d89 to 6c065d4 Compare October 16, 2026 13:57
@TheSentinel454
TheSentinel454 marked this pull request as ready for review October 16, 2026 19:06
@TheSentinel454
TheSentinel454 requested a review from a team as a code owner October 16, 2026 19:06
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: e2dc54e22fc113f298889d76c3acf674cb46db4b...533434ab5f32043fa9f87671ff90c4fded770bca
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings in the authorized PR range. The new link guard preserves community and workflow scoping and is consistent with deletion ordering.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source, schema, caller, test, and history inspection. Builds and tests were not executed.

Generated by Codex Security Review |
Requested by: @TheSentinel454 |
Workflow run

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Thanks, Luke. Nothing blocking.

The new EXISTS keeps the attach inside the admitted write and only links a run with the claim's community and workflow. The cron tick creates its run with the same IDs it attaches, so live behavior doesn't change. The FK inventory matches the schema at this head, the base, and current main: 9 CASCADE and 3 SET NULL, the same 12 rows as the table. The retire helper turns them into plain NO ACTION, which is checked at the end of each statement, so the purge deleting an owner and its agent in one statement is the same check the follow-up migration will leave in place.

Verified at this head on an isolated PostgreSQL stack:

  • All 522 PostgreSQL tests in buzz-db pass, including the three new or changed ones, and each also passes by name in the PostgreSQL job.
  • Removing each guard turns its test red: the EXISTS (cross-workflow assertion), personal_read_frontiers and channel_members in the purge order (both 23503 deleting the parent), the feedback community_id null-out (provenance stays set), and the manifest chunk delete in mark_logically_verified() ((2, 2) chunks remain instead of (0, 0)).

Optional

  • A missing run used to fail the attach with an FK violation, which the cron tick logs as a warning. Now it returns false like the cross-workflow case, and the tick only logs Err, so both now pass silently. This is the gap you already called out, but this PR widens it, so a warn on Ok(false) there might be worth folding in. Nothing tests the missing-run case either.
  • The audit method says production removes rows only through the purge loop and the channel soft delete. That holds for channels, users, read accounts, communities and deletion requests, but workflows/runs (delete_workflow_with_children) and relay members (delete_member_with_acceptances) have their own production hard deletes. Both already delete children first, as your table says, so it's just that sentence that needs scoping.
  • No buzz-review-completed in the description yet.

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord’s automated source review via Wes’s account.

No actionable findings in this revision. The attachment predicate keeps the run in the claim’s community and workflow, preserves the existing fire-before-run lock order, and matches the scheduler’s normal call path. The new tests exercise explicit child cleanup and retained deletion evidence with FK delete actions retired. The public PR description and changed source were inspected; no attached description images or actionable disclosure findings were identified.

Reviewed head 6c065d4084d741789ca51c8ff21a8bc4f5ecccf7 against base 93ffc37cbdb7ced6a07eca11744931cdffb82e20. Independent coverage: Rocket (systems/lifecycle), Mantis (correctness/security/concurrency), Groot (product/source-visible flows), with Star Lord integration. Minimalism, elegance and correctness: 9/10 each on source review.

Validation: source only; no tests, builds, application runs, SQL execution or mutation experiments were performed. A read-only head check snapshot showed 57 successful and 34 skipped checks; this is not independent runtime validation. PostgreSQL concurrency, purge execution and performance remain unverified by this review. The documented best-effort attachment behavior and optional logging of Ok(false) remain outside the requested fixes. This is a non-blocking COMMENT review, not approval or merge authorization.

@loganj loganj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Larry and Auto: an independent adversarial review of 6c065d4084. Source review only, plus local Postgres 17 runs. No blockers. Approving.

What we checked

  • The FK audit still holds on current main. We checked main at e2dc54e22. schema/ still has the same 12 ON DELETE actions as the table. Apart from the purge loop, the only production hard deletes of these parents are delete_member_with_acceptances (relay_members.rs) and delete_workflow_with_children (workflow/deletion.rs). Both delete their children explicitly. Every other DELETE FROM hit on these parents is inside a postgres_tests module.
  • The CI result is from Oct 19, and main has moved a lot since (deletion.rs is about +1,000 lines). So we merged this head into main e2dc54e22 and reran. cargo check -p buzz-db --tests passes, and the three changed tests pass (3/3).
  • Each test fails when the behavior it covers is removed. Auto ran these mutations; each one made the test fail:
    • Remove the EXISTS.
    • Move channel_members after channels in PURGE_SCOPED_TABLES (23503).
    • Split the users delete so owners go first (23503 on users_community_id_agent_owner_pubkey_fkey). So the owner+agent seed really does replace the SET NULL action.
  • Locks and performance. The EXISTS is a primary-key probe on workflow_runs (community_id, id) and takes no row lock. Lock order is still fire, then run (through the FK check), which matches the deadlock comment in delete_workflow_with_children.

Optional

  • (advice) The cron tick in buzz-workflow/src/lib.rs (~L745) logs only Err from attach_scheduled_workflow_run. This PR adds another silent Ok(false) case. The current caller can't reach it, but a one-line warn! on Ok(false) would close the debt the PR body already names.
  • (advice, later) A composite FK (community_id, workflow_id, workflow_run_id) → workflow_runs (community_id, workflow_id, id) would make the same-workflow rule part of the schema instead of one writer's predicate. It needs a unique index and a migration, so it's out of scope here.

Inline notes are optional.

Comment thread crates/buzz-db/src/store/deletion.rs Resolved
Comment thread crates/buzz-db/src/store/deletion.rs Resolved
…test

Deletion requests are never hard-deleted, so the heartbeat's SET NULL path
cannot fire and the seed pinned nothing about FK replacement.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Luke Tornquist <[email protected]>
@github-actions github-actions Bot added codex-security-review-current The posted Codex security review matches its recorded range. and removed codex-security-review-current The posted Codex security review matches its recorded range. labels Nov 10, 2026

@loganj loganj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Larry: re-approving at 533434a. The only change since the approved 6c065d4 deletes the heartbeat seed from the purge FK test (the optional comment). Test-only; no production change. CI is green at this head.

@TheSentinel454
TheSentinel454 merged commit aa9b44e into main Nov 12, 2026
159 of 161 checks passed
@TheSentinel454
TheSentinel454 deleted the elrond/explicit-cascade-deletes-2 branch November 12, 2026 18:28
ravarora2 added a commit that referenced this pull request Nov 12, 2026
Co-authored-by: dessert <7d616e7e143e5d408159614dccff1371350a1c1bd36c8de838a45ece5aca0aca@buzz.block.builderlab.xyz>

* origin/main:
  buzz-db: pin explicit FK-child cleanup and same-workflow fire links (#8317)
  chore(deps): bump hickory to 0.26.3 for RUSTSEC-2026-0506..0520 (#9394)

Signed-off-by: Ravneet Arora <[email protected]>
TheSentinel454 added a commit that referenced this pull request Nov 12, 2026
Replace the foreign-key checks on the workflow tables with explicit
in-transaction checks, so the constraints can be dropped in a later
contract migration. The foreign keys stay in place; the checks are
idempotent with them.

Each writer locks the parent row FOR KEY SHARE, the lock the foreign key
takes, and a missing parent is DbError::NotFound instead of a generic
foreign-key database error:

- create_workflow / upsert_workflow: owner in users, channel in channels
- create_workflow_run: workflow
- create_approval: workflow and run
- claim_scheduled_workflow_fire: FOR KEY SHARE OF w in the claim's SELECT,
  so a concurrent workflow delete (which locks the workflow FOR UPDATE and
  then deletes fires) cannot leave an orphan fire once the FK is gone

attach_scheduled_workflow_run is left to #8317, which adds the run
existence guard to the same UPDATE.

Tests drop the covered foreign keys in the per-test database and show
each writer rejects a missing parent, plus two-connection races between
each writer and workflow deletion. The existing deletion races now take
the explicit locks instead of relying on foreign-key locks.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Luke Tornquist <[email protected]>
TheSentinel454 added a commit that referenced this pull request Nov 12, 2026
…04 (#9418)

## Summary

Two separate CI breaks are hitting every PR right now. Each one blocks a
required check, and neither fix can go green on its own, so this PR
fixes both.

**1. Rust test targets stopped compiling on main at fc8c802.** #9227
added a required `RunCause` argument to `create_workflow_run` and a
`may_direct_agents` flag to `ActionSink::send_message`. Two tests that
merged around the same time still used the old signatures:

- `attach_rejects_run_from_another_workflow` in
`crates/buzz-db/src/store/workflow.rs` (from #8317)
- the agent-DM refusal test in `crates/buzz-relay/src/workflow_sink.rs`
(from #9371)

Each PR passed CI on its own base. Together they break Rust Lint, Unit
Tests, Windows Rust and the Desktop E2E Relay artifact build (main CI
run 43291564834). The fix passes `RunCause::Schedule` and `true`,
matching the neighbouring tests. Neither test is about run cause or
agent mentions, so neither assertion changes.

**2. Desktop E2E Integration fails on GitHub's new Ubuntu 26.04
runners.** `ubuntu-latest` is rolling to 26.04, and Playwright 1.60 (our
lockfile) fails with `Playwright does not support chromium on
ubuntu26.04-x64`. Playwright 1.61 is the first release that knows
ubuntu26.04. This PR bumps `@playwright/test` to `^1.65.0` in
`desktop/`, `web/` and `admin-web/` and regenerates `pnpm-lock.yaml`. It
also pins every `ubuntu-latest` job in `ci.yml` and `_ci-*.yml` to
`ubuntu-26.04`, so the next runner image change arrives in a reviewed
diff. macOS and Windows jobs are unchanged.

The newer Chromium bundled with Playwright 1.65 changed two smoke specs.
It reports Tailwind's `items-end` as `align-items: flow-end`
(`doctor-states` now accepts `flex-end` or `flow-end`), and it draws the
textarea resize grip differently, so the
`workflow-template-variable-autocomplete` baseline is refreshed from the
ubuntu-26.04 CI output.

It also exposed a timing race in `profile.spec.ts` "owned agent profile
stays in parity": when the Message click lands while the profile panel
is still settling, Playwright's scroll-into-view retry scrolls the
profile body, which hides the owned-agent action row (aria-hidden +
inert) for good. The test now pins the body to the top and waits for the
row before clicking (12/12 repeats plus the full profile spec pass on
Linux).

## Verification

- `cargo clippy -p buzz-db -p buzz-relay --tests -- -D warnings` is
clean on fc8c802 with commit 1 applied.
- `pnpm install --frozen-lockfile` succeeds with the new lockfile, and
`playwright --version` reports 1.65.0.
- `tsc --noEmit` passes for `desktop`, `web` and `admin-web`.
- This PR's CI is the E2E check on 26.04.

## Notes

- Workflows that don't run on PRs (release, helm charts, sprig, image
builds, codex-security-review) still use `ubuntu-latest`. This PR can't
exercise them, so they're left for a follow-up.
- The hermit-pinned actionlint (1.7.12) doesn't know the `ubuntu-26.04`
label yet. CI only actionlints `codex-security-review.yml`, which this
PR doesn't touch.

## Simpler

No production code changes. The runner pin swaps an implicit moving
target for an explicit one.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Luke Tornquist <[email protected]>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <[email protected]>
TheSentinel454 added a commit that referenced this pull request Nov 12, 2026
Replace the foreign-key checks on the workflow tables with explicit
in-transaction checks, so the constraints can be dropped in a later
contract migration. The foreign keys stay in place; the checks are
idempotent with them.

Each writer locks the parent row FOR KEY SHARE, the lock the foreign key
takes, and a missing parent is DbError::NotFound instead of a generic
foreign-key database error:

- create_workflow / upsert_workflow: owner in users, channel in channels
- create_workflow_run: workflow
- create_approval: workflow and run
- claim_scheduled_workflow_fire: FOR KEY SHARE OF w in the claim's SELECT,
  so a concurrent workflow delete (which locks the workflow FOR UPDATE and
  then deletes fires) cannot leave an orphan fire once the FK is gone

attach_scheduled_workflow_run is left to #8317, which adds the run
existence guard to the same UPDATE.

Tests drop the covered foreign keys in the per-test database and show
each writer rejects a missing parent, plus two-connection races between
each writer and workflow deletion. The existing deletion races now take
the explicit locks instead of relying on foreign-key locks.

Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Luke Tornquist <[email protected]>
matt2e added a commit that referenced this pull request Nov 14, 2026
…ests a test-lane acquire budget (#9442)

## Summary
Two Rust tests failed on loaded CI runners because their timing budget
came from the wall clock or from a production timeout, not from the
behavior they assert. Each fix changes only test code or `cfg(test)`
code.

Commits (cherry-picked unchanged from a local flake-fix series):
- `test(cli): freeze the test clock in the assertion refresh tests`
- `test(db): give the pool release Postgres tests a test-lane acquire
budget`

### Root cause and fix per test


**`federated_identity::tests::short_and_long_assertions_refresh_at_the_earlier_point`**
and its twin in `desktop_provider` (`crates/buzz-cli`): failed in CI
with `assertion left == right failed: lifetime 300`, left 2, right 1, at
`federated_identity.rs:634`.

- CI sighting, 11 November 2026, "Rust / Unit Tests", run 43122921918
attempt 1 (on #9342; the rerun passed):
-
https://github.com/block/buzz/actions/runs/43122921918/job/130868244938
- Root cause: under `cfg(test)`, `cached_assertion::unix_now()` was the
wall clock plus a thread-local skew. The mock stamps `exp = unix_now() +
lifetime`, then `CachedAssertion::get` computes `refresh_at(unix_now(),
exp)` after the HTTP round trip, and the next call checks `unix_now() <
refresh`. The test needed those reads to agree to the second. When the
wall clock crossed a second boundary between them, the refresh point
moved 1 s earlier, `advance(refresh - 1)` landed exactly on it, and the
assertion was minted one step early.
- Fix: a thread-local `FROZEN` base beside `SKEW`, and
`test_clock::freeze(at)` to pin it. Under `cfg(test)`, `unix_now()`
returns `FROZEN.unwrap_or(real_now) + SKEW`, so `advance` and its
existing callers in `client.rs` behave as before. Both tests freeze the
clock at the top of their loop body. The mock adapter runs on the same
current-thread runtime, so `exp`, `refresh_at` and the check share one
"now". Production code paths are unchanged.
- Verification: each test run 1,440 times, 24 in parallel, before and
after. `federated_identity`: 4 failures before, 0 after.
`desktop_provider`: 1 failure before, 0 after.
- Not seen in CI: the `desktop_provider` twin. It passed in the job
above and is fixed here because it has the same race and failed locally.


**`runtime::postgres_tests::pool_release_postgres_tests::silence_after_release_hook_does_not_strand_sqlx_ping`**
(`crates/buzz-db`): panicked at `pool_release_postgres_tests.rs:204:10`
with ``called `Result::unwrap()` on an `Err` value: PoolTimedOut`` after
0.85 s.

- CI sighting, 10 November 2026, "PostgreSQL Domain / PostgreSQL Tests",
run 42851548618 attempt 1 (on #8317; the rerun passed):
-
https://github.com/block/buzz/actions/runs/42851548618/job/129969964659
- Root cause: the test built its pool from the production
`Db::read_pool_options`, whose 150 ms `READER_ACQUIRE_TIMEOUT` also
bounded `connect_with`'s eager first dial (and `fresh_query`'s). On a
busy runner the cold dial through `PausingProxy`, SCRAM and the reader
`after_connect` hook overran it, so the test panicked at the initial
`connect_with(...).unwrap()` before the release-hook recovery path it
asserts ever ran. Production is not exposed: the relay dials the reader
pool lazily, so that budget only governs request-time acquires, which
fall back to the writer by design.
- Fix: a 30 s `TEST_LANE_ACQUIRE_TIMEOUT` on both pool builders in this
file: the reader test's `PoolOptions`, and `writer_pool`'s `DbConfig`,
whose eagerly dialed 3 s default is the same exposure #9273 fixed for
buzz-admin. `test_before_acquire(false)`, `after_connect` and
`after_release` stay as in production, and recovery still completes at
sqlx's 5 s return deadline inside the test's 10 s `await_capacity`
budget. No assertions change.
- Verification, against a local Postgres: 10 rounds of
`pool_release_postgres_tests --ignored --test-threads=6` per binary.
Before, 2 of 10 rounds failed at `:204:10` with `PoolTimedOut`, the CI
signature. After, 0 of 10. Under 28 CPU busy loops, with before and
after runs interleaved: 6 of 10 failed before, 0 of 10 after.
- Not done here: `reader_pool_postgres_tests.rs` already carries its own
5 s test budget on `read_pool_options` for the same reason. This PR does
not unify the two constants.

One sighting of each failure was found in the CI runs from 7 to 12
November 2026 that were searched.

### Related issue
N/A (flake fixes). No existing issue was found, and no open PR touches
these tests or the four files changed here.

### Testing
Human testing is still required. This PR does not carry
`buzz-review-completed`; the author has not yet run these tests
themselves on this branch.

The repetition counts above were measured when the fixes were written,
before this branch was split out. They were not repeated on this branch.

#### Local checks on this branch
The branch is one commit behind `main`; that commit changes only mobile
and docs files, none of them touched here.

Ran and passed at push time, on a checkout of this branch's head
(`42b3faccc`): the organization push check, `branch-skew`,
`push-head-scope`, `file-size-check` and git-lfs.

Did not run:
- The `rust-tests` and `desktop-tauri-checks` pre-push lanes. They were
excluded from the push (`LEFTHOOK_EXCLUDE`) because the machine ran out
of disk part-way through them on an earlier attempt. That attempt did
not complete, so it proves nothing either way about this branch.
- The desktop and mobile pre-push lanes (`desktop-check`,
`desktop-typecheck`, `desktop-test`, `mobile-checks`). This diff touches
no desktop or mobile file.
- `cargo fmt --check`, `cargo clippy`, `just ci`, and the PostgreSQL
lane.

CI's Unit Tests and PostgreSQL Tests jobs are the gate for this branch.
A green run does not prove the flakes are gone: both failures need a
loaded runner.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: mtoohey <[email protected]>
Signed-off-by: Matt Toohey <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>

This branch was previously deployed

1 inactive deployment
codex-review — 533434ab Deployed Nov 10, 2026 by TheSentinel454 via Run Codex Security Review #14252
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants