Skip to content

fix(plugin-sdk): install the mirror write assertion on the resolved transcript target - #169498

Open
RomneyDa wants to merge 8 commits into
mainfrom
fix/codex-mirror-assertion-resolved-target
Open

RomneyDa wants to merge 8 commits into
mainfrom
fix/codex-mirror-assertion-resolved-target

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Repair sweep — 2026-11-25

Rebased the repair onto main ba6d94ec17712. The mirror assertion is installed after agent inference, before reserving a transcript writer. The original admitted locator and callback are captured synchronously, and the existing transcript owner verifies the resolved target against the original session key, ID, store and storage environment; inferring an omitted agent must not authorize another transcript.

Current proof:

  • Nine SDK owner tests pass against real isolated SQLite: the allowed omitted-agent write persists, captured caller options remain stable, conflicting session/store targets are refused before entering the writer, and revoked or foreign ownership leaves no assistant row. Each newly found key/store/captured-options regression was reproduced before fixing it, including relative-path capture across a working-directory change and non-concrete (multiple) selectors.
  • Ten actual native Codex settled-turn finalizer cases pass through the compiled worker boundary and persist authorized final answers; the original finalizer failure was reproduced on main.
  • Touched files pass qualified type-aware lint, formatting and diff checks. Fresh whole-range local ClawSweeper review at d1b45f26bf84e has no findings.
  • Personally inspected sibling Codex 092d3acd6bec3e3a14bdc7e7a2810ab628ab759d, including codex-rs/app-server-protocol/src/protocol/v2/thread.rs:530-610; no Codex dependency or protocol change.

The SDK negative owner cases and native finalizer success cases are distinct proof; this does not claim a current live-provider/channel run. CI on the pushed head remains the broad gate.


Original proposal and historical evidence

What Problem This Solves

#169343 (43584d9) introduced a regression: extensions/codex/src/app-server/settled-turn-finalizer.native.test.ts fails 4/9 on main ("persists a host-authorized summary with the actual native selection …"). The settled-turn summary mirror is refused with SessionTranscriptWriterClaimReboundError, so stock Codex settled-turn summaries are not persisted.

Why This Change Was Made

#169343 moved the codex mirror's composed write assertion from per-append preparation to a write-level owner assertion, which fixed the Linux steering-settlement deadlock. However, it installed that assertion through withSessionTranscriptWriteAssertion on the caller's unresolved transcript target. The locked write then compares the installed context against the resolved owner scope (storageTarget from resolveSessionTranscriptRuntimeTarget). When the two differ, assertTranscriptWriteContext refuses the commit as a rebound writer claim; here the fields that can differ are agentId, sessionId and the store binding.

Fix: install the assertion inside withProjectedSessionTranscriptWriteLock, after it resolves the storage target, on exactly the boundScope it locks. The ordering property from #169343 is preserved: the assertion is still prepared before the writer is reserved. withCodexSessionTranscriptMirrorWrite goes back to a plain pass-through, and assertCurrent is now an optional field of InternalSessionTranscriptWriteLockParams.

Production LOC: +20/-19.

User Impact

Stock Codex settled-turn summaries persist again on current main. The Linux steering deadlock fix from #169343 remains in place.

Evidence

  • settled-turn-finalizer.native.test.ts:
  • pnpm test on this branch passes for settled-turn-finalizer.native, run-attempt.steering-settlement, transcript-mirror, transcript-mirror.user-idempotency, transcript-mirror.visibility and run-attempt.steering.
  • pnpm tsgo:core is clean.
  • Linux proof on decfedd (CI run 38190752080, job checks-node-changed-extensions-bundle-2, Ubuntu runner, real SQLite extension-database-workers project): settled-turn-finalizer.native.test.ts 9/9 and run-attempt.steering-settlement.test.ts pass, so the fix(codex): prepare mirror write authority before reserving the transcript writer #169343 deadlock fix still holds on Linux. A Blacksmith Testbox rerun (tbx_01m4ptfke8wabpy1sd4a7c66c6) never got capacity and timed out after 15m in queued, so CI is the Linux proof.
  • Authority boundary at final persistence: new src/plugin-sdk/codex-session-transcript-runtime.write-assertion.test.ts runs against a real SQLite session store. It uses a locator without agentId, which is the finalizer shape.
    • Resolved target persists: the row commits.
    • Mid-await revocation: assertCurrent starts throwing after an awaited readMessageFacts. The append rejects with the revocation error and no row persists.
    • Foreign ambient owner: the write runs inside an owned write context for a different session. It rejects with SessionTranscriptWriterClaimReboundError and no row persists.
    • Against the pre-fix code, the first two cases fail with SessionTranscriptWriterClaimReboundError (the regression) and the foreign-owner case still passes. Binding to the resolved target therefore keeps the foreign-owner refusal and the commit-time revocation check.
  • checks-node-changed failure (test/embedded-transcript-cursor.e2e.test.ts › "resumes a public raw cursor across /new and the next Gateway turn", generation_mismatch) is inherited. It fails the same way locally on the untouched merge base f92690e1 without this change. This PR does not touch cursor or /new code.

Current State (2026-10-12)

Latest CI repair

CI follow-up: corrected the mutable assertion fixture’s inferred never return to its intended void contract. All 9 mirror assertion cases, the exact Plugin SDK test type graph, formatting, and type-aware lint pass. New-head CI pending.

@clawsweeper

clawsweeper Bot commented Oct 12, 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 12, 2026 01:08
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR binds the Codex mirror write assertion to the resolved transcript target before acquiring its writer.

Example: Persist assistant text "settled" for session-1 using session key agent:main:session-1 without an explicit agentId.

  • Before: The assertion captures the unresolved target and persistence rejects with SessionTranscriptWriterClaimReboundError.
  • After: The assertion captures the resolved main-agent target and the message persists.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and correct on inspection, with meaningful SQLite authority coverage; supplied execution evidence is primarily harness-based.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): For this maintainer-authored authority repair, the reported real-SQLite production-boundary execution covers allowed persistence, revocation after awaited work, and foreign-session rejection with no persisted row; inspected source confirms those assertions reach the actual writer and storage reader.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Codex settled-turn summaries are refused instead of being saved to conversation history.
Reason: A focused, maintainer-authored repair restores intended persistence without reversing the earlier Linux deadlock fix.

Regression provenance

Regression provenance — suspected predecessor, not a causality claim: source commit 65365c80628d by Peter Steinberger; no PR verified.

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current-main transcript persistence regression, preserves the earlier deadlock fix, and introduces no actionable defect found in this review.

Priority: P1
Reviewed head: 65e1341735a5830b429d9afe9a4af50eee9afa23

Before merge

None.

Findings

None.

Agent review details

How this fits together

Codex mirroring passes messages and live authority into the Plugin SDK transcript adapter, which resolves storage ownership and delegates guarded persistence to the existing transcript writer.

flowchart TD
  A[Codex transcript mirror] --> B[SDK mirror adapter]
  B --> C[Resolve transcript target]
  C --> D[Bind live write assertion]
  D --> E[Existing transcript writer]
  E --> F[Guarded SQLite commit]
Loading

Technical review

Best possible solution:

Land the resolved-target binding repair while retaining pre-reservation preparation and final-commit authority checks.

Do we have a high-confidence way to reproduce the issue?

Source establishes the mismatch: the caller omits agentId, resolution supplies main, and the existing ownership check compares those fields exactly; the maintainer also reports failing base and passing patched persistence cases.

Is this the best way to solve the issue?

The repair belongs at the existing target-resolution owner, removes the earlier wrapper, and preserves source preparation before writer reservation without changing storage formats or adding configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 943da4fc9366.

Provenance checked

  • Mirror write-level authority keeps the original intent (43584d9: Prepare storage-dependent authority before writer reservation to avoid deadlocking steering persistence.)
  • Resolved storage ownership keeps the original intent (914059d: Retain the selected transcript store and owner through awaited operations and publication.)
  • Projected writer lifecycle keeps the original intent (65365c8: Use existing transcript owners for prepared writes while preserving ordering, compatibility, and live authority.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 914059d adds src/plugin-sdk/session-transcript-lock-runtime.ts:50 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 914059d0a630; files: src/plugin-sdk/session-transcript-lock-runtime.ts)
  • Josh Lehman: Raw commit 6beaff4 adds src/plugin-sdk/session-transcript-lock-runtime.ts:55 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6beaff450e6e; files: src/plugin-sdk/session-transcript-lock-runtime.ts)

PR surface

Source +1, Tests +88. Total +89 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 20 19 +1
Tests 1 88 0 +88
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 108 19 +89

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +20/-19; tests +88/-0 The small relocation is accompanied by distinct persistence, revocation, and foreign-owner controls.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The SDK changes authority binding for transcript writes; this maintainer-directed repair retains the optional caller contract and existing refusal checks.

Label justifications:

  • P1: Current-main Codex settled-turn summaries can fail to persist, breaking an active agent workflow.
  • merge-risk: 🚨 compatibility: The SDK changes authority binding for transcript writes; this maintainer-directed repair retains the optional caller contract and existing refusal checks.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (5 earlier review cycles)
  • reviewed 2026-10-12T01:15:22.883Z sha decfedd :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T02:15:55.944Z sha 0f77b19 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T02:21:53.765Z sha 0f77b19 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T03:03:13.288Z sha 6a88651 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T03:25:58.103Z sha 65e1341 :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 1:11 AM ET / 05:11 UTC (Revision 6).

@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 12, 2026
…ranscript target

unresolved transcript target, so the locked write compared it against the
resolved owner scope and refused the settled-turn summary mirror with
SessionTranscriptWriterClaimReboundError (settled-turn-finalizer.native,
4 cases). Move the assertion into withProjectedSessionTranscriptWriteLock,
which installs it on the same resolved scope it locks, still before the
writer is reserved.
@RomneyDa
RomneyDa force-pushed the fix/codex-mirror-assertion-resolved-target branch from 65e1341 to d1b45f2 Compare November 25, 2026 21:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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