select checkpoint version from policy · Entire

select checkpoint version from policy

3ba0901→main·

pfleidi·3w ago·5 files·+88 added/-1 removed

Resolve the effective checkpoint_version from repo policy while falling back to the CLI default when the configured value is unsupported.

Thread the selected version through checkpoint writes so storage records the caller-selected format for new summaries.

Sessions

79be90295d5aView transcript

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

Changes

5

25 unmodified lines

26
27
28
29
30
31
32
33
34

25 unmodified lines

// Strategy is the name of the strategy that created this checkpoint
    Strategy string

// CheckpointVersion is the checkpoint metadata format for new root summaries.
    CheckpointVersion string

// Branch is the branch name where the checkpoint was created (empty if detached HEAD)
    Branch string

Mapi/checkpoint/metadata.go+3

497 unmodified lines

498
499
500
501
502
503
504
505
506

497 unmodified lines

combinedAttribution := opts.CombinedAttribution
    checkpointVersion := CheckpointVersionBranchV1
    if opts.CheckpointVersion != "" {
        checkpointVersion = opts.CheckpointVersion
    }
    hasReview := opts.HasReview
    hasInvestigation := opts.HasInvestigation
    // imported is the umbrella flag: true when any session in this checkpoint

Mcmd/entire/cli/checkpoint/persistent.go+3

119 unmodified lines

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

119 unmodified lines

}
}

func TestWriteCommittedUsesExplicitCheckpointVersion(t *testing.T) {
    t.Parallel()
    repo, _ := setupBranchTestRepo(t)
    store := NewGitStore(repo, DefaultV1Refs())
    ctx := context.Background()
    cpID := id.MustCheckpointID("c1c2c3d4e5f6")
    const configuredVersion = "refs-v1"

if err := store.Write(ctx, Session{
        CheckpointID:      cpID,
        SessionID:         "session-001",
        Strategy:          "manual-commit",
        Transcript:        redact.AlreadyRedacted([]byte("transcript\n")),
        Prompts:           []string{"initial"},
        AuthorName:        "Test",
        AuthorEmail:       "test@test.com",
        CheckpointVersion: configuredVersion,
    }); err != nil {
        t.Fatalf("WriteCommitted() error = %v", err)
    }

rawSummary := readSummaryFromBranch(t, repo, cpID)
    if rawSummary.CheckpointVersion != configuredVersion {
        t.Fatalf("raw checkpoint_version = %q, want %q", rawSummary.CheckpointVersion, configuredVersion)
    }
}

// TestWrite_BackfillSummaryNotFound verifies error propagation through dispatch.
func TestWrite_BackfillSummaryNotFound(t *testing.T) {
    t.Parallel()

Mcmd/entire/cli/checkpoint/persistent_write_test.go+27

17 unmodified lines

18
19
20
21
22
23
24
25
26
23
27
28
29
30
1 unmodified line

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

17 unmodified lines

}
}

func DefaultCheckpointVersion() string {
    return checkpoint.CheckpointVersionBranchV1
}

func Normalize(policy Policy) Policy {
    if policy.CheckpointVersion == "" {
        policy.CheckpointVersion = checkpoint.CheckpointVersionBranchV1
        policy.CheckpointVersion = DefaultCheckpointVersion()
    }
    if policy.CheckpointMinVersion == "" {
        policy.CheckpointMinVersion = checkpoint.CheckpointVersionBranchV1
1 unmodified line

return policy
}

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

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

Mcmd/entire/cli/checkpointpolicy/policy.go+14/-1

14 unmodified lines

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

14 unmodified lines

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

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

func TestValidatePolicy(t *testing.T) {
    t.Parallel()
    tests := []struct {