Repository navigation
fix(sessions): restore history while transcripts keep growing (#115908) - #116259
CanadaOrNaw wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 5, 2026, 10:04 PM ET / August 6, 2026, 02:04 UTC. ClawSweeper reviewWhat this changesThis PR lets session transcript projection reconciliation absorb a bounded append-only tail so history can recover while transcript writes continue. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof is added - 3 items remain Keep open: this draft is the active candidate fix for the linked sustained-write session-history defect, but it still lacks inspectable exact-head real-behavior proof required before merge. Priority: P1 Review scores
Verification
How this fits togetherTranscript writes dirty a SQLite-backed session projection, while reconciliation rebuilds and publishes that projection for history and transcript-search readers. The PR changes the concurrent-write window between projection preparation and final publication. flowchart LR
A[Transcript writes] --> B[Dirty projection state]
B --> C[Reconciliation owner]
C --> D[Prepared projection]
D --> E[Bounded append validation]
E --> F[Published projection]
F --> G[History and search readers]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +220, Tests +438. Total +658 across 7 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: Provide a redacted exact-head packaged-Gateway trace that correlates reconciliation/finalize outcomes with history recovery and loopback responsiveness, then re-review the owner-level regression and bounded transaction behavior. Do we have a high-confidence way to reproduce the issue? No: the PR describes a controlled sustained-write reproduction, but no inspectable exact-head runtime artifact establishes it independently. Is this the best way to solve the issue? Unclear: bounded catch-up at the projection owner is plausible, but the required exact-head causal runtime proof is missing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f5125a7e56f0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
|
Maintainer routing note: the existing review already covers the missed follow-up pass. Three requirements still need an explicit record before this draft can advance:
No branch update or contributor-code execution is requested here. |
962c7c4 to
97be09b
Compare
Related: #115908
AI-assisted: this revision was developed and reviewed with Codex plus an independent isolated second-model review. The final source, tests, and synthetic evidence were verified manually before publication.
What Problem This Solves
Fixes an issue where session history for a hot, growing transcript can remain unavailable while projection reconciliation repeatedly loses an exact-snapshot claim race. On current
main, the Gateway can remain healthy while the affected session's history returns retryable 503 responses until writes stop.Why This Change Was Made
Current
mainalready prepares full projections in a Worker and commits them through bounded, yielding writer chunks. This revision therefore targets the remaining claim-time convergence failure rather than the original report's obsolete no-Worker/no-yield premise.A prepared projection may now claim same-generation append-only growth only when the entire post-snapshot tail is contiguous and bounded to 512 rows and 256 KiB of serialized
event_json. Finalize rereads the authoritative snapshot, rechecks the same bounds, and applies the existing live append inference before publication. Resets, generation changes, branches, side appends, leaf controls, parent mismatches, canonical/legacy ambiguity, and oversized tails remain dirty for the normal full-reconcile path.History and transcript-search readers also avoid re-latching an owner that is already running; writer-owned dirty transitions still retain the existing pending-pass signal.
User Impact
Ordinary bounded appends that race Worker preparation can converge while the session is still receiving writes, instead of requiring a quiet period before history becomes available again. Unsafe or oversized tails keep the existing conservative retry behavior rather than publishing stale state.
This change does not claim to fix every historical multi-minute Gateway stall reported in #115908. The controlled reproduction proves a current-main session-history convergence defect and a bounded synthetic improvement; it did not reproduce an event-loop freeze.
Evidence
Reviewed source:
d0b362f2558e91e450124c8212c253a5bad316a8d03a43a820d0b7810435d3aa57906da7b54707a81767639226bb3177f9f2c771d39de16fef2563aa(all touched source blobs were unchanged from the tested review base)97be09b5a84858b0476a78a67ae01ac368f7611dda990103a63f7ad6a9b78aba473b4b5a8daf62cbbb458838bb4d0e3c855a8e23Focused validation:
startSessionTranscriptIndexReconcile, injects an append after Worker preparation and before claim, and converges with exactly one Worker process;pnpm tsgo:corepassed;pnpm tsgo:test:srcpassed;pnpm buildpassed;oxfmt,oxlint, Kysely guardrails, andgit diff --checkpassed;autoreview --mode uncommitted --max-priority P1completed clean with no accepted/actionable findings.Separate-process packaged-Gateway comparison under identical bounded-tail load (2,000 seeded 8 KiB events, then one 512-byte append every 20 ms for five seconds):
/healthzThe controller, Gateway, writer, and read-only projection probe ran as separate processes against isolated synthetic state.
An oversized high-throughput run exercised the fallback path. The reviewed candidate remained conservative and baseline-like (37/112 history 503 samples versus 36/112 on the supplied baseline), recovered only after writes stopped, and kept
/healthzresponsive for 280/280 probes.Known limits: