reject checkpoint token self-comparison · Entire
reject checkpoint token self-comparison
508520e·
peyton-alt·3w ago·2 files·+33 added/-0 removed
Sessions
caff12e75277View transcript
Changes
2
cmd/entire/cli
Mcheckpoint_tokens.go+4
Msessions_test.go+29
111 unmodified lines
112
113
114
115
116
117
118
119
120
121
111 unmodified lines
if err != nil {
return tokenCommandError(err)
}
if baselineReport.CheckpointID == report.CheckpointID {
cmd.SilenceUsage = true
return fmt.Errorf("cannot compare checkpoint %s to itself", report.CheckpointID)
}
report.Comparison = buildCheckpointTokensComparison(report, baselineReport)
}
Mcmd/entire/cli/checkpoint_tokens.go+4
2230 unmodified lines
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2230 unmodified lines
}
}
func TestCheckpointTokensCmd_RejectsSelfComparison(t *testing.T) {
repo, _ := runExplainAutoTestRepo(t)
ctx := context.Background()
store := checkpoint.NewGitStore(repo, checkpoint.DefaultV1Refs())
cpID := id.MustCheckpointID("abc222abc222")
writeCommittedTokenCheckpoint(ctx, t, store, cpID, "checkpoint-token-self-compare", &agent.TokenUsage{
InputTokens: 100,
OutputTokens: 50,
APICallCount: 1,
})
cmd := newCheckpointGroupCmd()
var stdout bytes.Buffer
cmd.SetOut(&stdout)
cmd.SetArgs([]string{"tokens", "abc222", "--compare", "abc222abc222"})
err := cmd.ExecuteContext(ctx)
if err == nil {
t.Fatal("expected self-comparison error, got nil")
}
if !strings.Contains(err.Error(), "cannot compare checkpoint abc222abc222 to itself") {
t.Fatalf("expected self-comparison error, got: %v", err)
}
if stdout.Len() != 0 {
t.Fatalf("expected no report output for self-comparison, got:\n%s", stdout.String())
}
}
func TestCheckpointTokensCmd_JSONOutputWithComparison(t *testing.T) {
repo, _ := runExplainAutoTestRepo(t)
ctx := context.Background()