move branch-v1 default into checkpointpolicy · Entire
move branch-v1 default into checkpointpolicy
c8d3cab→main·
pfleidi·2w ago·12 files·+41 added/-59 removed
After the checkpoint_version metadata field was removed, the exported CheckpointVersionBranchV1 constant no longer described anything in api/checkpoint; its only consumer was checkpointpolicy's defaults, reached through a re-export in the cli checkpoint alias file. Define the constant in checkpointpolicy next to the format vocabulary that already owns it and drop the api const and alias, matching what the CheckpointVersionRefsV1 removal already did.
Also fold the AuthorReader interface into persistent.go (the file holding it had shrunk to that single declaration) and reuse the v1BranchRef test helper in the seam test instead of rebuilding the ref name inline.
Sessions
b417d0acc17aView transcript
Changes
12
api/checkpoint
- Merrors.go-3
cmd/entire/cli
- checkpoint
- Maliases.go-3
- Mpersistent.go+7
- Dpersistent_reader.go-14
- Mrefs_store_seam_test.go+1/-3
- checkpointpolicy
- Mformat.go+3
- Mformat_test.go+2/-3
- Mpolicy.go+4/-6
- Mpolicy_test.go+5/-6
- Mstore_test.go+2/-2
- Mupdate_test.go+11/-12
- Mwarning_test.go+6/-7
- checkpoint
// ErrNoTranscript is returned when a checkpoint exists but has no transcript.
ErrNoTranscript = errors.New("no transcript found for checkpoint")
// CheckpointVersionBranchV1 identifies the branch-backed checkpoint metadata format.
const CheckpointVersionBranchV1 = "branch-v1"
CheckpointAttribution = apicheckpoint.CheckpointAttribution
// CheckpointVersionBranchV1 identifies the branch-backed checkpoint metadata format.
const CheckpointVersionBranchV1 = apicheckpoint.CheckpointVersionBranchV1
// Sentinel errors (re-exported so errors.Is keeps working across packages).
var (
ErrCheckpointNotFound = apicheckpoint.ErrCheckpointNotFound
)
// AuthorReader provides optional checkpoint author lookup. It stays in the
// implementation package: GetCheckpointAuthor is a git-log operation and Author
// is an implementation type, not part of the storage contract.
type AuthorReader interface {
GetCheckpointAuthor(ctx context.Context, checkpointID id.CheckpointID) (Author, error)
}
// Reads must be served by the git-refs primary, not the mirror: after the
// mirror's v1 branch is deleted, the composed store still reads everything.
"test"
// CheckpointVersionBranchV1 identifies the branch-backed checkpoint format.
const CheckpointVersionBranchV1 = "branch-v1"
type CheckpointFormat struct {
Family CheckpointFamily
Major int
}
func TestSupportedFormats(t *testing.T) {
t.Parallel()
branchV1, err := checkpointpolicy.ParseFormat(checkpoint.CheckpointVersionBranchV1)
require.NoError(t, err)
refsV1, err := checkpointpolicy.ParseFormat("refs-v1")
require.NoError(t, err)
require.True(t, checkpointpolicy.CanRead(branchV1))
require.True(t, checkpointpolicy.CanWrite(branchV1))
}
func DefaultPolicy() Policy {
return Policy{
CheckpointVersion: checkpoint.CheckpointVersionBranchV1,
CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1,
}
}
func TestNormalize(t *testing.T) {
t.Parallel()
got := checkpointpolicy.DefaultPolicy()
require.Equal(t, checkpoint.CheckpointVersionBranchV1, got.CheckpointVersion)
require.Equal(t, checkpoint.CheckpointVersionBranchV1, got.CheckpointMinVersion)
}
require.False(t, checkpointpolicy.RequiresUpgrade(checkpointpolicy.DefaultPolicy()))
require.True(t, checkpointpolicy.RequiresUpgrade(checkpointpolicy.Policy{
CheckpointVersion: checkpoint.CheckpointVersionBranchV1,
CheckpointMinVersion: "refs-v2",
}))
require.False(t, checkpointpolicy.UnsupportedWrite(checkpointpolicy.DefaultPolicy()))
require.True(t, checkpointpolicy.UnsupportedWrite(checkpointpolicy.Policy{
CheckpointVersion: "refs-v2",
CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1,
}))
require.True(t, checkpointpolicy.CanSatisfyPolicy(checkpointpolicy.Policy{}))
require.False(t, checkpointpolicy.CanSatisfyPolicy(checkpointpolicy.Policy{
CheckpointVersion: "refs-v2",
CheckpointMinVersion: checkpoint.CheckpointVersionBranchV1,
}))
require.NoError(t, err)
// Implement further tests and logic as necessary.