Repository navigation
Conversation
v0.8.0 adds two engine fixes over v0.6.0: - A cache rewrite is charged to the new change at the first difference (rossoctl/accountant#110). - An in-place change on a whole item ends when a later change rewrites that same client item to 0 bytes (rossoctl/accountant#113, fixes rossoctl/accountant#108). Found reviewing rossoctl#2057: with tool-prune, turn 1 remove:[NotebookEdit] moves the cache mark onto the survivor, and turn 2 remove:[Bash,NotebookEdit] deletes that survivor, so the stale in-place rewrite failed the sum and conservation checks on every later turn. The nested metrics module is now tagged at this commit, so metrics moves from a pseudo-version to v0.8.0 (rossoctl/accountant#112, SizedPricer): it prices savings by the whole bill difference at each prompt size. The new interface is additive, so cortex builds unchanged. Add a toolprune regression test for the rossoctl#108 shape (fails on v0.6.0, passes on v0.8.0). Widen the savings-agreement thread-total tolerance to absorb the per-step micro-dollar rounding the new v0.8.0 case exposes. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: DAVID BOAZ <DAVIDBO@il.ibm.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
clawgenti
left a comment
There was a problem hiding this comment.
Reviewed the accountant v0.6.0 → v0.8.0 bump, the new toolprune regression test, and the widened savings-agreement tolerance. No must-fix findings.
Verified on the head commit (5efe292e; probes run in throwaway worktrees at base a4047fc7 and head, then deleted):
go mod download+go mod verifyincore: the v0.8.0 zips resolve and match the hashes in all fivego.sumfiles. Worth noting why both requires must stay explicit:accountant/metrics v0.8.0's owngo.modrequiresgithub.com/rossoctl/accountant v0.0.0behind areplace(ignored outside that module), so it iscore/go.mod'sv0.8.0line that keeps MVS at the right version.- Positive control: copying the new test onto base, which pins v0.6.0, reproduces the claimed failure exactly — turn 2 fails
sum(ops=3314 bodies=3351) andconservation(bill difference=846 ops=836); both turns are clean on head. The test does prove the claim it is named for (see the one inline suggestion about how tightly it proves it). - Tolerance mutation: restoring
> 1atcore/accounting/savings_agree_test.go:143fails exactly one case,inplace/deleted-by-a-later-change/cold-hot/5m, withthread total: net 7841 µ$, want 7843 µ$. A per-step dump over the whole case set shows the only non-zero per-step deltas anywhere are that case's steps 1 and 2, at −1 µ$ each.len(c.Steps)is exactly the drift a case can accumulate at the 1 µ$ per-step tolerance, so the new bound hides nothing the per-step check does not already allow. go testpasses forcore/accounting/...,core/pipeline,core/plugins/{inferenceparser,sessionbudget,toolprune};go vetandgofmt -lare clean on the two changed test files.
Notes, not findings
SizedPriceris inert in Cortex:core/accounting/metrics.go:147passes a*boundPricer, which implements onlyPrice(core/accounting/metrics.go:468), soaccountant/metrics'sizes()returns zero and the size-based re-rate never runs. The metrics bump changes no figure here. The body reads as if v0.8.0 changes pricing behavior generally; a sentence saying the sized pricing is additive and inactive until a host implementsPriceAtwould keep the next reader from looking for a regression that cannot occur.- The body says v0.8.0 "adds two engine fixes" and then lists three items (the third is the metrics-module
SizedPricer). deleted()in v0.8.0 (internal/engine/compute.go:848) documents one shape where its proof can end a change that only looks like the deleted one — same size at the same client position, after an earlier deletion. The rule errs toward keeping the change, and no case fixture covers that ambiguity. If you have a trace that reaches it, anaccountantcase would pin the safe direction; nothing here needs to change for this bump.
Author: boazdavid (CONTRIBUTOR — returning external)
Areas reviewed: Go dependency manifests (5 modules), Go tests, accounting behavior (probes), supply-chain (module hashes)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: 40 pass, 1 pending (Go CI (core peerproc, macOS)), 3 skipping
Not checked:
core/plugins/contextgurutests at head — not run locally: module download formodernc.org/sqlitetimes out in this sandbox (the proxy's storage host is unreachable); covered by CI's Go CI (core).go mod tidy -diffin the five modules — blocked locally by acontext-guru v0.7.7zip-hash mismatch in this sandbox's module cache (a stale entry, unrelated to this PR); CI's "Verify module graph is tidy" passes.
Generated by repoman github-pr-review@af425c8.
| // Turn 2: same thread, widen the removal to Bash as well. Bash — the item the turn-1 mark-move | ||
| // rewrite edited — is now deleted from the forwarded body. Before v0.8.0 this failed sum and | ||
| // conservation. | ||
| noFailedChecks(t, "turn 2 remove:[Bash,NotebookEdit]", turn(t, true, "Bash", "NotebookEdit")) |
There was a problem hiding this comment.
suggestion — the test is named KeepsThePrice, but it only asserts that no check failed; it never asserts that anything was priced. That gap is reachable on head: turn 1 of this same test returns zero failed checks and an unpriced entry (accountant.Result.Unpriced{Reason: "penalty_unknown"}), so "the checks are quiet" can hold while a request goes unpriced. A future regression that drops the survivor's price without tripping sum/conservation would pass.
Suggested fix: return the Result from the helper and assert the price the way the sibling test does:
res := turn(t, true, "Bash", "NotebookEdit")
noFailedChecks(t, "turn 2 ...", res)
var moved, removed *accountant.PricedOp
for i := range res.Ops {
switch {
case strings.HasPrefix(res.Ops[i].ChangeID, "tool-prune:NotebookEdit:"):
removed = &res.Ops[i]
case strings.HasPrefix(res.Ops[i].ChangeID, "tool-prune:marker:Bash:"):
moved = &res.Ops[i]
}
}
if moved == nil || moved.Saved.IsZero() {
t.Fatalf("the turn-1 mark move is not priced on turn 2: %+v", res.Ops)
}
if removed == nil || removed.Saved.IsZero() {
t.Fatalf("the widened removal is not priced: %+v", res.Ops)
}On head, turn 2 reports tool-prune:NotebookEdit:… with Saved=CacheRead 836 and tool-prune:marker:Bash:… with Saved=CacheRead 19, so these hold today and fail on v0.6.0 too.
Why it matters now: this test is the PR's evidence that the engine change is safe to take. An assertion that only restates "no check failed" is weaker than the price the PR claims to pin, and nothing else in the suite would notice a silent unpricing.
clawgenti
left a comment
There was a problem hiding this comment.
Summary
A clean dependency bump. accountant and accountant/metrics move to v0.8.0 in all five modules, and the go.sum hashes match everywhere. Both tags point at the same commit (52dd9e6). The v0.6.0..v0.8.0 diff adds no exported JSON-tagged types or decoder fields. The only API addition is the optional metrics.SizedPricer and Observation.Output. Cortex's boundPricer does not implement SizedPricer, so the new re-rate path stays off and cortex's metrics output is unchanged.
I checked the stated fix locally:
TestPrune_WideningRemovalToTheMarkerSurvivorKeepsThePricefails on v0.6.0, exactly as described: turn 2 failssumwithops=3314 bodies=3351and failsconservation. It passes on v0.8.0.- On v0.8.0 with the old tolerance of 1,
TestSavingsAgreesWithTheAccountantCases/inplace/deleted-by-a-later-change/cold-hot/5mfails with a thread total of 7841 vs 7843 µ$. That matches the rounding explanation. go mod tidy -diffis clean andgo build ./...passes in all five modules. Every core package that imports accountant passes its tests.
There is one non-blocking suggestion inline, about the thread-total assertion. One nit on the description: it says "two engine fixes" and then lists three bullets. #112 is a metrics feature, not an engine fix, and it has no effect in cortex today.
Author: boazdavid (CONTRIBUTOR association, admin repo permission — maintainer)
Areas reviewed: Go modules (go.mod/go.sum ×5), Go tests (core/accounting, core/plugins/toolprune), upstream accountant v0.6.0..v0.8.0 diff
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing. Annotations are only the existing Node 20, cache-restore, hadolint and yamllint warnings, with no hidden test failures.
| // µ$, float error puts the value just below the half, so the two paths can disagree | ||
| // by 1 µ$. Each step is held to 1 µ$ above, so the total can drift by up to one µ$ | ||
| // per step. Bound the total by the step count, not by 1. | ||
| if absAgree(gotTotal-wantTotal) > int64(len(c.Steps)) { |
There was a problem hiding this comment.
suggestion: With this bound, the thread-total check can no longer fail by itself. Each step is already held to |got_i - want_i| <= 1 above, so |Σ got_i - Σ want_i| <= Σ|got_i - want_i| <= len(c.Steps) is guaranteed whenever the per-step checks pass. The assertion is now dead code. The original 1 µ$ total bound was there to catch a small bias that repeats on every step (for example, a conversion that is always 0.6 µ$ high). Each step would pass alone, but the total would drift.
To keep that protection without the half-µ$ rounding false positive, you could keep the totals unrounded and round once at the end. Sum the float net in playedNet before microsAgree, sum c.StepPicos(s) on the expected side, and compare microsAgree(gotUSD) against cases.RoundMicros(wantPicos) with a tolerance of 1. The half-µ$ steps (2212.5 + 5212.5) then add up to a whole number before rounding, so they no longer drift. If that is too much churn for a dep bump, dropping the total check, or saying in the comment that it is now implied, would at least make the intent clear.
Summary
github.com/rossoctl/accountantfrom v0.6.0 to v0.8.0 in all five modules that require it:core(direct),cmd/cortex,cmd/cortex-envoy,cmd/agentop,scripts/readme-demo(indirect).github.com/rossoctl/accountant/metricsmodule too. It is now tagged v0.8.0 at the same commit, so it moves off its pseudo-version.SizedPricer(feat(metrics): price savings by the whole bill difference at each prompt size accountant#112).Behavior change
The owner approved this on 2026-11-25.
What changed
*/go.mod,*/go.sumin the five modules: the two version lines each, nothing else.core/plugins/toolprune/accounting_test.go: a regression test for the Need a third end rule: an active in-place rewrite whose item is absent from the next forwarded body has ended accountant#108 shape.core/accounting/savings_agree_test.go: widen the thread-total tolerance from 1 µ$ to the step count.Why the tolerance change
TestSavingsAgreesWithTheAccountantCasesplays every accountant case through Cortex's dollar conversion and nets it per step. v0.8.0 adds the caseinplace/deleted-by-a-later-change. Two of its steps land on an exact half-micro-dollar net (2212.5 and 5212.5 µ$). The library rounds exact pico-dollars half up (→2213, 5213). Cortex'smicrosAgreerounds a float dollar value, where float error puts the true.5just below, so it rounds down (→2212, 5212). Each step stays inside the 1 µ$ per-step tolerance, but two such steps sum to a 2 µ$ drift at the thread total, which had a 1 µ$ tolerance. Each step may legitimately round up to 1 µ$ off, so the total can drift by up to the step count. The per-step check still holds at 1 µ$. No conversion code changed.How it was tested
Run from the repo root, per module, with
GOWORK=off.go mod tidy -diff: clean in all five modules.go build ./...: OK in all five modules.go vet ./...: OK in all five modules.go teston every package that imports accountant (core/accounting/...,core/pipeline,core/plugins/{contextguru,inferenceparser,sessionbudget,toolprune}): all pass.gofmt -lon the two changed test files: clean.Regression test, before and after
TestPrune_WideningRemovalToTheMarkerSurvivorKeepsThePriceincore/plugins/toolprune:sum(3351 − 3314 = 37 bytes, the movedcache_control) andconservation. Turn 1 is clean. This matches Need a third end rule: an active in-place rewrite whose item is absent from the next forwarded body has ended accountant#108.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com