fix: enable creates local metadata branch from remote when available#511
fix: enable creates local metadata branch from remote when available#511
Conversation
When `entire enable` runs in a cloned repo that already has origin/entire/checkpoints/v1, it was creating an empty orphan branch that shadowed the remote data. This caused `entire explain` (and other checkpoint lookups) to fail with "checkpoint not found" because getSessionsBranchTree() found the empty local branch first. Now EnsureMetadataBranch() checks for the remote-tracking branch and creates the local branch from it, preserving existing checkpoint data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 2865d24ae758
PR SummaryLow Risk Overview Adds coverage for both paths with a new Written by Cursor Bugbot for commit 9017787. Configure here. |
There was a problem hiding this comment.
Pull request overview
Fixes entire enable behavior in cloned repos where origin/entire/checkpoints/v1 already exists: instead of creating an empty orphan branch that shadows existing remote metadata, the CLI now seeds the local metadata branch from the remote-tracking ref when available.
Changes:
- Update
EnsureMetadataBranch()to check fororigin/entire/checkpoints/v1and create the localentire/checkpoints/v1ref pointing at the same commit. - Retain the existing behavior of creating an empty orphan branch only when neither local nor remote-tracking metadata refs exist.
- Adjust function comment to reflect the new behavior (remote-first, orphan fallback).
|
bugbot run |
When enable creates an empty orphan entire/checkpoints/v1 branch, it shadows the remote-tracking branch that getSessionsBranchTree() would otherwise fall back to, breaking commands like explain. Fix EnsureMetadataBranch to detect when the local branch is an empty orphan and the remote has real checkpoint data, and update accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: d9f7d656b38d
Use git CLI for test setup instead of manual plumbing objects. Reuse initTestRepo helper for the no-remote case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 80e4ad299ce1
Remove scenario 2 (updating empty orphan from remote) — that will be a separate PR. This PR now only adds the remote-tracking branch check for repos where the local branch doesn't exist yet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: ca672efb0556
CI runners don't have global git user.name/user.email configured, causing the test commit to fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 35b128464ad9
|
@cursor review |
Return wrapped errors for unexpected failures when checking local and remote metadata branch refs, instead of silently falling through. Only fall back to orphan creation when refs are genuinely absent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 5cf83f1be508
|
bugbot run |
Problem
When
entire enableruns,EnsureMetadataBranch()creates the localentire/checkpoints/v1branch. Previously it always created an empty orphan, even whenorigin/entire/checkpoints/v1exists with real checkpoint data. This empty local branch shadows the remote —getSessionsBranchTree()finds the empty local first and never falls back to the remote, breakingentire explainwith "checkpoint not found".Reproduction:
git clonea repo that hasentire/checkpoints/v1on the remoteentire explain --commit <hash>→ works (falls back to remote ref)entire enable→ creates empty orphan local branchentire explain --commit <hash>→ fails (finds empty local, never checks remote)Fix
EnsureMetadataBranch()now checks fororigin/entire/checkpoints/v1before creating an empty orphan. If the remote branch exists, the local branch is created pointing to the same commit, preserving all checkpoint data.Test plan
TestEnsureMetadataBranch/creates_from_remote_on_fresh_clone— local created from remote with data intactTestEnsureMetadataBranch/creates_empty_orphan_when_no_remote— unchanged behavior when no remotegit clonefrom GitHub →enable→explainworks🤖 Generated with Claude Code