checkpoint: finish committed->persistent vocabulary (Type consts, refs) · Entire

checkpoint: finish committed->persistent vocabulary (Type consts, refs)

f56c864→main

Last of the committed-named identifiers: Type consts Committed/Temporary -> Persistent/Ephemeral CommittedRefs -> PersistentRefs ResolveCommittedRefs -> ResolvePersistentRefs CommittedReadRef -> PersistentReadRef committed_refs.go -> persistent_refs.go

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

5c315f628622View transcript

Changes

22

// committedRefs resolves the committed metadata topology.
func (opts attachOptions) committedRefs(ctx context.Context) cpkg.CommittedRefs {
    return cpkg.ResolveCommittedRefs(ctx)
}

func (opts attachOptions) committedRefs(ctx context.Context) cpkg.PersistentRefs {
    return cpkg.ResolvePersistentRefs(ctx)
}

// openAttachStore opens the committed store for the resolved topology. refs is
// passed explicitly so attach preserves PrimaryAsRead() pinning.
func openAttachStore(ctx context.Context, repo *git.Repository, refs cpkg.CommittedRefs) (cpkg.PersistentStore, error) {
    //nolint:ireturn // committed store capability preserves attach's read-ref override
}

// checkpointHasSessionMetadata reports whether sessionID has existing metadata
// at Primary. Reads target Primary directly, not refs.Read, because this guard
// must reflect what the next write would target.
func checkpointHasSessionMetadata(ctx context.Context, repo *git.Repository, refs cpkg.CommittedRefs, checkpointID id.CheckpointID, sessionID string) (bool, error) {
    return false, nil
}

// metadata fetch fallback chain used by `entire resume` (which advances the
// local ref on success) and re-check. Returns a possibly-freshly-opened repo
// handle so go-git sees any newly fetched packfiles.
func ensureCheckpointAvailable(ctx, logCtx context.Context, repo *git.Repository, refs cpkg.CommittedRefs, checkpointID id.CheckpointID, isExistingCheckpoint bool) (*git.Repository, error) {
    return nil, nil
}

// Primary locally. Reads target Primary directly, not refs.Read, because this
// asks what the next write would find, not what readers see. A missing local
// ref is reported as absent; the caller is responsible for any remote refresh.
func checkpointPresentLocally(ctx context.Context, repo *git.Repository, refs cpkg.CommittedRefs, checkpointID id.CheckpointID) (bool, error) {
    return false, nil
}
type Type int

const (
    // Temporary checkpoints contain full state (code + metadata) and are stored
    // Ephemeral checkpoints contain full state (code + metadata) and are stored
    // on shadow branches (entire/<commit-hash>). Used for intra-session rewind.
    Temporary Type = iota
    Ephemeral Type = iota

// Committed checkpoints contain metadata + commit reference and are stored
    // Persistent checkpoints contain metadata + commit reference and are stored
    // on the entire/checkpoints/v1 branch. They are the permanent record.
    Committed
    Persistent
)

// EphemeralStore provides the production shadow-branch checkpoint surface.
func TestCheckpointType_Values(t *testing.T) {
    if Temporary == Committed {
        t.Error("Temporary and Committed should have different values")
    }
    if Ephemeral == Persistent {
        t.Error("Ephemeral and Persistent should have different values")
    }

var defaultType Type
    if defaultType != Temporary {
        t.Errorf("expected zero value of Type to be Temporary, got %d", defaultType)
    }
    if defaultType != Ephemeral {
        t.Errorf("expected zero value of Type to be Ephemeral, got %d", defaultType)
    }
}
package checkpoint

import (
    "context"
    "slices"
    "github.com/go-git/go-git/v6/plumbing"
    "github.com/entireio/cli/cmd/entire/cli/paths"
)

// CommittedRefs is the committed-metadata ref topology.
type CommittedRefs struct {
    Primary plumbing.ReferenceName
    Read    plumbing.ReferenceName
    Push    []plumbing.ReferenceName
}

// DefaultV1Refs returns the v1-only topology.
func DefaultV1Refs() CommittedRefs {
    v1Branch := plumbing.NewBranchReferenceName(paths.MetadataBranchName)
    return CommittedRefs{
        Primary: v1Branch,
        Read:    v1Branch,
        Push:    []plumbing.ReferenceName{v1Branch},
    }
}
func TestResolveCommittedRefs(t *testing.T) {
    v1 := v1BranchRef()
    tests := []struct {
        name    string
        version string
        want    CommittedRefs
    }{
        {"unset", "", CommittedRefs{Primary: v1, Read: v1, Push: []plumbing.ReferenceName{v1}}},
        {"checkpoints version ignored", `"1.1"`, CommittedRefs{Primary: v1, Read: v1, Push: []plumbing.ReferenceName{v1}}},
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            dir := t.TempDir()
            t.Chdir(dir)
            writeSettings(t, dir, tt.version)
            assert.Equal(t, tt.want, ResolveCommittedRefs(context.Background()))
        })
    }
}