address committed store feedback · Entire

address committed store feedback

9efa5de·

pfleidi·4w ago·4 files·+19 added/-4 removed

Rename the committed checkpoint metadata store interface to avoid the generic Store name.

Also fast-path indexed session refs so callers that already know a session index do not re-read the checkpoint summary.

Sessions

7ecf2c5cef5aView transcript

Changes

4

186 unmodified lines

187
188
189
190
191
190
191
192
193
194
169 unmodified lines

364
365
366
367
368
369
370
371
372
373

186 unmodified lines

UpdateCheckpoint(ctx context.Context, checkpointID id.CheckpointID, opts ...WriteOption) error
}

// Store reads and writes committed checkpoint documents.
type Store interface {
// MetadataStore reads and writes committed checkpoint documents.
type MetadataStore interface {
    Reader
    Writer
}
169 unmodified lines

}

func (s *GitStore) resolveSessionIndex(ctx context.Context, ref SessionRef) (int, error) {
    if ref.sessionRefMode == sessionRefIndex {
        return ref.sessionIndex, nil
    }

summary, err := s.ReadCheckpoint(ctx, ref.checkpointID)
    if err != nil {
        return 0, err
    }

Mcmd/entire/cli/checkpoint/committed_domain.go+6/-2

9 unmodified lines

10
11
12
13
13
14
15
16

9 unmodified lines

// CommittedStore provides the production committed checkpoint storage surface.
type CommittedStore interface {
    SessionStore
    Store
    MetadataStore
}

// AuthorReader provides optional checkpoint author lookup.

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

116 unmodified lines

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

116 unmodified lines

require.Equal(t, cpID, infos[0].CheckpointID)
}

func TestResolveSessionIndexUsesIndexRefDirectly(t *testing.T) {
    t.Parallel()

store := &GitStore{}
    cpID := id.MustCheckpointID("555555555555")

sessionIndex, err := store.resolveSessionIndex(context.Background(), SessionIndexRef(cpID, 3))
    require.NoError(t, err)
    require.Equal(t, 3, sessionIndex)
}

func TestGitStoreStoresUpdateSpecificSessionAndCheckpoint(t *testing.T) {
    t.Parallel()

Mcmd/entire/cli/checkpoint/committed_reader_resolve_test.go+11

9 unmodified lines

10
11
12
13
13
14
15
16

9 unmodified lines

var (
    _ CommittedStore = (*GitStore)(nil)
    _ SessionStore   = (*GitStore)(nil)
    _ Store          = (*GitStore)(nil)
    _ MetadataStore  = (*GitStore)(nil)
    _ TemporaryStore = (*GitStore)(nil)
    _ AuthorReader   = (*GitStore)(nil)
)

Mcmd/entire/cli/checkpoint/store.go+1/-1