Keep completed chat turns completed across cold restarts - #68
Merged
Merged
Conversation
A cold restart can interrupt the enclosing recovery task after its answer commits. Retain the existing terminal stream through that window and announce completion only after persistence, so waking the task cannot infer another answer. The next turn already reclaims terminal streams.
MiguelsPizza
marked this pull request as ready for review
September 14, 2026 15:34
MiguelsPizza
marked this pull request as draft
September 14, 2026 15:46
Persistence must precede completion, but the observer accumulator still needs done before the canonical snapshot. Keep that wire order so stopping a turn preserves its elapsed label instead of replacing metadata with the final accumulator merge.
MiguelsPizza
marked this pull request as ready for review
September 14, 2026 21:47
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.
A browser restart immediately after a completed answer could trigger another model inference. Rook found this while upgrading a real Web Store 1.1.0.509 profile during release verification for Rook #166.
Think announced completion before committing the assistant message, then discarded the terminal stream while the enclosing recovery task could still be running. Move completion after persistence and retain the existing terminal stream until the next stream start reclaims it. This uses the existing
discard: falsecutover; it adds no storage shape, migration, timer, or recovery protocol. Exceptional terminal delivery and reconnect replay remain covered.The new native regressions failed on the old behavior: both transports announced completion with zero durable assistant rows, and recovery of a real completed turn scheduled an extra continuation. The production upgrade regression additionally counts model requests, so duplicate inference cannot hide behind transcript reconciliation.
Validation: SDK exports, formatting, lint and type checks passed; all 679 Think tests passed with retries disabled. Rook ran 18 production-artifact checks, including three fresh-profile runs and three upgrades from Web Store 1.1.0.509, each with two cold restarts and exactly two model requests. The immutable SDK candidate is built from this commit. Full SDK repository CI passed. Rook adoption CI remains a release gate. Source ownership and the superseded immediate-discard policy are recorded in the fork inventory.
Consumer adoption: Rook #167. Merge this SDK owner change before the consumer release follow-up.
After durable commit, Think closes the observer stream before broadcasting the canonical transcript, so observers retain terminal activity duration/status and normalized message parts. Both transports assert the frame order; all four affected Chrome regression cases pass with retries disabled. The earlier
rook-sdk-84c41693a052candidate is withdrawn.