Skip to content

fix: skip empty v1 orphan seed under git-refs backend#1819

Merged
gtrrz-victor merged 1 commit into
mainfrom
fix/git-refs-skip-v1-orphan-seed
Jul 21, 2026
Merged

fix: skip empty v1 orphan seed under git-refs backend#1819
gtrrz-victor merged 1 commit into
mainfrom
fix/git-refs-skip-v1-orphan-seed

Conversation

@gtrrz-victor

@gtrrz-victor gtrrz-victor commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/910

Problem

Running entire enable and selecting the git-refs checkpoint backend still created an empty entire/checkpoints/v1 branch — surprising, since git-refs writes checkpoints to per-checkpoint refs and never touches v1.

Root cause

The enable-time seed step EnsureSetupEnsurePrimaryRef (cmd/entire/cli/strategy/common.go) is backend-agnostic: it resolves the target ref via the hardcoded checkpoint.ResolveRefs (always entire/checkpoints/v1) and never consults checkpoints.primary. On a freshly git init'd folder with no origin and no checkpoint_remote, it falls through to createOrphanMetadataRef, unconditionally creating a vestigial empty orphan v1 that git-refs never writes to.

The git-refs backend selection is persisted correctly to settings.json before this runs — it's not a timing/ordering bug. The seed simply ignores the setting.

Fix

Gate the empty-orphan fallback in EnsurePrimaryRef on the primary backend. Under git-refs, skip the orphan seed. Scope kept minimal:

  • Only the empty-orphan creation is suppressed.
  • Adoption of real existing v1 data from origin / a checkpoint_remote is preserved, so legacy checkpoints stay readable.
  • Fail-soft: a config-load error keeps the legacy git-branch seeding behavior.
  • Reuses the existing checkpoint.PrimaryIsRefs predicate.

Test

New subtest TestEnsurePrimaryRef/skips_empty_orphan_when_primary_is_git-refs: writes a repo-local settings.json with git-refs primary, runs EnsurePrimaryRef, asserts no v1 branch is created. Red before the fix, green after.

Verification

  • go test ./cmd/entire/cli/strategy/ — pass
  • mise run fmt — applied
  • golangci-lint v2.11.3 on the package — 0 issues

🤖 Generated with Claude Code


Note

Low Risk
Localized setup-path change in EnsurePrimaryRef with fail-soft config handling and a focused regression test; no auth or data-migration logic.

Overview
EnsurePrimaryRef no longer seeds an empty entire/checkpoints/v1 orphan when checkpoints primary is git-refs, fixing entire enable creating a vestigial v1 branch even though that backend only uses per-checkpoint refs.

A new primaryIsGitRefs helper reads repo-local checkpoints config (fail-soft: load errors keep legacy git-branch behavior) and gates only the empty-orphan fallbacks—after a failed/missing checkpoint_remote bootstrap and when there is no local or origin ref. Adopting existing v1 data from origin or checkpoint_remote is unchanged so legacy checkpoints stay readable.

A TestEnsurePrimaryRef subtest asserts that with {"checkpoints":{"primary":{"type":"git-refs"}}} in .entire/settings.json, no v1 branch is created on a fresh repo.

Reviewed by Cursor Bugbot for commit bbc8a77. Configure here.

`entire enable` selecting the git-refs checkpoint backend still created an
empty `entire/checkpoints/v1` branch. The enable-time seed step
(EnsureSetup -> EnsurePrimaryRef) resolves the target ref via the hardcoded
checkpoint.ResolveRefs (always v1) and never consults the configured backend,
so on a freshly git-init'd folder with no origin it unconditionally created a
vestigial empty orphan v1 that git-refs never writes to.

Gate the empty-orphan fallback in EnsurePrimaryRef on the primary backend:
under git-refs, skip creating the orphan. Adoption of real existing v1 data
from origin or a checkpoint_remote is preserved so legacy checkpoints stay
readable. Resolution is fail-soft — a config-load error keeps the legacy
git-branch seeding behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 01KY223K2WZPQN3GGTQK15MJX8
Copilot AI review requested due to automatic review settings July 21, 2026 10:04
@gtrrz-victor
gtrrz-victor requested a review from a team as a code owner July 21, 2026 10:04

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

This PR fixes an enable-time behavior where selecting the git-refs checkpoint backend still seeded an empty entire/checkpoints/v1 metadata branch. Since git-refs stores checkpoints in per-checkpoint refs and does not write to the v1 branch, the change prevents creation of a vestigial empty v1 branch while still preserving adoption of existing v1 data from origin or a configured checkpoint_remote.

Changes:

  • Add a fail-soft config check to detect when the primary checkpoint backend is git-refs.
  • Update EnsurePrimaryRef to skip the “create empty orphan v1” fallback when the primary backend is git-refs (but still bootstrap/adopt real v1 data when present).
  • Add a regression test covering the git-refs primary case to assert no v1 branch is created.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/entire/cli/strategy/common.go Gates empty-orphan v1 seeding in EnsurePrimaryRef when primary backend is git-refs, while keeping existing remote adoption behavior.
cmd/entire/cli/strategy/common_test.go Adds a subtest ensuring EnsurePrimaryRef does not create entire/checkpoints/v1 when the repo’s primary backend is configured as git-refs.

@gtrrz-victor
gtrrz-victor merged commit d777af9 into main Jul 21, 2026
12 checks passed
@gtrrz-victor
gtrrz-victor deleted the fix/git-refs-skip-v1-orphan-seed branch July 21, 2026 11:40
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