Repository navigation
fix: keep concurrent session starts from failing history reads - #188073
Conversation
After two optimistic history reads lose to writes, perform one fresh read under the existing writer admission. Preserve live authority and mutation checks and consume only once. This restores concurrent starts in shared session stores without blocking writers on ordinary slow reads.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesAfter two history reads conflict with writes, this PR performs one fresh read under the existing writer admission. Example: Transcript writes containing later-0 and later-1 overtake the first two model-context reads.
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 PR repairs a source-confirmed concurrent-start regression still present on current main, and review found no actionable introduced defect. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSession hydration and prepared model-context loading share a read-and-accept operation between SQLite history workers and synchronous consumers, using the existing writer FIFO and mutation witnesses. flowchart TD
A[Session history request] --> B[Capture mutation witnesses]
B --> C[Read outside writer admission]
C --> D[Validate under writer admission]
D -->|First conflict| B
D -->|Second conflict| E[Fresh read under writer admission]
E --> F[Recheck owner and witnesses]
D -->|Unchanged| G[Consume once]
F --> G
Technical reviewBest possible solution: Keep the two optimistic reads and use the existing writer owner for one final fresh read while preserving all acceptance checks. Do we have a high-confidence way to reproduce the issue? Two writes overtaking the two optimistic reads reach the terminal throw on current main; the revised regression exercises that sequence, and the author reports red-on-base/green-on-head results, but this read-only review executed no target code. Is this the best way to solve the issue? This is a focused repair in the existing shared owner: the fallback obtains a fresh snapshot under admission rather than accepting stale data or replaying the consumer, and every changed hunk serves that invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 315380c47895. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +12, Tests -2, Docs +2. Total +12 across 3 files. Added test files: 0. View PR surface stats
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 29, 2026, 11:57 PM ET / October 30, 2026, 03:57 UTC. |
…failing (openclaw#188073) openclaw#187989 (570a3bf, "keep slow history reads from blocking transcript writes") made the bounded history-read owner rethrow on a second mutation conflict (session-transcript-read-cohort). Concurrent session starts then failed with SessionEntryChangedDuringReadError. That broke the restart acceptance e2e (test/gateway-restart-resume.e2e.test.ts) and test/gateway-restart-handoff.e2e.test.ts on main, and any production path that starts sessions concurrently. The read now makes two optimistic attempts, then one fresh bounded read under the existing writer admission, rechecking authority before consuming once. Accepted tradeoff: under repeated contention, the final bounded read briefly holds the writer queue. Proof at exact head de60b65: bisect from 4e2e6c6 (good) to main (bad) found 570a3bf as first bad, and its parent passes. The unchanged acceptance e2e is red on main and on the culprit, green here (1 passed). The owner regression ("repeated contention") is red with SessionEntryChangedDuringReadError before the fix and green after. Owner and consumer suites pass (66 tests); targeted typecheck, lint, format and ratchets pass. Exact-head CI succeeded, both ci-gate checks SUCCESS. Production +12 LOC.
…188947) Related: #187989 ## What Problem This Solves Fixes a model-context CI test failing intermittently when transcript projection writes overlap its second read. ## User Impact The fixture reliably checks the intended two-read contract. There is no user-visible runtime change. ## Why This Change Was Made #187989 moved slow history reads outside writer admission and updated this test to expect refreshed messages after one retry. The native rewrite also schedules background projection reconciliation; those later writes can legitimately trigger the serialized fallback added by #188073. The fixture now joins that reconciliation before returning its first stale read. The exact two-call assertion and both refreshed-message checks remain unchanged. ## Evidence - Directed scheduling reproduces the original expected-2/received-3 failure; the same qualifier passes with exactly two reads after the fix. - 66 real-worker tests pass across the changed file and its two sibling suites on Node 24.22.1 and repository-pinned Bun. - Scoped typecheck, lint, format, four ratchets and whitespace checks pass. Test count and test-line ceiling are unchanged. - Fresh independent canonical P0–P2 autoreview: scoped-clean, no findings. - Test-only change; production retries, timeouts and assertions are preserved. The historical CI scheduler interleave is unobserved; the controlled projection-write cause is proven. Requested by @steipete ## Work sessions [Discussion, implementation and verification](https://team.openclaw.ai/chat/roboclaw/~key/dashboard/b5679712-7777-4ff7-a05a-81c1efab2069) Co-authored-by: steipete <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
…penclaw#188947) Related: openclaw#187989 ## What Problem This Solves Fixes a model-context CI test failing intermittently when transcript projection writes overlap its second read. ## User Impact The fixture reliably checks the intended two-read contract. There is no user-visible runtime change. ## Why This Change Was Made openclaw#187989 moved slow history reads outside writer admission and updated this test to expect refreshed messages after one retry. The native rewrite also schedules background projection reconciliation; those later writes can legitimately trigger the serialized fallback added by openclaw#188073. The fixture now joins that reconciliation before returning its first stale read. The exact two-call assertion and both refreshed-message checks remain unchanged. ## Evidence - Directed scheduling reproduces the original expected-2/received-3 failure; the same qualifier passes with exactly two reads after the fix. - 66 real-worker tests pass across the changed file and its two sibling suites on Node 24.22.1 and repository-pinned Bun. - Scoped typecheck, lint, format, four ratchets and whitespace checks pass. Test count and test-line ceiling are unchanged. - Fresh independent canonical P0–P2 autoreview: scoped-clean, no findings. - Test-only change; production retries, timeouts and assertions are preserved. The historical CI scheduler interleave is unobserved; the controlled projection-write cause is proven. Requested by @steipete ## Work sessions [Discussion, implementation and verification](https://team.openclaw.ai/chat/roboclaw/~key/dashboard/b5679712-7777-4ff7-a05a-81c1efab2069) Co-authored-by: steipete <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
Backport #188073 from main, source commit f0586d2. Repeated transcript mutations currently exhaust both optimistic reads and abort restart recovery with SessionEntryChangedDuringReadError before replying. After two contended attempts, make one fresh bounded read under the existing writer admission. Recheck owner authority and the snapshot before consuming once. The accepted tradeoff is briefly holding the writer queue after repeated contention. Release adaptation: preserve the release's session-scoped write receipts and target interface rather than restoring the source's database-wide receipt. Update the existing same-session mutation test to expect the third read while retaining rejection and zero consumption. No schema, configuration, grant, or permission changes. The unchanged signed-in-person restart E2E is red on 8142a61 and green with this patch (22.359s). The deterministic owner regression is red without the fallback. Both owner suites pass (18 tests), including on base 50fde57. Targeted typecheck, lint, formatting and diff checks pass for the patch. (cherry picked from commit f0586d2) Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes agent turns failing with
Session entry changed during readwhen several sessions start concurrently in a shared session store, before restart acceptance can reach its restart checks.Related: #187989.
User Impact
Concurrent starts can finish loading history and produce replies. Ordinary slow history reads continue to let transcript writers progress. When both optimistic reads lose to writes, one final bounded read holds the existing writer admission; queued writes can wait for that read. No configuration, schema, stored-data, dependency, or upgrade changes.
Why This Change Was Made
Bisect identifies
8bc631709922a7f994253aef52cddf74e627745f(#187989) as the first bad commit; its direct parent9abf96a0ac1e53ceb5a1bdbf302452b5b50ac8b5passes the unchanged restart acceptance test. Insession-transcript-read-cohort.ts, the second database-wide mutation conflict was rethrown at line 54, turning normal concurrent activity into a terminal turn failure.Keep the two optimistic attempts, then reread under the existing FIFO admission when both were overtaken. Recheck the live owner, current authority, and freshly captured mutation witness after the awaited read and before consuming. Consume only once. Physical replacement, revocation, cancellation, or a native write that bypasses admission still refuses unsafe consumption.
The existing model-context writer-progress test now performs two real transcript writes and verifies that the consumer receives the newest content once. Production: +12 lines; tests: -2 lines; docs: +2 lines. The simplify pass retained one read owner and no new state.
Evidence
264adfe194c1and first bad8bc631709922: the original restart acceptance fails during initial setup withSession entry changed during read; direct parent9abf96a0ac1epasses. All nine bisect probes completed; no setup/build failures were treated as product verdicts.SessionEntryChangedDuringReadError; green with this fix.session-transcript-context-read.worker.test.ts,session-transcript-anchor-read.worker.test.ts, andsession-manager-model-context-snapshot.test.ts(two shards, 51.83 seconds including orchestration).git diff --check: pass. No budget or baseline changes.264adfe194c1to the local snapshot committed asde60b653589e062be2c68a8b4833f8729c8dfe05: scoped-clean at P0 only; no accepted/actionable P0 findings. Maintainer review remains pending.de60b653589e062be2c68a8b4833f8729c8dfe05: the unchanged restart acceptance passes (1 test, 61.39 seconds including transformation; test execution 36.92 seconds), including both graceful replacement cycles, FIFO queued inputs, and lossy SIGKILL behavior.openclaw/ci-gatechecks are SUCCESS. The PR is ready and mergeable; not merged.All Gateway tests use isolated state and ports with the synthetic Responses provider. No live Gateway, deployment, or release changes.