Skip to content

feat: v2 dual-write for checkpoints behind feature flag#759

Merged
pfleidi merged 24 commits intomainfrom
feat/checkpoints-v2-refs
Mar 25, 2026
Merged

feat: v2 dual-write for checkpoints behind feature flag#759
pfleidi merged 24 commits intomainfrom
feat/checkpoints-v2-refs

Conversation

@pfleidi
Copy link
Copy Markdown
Contributor

@pfleidi pfleidi commented Mar 23, 2026

Summary

Introduces checkpoints v2 dual-write support. When checkpoints_v2 is enabled in strategy options, the CLI writes checkpoint data to both v1 (entire/checkpoints/v1 branch) and v2 custom refs (refs/entire/checkpoints/v2/main and refs/entire/checkpoints/v2/full/current).

  • V2GitStore — new store type for v2 ref operations, separate from GitStore (v1) to simplify future v1 removal
  • /main ref — receives metadata, prompts, session metadata (no raw transcript or content hash). Compact transcript.jsonl will be added here once compaction (workstream B) is ready
  • /full/current ref — accumulates raw transcripts (full.jsonl) + content_hash.txt across checkpoints via tree splicing (same pattern as v1). Generation rotation will archive and reset this ref when it reaches capacity (future work)
  • Dual-write wiringCondenseSession and stop-time finalization both dual-write, gated by settings.IsCheckpointsV2Enabled(). V2 failures are best-effort (logged as warnings, never block v1)
  • Stop-time optimization — v2 feature flag is evaluated once before the finalization loop (not per-checkpoint) to avoid repeated settings I/O

What's NOT in scope (future steps per design spec)

  • Task checkpoint support on /main
  • Push logic for v2 refs
  • Read paths (entire status, entire explain, entire resume)
  • Generation rotation for /full/current
  • Compact transcript format / compaction (workstream B)
  • v1 → v2 migration tool

Test plan

  • 20 unit tests for V2GitStore (ref management, write/update for both refs, multi-session, accumulation, edge cases)
  • 2 strategy-level tests (v2 enabled vs disabled in CondenseSession)
  • 3 integration tests (full workflow, disabled path, stop-time finalization)
  • mise run fmt && mise run lint — 0 issues
  • mise run test:ci — all unit, integration, and E2E canary tests pass

🤖 Generated with Claude Code

@pfleidi pfleidi requested a review from a team as a code owner March 23, 2026 23:57
Copilot AI review requested due to automatic review settings March 23, 2026 23:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a feature-flagged “checkpoints v2” dual-write path so the manual-commit strategy can persist checkpoint data to both the existing v1 metadata branch and the new v2 custom refs, enabling a gradual migration without breaking current read paths.

Changes:

  • Wire dual-write into CondenseSession and stop-time finalization (UpdateCommitted) behind settings.IsCheckpointsV2Enabled(), with v2 failures treated as best-effort.
  • Introduce V2GitStore to write v2 checkpoint data to custom refs (/main for metadata/prompts, /full/current for raw transcript + content hash).
  • Add unit + strategy-level + integration tests, and extend integration TestEnv helpers to read from arbitrary refs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
cmd/entire/cli/strategy/manual_commit_condensation.go Builds shared v1/v2 write opts and adds best-effort v2 dual-write during condensation.
cmd/entire/cli/strategy/manual_commit_hooks.go Adds best-effort v2 dual-write during stop-time checkpoint finalization.
cmd/entire/cli/strategy/manual_commit_test.go Adds strategy-level tests for v2 dual-write enabled/disabled behavior.
cmd/entire/cli/paths/paths.go Defines v2 custom ref names under refs/entire/....
cmd/entire/cli/integration_test/v2_dual_write_test.go Adds integration coverage for full workflow, disabled path, and stop-time finalization.
cmd/entire/cli/integration_test/testenv.go Adds helpers for reading files from full refs and for checking ref existence.
cmd/entire/cli/checkpoint/v2_store.go Adds low-level v2 ref creation/state/update primitives.
cmd/entire/cli/checkpoint/v2_committed.go Implements v2 committed write/update logic for /main and /full/current.
cmd/entire/cli/checkpoint/v2_store_test.go Adds unit tests for v2 ref management and committed write/update behavior.
cmd/entire/cli/checkpoint/committed.go Reuses shared write-option validation via validateWriteOpts.
cmd/entire/cli/checkpoint/checkpoint.go Makes SessionFilePaths JSON fields omitempty to support v2 layouts with missing fields.

@pfleidi pfleidi requested review from Soph and computermode March 24, 2026 00:11
computermode

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

computermode
computermode previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@computermode computermode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We chatted about these changes together, approving to unblock testing/progress. Thank you for thinking through the updated ref changes and talking through them with me. 😄

Since GH swallowed my comments and I can't seem to undo that, I'll echo here that I think creating packages for v1 vs v2 might be a nice way to approach changes like this in the future.

Copy link
Copy Markdown
Collaborator

@Soph Soph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise 👍

Entire-Checkpoint: f28ddc010230
@pfleidi pfleidi merged commit cdf0d83 into main Mar 25, 2026
3 checks passed
@pfleidi pfleidi deleted the feat/checkpoints-v2-refs branch March 25, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants