Repository navigation
fix(agents): settle owned orphan transcript repair - #133243
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 30, 2026, 6:42 AM ET / 10:42 UTC. ClawSweeper reviewWhat this changesThe branch makes orphaned transcript-cursor repairs durable through the owning writer and waits for their projection before an embedded agent attempt continues. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep this maintainer-authored PR open: the owner-bound transcript repair remains needed on current main, but the still-present direct Priority: P2 Review scores
Verification
How this fits togetherEmbedded agent attempts prepare model-session state from persisted transcript events. When an orphaned user turn is removed, the repaired cursor and its projection must settle before another transcript append reads that state. flowchart LR
A[Persisted transcript] --> B[Embedded attempt setup]
B --> C[Writer-owned cursor repair]
C --> D[Projection reconcile]
D --> E[Prepared model session]
E --> F[Later transcript append]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +23, Tests +109, Docs +1. Total +133 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Remove the direct changelog entry, retain the PR-body release context, and keep the durable cursor update plus projection wait within the existing transcript-writer lifecycle. Do we have a high-confidence way to reproduce the issue? Yes, source provides a high-confidence path: current main removes the in-memory orphan but does not persist a cursor-only repair or await the dirty projection; the added real-SQLite boundary tests exercise that sequence. Is this the best way to solve the issue? Yes for the runtime repair: it uses the existing leaf-control persistence mechanism and owning writer lifecycle rather than weakening bounded reads or retrying downstream. The changelog edit is not part of the best solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ba1be2f427ae. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (1 earlier review cycle)
|
* fix(agents): settle owned orphan transcript repair * test(agents): use canonical transcript writer context * test(agents): complete in-memory session manager fixture
Problem and repair
Full release QA parity failed while an embedded attempt repaired an orphaned user turn. The repair rewound its in-memory cursor and replayed trailing metadata, leaving the persisted active projection dirty. A subsequent append adopted the canonical storage parent and synchronously reopened the bounded transcript before that projection was ready, throwing
SessionTranscriptProjectionUnavailableError. Without trailing metadata, the cursor change was never persisted at all.The embedded attempt boundary now uses the existing fenced leaf-control append to record its repaired cursor, replays metadata, and joins the projection work already scheduled for that target. Its already-asynchronous caller runs this preparation inside the existing owned transcript-write lifecycle and passes the run's abort signal. Cancellation is checked before repair and after the wait. The next append sees the canonical repaired path; the historical orphan remains in the append-only record.
This changes the mutation owner rather than retrying fresh reads. Generic synchronous SessionManager APIs and fail-fast bounded reads remain unchanged. There are no new SQL statements, schemas, migrations, indexes, configuration settings, transaction boundaries, retention policies, or recovery mechanisms. The existing leaf-control contract is also used when withdrawing rejected assistant drafts.
Production is net +20 lines across two modules. That growth records the previously missing durable cursor update and joins its asynchronous projection under the existing lifecycle; the competing unowned synchronous preparation call is removed. Tests and test-support changes are net +112 lines, separately from one changelog line.
Verification
Four real-SQLite branch/reset cases, each with and without trailing metadata, failed before the fix. They now verify that a fresh bounded reader excludes the orphan while raw history retains it, and that a real out-of-band append is adopted with the correct transcript anchor.
Cancellation coverage holds an actual reconcile worker at its existing acknowledgement boundary, aborts the wait, and verifies that repaired prompt state is not published. Pre-abort and stale-writer cases reject without changing durable rows. Existing raw-probe, settled-finalization, current-user preservation, branch/idempotency, fresh dirty-read, and reconciliation-lifecycle checks are included in the focused proof.
All 74 tests passed across nine files (83.33 seconds wrapper time). Managed Codex review passed through P2 with no actionable findings. The first full changed-file gate caught a test-fixture type mismatch: the writer fence belongs in the owned context, not the runtime target. The test now uses that canonical context; all 23 owner tests and the affected test typecheck pass. The final complete changed-file gate passed, including core and all core-test typechecks, lint, schema and ownership guards, and import-cycle checks. This follow-up changes only the test file; production is byte-identical to the fresh hosted QA parity target. Exact PR CI and hosted results are recorded below. This PR does not claim that the failed full release run is green; a fresh complete verification is still required after the repairs land.
Hosted proof and review disposition
Focused release checks 33305374796 passed on the unchanged production fix at
9a0793a25a435890800895847773226ff7f95781, using frozen trusted tooling3ed6805a6f32ad8cdfd3c30dd94d7ae4d75bd667. Baseline and candidate each passed 12/12 without retries, including the formerly failing capability-change scenario. Runtime core passed 25/25, soak 2/2, and explicit restart 1/1. Both artifact digests were verified. The existing nested Codex compaction harness-gap skip remains; this focused run is not the subsequent full/all verification.The latest ClawSweeper review judged the runtime repair canonical and its +20 production lines justified. Its only finding and Rank-up move requests changelog removal. That request is explicitly declined: this maintainer-directed release-validation task carries a standing instruction to include changelog entries for user-visible fixes. No additional runtime change is needed for that policy preference.
The corrected-head PR CI exposed seven older context-engine fixtures whose shared test double omitted the existing SessionManager method now used by the repair. A three-line fixture correction declares, initializes, and resets
getSessionTargetto returnundefined, matching the real in-memory manager. All 94 tests across the ten shared-harness files pass, including all seven original failures with unchanged assertions; affected test types and formatting pass. Managed Codex review is clean through P2. Production remains byte-identical to the hosted proof target. Exact-head CI 33306869917 passed for586f3464b7d66ee0e79f4c286e2a2a86ed19ff6f; all 185 jobs are terminal with no failed jobs.