checkpoint: collapse ephemeral reads/lists to generic Read/List · Entire
checkpoint: collapse ephemeral reads/lists to generic Read/List
ae36a26→main·
Soph·3w ago·4 files·+19 added/-18 removed
Mirror the persistent generic surface on the shadow-branch store: ReadTemporary -> Read (added to the EphemeralStore interface) ListTemporary -> List ListTemporaryCheckpoints -> ListCheckpoints ListAllTemporaryCheckpoints -> ListAllCheckpoints
Write methods become a Write request union in the next commit. No behavior change.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
59955a4431e2View transcript
Changes
4
cmd/entire/cli
checkpoint
Mcheckpoint.go+5/-4
Mtemporary.go+11/-11
Mexplain.go+2/-2
strategy
Mmanual_commit_rewind.go+1/-1
62 unmodified lines
63
64
65
66
67
66
67
68
69
69
70
71
72
73
639 unmodified lines
713
714
715
715
716
717
718
719
62 unmodified lines
// EphemeralCheckpointInfo contains information about a single commit on a shadow branch.
// Used by ListTemporaryCheckpoints to provide rewind point data.
// Used by ListCheckpoints to provide rewind point data.
type EphemeralCheckpointInfo struct {
// CommitHash is the hash of the checkpoint commit
CommitHash plumbing.Hash
}
Mcmd/entire/cli/checkpoint/checkpoint.go+5/-4
179 unmodified lines
180 181 182 183 183 184 185 186 186 187 188 189 24 unmodified lines
214 215 216 217 218 217 218 219 220 221 263 unmodified lines
485 486 487 488 488 489 490 491 492 492 493 494 495 496 497 498 498 499 500 501 502 503 504 505 505 506 507 508 73 unmodified lines
582 583 584 585 585 586 587 588 588 589 590 591 592 593 594 594 595 596 597
179 unmodified lines
return result, nil }
// ReadTemporary reads the latest checkpoint from a shadow branch. // Read reads the latest checkpoint from a shadow branch. // Returns nil if the shadow branch doesn't exist. // worktreeID should be empty for main worktree or the internal git worktree name for linked worktrees. func (s *ephemeralStore) ReadTemporary(ctx context.Context, baseCommit, worktreeID string) (*ReadEphemeralResult, error) { func (s *ephemeralStore) Read(ctx context.Context, baseCommit, worktreeID string) (*ReadEphemeralResult, error) { if err := ctx.Err(); err != nil { return nil, err //nolint:wrapcheck // Propagating context cancellation } 24 unmodified lines
}, nil }
// ListTemporary lists all shadow branches with their checkpoint info. func (s *ephemeralStore) ListTemporary(ctx context.Context) ([]EphemeralInfo, error) { // List lists all shadow branches with their checkpoint info. func (s *ephemeralStore) List(ctx context.Context) ([]EphemeralInfo, error) { if err := ctx.Err(); err != nil { return nil, err //nolint:wrapcheck // Propagating context cancellation } 263 unmodified lines
return ApplyTreeChanges(ctx, s.repo, baseTreeHash, changes) }
// ListTemporaryCheckpoints lists all checkpoint commits on a shadow branch. // ListCheckpoints lists all checkpoint commits on a shadow branch. // This returns individual commits (rewind points), not just branch info. // The sessionID filter, if provided, limits results to commits from that session. // worktreeID should be empty for main worktree or the internal git worktree name for linked worktrees. func (s *ephemeralStore) ListTemporaryCheckpoints(ctx context.Context, baseCommit, worktreeID, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { func (s *ephemeralStore) ListCheckpoints(ctx context.Context, baseCommit, worktreeID, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { shadowBranchName := ShadowBranchNameForCommit(baseCommit, worktreeID) return s.listCheckpointsForBranch(ctx, shadowBranchName, sessionID, limit) }
// ListCheckpointsForBranch lists checkpoint commits for a shadow branch by name. // Use this when you already have the full branch name (e.g., from ListTemporary). // Use this when you already have the full branch name (e.g., from List). // The sessionID filter, if provided, limits results to commits from that session. func (s *ephemeralStore) ListCheckpointsForBranch(ctx context.Context, branchName, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { return s.listCheckpointsForBranch(ctx, branchName, sessionID, limit) }
// listCheckpointsForBranch lists checkpoint commits for a specific shadow branch name. // This is an internal helper used by ListTemporaryCheckpoints, ListCheckpointsForBranch, and ListAllTemporaryCheckpoints. // This is an internal helper used by ListCheckpoints, ListCheckpointsForBranch, and ListAllCheckpoints. func (s *ephemeralStore) listCheckpointsForBranch(ctx context.Context, shadowBranchName, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { if err := ctx.Err(); err != nil { return nil, err //nolint:wrapcheck // Propagating context cancellation } 73 unmodified lines
return results, nil }
// ListAllTemporaryCheckpoints lists checkpoint commits from ALL shadow branches. // ListAllCheckpoints lists checkpoint commits from ALL shadow branches. // This is used for checkpoint lookup when the base commit is unknown (e.g., HEAD advanced since session start). // The sessionID filter, if provided, limits results to commits from that session. func (s *ephemeralStore) ListAllTemporaryCheckpoints(ctx context.Context, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { func (s *ephemeralStore) ListAllCheckpoints(ctx context.Context, sessionID string, limit int) ([]EphemeralCheckpointInfo, error) { if err := ctx.Err(); err != nil { return nil, err //nolint:wrapcheck // Propagating context cancellation }
// List all shadow branches branches, err := s.ListTemporary(ctx) branches, err := s.List(ctx) if err != nil { return nil, fmt.Errorf("failed to list shadow branches: %w", err) }