Stop null-padding turns.jsonl and recover poisoned resume loads - #480
Merged
TheGreatAxios merged 2 commits intoAug 17, 2026
Merged
Conversation
When keepBytes exceeds on-disk size, rebuild the segment instead of truncate-past-EOF (which pads null bytes). On load, if the base store fails, recover usable turns with null-strip parse and soft-default metadata; unrecoverable errors name the file.
Turn recovery after a hard base.load failure was always soft-emptying metadata even when metadata.json parsed cleanly under the real schema. That dropped pendingOperations, tokenUsage, and connectorState for sessions whose turns.jsonl had null-byte holes but whose gates were still parked — rehydrateGates then found nothing to re-arm and left suspended agents wedged. Prefer base.loadMetadata() on the recovery path so a good metadata file survives; soft-empty only when that load itself fails. Regression covers null-hole turns plus non-empty pendingOperations.
TheGreatAxios
force-pushed
the
cl-5934-context-store-load-fails-hard-on-json-parse-during-resume
branch
from
August 17, 2026 17:13
e7e617e to
7f88025
Compare
This was referenced Aug 17, 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.
Summary
truncatewith a length past EOF whenkeepBytesis stale after an external shrink; rebuilds the segment from in-memory records instead (null-byte poison root cause).load()recovers usable turns when the base isogit store hard-fails (null holes, corrupt metadata soft-defaults); unrecoverable parse errors nameturns.jsonl.Test plan
bun test src/session/incremental-jsonl.test.ts src/session/optimized-context-store.test.tsbun run typecheckbun run test(full suite)Fixes CL-5934