Skip to content

fix(codex): prepare mirror write authority before reserving the transcript writer - #169343

Merged
RomneyDa merged 2 commits into
mainfrom
fix/codex-mirror-source-before-lock
Oct 11, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
fix/codex-mirror-source-before-lock

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

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 blocks checks-node-changed-extensions-bundle-3 for 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, beforeSubmit first mirrors the completed steering prefix into the transcript. That mirror append never returns. So:

  • the steer is never persisted or sent;
  • onQueueAccepted never fires;
  • the shared agent write queue never drains, which is why the afterEach drain also times out after 180s.

Why This Change Was Made

Root cause, traced with instrumentation on a Linux Blacksmith Testbox:

  1. transcript-mirror-write.ts passed its composed write assertion as each append's preparation.source. The assertion composes connection.assertLegacyCurrent with createNativeSessionBindingAuthority(...).assertLegacyCurrent.
  2. The worker-locked append (session-transcript-locked-write.ts) prepares that per-append source with prepareSessionSourceAuthority(...). It does this while the worker transcript write lock holds the agent database.
  3. The native binding authority's prepareSessionSource → prepareMutation → withSessionEntryReadOnlyInWorker reads 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.
  4. Instrumented trace of the last progress before the hang: core-append-start prepare=true source=true → core-expected … → binding-prepare-read-start, with no binding-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 withCodexSessionTranscriptMirrorWrite as a write-level assertCurrent. The seam installs it through withSessionTranscriptWriteAssertion, so the locked write captures it as its owner assertion:

  • it is prepared before the writer is reserved (owned = prepareSessionSourceAuthority(assertOwned) runs before runSessionEntryWorkerOperation);
  • it is still checked at every commit, through assertCurrent and the worker-side sources predicates.

The per-append preparation existed only to carry that source (its prepareMessage was 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:

  • the steer is committed and sent;
  • the queued-acceptance callback fires;
  • later writes to that agent's database are no longer stuck behind the hung append.

Evidence

  • Linux Blacksmith Testbox, CI=1 pnpm test extensions/codex/src/app-server/run-attempt.steering-settlement.test.ts:
    • main at 5f93ba3, 8e17f90 and d4e9d09: 1 failed / 1 passed, every run (accepted never called, then the 180s hook timeout);
    • this branch: 2/2 passed.
  • The same test passes locally on macOS both before and after the change, for the symlinked-tmpdir reason above.
  • Local runs on this branch:
    • transcript-mirror.test, transcript-mirror.user-idempotency, transcript-mirror.visibility, run-attempt.steering, run-attempt.steering-authority, run-attempt.steering-media and run-attempt.steering-settlement all pass.
    • transcript-mirror.admission.test.ts has 2 failures ("preserves host prompt ownership …") that reproduce identically on unmodified main. 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 on main.

…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.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa marked this pull request as ready for review October 11, 2026 20:36
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.”

  • Before: Mirroring the completed answer waits on a worker read blocked by its own writer reservation, preventing steering acceptance.
  • After: Authority preparation completes before reservation, allowing the answer and follow-up to persist and steering to proceed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with reported production-path regression coverage and no identified introduced defect; supplied media does not establish shipped-entry-point behavior.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; reported Linux harness results exercise the changed persistence path, while both inspected screenshots show general chat activity without demonstrating steering recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Steering an active native Codex session on Linux can hang before accepting the follow-up and block later transcript writes.
Reason: The maintainer-authored repair addresses a concrete failure with a narrow ordering change and no new configuration or stored format.

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
Reviewed head: 2ef62fef7caa16670746cbedb3e1b9858489d6b4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied artifact demonstrates Linux steering recovery through a shipped Gateway; the reported baseline/head regression uses the existing production-path harness.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Prepared mirror writes changes intended behavior with a stated reason (65365c8: Provide asynchronous preparation outside transactions while checking exact source predicates and live authority at commit.)
  • Composed authority and writer settlement keeps the original intent (a51a76b: Preserve prepared authority and settle accepted transcript operations before releasing their writer.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 65365c8 adds src/plugin-sdk/codex-session-transcript-runtime.ts:206 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 65365c80628d; files: src/plugin-sdk/codex-session-transcript-runtime.ts)

PR surface

Source +10. Total +10 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 24 14 +10
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 24 14 +10

Review metrics

Metric Value Why it matters
SDK parameter 1 additive optional assertCurrent parameter Existing callers retain their invocation shape; the bundled mirror supplies its existing composed authority.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported and source-supported deadlock blocks Linux Codex steering acceptance and subsequent writes sharing the agent database.
  • merge-risk: 🚨 compatibility: The Plugin SDK parameter contract changes; the maintainer-authored direction explicitly accepts an additive optional parameter while preserving existing calls.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T20:48:40.163Z sha ddca5c6 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 6:33 PM ET / 22:33 UTC (Revision 2).

@RomneyDa
RomneyDa merged commit 43584d9 into main Oct 11, 2026
108 checks passed
@RomneyDa
RomneyDa deleted the fix/codex-mirror-source-before-lock branch October 11, 2026 23:25
@RomneyDa

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant