fix: pass fetched ref to metadata reconciliation for checkpoint URL flow#836
fix: pass fetched ref to metadata reconciliation for checkpoint URL flow#836
Conversation
ReconcileDisconnectedMetadataBranch was hardcoded to check refs/remotes/origin/<branch>, but when pushing to a checkpoint URL (ENTIRE_CHECKPOINT_TOKEN flow), fetchAndMergeSessionsCommon fetches to refs/entire-fetch-tmp/<branch>. This meant reconciliation never found the remote ref and returned early, leaving a disconnected "Initialize sessions branch" orphan commit in the metadata branch history. Add a remoteRefName parameter to both IsMetadataDisconnected and ReconcileDisconnectedMetadataBranch so callers pass the actual reference to compare against. The push path now passes fetchedRefName (which is already computed as either origin or temp ref), enabling reconciliation to work correctly for both flows. Signed-off-by: Paulo Gomes <paulo@entire.io> Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 4108db521b5d
There was a problem hiding this comment.
Pull request overview
Fixes metadata-branch reconciliation when pushing via checkpoint URL (ENTIRE_CHECKPOINT_TOKEN flow) by comparing against the actual fetched reference (temp ref) instead of a hardcoded refs/remotes/origin/... remote-tracking ref.
Changes:
- Adds a
remoteRefNameparameter toIsMetadataDisconnectedandReconcileDisconnectedMetadataBranchso callers can supply the correct ref to compare against. - Updates the push fetch+merge flow to pass the computed
fetchedRefName(origin-tracking ref or temp ref) into reconciliation. - Updates doctor + unit tests, including a new test covering the temp-ref reconciliation path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/entire/cli/strategy/push_common.go | Passes the fetched ref name into metadata reconciliation during fetch+merge recovery. |
| cmd/entire/cli/strategy/metadata_reconcile.go | Extends reconciliation/disconnection APIs to accept a caller-supplied remote ref name. |
| cmd/entire/cli/strategy/metadata_reconcile_test.go | Updates tests for new signatures and adds coverage for temp-ref reconciliation behavior. |
| cmd/entire/cli/doctor.go | Updates doctor’s disconnected-metadata check/fix to pass the origin metadata remote-tracking ref explicitly. |
| // branches would silently combine unrelated histories. | ||
| if reconcileErr := ReconcileDisconnectedMetadataBranch(ctx, repo, os.Stderr); reconcileErr != nil { | ||
| if reconcileErr := ReconcileDisconnectedMetadataBranch(ctx, repo, fetchedRefName, os.Stderr); reconcileErr != nil { | ||
| return fmt.Errorf("metadata reconciliation failed: %w", reconcileErr) |
There was a problem hiding this comment.
ReconcileDisconnectedMetadataBranch always reconciles the local metadata branch (paths.MetadataBranchName), but here the remote ref passed in is derived from the generic branchName being synced. If fetchAndMergeSessionsCommon were ever used for a non-metadata branch, this would compare the metadata branch against an unrelated remote ref and could incorrectly cherry-pick onto that history. Consider either (a) guarding this call so reconciliation only runs when branchName == paths.MetadataBranchName, or (b) computing the remoteRefName specifically for the metadata branch (independent of branchName) to keep the function safe if reused.
fetchAndMergeSessionsCommon is a generic branch sync function, but ReconcileDisconnectedMetadataBranch always operates on the metadata branch (paths.MetadataBranchName). Without a guard, reusing this function for a non-metadata branch would compare the metadata branch against an unrelated remote ref, risking incorrect cherry-picks. Add a branchName == paths.MetadataBranchName check so reconciliation only runs when syncing the metadata branch. Signed-off-by: Paulo Gomes <paulo@entire.io> Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 311cbcd1ffe0
ReconcileDisconnectedMetadataBranch was hardcoded to check refs/remotes/origin/, but when pushing to a checkpoint URL (ENTIRE_CHECKPOINT_TOKEN flow), fetchAndMergeSessionsCommon fetches to refs/entire-fetch-tmp/. This meant reconciliation never found the remote ref and returned early, leaving a disconnected "Initialize sessions branch" orphan commit in the metadata branch history.
Add a remoteRefName parameter to both IsMetadataDisconnected and ReconcileDisconnectedMetadataBranch so callers pass the actual reference to compare against. The push path now passes fetchedRefName (which is already computed as either origin or temp ref), enabling reconciliation to work correctly for both flows.
Note
Medium Risk
Medium risk because it changes how git refs are selected for metadata disconnection detection/reconciliation during pushes, which can affect branch repair behavior and history if the wrong ref is passed.
Overview
Fixes metadata-branch disconnection detection/repair to work for both normal remotes and checkpoint-URL pushes.
IsMetadataDisconnectedandReconcileDisconnectedMetadataBranchnow take an explicitremoteRefName, and callers (fetchAndMergeSessionsCommonandentire doctor) pass the appropriate fetched ref (includingrefs/entire-fetch-tmp/...). Tests are updated accordingly and add coverage for reconciling against a temp fetched ref.Written by Cursor Bugbot for commit 2748ecc. Configure here.