Repository navigation
fix(codex): prepare mirror write authority before reserving the transcript writer - #169343
Conversation
…cript writer The steering prefix mirror passed its composed write assertion as each append's preparation source. The locked append prepares that source while the worker transcript lock holds the agent database, and the native session binding authority's preparation reads the session row through a worker. That read can never be admitted, so the steer never persisted, the queue never accepted it, and the shared write queue never drained. run-attempt.steering-settlement hangs on Linux CI every time; macOS escaped only because its symlinked temp root resolved to a different store path. Pass the assertion to withCodexSessionTranscriptMirrorWrite instead, which installs it as the write's owner assertion so it is prepared before the writer is reserved and still checked at every commit.
|
🦞👀 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. What this changesThis PR prepares Codex transcript mirror authority before reserving the database writer. Example: On Linux, send “Use this committed follow-up.” after an active Codex turn produces “Earlier completed answer.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main retains the source-supported Codex steering deadlock, and this focused maintainer-authored repair preserves commit-time validation without an identified correctness defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Codex plugin sends native conversation messages and session assertions through the Plugin SDK to the canonical transcript writer, which returns committed message receipts before steering submission. flowchart TD
A[Codex steering request] --> B[Mirror completed prefix]
B --> C[Prepare session authority]
C --> D[Reserve transcript writer]
D --> E[Validate sources in transaction]
E --> F[Persist transcript and return receipts]
F --> G[Submit native steer]
Technical reviewBest possible solution: Prepare mirror authority through the existing transcript assertion owner before writer reservation while retaining transaction-time source validation. Do we have a high-confidence way to reproduce the issue? Source inspection establishes a worker read awaited under the same database's writer reservation, matching the reported Linux baseline failures; no target code was executed during this review. Is this the best way to solve the issue? The patch repairs ordering at the existing owner, removes redundant preparation, and preserves both live assertions and transaction-local predicates. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3be41182be9b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +10. Total +10 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 11, 2026, 6:33 PM ET / 22:33 UTC (Revision 2). |
|
Merged via squash.
|
…cript writer (openclaw#169343) * fix(codex): prepare mirror write authority before reserving the transcript writer The steering prefix mirror passed its composed write assertion as each append's preparation source. The locked append prepares that source while the worker transcript lock holds the agent database, and the native session binding authority's preparation reads the session row through a worker. That read can never be admitted, so the steer never persisted, the queue never accepted it, and the shared write queue never drained. run-attempt.steering-settlement hangs on Linux CI every time; macOS escaped only because its symlinked temp root resolved to a different store path. Pass the assertion to withCodexSessionTranscriptMirrorWrite instead, which installs it as the write's owner assertion so it is prepared before the writer is reserved and still checked at every commit. * fix(plugin-sdk): merge duplicate transcript write context import
What Problem This Solves
extensions/codex/src/app-server/run-attempt.steering-settlement.test.ts("keeps one steering prefix and source through degraded tainted native completion") hangs on Linux CI every run. It blockschecks-node-changed-extensions-bundle-3for every PR whose change selection includes the codex harness (for example #168401 and #169026).The hang is a real deadlock in the product path. When a native Codex turn receives a steer,
beforeSubmitfirst mirrors the completed steering prefix into the transcript. That mirror append never returns. So:onQueueAcceptednever fires;afterEachdrain also times out after 180s.Why This Change Was Made
Root cause, traced with instrumentation on a Linux Blacksmith Testbox:
transcript-mirror-write.tspassed its composed write assertion as each append'spreparation.source. The assertion composesconnection.assertLegacyCurrentwithcreateNativeSessionBindingAuthority(...).assertLegacyCurrent.session-transcript-locked-write.ts) prepares that per-append source withprepareSessionSourceAuthority(...). It does this while the worker transcript write lock holds the agent database.prepareSessionSource→prepareMutation→withSessionEntryReadOnlyInWorkerreads the session row through a worker on the same database. That read cannot be admitted while the write holds the store, so it never resolves.core-append-start prepare=true source=true→core-expected …→binding-prepare-read-start, with nobinding-prepare-read-done.macOS escapes this only because the test's symlinked
os.tmpdir()(/var→/private/var) makes the read resolve to a different store identity.Fix: give the assertion to
withCodexSessionTranscriptMirrorWriteas a write-levelassertCurrent. The seam installs it throughwithSessionTranscriptWriteAssertion, so the locked write captures it as its owner assertion:owned = prepareSessionSourceAuthority(assertOwned)runs beforerunSessionEntryWorkerOperation);assertCurrentand the worker-sidesourcespredicates.The per-append
preparationexisted only to carry that source (itsprepareMessagewas the identity function), so it is removed.The new parameter is additive and optional on the codex-only SDK seam. No other caller changes.
Production LOC: +21/-13.
User Impact
Steering a running native Codex turn ("Use this follow-up" while Codex is mid-answer) no longer wedges the session on Linux hosts:
Evidence
CI=1 pnpm test extensions/codex/src/app-server/run-attempt.steering-settlement.test.ts:mainat 5f93ba3, 8e17f90 and d4e9d09: 1 failed / 1 passed, every run (acceptednever called, then the 180s hook timeout);transcript-mirror.test,transcript-mirror.user-idempotency,transcript-mirror.visibility,run-attempt.steering,run-attempt.steering-authority,run-attempt.steering-mediaandrun-attempt.steering-settlementall pass.transcript-mirror.admission.test.tshas 2 failures ("preserves host prompt ownership …") that reproduce identically on unmodifiedmain. They are unrelated to this change.node scripts/check-changed.mjs -- <touched files>passes, including tsgo for core, plugin-sdk, extensions and extension tests. The only failure is the dead-export scan, which flags ui Solid-migration exports from refactor(ui): migrate chat transcript rows to Solid 2 #168887 that are also flagged onmain.