Verify end-to-end JSONL restore against a real deleted session (Alpha #2)
Epic
One of four alpha-release criteria. csb restore <id> was implemented in v0.1.1 but has never been tested end-to-end against a real session deletion. This issue tracks the verification procedure and any fixes discovered along the way.
Why
Backup without proven restore is just "hopeful storage." We need to demonstrate that:
- A JSONL can be committed to git by
csb backup
- The same JSONL can be deleted from
~/.claude/projects/
csb restore <id> recovers it from git history
- Claude Code sees the restored session and can
claude --resume <id> it successfully
Currently we have #1 (verified 1343+ jsonls tracked in git) and the code for #3 exists, but #2, #3 (in practice), and #4 are untested.
Approach
Step 1: Create a throwaway session
Start a new Claude Code session specifically for this test. Send a few messages, get responses, close the session. Note its UUID.
Step 2: Confirm it's in git
csb backup # commit the new session to git
git -C ~/.claude log --oneline -- "projects/<project>/<uuid>.jsonl"
Step 3: Delete it from disk
# Capture mtime and size before delete, for later comparison
stat ~/.claude/projects/<project>/<uuid>.jsonl
rm ~/.claude/projects/<project>/<uuid>.jsonl
Step 4: Verify csb detects the deletion
csb backup --no-commit # rescans, should mark the session as deleted_at
csb list --deleted # should show the deleted session
Step 5: Restore
csb restore <uuid> # should find the file in git history and write it back
ls -la ~/.claude/projects/<project>/<uuid>.jsonl # exists again
Step 6: Verify Claude Code can resume
claude --resume <full-uuid>
# Should load the session without errors
# Send a test message to verify the session context is intact
Step 7: Document the procedure
Add a "Recovery" section to README.md with the tested steps. Note any quirks discovered.
Possible issues to fix
Things that might go wrong and need patches:
- Mtime not preserved: When
git show writes the file back, mtime is "now" not the original timestamp. Claude Code might not care, but csb's purge countdown will be wrong until next backup cycle.
- Subagent data not restored: The
<uuid>/subagents/ and <uuid>/tool-results/ directories alongside the JSONL may also need restoration. Current csb restore only restores the JSONL, not the subdirectory contents.
- Session-states file: The session-state JSON in
~/.claude/session-states/<uuid>.json might need to be restored too for Claude Code to recognize the session.
- Windows line endings: git might change LF to CRLF on Windows checkouts, which could corrupt JSONL parsing.
Acceptance criteria
Related
Verify end-to-end JSONL restore against a real deleted session (Alpha #2)
Epic
One of four alpha-release criteria.
csb restore <id>was implemented in v0.1.1 but has never been tested end-to-end against a real session deletion. This issue tracks the verification procedure and any fixes discovered along the way.Why
Backup without proven restore is just "hopeful storage." We need to demonstrate that:
csb backup~/.claude/projects/csb restore <id>recovers it from git historyclaude --resume <id>it successfullyCurrently we have #1 (verified 1343+ jsonls tracked in git) and the code for #3 exists, but #2, #3 (in practice), and #4 are untested.
Approach
Step 1: Create a throwaway session
Start a new Claude Code session specifically for this test. Send a few messages, get responses, close the session. Note its UUID.
Step 2: Confirm it's in git
Step 3: Delete it from disk
Step 4: Verify csb detects the deletion
Step 5: Restore
Step 6: Verify Claude Code can resume
Step 7: Document the procedure
Add a "Recovery" section to README.md with the tested steps. Note any quirks discovered.
Possible issues to fix
Things that might go wrong and need patches:
git showwrites the file back, mtime is "now" not the original timestamp. Claude Code might not care, but csb's purge countdown will be wrong until next backup cycle.<uuid>/subagents/and<uuid>/tool-results/directories alongside the JSONL may also need restoration. Currentcsb restoreonly restores the JSONL, not the subdirectory contents.~/.claude/session-states/<uuid>.jsonmight need to be restored too for Claude Code to recognize the session.Acceptance criteria
tests/test_restore.pythat simulates deletion+restore againstmock_claude_dirfixtureRelated
notes/ideas/2026-04-10__21-58-00__both_initial-release-criteria-and-repokit-common-question.md