checkpoint: route callers through split stores · Entire

checkpoint: route callers through split stores

dddd06e→main·

pfleidi·4w ago·11 files·+49 added/-32 removed

Expose committed and temporary checkpoint storage through separate interfaces from the Stores facade.

Call sites now depend on committed readers and writers or temporary shadow-branch storage instead of the concrete GitStore.

Sessions

bb51dce048b6View transcript

Changes

11

// 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.GitStore, error) {

func openAttachStore(ctx context.Context, repo *git.Repository, refs cpkg.CommittedRefs) (cpkg.CommittedStore, error) { //nolint:ireturn // committed store capability preserves attach's read-ref override
    stores, err := cpkg.Open(ctx, repo, cpkg.OpenOptions{Refs: &refs})
    if err != nil {
        return nil, fmt.Errorf("open checkpoint store: %w", err)
    }
}

// LookupSessionLog is a convenience function that opens the repository and retrieves // a session log by checkpoint ID. This is the primary entry point for callers that // don't already have a GitStore instance. // Returns ErrCheckpointNotFound if the checkpoint doesn't exist. // Returns ErrNoTranscript if the checkpoint exists but has no transcript. func LookupSessionLog(ctx context.Context, cpID id.CheckpointID) ([]byte, string, error) { if err != nil { return nil, "", fmt.Errorf("open checkpoint store: %w", err) } return stores.Primary.GetSessionLog(ctx, cpID) return ReadRawSessionLogForCheckpoint(ctx, stores.Primary, cpID) }

// UpdateSummary updates the summary field in the latest session's metadata.

// Stores is the facade returned by Open: the committed store plus the git-only
// temporary capability and resolved committed-ref topology.
type Stores struct {
    // Primary is the committed store — the source of truth that serves all
    // committed reads and writes.
    Primary *GitStore
    // Primary is the committed store that serves committed reads and writes.
    Primary CommittedStore

refs CommittedRefs
    temporary TemporaryStore
}

func (s *Stores) Temporary() *GitStore { return s.Primary } // Temporary returns the git-backed temporary shadow-branch store.

// Refs returns the resolved committed-ref topology. func (s *Stores) Refs() CommittedRefs { return s.refs }

type explainCheckpointLookup struct {
    repo      *git.Repository
    store     *checkpoint.GitStore
    store     checkpoint.CommittedStore
    committed []checkpoint.CommittedInfo
}

// Searches ALL shadow branches, not just the one for current HEAD, to find checkpoints // created from different base commits (e.g., if HEAD advanced since session start). // The writer w is used for raw transcript output to bypass the pager. func explainTemporaryCheckpoint(ctx context.Context, w, errW io.Writer, repo *git.Repository, store *checkpoint.GitStore, shaPrefix string, verbose, full, rawTranscript bool) (string, bool, error) { // List temporary checkpoints from ALL shadow branches // This ensures we find checkpoints even if HEAD has advanced since the session started }

// GetRewindPoints returns available rewind points. // Uses checkpoint.GitStore.ListTemporaryCheckpoints for reading from shadow branches. // Uses checkpoint.TemporaryStore for reading from shadow branches. func (s *ManualCommitStrategy) GetRewindPoints(ctx context.Context, limit int) ([]RewindPoint, error) { repo, err := OpenRepository(ctx) if err != nil {

}
defer repo.Close()

}