checkpoint: preserve checkpoint version on rewrite · Entire

checkpoint: preserve checkpoint version on rewrite

f45406b→main·

pfleidi·3w ago·2 files·+33 added/-1 removed

Carry an existing root checkpoint_version through repeated checkpoint writes.

This keeps future storage-format values from being downgraded when another session updates the same checkpoint metadata.

Sessions

a6e9619f8c2cView transcript

[?
Checkpoint Version Management and PersistenceCodex·GPT-5.5·3 steps](/content/gh/entireio/cli/session/019ef050-bbd5-7863-b97e-af881fab4c74#timeline-a6e9619f8c2c/index.html)

Changes

2

487 unmodified lines

488
489
490
491
492
493
494
495
496
497
498
499
500
501
9 unmodified lines

511
512
513
512
514
515
516
517

487 unmodified lines

}

combinedAttribution := opts.CombinedAttribution
    checkpointVersion := CheckpointVersionBranchV1
    hasReview := opts.HasReview
    hasInvestigation := opts.HasInvestigation
    rootMetadataPath := basePath + paths.MetadataFileName
    if entry, exists := entries[rootMetadataPath]; exists {
        existingSummary, readErr := s.readSummaryFromBlob(entry.Hash)
        if readErr == nil {
            checkpointVersion = existingSummary.CheckpointVersion
            if combinedAttribution == nil {
                combinedAttribution = existingSummary.CombinedAttribution
            }
        }
    }

summary := CheckpointSummary{
        CheckpointID:        opts.CheckpointID,
        CLIVersion:          versioninfo.Version,
        CheckpointVersion:   CheckpointVersionBranchV1,
        CheckpointVersion:   checkpointVersion,
        Strategy:            opts.Strategy,
        Branch:              opts.Branch,
        CheckpointsCount:    checkpointsCount,

Mcmd/entire/cli/checkpoint/committed.go+3/-1

467 unmodified lines

468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503

467 unmodified lines

}
}

func TestWriteCommittedPreservesExplicitCheckpointVersion(t *testing.T) {
    t.Parallel()
    _, store, cpID := setupRepoForUpdate(t)
    const futureVersion = "refs-v1"

rewriteRootSummary(t, store, cpID, func(summary *CheckpointSummary) {
        summary.CheckpointVersion = futureVersion
    })

if err := store.WriteCommitted(context.Background(), WriteCommittedOptions{
        CheckpointID: cpID,
        SessionID:    "session-002",
        Strategy:     "manual-commit",
        Transcript:   redact.AlreadyRedacted([]byte("second session\n")),
        Prompts:      []string{"second prompt"},
        AuthorName:   "Test",
        AuthorEmail:  "test@test.com",
    }); err != nil {
        t.Fatalf("WriteCommitted() error = %v", err)
    }

rawSummary := readSummaryFromBranch(t, store.repo, cpID)
    if rawSummary.CheckpointVersion != futureVersion {
        t.Fatalf("raw checkpoint_version = %q, want %q", rawSummary.CheckpointVersion, futureVersion)
    }
    if len(rawSummary.Sessions) != 2 {
        t.Fatalf("len(Sessions) = %d, want 2", len(rawSummary.Sessions))
    }
}

func isValidContentHash(hash string) bool {
    return len(hash) > 10 && hash[:7] == "sha256:"
}