Repository navigation
fix(ui-server): hold a session's history reads until its turn's boundary is recorded - #3899
Merged
Merged
Conversation
…ary is recorded A client can read history again the moment a turn's result arrives, while host teardown still runs. That replay happened before the turn boundary was recorded, so the answer replayed without its turn id and nothing replayed it again. Reads of that session now wait for the turn's finish, bounded by BOUNDARY_READ_MS. Not landed ahead of #3155's image PR (maintainer ruling); see the issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s at the boundary deadline (#3803) The result-to-finish hold is keyed by session and raced against the boundary deadline. Two unit tests pin both: an unrelated session's history read is never held, and a teardown that never finishes releases the hold with no pending entry left and no boundary made up. The deadline is a constructor option so the second test runs in milliseconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schlessera
marked this pull request as draft
November 10, 2026 20:09
schlessera
marked this pull request as ready for review
November 10, 2026 20:09
…ped guard (#3803) ServerResultMessage declares no turnId; servers stamp it on every frame. Strict typecheck refused the direct property read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schlessera
marked this pull request as draft
November 10, 2026 20:46
schlessera
marked this pull request as ready for review
November 10, 2026 20:46
This was referenced Nov 10, 2026
Closed
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3803
Refs #3884
What changed
A history read of a session issued between its turn's
resultand the end of host teardown (finish) now waits for that turn's boundary. Before, such a read ran before the boundary was recorded, so the answer replayed without itsturnId. Nothing replayed it again, so the session's tracker could never be observed as seen.The hold is tracked per session in
FailureReplay, the same way failure and boundary writes are already tracked. It starts when the turn's own result goes out (onTurnResult→resulted). It ends infinish, including on failure, or at the existingBOUNDARY_READ_MSdeadline, whichever comes first.This is the declared fix for red-main incident #3884. Main went red on
parallel-sessions-runtimeat #3805's mergeb77987afb. That slice made every image an attachment ref, which widened this pre-existing teardown window. The incident has the evidence and the decision.Why this shape
#3803's scope: coordinate the existing boundary metadata instead of changing prefix digests or positions, and make no client change. The hold manufactures nothing. A stalled teardown releases at the deadline without recording a boundary. An unrelated session is never held.
The deadline became a constructor option (default unchanged) only so the deadline test runs in milliseconds.
Proof
Failing-first, mutations and the runtime case:
ws-turn-failure-replay.test.ts"a resume between a turn's result and its end waits for the turn's boundary" fails on both backends with main'spackages/ui-server/src(Expected: <turnId>,Received: undefined). It passes with the fix (32 pass).this.track(sid, hold)removed). Both cases fail again. Restored.turn-boundary-hold.test.ts:finish, and no pending entry remains. A mutation makingwaitinclude every session fails "another session reads at once".parallel-sessions-runtime"1440 desktop, light, fine pointer…" ran with 10 busy loops on a 16-core host:b77987afb: 3 failures in 14 runs.b6c330a60: 0 failures in 5 runs.emission.ts:273,emission.ts:203-229,turn-failures.ts:67-94).check-citationsreports none of them.{ "version": 1, "kind": "brain-check-pr-receipt", "head": "1917da1c711fb0de6bcc773aaa96b02614393241", "base": "origin/main", "mode": "focused", "startedAt": "2026-11-10T20:42:24.652Z", "finishedAt": "2026-11-10T20:44:24.014Z", "checks": [ { "name": "all lint and leakage gates", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 28378.931565 }, { "name": "environment documentation", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 207.19922399999632 }, { "name": "pending changeset package names", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 162.6990850000002 }, { "name": "contribution changeset", "categories": [ "changeset" ], "outcome": "passed", "elapsedMs": 28.339718000002904 }, { "name": "affected fast invariants", "categories": [ "verify", "unit" ], "outcome": "passed", "elapsedMs": 90565.778922 } ] }verifyrun failed strict types: the cherry-picked test readresult.turnId, whichServerResultMessagedoes not declare. The test now reads the stamped id through a typed guard, the patternclaude-cancellation.test.tsuses.tsc --noEmitandbun run buildpass locally on1917da1c7.Checklist
integrate.ts confirmas the declared fix.@schlessera/brain-ui-serverpatch.Anything left open
The other two failures in #3884 (
runtime_host,safety-history) are outside this change and outside #3805. The recovery main run has to pass them as they stand.🤖 Generated with Claude Code