# drop checkpoint_version from checkpoint metadata

`e4ca450`→[main](/content/gh/entireio/cli/commits/main/index.html)·

pfleidi·2w ago·15 files·+32 added/-302 removed

Remove the checkpoint_version stamp from checkpoint metadata.json. It
was a pure label: backend selection comes from settings topology, and
nothing dispatched on the stored value. Existing checkpoints are
handled by an external migration.

The checkpoint policy subsystem is untouched — its checkpoint_version
field remains a checkpoint-data write guard (attach now calls the
shared ensureCheckpointPolicyAllowsCheckpointData gate like explain
and import), it just no longer feeds a stamp into new summaries.

## Sessions

e2a3a0318080View transcript

## Changes

15

- api/checkpoint

- Merrors.go-6

- Mmetadata.go-4

- cmd/entire/cli

- Mattach.go+12/-14

- checkpoint

- Maliases.go-3

- Mpersistent.go+9/-20

- Mpersistent_reader.go-12

- Mpersistent_tripwire_test.go+1/-1

- Mpersistent_update_test.go-153

- Mpersistent_write_test.go-63

- Mrefs_store.go+1/-1

- Mrefs_store_seam_test.go+3/-4

- Mrefs_store_test.go-1

- Mcheckpoint_policy_write.go-11

- strategy

- Mmanual_commit_condensation.go-2

- docs/architecture

- Msessions-and-checkpoints.md+6/-7

```
12 unmodified lines

13
14
15
16
17
18
19
20
21

12 unmodified lines

// CheckpointVersionBranchV1 identifies the branch-backed checkpoint metadata format.
const CheckpointVersionBranchV1 = "branch-v1"

// CheckpointVersionRefsV1 identifies the per-checkpoint-ref checkpoint metadata
// format (one ref per checkpoint at refs/entire/checkpoints/<shard>/<id>). The
// value follows the <family>-v<major> convention (cf. branch-v1) so
// checkpointpolicy.ParseFormat parses it.
const CheckpointVersionRefsV1 = "refs-v1"

Mapi/checkpoint/errors.go-6

```
25 unmodified lines

26
27
28
29
30
31
29
30
31
413 unmodified lines

445
446
447
451
448
449
450

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

413 unmodified lines

//nolint:revive // Named CheckpointSummary to avoid conflict with existing Summary struct
type CheckpointSummary struct {
	CLIVersion          string             `json:"cli_version,omitempty"`
	CheckpointVersion   string             `json:"checkpoint_version,omitempty"`
	CheckpointID        id.CheckpointID    `json:"checkpoint_id"`
	Strategy            string             `json:"strategy"`
	Branch              string             `json:"branch,omitempty"`
}

Mapi/checkpoint/metadata.go-4

```
254 unmodified lines

255
256
257
258
259
258
259
260
261
88 unmodified lines

350
351
352
354
355
356
357
358
359
360
361
362
363
364
365
353
354
355
356
357
358
359
360
361
362
363
364
365
366

254 unmodified lines

return nil
	}

checkpointVersion, err := checkpointVersionForNewCheckpoint(ctx, repo)
	if err != nil {
	if err := ensureCheckpointPolicyAllowsCheckpointData(ctx, repo); err != nil {
		return err
	}

88 unmodified lines

}

writeOpts := cpkg.WriteOptions{
		CheckpointID:      checkpointID,
		SessionID:         sessionID,
		Strategy:          strategy.StrategyNameManualCommit,
		CheckpointVersion: checkpointVersion,
		Transcript:        redactedTranscript,
		Prompts:           attachPrompts(meta),
		CheckpointsCount:  attachStepCount(meta.TurnCount),
		AuthorName:        author.Name,
		AuthorEmail:       author.Email,
		Agent:             ag.type(),
		Model:             meta.Model,
		TokenUsage:        tokenUsage,
		CheckpointID:     checkpointID,
		SessionID:        sessionID,
		Strategy:         strategy.StrategyNameManualCommit,
		Transcript:       redactedTranscript,
		Prompts:          attachPrompts(meta),
		CheckpointsCount: attachStepCount(meta.TurnCount),
		AuthorName:       author.Name,
		AuthorEmail:      author.Email,
		Agent:            ag.type(),
		Model:            meta.Model,
		TokenUsage:       tokenUsage,
	}
	if opts.Review {
		writeOpts.Kind = string(session.KindAgentReview)
``

Mcmd/entire/cli/attach.go+12/-14

```
53 unmodified lines

54
55
56
57
58
59
57
58
59

53 unmodified lines

// CheckpointVersionBranchV1 identifies the branch-backed checkpoint metadata format.
const CheckpointVersionBranchV1 = apicheckpoint.CheckpointVersionBranchV1

// CheckpointVersionRefsV1 identifies the per-checkpoint-ref checkpoint metadata format.
const CheckpointVersionRefsV1 = apicheckpoint.CheckpointVersionRefsV1

// Sentinel errors (re-exported so errors.Is keeps working across packages).
var (
	ErrCheckpointNotFound = apicheckpoint.ErrCheckpointNotFound
)
```

Mcmd/entire/cli/checkpoint/aliases.go-3

```
89 unmodified lines

90
91
92
93
94
95
96
97
93
94
95
96
115 unmodified lines

212
213
214
219
220
221
215
216
217
218
219
7 unmodified lines

227
228
229
235
230
231
232
233
331 unmodified lines

565
566
567
573
568
569
570
571
82 unmodified lines

654
655
656
662
657
658
659
660
99 unmodified lines

760
761
762
768
763
764
765
766
10 unmodified lines

777
778
779
785
780
781
782
12 unmodified lines

795
796
797
804
798
799
800
152 unmodified lines

953
954
955
963
964
965
966
967
956
957
958
959
381 unmodified lines

1341
1342
1343
1355
1344
1345
1346
1347

89 unmodified lines

if err != nil {
		return err
	}
	checkpointVersion := CheckpointVersionBranchV1
	if opts.CheckpointVersion != "" {
		checkpointVersion = opts.CheckpointVersion
	}
	checkpointSubtree, taskMetadataPath, err := s.applySessionWrite(ctx, opts, existing, opts.CheckpointID.Path()+"/", checkpointVersion)
	checkpointSubtree, taskMetadataPath, err := s.applySessionWrite(ctx, opts, existing, opts.CheckpointID.Path()+"/")
	if err != nil {
		return err
	}

115 unmodified lines

// applySessionWrite applies a Session write to a checkpoint's current subtree and
// returns the new checkpoint subtree hash plus the task metadata path (for the
// commit trailer). It is backing-independent: the v1-branch store passes the
// sharded basePath and the per-checkpoint-ref store passes "". checkpointVersion
// is stamped into a freshly written root summary.
func (s *treeWriter) applySessionWrite(ctx context.Context, opts WriteOptions, existing *object.Tree, basePath, checkpointVersion string) (plumbing.Hash, string, error) {
// sharded basePath and the per-checkpoint-ref store passes "".
func (s *treeWriter) applySessionWrite(ctx context.Context, opts WriteOptions, existing *object.Tree, basePath string) (plumbing.Hash, string, error) {
	entries, err := s.flattenExisting(existing, basePath)
	if err != nil {
		return plumbing.ZeroHash, "", err
	}

if err := s.writeStandardCheckpointEntries(ctx, opts, basePath, entries, checkpointVersion); err != nil {
		if err := s.writeStandardCheckpointEntries(ctx, opts, basePath, entries); err != nil {
			return plumbing.ZeroHash, "", err
	}
}
}

// writeStandardCheckpointEntries writes the checkpoint entries to the storage with the given options.

// ... (truncated for brevity)
