Skip to content

Add Go v2 checkpoint migration tool#1270

Draft
pfleidi wants to merge 41 commits into
mainfrom
tmp-migrate-v2-script-go
Draft

Add Go v2 checkpoint migration tool#1270
pfleidi wants to merge 41 commits into
mainfrom
tmp-migrate-v2-script-go

Conversation

@pfleidi
Copy link
Copy Markdown
Contributor

@pfleidi pfleidi commented May 26, 2026

What

Adds a Go-based migration binary under cmd/migrate-v2-checkpoints to restore useful v2-only checkpoint data into v1 storage. It reuses the existing checkpoint stores instead of line-for-line porting the shell script.

How

  • Adds optional commit timestamp support to committed checkpoint writes.
  • Discovers checkpoint trailers in branch history after a selected base commit.
  • Reads v2 metadata and raw transcript content through the v2 store.
  • Writes restored v1 checkpoints through the production v1 GitStore path.
  • Supports list, dry-run, and apply modes with skipped-data reporting.
  • Adds focused tests for timestamp preservation, discovery, migration, dry-run, existing v1 data, and incomplete v2 data.

Notes

The migration intentionally skips transcript data that lacks usable v2 metadata, since that data is not useful for v1 restoration by itself.

Verification

  • mise run lint
  • go build -ldflags "-X github.com/entireio/cli/cmd/entire/cli/versioninfo.Version=v0.0.0-dev-9df43932c -X github.com/entireio/cli/cmd/entire/cli/versioninfo.Commit=9df43932c" -o /private/tmp/entire-pr-check ./cmd/entire
  • go build -o /private/tmp/migrate-v2-checkpoints-pr-check ./cmd/migrate-v2-checkpoints
  • go test ./cmd/entire/cli/checkpoint ./cmd/migrate-v2-checkpoints -count=1

Note

Medium Risk
Apply mode rewrites the v1 metadata branch from discovered v2 data; mistakes could affect checkpoint history, though dry-run and skip-existing-session behavior limit exposure.

Overview
Adds a migrate-v2-checkpoints CLI that discovers checkpoints from Entire-Checkpoint trailers in normal branch history (with --since, --head, list / dry-run / apply) and restores eligible v2 sessions into v1 via the existing GitStore / V2GitStore paths, skipping sessions already on v1 and reporting missing v2 metadata or raw transcripts.

Committed checkpoint writes gain optional CommitTime so metadata-branch commits can keep historical author/committer times during migration (zero still means “now”; CreatedAt is not reused as the git timestamp). Checkpoint pushes now use an explicit refs/heads/…:refs/heads/… refspec so stale refs/entire/checkpoints/v1 refs cannot make the source branch ambiguous.

Reviewed by Cursor Bugbot for commit f5ef3ca. Configure here.

Copilot AI review requested due to automatic review settings May 26, 2026 23:02
Comment thread cmd/migrate-v2-checkpoints/migration.go
Comment thread cmd/migrate-v2-checkpoints/history.go
Entire-Checkpoint: 0fc8bb5eb2ef
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 standalone Go migration binary (cmd/migrate-v2-checkpoints) that discovers Entire-Checkpoint trailers in git history and restores v2-only checkpoint/session data back into the production v1 checkpoint store, including preserving historical commit timestamps when writing to the v1 metadata branch.

Changes:

  • Introduces migrate-v2-checkpoints with list/plan/dry-run/apply modes, repo opening, checkpoint discovery, and migration reporting.
  • Implements checkpoint discovery by scanning git history tips for Entire-Checkpoint trailers and associating checkpoint IDs with commits.
  • Extends v1 committed checkpoint writes with optional CommitTime, wiring it through commit creation and adding focused tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/migrate-v2-checkpoints/main.go Adds CLI entrypoint, flag parsing, repo opening, and mode dispatch for migration.
cmd/migrate-v2-checkpoints/history.go Implements checkpoint trailer discovery by scanning reachable commits from selected history tips.
cmd/migrate-v2-checkpoints/migration.go Implements v2→v1 migration logic and prints a summary report.
cmd/migrate-v2-checkpoints/main_test.go Adds end-to-end tests for discovery, dry-run, apply, idempotency, and missing-data handling.
cmd/entire/cli/checkpoint/checkpoint.go Extends WriteCommittedOptions with CommitTime.
cmd/entire/cli/checkpoint/committed.go Uses CommitTime (or now) when creating metadata-branch commits; factors commit creation into a helper.
cmd/entire/cli/checkpoint/temporary.go Routes commit creation through the new commit-time-aware helper.
cmd/entire/cli/checkpoint/committed_commit_time_test.go Adds tests validating commit timestamp preservation vs “use current time” behavior.

Comment thread cmd/migrate-v2-checkpoints/migration.go Outdated
Comment thread cmd/migrate-v2-checkpoints/history.go
Comment thread cmd/migrate-v2-checkpoints/history.go Outdated
@pfleidi
Copy link
Copy Markdown
Contributor Author

pfleidi commented May 26, 2026

Bugbot run

Comment thread cmd/migrate-v2-checkpoints/migration.go
Comment thread cmd/migrate-v2-checkpoints/migration.go Outdated
pfleidi added 3 commits May 26, 2026 16:27
Entire-Checkpoint: ec521d6d285c
Entire-Checkpoint: 592345236abe
Entire-Checkpoint: 962df06c99d3
@pfleidi pfleidi changed the base branch from tmp-migrate-v2-script to main May 27, 2026 00:48
@pfleidi
Copy link
Copy Markdown
Contributor Author

pfleidi commented May 27, 2026

Bugbot run

Comment thread cmd/migrate-v2-checkpoints/migration.go Outdated
pfleidi added 2 commits May 27, 2026 10:57
Entire-Checkpoint: d4f016669f04
Open the migration tool's repository via gitrepo.OpenPath so shared
clones with object alternates resolve correctly instead of silently
downgrading to PlainOpen.

Inline single-call forwarders in migration.go and drop the redundant
second hasRequiredV2Metadata check — both v2 session reads parse the
same metadata.json. Inline stringly-typed flag-name constants in the
migrate tests, and collapse refHeadCommit into its sole caller.

Entire-Checkpoint: 1a30a6f9fdcd
@pfleidi pfleidi requested a review from Copilot May 27, 2026 20:14
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 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread cmd/migrate-v2-checkpoints/main.go
Comment thread cmd/migrate-v2-checkpoints/v2_fixture_test.go
Comment thread cmd/migrate-v2-checkpoints/history.go Outdated
Comment thread cmd/migrate-v2-checkpoints/history.go
Entire-Checkpoint: b01e75e8d461
@pfleidi
Copy link
Copy Markdown
Contributor Author

pfleidi commented May 27, 2026

Bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 1 potential issue.

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 f5ef3ca. Configure here.

Comment thread cmd/migrate-v2-checkpoints/history.go
pfleidi added 20 commits May 27, 2026 13:36
Entire-Checkpoint: a458a0437dc3
Entire-Checkpoint: 93e1fd5362dc
Entire-Checkpoint: e699268f21c8
Entire-Checkpoint: 3b731107bd53
Entire-Checkpoint: 0b3b7a44bfd6
Entire-Checkpoint: 1db8610b3316
Entire-Checkpoint: 238dcfa519fc
Entire-Checkpoint: 1d716c292e2f
Entire-Checkpoint: 3141746402c0
Entire-Checkpoint: 5b8d4688d945
Entire-Checkpoint: b13ed8c7932b
Entire-Checkpoint: 54aa5a6f6fb1
Entire-Checkpoint: 912a3eb7de7e
Entire-Checkpoint: 70b0acc0e628
Entire-Checkpoint: eedb9b4ae0cc
Entire-Checkpoint: 13bdc2a14cbd
Entire-Checkpoint: c58d83f4bb9a
Entire-Checkpoint: 77778444950d
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.

3 participants