Repository navigation
Refactor: Use one source for the 1h cache-write rate, the billed tier and the accountant's rules - #1091
Conversation
tierUSD priced a 1h write at 2x Input while Event.CostUSD used Price.CacheWrite1h, so a price with cache_write_1h_frac set was priced two ways. Add Price.CacheWrite1hPremium and use it in CostWithCacheWrite1h, tierUSD and spendexplain. NextRequestUSD names the 1h tier by modelinfo.AnthropicCacheTTL1h. Refs #1076 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
accBilledTTL copied keepalive.ResolveTier's rule but kept the asked tier on a turn that wrote nothing, where ResolveTier keeps the thread's last billed one. After a gateway billed a requested 1h cache as 5m, a read-only turn put the 1h tier back, and the next gap of 5 to 60 minutes read as hot. Add keepalive.BilledOneHour, the response half of ResolveTier, and call it from accBilledTTL with a per-thread record of the last billed tier. A thread with no earlier write keeps the asked tier, as before. Behavior change (money): a rescue after a downgrade followed by a read-only turn is no longer credited for the 5 to 60 minute gap. Fixes #1078 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
… arithmetic and SharedWarmFrom Delete the copies of four library rules: - gatedChecks: a check is fatal when CheckFailure.Fatal says so; an unnamed fatal check gates as check_other. - the effect value is tierUSD(ce.Net()). - dash.TierTokens add and less call accountant.TierTokens.Add and Sub; a test fails if the library gains a tier that dash.TierTokens lacks. - siblingStore.sharedWarm builds the sibling list and calls accountant.SharedWarmFrom; commonPrefix, bps2flat, flatOf, positionOf and sectionOrder are gone. The library hides Request fields, so the proxy keeps the meta, the entry facts and the end record itself, and accBilledTTL lowers the TTL with Request.LowerTTL. Behavior change (money): a sibling that sent no breakpoint now counts as warm over the whole shared prefix (accountant design 5.1). The rescue credit is lower in that case. Needs the accountant go.mod bump (LowerTTL, accountant#68). Refs #1077, #1079 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
Brings SharedWarmFrom, Result.Reliable, CacheEffect.Net, TierTokens.Add/Sub and Request.LowerTTL (accountant#67, #68), and the hidden Request fields. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
adaptRates built a fake Event to call Event.repeatRate, the legacy rule. The rate now lives in estimateRepeatRate (dash/estimate.go), which the what-if screens call; Event.repeatRate calls it too. The legacy rule can then go, with the last row written before the accountant switch, without touching the what-if screens. No figure changes. Refs #1080 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
|
Integrator note: the owner added this PR to v0.7.4 (2026-11-12). It has no offload-review round yet. Please run offload-review on the final head, then tell the integrator session. |
…t warm End to end through siblingStore and accountant.SharedWarmFrom: two threads of one session, a warm sibling inside the TTL, and a rescue that credits only the part past the shared prefix. Refs #1079 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID BOAZ <[email protected]>
boazdavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @boazdavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 | offload-review skill, @boazdavid's session | fresh | 2 of 2 | 1 of 2 | 84b2d2e45cb0 |
approve |
Verdict: approve
Findings
None. I tried to break each change and could not. The traces are under "What I checked".
Non-blocking
- proxy/accountant_tier.go:19 + proxy/accountant_wire.go:249 — the tier key has no model.
accPingKey(session, thread)keysbilled1h. A cache entry belongs to one model. A thread that writes 5m-billed on model A, then sends a read-only 1h ask on model B, inherits A's tier. The rescue figure can be off in either direction for that turn. The ping store uses the same key shape, so this follows an existing pattern. Fix only if a real session mixes models in one thread. - proxy/accountant_tier.go:31-34 — the cap resets the whole map.
PingStore.putevicts one entry;tierStore.setdrops every thread. After a reset, each thread's next read-only 1h ask reads the asked tier, which is the pre-fix behavior and can overstate a rescue for one turn per thread. The comment says this. Low impact at 8192 threads. - proxy/accountant_wire.go:255-257 — the comment says more than the code does. "A read-only turn leaves the remembered tier alone", but the code calls
set(key, true)whenwrite == 0andprevis true or unknown. This is sound: a read-only turn never turns a remembered false into a true, becauseoneHour == prevwhenwrite == 0, andsetruns only whenoneHouris true. Only the wording is imprecise.
What I checked
- The full diff
f123d528..HEAD, every file it touches, and the code around each hunk. CLAUDE.md,docs/design.md, and the PR description (fetched the body only; no comments or other reviews).- The new library,
accountant@181c523, from the module cache:CheckFailure.Fatal(gates exactlysum,unique_change,spans),SharedWarmFrom+Body.breakpoints/firstDiff(the old host code inproxy/accountant_shared.gowas the same rule, plus the new no-breakpoint case),Request.LowerTTL(lowersr.facts.TTLand both breakpoint slices;Computereadsr.facts.TTL, so the downgrade is effective),TierTokens.Add/Sub/Net(plain linear arithmetic, sotierUSD(Net())equals the oldtierUSD(Saved) - tierUSD(Caused)). - #1076 pricing.
tierUSDnow prices a 1h token atCacheWrite + CacheWrite1hPremium(). For a derived rate this equals the old2 x Input. For a flat 1h rate or a stated 5m rate above the derived 1h one it changes, which is the fix: it now matchesCostWithCacheWrite1h. The three price shapes inTestTierUSDAgreesWithCostWithCacheWrite1hagree by hand computation. No inlineCacheWrite1h() - CacheWriteis left outsideCacheWrite1hPremiumitself (dash/keepalive.go:1275is a different quantity, 1h write minus read). - #1078 tier keep. Traced
accBilledTTLthrough the async path:accBegin(request goroutine) setsaccMeta;accEndcopies it into the workerw;accEndNowsetsw.accFacts;accWaitjoins viajob.doneand copiesaccFactsback (happens-before holds);finishcallsaccBilledTTLbeforecomputeSafe. Verified the store update rule: withwrite == 0,oneHour == prev, sosetruns only whenprevis true and never overwrites a remembered false. Withwrite > 0the write re-bills the tier. Theprev = truedefault for an unknown thread keeps the asked tier, which is the old behavior. The downgrade path (LowerTTL(5m)) also lowers the client breakpoints, where the old code lowered only the forwarded ones. - #1079 sibling rule. The host keeps only sibling selection (another thread, inside the asked TTL, not later) and the bounds (4096 sessions, 64 threads); the prefix rule moved to
SharedWarmFrom. The new no-breakpoint case lowers the rescue credit, the conservative direction. The end-to-end testTestARescueLeavesOutThePrefixASiblingKeptWarmexercises it throughsavingsTrackerwith no hand-set facts. - #1077 check gating.
accOverridegates onFatal(); today that is the same three checks the deleted map gated, and an unknown fatal check gates ascheck_other.docs/dashboard.mdlists the new reason. - The
end()rewrite (proxy/accountant_savings.go): the map-hit, bytes-equal, bytes-changed and map-miss branches price the same bodies as before. The map-miss path now yields a zerometa, soSharedWarmreturns nil — but no production path callsendafterdrop(drop runs only on the panic path, whereendis never reached, and infinish's defer afterend). - The
estimateRepeatRatemove:Event.repeatRateandadaptRatespass the same arguments the old code passed; the test pins both callers to the same three-case rule. - Process rules: the PR names the three money behavior changes at the top, with who is affected. The data-dependence section covers
tierStore(one bool per thread, in memory, ids only). No component changed, sodatadep_testrows are unaffected. - Tests: every new behavior has a test. I could not run them: live tests were not approved, and Go is not installed on this machine. The PR reports all pass except
TestRateFillTableAndPrice, which it says also fails on unmodifiedmain(a 1-ulp float difference on arm64). I could not verify that claim.
boazdavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @boazdavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 | offload-review skill, @boazdavid's session | fresh | 1 of 2 | 1 of 2 | 84b2d2e45cb0 |
approve |
Verdict: approve
Findings
None. I found no wrong behavior, no data loss, no broken fail-open path and no security problem.
Non-blocking
proxy/accountant_savings.go:75-84— When the client-hash map entry is missing,metastays zero, sosharedWarmgets an empty session and returns nil. The old code readreq.Meta.Sessionand still judged SharedWarm. The path is defensive only today:dropruns only for a request that never ends, andendremoves the entry itself. I could not construct a reachable case. A one-line comment on the else branch would make the silent fallback deliberate.proxy/accountant_wire.go:258-261—accBilledTTLsetsc.accFacts.TTL = 5 * time.Minuteon the host copy and then callsc.accReq.LowerTTL, which writes the library's own record. The two cannot disagree today, because the gate above ensures TTL > 5m. The host-copy write is redundant withLowerTTLand would diverge silently if the gate ever changes. Consider dropping the host-copy write, or asserting the two agree.- The no-breakpoint sibling rule (accountant
SharedWarmFrom) now applies to every provider. On Anthropic, a sibling that sent nocache_controlcached nothing, yet its shared prefix now counts as warm. This under-credits a rescue. That is the conservative direction for a savings figure, the library owns the rule, and the PR names the change. Worth a note in the PR that the rule is not limited to automatic-prefix-caching providers. proxy/accountant_tier.go—tierStorewipes wholesale at 8192 entries. A thread that loses its entry falls back to the asked tier on a read-only turn, which is the pre-fix behavior. The code comment says so. In-memory only, one bool per thread, no content. Acceptable.- The three behavior changes (the 1h rate for
cache_write_1h_fracprices, the read-only turn after a downgrade, the no-breakpoint sibling) are named at the top of the PR, as CLAUDE.md requires. A human developer must still confirm them before merge; I saw no such confirmation yet.
What I checked
- Read
CLAUDE.mdanddocs/design.md. - Read the full diff
f123d528..HEAD(6 commits, 27 files) and the code around each change. - Read the PR description. Did not read any other review or comment on the PR.
- Verified the new accountant library (
181c523e81ae, present in the module cache) exports everything this repo calls:Request.LowerTTL,TierTokens.Add/Sub,CacheEffect.Net,CheckFailure.Fatal, theCheck*constants,Sibling,SharedWarmFrom. Diffed the old library version (5181d50c1f98) against the new one: the changes are the field privatization this PR adapts to, plusProvider,StorageTokensandPricedOp.Kind, which the host does not need to set (zeroProviderkeeps the old tolerance and TTL rules). - Grepped the repo for stale uses of the now-private
Requestfields (Meta,Facts,Breakpoints,Ops,Client,Forwarded). None remain outside the newclientHash.meta,capture.accMeta,capture.accFactsandendRecord. - Traced
accBilledTTLend to end: it runs infinishonly when usage is OK, the status is 2xx androunds <= 1, afteraccWaitjoins the record.LowerTTLonly lowers, on a copy, afterEndRequest. ThetierStoreupdate rule (write turns record their tier, read-only turns keep it) matcheskeepalive.BilledOneHour. Verified against the library that the verdict prefers the storedCache.EntryTTLover the facts' TTL, so a stale remembered tier cannot make a mixed-ask thread read hot. - Checked the pricing identities:
tierUSDon a 1h token equalsCostWithCacheWrite1hfor a derived rate, a flat 1h rate (Write1hFrac: 1.0, asdeploy/service/prices.example.yamlships on six entries) and a stated 5m rate above the derived 1h rate.ce.Net()equals the oldtierUSD(Saved) - tierUSD(Caused)(linear per tier).CacheWrite1hPremiumequals the old inlineCacheWrite1h() - CacheWriteguard at all three call sites. - Checked
estimateRepeatRateis byte-for-byte the oldEvent.repeatRaterule, and thatadaptRatespasses the same three counts the old fakeEventcarried. - Checked
siblingStore.sharedWarm: the host keeps the policy (TTL window, other thread, not later, LRU caps) and passes all qualifying siblings toSharedWarmFrom. The library'sfirstDiff/breakpoints/flatmatch the deleted host helpers' semantics, including out-of-range breakpoint filtering. - Checked
ResolveTier's extraction intoBilledOneHourchanges no behavior, and that the keeper's own call site is untouched. - Checked the new tests compile against the types they use (read-only; I did not run them).
TestTierTokensCarryEveryLibraryTierfails if the library adds a tierdash.TierTokenslacks;TestAnUnnamedFatalCheckStillGatescovers the newcheck_otherpath;docs/dashboard.mdlists it. - Live tests were not approved, so I ran nothing. The PR reports
TestRateFillTableAndPricefails on unmodifiedmaintoo (a 1-ulp float difference on arm64); I could not verify that claim.
…countant-single-source One hand resolution: proxy/accountant_savings.go, struct savingsTracker. Keep both fields: billed1h (this branch) and rescueFactsMissing (main). Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Integrator note: the owner decided both money changes on 2026-11-12.
|
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.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 2 of 2 | 93e4f2edf34e |
approve |
Verdict: approve
Findings
None. The only change since round 1 is a merge of origin/main (abb77b19) into the branch. I checked every point where the two sides touch. The merge is correct at each one.
Non-blocking
Carried from round 1, both mine and reviewer 1's. The merge touches none of them, so they stand as before:
proxy/accountant_tier.go— the tier key has no model, and the 8192-entry cap wipes the whole map. Existing pattern, conservative direction, in-memory only.proxy/accountant_savings.go— on a client-hash map miss,metastays zero, sosharedWarmreturns nil. Defensive path only; no reachable case found.proxy/accountant_wire.go—accBilledTTLwritesc.accFacts.TTLon the host copy and also callsLowerTTLon the library record. Redundant today; the gate keeps the two equal.- The no-breakpoint sibling rule applies to every provider, also ones without automatic prefix caching. It under-credits, the conservative direction. The library owns the rule.
What I checked
- Last review: round 1, 84b2d2e, 2026-11-12T08:26:09Z
- New commits read: 1 on the PR branch,
93e4f2ed(merge oforigin/mainabb77b19, hand resolution inproxy/accountant_savings.go). The range also carries 23 main commits, each read fromgit log --statin full:abb77b19plugins matrix,1bed2683Pi strategies,09f96c53testdb,4a7f8d7etestutil,b5037247Bob setup skip,cd82e95asummary-token test,fff61bfbsubscription figure,826e46f7hosted-vs-local doc,c8f9b67eagentmodel test wait,245f584bstrategy tags,89c98de6CLAUDE.md force-push rule,e13ba47ecounter docs,cfe8d6fbBob strategy offer,c4b284e2plugin versions,791d296ebob-ultrahigh,3048e121proxyapp.Main,bc80520cheld estimate range,d877ba5drelease lessons,ea509595keep-alive body limit,b68d0741rescue-facts counters,55d8b497dedup keep marks,9966adf0data-dependence rows,202087deBob model calls. Each is already on main through its own reviewed PR. They add nothing to this PR's net diff (git diff abb77b19..HEAD) except through the merge resolution. - Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files).
- New items since my last review:
- Integrator comment, 12:01:25Z — the owner confirmed both money changes. I verified the code matches:
modelinfo.CacheWrite1hForreads the entry'scache_write_1h_fracwhen set, else the Anthropic 2x;dash.tierUSDprices a 1h write atCacheWrite + CacheWrite1hPremium(), the same number. This closes reviewer 1's round-1 note that no human confirmation was on record. - Merge commit
93e4f2ed— checked as follows.
- Integrator comment, 12:01:25Z — the owner confirmed both money changes. I verified the code matches:
- The merge resolution,
proxy/accountant_savings.go: the struct keeps bothbilled1h(this branch) andrescueFactsMissing(main, #1099).newSavingsTrackerstill setsbilled1h; the atomic counter needs no init. Both methods are nil-safe. - The counter path end to end. Main's
#1099code now runs inside this branch's async accountant flow:finishcallsaccWait(line 826) before it readsc.accPingWindow(set by the worker, copied back ataccountant_wire.go:78), so thekaPings > 0 && accPingWindow == ""check sees the worker's result. The check sits in the samerounds <= 1branch as on main. The drop key changed fromc.accReq.Meta.Session(main, public library field) toc.accMeta.Session(branch, private field) — the branch already used that form at84b2d2e, andaccMetais set byaccBeginbeforeaccEndcan run, so the key is the same value the library holds. - Every file both sides changed since the merge base
f123d528:dash/accountant_price.go,dash/event.go,docs/dashboard.md,keepalive/keeper.go,proxy/accountant_savings.go,proxy/dashcapture.go. The first three andkeeper.gochanged in separate regions; the merged files carry both sides (verifiedBilledOneHourandpol.BodyLimit()together inkeeper.go,EstimatedSavedLowUSDand the newtierUSDtogether indash). - The
tierUSD/held-floor interaction, the one place the two sides meet in logic:heldFloorUSD(main, #1001) re-prices saved tokens at the read rate using the branch'stierUSDfor the ceiling. Both bounds use the same per-model 1h premium, and the guard atdash/accountant_price.go:477keeps the floor at or below the ceiling. Coherent. - The library bump: the merge keeps the branch's
rossoctl/accountant 181c523e81ae(private fields). I grepped the merged tree for uses of the now-privateRequestfields (Meta,Facts,Breakpoints,Ops,Client,Forwarded); none remain outside the branch's ownclientHash.meta,capture.accMetaandendRecord. No branch-changed file was moved by main's#1109(cmd/context-guru-proxy→proxyapp/), so no edit needed porting. - Earlier findings: mine and reviewer 1's round-1 verdicts were approve with non-blocking notes only. None was a blocking finding, so nothing to re-check as fixed or rejected; their status is under "Non-blocking" above. Reviewer 1's confirmation point is now closed by the owner's decision.
- Live tests were not approved, so I ran nothing. Go is not installed on this machine.
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.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 2 of 2 | 93e4f2edf34e |
approve |
Verdict: approve
Findings
None. The only new commit is a merge of main. I checked its resolution and every place the two sides meet. I found no lost change and no broken interaction.
Non-blocking
- docs/data-dependence/features/accountant-savings.md — the row does not name the tier bool. The PR adds
tierStore: one bool per thread, in memory, keyed by session and thread id. The row text covers per-thread in-memory state in general ("hashes are held in memory, one set per conversation thread"), so the level does not change. One sentence naming the tier bool would make it deliberate. - My round-1 notes 1 to 4 (the defensive map-miss path, the redundant host-copy TTL write, the sibling rule on non-automatic-prefix providers, the tierStore wholesale wipe) still stand as written. The merge changed none of that code.
What I checked
- Last review: round 1, 84b2d2e, 2026-11-12T08:28:01Z.
- New commits read: 1 — 93e4f2e "Merge remote-tracking branch 'origin/main' into refactor/1076-1080-accountant-single-source". The 23 commits inside it are main's, each already reviewed on its own PR.
- Read in full: 2 reviews, 2 comments, 0 inline comments (from the three files).
- New items since my last review:
- Merge commit 93e4f2e (13:45). What I did: recomputed the automatic merge of both parents with
git merge-tree --write-tree. It conflicts in one file only,proxy/accountant_savings.go. I diffed HEAD against the automatic-merge tree: the only difference is the three conflict-marker lines. So the merge is the exact union of both parents, and nothing from either side was dropped anywhere. - The hand resolution itself:
savingsTrackerkeeps both fields —billed1h(this branch, #1078) andrescueFactsMissing(main, #1099).newSavingsTrackerstill setsbilled1h;rescueFactsMissingis a zero-value atomic. Both sides' methods are present. - Comment by @amiddavid at 12:01:25 (integrator note): the owner decided both money changes on 2026-11-12, quoted. This resolves my round-1 note that a human must confirm them. The note also says the integrator merges main without force; the merge commit matches that.
- Comment by @amiddavid at 07:13:21 predates my round-1 review. Already known.
- Merge commit 93e4f2e (13:45). What I did: recomputed the automatic merge of both parents with
- Semantic interactions of the merge, each read at HEAD:
proxy/dashcapture.gofinish:accBilledTTL(branch) runs beforecomputeSafe, then main'snoteRescueFactsMissingcounter and the ping drop. The drop line usesc.accMeta.Session, the branch's adaptation of main's line. Both behaviors kept, order unchanged.keepalive/keeper.go: the branch'sResolveTier/BilledOneHourextraction and main's #1102 body-limit change (Policy.BodyLimit, the unpriced-model 8 MiB fallback) touch different functions. No overlap.dash/accountant_price.go: main's #1001heldFloorUSDprices its floor with the branch'stierUSD, which now usesCacheWrite1hPremium. Ceiling and floor use the same pricing rule, and the guard at the end keeps the floor at or below the ceiling. Coherent.dash/event.go: the branch'srepeatRate→estimateRepeatRatemove and main'sEstimatedSavedLowUSDfield coexist;PriceandPriceModeboth reset the new field.- Tests: no test file references the library fields this branch privatized (
accReq.Metaand friends). Main'spingunpriced_test.gobuildscapturewith named fields andnewSavingsTracker(), which compiles against the merged struct. go.mod: the only change against main is the branch's accountant bump to181c523e81ae, verified in round 1.- Data dependence: the branch never edited
docs/data-dependence.mdor the row files (checked against the round-1 merge basef123d528), so main's #1090 restructure lost nothing from this PR. No component changed, sodatadep_testis unaffected.
- Earlier findings: my round 1 and reviewer 2's round 1 were both approves with non-blocking notes only, so there was nothing to fix. Status of my notes: note 5 (human confirmation of the money changes) is resolved by the owner's decisions quoted in the integrator's comment; notes 1 to 4 stand as observations, unchanged by the merge.
- Live tests were not approved, so I ran nothing.
Behavior changes (money): a developer must confirm
cache_write_1h_fracset (Refactor: Use one source for the 1h cache-write rate #1076).tierUSDpriced a 1h write at 2x Input.Event.CostUSDpriced it at the model's 1h rate. For a price that setscache_write_1h_frac: 1.0the two differed.deploy/service/prices.example.yamlships such entries (premium,standard,premium-ide). The accountant figure now uses the same rate asEvent.CostUSD. Bundled model prices are unaffected. Not switchable: the old figure was the wrong one.accBilledTTLput the 1h tier back, so a 5 to 60 minute gap after it read as hot, and a rescue could be overstated by up to 55 minutes of idle time.accBilledTTLnow keeps the thread's last billed tier on a read-only turn, askeepalive.ResolveTierdoes. A thread with no earlier write keeps the asked tier, as before. Also, the saving after a downgrade is priced at the 5m tier: the library'sRequest.LowerTTLlowers the client breakpoints as well as the forwarded ones, whereaccBilledTTLlowered only the forwarded ones. Not switchable.sharedWarmreturned nothing for such a sibling. The library rule says that with no breakpoint every position is one (accountant design §5.1, §6.2), so the rescue credit is lower in that case (R54). Who is affected: providers with automatic prefix caching (for example OpenAI) when two threads of a session share a prefix. Not switchable.What this PR does
Price.CacheWrite1hPremiumis the one place the 1h premium is taken.CostWithCacheWrite1h,tierUSDandspendexplain.gouse it.oneHourWriteInputMultipleis deleted.NextRequestUSDnames the 1h tier withmodelinfo.AnthropicCacheTTL1h.keepalive.BilledOneHouris the response half ofResolveTier, andResolveTiercalls it.accBilledTTLcalls it with a per-thread record of the last billed tier (proxy/accountant_tier.go, bounded, no content), thenRequest.LowerTTL.go.mod: accountant is bumped to181c523(accountant#67, docs(components): document marker_mode on the six pages that omit it, and collapse's max_frac #68). The new library hides theRequestfields, so the proxy keeps the meta (clientHash.meta,capture.accMeta), the entry facts (capture.accFacts) and the end record (endRecord) itself.gatedChecksis deleted.CheckFailure.Fataldecides. A fatal check this host has no name for gates as the new reasoncheck_other(indocs/dashboard.md). The effect value istierUSD(ce.Net()).dash.TierTokens.addandlesscall the library'sAddandSub.commonPrefix,bps2flat,flatOf,positionOfandsectionOrderare deleted.siblingStorekeeps the policy (4096 sessions, 64 threads, TTL, LRU) and callsaccountant.SharedWarmFrom.Tests
TestTierUSDAgreesWithCostWithCacheWrite1h:tierUSDequalsCostWithCacheWrite1hfor a derived rate, a flat 1h rate and a 5m rate above the derived 1h rate.TestAReadOnlyTurnKeepsTheLastBilledTier: written first. It failed (phase = "hot") before the fix.TestBilledOneHourIsResolveTiersResponseHalf.TestSharedWarm: a new case, a sibling without breakpoints.TestARescueLeavesOutThePrefixASiblingKeptWarm: end to end. Two threads of one session, a warm sibling inside the TTL, and a rescue that credits only the part past the shared prefix (it fails ifSharedWarmFromis not called).TestAnUnnamedFatalCheckStillGates,TestTierTokensCarryEveryLibraryTier(fails if the library gets a tier thatdash.TierTokenslacks).Resultinstead.go test ./dash/ ./proxy/ ./keepalive/ ./internal/...pass, exceptTestRateFillTableAndPriceininternal/modelinfo. It fails on unmodifiedmaintoo (a 1-ulp float difference on arm64).go vet ./...,gofmt -landgo mod tidy -diffare clean.Data dependence
No feature changes. No new stored data.
tierStorekeeps one bool per thread in memory.check_otheris a new value for a column that already holds the othercheck_*reasons.#1080: the part done now, and the part that waits
Decided: rows written before the accountant switch (
priced_by '') age out. The what-if screens (adapt-compaction) keep a small estimate rule.estimateRepeatRate(dash/estimate.go) is the one place the what-if screens price a re-sent block.adaptRatescalls it, no longer through a fakeEvent.Event.repeatRatecalls it too. No figure changes (TestEstimateRepeatRate).ComponentSavedUSD,uniqueRate,Event.repeatRateandMarkUniquestay until the lastpriced_by ''row has aged out. The default retention is 7 days and the accountant pricing re-landed on 2026-11-09 (Feat: Re-land the accountant pricing of proxy savings (#768) with the review fixes #930), so with defaults that is about 2026-11-16. A longer retention keeps them longer. Their only readers left are the legacy-row paths (readvalue.go,summarizeattr.go,replaycap.go'sfirstShare). Issue Refactor: Delete the legacy savings rule after old rows age out (rest of #1080) #1123 tracks the deletion. A later PR deletes them after a count (SELECT priced_by, COUNT(*) FROM request_components GROUP BY priced_by) on a long-lived database, and reduces the tool-defer ledger toSearchCost.Fixes #1076
Fixes #1078
Fixes #1077
Fixes #1079
Refs #1080 (the remaining work is in #1123)
Assisted-By: Claude (Anthropic AI) [email protected]