Repository navigation
fix(agent): a torn JSONL append never refuses the session - #4297
Open
code-yeongyu wants to merge 1 commit into
Open
code-yeongyu wants to merge 1 commit into
code-yeongyu wants to merge 1 commit into
Conversation
Set damaged records aside in <file>.torn-<time>, keep every record around them, repair before the next append, never reuse a failed commit's sequence, and report each repair once through onRecovery.
code-yeongyu
marked this pull request as ready for review
October 26, 2026 01:37
This was referenced Oct 26, 2026
This branch has not been deployed
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.
Part of #4295
Summary
A JSONL session (harness
JsonlStorage, used by the experimental server and session-worker) refused to open after an append torn by a full disk. The next commit landed glued to the fragment, and it reused the failed commit's sequence, so every reopen threwInvalid JSONL storage <file>: line N.<file>.torn-<time>atomically (not listed as a session), then the session file is rewritten atomically once.onRecoveryonJsonlStorageOptions/JsonlSessionRepoOptionsreceives a typedJsonlStorageRecovery(cause:disk_full|write_failed|unknown,backupPath,droppedRecords, a user-facingmessage). A repair the disk refuses on open is deferred to the next append, which fails with that error instead of appending after the damage.The main CLI/RPC
SessionManagerpath is a separate PR (backup + typed notice).Evidence
main96f8ac1:jsonl-storage-torn-append.test.ts4/4 fail (Invalid JSONL storage s.jsonl: line 4, causeInvalid JSONL transaction: not valid JSON).tsc --noEmit,oxlint --deny-warnings,oxfmt --check, lint ratchet (baseline lowered: one!removed) and the changelog gate pass.rejects a complete malformed final line without rewritingnow expects the line set aside; the two refusal tests for unknown record kinds are unchanged.Merge order (with bugwatch)
#4297 (A1) -> #4303 (B) -> #4300 (A2) -> #4305 (C) last. #4305 touches the same flushed-append block in
SessionManager._persistas #4300, so it rebases after #4300 merges. #4305 carriesFixes #4295; the others arePart of #4295.