Skip to content

Refactor: Use one source for the 1h cache-write rate, the billed tier and the accountant's rules - #1091

Merged
amiddavid merged 7 commits into
mainfrom
refactor/1076-1080-accountant-single-source
Nov 12, 2026
Merged

amiddavid merged 7 commits into
mainfrom
refactor/1076-1080-accountant-single-source

Conversation

@boazdavid

@boazdavid boazdavid commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior changes (money): a developer must confirm

  1. Accountant figure for a price with cache_write_1h_frac set (Refactor: Use one source for the 1h cache-write rate #1076). tierUSD priced a 1h write at 2x Input. Event.CostUSD priced it at the model's 1h rate. For a price that sets cache_write_1h_frac: 1.0 the two differed. deploy/service/prices.example.yaml ships such entries (premium, standard, premium-ide). The accountant figure now uses the same rate as Event.CostUSD. Bundled model prices are unaffected. Not switchable: the old figure was the wrong one.
  2. Rescue credit after a gateway downgrade (Fix: Align accBilledTTL with keepalive.ResolveTier on read-only turns #1078). A gateway billed a requested 1h cache as 5m. The next turn only read the cache. accBilledTTL put 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. accBilledTTL now keeps the thread's last billed tier on a read-only turn, as keepalive.ResolveTier does. 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's Request.LowerTTL lowers the client breakpoints as well as the forwarded ones, where accBilledTTL lowered only the forwarded ones. Not switchable.
  3. A sibling thread that sent no breakpoint counts as warm over the whole shared prefix (Refactor: Move SharedWarm prefix selection into accountant #1079). sharedWarm returned 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

Tests

  • TestTierUSDAgreesWithCostWithCacheWrite1h: tierUSD equals CostWithCacheWrite1h for 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 if SharedWarmFrom is not called).
  • TestAnUnnamedFatalCheckStillGates, TestTierTokensCarryEveryLibraryTier (fails if the library gets a tier that dash.TierTokens lacks).
  • Two tests no longer read private library fields. They check the priced Result instead.
  • go test ./dash/ ./proxy/ ./keepalive/ ./internal/... pass, except TestRateFillTableAndPrice in internal/modelinfo. It fails on unmodified main too (a 1-ulp float difference on arm64).
  • go vet ./..., gofmt -l and go mod tidy -diff are clean.

Data dependence

No feature changes. No new stored data. tierStore keeps one bool per thread in memory. check_other is a new value for a column that already holds the other check_* 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.

  • Done: estimateRepeatRate (dash/estimate.go) is the one place the what-if screens price a re-sent block. adaptRates calls it, no longer through a fake Event. Event.repeatRate calls it too. No figure changes (TestEstimateRepeatRate).
  • Waits: ComponentSavedUSD, uniqueRate, Event.repeatRate and MarkUnique stay until the last priced_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's firstShare). 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 to SearchCost.

Fixes #1076
Fixes #1078
Fixes #1077
Fixes #1079
Refs #1080 (the remaining work is in #1123)

Assisted-By: Claude (Anthropic AI) [email protected]

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]>
@boazdavid boazdavid changed the title Fix: Use one source for the 1h cache-write rate and the billed tier Refactor: Use one source for the 1h cache-write rate, the billed tier and the accountant's rules Nov 11, 2026
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]>
@amiddavid

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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) keys billed1h. 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.put evicts one entry; tierStore.set drops 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) when write == 0 and prev is true or unknown. This is sound: a read-only turn never turns a remembered false into a true, because oneHour == prev when write == 0, and set runs only when oneHour is 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 exactly sum, unique_change, spans), SharedWarmFrom + Body.breakpoints/firstDiff (the old host code in proxy/accountant_shared.go was the same rule, plus the new no-breakpoint case), Request.LowerTTL (lowers r.facts.TTL and both breakpoint slices; Compute reads r.facts.TTL, so the downgrade is effective), TierTokens.Add/Sub/Net (plain linear arithmetic, so tierUSD(Net()) equals the old tierUSD(Saved) - tierUSD(Caused)).
  • #1076 pricing. tierUSD now prices a 1h token at CacheWrite + CacheWrite1hPremium(). For a derived rate this equals the old 2 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 matches CostWithCacheWrite1h. The three price shapes in TestTierUSDAgreesWithCostWithCacheWrite1h agree by hand computation. No inline CacheWrite1h() - CacheWrite is left outside CacheWrite1hPremium itself (dash/keepalive.go:1275 is a different quantity, 1h write minus read).
  • #1078 tier keep. Traced accBilledTTL through the async path: accBegin (request goroutine) sets accMeta; accEnd copies it into the worker w; accEndNow sets w.accFacts; accWait joins via job.done and copies accFacts back (happens-before holds); finish calls accBilledTTL before computeSafe. Verified the store update rule: with write == 0, oneHour == prev, so set runs only when prev is true and never overwrites a remembered false. With write > 0 the write re-bills the tier. The prev = true default 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 test TestARescueLeavesOutThePrefixASiblingKeptWarm exercises it through savingsTracker with no hand-set facts.
  • #1077 check gating. accOverride gates on Fatal(); today that is the same three checks the deleted map gated, and an unknown fatal check gates as check_other. docs/dashboard.md lists 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 zero meta, so SharedWarm returns nil — but no production path calls end after drop (drop runs only on the panic path, where end is never reached, and in finish's defer after end).
  • The estimateRepeatRate move: Event.repeatRate and adaptRates pass 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, so datadep_test rows 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 unmodified main (a 1-ulp float difference on arm64). I could not verify that claim.

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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, meta stays zero, so sharedWarm gets an empty session and returns nil. The old code read req.Meta.Session and still judged SharedWarm. The path is defensive only today: drop runs only for a request that never ends, and end removes 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 — accBilledTTL sets c.accFacts.TTL = 5 * time.Minute on the host copy and then calls c.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 with LowerTTL and 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 no cache_control cached 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 — tierStore wipes 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_frac prices, 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.md and docs/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, the Check* constants, Sibling, SharedWarmFrom. Diffed the old library version (5181d50c1f98) against the new one: the changes are the field privatization this PR adapts to, plus Provider, StorageTokens and PricedOp.Kind, which the host does not need to set (zero Provider keeps the old tolerance and TTL rules).
  • Grepped the repo for stale uses of the now-private Request fields (Meta, Facts, Breakpoints, Ops, Client, Forwarded). None remain outside the new clientHash.meta, capture.accMeta, capture.accFacts and endRecord.
  • Traced accBilledTTL end to end: it runs in finish only when usage is OK, the status is 2xx and rounds <= 1, after accWait joins the record. LowerTTL only lowers, on a copy, after EndRequest. The tierStore update rule (write turns record their tier, read-only turns keep it) matches keepalive.BilledOneHour. Verified against the library that the verdict prefers the stored Cache.EntryTTL over the facts' TTL, so a stale remembered tier cannot make a mixed-ask thread read hot.
  • Checked the pricing identities: tierUSD on a 1h token equals CostWithCacheWrite1h for a derived rate, a flat 1h rate (Write1hFrac: 1.0, as deploy/service/prices.example.yaml ships on six entries) and a stated 5m rate above the derived 1h rate. ce.Net() equals the old tierUSD(Saved) - tierUSD(Caused) (linear per tier). CacheWrite1hPremium equals the old inline CacheWrite1h() - CacheWrite guard at all three call sites.
  • Checked estimateRepeatRate is byte-for-byte the old Event.repeatRate rule, and that adaptRates passes the same three counts the old fake Event carried.
  • Checked siblingStore.sharedWarm: the host keeps the policy (TTL window, other thread, not later, LRU caps) and passes all qualifying siblings to SharedWarmFrom. The library's firstDiff/breakpoints/flat match the deleted host helpers' semantics, including out-of-range breakpoint filtering.
  • Checked ResolveTier's extraction into BilledOneHour changes 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). TestTierTokensCarryEveryLibraryTier fails if the library adds a tier dash.TierTokens lacks; TestAnUnnamedFatalCheckStillGates covers the new check_other path; docs/dashboard.md lists it.
  • Live tests were not approved, so I ran nothing. The PR reports TestRateFillTableAndPrice fails on unmodified main too (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]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Integrator note: the owner decided both money changes on 2026-11-12.

  1. The 1h cache-write rate: "the 1h cache-write should be based on the model ( anthropic it is 2x)". This PR does that. CacheWrite1hFor takes the price entry's own cache_write_1h_frac when it is set (for example 1.0 on the Bob entries in the example price list), and the Anthropic 2x otherwise. The accountant now uses that same per-model rate, in place of a fixed 2x input.
  2. The rescue credit after a gateway downgrade: "downgrade - ok".
    The integrator is merging main into this branch (no force).

@amiddavid amiddavid 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.

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, meta stays zero, so sharedWarm returns nil. Defensive path only; no reachable case found.
  • proxy/accountant_wire.go — accBilledTTL writes c.accFacts.TTL on the host copy and also calls LowerTTL on 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 of origin/main abb77b19, hand resolution in proxy/accountant_savings.go). The range also carries 23 main commits, each read from git log --stat in full: abb77b19 plugins matrix, 1bed2683 Pi strategies, 09f96c53 testdb, 4a7f8d7e testutil, b5037247 Bob setup skip, cd82e95a summary-token test, fff61bfb subscription figure, 826e46f7 hosted-vs-local doc, c8f9b67e agentmodel test wait, 245f584b strategy tags, 89c98de6 CLAUDE.md force-push rule, e13ba47e counter docs, cfe8d6fb Bob strategy offer, c4b284e2 plugin versions, 791d296e bob-ultrahigh, 3048e121 proxyapp.Main, bc80520c held estimate range, d877ba5d release lessons, ea509595 keep-alive body limit, b68d0741 rescue-facts counters, 55d8b497 dedup keep marks, 9966adf0 data-dependence rows, 202087de Bob 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.CacheWrite1hFor reads the entry's cache_write_1h_frac when set, else the Anthropic 2x; dash.tierUSD prices a 1h write at CacheWrite + 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.
  • The merge resolution, proxy/accountant_savings.go: the struct keeps both billed1h (this branch) and rescueFactsMissing (main, #1099). newSavingsTracker still sets billed1h; the atomic counter needs no init. Both methods are nil-safe.
  • The counter path end to end. Main's #1099 code now runs inside this branch's async accountant flow: finish calls accWait (line 826) before it reads c.accPingWindow (set by the worker, copied back at accountant_wire.go:78), so the kaPings > 0 && accPingWindow == "" check sees the worker's result. The check sits in the same rounds <= 1 branch as on main. The drop key changed from c.accReq.Meta.Session (main, public library field) to c.accMeta.Session (branch, private field) — the branch already used that form at 84b2d2e, and accMeta is set by accBegin before accEnd can 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 and keeper.go changed in separate regions; the merged files carry both sides (verified BilledOneHour and pol.BodyLimit() together in keeper.go, EstimatedSavedLowUSD and the new tierUSD together in dash).
  • 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's tierUSD for the ceiling. Both bounds use the same per-model 1h premium, and the guard at dash/accountant_price.go:477 keeps 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-private Request fields (Meta, Facts, Breakpoints, Ops, Client, Forwarded); none remain outside the branch's own clientHash.meta, capture.accMeta and endRecord. 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 amiddavid 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.

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: savingsTracker keeps both fields — billed1h (this branch, #1078) and rescueFactsMissing (main, #1099). newSavingsTracker still sets billed1h; rescueFactsMissing is 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.
  • Semantic interactions of the merge, each read at HEAD:
    • proxy/dashcapture.go finish: accBilledTTL (branch) runs before computeSafe, then main's noteRescueFactsMissing counter and the ping drop. The drop line uses c.accMeta.Session, the branch's adaptation of main's line. Both behaviors kept, order unchanged.
    • keepalive/keeper.go: the branch's ResolveTier/BilledOneHour extraction 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 #1001 heldFloorUSD prices its floor with the branch's tierUSD, which now uses CacheWrite1hPremium. 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's repeatRate → estimateRepeatRate move and main's EstimatedSavedLowUSD field coexist; Price and PriceMode both reset the new field.
    • Tests: no test file references the library fields this branch privatized (accReq.Meta and friends). Main's pingunpriced_test.go builds capture with named fields and newSavingsTracker(), which compiles against the merged struct.
    • go.mod: the only change against main is the branch's accountant bump to 181c523e81ae, verified in round 1.
    • Data dependence: the branch never edited docs/data-dependence.md or the row files (checked against the round-1 merge base f123d528), so main's #1090 restructure lost nothing from this PR. No component changed, so datadep_test is 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.

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

Labels

None yet

Projects

Status: Done

2 participants