Repository navigation
revert: Price proxy savings with the accountant library (#768) - #903
Conversation
This reverts commit 0c0e9ff. The author found bugs in #768, and the repo owner took it out of the next release. The dashboard goes back to the savings rules from before #768. The author reopens the work in a new PR with the fixes. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 77e4f27badcf |
approve |
Verdict: approve
Findings
None. The revert is exact and complete. See "What I checked" for the proof.
Non-blocking
- dash/store.go:349 — the read-only shim covers
requestsonly again. #768 had generalized it to every table with additive columns, includingrequest_components. The revert takes that back. Effect: a read-only tool that opens an old database missingrequest_components.eventsorsaved_usdfails with "no such column", as it did before #768. This restores the shipped pre-#768 state, so it is not a new defect. If the shim generalization was worth keeping, it needs its own small PR. - Mixed-ruler window. Rows a #768 proxy wrote while it was deployed keep their stored accountant figures in
saved_usd. The reverted read views value those rows from their token counts with the legacy rule. A dashboard window that spans the revert mixes the two rules. This is inherent to any revert of a pricing change and needs no code.
What I checked
- The revert is exact. I compared the whole tree, not the diff alone. Let PRE be
0c0e9ff5^(the commit before #768). Every file the PR changes matches its PRE version byte for byte, except four:dash/overview.go,dash/query.go,dash/ui/app.js,proxy/proxy.go. Five commits landed between #768 and this PR's base (0f0d2d84,4090759b,6460acdf,47de51a9,dd3cfa6f), and those four files are exactly the ones they touched. I read each of the four diffs PRE→HEAD: the only content is the tool-deferral lever (#891), the Responses streaming and WebSocket fast-fail (#894), and the preset status (#889). Nothing from the later commits was lost. No file differs between PRE and HEAD that no later commit touched, so no #768 code survives anywhere and no new code was added. - No dangling references. I grepped the whole tree for every symbol #768 introduced or removed:
rossoctl/accountant,PingStore,PingSavings,accBegin/accEnd/accDrop,noteRounds,savingsTracker,PriceMode,SetAccountant,AccountantFallback,PricedByAccountant,PriceEstimated/price_estimated,priced_by,saved_first_usd,saved_replay_usd,SavedFirstUSD,SavedReplayUSD,SavedUSDCosts,Windowon the keep-alive report,Tap,opsFromRun,wireSizes. Zero hits in Go, JS, MJS and docs.go.mod/go.sumdrop therossoctl/accountantmodule and no import remains. There is nogo.work. - Schema safety on existing databases. #768 added
requests.price_estimatedand therequest_componentssplit columns as additive columns with defaults, without a schema-version bump. The revert removes them from the DDL and fromadditiveColumns. Migration isALTER TABLE … ADD COLUMNonly (dash/schema.go:1040), never DROP, so a database a #768 proxy wrote keeps the extra columns unused and the revertedINSERT(which omits them) still works through theirNOT NULL DEFAULT.schemaVersionis 6 at PRE, at base and at HEAD, so no version mismatch blocks opening any of these databases. - Read every changed line. I read the full diff for all 85 files: the library paths (
apply/apply.go,components/component.go,components/pipeline.go), the proxy wiring (proxy/proxy.go,proxy/dashcapture.go,cmd/context-guru-proxy/main.go), the dash pricing and read paths (dash/event.gowith the restoredbaselineDeltaUSD,cachesplitSavedUSD,keepaliveSavedUSD;dash/query.go,dash/readvalue.go,dash/replaycap.go,dash/summarizeattr.go,dash/adaptcompaction.go,dash/compactepisode.go,dash/keepalive.go), the keep-aliveWindowremoval,internal/modelinfo, and every deleted or restored test and doc. The deletions are exactly the files #768 added; the restored tests (dash/billedfactor_test.go,dash/keepalivecost_test.go, and the rest) are the pre-#768 ones. - Repo rules. The PR removes a feature, so
docs/data-dependence.mdloses the accountant row — correct, andcomponents/all/datadep_test.gois about registered components, which the accountant pricing is not. The behavior change restores pre-#768 figures, and the commit message records the repo owner's decision to pull #768 from the release. Fail-open paths are untouched: the revert removes only pricing code, and every removed path (panic recovery, observe mode) keeps its pre-#768 shape. - Live tests were not run. Go is not installed on this machine and the review brief did not approve them. The compile and test risk is bounded by the tree comparison: the code is the pre-#768 code that built and passed, plus the five already-merged commits.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 77e4f27badcf |
approve |
Verdict: approve
Findings
None. The revert is clean and I could prove it structurally (see "What I checked").
Non-blocking
- A window spanning the #768 period mixes two rulers. A database that #768 already
migrated keeps the accountant's figures incachesplit_saved_usd,
keepalive_saved_usdand the componentsaved_usd. The restored Overview sums those
stored columns as written, and the components view re-prices stored component dollars
with the legacy formula. So old rows keep accountant figures while new rows get the
v0.6.6 rules. #768 merged and reverted on the same day (2026-11-04), so this touches
dev databases only. The PR declares the behavior change at the top, so this needs no
action. - The read-only shim covers
requestsonly again (dash/store.go:337). This is the
pre-#768 state, restored faithfully. #768 had generalized it to every table with
additive columns, which also coveredrequest_components. An old database that lacks
request_components.saved_usdstill fails a read-only query that names it. The defect
predates this PR; a revert must not fix it. If it matters, it needs its own issue.
What I checked
- The revert is exact. I diffed HEAD against
0c0e9ff5^(main before #768). The diff
touches 35 files, all of them the five later PRs' files (#889, #891, #894, #896, #897).
Every hunk in that diff is later-PR content. No file the later PRs did not touch
differs from pre-#768 by one byte. No pre-#768 file was deleted (0 deletions in
git diff --name-status 0c0e9ff5^..HEAD). - No accountant remnant. I grepped the whole tree for
rossoctl/accountant,PriceEstimated,price_estimated,priced_by,
saved_first_usd,SavedFirstUSD,PingStore,PingSavings,savingsTracker,
accBegin,accEnd,accDrop,noteRounds,OpsFromRun,SetAccountant,
PriceMode,Trace.Ops,gapStart,KeepAliveReport.Window,CountChanged,
changesOf,spliceOf,wireSizes. The only hit is an unrelated test name in
context-guru-plugin. - The later PRs survived the auto-merge. The 4 overlapping files keep every later
feature:DeferNetUSDindash/overview.goand the waterfall step (#891); the
defer_net_usdbucket series indash/query.go(#891); the tool-deferral card and day
columns indash/ui/app.js(#891); the WebSocket 426 route, the stateless Responses
splice and the stats preset inproxy/proxy.go(#894, #897).savingsArithmetic
takesdeferNetat all four call sites (dash/savings.go:73,dash/overview.go:1101,
dash/overview_lean.go:76,dash/cachestate.go:313), and the UI'ssavedPartsadds
defer. That answers the PR's own open item: the Savings total still adds up. - The restored code resolves every symbol it names.
modelinfo.GPT56OrLater,
modelinfo.CacheLifetime,apply.TTLEphemeral1h,repeatRate,uniqueRate,
SummarizerComponentsall exist with matching signatures. Imports the revert trimmed
(reflect,sha256,hexincomponents/pipeline.go;strconv,gjsonin
proxy/proxy.go) are still used elsewhere in those files.wireGroupskeeps its
pre-#768 caller (apply/apply.go:698,Ctx.WireGroup, #457). - Database compatibility.
insertBatchand the component insert name their columns,
so the four columns a #768-migrated database gained (price_estimated,
saved_first_usd,saved_replay_usd,priced_by) sit unread with
NOT NULL DEFAULT 0. No query names them. The read-only shim change in
dash/store.gowas introduced by #768 itself (verified ingit show 0c0e9ff5), so
restoring the single-table shim is faithful. - Tests. Every deleted test file was a #768 addition (the
Windowtests in
keepalive/, theapply/ops_*tests,dash/openreadonly_test.go,
cmd/context-guru-proxy/dashemitter_savings_test.go). Every restored test file
(dash/keepalivecost_test.go,dash/billedfactor_test.go,
dash/keepalive_ttl_test.go) existed at0c0e9ff5^(verified withgit cat-file). - Docs and rules. The data-dependence row is removed with the code; the accountant
was not a registered pipeline component, socomponents/all/datadep_test.gois safe.
The behavior change is named at the top of the PR with the owner's approval quoted.
Live tests were not approved for this review, so I verified by reading only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (bob, user of @amiddavid) | IBM Bob Shell 1.0.3 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 77e4f27badcf |
approve |
Verdict: approve
Findings
None. The PR cleanly removes the accountant library integration without breaking the fail-open guarantee or introducing data loss.
Non-blocking
-
The PR removes a significant amount of test coverage (238 lines in
accountant_wire_test.go, 112 lines inaccountant_shared_test.go). The removed tests validated the accountant library's integration with the proxy. The internal pricing logic indash/event.gohas its own test coverage, but consider whether any integration-level tests should be preserved or adapted. -
proxy/savings_test.goline 88 comment still references "the accountant library books a saving" but the library is now removed. The test itself is correct (it usessavingsUpstream), but the comment is outdated. -
The diff shows
dash/event.gochanged fromPriceModetoPrice, removing accountant-specific logic. The newPricemethod is simpler and computes savings directly. This is the intended behavior change, but it represents a shift from an external library's calculation to an internal one. The PR description should state this explicitly as a behavior change per CLAUDE.md rules.
What I checked
- Read CLAUDE.md and docs/design.md for repo rules
- Read the full diff from base dd3cfa6 to head 77e4f27
- Verified all accountant imports are removed from the codebase
- Confirmed the accountant dependency is removed from go.mod
- Checked that
dash/event.goPrice method maintains the baseline cost calculation - Verified fail-open paths remain intact: the pricing logic returns zero costs when accounting is incomplete, which is the correct fail-open behavior
- Confirmed no data loss: the Event struct retains all token counts and cost fields
- Checked that test files are consistently removed (no orphaned references)
- Verified the proxy's capture flow still calls
e.Price()with the same parameters - Confirmed the dashboard's cost attribution logic (cachesplit, keepalive, per-component) remains unchanged in structure
On ultrahigh (and OpenAI routes with our tool search), a keep-alive ping touched a different cache-clock key than the one the next request reads: deferral changes messages[1], so the alias derived after deferral differed. The turn read cold and the sweep cut a live prefix. Now apply derives the touch alias once, from the pre-deferral body, and passes it through Trace.TouchAlias to keepalive.Record.TouchAlias; the ping, the substitute and the manual ping touch that key. No default changes. Reviewed by GLM x2 (offload-review, round 3) at ad769b2, including the conflict resolution with the #903 revert. Bug fix approved by the repo owner in the integrator session on 2026-11-04 ("I approve the behavior change on 904"). Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
…) with the review fixes (#930) This PR re-lands the accountant pricing of proxy savings (#768). #903 reverted #768. This PR brings it back. It adds the review fixes #906 to #920 and #938 to #940. It speeds up the request path: 2.8 ms and 87 allocations, from 4.8 ms and 4,905, on a 600 KB body. It moves the accountant pin to 5181d50c. Fixed issues: #906 tail breakpoint mark reported as an operation #907 tool-section operations left out of the plausibility bound #908 tool deferral names list reported as an operation #909 cachesplit saving credited on a short conversation #910 kept-wire preference kept off standalone messages #911 measured filter requests and reads kept on priced rows #912 library keep-alive rescue trusted; TTL judged by billed tier #913 request after a manual ping pinned hot; manual figure is an estimate #914 no saved tokens booked on a rejected request #915 no-history estimate held out of the totals #916 since and until exact in the stats cache key #917 state file versioned, synced, de-duplicated #918 panics recovered in ping pricing and in accBegin #919 TTL judged by the billed tier (with #912) #920 first-request pricing pinned in a test #938 cacheinject marks reported to the accountant #939 acc_fallback line says why an event is unpriced #940 replay cap reopens at each close Behavior change: the replay cap reopens after each close (#940). Before, the cap closed once and dropped all later replay credit. Now each close ends the credit of earlier removals. A removal after a close earns credit until the next close. A counterfactual compaction closes the epoch. The assumed summary is 80,000 tokens, or half of C when C is at most 160,000. The new field avoided_compaction_usd is in no total. Known limit: it can over-count when the trimmed transcript is larger than the baseline summary. Not measured on real sessions. Owner's yes, 2026-11-09, in the integrator session: "930 is ready and I want u to merge and start new release immediately" (v0.7.0 holds #930 only). DCO: 12 commits have no Signed-off-by. The owner accepted the risk for #930, 2026-11-09, in the integrator session ("b"). They are 37d4c6e 0206b44 ec660bd b0b7e70 9dc81c7 6c43448 061dfd2 9a972d4 5e47f96 fbf993b b41f5e7 e639b12. Data dependence: metadata only. With storage off, it does not run: it needs the dashboard. At the metadata and everything levels, the new accountant row keeps hashes, sizes and ids, no message text. The dashboard rows add the flags acc_priced and estimate_held and the number estimated_saved_usd. Reviews: 2 offload reviews (claude backend), round 9, both approve at dac0790. CI green at dac0790 (build-test passed on a rerun; the first run failed the timing test TestDashboardAddsNoRequestLatencyWithContentCapture). Signed-off-by: DAVID BOAZ <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
Summary
Revert #768 (
0c0e9ff5). The author found bugs in it, and the repo owner took it out of the next release. The author will reopen the work in a new PR with the fixes.Behavior change (approved by the owner: "open the revert PR", 2026-11-04)
What changed
git revert 0c0e9ff5, with no conflicts. 85 files, +909 / -7,847.dash/overview.go,dash/query.go,dash/ui/app.js,proxy/proxy.go). Git merged them on its own.priced_by,price_estimated,saved_first_usd, the accountant module).How it was tested
go vet ./...andgo build ./...pass.go testpasses on./dash/...,./proxy/...and every other package.Technical notes
request_componentsand theprice_estimatedcolumn onrequestsare additive. A database that feat(accountant): Price proxy savings with the accountant library #768 already migrated keeps them, unused. The old code does not read them.🤖 Generated with Claude Code