Serialize run.json writes and seed turnsUsed/mcpServers on resume - #343
Merged
Conversation
Concurrent saveState calls for one session had no ordering guarantee on their underlying rename()s, so a late progress snapshot could land after the terminal finalize write and flip a finished session back to status: "running" with no finishedAt. Chain writes per sessionId so they always apply in call order. Documents why runner.ts's finalized flag still earns its place now that saveState serializes writes per session: the write chain only orders writes that are already issued, it has no way to know a stale post-finalize snapshot shouldn't be issued at all.
Resuming a session unconditionally reset the run sink's turn counter to zero and connectedMcpServers to empty, both in memory and by immediately persisting those zeroed values to run.json before the reactor even started. resolveResumeSeed folds a picked session's run.json into a single concrete seed once, at the resume boundary, so createRunSink, connectedMcpServers, and the immediate post-resume saveState all read a trusted value instead of each repeating its own `?? 0` / `?? []` default.
TheGreatAxios
force-pushed
the
cl-5567-run-json-integrity
branch
from
August 7, 2026 04:43
67ce98c to
ffe25ac
Compare
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.
Summary
Verification
Closes CL-5567
Closes CL-5566