Repository navigation
fix(sessions): keep gateway responsive while large transcript archives are built - #112424
Conversation
8d8382c to
2a84e32
Compare
2a84e32 to
caf995a
Compare
caf995a to
822b649
Compare
f6e8f7c to
74566a7
Compare
|
Codex review: needs changes before merge. Reviewed August 4, 2026, 5:18 PM ET / 21:18 UTC. ClawSweeper reviewWhat this changesMoves SQLite lifecycle transcript archive materialization into a queued Worker, adds snapshot fencing, and extends packaging and Gateway responsiveness coverage. Merge readiness⛔ Blocked by patch quality or review findings - 6 items remain Keep this PR open: its direct session-delete path now releases the writer lane, but automatic cleanup, projection, purge, eviction, and historical deletion still await archive Worker work while holding it, so same-store writes can remain blocked. Priority: P1 Review scores
Verification
How this fits togetherGateway session lifecycle operations must durably archive a SQLite transcript before deleting its state. They receive cleanup, deletion, projection, and eviction requests and then update session rows and archive files. flowchart LR
A[Gateway lifecycle request] --> B[Session cleanup planner]
B --> C[Per-store writer lane]
C --> D[Archive worker queue]
D --> E[Durable transcript archive]
E --> F[Final state validation]
F --> G[Session row deletion]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +422, Tests +1268, Config 0, Other +5. Total +1695 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make every archive-capable lifecycle owner use one three-phase flow: plan under the writer lane, archive after release, then reacquire and revalidate before deletion. Do we have a high-confidence way to reproduce the issue? Yes—source establishes that the queue awaits its callback and several archive owners await Worker materialization inside it; the provided built-Gateway proof independently demonstrates the direct-delete version of this contention. Is this the best way to solve the issue? No—the Worker is the right execution boundary, but applying the three-phase flow only to direct deletion and entry patches leaves equivalent lifecycle owners with the original same-store blocking behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8fc44585931d. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
c3f71c1 to
df980e9
Compare
|
@clawsweeper re-review Small CI/landing note for exact head
No urgency—thank you for taking a look when bandwidth allows. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
fa813e7 to
144f917
Compare
144f917 to
3018a1d
Compare
|
Merged via squash.
|
Punchcard-Session: crisp-lantern-orchard-nv * origin/main: perf(memory): defer session backfill runtime (#119372) fix(ci): isolate built TUI PTY fixture (#119339) fix(commands): restore tool inventory for dynamic models (#119306) fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257) docs: add ChromeOS (Crostini) platform install guide (#107663) test(msteams): serve JWKS from in-process server in auth coverage (#119354) fix(qa): enable OpenAI for stored audio scenario (#119349) test(agents): realpath apply-patch temp dir fixture (#119353) test(slack): drop redundant .js-suffixed system-event mock (#119352) fix(exec): leave safe builtins unrewritten in enforced mode (#119351) fix(sessions): keep gateway responsive while large transcript archives are built (#112424) fix(tui): restore provider auth in installed local mode (#119283)
…time * origin/main: (75 commits) fix(commands): restore tool inventory for dynamic models (#119306) fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257) docs: add ChromeOS (Crostini) platform install guide (#107663) test(msteams): serve JWKS from in-process server in auth coverage (#119354) fix(qa): enable OpenAI for stored audio scenario (#119349) test(agents): realpath apply-patch temp dir fixture (#119353) test(slack): drop redundant .js-suffixed system-event mock (#119352) fix(exec): leave safe builtins unrewritten in enforced mode (#119351) fix(sessions): keep gateway responsive while large transcript archives are built (#112424) fix(tui): restore provider auth in installed local mode (#119283) fix(release): accept legacy empty core artifacts (#119337) fix(qa): carry selected runtime into flow scenarios (#119324) fix(ci): retry interrupted Windows dashboard release checks (#119095) fix(release): filter validation ancestry fetch (#119334) fix(release): accept trusted extended-stable validation evidence (#119264) fix(sessions): preserve recorder-owned user turns (#119307) perf(cli): split plugin registry startup timing (#119318) fix(qa): align release scenario setup and compaction proof (#119188) fix(ci): avoid duplicate Matrix release QA runs (#119171) perf(agents): reuse provider policy manifest registry (#119305) ...
…s are built (openclaw#112424) * fix(sessions): keep gateway responsive during transcript archiving * test(sessions): strengthen archive worker coverage * fix(sessions): bound archive worker concurrency * test(sessions): normalize rollback paths on Windows * fix(sessions): load source archive worker on node 22 * fix(sessions): align archive fencing with session windows * test(sessions): adapt cleanup race to archive worker * fix(sessions): harden archive worker lifecycle * style(sessions): format archive lifecycle tests * fix(sessions): release writer lane during archive work --------- Co-authored-by: Josh Lehman <[email protected]>
…ion generations (#128980) * fix(sessions): keep gateway responsive while large transcript archives are built (#112424) * fix(sessions): keep gateway responsive during transcript archiving * test(sessions): strengthen archive worker coverage * fix(sessions): bound archive worker concurrency * test(sessions): normalize rollback paths on Windows * fix(sessions): load source archive worker on node 22 * fix(sessions): align archive fencing with session windows * test(sessions): adapt cleanup race to archive worker * fix(sessions): harden archive worker lifecycle * style(sessions): format archive lifecycle tests * fix(sessions): release writer lane during archive work --------- Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9bfe292) * fix(sessions): release writer lane during transcript archival (#119460) (cherry picked from commit 141a16f) * fix(gateway): fence background titles during session archival Backport the session-title admission fix from upstream commit 530b33e (#123608) without its unrelated gateway changes. Keep asynchronous disk-budget scans out of the transcript stat regression fixture. * test(ui): settle custodian mobile layout assertions (#116613) (cherry picked from commit 871abad) --------- Co-authored-by: Heming Zeng <[email protected]> Co-authored-by: Josh Lehman <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
Related: #112423
AI-assisted: Codex was used for implementation, testing, and review. The design boundaries and validation evidence are documented below for review.
What Problem This Solves
Fixes an issue where users cleaning up, resetting, deleting, or evicting a SQLite-backed session with a large transcript could temporarily stall the Gateway event loop while the transcript archive was built and published.
Why This Change Was Made
This is the first bounded phase of #112423. It moves lifecycle transcript-archive materialization to a dedicated Worker while preserving the existing archive format and the parent process's authoritative archive-before-delete fence.
Design Boundaries
The Worker opens the exact physical agent database read-only, validates the planned snapshot inside one consistent SQLite read transaction, reads transcript events in sequence order, and uses the existing compression and durable publication path. Lifecycle mutation now has three phases: plan while holding the per-store writer lane, materialize and publish after releasing that lane, then reacquire the lane for final validation and deletion. The final write transaction rereads authoritative references and snapshot state before deleting lifecycle rows. No transcript or lifecycle rows covered by the plan are reclaimed without a verified archive; existing best-effort and captured-cleanup caller behavior is unchanged.
A process-local keyed FIFO permits one lifecycle archive Worker at a time. This avoids multiplying whole-buffer pressure across multiple Worker heaps while allowing unrelated Gateway work to continue. Failed jobs release the queue for later work. This queue covers lifecycle archive materialization through this path; existing manual compaction paths are unchanged.
Automatic lifecycle maintenance for an in-process incognito database now skips transcript archive creation at the canonical planner. Maintenance can still prune the in-memory rows, but it neither sends an unreachable in-memory database to a Worker nor publishes private transcript content to disk.
For source-tree tests and development on supported Node 22 versions, the TypeScript Worker registers the supported tsx ESM API so source
.jsspecifiers resolve to.ts. The built JavaScript Worker does not use this preload and has no runtime dependency on tsx.User Impact
Large lifecycle archives no longer monopolize the Gateway event loop or hold the per-store writer lane while their transcript is read, serialized, compressed, and durably published. Same-store writes can complete while archive materialization is pending. For durable sessions, existing archive naming, compression compatibility, retention behavior, schema, configuration, shared-database ownership, and final deletion semantics remain unchanged.
This phase deliberately does not stream one archive generation or make final SQLite/FTS row reclamation asynchronous. One generation is still whole-buffered inside the Worker, queued lifecycle archives wait their turn, and final reclamation can still cause a shorter tail stall. Streaming extraction and chunked reclamation remain separate follow-up work under #112423.
Evidence
3018a1de2c3f5793a76eaeded9570b25dc0d4d07, based on532580fa2b1b13f2ff270cccbb170e543fa49237. GitHub reports the PR mergeable, and fresh exact-head CI is running.main, wherepathis undefined atsrc/plugins/install-persistence.ts:543; this PR does not change the failing source or tests.git diff --check, all 11 cleanup-race tests, and both built CLI E2E tests. Blacksmith Testbox run 30947263450 also passed the production build and all 80 TUI PTY tests on the rebased head; the built CLI run completed in 92.76 seconds and the TUI suite in 727.50 seconds.sessions.patchcompletes in under 500 ms whilesessions.deleteremains pending on archive materialization. It then verifies archive integrity and successful deletion. This covers the writer-lane progress gap identified by ClawSweeper.package.jsononly adds the Worker test to the existing Windows CI command.