Repository navigation
fix: keep slow history reads from blocking transcript writes - #187989
Conversation
Release writer admission while bounded history workers run, then validate existing source and mutation witnesses before synchronous consumption. Retry one intervening mutation without repeating the consumer. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
|
🦞👀 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. |
Update three consumer expectations for the bounded retry contract; assert refreshed content and two reads. CI failure retained from run 40983725167; the repaired 32-test consumer suite, focused lint, format and test types pass. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
|
Codex review: needs maintainer review before merge. What this changesThis PR releases writer admission while bounded transcript hydration and prepared model-context reads await workers, then validates results before consumption. Example: A history hydration read takes 59,999 ms while a transcript append queues behind it.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses writer blocking still present on main, and inspection found no concrete introduced correctness defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSessionManager requests transcript snapshots from SQLite history workers; writer admission orders mutation checks and synchronous publication of accepted snapshots. flowchart TD
A[SessionManager request] --> B[Capture mutation witnesses]
B --> C[History worker read]
C --> D[Reacquire writer admission]
D --> E[Validate source and witnesses]
E --> F[Synchronous consumer]
E -->|First mutation| B
Technical reviewBest possible solution: Keep the shared read-and-accept operation using the existing writer, receipt, reader, and mutation owners. Do we have a high-confidence way to reproduce the issue? Current main visibly holds writer admission across the worker await; the author reports base-failing regressions, but this read-only review ran no target code. Is this the best way to solve the issue? The patch removes the blocking reservation while retaining synchronous acceptance and existing freshness checks; the shared helper serves both affected callers without introducing another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1ae91fa20263. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +44, Tests +152, Docs +7, Other +2. Total +205 across 8 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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, 9:29 PM ET / October 30, 2026, 01:29 UTC. |
…failing (#188073) #187989 (8bc6317, "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 9344233 (good) to main (bad) found 8bc6317 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.
|
Heads-up: this change made the bounded history-read owner rethrow on a second mutation conflict, so concurrent session starts failed with The fix is #188073 (f0586d2). It keeps two optimistic reads, then does one fresh bounded read under the existing writer admission and rechecks authority before consuming. Under repeated contention the writer queue is held briefly during that final read. The intent of this PR, keeping slow history reads from blocking transcript writes, is otherwise preserved. |
…w#187989) * fix: keep slow history reads from blocking transcript writes Release writer admission while bounded history workers run, then validate existing source and mutation witnesses before synchronous consumption. Retry one intervening mutation without repeating the consumer. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> * test: verify refreshed model context after admitted read retry Update three consumer expectations for the bounded retry contract; assert refreshed content and two reads. CI failure retained from run 40983725167; the repaired 32-test consumer suite, focused lint, format and test types pass. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> --------- Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
…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]>
* fix: keep slow history reads from blocking transcript writes Release writer admission while bounded history workers run, then validate existing source and mutation witnesses before synchronous consumption. Retry one intervening mutation without repeating the consumer. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> * test: verify refreshed model context after admitted read retry Update three consumer expectations for the bounded retry contract; assert refreshed content and two reads. CI failure retained from run 40983725167; the repaired 32-test consumer suite, focused lint, format and test types pass. Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> --------- Co-authored-by: jalehman <[email protected]> Co-authored-by: fuller-stack-dev <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 8bc6317)
What Problem This Solves
Fixes: a slow history read can stall transcript writes behind it for the entire history-worker timeout.
User Impact
Bounded hydration and prepared model-context reads no longer reserve the database writer while awaiting a worker response. Existing source, authority, mutation and synchronous-consumer checks remain enforced. No configuration change or data migration is required.
Why This Change Was Made
An incident trace showed a history hydration read holding the writer for 59,999 ms while a transcript append queued behind it for 59,975 ms. This establishes head-of-line blocking, not a circular deadlock or the underlying cause of the worker timeout.
The two affected paths now share one small read/accept operation: capture the existing mutation witnesses under writer admission, perform the read outside that reservation, then reacquire admission and validate before synchronous consumption. An intervening mutation retries the read once; continued mutation rejects it without invoking the consumer. Already-owned writer execution keeps its existing custody.
Scope is deliberately limited: this does not repair filesystem fragmentation, change SQLite durability, remove whole-file snapshots, or change other ordered-read paths. It has not been deployed to the incident server.
Evidence
node scripts/run-vitest.mjs src/config/sessions/session-transcript-anchor-read.worker.test.ts src/config/sessions/session-transcript-context-read.worker.test.ts src/config/sessions/session-actor-transcript-reuse.test.ts --maxWorkers=1.Review and qualification limits
Independent review of the production patch and the subsequent consumer-test repair found no actionable blocking findings. Reviews were diff/evidence-based; the author separately inspected the ownership contracts and verified test results. Real-provider/Gateway end-to-end validation is not claimed; current-head PR CI remains pending.
Earlier checks exposed and corrected a required-environment type mismatch and test lint issues. An intermediate run passed all 36 assertions but was invalidated because source changed before the worker-generation verification; it is not counted as the final passing run.
CI repair: run 40983725167 exposed three stale model-context consumer expectations. The tests now require refreshed contents after the bounded retry rather than a rejection or stale snapshot. All 32 tests in that consumer suite passed, as did its targeted TypeScript graph, lint, format, and the test-line ratchet. The failed CI receipt is retained; it is not relabeled green.