(Do not merge) One-time migration script for v2 checkpoints to v1#1257
(Do not merge) One-time migration script for v2 checkpoints to v1#1257computermode wants to merge 2 commits into
Conversation
Entire-Checkpoint: c9bc625237a6
Entire-Checkpoint: e25de9aab773
There was a problem hiding this comment.
Pull request overview
Adds a standalone, one-time Bash script to migrate legacy v2 checkpoint artifacts (raw transcripts + companion metadata) into the v1 checkpoint tree and optionally write a single migration commit updating refs/heads/entire/checkpoints/v1.
Changes:
- Introduces
scripts/migrate-v2-checkpoints-to-v1.shwith modes to list, dry-run, or apply a migration. - Scans git history for
Entire-Checkpoint: <12-hex>trailers and maps them to v2full/*andmainref artifacts. - (On
--apply) rewrites checkpoint-levelmetadata.jsonto include discovered session entries and writes a migration commit.
| main_metadata_file="" | ||
|
|
||
| show_help() { | ||
| sed -n '3,/^$/p' "$0" | sed -E 's/^# ?//' |
|
|
||
| git log HEAD --branches --remotes --format='__ENTIRE_COMMIT__%H%n%B' --not "$since" | |
| tree_path_exists() { | ||
| local ref_name="$1" | ||
| local path="$2" | ||
| git cat-file -e "${ref_name}:${path}" 2>/dev/null | ||
| } | ||
|
|
||
| list_numeric_dirs() { | ||
| local ref_name="$1" | ||
| local path="$2" | ||
| local entries | ||
| entries=$(git ls-tree -d --name-only "${ref_name}:${path}" 2>/dev/null || true) | ||
| printf '%s\n' "$entries" | sed -nE '/^[0-9]+$/p' | ||
| } | ||
|
|
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 1ea7f14. Configure here.
| END { | ||
| print count + 0 | ||
| } | ||
| ' "$raw_checkpoint_ids_file" "$checkpoint_ids_file") |
There was a problem hiding this comment.
Empty first file breaks NR==FNR diagnostic counts
Low Severity
The NR == FNR awk idiom in compute_plan_counts silently produces wrong results when the first file is empty. If raw_checkpoint_ids_file is empty (no raw transcripts found in any full ref) or main_metadata_file is empty (e.g., V2_MAIN_REF doesn't exist), awk treats the second file as the first, routing all its lines into the lookup-building block instead of the counting block. This makes missing_raw_checkpoints, missing_metadata_checkpoints, and missing_metadata_sessions all incorrectly report 0, suppressing the corresponding warning messages that inform the user about skipped checkpoints or missing metadata.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 1ea7f14. Configure here.
| local entries | ||
| entries=$(git ls-tree -d --name-only "${ref_name}:${path}" 2>/dev/null || true) | ||
| printf '%s\n' "$entries" | sed -nE '/^[0-9]+$/p' | ||
| } |
There was a problem hiding this comment.
Three helper functions defined but never called
Low Severity
tree_path_exists, list_numeric_dirs, and v1_raw_artifact_name are defined but never invoked anywhere in the script. The artifact-name mapping logic in v1_raw_artifact_name is duplicated inline within the awk block of write_full_artifact_index. These dead functions add noise for anyone reading or maintaining the script.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 1ea7f14. Configure here.


Example command:
To see all the checkpoints to migrate:
To go through a dry run:
To create the commit that copies the checkpoints from v2 to v1:
To validate:
git show --stat refs/heads/entire/checkpoints/v1To push after:
git push origin refs/heads/entire/checkpoints/v1:refs/heads/entire/checkpoints/v1Note
Medium Risk
Adds a one-off migration script that can create and update the
refs/heads/entire/checkpoints/v1ref based on parsed commit trailers and checkpoint refs; misuse could write incorrect history or overwrite the local ref.Overview
Introduces
scripts/migrate-v2-checkpoints-to-v1.sh, a standalone tool to plan or apply migration of legacy v2 checkpoint artifacts back into the v1 checkpoint tree.The script scans commits after a given
--since(optionally constrained by--head) forEntire-Checkpointtrailers, maps those checkpoint IDs to v2 data underrefs/entire/checkpoints/v2/full/*(raw transcripts + hashes), and pulls companion session/prompt metadata fromrefs/entire/checkpoints/v2/mainwhen available.It supports
--list(checkpoint IDs + commit IDs),--dry-run(print every source artifact), and--apply, which builds a new v1 tree, rewrites checkpoint-levelmetadata.jsonto include discovered sessions, and writes a single migration commit updatingrefs/heads/entire/checkpoints/v1.Reviewed by Cursor Bugbot for commit 1ea7f14. Configure here.