Route tokens profile through checkpoint.Open · Entire

Route tokens profile through checkpoint.Open

082ce88→main·

Soph·3w ago·2 files·+12 added/-6 removed

tokens profile was the one remaining production CLI path constructing a checkpoint store directly (checkpoint.NewGitStore) instead of going through checkpoint.Open, so a future settings-driven primary backend would be silently ignored there. Route it through Open and widen the report helpers from *checkpoint.GitStore to the checkpoint.PersistentStore interface.

benchutil keeps its direct NewGitStore (documented benchmark fixture that pins the v1 topology and never exercises backend selection).

No behavior change: Open with default options resolves the same v1 git store.

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

Sessions

3bbb48203da7View transcript

Changes

2

171 unmodified lines

172
173
174
175
176
175
176
177
178
179
180
181
182

171 unmodified lines

}

br := &BenchRepo{
    Dir:       dir,
    Repo:      repo,
    Dir:  dir,
    Repo: repo,
    // Benchmark fixture: construct the git store directly rather than via
    // checkpoint.Open. Benchmarks pin the v1 topology and never exercise
    // settings-driven backend selection, so they deliberately bypass Open.
    Store:     checkpoint.NewGitStore(repo, checkpoint.DefaultV1Refs()),
    Ephemeral: checkpoint.NewEphemeralStore(repo, checkpoint.DefaultV1Refs()),
    HeadHash:  headHash.String(),

Mcmd/entire/cli/benchutil/benchutil.go+5/-2

112 unmodified lines

113
114
115
116
117
116
117
118
119
120
121
122
123
11 unmodified lines

135
136
137
135
138
139
140
141
53 unmodified lines

195
196
197
195
198
199
200
201

112 unmodified lines

}
def defer repo.Close()

store := checkpoint.NewGitStore(repo, checkpoint.ResolveRefs(ctx))
store.SetBlobFetcher(FetchBlobsByHash)
stores, err := checkpoint.Open(ctx, repo, checkpoint.OpenOptions{BlobFetcher: FetchBlobsByHash})
if err != nil {
    return fmt.Errorf("failed to open checkpoint stores: %w", err)
}
store := stores.Persistent
infos, err := store.List(ctx)
if err != nil {
    return fmt.Errorf("failed to list checkpoints: %w", err)
}
11 unmodified lines

return nil
}

func buildTokensProfileReport(ctx context.Context, store *checkpoint.GitStore, infos []checkpoint.CheckpointInfo, limit int) (tokensProfileReport, error) {
func buildTokensProfileReport(ctx context.Context, store checkpoint.PersistentStore, infos []checkpoint.CheckpointInfo, limit int) (tokensProfileReport, error) {
    checkpointsAvailable := len(infos)
    infos = limitTokensProfileCheckpoints(infos, limit)
    report := tokensProfileReport{
53 unmodified lines

return infos[:limit]
}

func tokensProfileCheckpointUsage(ctx context.Context, store *checkpoint.GitStore, checkpointID id.CheckpointID, summary *checkpoint.CheckpointSummary) (*agent.TokenUsage, bool, error) {
func tokensProfileCheckpointUsage(ctx context.Context, store checkpoint.PersistentStore, checkpointID id.CheckpointID, summary *checkpoint.CheckpointSummary) (*agent.TokenUsage, bool, error) {
    if summary == nil {
        return nil, false, nil
    }