Repository navigation
fix(sessions): fence transcript writes by admitted run - #121003
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
1a1e781 to
9d5309d
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
65c8744 to
1a4af69
Compare
|
Codex review: found issues before merge. Reviewed August 9, 2026, 5:44 AM ET / 09:44 UTC. ClawSweeper reviewWhat this changesThis PR adds a durable admitted-run claim intended to prevent stale agent runs from writing to a session transcript and to record supersession visibly. Merge readiness⛔ Blocked by patch quality or review findings - 8 items remain Keep open: three P1 paths still allow a superseded run to bypass or prematurely disrupt the new transcript-writer ownership invariant. Priority: P1 Review scores
Verification
How this fits togetherSession-lane admission selects the run that may persist a session’s transcript. That private ownership fact must survive prompt setup, CLI and delivery write paths, and SQLite transactions so stale output is rejected and supersession is visible. flowchart LR
A[Run enters session lane] --> B[Durable writer claim]
B --> C[Prompt and dispatch state]
C --> D[Transcript write paths]
D --> E{Writer claim matches?}
E -->|yes| F[Persist transcript]
E -->|no| G[Reject stale write]
B --> H[Record and cancel prior run]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +390, Tests +463, Generated 0. Total +853 across 54 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep a private admitted-writer fence through prompt setup, dispatch, rebased targets, CLI recording, and transactional writes; commit the replacement claim before recording or cancelling the displaced run. Do we have a high-confidence way to reproduce the issue? Yes, from source: a normal embedded attempt loses its writer fence during prompt-state construction; separately, a CLI recorder and a failed concurrent-claim sequence provide focused regression paths. Is this the best way to solve the issue? No. A durable writer claim is the right owner boundary, but this branch does not carry it through all ordinary writers or commit it before cancelling the prior owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 135278c8968f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
0f261e6 to
e7b3a39
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Land-ready proof for
Known follow-ups remain the coordinator-tracked non-turn writers and deletion of the session-write lease. |
|
Merged via squash.
|
* fix(sessions): fence transcript writes by admitted run * fix(agents): break terminal outcome import cycle * test(sessions): cover writer fence propagation * fix(sessions): complete admitted writer fence
What Problem This Solves
Nothing durable recorded WHICH run owns a session's transcript writes. A wedged run that lost its lane slot could still write (its SessionManager snapshot intact), and its successor had no supersession path — the production incident showed successors failing on lease timeouts every 30 minutes with no recorded reason. Silent zombies are the worst bug class.
Why This Change Was Made
Durable
activeWriterRunIdclaim CAS'd at lane admission with the{sessionId, lifecycleRevision}pair; every run-owned transcript write validates the claim inside the SQLite transaction (async guarded turns, sync SessionManager writes, CLI writes, delivery mirrors); a superseding admission records a stickysupersededterminal outcome for the live prior run before exact-run cancellation — supersession is always visible, never silent. Stale claims from dead processes are CAS'd over without ceremony. Leases, stale-parent rebasing (claim holders keep rebasing),lifecycleRunId, placements, and heartbeat gating are intentionally unchanged. This is the designed replacement for the session-write lease, which a follow-up PR deletes.User Impact
A stuck run can no longer silently corrupt or contend its session; the successor supersedes it with a recorded outcome visible in tasks/TUI/session activity.
Evidence
Transcript suite 67 tests incl. in-transaction fence rejection; admission incident-order integration test; terminal outcome/merge 41; embedded terminal/lifecycle/registry 47; tasks 121; subagents 191; gateway wait reconstruction 8; plugin projection 26; full changed gate (typecheck/lint/surface/dead-code/storage/cycles); codex autoreview clean. Production +473/−104 — growth justified by the new ownership boundary (Repair Doctrine: recorded fact at the owning boundary).
Exact-head CI and ClawSweeper review surfaced related guard, propagation, ordering, and stale-expectation gaps. The completed follow-up extracts a leaf terminal-outcome type contract, regenerates the intentional Plugin SDK API manifest, keeps the admitted fence private across context-engine target adoption, restores it at attempt dispatch, fences CLI streamed/abort/final transcript recording, commits the replacement claim before recording and cancelling its incumbent, and adds exact failure-order assertions. Current totals: production +555/−128, tests +622/−28, generated baseline +77/−77. Focused repair proof: claim/order 2, prompt-state 13, CLI recorder 9, CLI dispatch 43; post-rebase proof: transcript 67, writer claim 1, terminal outcome 41, attempt lock/teardown 44, delivery mirror 336, attempt stream 10, SDK projection 1, Madge 0 cycles, exact API baseline, and fresh branch autoreview clean.
Named follow-ups (coordinator-tracked): fence the remaining non-turn writers (session-manager-branching, sqlite-checkpoint, sqlite-message-cut, worker transcript-commit session-row write); delete the session-write lease.