feat: generation rotation for /full/current ref#781
Merged
Conversation
Add V2FullRefPrefix and GenerationFileName constants to the paths package, and introduce GenerationMetadata struct for tracking /full/* generation state (checkpoint count, checkpoint IDs, timestamps). Entire-Checkpoint: c23e9d9220b4
Implement readGeneration, readGenerationFromRef, writeGeneration, and addGenerationToRootTree on V2GitStore. These helpers read/write GenerationMetadata (generation.json) from git trees, supporting the generation rotation lifecycle. Entire-Checkpoint: b90857dc67c4
…rent write Add updateGenerationForWrite helper that maintains checkpoint IDs and timestamps in generation.json. Wire it into writeCommittedFullTranscript so every WriteCommitted updates the generation metadata at the tree root. UpdateCommitted (stop-time finalization) does not modify generation.json since it replaces an existing transcript rather than adding a new checkpoint. Changes: - cmd/entire/cli/checkpoint/v2_generation.go — added updateGenerationForWrite - cmd/entire/cli/checkpoint/v2_committed.go — wired generation tracking into writeCommittedFullTranscript - cmd/entire/cli/checkpoint/v2_generation_test.go — 5 new tests Entire-Checkpoint: 0be8f3fb287a
Scan refs under refs/entire/checkpoints/v2/full/ (excluding current) to enumerate archived generations. nextGenerationNumber finds the highest existing archive number and returns max+1 for the next rotation. Changes: - cmd/entire/cli/checkpoint/v2_generation.go — added listArchivedGenerations, nextGenerationNumber - cmd/entire/cli/checkpoint/v2_generation_test.go — 5 new tests + createArchivedRef helper Entire-Checkpoint: c68e85deaf3a
…fresh orphan Three-phase rotation: (1) finalize generation.json on /full/current with the archive sequence number, (2) create archived ref pointing to the finalized commit, (3) create fresh orphan /full/current with seed generation.json (generation: 0, empty checkpoints). Changes: - cmd/entire/cli/checkpoint/v2_generation.go — added rotateGeneration - cmd/entire/cli/checkpoint/v2_generation_test.go — 2 new tests + populateFullCurrent helper Entire-Checkpoint: f32242003084
After each successful write to /full/current, check if the checkpoint count has reached the threshold. If so, trigger rotation (non-fatal on failure). Add MaxCheckpointsPerGeneration field to V2GitStore for testability (defaults to 100). Changes: - cmd/entire/cli/checkpoint/v2_store.go — added MaxCheckpointsPerGeneration field, maxCheckpoints() helper - cmd/entire/cli/checkpoint/v2_committed.go — added rotation check after updateRef - cmd/entire/cli/checkpoint/v2_store_test.go — 2 new tests (triggers at threshold, no rotation below) Entire-Checkpoint: 02f58fcff274
Entire-Checkpoint: d8cb610329ec
…ogic Entire-Checkpoint: d4f66ac7e8b9
strings.TrimLeft on an all-zero string returns "", causing Atoi to fail. strconv.ParseInt handles zero-padded decimal strings natively. Entire-Checkpoint: dbb1cf5bbaef
Entire-Checkpoint: b188823acb99
Eliminates stringly-typed checkpoint IDs in generation.json. The typed ID is already used everywhere else and marshals identically to JSON. Entire-Checkpoint: 83c2919167b8
v2 is a clean break — no need to carry the backward-compat field that v1 still needs for older CLI versions. Entire-Checkpoint: cca08210a63b
Re-read /full/current before archiving and skip if checkpoint count is already below threshold. Prevents archiving an empty generation if another CLI instance already rotated. Entire-Checkpoint: f2f088150117
Contributor
There was a problem hiding this comment.
Pull request overview
Adds generational rotation to the v2 /full/current checkpoint ref so large transcript histories are periodically archived into numbered refs, keeping /full/current bounded while preserving access to older generations.
Changes:
- Introduces
generation.jsonmetadata at the root of each/full/*generation and updates it on eachWriteCommitted. - Implements rotation: archive
/full/currentto a numbered ref and reset/full/currentto a fresh orphan commit when the checkpoint threshold is reached. - Adds unit/integration tests validating generation metadata behavior, archived generation discovery, numbering, and rotation triggering.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/paths/paths.go | Adds constants for /full/* ref prefix and generation.json filename. |
| cmd/entire/cli/checkpoint/v2_store.go | Adds a test override for the max checkpoints-per-generation threshold. |
| cmd/entire/cli/checkpoint/v2_committed.go | Wires generation metadata updates and post-write rotation checks into /full/current writes. |
| cmd/entire/cli/checkpoint/v2_generation.go | Implements generation metadata read/write, archived generation listing, numbering, and rotation logic. |
| cmd/entire/cli/checkpoint/v2_generation_test.go | Adds unit tests covering generation read/write, accumulation/dedup, listing, and rotation behavior. |
| cmd/entire/cli/checkpoint/v2_store_test.go | Adds tests asserting rotation triggers at threshold and not below it. |
Previously all errors from tree.File() were treated as "missing file". Now only ErrFileNotFound/ErrEntryNotFound are ignored; real failures (tree corruption, entry conflicts) are surfaced. Entire-Checkpoint: be7d8ec41404
Re-read /full/current after archiving and before resetting to orphan. If another writer advanced the ref, abort the reset to prevent making their writes unreachable. The archive ref is harmless and the next writer will trigger rotation again. Entire-Checkpoint: e118558f00d3
Check if the target archived ref exists before creating it. If another instance already rotated and created the same archive number, skip instead of overwriting. Entire-Checkpoint: 4faaf3537e42
Move timestamp updates inside the dedup guard so they reflect checkpoint creation times, not last-write times for duplicate multi-session writes. Entire-Checkpoint: 1bc2f6399ff9
Only include refs whose suffix matches the expected 13-digit format. Prevents unexpected refs under the prefix from breaking nextGenerationNumber parsing. Entire-Checkpoint: 9922d253ea7f
Iterate all archived generation names and take the max, skipping any that fail to parse instead of failing the entire rotation. Entire-Checkpoint: 58a487f7498f
Testing override only — tests are in the same package so they can set the unexported field directly. Avoids suggesting it's a supported runtime tuning knob. Entire-Checkpoint: d9436b8f2630
pfleidi
commented
Mar 26, 2026
Soph
previously approved these changes
Mar 26, 2026
Address review comments: clarify that a generation is a batch of transcripts under a single ref, and that timestamps exist for the future cleanup tool (RFD-009). Entire-Checkpoint: 948bcc63eb93
Add offset parameter to populateFullCurrent so sequential rotation tests generate unique IDs per cycle, avoiding accidental collisions. Entire-Checkpoint: 3288358d689d
computermode
approved these changes
Mar 26, 2026
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.
Summary
Implements generational rotation for the v2
/full/currentref (task A6 from the checkpoints v2 design spec). When/full/currentaccumulates >= 100 checkpoints, it is archived as a numbered ref and a fresh orphan is created.generation.jsonat tree root tracks checkpoint IDs and timestamps, updated on everyWriteCommitted(skipped forUpdateCommittedsince that's stop-time finalization, not a new checkpoint)refs/entire/checkpoints/v2/full/0000000000001, create fresh orphan/full/currentwith seedgeneration.json/full/currentbefore archiving to skip if another instance already rotatedTranscriptLinesAtStartfrom v2 metadata writes (v2 is a clean break)New files
checkpoint/v2_generation.go—GenerationMetadatatype, read/write helpers, rotation, archived generation listingcheckpoint/v2_generation_test.go— 17 unit testsModified files
paths/paths.go—V2FullRefPrefix,GenerationFileNameconstantscheckpoint/v2_store.go—MaxCheckpointsPerGenerationfield for testabilitycheckpoint/v2_committed.go— generation tracking + rotation check wired into write pathcheckpoint/v2_store_test.go— 2 integration tests for rotation triggeringTest plan
mise run test:cipasses (unit + integration + E2E canary)mise run lintclean🤖 Generated with Claude Code
Note
Medium Risk
Adds automatic archival/rotation of the v2
refs/entire/checkpoints/v2/full/currentref based on checkpoint count, which changes git ref/tree update behavior and could impact transcript retention if bugs exist. Risk is mitigated by extensive new unit/integration tests and making rotation non-fatal to the write path.Overview
Adds generation tracking + rotation for v2 raw transcript storage under
/full/current: eachWriteCommittednow updates a rootgeneration.json(checkpoint IDs + oldest/newest timestamps) and, once the checkpoint count hits a threshold (default 100), archives the current ref as a numberedrefs/entire/checkpoints/v2/full/<NNN...>and resets/full/currentto a fresh orphan commit.Introduces new generation/rotation helpers on
V2GitStore(including archived generation discovery and sequential numbering), a test-onlyMaxCheckpointsPerGenerationoverride, and new path constants (V2FullRefPrefix,GenerationFileName). Also drops writing the deprecatedTranscriptLinesAtStartfield in v2 committed metadata and adds comprehensive tests covering metadata updates, deduping, rotation mechanics, and threshold behavior.Written by Cursor Bugbot for commit 3dd257d. Configure here.