fix(enable): first-run refs default yields to ENTIRE_CHECKPOINTS_PRIMARY · Entire

fix(enable): first-run refs default yields to ENTIRE_CHECKPOINTS_PRIMARY

7a959ac→main· peyton-alt·11h ago·4 files·+39 added/-4 removed

The git-branch CI lanes exposed a real divergence: with the env override active (which fully replaces any settings block), first-run enable still wrote checkpoints.primary: git-refs into settings — config on disk disagreeing with the backend actually in use, and the git-branch canary lane (which relied on the old product default) asserting v1-branch behavior against refs-writing binaries.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

Changes

4

28 unmodified lines

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

28 unmodified lines

gitOutput(t, env.RepoDir, "add", "README.md")
gitOutput(t, env.RepoDir, "commit", "-m", "Initial SHA-256 commit")

// Pin the git-branch backend: this test asserts the v1-branch condensation
// flow in a SHA-256 repo, and first-run enable now defaults new setups to
// git-refs.
output := env.RunCLI(
    "enable",
    "--no-github",
    "--agent", "claude-code",
    "--telemetry=false",
    "--checkpoint-backend", "branch",
)
if !strings.Contains(output, paths.MetadataBranchName) {
    t.Fatalf("expected enable to create %s branch, got output:\n%s", paths.MetadataBranchName, output)
}

Mcmd/entire/cli/integration_test/sha256_repo_test.go+4

1244 unmodified lines

1245
1246
1247
1248
1248
1249
1250
1251
107 unmodified lines

1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
500 unmodified lines

1879
1880
1881
1868
1882
1883
1884
1885

1244 unmodified lines

// during first-time setup (the old wizard prompt), and the config-less
// runtime default stays git-branch so existing repos are untouched.
if opts.CheckpointBackend == "" && firstRun {
    opts.CheckpointBackend = checkpointBackendRefsAlias
    opts.CheckpointBackend = firstRunCheckpointBackendDefault()
}
if err := applyCheckpointBackendFlag(settings, opts.CheckpointBackend); err != nil {
    return err
}
107 unmodified lines

fmt.Fprintln(w, "\nTo add more agents, run `entire agent add <name>`.")

// firstRunCheckpointBackendDefault is the backend written on first-time
// setups when --checkpoint-backend wasn't passed: the git-refs store (a
// storage-topology question is unanswerable during first-time setup). Empty —
// write nothing — while the ENTIRE_CHECKPOINTS_PRIMARY override is active:
// the env fully replaces any settings block, so persisting a default here
// would write config that diverges from the backend actually in use (and
// break harnesses that pin git-branch via the env).
func firstRunCheckpointBackendDefault() string {
if os.Getenv(settings.EnvCheckpointsPrimary) != "" {
    return ""
}
return checkpointBackendRefsAlias
}

// runEnable flips the enabled flag to true in the scope chosen by the caller
// (see setEnabledFlag). Callers resolve the scope: runEnableOnConfiguredRepo
// uses settingsTargetFile so a bare `entire enable` targets the committed
500 unmodified lines

// runs otherwise get the git-refs backend written explicitly, matching the
// interactive setup path (runEnableInteractive).
if opts.CheckpointBackend == "" && firstRun {
    opts.CheckpointBackend = checkpointBackendRefsAlias
    opts.CheckpointBackend = firstRunCheckpointBackendDefault()
}
if err := applyCheckpointBackendFlag(targetSettings, opts.CheckpointBackend); err != nil {
    return err
}

Mcmd/entire/cli/setup.go+16/-2

3912 unmodified lines

3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932

3912 unmodified lines

}
})

t.Run("env override suppresses the first-run default", func(t *testing.T) {
    setupTestRepo(t)
    stubLadder(t)
    // ENTIRE_CHECKPOINTS_PRIMARY fully replaces the settings block, so
    // writing the refs default under it would persist config diverging
    // from the backend actually in use (and break harnesses pinning
    // git-branch via the env).
    t.Setenv(settings.EnvCheckpointsPrimary, "git-branch")
    cfg := enable(t, EnableOptions{Yes: true, Telemetry: true})
    if cfg != nil {
        t.Errorf("Checkpoints = %+v, want none written under the env override", cfg)
    }
})

t.Run("re-run of an existing config-less repo stays config-less", func(t *testing.T) {
    setupTestRepo(t)
    // A repo set up before this change: settings.json exists, no

Mcmd/entire/cli/setup_test.go+14

43 unmodified lines

44
45
46
47
48
47
48
49
50
51
52
53
54

43 unmodified lines

// Select the checkpoint storage backend for the whole suite. E2E_CHECKPOINT_STORE
// (e.g. "git-refs") maps to the ENTIRE_CHECKPOINTS_PRIMARY override the spawned
// binary honors, so every condensation/read/push in the run exercises that
// backend. Unset or "git-branch" leaves the default branch backend in place.
if store := os.Getenv("E2E_CHECKPOINT_STORE"); store != "" && store != "git-branch" {
// backend. "git-branch" is mapped explicitly too — first-run enable defaults
// new setups to git-refs, so the branch mode must be pinned rather than
// relying on the product default (the env also suppresses that first-run
// settings write). Unset leaves the product defaults in place.
if store := os.Getenv("E2E_CHECKPOINT_STORE"); store != "" {
    os.Setenv("ENTIRE_CHECKPOINTS_PRIMARY", store)
}

Me2e/tests/main_test.go+5/-2