Repository navigation
fix(agents): reread native ownership when the writer claim follows admission - #169101
Conversation
…mission #168992 (e63b5a0) reused the run-admission session snapshot for the first native ownership read. Admission runs in prepareEmbeddedRunSession, before the lane controller claims the session writer, so the snapshot never carries the claimed activeWriterRunId. Every pinned native harness run with a writer claim then failed with "Native model ownership changed during run preparation" (run.harness-auth-failover.test.ts, 5 tests). Reuse the admitted snapshot only when it already carries the expected writer; otherwise take the existing worker read.
|
🦞👀 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 rereads native session ownership when the admission snapshot does not contain the subsequently claimed writer. Example: Session agent:main:model-chat is admitted before its writer becomes claimed-writer.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current-main regression that rejects pinned native sessions after writer admission. No actionable introduced defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded runner admits a session, claims its writer through the lane controller, prepares native model ownership, and validates that ownership before harness dispatch. flowchart TD
A[Session admission] --> B[Lane writer claim]
B --> C[Native model preparation]
C --> D[Snapshot matches writer]
D --> E[Reuse admitted row]
D --> F[Read current row through owner]
E --> G[Ownership validation and dispatch]
F --> G
Technical reviewBest possible solution: Retain the conditional authoritative reread while preserving snapshot reuse and existing dispatch validation. Do we have a high-confidence way to reproduce the issue? The production ordering deterministically supplies a pre-claim row to a post-claim writer check on current main; the author reports matching baseline failures and a passing regression, but no tests were executed during this read-only review. Is this the best way to solve the issue? The conditional reread repairs the stale input at the existing ownership boundary without fabricating row state, moving writer responsibility, or weakening validation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3a0db8a3a052. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +15. Total +21 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel 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 Reviewed October 11, 2026, 8:44 AM ET / 12:44 UTC. |
|
Merged via squash.
|
…mission (openclaw#169101) openclaw#168992 (70e895e) reused the run-admission session snapshot for the first native ownership read. Admission runs in prepareEmbeddedRunSession, before the lane controller claims the session writer, so the snapshot never carries the claimed activeWriterRunId. Every pinned native harness run with a writer claim then failed with "Native model ownership changed during run preparation" (run.harness-auth-failover.test.ts, 5 tests). Reuse the admitted snapshot only when it already carries the expected writer; otherwise take the existing worker read.
What Problem This Solves
Since #168992 (e63b5a0), every run on a session pinned to a native harness with session-runtime ownership (Codex) fails before dispatch whenever the lane has claimed the session writer:
Current
main(0690a2ef) fails 5/10 tests insrc/agents/embedded-agent-runner/run.harness-auth-failover.test.tsfor this reason. That test file blocks CI for any PR that touches the embedded runner, for example #168401.Why This Change Was Made
Root cause:
sessionAdmission.entry) for the first native ownership read inprepareNativeSessionRuntime(src/agents/embedded-agent-runner/run/model-setup.ts).prepareEmbeddedRunSession. The lane controller claims the session writer later, inclaimAgentSessionWriterinlane-controller.ts, and then setssessionTarget.expectedWriterRunId.activeWriterRunId, and the ownershipassertCurrentwriter check always fails.expectedWriter: "run-1",activeWriterRunId: undefined, all other fields matching.Fix: reuse the admitted snapshot only when it already carries the expected writer, or when there is no writer claim. Otherwise take the existing worker read, which is the behavior before #168992. The no-claim reuse that #168992 added (and its no-main-thread-SQL test) is unchanged.
Alternative considered: patching the claimed writer into the admitted snapshot, or refreshing admission inside the lane claim. Both would fabricate or relocate row state across owners. Rereading is the existing authoritative path.
User Impact
Pinned native Codex sessions run again instead of failing every turn at preparation. There is no config or schema change.
Evidence
git bisectbetween bdcbb2d (good) and ff6f58a (bad), runningrun.harness-auth-failover.test.ts, names e63b5a0 as the first bad commit.model-setup.ownership.test.ts"rereads native ownership when the writer claim follows run admission". It fails onmainwith the exact error above and passes with this fix.pnpm test src/agents/embedded-agent-runner/run/model-setup.ownership.test.ts src/agents/embedded-agent-runner/run.harness-auth-failover.test.ts: 42/42 pass. The 10 failover tests were 5/10 onmain.Note:
node scripts/check-changed.mjscurrently stops atduplicate scan target coveragebecause of the rootworker-heap-flag.mjsadded in #166581. That failure also happens onmainand is unrelated to this change.