remove checkpoint version fallback helper · Entire

remove checkpoint version fallback helper

9994d75→main·

pfleidi·2w ago·5 files·+24 added/-32 removed

Use normalized policy values directly at checkpoint write call sites.

This keeps unsupported policy decisions in CanSatisfyPolicy instead of hiding them behind a version accessor.

Sessions

76a5489de55eView transcript

[?
Enforce Checkpoint Policies in CLICodex·GPT-5.5·5 steps](/content/gh/entireio/cli/session/019f05ad-eea0-7202-a508-ec34d069a2d2#timeline-76a5489de55e/index.html)

Changes

5

95 unmodified lines

96
97
98
99
99
100
101
102

95 unmodified lines

}

effectivePolicy := checkpointpolicy.Normalize(state.Policy)
    fmt.Fprintf(cmd.OutOrStdout(), "checkpoint_version: %s\n", formatCheckpointVersionPolicyValue(state.Policy.CheckpointVersion, checkpointpolicy.CheckpointVersion(state.Policy)))
    fmt.Fprintf(cmd.OutOrStdout(), "checkpoint_version: %s\n", formatCheckpointVersionPolicyValue(state.Policy.CheckpointVersion, effectivePolicy.CheckpointVersion))
    fmt.Fprintf(cmd.OutOrStdout(), "checkpoint_min_version: %s\n", formatCheckpointPolicyValue(state.Policy.CheckpointMinVersion, effectivePolicy.CheckpointMinVersion))
    fmt.Fprintf(cmd.OutOrStdout(), "source: %s\n", state.Source)
    return nil

Mcmd/entire/cli/checkpoint_policy.go+1/-1

22 unmodified lines

23
24
25
26
26
27
28
29

22 unmodified lines

if !checkpointpolicy.CanSatisfyPolicy(policy) {
        return "", unsupportedCheckpointPolicyError(policy)
    }
    return checkpointpolicy.CheckpointVersion(policy), nil
    return checkpointpolicy.Normalize(policy).CheckpointVersion, nil
}

func ensureCheckpointPolicyAllowsCheckpointData(ctx context.Context, repo *git.Repository) error {

Mcmd/entire/cli/checkpoint_policy_write.go+1/-1

32 unmodified lines

33
34
35
36
37
38
39
40
41
42
43
44
36
37
38

32 unmodified lines

return policy
}

func CheckpointVersion(policy Policy) string {
    policy = Normalize(policy)
    version, err := ParseFormat(policy.CheckpointVersion)
    if err != nil || !CanWrite(version) {
        return DefaultCheckpointVersion()
    }
    return policy.CheckpointVersion
}

func ValidatePolicy(policy Policy) error {
    policy = Normalize(policy)

Mcmd/entire/cli/checkpointpolicy/policy.go-9

14 unmodified lines

15
16
17
18
18
19
20
21
22
23
21
22
23
24
25
26
27
28
26
27
28
29
30
31
32
33
31
32
33
34
35
36
37
38
36
37
38
39
40
41
42
43
44
45
40
41
42
43
44
46
47
48
49
49
50
50
51
52
53
54

14 unmodified lines

require.Equal(t, checkpoint.CheckpointVersionBranchV1, got.CheckpointMinVersion)
}

func TestCheckpointVersion(t *testing.T) {
func TestNormalize(t *testing.T) {

t.Parallel()
tests := []struct {
    name        string
    policy      checkpointpolicy.Policy
    wantVersion string
    name string
    in   checkpointpolicy.Policy
    want checkpointpolicy.Policy
}{
    {
        name:        "default",
        policy:      checkpointpolicy.DefaultPolicy(),
        wantVersion: checkpoint.CheckpointVersionBranchV1,
        name: "default",
        in:   checkpointpolicy.DefaultPolicy(),
        want: checkpointpolicy.DefaultPolicy(),
    },
    {
        name:        "missing version",
        policy:      checkpointpolicy.Policy{CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1},
        wantVersion: checkpoint.CheckpointVersionBranchV1,
        name: "missing version",
        in:   checkpointpolicy.Policy{CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1},
        want: checkpointpolicy.DefaultPolicy(),
    },
    {
        name:        "unsupported configured version",
        policy:      checkpointpolicy.Policy{CheckpointVersion: "refs-v1", CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1},
        wantVersion: checkpoint.CheckpointVersionBranchV1,
        name: "configured versions",
        in: checkpointpolicy.Policy{
            CheckpointVersion:    "refs-v1",
            CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1,
        },
        want: checkpointpolicy.Policy{
            CheckpointVersion:    "refs-v1",
            CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1,
        },
    },
    {
        name:        "invalid configured version",
        policy:      checkpointpolicy.Policy{CheckpointVersion: "invalid", CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1},
        wantVersion: checkpoint.CheckpointVersionBranchV1,
    },
}
for _, tt := range tests {
    t.Run(tt.name, func(t *testing.T) {
        t.Parallel()
        got := checkpointpolicy.CheckpointVersion(tt.policy)
        require.Equal(t, tt.wantVersion, got)
        got := checkpointpolicy.Normalize(tt.in)
        require.Equal(t, tt.want, got)
    })
}
}

Mcmd/entire/cli/checkpointpolicy/policy_test.go+21/-20

155 unmodified lines

156 157 158 159 159 160 161 162

155 unmodified lines

warnIfCheckpointPolicyNeedsUpgrade(logCtx, policy) return nil, errors.New("checkpoint policy cannot be satisfied by this Entire CLI") } checkpointVersion := checkpointpolicy.CheckpointVersion(policy) checkpointVersion := checkpointpolicy.Normalize(policy).CheckpointVersion

shadowBranchName := getShadowBranchNameForCommit(state.BaseCommit, state.WorktreeID) ref, hasShadowBranch := resolveShadowRef(repo, shadowBranchName, o.shadowRef)


Mcmd/entire/cli/strategy/manual_commit_condensation.go+1/-1