feat(capture): automatic session finalization on sessionstart and close#304
Conversation
design: automatic finalization of old buffers on sessionstart, and current session on window close. plan: 8-task breakdown covering capture.py functions, cli command, adapter hooks, comprehensive unit tests, integration test, and documentation.
implement is_stale_buffer() to check file age, and finalize_all_except() to bulk-finalize capture buffers older than a threshold. this enables sessionstart cleanup of orphaned buffers from previous sessions. includes 9 unit tests covering single/multiple buffers, age boundaries, and current session exclusion.
new command finalizes all capture buffers except the given session, if they are older than max_age_seconds (default 3600s). silently succeeds if no kb found. used by sessionstart hook to clean up orphaned buffers from previous sessions. includes 3 unit tests covering option parsing, env fallback, and graceful degradation.
run 'vouch capture finalize-all' as the first sessionstart hook to clean up orphaned buffers from previous sessions before banner and recall commands. ensures old sessions are finalized automatically on next session start.
add comment to sessionstart hook explaining that current session finalization happens on next session start (fallback behavior when windowclose event is not supported by the vs code extension).
add section describing how capture works, configuration options, and the fallback behavior if windowclose event is not available.
verify that old buffers are cleaned up on new session start and current session is finalized on window close (or manual finalize), resulting in two separate proposals.
…rigin when finalize_all_except() cleans up orphaned buffers, those old sessions have unknown origin (no cwd), so we should not attribute the current working directory's git diff to them. this prevents data corruption where old sessions' summaries get current repo changes, and avoids spurious proposals that cross min_observations due to misattributed file counts. added explicit cwd check: if cwd is None (unknown origin), skip git changes. normal finalize calls with explicit cwd still get git context. also fix typo: unfinalzed -> unfinalized in adapter README.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (58)
📝 WalkthroughWalkthroughThis PR adds a Claude session auto-capture pipeline that harvests tool-use into review-gated proposals, a session-start recall hook injecting approved knowledge digests, JSON-merge semantics for adapter settings installation, storage resilience against corrupt YAML, and consistent UTF-8 encoding across file I/O, alongside version bumps and extensive documentation. ChangesSession Auto-Capture Feature
Session-Start Recall Feature
JSON-Merge Install Behavior
Storage Resilience
UTF-8 Encoding Hardening
Release Metadata and General Documentation
Estimated code review effort: 4 (Complex) | ~75 minutes Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
finalize-all resolved the current session id from --session-id or VOUCH_SESSION_ID only. the shipped SessionStart hook passes neither, and nothing in the adapter or runtime exports VOUCH_SESSION_ID, so sid was always "" and the sweep returned empty on every session start. that made the vouchdev#304 backstop dead: buffers orphaned by sessions that ended without SessionEnd accumulated in .vouch/captures/ and never rolled up into pending proposals, so the session never reached the review queue. the id now comes off the stdin payload the same way capture finalize reads it at SessionEnd, with --session-id and VOUCH_SESSION_ID kept as fallbacks. a malformed payload still no-ops rather than failing the host's turn. the adapter hook test asserted observe/finalize/banner but never finalize-all, which is why the shipped wiring went unexercised; it now covers it.
The SessionStart finalize-all backstop (vouchdev#304) never fires: the shipped hook passes no --session-id and sets no VOUCH_SESSION_ID, so the command always saw an empty session id and silently no-op'd, letting orphaned buffers accumulate in .vouch/captures/ indefinitely instead of rolling up into pending proposals. - Read the session id off the stdin hook payload, mirroring how capture_finalize_cmd already does it at SessionEnd - Keep --session-id and VOUCH_SESSION_ID as fallbacks for direct/ manual invocation - Assert finalize-all is actually wired to SessionStart in test_adapter_settings_wires_capture_hooks (the gap that let this ship unnoticed) - Add regression tests for stdin-payload precedence, option-overrides- payload, and the genuinely-session-less no-op case Closes vouchdev#492
The SessionStart finalize-all backstop (vouchdev#304) never fires: the shipped hook passes no --session-id and sets no VOUCH_SESSION_ID, so the command always saw an empty session id and silently no-op'd, letting orphaned buffers accumulate in .vouch/captures/ indefinitely instead of rolling up into pending proposals. - Read the session id off the stdin hook payload, mirroring how capture_finalize_cmd already does it at SessionEnd - Keep --session-id and VOUCH_SESSION_ID as fallbacks for direct/ manual invocation - Assert finalize-all is actually wired to SessionStart in test_adapter_settings_wires_capture_hooks (the gap that let this ship unnoticed) - Add regression tests for stdin-payload precedence, option-overrides- payload, and the genuinely-session-less no-op case Closes vouchdev#492
Summary
Automatically finalize session capture buffers without user action:
Buffers are rolled into PENDING proposals for review—the review gate is preserved.
What Changed
is_stale_buffer()&finalize_all_except()functions in capture.py for bulk cleanupvouch capture finalize-allCLI command (called by SessionStart hook)Testing
Tested end-to-end in VS Code Claude Code extension:
Commits
5933700feat(capture): add finalize_all_except() for old buffer cleanupf6cb506feat(capture): add 'vouch capture finalize-all' CLI command6ec0fe7feat(adapter): wire capture finalize-all into sessionstart hookd68a376docs(adapter): document windowclose fallback behavior2d76811docs(adapter): explain session capture auto-proposal behaviorb2955f0test(capture): add e2e test for sessionstart cleanup + finalize flow2a5d2d2fix(capture): skip git context when finalizing buffers with unknown originDesign
See:
docs/superpowers/specs/2026-07-01-vscode-session-autoproposal-design.mdSee:
docs/superpowers/plans/2026-07-01-vscode-session-autoproposal.mdAll tests pass (805 tests). Review gate preserved. No Co-Authored-By trailers.
Summary by CodeRabbit
New Features
Bug Fixes