reject checkpoint token self-comparison · Entire
reject checkpoint token self-comparison
956e0fb→main·
peyton-alt·3w ago·2 files·+33 added/-0 removed
Sessions
caff12e75277View transcript
?\ okay proceedCodex·GPT-5.5·1 step
Changes
2
cmd/entire/cli
Mcheckpoint_tokens.go+4
Msessions_test.go+29
116 unmodified lines
117
118
119
120
121
122
123
124
125
126
116 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
2383 unmodified lines
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2383 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()