Repository navigation
fix: prevent transcript writes racing reclamation shutdown - #147178
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:38 PM ET / 16:38 UTC. ClawSweeper reviewWhat this changesSerializes cleanup-worker shutdown with transcript writes and extends the database-switch regression to verify ordering through native worker exit. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The patch preserves the existing ownership model, and no blocking correctness or security findings were identified. Priority: P2 Review scores
Verification
How this fits togetherSession reclamation removes obsolete session data using a retained SQLite worker. Its shutdown shares the agent database with foreground transcript writes, so both must coordinate through the same write queue. flowchart TD
A[Foreground transcript writes] --> C[Per-agent write queue]
B[Cleanup worker retirement] --> C
C --> D[Dispatch worker close]
D --> E[SQLite cleanup and native exit]
E --> F[Resume queued writes]
E --> G[Release exact worker lease]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +13, Tests +104. Total +117 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep worker shutdown inside the existing per-agent FIFO through native exit, preserving exact lease cleanup and transcript ordering. Do we have a high-confidence way to reproduce the issue? Yes, from source: switching databases can dispatch native cleanup outside foreground write admission on current main. The real-worker regression encodes that ordering failure; this review did not execute it. Is this the best way to solve the issue? Yes. Reusing the existing worker reservation fixes the lifecycle owner without introducing another queue, changing stored data, or weakening current-authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b076a15e5103. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* commit '201f11afefdb19a9c75e9d3542bf7425c80df7a7': (141 commits) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) refactor: share streaming media tail boundary update (#146989) refactor(tui): classify resume candidates once (#146983) improve: skip unused toast dismissal work (#147196) fix(linux): recover saved remote connections without replacing active sessions (#146047) fix: doctor stays silent when Windows state dir is under OneDrive (#123720) feat: announce successful Daybreak retries (#147146) feat(code-mode): reuse results across code cells (#147154) refactor(test): reuse CLI plugin fixture writer (#147186) test: skip unused compiler setup in routing fixtures (#147194) test: reuse LINE webhook runtime fixture (#146710) fix(code-mode): check automation and process result types (#147143) ...
* commit '2d87daf04b78992382299d552f15ac84a86a23ed': (1815 commits) fix(ui): distinguish tool activity with semantic icons (#147207) fix(linux): recover completed Quick Chat replies without resending (#146048) feat(desktop): unify Tauri title bar and window controls (#147097) refactor(test): share plugin fixture server shims (#147225) perf(gateway): defer worker workspace execution imports (#143496) fix(gateway): post-ack webhook work fails with "Async work scope is closed" (#144801) refactor(scripts): centralize upgrade survivor version floors (#146975) fix(ci): check publication registries before FRV fanout (#147184) fix(qa): align system-agent delegation with channel contracts (#145905) improve: reduce repeated chat message identity work (#147210) fix(channels): remove stale pre-tool previews from Slack and Telegram (#147106) fix: keep catalog discovery scoped and execution lazy (#147159) fix: serialize reclamation worker shutdown with foreground writes (#147178) test(sessions): cover abrupt committed transcript recovery (#143984) fix: stop transcript storms during context overflow recovery (#147202) fix: reduce CPU overhead for small history and usage reads (#147205) fix: resume tasks after tools finish and the model times out (#147203) refactor(scripts): share SQLite reliability message waits (#146900) feat(exec): configure approval reviewer thinking and fastMode (#147192) test: remove redundant Bonjour module headers (#146981) ...
Related: #130741
What Problem This Solves
Fixes foreground transcript writes racing a retained cleanup worker's shutdown when the worker retires or switches databases.
User Impact
Session writes wait for cleanup shutdown to finish before accessing the same database, preserving their existing FIFO order.
Why This Change Was Made
Native SQLite close can perform writes. Route the retained worker's close through the existing per-agent write queue, keep the worker alive while queued, and hold its reservation until actual worker exit. Exact lease cleanup still happens after exit.
Evidence
The real database-switch regression failed on the original code: close dispatched before the preceding foreground write released admission, and the following write ran before native exit. The fixed order is foreground release, close dispatch, worker exit, then the following write.
Six native retirement cases passed on the rebased commit covering database switching, path/root retirement, idle shutdown, crashes, and exact lease receipts. Before the patch-identical rebase, the complete 30-command changed-file check plan had passing evidence across its initial prefix, the corrected Node Worker transfer-list lint call, and the eight remaining guards. Independent review found no actionable P0–P2 findings. The rebase onto current main preserves the exact two-file patch and excludes the separate live-fixture changes.
One earlier broader local run passed 26 cases and failed one during shared-state database opening with
SQLITE_BUSYwhile selecting rollback journal mode. The blocking peer and journal-policy input were not captured; that failure remains unresolved and is not claimed repaired here. End-to-end Swarm performance verification continues separately.Exact-head CI passed after one targeted failed-job rerun. The initial attempt timed out while terminating a Logbook test fork after all assertions passed. A bounded Linux diagnostic then passed the full 27-file, 360-test shard and observed every test fork exit; it did not reproduce or explain the original timeout.