Skip to content

feat(sweep): cut below a provider's price-tier line when it pays - #1455

Merged
amiddavid merged 4 commits into
mainfrom
feat/sweep-tier-line
Nov 26, 2026
Merged

amiddavid merged 4 commits into
mainfrom
feat/sweep-tier-line

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change (a human must say yes)

  • Who: users of long sessions on OpenAI GPT-5.4 and later (line 272K) and Claude Haiku 5.5 (line 100K), with sweep v3 on.
  • Old: below the sweet spot the sweep never cuts. At 300K on a 1M window it does nothing.
  • New: a request above a price-tier line may be cut to just below the line, when the cut pays back. The sweep cuts deeper than the sweet spot would ask for.
  • Off switch: tier_target in the extract_llm_sweep config. Default: off. It needs sweep v3 and does not switch v3 on. A flat price has no line, so nothing changes for it.

Second behavior change (NOT behind tier_target)

  • Who: every user on a model with a price tier (GPT-5.4 and later, Haiku 5.5), also with tier_target off.
  • Old: TokenRates.Cost used the base rates for every prompt size. The booked spend of a sweep question, a summarize_async deferred call and any other caller was 2x (Haiku 5.5: 5x) too low above a line.
  • New: TokenRates.Cost prices a call at the tier rates of its own prompt size. CostUSD, RecordExtractionSpend and the cost_usd logs rise above a line. They now match the provider's bill.
  • Also: the dash PriceCG row (cg_llm_cost_usd) prices the compaction calls at the tier of their prompt size, so it agrees with the component's booked spend. Test: TestPriceCGPricesAtTheTierOfTheCallsPrompt.
  • Off switch: flat: true on the price-file entry removes the tiers.

Summary

Fixes #1329. The sweep now has a price-tier target. Local tests: waived (owner rule).

What changed

  • Goal: line - margin. The line comes from Price.Tiers through Price.At. No constant.
  • Margin: 8 turns of the session's billed growth, at least 4% and at most 10% of the line (10.9K to 27.2K at 272K). 4% is about 2 to 5 typical turns. The growth term gives room for the payback. The cap stops a cut deeper than needed. With no growth data the floor applies.
  • Gate 1: the cut must reach the goal. Else tier_line_not_reached, and today's target stands (no cut).
  • Gate 2 (payback): the warm gate runs with tier rates.
    • saving = (P x read rate at P - (P-D) x read rate at P-D) x turns
    • turns = the sweep's existing estimate, capped at the turns until the prompt grows back to the line
    • rewrite = rewritten tokens x (write - read) at the rates after the cut
    • Output is not counted. It only makes the saving larger.
  • Sweet spot: a request in the sweet spot keeps today's gate.
  • No growth wait (third change, behind tier_target): a request above a line and below the sweet spot is no longer held by the min_drop_frac x C wait (150K at C = 1M). The tier gates decide when the next cut may happen. In the sweet spot the wait stays. Test: TestTierCutIsNotHeldByTheGrowthWait.
  • Question cost: a sweep question is priced at the tier rates of its prompt size (see the second behavior change).
  • Same cut: the marker and the stash are the same. Fail open is unchanged.
  • Rates: components.TokenRates gets Tiers (absolute rates, built by lifecycle.RatesOf from Price.At). lifecycle.SelfRates uses it.
  • Savings: no savings math added. The accountant books the re-rate (summarize: the role=system summary is placed where the provider rejects it (measured 400) #112/fix(dash): stop /metrics hanging on an unchecked WAL backlog #115/housellm: min_tokens is 3000 but its comment derives 8000 as the floor #120). The sweep uses Price.At only for its own decision.

How it was tested

macOS, Go 1.27.4.

  • go build ./..., go vet ./...: clean.
  • go test on components/..., apply/..., lifecycle/..., config/..., internal/...: pass.
  • CGO_ENABLED=1 go test -race -run 'TestTier|TestRatesCarry' on components/offload and lifecycle: pass.
  • New tests:
    • 300K on gpt-5.6, enough turns: cut to below 272K.
    • Too few expected turns: no cut.
    • A cut that stays above the line, or ends inside the margin: refused.
    • Haiku 5.5 at 110K: cut to below 100K.
    • Flat price, switch off, tier_target: false: unchanged.
    • Margin clamp, and the tier lines in the rate card.
  • Mutations, both fail tests:
    • Ignore the payback check: TestTierKeepsTodaysTargetWhenTheCutDoesNotPay fails.
    • Ignore the margin: TestTierRefusesACutThatEndsInsideTheMargin fails.

Not covered

  • extract_llm's per-candidate calls still price below tier. Their prompts carry one tool output, so they rarely cross a line.
  • No direct test of recordLeg. TestTierCardPricesACallAtItsPromptSize covers the call it makes.
  • Round 1 added tests for the judge selector (TestTierJudgeSelectorAsksThenCutsBelowTheGoal, TestTierHeldAnswerIsNotAppliedBelowEveryLine), v3 off, and the gate price model.

Not covered (more)

  • extract_econ.go callCost and analyticBaseline (flat gate estimates) still price below tier.

Data dependence

Metadata only. Token counts, tier lines, rates and growth per turn. No customer text. The feature's data dependence does not change at any storage level (off, metadata only, everything). The row note for extract_llm_sweep is updated and docs/data-dependence.md is regenerated.

Decided

  • Default for tier_target: off. Owner decision, 2026-11-26.
  • TokenRates.Cost priced at the prompt's tier for every caller (owner, 2026-11-26, together with the tier feature). The merge yes is still with the integrator.

Open questions

  1. Margin: 4% to 10% of the line, 8 turns of growth. Is this right?
  2. Sweet spot: the tier target applies only below the sweet spot. A request above the sweet spot keeps today's gate, even if the cut would also cross a line.
  3. Cold path: the target applies on the warm path only.

Local tests: waived (owner rule)

Below the sweet spot the sweep never cut. A request just above a price-tier
line (OpenAI GPT-5.4+ at 272K, Haiku 5.5 at 100K) paid the high rates for
many turns.

With tier_target: true (off by default, needs sweep v3) a request above a
line may be cut to line minus a margin. The cut must reach the goal and pass
the warm gate with tier rates, counted for the turns until the prompt grows
back to the line. Lines and rates come from Price.Tiers via Price.At.

Fixes #1329

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid amiddavid added the openai OpenAI / Codex traffic and pricing label Nov 26, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Owner decision (David Amid, 2026-11-26)

tier_target defaults to off. The sweep keeps today's target unless an operator turns the switch on. A later measurement on long GPT-5.4+ sessions, of cost and answer quality with the switch on and off, decides whether it defaults to on.

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 4 c18ddf4452cc blocking

Verdict: blocking

Findings

  1. components/offload/extract_sweep_v3.go:694 — no test covers the tier target on the judge or hybrid selector, only on selector: rule
    • What fails: with selector: judge (the default) or hybrid, tier_target: true and a prompt above a line but below the sweet spot, the code now walks past the sweet-spot return and reaches the judge-ask block (extract_sweep_v3.go:770-780). The judge question is now asked below the sweet spot, and the held answer is later applied through the tier gate. Before this PR, not_in_sweet_spot returned first and no question was ever asked there. All six new tests in extract_sweep_tier_test.go use v3Rule (selector: rule). A defect in the judge path of the default config would ship untested.
    • Proof: v3Step assigns tier at line 694 and falls through; the rule branch at line 735 is the only selector path the tests take. apply(true) (held answer, line 767) and the hybrid rules-only branch (line 771) have no tier test. grep -n selector extract_sweep_tier_test.go finds only v3Rule.
    • Fix: add one judge-selector (or hybrid) test: above the line, below the sweet spot, tier_target: true — assert the question is asked, the answer is applied, and the cut reaches below the goal. Add one test that a held answer is not applied when the apply-time prompt falls back below every line.

Non-blocking

  • extract_sweep_v3.go:884 — tier_line_not_reached mislabels two unrelated refusals. The check !measured also fires when the recheck left no valid drop (no_valid_drop, no_drop_proposed) or the billed size is unknown (no_billed_size). The outcome is the same (refuse, fail-safe), only the logged reason is wrong. Split the !measured case out, or let inner run first.
  • components/ratesof.go:7 — components.RatesOf names an internal/ type in an exported signature. modelinfo.Price is not importable outside this module, so the sidecar plugin and Cortex cannot call RatesOf even though components is one of the four public API packages (CLAUDE.md, hard boundaries). Within the module everything works. Consider moving RatesOf to lifecycle, which already exports modelinfo.Pricer signatures.
  • components/component.go:1028,1045 — TokenRates.At/LineBelow re-implement modelinfo.Price.At's line selection. Two copies of "the highest line below the prompt size wins" must now stay in sync, or the sweep's gate and the bill disagree. Price.At cannot be reused on TokenRates directly, so at least keep the pinning tests (TestTierRatesCarryTheLines, TestRatesCarryTheTiers) over both.
  • Margin vs the growth wait. After a tier cut, the thread waits minDropFrac x C of growth (default 0.15 x C) before any new cut (extract_sweep_v3.go:678-681). At C = 1M that is 150k, far more than the 4-10% margin (11k-27k at 272k). The prompt can sit above the line, paying the high rates, for many turns before a re-cut. Each cut still pays back on its own (the gate's saving counts only the turns below the line), so this is a coverage limit of the feature, not a wrong result. Worth an answer under the PR's open question 1.

What I checked

  • Full diff base 3ef26ffd..head c18ddf44, and the code around each hunk: v3Step, v3Gate, v3Apply, warmGate, warmEconIn, agentRates, warmGateRates, warmRatios, noteBilledGrowth, warmTurnsLeftAfter.
  • Tier plan math: tierGoal, tierMargin (4-10% clamp, 8 turns), tierEcon (saving, rewrite, turns cap at the line). Verified the goal and after use the same content ratio as the gate's dBilled, and that tierEcon runs only after v3Gate's goal check passed, so readB is always the lower-tier rate there.
  • Rate wiring: components.RatesOf resolves tiers through Price.At(line+1); both production price sources apply WithTiers (internal/modelinfo/table.go:347, litellm.go:233), so lifecycle.SelfRates carries lines in production, not only in tests.
  • Off-by-default and isolation: tier_target is not in the v3 switch-on list (parseSweepV3), so it does not switch v3 on; every non-v3 warmApply is built without a tier (extract_sweep_warm.go:922, extract_sweep_v3.go:621); tierGoal returns nil with warm_gate_price_model set, matching the rates the gate would use.
  • Fail open: no new panic path (withRates copies a lock-free Ctx); the warm step's recover still forwards the request unchanged.
  • No other consumer of SelfRates reads the new Tiers field, and no positional TokenRates{...} literal breaks.
  • Docs: advanced-offload.md section, the tier_target field hint, and the data-dependence row match the code; the generated page diff matches the row edit. Data dependence is metadata only, as the PR states.
  • PR body: names the behavior change at the top, default off, owner decision dated 2026-11-26. CI green (lint-build, purego, trivy); go.mod unchanged; no binaries.

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 4 c18ddf4452cc blocking

Verdict: blocking

Findings

  1. components/offload/extract_sweep.go:818 — the sweep's own question cost ignores the tier rates
    • What fails: with tier_target on, a judge or hybrid sweep asks its question on prompts above a price line (272K–600K on GPT-5.4+, 100K–140K on Haiku 5.5). recordLeg (line 842) prices that call with ratesPricing(c.SelfRates), and ratesPricing (extract_llm.go:656) copies only the four base rates and drops the new Tiers. The booked CostUSD, metrics.RecordExtractionSpend and the cost_usd log row (line 1272) come out 2x too low on GPT and 5x too low on Haiku. The request-level accountant prices the same traffic with Price.At (dash/event.go:1017, proxy/metricsink.go:39), so the two ledgers disagree — the same defect class the comment above this code says #176 fixed ("two recorded totals disagreeing ... is worse than either alone").
    • Proof: ratesPricing builds cheapmodel.Pricing from r.Input/Output/CacheRead/CacheWrite only; TokenRates.Tiers is never read. The question reads the stashed body, so usage.CacheRead is ~P, above the line. Price.At (internal/modelinfo/pricetier.go:34) is what the provider bills there.
    • Partly pre-existing: sweet-spot questions above a line were already under-priced. This PR opens the below-sweet-spot band, where every new question sits above the line, and it is the PR that puts the tiers on SelfRates in the first place.
    • Fix: in recordLeg, resolve the tier before pricing: rates := c.SelfRates.At(usage.Fresh + usage.CacheRead + usage.CacheWrite), then ratesPricing(rates). Or make a tier-aware Cost. If the owner prefers, file it as its own issue — but then say so in the PR.

Non-blocking

  • components/component.go:1017 — MaxRateTiers = 3 redefines modelinfo.MaxTiers with a comment "It matches modelinfo.MaxTiers". That is a keep-in-sync constant. components already imports modelinfo (ratesof.go), so write const MaxRateTiers = modelinfo.MaxTiers.
  • components/component.go:1026 — TokenRates.At and LineBelow duplicate modelinfo.Price.At's tier-selection loop (the same "highest line below" rule in two packages). RatesOf already delegates rate resolution to Price.At; the selection rule could be shared too.
  • components/ratesof.go:8 — RatesOf is exported and its signature names modelinfo.Price, an internal type. A module outside this one cannot name that type, so it cannot call the function. In-module callers (lifecycle) are the only users.
  • components/component.go:1060 — TokenRates.Cost ignores Tiers. Any caller pricing a large prompt from a TokenRates under-reports (finding 1 is one instance; summarize_async.go:586 prices deferred calls the same way). Worth one decision for all callers.
  • No test covers the warm_gate_price_model guard in tierGoal (extract_sweep_tier.go:59), and none covers tier_target: true with v3 off ("does nothing without v3").
  • extract_sweep_v3.go:884 — with a tier plan set, a refusal for no valid drops or no billed size is labelled tier_line_not_reached. The finer cause (no_valid_drop, no_billed_size) is lost from the reason ledger.
  • Design tension, adjacent to the PR's open question 1: after a tier cut, the growth wait demands minDropFrac x C of growth before the next cut (extract_sweep_v3.go:669). On a 1M window that is 150K, while the margin buys only 10.9K–27.2K below the line. The thread can sit above the line, paying the high rates, for ~120K of growth while the sweep answers waiting_for_growth. The payback gate itself would allow a re-cut much sooner.

What I checked

  • Read the full diff (14 files) and the code around each change: TokenRates.At/LineBelow/RatesOf against modelinfo.Price.At and WithTiers; tierGoal, tierMargin, tierEcon; the v3Step sweet-spot branch; the rule-select early refusal; the v3Gate tier check and its order against warmGate; the warmGate tier-econ hook; the config plumbing (tier_target does not switch v3 on, parseSweepV3 reads it only past the on gate).
  • Checked the gate order for fail-safe behaviour: tier_line_not_reached runs before warmGate, so tierEcon only sees cuts that reach the goal; a cut whose valid drops are not all found in the request drives turns to 0 and refuses. Errors in the tier code only refuse a cut; the request goes out unchanged. The marker and the stash are the unchanged cut path.
  • Checked the saving arithmetic: P x readA - after x readB = D x readA + after x (readA - readB), counted only for the turns until the prompt grows back to the line. The constant-size approximation under-counts the saving (growth above the line would bill at the high rate), so it errs towards refusal.
  • Checked agentRates on tier-resolved rates: a stated tier rate passes through CacheReadFor unchanged; a blank one falls back to the model's multiplier, the same rule as the base card.
  • Checked the new tests: each rig test resets the v3 ledger (newV3Rig → resetWarmForTest → resetV3ForTest), so the len(v.Recent) != 1 assertions are safe; the paced refusal counters line up with warm_every_n 3 over the tierRun request sequence; the Haiku rig at 110K is below its sweet spot (0.70 x 200K), so it does exercise the tier path.
  • Checked the units: P, growthFrom and the margin are all billed tokens; RatioContent/RatioFull are used the same way as warmEcon.
  • Checked the docs: the advanced-offload.md section matches the code; the data-dependence row file and the generated page carry the same sentence; the row says the dependence does not change, which matches what the code reads (token counts, prices, growth).
  • Checked the PR body: the behavior change is named at the top, with the off switch, the default (off) and the owner decision date; test notes name the machine.
  • No builds or tests were run (not approved). Code reading only.

… wait on a tier cut

- TokenRates.Cost and the sweep's recordLeg price a call at the tier rates of
  its own prompt size. Before, the question's cost was 2x or 5x low above a line.
- A tier cut is not held by the growth wait; the tier gates decide.
- tier_line_not_reached no longer hides no_valid_drop, no_drop_proposed or
  no_billed_size.
- MaxRateTiers = modelinfo.MaxTiers. RatesOf moves to lifecycle. A test pins
  TokenRates.At to Price.At on a grid.
- Tests: judge selector, held answer below every line, v3 off, gate price
  model, growth wait, card cost.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Replies to round 1 (both reviewers blocked)

Fixed in 93cf004c. #1193 lands first, so the merge of main comes later.

Reviewer 1, finding 1: the question cost ignored the tiers. Fixed. TokenRates.Cost now prices a call at the rates of its own prompt size (fresh + cache write + cache read). recordLeg prices each leg with card.At(prompt). This also covers summarize_async. It is a second behavior change, NOT behind tier_target, and the top of the body names it. TestTierCardPricesACallAtItsPromptSize covers it. extract_llm's per-candidate calls still price below tier; their prompts carry one tool output and rarely cross a line. That is listed under "Not covered".

Reviewer 2, finding 1: no judge or hybrid test. Fixed:

  • TestTierJudgeSelectorAsksThenCutsBelowTheGoal
  • TestTierHeldAnswerIsNotAppliedBelowEveryLine

Non-blocking notes: all done.

  • MaxRateTiers = modelinfo.MaxTiers.
  • RatesOf moved to lifecycle, so no exported signature names an internal type.
  • TestRatesAtMatchesPriceAt pins TokenRates.At to Price.At on a grid.
  • tier_line_not_reached fires only for a measured cut that misses the goal. The finer reasons come through.
  • Guard tests: TestTierTargetIsOffWithAGatePriceModel and TestTierTargetWithoutV3DoesNothing.
  • The growth wait (both reviewers): a request above a line and below the sweet spot is no longer held by the min_drop_frac × C wait. The tier gates decide when the next cut comes, and in the sweet spot the wait stays. TestTierCutIsNotHeldByTheGrowthWait covers it.

Owner decision: tier_target defaults to off.

Tests (macOS, Go 1.27.4):

  • Build and vet are clean.
  • Plain go test passes on components/..., apply/..., lifecycle/..., config/... and internal/....
  • -race -run 'TestTier|TestRates' passes.
  • Mutations: ignoring the payback check, ignoring the margin, and removing the growth-wait bypass each make a test fail.

Local tests: waived (owner rule)

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 4 93cf004c2236 approve

Verdict: approve

Findings

None. The round-2 commit fixes both round-1 findings correctly, and I found no new defect in it.

Round-1 findings, checked

  1. Mine, finding 1 (question cost ignored the tiers): fixed. recordLeg now prices each leg with ratesPricing(card.At(fresh + cacheWrite + cacheRead)) (extract_sweep.go:846-852), which is the fix I proposed. TokenRates.Cost is also tier-aware now (component.go:1058-1062), which fixes summarize_async's deferred calls the same way. TestTierCardPricesACallAtItsPromptSize pins the arithmetic, including the equality between the card and the sweep-leg pricing. The change is a second behavior change, not behind tier_target, and the PR body names it at the top with its off switch (flat: true). extract_llm's per-candidate calls stay below tier, named under "Not covered" — accepted: their prompts carry one tool output.
  2. Reviewer 2, finding 1 (no judge or hybrid tier test): fixed. I checked both new tests myself. TestTierJudgeSelectorAsksThenCutsBelowTheGoal walks the real path: question asked below the sweet spot, answer held, then applied through the tier gate, cut below the goal, judge drops counted. TestTierHeldAnswerIsNotAppliedBelowEveryLine checks the apply-time prompt below every line leaves the answer unapplied.
  3. Non-blocking notes, mine and reviewer 2's: all addressed. MaxRateTiers = modelinfo.MaxTiers (components/ratesof.go). RatesOf moved to lifecycle; no exported signature in components names an internal type any more, and no caller of the old components.RatesOf remains. TestRatesAtMatchesPriceAt pins TokenRates.At to Price.At on a grid over both lines. tier_line_not_reached now fires only for a measured cut that misses the goal; no_valid_drop, no_drop_proposed and no_billed_size come through inner again. Guard tests added for warm_gate_price_model and v3 off. The growth wait no longer holds a request above a line below the sweet spot.

The growth-wait bypass (new behavior, checked)

  • v3Step sets waiting = false when a tier plan exists (extract_sweep_v3.go:694-701). The bypass is inside the below-sweet-spot branch only; a request in the sweet spot keeps the wait. After a tier cut the prompt sits below the line, tierGoal returns nil, and the sweep refuses with not_in_sweet_spot — so the bypass cannot make the sweep cut every turn. A re-cut needs the prompt above the line again, and the payback gate prices the rewrite. Fail open is unchanged.
  • Documented in advanced-offload.md ("No growth wait") and named in the PR body as the third behavior change, behind tier_target. TestTierCutIsNotHeldByTheGrowthWait covers it, and the author reports the mutation (removing the bypass) fails a test.

Non-blocking

  • components/component.go:1016 — the comment "MaxRateTiers is how many tiers TokenRates holds. It matches modelinfo.MaxTiers." was left behind when the const moved to ratesof.go. It now floats above type RateTier and documents the wrong thing. Delete it (the const has its own comment).
  • The PR body's "Rates" bullet still says the tiers are "built by components.RatesOf". The function moved to lifecycle. Worth one edit so a reader finds it.
  • tierRates in extract_sweep_tier_test.go copies lifecycle.RatesOf inline. The comment says offload cannot import lifecycle; that is right (lifecycle imports components/offload, so a test in package offload would cycle). A drift between the copy and the real one would weaken the tier tests silently; TestRatesAtMatchesPriceAt covers the selection rule but not this conversion. Acceptable as is.

What I checked

  • Last review: round 1, c18ddf4452cce4547c1443654f01c347d8e6d4f9, 2026-11-26T11:31:04Z.
  • New commits read: 1 — 93cf004c "fix(sweep): price a question at its tier, judge-path tests, no growth wait on a tier cut".
  • Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files).
  • New items since my last review: the author's reply comment (2026-11-26T11:36:49Z, fixes and owner decision) and commit 93cf004c. Both handled above. The owner-decision comment (11:18) predates my round 1 and matches the PR body.
  • Read the full round-2 diff and the code around each hunk: TokenRates.Cost's new At (checked every caller repo-wide: only summarize_async passes a real prompt size; dash's Price.Cost and cheapmodel.Pricing.Cost are different types and unchanged); recordLeg's per-leg resolution (the pricing fallback is used only when the card is zero); the waiting = false bypass and its reach; the v3Gate measured fix (verified warmGate still returns the finer reasons before tierEcon can run).
  • Checked the new tests' mechanics: the judge test's ask cadence over warm_every_n 3, the held-answer test's refusal path, the without-v3 test's direct e.v3 assertion (the rig config is v3Base without a v3-switching setting), and the card-cost test's argument order against Cost(fresh, output, cacheWrite, cacheRead).
  • Checked the PR body: both new behavior changes are named at the top with off switches; "Not covered" names the extract_llm gap and the recordLeg indirection honestly.
  • No builds or tests were run (not approved). Code reading only.

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 4 93cf004c2236 blocking

Verdict: blocking

Findings

  1. dash/event.go:998 — PriceCG still prices the compaction calls flat, so the dash row and the sweep's booked spend now disagree above a line
    • What fails: this commit makes recordLeg (extract_sweep.go:846-851) and summarize_async (summarize_async.go:586, through the new tier-aware TokenRates.Cost) book a compaction call at the tier rates of its prompt size. The dash row prices the SAME call at the base rates: PriceCG calls p.Cost(e.CGFresh, e.CGCacheRead, e.CGCacheWrite, e.CGOutput) on a p that never went through p.At. Above a line, cg_llm_cost_usd (dash, Prometheus cg_tenant_cg_llm_cost_usd) reads 2x low on GPT-5.4+ and 5x low on Haiku 5.5 while the component's RecordExtractionSpend, ModelCall.CostUSD and cost_usd logs are right. Before this PR both sides were flat and agreed; now they disagree.
    • Proof: priceCost in the same file applies p = p.At(modelinfo.PromptTokens(...)) for the request's own cost (dash/event.go:1017); PriceCG, which the capture site and the reprice pass both call (dashcapture.go:872), does not. The comment above recordLeg (extract_sweep.go:806-809) says the component prices "from the same rates the request-level figure uses, so the two agree rather than being two independent guesses" — above a line that claim is now false. This is the #176 defect class the fix itself cites: "Two recorded totals disagreeing ... is worse than either alone."
    • Fix: in PriceCG, resolve the tier before pricing, as priceCost does: p = p.At(modelinfo.PromptTokens(e.CGFresh, e.CGCacheRead, e.CGCacheWrite)). The PR body's second behavior change then holds for both ledgers.

Non-blocking

  • PR body, "What changed → Rates" still says the tiers are "built by components.RatesOf". That function moved to lifecycle in this commit. Update the line.
  • "Decided" records only the tier_target default. The second behavior change (TokenRates.Cost, not behind any sweep switch) has no recorded owner yes in the PR. The author is the owner, so add one line naming the decision and the date.
  • extract_econ.go:269,294 (callCost, analyticBaseline) still estimate a judge call at flat rates. It is a gate estimate, not booked spend, and the "Not covered" section already names the per-candidate class. Fine to leave, worth one line there.
  • The test helper tierRates (extract_sweep_tier_test.go:22) copies the RatesOf conversion. The comment is right that offload cannot import lifecycle (lifecycle/prepare.go imports components/offload), so the copy is forced. Test-only.

Earlier findings

  • Mine, round 1, finding 1 (no judge or hybrid test): fixed. TestTierJudgeSelectorAsksThenCutsBelowTheGoal covers the question below the sweet spot, the apply through the tier gate, and the goal; TestTierHeldAnswerIsNotAppliedBelowEveryLine covers the prompt falling back below every line. Both assert what I asked for.
  • Reviewer 1, round 1, finding 1 (question cost ignored the tiers): fixed in the component, incomplete on the dash side. TokenRates.Cost now applies At(fresh + cacheWrite + cacheRead), recordLeg resolves the card per leg, summarize_async is covered through Cost, and TestTierCardPricesACallAtItsPromptSize pins the arithmetic. My finding 1 above is the remaining half: the dash row for the same calls.
  • My round-1 non-blocking notes: all addressed. tier_line_not_reached now fires only for a measured cut (extract_sweep_v3.go:885); I re-checked that inner always refuses when !measured, so no tier cut slips through unmeasured. RatesOf moved to lifecycle, so no exported signature in components names an internal type. TestRatesAtMatchesPriceAt pins TokenRates.At to Price.At on a grid with the lines and both sides. The growth wait no longer holds a tier cut.
  • Reviewer 1's non-blocking notes: all addressed (MaxRateTiers = modelinfo.MaxTiers, the same pinning test, RatesOf move, the measured label, the two guard tests, the growth wait).

What I checked

  • Last review: round 1, c18ddf4452cce4547c1443654f01c347d8e6d4f9, 2026-11-26T11:29:26Z
  • New commits read: 1 (93cf004 "fix(sweep): price a question at its tier, judge-path tests, no growth wait on a tier cut")
  • Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files)
  • New items since my last review: reviewer 1's round-1 review (read in full, its finding cross-checked above); the owner-decision comment (tier_target defaults off, David Amid 2026-11-26); the author's replies comment (each reply checked against the code); the fix commit (reviewed below).
  • The growth-wait bypass (extract_sweep_v3.go:694-699): waiting = false only below the sweet spot with a live tier plan; the sweet-spot path keeps the wait, as the docs say. The margin and the payback gate replace the wait as anti-thrash: after a tier cut the prompt sits below the line, tierGoal returns nil there, and a re-cut needs the prompt above the line again plus a paying gate. Behavior change named in the body, behind tier_target, test attached.
  • The Cost change's blast radius: every TokenRates.Cost and cheapmodel.Pricing.Cost caller in the repo enumerated (extract_sweep.go:851, extract_llm.go:1364, summarize_async.go:586, extract_econ.go:269,294, proxy/proxy.go:2748, dash/event.go:998). Only summarize_async.go:586 calls the tier-aware TokenRates.Cost; the sweep leg resolves card.At per leg before the flat cheapmodel cost, and At of an already-resolved card is a no-op (its Tiers are empty), so nothing double-applies. extract_llm's per-candidate calls stay flat, as "Not covered" says.
  • The second behavior change is named at the top of the PR body with its off switch (flat: true on the price-file entry).
  • The new tests' logic and arithmetic: judge path (ask at 300K above the line, apply, JudgeDrops > 0, goal reached), held answer below every line, v3 off (tier_target is not in the v3 switch-on list), gate price model guard, growth-wait bypass, and the Cost numbers in TestTierCardPricesACallAtItsPromptSize (300K read at 2x 0.5e-6 plus 1000 output at 1.5x 30e-6).
  • lifecycle.RatesOf moved verbatim; no reference to components.RatesOf remains; MaxRateTiers = modelinfo.MaxTiers compiles as an untyped constant.
  • CI green on the new head (lint-build, purego, trivy, DCO). No builds or tests were run by me (not approved). Code reading only.

PriceCG priced the compaction calls flat, so above a price-tier line the
cg_llm_cost_usd row disagreed with the component's booked spend. It now
resolves the tier as priceCost does. Also drops a stale comment.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Replies to round 2

Fixed in e27765bd.

Reviewer 2, finding 1: PriceCG priced the compaction calls flat. Fixed. PriceCG (dash/event.go) resolves the tier first: p.At(modelinfo.PromptTokens(CGFresh, CGCacheRead, CGCacheWrite)), as priceCost does. TestPriceCGPricesAtTheTierOfTheCallsPrompt covers a compaction call on a 300K prompt on gpt-5.6: the dash row equals the component's CostUSD and is about 2x the flat price. A mutation that drops the At makes it fail. The second behavior-change block names the dash row.

Non-blocking notes, both reviewers:

  • The stale MaxRateTiers comment is deleted.
  • The "Rates" bullet now names lifecycle.RatesOf.
  • "Decided" now records TokenRates.Cost at the prompt's tier for every caller. The merge yes stays with the integrator.
  • "Not covered" now lists extract_econ.go callCost and analyticBaseline. They are gate estimates, still at flat rates.
  • The tierRates copy in the test is forced by the import cycle, and the test file says so.

Tests (macOS, Go 1.27.4): build and vet are clean. Plain go test ./dash/... ./components/... ./lifecycle/... passes. -race -run TestPriceCGPrices ./dash passes.

Local tests: waived (owner rule)

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 3 of 4 e27765bdc approve

Verdict: approve

Findings

None. The round-3 commit fixes my round-2 finding exactly as proposed, and I found no new defect in it.

Earlier findings

  • Mine, round 2, finding 1 (PriceCG priced the compaction calls flat): fixed. dash/event.go:998-999 now resolves the tier before pricing: p = p.At(modelinfo.PromptTokens(e.CGFresh, e.CGCacheRead, e.CGCacheWrite)), the same pattern priceCost uses ten lines below, placed after the !ok guard. The capture site and the reprice pass both go through PriceCG, so both get the fix.
  • My round-2 non-blocking notes: all addressed. The "Rates" bullet now names lifecycle.RatesOf (body line 34). "Decided" records the TokenRates.Cost decision with the owner and the date (line 72). "Not covered" lists extract_econ.go's callCost and analyticBaseline (line 63). The tierRates test copy stays, forced by the import cycle — accepted.
  • Reviewer 1's round-2 review (approve): its three non-blocking notes are handled. The orphan MaxRateTiers comment in components/component.go is deleted by this commit; the stale "Rates" bullet is fixed in the body; the tierRates copy is accepted by both reviewers. Nothing to add.
  • Reviewer 1's round-1 finding and my round-1 finding: fixed in round 2 and unchanged since. I re-read the round-2 fix areas (recordLeg, TokenRates.Cost, the judge tests) in this head; they are as reviewed.

What I checked

  • Last review: round 2, 93cf004c22363d1b9c03107c01f9aeb2b15bd23f, 2026-11-26T11:42:37Z
  • New commits read: 1 (e27765b "fix(dash): price the compaction calls at the tier of their prompt size")
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three saved files)
  • New items since my last review: reviewer 1's round-2 review (approve, 11:40:40Z — read in full, its notes cross-checked above); the author's replies-to-round-2 comment (11:46:49Z — each reply checked against the code and the body); commit e27765b (reviewed below).
  • The PriceCG fix: modelinfo.PromptTokens(fresh, cacheRead, cacheWrite) argument order matches its signature; output tokens stay out of the prompt size, as modelinfo defines; At of the resolved card leaves Cost on the tier rates. compactepisode.go and the tenant rollup (cg_tenant_cg_llm_cost_usd) read CGLLMCostUSD and now agree with the component's booked spend.
  • The new test TestPriceCGPricesAtTheTierOfTheCallsPrompt: prompt = 1000 + 299,000 = 300,000 > 272,000, so the gpt-5.6 tier applies. Both sides compute 1000 x 10e-6 + 299,000 x 1e-6 + 500 x 45e-6 = $0.3315; the flat price is $0.1695, and the assertion > 1.9x flat holds. The argument order matches both Cost signatures (TokenRates.Cost(fresh, output, cacheWrite, cacheRead), Price.Cost(fresh, cacheRead, cacheWrite, output)). Dropping the At makes the equality fail, so the mutation claim holds. dash importing lifecycle is a host importing a library — allowed.
  • components/component.go: only the orphan comment is removed; the const keeps its own comment in ratesof.go.
  • The PR body: the dash row is named inside the second behavior-change block with its test; "Decided" now records the Cost decision; the two "Not covered" sections name every flat-rate remainder honestly.
  • CI on head e27765b: trivy and DCO pass; build, analyze, lint-build and purego were still pending when I checked. The integrator needs them green before merge. No builds or tests were run by me (not approved). Code reading only.

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 3 of 4 e27765bdcc8c approve

Verdict: approve

Findings

None. The round-3 commit fixes reviewer 2's round-2 finding correctly, and I found no new defect in it.

Round-2 findings, checked

  1. Reviewer 2, finding 1 (PriceCG priced the compaction calls flat): fixed. I checked the fix myself. PriceCG now resolves the tier before pricing (dash/event.go:998-999): p = p.At(modelinfo.PromptTokens(e.CGFresh, e.CGCacheRead, e.CGCacheWrite)), the same pattern priceCost uses for the request's own cost (dash/event.go:1017). I checked the argument order of PromptTokens(fresh, cacheRead, cacheWrite) and of Price.Cost(fresh, cacheRead, cacheWrite, output) against the call — both match. A flat price is unchanged (At is a no-op without tiers). Both PriceCG call sites (capture and reprice) go through the one function.
  2. The new test, checked by hand. TestPriceCGPricesAtTheTierOfTheCallsPrompt: a 300K gpt-5.6 prompt (1000 fresh + 299K cache read) above the 272K line. The dash row and lifecycle.RatesOf(p).Cost(...) must agree, and both must sit near 2x the flat price. I computed them: tier cost 1000 x 1e-5 + 299,000 x 1e-6 + 500 x 45e-6 = $0.3315; flat $0.1695; ratio 1.955, above the test's 1.9 floor. The two paths run the same resolved rates, so the equality holds exactly. The test's import of lifecycle into dash is test-only and acyclic (lifecycle does not import dash).
  3. My round-2 non-blocking notes: fixed. The orphaned MaxRateTiers comment above type RateTier is deleted (component.go). The PR body's "Rates" bullet now names lifecycle.RatesOf. The tierRates test copy stays, with the import-cycle note — acceptable.
  4. Reviewer 2's round-2 non-blocking notes: fixed. "Decided" now records the TokenRates.Cost decision (owner, 2026-11-26). "Not covered (more)" lists extract_econ.go's callCost and analyticBaseline as flat gate estimates. The dash row is named inside the second behavior-change block, with its test.

What I checked

  • Last review: round 2, 93cf004c22363d1b9c03107c01f9aeb2b15bd23f, 2026-11-26T11:40:40Z.
  • New commits read: 1 — e27765bd "fix(dash): price the compaction calls at the tier of their prompt size".
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-2 review (11:42:37Z, its finding cross-checked above), the author's replies comment (11:46:49Z, each reply checked against the code), and commit e27765bd. All handled.
  • Read the full round-3 diff (3 files) and the code around each hunk: PriceCG and its guard for a request with no compaction tokens, the p selection when prices is nil or the CG model differs, and the stale-comment deletion in components/component.go.
  • Checked the PR body: the dash row is part of the named second behavior change, with the off switch (flat: true); "Decided" records both owner decisions; "Not covered" names the remaining flat-rate estimates honestly.
  • Confirmed the tier-aware pricing is now complete where it matters: priceCost, PriceCG, adapttools, toolsuggest, cachestate, keepalive and accountant_price in dash all resolve At before Cost; the component side resolves per leg; extract_econ's gate estimates stay flat and are listed.
  • No builds or tests were run (not approved). Code reading only.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged main (with #1193)

7212131e merges origin/main, which has #1193 (with warm on, keep the copy without a ping).

approval-still-valid.sh says CHANGED, because of the merge. Round 4 re-checks the delta: the two code paths must work together.

Local tests: waived (owner rule)

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 7212131e6a69 approve

Verdict: approve

Findings

None. The only new commit is a merge of origin/main (#1193 and others). The merge is correct, and the two code paths work together.

The merge, checked

  1. Conflicts: only the data-dependence docs, resolved right. The combined diff of the merge shows the two conflicted files (docs/data-dependence.md and the extract_llm_sweep row file). The resolution takes main's #1193 text (the warm-only copy for a thread the keep-alive cannot ping, the 300-second bound, the new "off" column wording) with the tier_target sentence added back in its place. I read the merged row in both files: they carry the same text, so the page matches the row.
  2. The tier code survived the merge intact. Verified in the merged head: the sweet-spot branch with the tier plan and the growth-wait bypass (extract_sweep_v3.go:694-701), the measured fix (:888), the tierEcon hook in warmGate (extract_sweep_warm.go:796), tierGoal, the tier-aware TokenRates.Cost (component.go:1062), and PriceCG's At resolution (dash/event.go:999).
  3. The two features work together (the round-4 question). #1193 changes registerWarm's guard from CanKeepAlive() to keepsCopy(c) (e.warm || pingable), so with warm on, a thread the keep-alive cannot ping (IBM Bob's route) now registers a warm-only copy and can be asked. The tier path reaches registerWarm through the same v3Step hybrid branch, so a tier question on such a route asks after the forward, from that copy — which is #1193's design and the tier feature's design together, not a conflict. The copy is dropped when the question ends (dropWarmOnly), and the question's Ctx copy carries SelfRates with tiers (extract_sweep_ping.go:314), so the per-leg tier pricing applies there too.
  4. One convention note, not a defect. tierEcon prices the per-turn saving at the cache-read rate, as warmEcon always has. On a route with no prompt caching (Bob's, cache strategy none) the true per-turn cost is the fresh rate, so both gates under-count the saving there and refuse more. Same direction as today's warm gate, conservative. Nothing to change in this PR.
  5. Main's new pricing code is tier-aware. The files the merge brought in (dash/accountant_price.go, proxy/accountant_wire.go, dash/cachestate.go's NextRequestUSD) all resolve Price.At before costing; NextRequestUSD gained the nextIn parameter from #1454 and its test moved with it.
  6. CI is green on the merged head (lint-build, purego, trivy, build, analyze, CodeQL all pass).

Earlier findings

  • All findings from rounds 1 to 3, both reviewers, are fixed and unchanged by the merge (verified per point 2 above).

What I checked

  • Last review: round 3, e27765bdcc8c0d939b3018582f80e8a316768b56, 2026-11-26T11:48:46Z.
  • New commits read: 1 — 7212131e "merge origin/main into feat/sweep-tier-line" (a merge of main e2d4177e, which carries #1193, #1454, #1456, #1458 and more).
  • Read in full: 6 reviews, 4 comments, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-3 review (approve, 11:48:43Z — read in full, nothing to add); the author's merge comment (13:12:04Z — its claims checked: conflicts only in the docs, code merged clean, tests re-run); the merge commit itself. All handled above.
  • Read the merge's combined diff (git show --cc) in full: only the two data-dependence files needed a hand resolution. Read the merge's diff against my round-3 head for every code file it touched, and the code around the interaction points (registerWarm, keepsCopy, runWarmQuestion, dropWarmOnly, warmPending, the v3Step hybrid branch).
  • Checked the PR's merge-base claim: base moved from 3ef26ffd to e2d4177e (main), so the PR now contains only its own changes on top of main.
  • No builds or tests were run by me (not approved). Code reading only. The author reports build, vet, plain tests and -race -run 'TestTier|TestRates|Warm' clean on the merged head, macOS, Go 1.27.4.

From my side the PR is ready for the integrator at head 7212131e.

@amiddavid amiddavid 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 @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 7212131e6a69 approve

Verdict: approve

Findings

None. The only new commit is a merge of origin/main. The merge keeps every change of this PR byte-identical, resolves the one conflict correctly, and the two code paths work together.

What the merge brings and how it fits

  • #1193 (warm question without a ping) is the one main change that touches this PR's area. It rewrites registerWarm (extract_sweep_warm.go:1122-1127) to keep a warm-only conversation copy for threads the keep-alive cannot ping, and changes the CanKeepAlive contract comment in components/component.go. Interaction with the tier target: the judge-ask call at extract_sweep_v3.go:780 now also registers on unpingable threads. That widens WHERE a question can happen (main's reviewed behavior change, #1191), and changes nothing about WHEN: the sweet-spot and tier gates still decide, unchanged. Fail open is unchanged.
  • Main's parallel dash tier work (#1454: pricetier_callers_test.go, cachestate.go, nextinput; #1458; #1456) is complementary. Main did not touch dash/event.go, so this PR's PriceCG fix stands as reviewed, and main's tests pin the same tier semantics (Price.At at the prompt size) this PR relies on.
  • The remaining main commits (#1450, #1414, #1296, #1453, #1452) touch the accountant version, the OpenCode installer, lock gaps and test timing — no contact with this PR's code.

Earlier findings

  • All findings from rounds 1 to 3, both reviewers, are fixed and stay fixed: every PR-owned file is byte-identical across the merge (verified, see below), and the PR's hunks inside the three merge-co-touched files are intact (TokenRates.Cost's At at components/component.go:1062, recordLeg's card.At at extract_sweep.go:849).

What I checked

  • Last review: round 3, e27765bdcc8c0d939b3018582f80e8a316768b56, 2026-11-26T11:48:43Z
  • New commits read: 1 on the PR branch (7212131e "merge origin/main into feat/sweep-tier-line"), bringing 9 main commits: e2d4177e #1193 warm copy without a ping, ec82ede3 #1458, 5dcb70fa #1450 accountant bump, f174d823 #1454 NextRequestUSD, 8dee073a #1456 accountant on every request, c4a6dd86 #1414 and 25580ca3 #1296 OpenCode installer, bf68543d #1453 lock gaps, e0ad5c51 #1452 picker test.
  • Read in full: 5 reviews, 4 comments, 0 inline comments (from the three saved files)
  • New items since my last review: reviewer 1's round-3 review (approve, 11:48:46Z — read in full, nothing to add); the author's merge comment (13:12:04Z — each claim checked below); the merge commit 7212131e.
  • The merge keeps this PR intact: git diff e27765bd..HEAD over the PR-owned paths (extract_sweep_tier.go, extract_sweep_tier_test.go, extract_sweep_v3.go, extract_sweep_v3_test.go, components/ratesof.go, lifecycle/, dash/event.go, dash/pricecg_tier_test.go, docs/components/advanced-offload.md) is empty. The tier markers are all present in the merged head: tierGoal, tierEcon, waiting = false (extract_sweep_v3.go:697), the measured goal check (:888), and PriceCG's p.At (dash/event.go:999).
  • The conflict resolution is correct: the author says only the data-dependence docs conflicted. The merged extract_llm_sweep row carries both #1193's warm-only-copy text and the tier_target sentence, and the generated docs/data-dependence.md matches the row file exactly — I compared the where and off columns of the table row against the row file's fields, character for character. No hand edit of the generated page.
  • The two code paths work together: registerWarm's new condition (c.PrefixAsk == nil || !e.keepsCopy(c)) and the tier judge path compose — registration widens, gates unchanged. The test helpers this PR's tests use (pingAsker, warmRig.forward) are unchanged by the merge, so the tier tests compile and run against the merged machinery; purego CI on the merge head runs the components tests and is green.
  • CI on head 7212131e: all jobs pass (build, lint-build, purego, analyze, trivy, DCO, CodeQL). No builds or tests were run by me (not approved). Code reading only.

@amiddavid
amiddavid merged commit dec2ef0 into main Nov 26, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
amiddavid added a commit that referenced this pull request Nov 26, 2026
…1462)

refactor(dash): price the dashboard's savings with accountant.Figure

The dollar math leaves dash. AccountantFigure now calls accountant.Figure with
the host pricer (modelinfo.Price.RateAt, the rule the metrics sink uses) and
only maps the USDFigure to the dashboard's rows and columns. accPrices,
reRateUSD, bookReRate, tierUSD and the effect pricing are removed.

- UnownedMarkUSD goes to the tailbreakpoint row, as before.
- UnownedReRateUSD goes to the ended_change row, as before.
- The held floor reads ByComponentSaved and ByComponentSavedAsRead
  (accwire.HeldFloorUSD).
- The re-rate goes to the operations that moved the size (#120).
- A test checks the dashboard figure equals the llm_savings_* counters.

Fixes #1440

refactor(dash): review round 1 notes for the figure mapping

- Move HeldFloorUSD from accwire to accrec (shared glue rule).
- hostPricer refuses a model it does not hold (rate 0, estimated).
- Skip a zero-token op in the mapping, as before.
- Fix two stale names in comments.
- Test an InBaseline rescue and the pricer refusal.

fix(dash): keep a zero-token key of a component that acted

A component that acted can have counted ops of 0 tokens (the byte ratio
truncates). The zero-token skip removed its key, and accOverride then dropped
the whole request's saving. The skip now applies only to a name with no row.

- Test: an acted row with a zero-token op plus a real figure still prices.
- docs/design.md: name HeldFloorUSD in the accrec row.

Behavior change (the dashboard savings figures come only from accountant.Figure; figures move where the library rule differs from the old dash copy) approved by the owner in the integrator session: "1462 yes". Merged tree with #1461/#1455 built, vetted and tested before the merge; proxy-boundary check passed.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openai OpenAI / Codex traffic and pricing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(sweep): cut below a provider's long-context price line (OpenAI 272K)

1 participant