Skip to content

chore(deps): [cg] Bump the accountant to v0.8.0 - #2131

Open
boazdavid wants to merge 1 commit into
rossoctl:mainfrom
boazdavid:cg/12-accountant-v080
Open

boazdavid wants to merge 1 commit into
rossoctl:mainfrom
boazdavid:cg/12-accountant-v080

Conversation

@boazdavid

Copy link
Copy Markdown
Contributor

Summary

Behavior change

The owner approved this on 2026-11-25.

  • The change is accounting only. It changes the money and token figures the accountant reports for one request shape. It does not change any request or response the proxy sends.
  • There is no off switch. It is a library fix, not a config flag.
  • The affected shape: tool-prune moves a cache mark onto a surviving tool on one turn, and a later turn on the same thread deletes that survivor. Before the fix, those later turns reported no saving and a failed check. After the fix, they are priced.

What changed

Why the tolerance change

TestSavingsAgreesWithTheAccountantCases plays every accountant case through Cortex's dollar conversion and nets it per step. v0.8.0 adds the case inplace/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's microsAgree rounds a float dollar value, where float error puts the true .5 just 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 test on every package that imports accountant (core/accounting/..., core/pipeline, core/plugins/{contextguru,inferenceparser,sessionbudget,toolprune}): all pass.
  • gofmt -l on the two changed test files: clean.

Regression test, before and after

TestPrune_WideningRemovalToTheMarkerSurvivorKeepsThePrice in core/plugins/toolprune:

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

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>
@boazdavid
boazdavid requested a review from a team as a code owner November 25, 2026 18:13
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c162e337-a7a3-4d2f-9ca8-145216828ae9
Commits

Reviewing files that changed from the base of the PR and between a4047fc and 5efe292.

Files ignored due to path filters: 5

  • cmd/agentop/go.sum is excluded by !**/*.sum
  • cmd/cortex-envoy/go.sum is excluded by !**/*.sum
  • cmd/cortex/go.sum is excluded by !**/*.sum
  • core/go.sum is excluded by !**/*.sum
  • scripts/readme-demo/go.sum is excluded by !**/*.sum
Files selected for processing: 7

  • cmd/agentop/go.mod
  • cmd/cortex-envoy/go.mod
  • cmd/cortex/go.mod
  • core/accounting/savings_agree_test.go
  • core/go.mod
  • core/plugins/toolprune/accounting_test.go
  • scripts/readme-demo/go.mod
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions github-actions Bot added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 25, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 verify in core: the v0.8.0 zips resolve and match the hashes in all five go.sum files. Worth noting why both requires must stay explicit: accountant/metrics v0.8.0's own go.mod requires github.com/rossoctl/accountant v0.0.0 behind a replace (ignored outside that module), so it is core/go.mod's v0.8.0 line 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) and conservation (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 > 1 at core/accounting/savings_agree_test.go:143 fails exactly one case, inplace/deleted-by-a-later-change/cold-hot/5m, with thread 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 test passes for core/accounting/..., core/pipeline, core/plugins/{inferenceparser,sessionbudget,toolprune}; go vet and gofmt -l are clean on the two changed test files.

Notes, not findings

  • SizedPricer is inert in Cortex: core/accounting/metrics.go:147 passes a *boundPricer, which implements only Price (core/accounting/metrics.go:468), so accountant/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 implements PriceAt would 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, an accountant case 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/contextguru tests at head — not run locally: module download for modernc.org/sqlite times out in this sandbox (the proxy's storage host is unreachable); covered by CI's Go CI (core).
  • go mod tidy -diff in the five modules — blocked locally by a context-guru v0.7.7 zip-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"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_WideningRemovalToTheMarkerSurvivorKeepsThePrice fails on v0.6.0, exactly as described: turn 2 fails sum with ops=3314 bodies=3351 and fails conservation. 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/5m fails with a thread total of 7841 vs 7843 µ$. That matches the rounding explanation.
  • go mod tidy -diff is clean and go 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)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

Status: New/ToDo

Development

Successfully merging this pull request may close these issues.

Need a third end rule: an active in-place rewrite whose item is absent from the next forwarded body has ended

2 participants