Skip to content

fix(session): recover interrupted JSONL appends - #1000

Open
lewismosciski wants to merge 1 commit into
modelscope:mainfrom
lewismosciski:fix/session-log-partial-tail
Open

lewismosciski wants to merge 1 commit into
modelscope:mainfrom
lewismosciski:fix/session-log-partial-tail

Conversation

@lewismosciski

Copy link
Copy Markdown

Change Summary

Resuming a session whose last JSONL write was interrupted can lose the next message: appending joins it to the unfinished record, and the reader drops the combined line. A write interrupted inside a UTF-8 character also prevents the session from opening.

Separate an unterminated tail from the next append and skip records with invalid UTF-8 when reading. Keep the existing bytes and complete records intact, including a valid final record missing only its newline.

Validation: six regressions failed before the fix; 171 related tests passed afterward, with 20 skips. Tests cover partial JSON, partial UTF-8, a complete unterminated record, metadata-sidecar recovery, event readers, and sequence numbers. Applicable changed-file pre-commit hooks passed. Full-repository pre-commit reports existing main lint/format failures, including skills_manager.py:61 and shell_validator.py:91.

Related issue number

Found while inspecting session-log recovery; no existing issue.

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Run pre-commit install and pre-commit run --all-files before git commit, and passed lint check. (Both run; existing repository failures noted above.)
  • Documentation reflects the changes where applicable (internal recovery fix; no API change)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant