Add hidden doctor rewrite-checkpoints test tooling (git-branch β git-refs)#1628
Add hidden doctor rewrite-checkpoints test tooling (git-branch β git-refs)#1628Soph wants to merge 3 commits into
doctor rewrite-checkpoints test tooling (git-branch β git-refs)#1628Conversation
β¦ch β git-refs) Test tooling for evaluating the git-refs store against real branch data. It re-materializes every checkpoint on the entire/checkpoints/v1 branch as a per-checkpoint ref by re-driving the git-refs store's write path: - Per session it replays the transcript (regenerating the compact transcript.jsonl), prompts, and metadata through Write, so the tree is rooted at the checkpoint (no shard folders) and SessionFilePaths/CompactTranscriptStart are correct by construction. Per-session summaries and combined attribution are replayed; a tasks/ subtree is grafted in unchanged. - The checkpoint id is preserved, and each commit keeps the original author β read from the v1-branch commit that wrote the session (metadata carries no author), falling back to the repo git author. The command is hidden and writes refs locally without pushing (test tooling for now). Idempotent: existing refs are skipped unless --force; --dry-run reports without writing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: b33b68817ca3
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
β Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 07aac08. Configure here.
| Strategy: m.Strategy, | ||
| Branch: m.Branch, | ||
| Transcript: redact.AlreadyRedacted(content.Transcript), | ||
| Prompts: []string{content.Prompts}, |
There was a problem hiding this comment.
Prompt replay skips SplitPromptContent
Medium Severity
Session replay wraps the entire prompt.txt blob in a one-element Prompts slice instead of deserializing with SplitPromptContent. That can emit a spurious prompt file when the session had none, and re-runs RedactedJoinedPrompts on already-persisted prompt text instead of the original prompt list.
Reviewed by Cursor Bugbot for commit 07aac08. Configure here.
| CheckpointTranscriptStart: m.CheckpointTranscriptStart, | ||
| TokenUsage: m.TokenUsage, | ||
| SkillEvents: m.SkillEvents, | ||
| })); err != nil { |
There was a problem hiding this comment.
Replay omits session metadata fields
Medium Severity
The Session replay copies only a subset of fields from content.Metadata into WriteOptions. Session-level initial_attribution, prompt_attributions, session_metrics, kind, and review/investigate metadata are not forwarded, so rewritten refs can differ from the git-branch checkpoint the tool is meant to evaluate.
Reviewed by Cursor Bugbot for commit 07aac08. Configure here.
There was a problem hiding this comment.
Pull request overview
Adds hidden βdoctor rewrite-checkpointsβ tooling to replay legacy entire/checkpoints/v1 (git-branch) checkpoints through the git-refs store write path, materializing per-checkpoint refs for evaluation/testing.
Changes:
- Wires a hidden
entire doctor rewrite-checkpointsCobra subcommand intodoctor. - Implements
checkpoint.RewriteBranchToRefsto walk v1 shard trees and rewrite each checkpoint intorefs/entire/checkpoints/<shard>/<id>by replaying session writes/summaries/attribution and grafting anytasks/subtree. - Adds self-contained unit tests covering rewrite behavior (read-back via git-refs store, idempotency/
--force, multi-session, dry-run, and missing v1 branch).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cmd/entire/cli/doctor.go | Registers the new hidden doctor subcommand. |
| cmd/entire/cli/doctor_rewrite.go | Implements the hidden CLI command and user-facing output for rewrite results. |
| cmd/entire/cli/checkpoint/rewrite.go | Core rewrite logic: branch β refs replay, author preservation, tasks grafting. |
| cmd/entire/cli/checkpoint/rewrite_test.go | Unit tests validating rewrite behavior and flags. |
| Strategy: m.Strategy, | ||
| Branch: m.Branch, | ||
| Transcript: redact.AlreadyRedacted(content.Transcript), | ||
| Prompts: []string{content.Prompts}, |
| if !dryRun && len(result.Rewritten) > 0 { | ||
| fmt.Fprintln(out, "Refs written locally under refs/entire/checkpoints/ β not pushed.") | ||
| } |
| This is test tooling for evaluating the git-refs store against real branch data: | ||
| it writes refs locally and does not push them. Idempotent β checkpoints that | ||
| already have a ref are skipped (use --force to re-materialize from scratch).`, |
- Split the stored prompt blob back into the original prompt list via SplitPromptContent instead of wrapping it in a one-element slice β so an empty prompt file stays empty and RedactedJoinedPrompts reconstructs the original prompts (and count) rather than re-redacting the joined text. [cursor] - Forward the remaining session-level fields the replay dropped β Attribution, PromptAttributions, SessionMetrics, Kind, ReviewPrompt/Skills, Investigate run/topic, and the root HasReview/HasInvestigation flags β so a rewritten ref matches the branch checkpoint the tool evaluates. [cursor] Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 78d184424eb8
β¦graft) - Collapse the fallback name/email into a commitAuthor and extract resolveAuthor, shrinking rewriteCheckpoint's parameter list and de-duplicating the per-session and tasks-graft author fallback. - Compute the ref name once in the walk and thread it through rewriteCheckpoint and graftTasksSubtree instead of recomputing RefName three times per checkpoint. - Graft tasks with a single UpdateSubtree(MergeKeepExisting) call β splicing the tasks/ entry into the root tree so sibling session subtrees keep their hashes β instead of flattening and rebuilding the whole tree. - Reset the ref only under --force (the non-force existing-ref case is already skipped by the caller), dropping a redundant check. - Add a graft test covering the tasks splice (tasks/ added, existing entries preserved, checkpoint still reads back). Skipped as out of scope for hidden test tooling: adding a tasks WriteRequest type / AuthorReader.GetSessionAuthor, and dropping the deliberate metadata forwarding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 48ce721ba1a2


https://entire.io/gh/entireio/cli/trails/752
Hidden test tooling for evaluating the git-refs checkpoint store against real branch data: it re-materializes every checkpoint on the
entire/checkpoints/v1branch as a per-checkpoint ref by re-driving the git-refs store's write path. Independent of the (still-undecided) byte-identical migration β standalone offmain.What it does
entire doctor rewrite-checkpoints(hidden). For each checkpoint on the v1 branch:Write, so the compacttranscript.jsonlis regenerated, the tree is rooted at the checkpoint (no shard folders), andSessionFilePaths/CompactTranscriptStartare correct by construction.tasks/subtree in unchanged.It writes refs locally and does not push (test tooling for now). Idempotent: existing refs are skipped unless
--force;--dry-runreports without writing.Testing
rewrite_test.go(self-contained): root-flat layout + reads back via the git-refs store, author preserved from the branch commit, idempotency +--force, multi-session replay, dry-run/no-branch. Build clean, lint 0, checkpoint + cli suites pass.Notes
transcript.jsonlregeneration is best-effort (same as native git-refs writes) β produced when the transcript is compactable.π€ Generated with Claude Code
Note
Medium Risk
Rewrites local git refs and checkpoint object graphs; mistakes could corrupt local checkpoint data, but the command is hidden, local-only, and positioned as evaluation tooling rather than a supported migration.
Overview
Introduces hidden test tooling to copy checkpoints from the legacy
entire/checkpoints/v1git-branch layout into per-checkpoint refs (refs/entire/checkpoints/...) by replaying the git-refs storeβs write pathβnot a byte copy.checkpoint.RewriteBranchToRefswalks v1 shard trees, skips checkpoints that already have a ref (unless--force), and for each checkpoint replays sessions (regenerating compacttranscript.jsonl), summaries, and combined attribution at a root-flat ref tree, preserves checkpoint IDs, and restores session commit authors from v1 branch history (with repo author fallback). Existing refs are removed before replay when rewriting; anytasks/subtree is grafted unchanged. Supports dry-run and returns counts of total, rewritten, and skipped.entire doctor rewrite-checkpointswires this up (hidden from help), opens the repo, prints a short summary, and notes refs are written locally only.rewrite_test.gocovers happy path, idempotency/force, multi-session, dry-run, and missing v1 branch.Reviewed by Cursor Bugbot for commit 07aac08. Configure here.