Skip to content

Add hidden doctor rewrite-checkpoints test tooling (git-branch β†’ git-refs)#1628

Draft
Soph wants to merge 3 commits into
mainfrom
feat/checkpoint-rewrite
Draft

Add hidden doctor rewrite-checkpoints test tooling (git-branch β†’ git-refs)#1628
Soph wants to merge 3 commits into
mainfrom
feat/checkpoint-rewrite

Conversation

@Soph

@Soph Soph commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

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/v1 branch as a per-checkpoint ref by re-driving the git-refs store's write path. Independent of the (still-undecided) byte-identical migration β€” standalone off main.

What it does

entire doctor rewrite-checkpoints (hidden). For each checkpoint on the v1 branch:

  • Replays each session's transcript through Write, so the compact transcript.jsonl is regenerated, the tree is rooted at the checkpoint (no shard folders), and SessionFilePaths/CompactTranscriptStart are correct by construction.
  • Replays per-session summaries and combined attribution; grafts any tasks/ subtree in unchanged.
  • Preserves the checkpoint id, 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.
  • Fresh commits copy the data; the branch's own commits are not reused.

It writes refs locally and does not push (test tooling for now). Idempotent: existing refs are skipped unless --force; --dry-run reports 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

  • Hidden from help β€” it's evaluation tooling, not a supported migration, while the migration approach is still being decided.
  • Summary/attribution backfill commits use the repo author (consistent with the branch store's own backfills); only the session commits carry the original author.
  • transcript.jsonl regeneration 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/v1 git-branch layout into per-checkpoint refs (refs/entire/checkpoints/...) by replaying the git-refs store’s write pathβ€”not a byte copy.

checkpoint.RewriteBranchToRefs walks v1 shard trees, skips checkpoints that already have a ref (unless --force), and for each checkpoint replays sessions (regenerating compact transcript.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; any tasks/ subtree is grafted unchanged. Supports dry-run and returns counts of total, rewritten, and skipped.

entire doctor rewrite-checkpoints wires this up (hidden from help), opens the repo, prints a short summary, and notes refs are written locally only. rewrite_test.go covers happy path, idempotency/force, multi-session, dry-run, and missing v1 branch.

Reviewed by Cursor Bugbot for commit 07aac08. Configure here.

…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
@Soph Soph requested a review from a team as a code owner July 4, 2026 08:48
Copilot AI review requested due to automatic review settings July 4, 2026 08:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread cmd/entire/cli/checkpoint/rewrite.go Outdated
Strategy: m.Strategy,
Branch: m.Branch,
Transcript: redact.AlreadyRedacted(content.Transcript),
Prompts: []string{content.Prompts},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in CursorΒ Fix in Web

Reviewed by Cursor Bugbot for commit 07aac08. Configure here.

CheckpointTranscriptStart: m.CheckpointTranscriptStart,
TokenUsage: m.TokenUsage,
SkillEvents: m.SkillEvents,
})); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in CursorΒ Fix in Web

Reviewed by Cursor Bugbot for commit 07aac08. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-checkpoints Cobra subcommand into doctor.
  • Implements checkpoint.RewriteBranchToRefs to walk v1 shard trees and rewrite each checkpoint into refs/entire/checkpoints/<shard>/<id> by replaying session writes/summaries/attribution and grafting any tasks/ 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.

Comment thread cmd/entire/cli/checkpoint/rewrite.go Outdated
Strategy: m.Strategy,
Branch: m.Branch,
Transcript: redact.AlreadyRedacted(content.Transcript),
Prompts: []string{content.Prompts},
Comment on lines +65 to +67
if !dryRun && len(result.Rewritten) > 0 {
fmt.Fprintln(out, "Refs written locally under refs/entire/checkpoints/ β€” not pushed.")
}
Comment on lines +31 to +33
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).`,
Soph and others added 2 commits July 4, 2026 11:25
- 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
@Soph Soph marked this pull request as draft July 4, 2026 20:42
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.

2 participants