preserve empty summary lookup behavior · Entire

preserve empty summary lookup behavior

f39e8dbmain·

pfleidi·4w ago·2 files·+3 added/-7 removed

Return ErrCheckpointNotFound for empty committed summaries in the split reader helper.

This keeps the interface split behavior-neutral and updates the regression test to cover the pre-split contract.

Sessions

b7a703224f22View transcript

?\
Refactor Checkpoint Storage Interfaces and Domain AdaptersCodex·GPT-5.5·3 steps

Changes

2

60 unmodified lines

61
62
63
64
64
65
66
67
68
69
67
68
69

60 unmodified lines

// ReadLatestSessionContent reads the latest session from an already-resolved
// committed reader and summary.
func ReadLatestSessionContent(ctx context.Context, reader CommittedReader, checkpointID id.CheckpointID, summary *CheckpointSummary) (*SessionContent, error) {
    if summary == nil {
    if summary == nil || len(summary.Sessions) == 0 {
        return nil, ErrCheckpointNotFound
    }
    if len(summary.Sessions) == 0 {
        return nil, fmt.Errorf("checkpoint has no sessions: %s", checkpointID)
    }
    latestIndex := len(summary.Sessions) - 1
    content, err := reader.ReadSessionContent(ctx, checkpointID, latestIndex)
    if err != nil {

Mcmd/entire/cli/checkpoint/committed_reader_resolve.go+1/-4

31 unmodified lines

32
33
34
35
35
36
37
38
2 unmodified lines

41
42
43
44
45
44
45
46
47

31 unmodified lines

require.ErrorContains(t, err, "read committed checkpoint")
}

func TestReadLatestSessionContentEmptySummaryReturnsDistinctError(t *testing.T) {
func TestReadLatestSessionContentEmptySummaryReturnsNotFound(t *testing.T) {
    t.Parallel()

cpID := id.MustCheckpointID("111111111111")
2 unmodified lines

content, err := ReadLatestSessionContent(context.Background(), reader, cpID, summary)
    require.Nil(t, content)
    require.ErrorContains(t, err, "checkpoint has no sessions")
    require.NotErrorIs(t, err, ErrCheckpointNotFound)
    require.ErrorIs(t, err, ErrCheckpointNotFound)
}

func TestReadRawSessionLogForCheckpointReadsLatestV1Session(t *testing.T) {