Skip to content

fix(dash): Count fallback requests and keep them out of the saving share - #1173

Merged
amiddavid merged 5 commits into
mainfrom
fix/1004-fallback-share
Nov 16, 2026
Merged

amiddavid merged 5 commits into
mainfrom
fix/1004-fallback-share

Conversation

@boazdavid

@boazdavid boazdavid commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change (needs a human developer's yes before merge).

Summary

Fixes #1004 (B8 of the #768 review). A fallback request no longer lowers the saving share, and Overview says how many requests fell back.

What changed

  1. New column requests.acc_fallback. It holds the fallback reason (unpriced, unsupported_wire, and so on), or ''.
    • The proxy sets it on the requests it already logs as acc_fallback.
    • A request with no accountant record (no_record) stores none: it had nothing to price.
    • A bypassed request stores none. The proxy logs it as size_unknown, because bypass leaves the size at 0. But the client asked for no context-guru, so its $0 is a measured $0. Counting it would raise the share for users who bypass often.
  2. One-time backfill. Rows written since Feat: Re-land the accountant pricing of proxy savings (#768) with the review fixes #930 that have a priced_by = 'none' component are marked unrecorded. A meta key stops a second run.
  3. New Overview fields: fallback_requests, fallback (count by reason), fallback_cost_usd (cost_usd + cg_llm_cost_usd of those rows), and fallback_saved (their booked saving by part: compaction_usd, defer_usd, keepalive_usd, reorder_usd, filter_usd). The lean read carries all but fallback and filter_usd.
  4. UI: each part is the server's part less its fallback share, and "You spent" is the spend less the fallback cost. A line under the total: "N requests could not be priced: $X spent, $Y saved. They are left out of these figures."

Item 3 of #1004 (a regression test for the unpriced count) already exists on main: TestAComponentWhoseRequestsAllFellBackIsUnpricedNotZero.

Data dependence

Metadata only. acc_fallback is a fixed code, no text. It works the same at every storage level. docs/data-dependence/features/dashboard-database.md is updated and docs/data-dependence.md regenerated. No change of data dependence for any feature.

How it was tested

  • TestFallbackRequestsLeaveTheSavingShareAlone: the feat(accountant): Price proxy savings with the accountant library #768 repro. 10 priced plus 10 fallback requests now give the same share as the 10 priced alone. It was 93.75% against 88.24%.
  • TestUnrecordedFallbackIsNotCounted, TestBypassedRequestIsNotAFallback, TestAccFallbackRoundTrips, TestBackfillAccFallbackMarksOldFallbackRows.
  • Proxy: TestBypassedRequestStoresNoFallback (through the real handler); the Responses wire test checks the stored unsupported_wire; a priced request stores none.
  • node --test dash/*.test.mjs: 42 of 42 pass, with a new overviewTotals case.
  • go test ./dash/ ./proxy/ pass. Failing on unchanged main too, not from this PR: TestBobPluginPythonSuite (local Python 3.8), and 2 proxyapp preflight tests.

Open questions

  • None. (Round 1 showed that the lean read also paints the hero first. It now carries the fallback fields.)

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

A request the accountant library cannot price books its cost and no
saving. The Overview share counted that cost, so each fallback lowered
the share although no saving changed (#1004, B8 of the #768 review).

- Store the fallback reason in requests.acc_fallback. The proxy sets it
  on the requests it logs as acc_fallback. A bypassed request stores
  none: its $0 is a measured $0.
- Back-fill older rows once from their priced_by 'none' components.
- Add fallback_requests, fallback and fallback_cost_usd to Overview.
- The hero share leaves the fallback cost out, and says how many
  requests and dollars it leaves out.

Fixes #1004

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 (claude, user of @boazdavid) Claude Code 2.1.241, opus offload-review skill, @boazdavid's session fresh 2 of 2 1 of 2 983fe23ec724 blocking

Verdict: blocking

Findings

  1. dash/ui/savings.js:480-482 — The share takes the fallback rows' cost out of "without", but keeps their savings in "saved".

    • What fails: A fallback row does not always book "no saving". Three savings stay on it. The share then rises, and it can reach 100%.
      • The declaration filter credit (decl_filter_usd) counts a fallback row on purpose. declFilterInBaseline (dash/toolsuggest.go:204) is 0 for a row with priced_by = 'none'. So the measured credit adds the USD of that row.
      • Tool deferral (defer_net_usd) keeps the ledger's net on a fallback row. accOverride returns before line 430 of dash/accountant_price.go. So the net from proxy/dashcapture.go:696 stays.
      • Compaction (net_saved_usd = baseline - cost - cg_llm, dash/savings.go:87) is -cg_llm_cost_usd on a fallback row. But fallback_cost_usd also takes cg_llm_cost_usd out of the spend. So our own model cost leaves the denominator and stays in the numerator.
    • Proof: overviewTotals with 10 fallback requests at $1.00 each and a $0.20 filter credit each. The input is {cost_usd: 10, decl_filter_usd: 2, fallback_requests: 10, fallback_cost_usd: 10}.
      • Old: saved 2, spent 10, without 12, 16.7%.
      • New: saved 2, pricedSpent 0, without 2, 100%. The hero says "You spent $0.00 instead."
      • Add 10 priced rows at $1.00 with no saving. Priced alone gives 0%. With the fallback rows the share is 2 / 12 = 16.7%, so the fallback rows now raise the share.
      • This hits the wires that #899 names as the main source of fallbacks (unsupported_wire), when the filter or deferral acts there.
      • #1004 proposed to leave fallback rows out of "both the numerator and the denominator". The PR does only the denominator. TestFallbackRequestsLeaveTheSavingShareAlone uses rows with no filter credit, no deferral and no cg_llm cost. So it does not see this.
    • Fix: Choose one of these:
      • Let the server also return the savings of the fallback rows: their defer_net_usd, their filter credit, and -cg_llm_cost_usd. Take that sum out of the share's numerator too.
      • Or put only cost_usd in fallback_cost_usd, and keep the share unchanged for a row that carries any other saving.
      • Add a Go test with a fallback row that has filtered_decl_tokens > 0, defer_net_usd > 0 and cg_llm_cost_usd > 0.
  2. dash/ui/app.js:1576 — The Overview hero paints first from the lean read. The lean read has no fallback fields.

    • What fails: loadOverview calls renderSavedLedger(lean, …, true) before the full read lands. overviewLean (dash/overview_lean.go) does not set fallback_requests or fallback_cost_usd. So the first paint shows the old share and the whole bill in "You spent …". The full read then changes "without", the percent and "You spent". A user who reads the first paint gets a different share.
    • Proof: app.js:1566-1576 renders the lean body. overviewTotals reads o.fallback_cost_usd || 0, which is 0 on lean. The PR's open question says that only the status line reads lean. That is not correct: the Overview hero reads it too.
    • Fix: Add SUM(CASE WHEN r.acc_fallback <> '' …) for the count and the cost to leanWindowMainQuery. It is the same scan. Or do not draw the share and "You spent" while partial is true. Correct the open question and the line in docs/dashboard.md.

Non-blocking

  • dash/schema.go:381 — The backfill marks old rows unrecorded when any component has priced_by = 'none'. PriceMode also marks a no_result row so when accReq is nil (for example the record panicked, proxy/accountant_wire.go:93). A new row of that kind stores ''. So old and new rows of one kind count differently. This is small, but the docs could say it.
  • docs/dashboard.md:507-509 — The backfill also cannot find a row that fell back in the first priceCost branch (no price, or usage not complete). That branch returns before it marks the components. The doc names only the case "no component row".
  • dash/schema.go:381 — The one-time backfill scans request_components in full, with no index on priced_by, at open. On a large database this may slow the first start. It runs one time only.
  • RecordAccountantFallback keeps the record of a request that had no price at write time and that the reprice pass (dash/reprice.go) prices later. That is consistent, because the reprice books no saving.

What I checked

  • I read the full diff (16 files) and the PR body.
  • I read PriceMode, accOverride, priceCost, Price and the deferral part of the override in dash/accountant_price.go and dash/event.go.
  • I read the call site in proxy/dashcapture.go:860-880, noResultWhy, accDrop and accRun.
  • I read the main Overview aggregate, savingsArithmetic, savedParts, overviewTotals, declFilterInBaseline, DeclFilterSavings and OverviewLean.
  • I read the Overview's two-step load in dash/ui/app.js:1555-1600 and the hero at 1704-1800.
  • Insert and scan: one new column, one new placeholder and one new argument in insertBatch. requestCols and scanRequest match. Only dash/query.go, dash/store.go and dash/acctokens.go write or read requests rows. Only the proxy calls PriceMode.
  • Migration: addColumns runs before the backfill on both paths of migrate. A fresh database creates the column in ddl. The meta key stops a second run.
  • The new Overview query uses the same cond and args as the main aggregate, so the ping rows stay out on both.
  • Data dependence: the row file and the generated page have the same new text. There is no change of Kind or of a level.
  • Fail open: the change adds no new error path on the request path. RecordAccountantFallback only copies a string.
  • The PR names the behavior change at the top, as CLAUDE.md requires.
  • I did not run Go or node tests. Live tests are not approved, and Go is not installed.

@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 (claude, user of @boazdavid) Claude Code 2.1.241, opus offload-review skill, @boazdavid's session fresh 1 of 2 1 of 2 983fe23ec724 blocking

Verdict: blocking

Findings

  1. dash/ui/savings.js:480 — the share takes the fallback rows out of the denominator only. Their savings stay in the numerator.
    • What fails: the PR says the decision is "exclude both sides", and the test says the result is "the priced requests' share". That holds only when a fallback row books exactly $0 of saving and has cg_llm_cost_usd = 0. A fallback row can book three things in p.total:
      • Tool deferral's ledger net. proxy/dashcapture.go:696 sets DeferNetUSD = d.net before PriceMode. On a fallback, accOverride returns before dash/accountant_price.go:433, which is the only line that replaces the ledger net. deferNetSum (dash/overview.go:702) then sums it for every row in cond, fallback rows included.
      • The tool filter's measured credit. declFilterInBaseline (dash/toolsuggest.go:204) is true only when the toolfilter component has priced_by = 'accountant'. A fallback row has priced_by = 'none', so its filtered_decl_tokens go into decl_filter_usd, the filter part.
      • Minus its own model-call cost. savingsArithmetic (dash/savings.go:87) gives net = baseline - cost - cgllm. A fallback row has baseline = cost, so it adds -cg_llm_cost_usd to net_saved_usd. But fallback_cost_usd (dash/overview.go:270) also takes that cg_llm_cost_usd out of the spend. So that cost leaves the denominator and stays in the numerator.
    • Proof (arithmetic, same formula as overviewTotals):
      • Priced rows: cost $9, baseline $10, no model calls. Priced-only share = 1 / 10 = 10%.
      • Add 1 fallback row with cost $1 and cg_llm_cost_usd $0.50. Overview: cost_usd 10, cg_llm_cost_usd 0.5, net_saved_usd = 11 − 10 − 0.5 = 0.5, fallback_cost_usd 1.5. New share = 0.5 / (10.5 − 1.5 + 0.5) = 5.3%. The old share was 4.5%. The fallback row still lowers the share.
      • Add instead 1 fallback row with cost $1 and a ledger defer net of $0.40. New share = 1.4 / (9 + 1.4) = 13.5%. The fallback row now raises the share above the priced share.
      • The same holds for the filter credit. A common source: every request in the first seconds after start, before the price map loads. priceCost fails, PriceMode returns FallbackUnpriced at dash/accountant_price.go:293, and the row keeps its ledger defer net and its filter tokens.
    • The test does not see it: fbEvent (dash/fallback_share_test.go:67) has one mask component, no deferral, no filtered declarations and CGLLMCostUSD = 0.
    • Fix: take the fallback rows out of both sides. Option: the fallback query also sums the fallback rows' booked saving (baseline_cost_usd - cost_usd - cg_llm_cost_usd plus the defer net column), and the filter credit scan reports the fallback rows' part. The UI then takes that saving off p.total for the share. Simpler option: take only cost_usd (not cg_llm_cost_usd) out of the spend, and leave out of the share the defer net and filter credit of fallback rows. Add a test with a fallback row that has CGLLMCostUSD > 0, a deferral ledger net and FilteredDeclTokens > 0, and check that the share equals the priced-only share.

Non-blocking

  • dash/schema.go:381 — the backfill rule is wider than the live rule. PriceMode marks components priced_by = 'none' on every fallback, also when c.accReq == nil. Live code stores no reason then (proxy/dashcapture.go:873). Example: a panic before forward calls cp.accDrop() (proxy/proxy.go:1465) after some components ran. The backfill marks such an old row unrecorded; a new row of the same kind stays ''. The case is rare. The doc text in docs/dashboard.md could say so.
  • dash/schema.go:381-386 — the UPDATE and the meta insert are two statements, not one transaction. If the process stops between them, the next open runs the UPDATE again over rows the new code wrote with ''. Same class of rows as the point above. A transaction removes it.
  • proxy/dashcapture.go:844 — a rejected request (rejected_status) gets no_result and is now counted under "could not be priced". The text under the hero then counts 4xx/5xx requests as unpriced. Its cost is probably $0, so the share does not move, but the count can confuse a reader.
  • dash/ui/app.js:1714-1716 — the token figure ("Input tokens removed … of …") still includes the fallback rows. The dollar share and the token share now use different row sets. Consider a word about it in the info text.
  • dash/overview.go:238 — the comment says "the agent-only rows the main aggregate reads". cond excludes pings; it has no agent filter. "the non-ping rows" is more exact.

What I checked

  • Read the full diff (16 files, 1 commit) and the commit message. Read the PR body and issue #1004.
  • PriceMode, accOverride and priceCost: which fallback paths mark components priced_by = 'none', and which leave DeferNetUSD, KeepAliveSavedUSD and CachesplitSavedUSD set. Keep-alive and split are 0 on a fallback; the defer ledger net is not.
  • proxy/dashcapture.go finish: RecordAccountantFallback is called only when accReq != nil || accUnsupportedWire, the same gate as logFallback. The bypass case stores ''. cg_llm_cost_usd is set after it, but the SQL reads it from the row, so that is fine.
  • Filter.where: the fallback query and the main aggregate use the same cond, so fallback_cost_usd is a subset of cost_usd + cg_llm_cost_usd. pricedSpent cannot go below 0.
  • reprice.go: a row priced late keeps acc_fallback = 'unpriced' and books no saving. Its later cost is in fallback_cost_usd. Consistent.
  • Store and read: the new column is in insertBatch (placeholder count +1), requestCols and scanRequest, in the same order. additiveColumns adds it before the backfill runs on both migrate paths.
  • declFilterInBaseline and deferNetSum, to trace finding 1.
  • Data dependence: docs/data-dependence/features/dashboard-database.md and the generated row in docs/data-dependence.md have the same new text. The level cells and the Kind did not change. Metadata only (a fixed code).
  • Behavior change: the PR names it at the top (who, old, new, how to turn off, decided by). Finding 1 means the code does not yet do the decided option ("exclude both sides").
  • Fail open: the change is read-side and dashboard-only. No request path changes. A failed fallback query fails the Overview read, like the other errgroup queries.
  • I did not run Go or Node tests. Live tests are not approved for this review.

Review of #1173 (both reviewers): a fallback row is not always a $0
saving. It keeps the deferral ledger's net and the measured filter
credit, and its own model calls make its compaction net negative. The
share took the fallback cost out of the denominator only, so these
moved it either way, up to 100%.

- The reads return fallback_saved, the fallback rows' saving by part.
  The filter part comes from DeclFilterSavings.
- overviewTotals takes each part's fallback share off that part, and
  the fallback cost off the spend. The hero and the cards describe the
  priced requests only. The fallback line names the spend and the
  saving left out.
- The lean read, which paints the hero first, carries the same fields.
- The backfill and its meta mark are one transaction.
- Update the stats goldens for the new fields.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
@boazdavid

Copy link
Copy Markdown
Collaborator Author

Replies to round 1 (both reviewers)

Fixed in 6122e43.

Reviewer 1, finding 1, and reviewer 2, finding 1: the fallback saving stayed in the numerator. Fixed.

  • fallback_saved gives the fallback rows' saving by part: compaction (baseline - cost - cg_llm), deferral net, keep-alive, reorder, and the filter credit (from DeclFilterSavings, which now splits it by acc_fallback).
  • overviewTotals takes each part's fallback share off that part, and fallback_cost_usd off the spend. The hero and the cards then describe the priced requests only, in dollars and percent.
  • Reviewer 2's case (cost_usd: 10, decl_filter_usd: 2, 10 fallback rows) now gives without 0 and 0%, not 100%. It is in dash/savings.test.mjs.
  • TestFallbackSavingIsLeftOutToo: fallback rows with CGLLMCostUSD > 0, a deferral ledger net and FilteredDeclTokens > 0. The share equals the priced-only share.

Reviewer 2, finding 2: the lean first paint has no fallback fields. Fixed. leanWindowMainQuery adds the same terms (fallbackTerms, shared with the full read) in its one scan. It has no filter part, because the lean read has no filter credit either. The test checks lean against full. The PR body's open question is corrected.

Non-blocking

  • Backfill wider than the live rule, and blind to the priceCost branch: kept, and now said in the backfillAccFallback comment and in docs/dashboard.md. Both cases are rare, and the old rows age out with retention.
  • Backfill not in one transaction: fixed. The update and the meta mark are one transaction.
  • One-time full scan at open: kept. It runs once, and a meta key stops it later.
  • Rejected 4xx/5xx requests counted as no_result: kept. They are fallbacks by the proxy's own acc_fallback rule, and their cost is normally $0, so the share does not move. fallback gives the count by reason for a reader who wants to split them.
  • The token figure still counts every request: kept, and now said in the hero info text and the docs.
  • "agent-only" in the comment: fixed to "non-ping rows".
  • Reprice keeps the reason: agreed, no change.

Also: the stats golden files now carry the new fields. The first head failed TestGoldenEndpoints.

@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 (claude, user of @boazdavid) Claude Code 2.1.241, opus offload-review skill, @boazdavid's session resumed 1 of 2 2 of 2 6122e43349ca approve

Verdict: approve

Findings

None.

Status of the round-1 findings

  • Reviewer 1, finding 1 (the fallback saving stayed in the numerator): fixed.
    • fallbackTerms (dash/fallback.go:49) sums the cost and 4 saving parts of the fallback rows. The formulas are the same as the main aggregate: baseline - cost - cg_llm, deferNetCol, kaSavedSince("r.", since) and cachesplit_saved_usd.
    • DeclFilterSavings gives the filter part from the same row loop as USD, so it is always a subset of decl_filter_usd. SetDeclCredit sets it, and /api/stats (dash/api.go:1484, 1539) calls both.
    • overviewTotals takes each fallback part off its own part and fallback_cost_usd off the bill. I checked the new savings.test.mjs case by hand: compaction 28 + 2 = 30, defer 3 − 3 = 0, filter 1 − 1 = 0, spend 92 − 22 = 70, without 100, share 30%. All are correct.
    • My round-1 examples now give the priced-only share. The $0.50 model-call example: compaction 0.5 − (−0.5) = 1, spend 9, share 10%. The $0.40 deferral example: defer 0.4 − 0.4 = 0, share 10%.
    • The ledgers that run after Overview do not add fallback saving back. The replay cap joins only components with saved_usd <> 0 (dash/replaycap.go:455-457), and rePriceRow skips StoredUSD == 0. A fallback component has saved_usd = 0.
    • TestFallbackSavingIsLeftOutToo covers model-call cost, a deferral ledger net and filtered declarations, as I asked.
  • Reviewer 2, finding 1 (same defect): fixed, for the same reasons. Reviewer 2's case now gives without 0 and 0%. It is in savings.test.mjs.
  • Reviewer 2, finding 2 (the lean first paint had no fallback fields): fixed. leanWindowMainQuery adds fallbackTerms(agent + " AND r.acc_fallback <> ''", f.Since) in the same scan. The agent guard keeps the ping rows out, like the full read's cond. The lean read sets no decl_filter_usd, so the filter part is 0 on both sides of the lean hero. The new test compares lean with full.
  • Round-1 non-blocking points:
    • Backfill not in one transaction: fixed (dash/schema.go:982-994).
    • Backfill wider or narrower than the live rule: the author kept it and documented it in the code comment and docs/dashboard.md. I accept this. The cases are rare.
    • Full scan at open, rejected_status counted, the token figure: kept with reasons. I accept them. The info text now says the token figures count every request.
    • "agent-only" comment: fixed.

Non-blocking

  • dash/ui/app.js:1760-1762 — t.unpriced.saved can be negative. A fallback row with model calls and no other saving gives compaction -cg_llm. The line then reads "… spent, -$0.02 saved." A word such as "net" or a cost label would read better.
  • dash/ui/savings.js:512-513 — when every request in the window falls back (for example, a user on the Responses wire only), the hero reads "$0.00 saved, out of $0.00", "0% saved" and "You spent $0.00 instead." The fallback line under it explains this, but the hero could say "nothing priced" instead of three zeros.
  • dash/ui/savings.js:22 — savedParts still adds cachesplit_historical.usd to reorder, and the fallback split does not cover it. That credit is for rows from before the split's instrumentation, so it probably does not meet the acc_fallback rows. I note it only for completeness.

What I checked

  • Last review: round 1, 983fe23ec72491cccad34dace55ad27f61c86021, 2026-11-16T16:26:09Z
  • New commits read: 1 (6122e433 fix(dash): Leave fallback requests out on both sides of the share)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Comment by boazdavid at 2026-11-16T16:39:19Z (replies to round 1): I checked each reply against the code. See "Status of the round-1 findings".
    • Reviewer 2's round-1 review (16:25:54Z, before mine): I read it for the first time in this round. Its 2 findings and 4 non-blocking points are in the status list above.
    • The PR body: the behavior-change note now describes both sides and the new "Turn off" step. The lean open question is corrected.
  • Read the full diff 983fe23e..6122e433 (14 files), including the 3 golden files, and the code around each change: OverviewLean, leanWindowMainQuery, Overview's main aggregate (kaSavedSince at line 689), SetDeclCredit, DeclFilterSavings and DeclFilterSavingsByTenant (unchanged query, return value ignored, no scan mismatch), accumulateDeclFilterRow (the dollars it returns equal what it adds to USD), ApplyReplayLedger, ApplySummarizeLedger, and the hero cards in renderSavedLedger (they read t.parts).
  • Scan order: fallbackAgg.dest() has 6 targets for the 6 fallbackTerms columns. The full read adds acc_fallback in front. The lean read appends them last, after tok.dest(), which matches the SQL order.
  • fallback is now omitempty. The UI does not read it. The goldens carry the new fields.
  • Data dependence: no new column in this commit. The new fields are sums of existing columns. The row file and the generated page are unchanged and still match.
  • Fail open: the change is read-side and dashboard-only. It has no request-path code.
  • I did not run Go or Node tests. Live tests are not approved for this review.

@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 (claude, user of @boazdavid) Claude Code 2.1.241, opus offload-review skill, @boazdavid's session resumed 2 of 2 2 of 2 6122e43349ca approve

Verdict: approve

Findings

None.

Status of the round-1 findings

  • Reviewer 2, finding 1 (the fallback saving stayed in the numerator): fixed.
    • fallbackTerms (dash/fallback.go:49) sums 6 terms over the fallback rows: the count, cost_usd + cg_llm_cost_usd, baseline - cost - cg_llm, defer_net_usd, kaSavedSince and cachesplit_saved_usd. These are the same expressions that savingsArithmetic and the main aggregate use. So each part comes off with its own formula.
    • DeclFilterSavings now splits the filter credit by acc_fallback <> ''. SetDeclCredit puts that part in fallback_saved.filter_usd.
    • overviewTotals takes each part's fallback share off that part, and takes the fallback cost off the spend. My round-1 case (cost_usd 10, decl_filter_usd 2, 10 fallback rows) now gives without 0 and 0%. That case is in dash/savings.test.mjs.
    • TestFallbackSavingIsLeftOutToo uses fallback rows with CGLLMCostUSD, a deferral ledger net and FilteredDeclTokens. It checks that the share is equal to the priced-only share.
    • The hero cards (cache, preset, filter, deferral) read t.parts, so they also show the priced requests only. I checked dash/ui/app.js:1795-1900.
  • Reviewer 2, finding 2 (the lean first paint has no fallback fields): fixed. leanWindowMainQuery adds fallbackTerms(agent+" AND r.acc_fallback <> ''", f.Since) in the same scan. The Scan order matches the SQL order: accTokenLeanTerms, then the 6 fallback terms. The lean read leaves out the filter part. That is correct for the hero, because the lean read does not set decl_filter_usd, so savedParts already shows a filter part of 0 there. The PR's open question is corrected.
  • Reviewer 1, finding 1: this is the same defect as my finding 1. It is fixed by the same change.
  • Non-blocking points from both reviewers:
    • Backfill wider than the live rule, and blind to the priceCost branch: kept. Both are now described in the backfillAccFallback comment and in docs/dashboard.md. I accept this, because the cases are rare and the old rows age out.
    • Backfill not in one transaction (reviewer 1): fixed (dash/schema.go:982-994).
    • The full scan at open: kept. I accept this, because it runs one time only.
    • Rejected 4xx/5xx counted as no_result (reviewer 1): kept. I accept the reason: their cost is normally $0, and fallback gives the count by reason.
    • The token figure counts every request (reviewer 1): kept, and now said in the info text and the docs.
    • The "agent-only" comment: fixed to "non-ping rows".

Non-blocking

  • dash/cachehistory.go — The historical reorder credit (cachesplit_historical.usd, which is in parts.reorder) is not split by acc_fallback. A session's first request can be a fallback row and still get this credit. Then that saving stays in the numerator while its cost leaves the denominator. The case is small: it needs a session-first row with split_stable_tokens = 0, a model with one constant stable half, and a large cache read. This is old code, not a defect of this PR.
  • OverviewLean — With a price function, total_saved_usd on the lean read includes the fallback rows' filter credit, but fallback_saved.filter_usd is 0. The hero does not use total_saved_usd, so nothing on the page is wrong. A different API client that computes the share from total_saved_usd minus fallback_saved would get a small error.
  • docs/data-dependence/features/dashboard-database.md — The row says that the Overview "leaves their cost out of the saving share". It now leaves out their saving too. The data level does not change, so this is only a text update.
  • The behavior-change block at the top of the PR now names the wider change (the hero total and the part cards drop the fallback saving). It still needs the human "yes" before merge, as CLAUDE.md requires.

What I checked

  • Last review: round 1, 983fe23, 2026-11-16T16:25:54Z
  • New commits read: 1 (6122e433 fix(dash): Leave fallback requests out on both sides of the share)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-1 review (16:26:09Z): I checked its finding 1 (the same as my finding 1) and its 5 non-blocking points against the new commit. See the status list above.
    • The author's reply comment (16:39:19Z): I checked each reply against the code. All fixes are in the diff. I accept the "kept" reasons.
    • The updated PR body: the behavior-change block, item 3 and item 4, and the open question.
  • I read the whole diff 983fe23e..6122e433 (14 files), and the code around it:
    • fallbackTerms, fallbackAgg.dest/add/apply against the SQL column order, in both the full read and the lean read.
    • kaSavedSince, deferNetCol and savingsArithmetic, to check that each fallback part uses the same expression as its part.
    • DeclFilterSavings, declFilterSavingsQuery and both callers of accumulateDeclFilterRow. DeclFilterSavingsByTenant ignores the new return value and keeps its own SELECT, so it is not changed.
    • SetDeclCredit: it runs after fallback.apply, and apply keeps the filter part.
    • ApplyReplayLedger and the replay cap: its join needs c.saved_usd <> 0, and a fallback row's components have saved_usd = 0, so the cap does not touch fallback rows.
    • The API lean branch (dash/api.go:1411-1434) and renderSavedLedger, including the hero, the fallback line, and the cards.
    • The golden files: the fallback map has omitempty, so an empty map is left out, as the goldens show.
    • The backfill transaction, and its call on both migrate paths.
  • Data dependence: the new commit does not change the row file or the generated page. The new fields are numbers only.
  • Fail open: the change is on the read side and in the dashboard only. No request path changes.
  • I did not run Go or node tests. Live tests are not approved, and Go is not installed.

@boazdavid

Copy link
Copy Markdown
Collaborator Author

Behavior change approved by @boazdavid (human developer), 2026-11-16, as RELEASING.md requires.

Approved change: the Overview hero and its part cards leave out the requests the accountant library could not price, both their spend and the saving they still book. A line under the total names the requests, spend and saving left out. Cost totals on other pages, and the token figures, are unchanged.

amiddavid pushed a commit that referenced this pull request Nov 16, 2026
…dropped (#1139)

When the pipeline's operations are dropped (the accountant's
ops_dropped path), apply still reports the tail mark's operation, so
the accountant can price it.

Behavior change: readers of the central llm.savings.* metrics, for
requests with dropped operations and a tail mark. Old: 0 operations,
llm.savings.requests{result="skipped"} and a +1 on
llm.savings.check_failures{check="sum"}. New: the mark's operation is
booked under component="tailbreakpoint" in llm.savings.saved.tokens and
llm.savings.added.tokens (and the .usd counters on api billing), with
result="priced"; the sum failure is not counted when the mark was the
only operation. The thread state that computeSafe keeps also gets the
mark's ChangeID, which can change the next request's figure on the
thread.
Owner's yes, 2026-11-16, in the integrator session: "yes" (to the
behavior changes of #1150, #1173, #1165, #1139, #1172 and #1140).

Data dependence: none (sizes and a hash of the message, as before).

Reviews: 2 offload review rounds (Claude backend). Round 2: both
approve at da52ebd, which is the PR head.

Signed-off-by: DAVID BOAZ <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid pushed a commit that referenced this pull request Nov 16, 2026
The accountant library now prices the OpenAI Responses wire
(/openai/v1/responses). The proxy builds the accountant's view of a
Responses body the same way as for the other two wires: a hash and a
size per part, no text kept.

Behavior change: accounts on /openai/v1/responses. Old: every request
on that wire booked $0 saving, with fallback unsupported_wire. New: a
request that sends its full history is priced as on the other two
wires. A request that leaves part of its prompt on the provider's side
(previous_response_id) still books $0, now with fallback
server_held_history.
Owner's yes, 2026-11-16, in the integrator session: "yes" (to the
behavior changes of #1150, #1173, #1165, #1139, #1172 and #1140).

Data dependence: unchanged (metadata only). The accountant-savings row
says so.

Reviews: 2 offload review rounds (Claude backend). Round 2: both
approve at ea37791, which is the PR head. After it, main changed only
docs/dashboard.md among its files (#1151); the merge is clean.

Signed-off-by: DAVID BOAZ <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid pushed a commit that referenced this pull request Nov 16, 2026
The proxy reports the first request after a client compaction, from
the thread tracker (#947), and the replay cap uses that mark to close
an epoch.

Behavior change: dashboard users, through the replay-cap savings
figures. Old: the replay cap guessed a client compaction from a drop
in tokens_before after the agent's compaction request. New: on rows
written from now on, an epoch closes only where the thread tracker
marked the first request after a compaction; a header subagent or a
tool-less helper thread can no longer close an epoch (#585). Rows
written before keep the old rule. Turn off: no switch.
Owner's yes, 2026-11-16, in the integrator session: "yes" (to the
behavior changes of #1150, #1173, #1165, #1139, #1172 and #1140).

Data dependence: metadata only, unchanged in kind: one short label per
request (unknown or empty), no text. The Thread tracker row is updated.

Reviews: 2 offload review rounds (Claude backend). Round 2: both
approve at be71e02, which is the PR head. CI passed on a fresh merge
with main after #1150 (the eval box was down; owner: merge on CI and
reviews until it is back).

Signed-off-by: DAVID BOAZ <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid added a commit that referenced this pull request Nov 16, 2026
On a local proxy, the Overview's Preset card names the preset the proxy
runs now, with a note while the window's history says something else.
After a switch from off to ultrahigh, the card still said "Preset
(off)", because 96% of the window's requests (2,898 of 3,016) ran
under off.

Behavior change (asked for by a developer): local proxy users of the
Overview. Old: the card named the preset most requests in the window
ran under. New: it names the running preset (from /api/whoami). A
hosted account keeps the old card.
Owner's yes, 2026-11-16, in the integrator session: "yes" (to the
behavior changes of #1150, #1173, #1165, #1139, #1172 and #1140).

Data dependence: none changed.

Reviews: 3 offload review rounds (Claude backend). Round 3: both
approve at 0fbbe2c, which is the PR head and the integrator's merge
of main that moved the change into the split dashboard files (#1151):
presetName() and loadOverviewIdentity() into dash/ui/tabs/overview.js,
the account.preset lines in dash/ui/app.js, and presetLabel in
dash/ui/savings.js with a forTests entry. CI ran the Go checks (the
eval box was down; owner: merge on CI and reviews until it is back).

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid pushed a commit that referenced this pull request Nov 16, 2026
…tartup (#1172)

The reprice pass (#1002) also prices a row's compaction call. A row
written in the first seconds after a start, before the price map
loads, for a request that also made compaction calls, stayed partial
at $0 for good: neither cost_usd nor cg_llm_cost_usd was priced.

Behavior change: those dashboard rows. Old: partial at $0 for good.
New: once the map loads, the reprice pass prices both halves, marks
the row complete, and adds both halves to tenant_spend. Turn it off:
no separate switch; Options.Prices = nil turns off the whole reprice
pass, as before.
Owner's yes, 2026-11-16, in the integrator session: "yes" (to the
behavior changes of #1150, #1173, #1165, #1139, #1172 and #1140).

Data dependence: unchanged (metadata only). Row:
docs/data-dependence/features/dashboard-database.md.

Reviews: 2 offload review rounds (Claude backend). Round 2: both
approve at df9c251, which is the PR head. CI passed on a fresh merge
with main after #1150 and #1165 (the eval box was down; owner: merge
on CI and reviews until it is back).

Signed-off-by: DAVID BOAZ <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Port the share UI to the split dashboard files and keep both sides of the
event, query, schema and store changes.

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

@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 (claude, user of @amiddavid) Claude Code 2.1.325 offload-review skill, @amiddavid's session fresh 1 of 2 3 of 3 9c13135ffaea blocking

Verdict: blocking

Findings

  1. dash/store.go:603 — the merge lost the PR's extra ?. The requests insert has 3 trailing columns and only 2 placeholders.

    • What fails: every insertBatch call. SQLite rejects the statement at tx.Prepare ("N values for N+1 columns"). The dashboard then stores no request rows at all. Every page and every test that writes an event fails.
    • Proof:
      • Line 599 ends with ..., backend, client_compaction, acc_fallback: 3 columns after the token columns.
      • Line 603 ends with placeholders(len(requestStoredTokenColumns())) + ,?,?)``: 2 placeholders.
      • The args (line ~629) pass 3 values: backendOf(e.Backend), clientCompactionArg(e), e.AccFallback.
      • Before the trailing part, the counts match: 107 named columns (with the 7 of limitCols) and 107 literal ?.
      • Cause: main (43ce370c, #1165) changed this line from ,?) to ,?,?) for client_compaction. The PR at 6122e433 changed it from ,?) to ,?,?) for acc_fallback. The merge kept main's line, so one ? is missing. Compare git diff a4d43d94 6122e433 -- dash/store.go (changes the placeholder line) with git diff 43ce370c HEAD -- dash/store.go (does not).
      • CI did not catch it: on 9c13135f only the DCO check ran. No Go build or test ran on this head.
    • Fix: ,?,?,?) on line 603. Then run the Go CI (or go test ./dash/... on the box) on the new head before merge.
  2. dash/schema.go:973-974 — the merge left two blank lines after additiveColumns. gofmt -l lists the file, so make lint fails.

    • What fails: the lint step (Makefile:89, test -z "$(gofmt -l .)"). gofmt reduces a run of blank lines to one.
    • Proof: lines 972-975 are }, empty, empty, // backfillAccFallback .... At 6122e433 there was one blank line.
    • Fix: delete one blank line.

Non-blocking

  • proxy/accountant_wire_test.go — #1150 deleted TestResponsesWireBooksNoSavingAndSaysWhy, and with it this PR's check that a Responses fallback is also stored in AccFallback. The new TestResponsesServerHeldHistoryBooksNoSavingAndSaysWhy (proxy/accountant_responses_test.go:249) checks only AccountantFallback(). One line if e.AccFallback != dash.FallbackServerHeldHistory there keeps the coverage of the c.accServerHeldHistory gate in proxy/dashcapture.go.
  • The round-2 non-blocking points of both reviewers (negative t.unpriced.saved, three zeros when every request falls back, the historical reorder credit, lean total_saved_usd, the data-dependence row text) are unchanged by the merge. I keep them as non-blocking.

Status of earlier findings

  • Reviewer 1, round 1, finding 1 (fallback saving in the numerator): fixed in 6122e433, and the merge kept the fix. fallbackTerms, overviewTotals and the tests are the same as at 6122e433.
  • Reviewer 2, round 1, finding 1: same, fixed and kept.
  • Reviewer 2, round 1, finding 2 (lean first paint): fixed and kept. dash/overview_lean.go has the same diff as before.
  • Round 2: both reviewers approved with no findings.

What I checked

  • Last review: round 2, 6122e43, 2026-11-16T16:41:56Z
  • New commits read: 1 PR commit, 9c13135f Merge origin/main into fix/1004-fallback-share. It brings in from main: 43ce370c (#1140), c5e1323a (#1165), a5a52d04 (#1150), 269b6676 (#1151), 41e3de8e (#1139), a7b975e0 (#1143). I read their logs and stats; I reviewed only how the merge combined them with this PR.
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-2 review (16:42:31Z): approve, 4 non-blocking points. Still valid; see above.
    • Comment by boazdavid (16:46:27Z): the human approval of the behavior change. It matches the behavior the head implements (hero and part cards leave out fallback spend and saving; a line names them). Also #1140's commit message records the owner's yes for #1173.
    • The merge commit: see the findings.
  • Method: I compared the PR's net diff before the merge (a4d43d94..6122e433, 23 files) with the net diff after it (43ce370c..HEAD, 23 files), hunk by hunk. The differences:
    • dash/ui/app.js hero changes moved to dash/ui/tabs/overview.js (#1151). The text is the same. num, usd and overviewTotals are globals there. forTests.overviewTotals is in dash/ui/savings.js:60, and savings.test.mjs uses it.
    • dash/query.go select and scan: r.client_compaction, r.acc_fallback and &compVerdict, &e.AccFallback, in the same order. Correct.
    • dash/store.go columns and args: 3 each. The placeholders: 2. Finding 1.
    • dash/schema.go: acc_fallback in the DDL and in additiveColumns after client_compaction. Backfill unchanged. Extra blank line: finding 2.
    • dash/accountant_price.go comment and proxy/dashcapture.go gate now name server_held_history / c.accServerHeldHistory in place of unsupported_wire. Correct after #1150: unsupported_wire no longer exists as a reason.
    • docs/dashboard.md: the reason list names server_held_history. Correct.
    • proxy/accountant_wire_test.go: the old Responses assertion is gone with its test; a priced-request assertion is kept. Non-blocking point above.
  • Check runs on 9c13135f: DCO only. On 6122e433 all Go checks passed.
  • Data dependence: no change in the merge. The row file and the generated page still match.
  • Fail open: the merge adds no request-path code. Finding 1 breaks the dashboard writes, not the forwarded request.
  • I did not run Go or Node tests. Live tests are not approved, and Go is not installed.

@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 (claude, user of @amiddavid) Claude Code 2.1.325 offload-review skill, @amiddavid's session fresh 2 of 2 3 of 3 9c13135ffaea blocking

Verdict: blocking

Findings

  1. dash/store.go:603 — The merge lost the placeholder for acc_fallback. Every row insert now fails.

    • What fails: insertBatch names 1 more column than it has ? placeholders. SQLite rejects the INSERT ("N values for N+1 columns"). So the dashboard stores no request rows at all. Every dash test that calls insertBatch fails too.
    • Proof:
      • Merge base a4d43d94, line 603 ends ,?) (1 placeholder after the token columns: backend).
      • The PR at 6122e433 changed it to ,?,?) (backend, acc_fallback).
      • main at 43ce370c (#1165) changed it to ,?,?) too (backend, client_compaction).
      • Both sides made the same text change. So git took it one time, with no conflict. HEAD line 603 still ends ,?,?).
      • HEAD line 599 lists 3 columns after the token columns: backend, client_compaction, acc_fallback. HEAD line 683 passes 3 args: backendOf(e.Backend), clientCompactionArg(e), e.AccFallback.
      • git diff 43ce370c..HEAD -- dash/store.go shows the column and the arg added, and no placeholder change.
      • CI did not catch it: the PR checks show only DCO.
    • Fix: change line 603 to end ,?,?,?). Then run go test ./dash/... on the box before the next push.
  2. proxy/accountant_responses_test.go:249 — The merge dropped the only proxy test that a fallback request stores its reason.

    • What fails: at 6122e433, TestResponsesWireBooksNoSavingAndSaysWhy checked e.AccFallback == unsupported_wire. #1150 replaced that test with TestResponsesServerHeldHistoryBooksNoSavingAndSaysWhy. The merge kept the new test and did not carry the AccFallback check into it. Now no proxy test checks that RecordAccountantFallback (proxy/dashcapture.go:882-883) stores a non-empty reason. The two proxy checks left (accountant_wire_test.go:194, accountant_fallbacks_test.go:238) check only that the column stays empty. If someone removes line 883, no test fails.
    • Proof: grep -n AccFallback proxy/*_test.go at HEAD gives only lines 194 and 238, both != "" checks. At 6122e433, accountant_wire_test.go:294 had the positive check.
    • Fix: add if e.AccFallback != dash.FallbackServerHeldHistory { t.Errorf(...) } in the loop of TestResponsesServerHeldHistoryBooksNoSavingAndSaysWhy.

Non-blocking

  • The other merge results are correct. requestCols and scanRequest in dash/query.go put client_compaction before acc_fallback in both lists. The schema DDL, additiveColumns and both migrate calls of the backfill are in place. The comments and docs/dashboard.md now name server_held_history in place of unsupported_wire. The hero line moved from dash/ui/app.js to dash/ui/tabs/overview.js with no change. overviewTotals is exported through forTests, as #1151 needs.

Status of the earlier findings

  • Reviewer 2, round 1, finding 1 (fallback saving in the numerator): fixed in 6122e433. The merge did not change dash/fallback.go's terms or overviewTotals.
  • Reviewer 2, round 1, finding 2 (lean first paint): fixed in 6122e433. The merge did not change leanWindowMainQuery's fallback terms.
  • Reviewer 1, round 1, finding 1: same defect as my finding 1, fixed.
  • Round-2 non-blocking points (both reviewers): no new change. They stay non-blocking.

What I checked

  • Last review: round 2, 6122e43349ca6e9198837985da0f1aaaf5f513e3, 2026-11-16T16:42:31Z
  • New commits read: 1 PR commit, 9c13135f Merge origin/main into fix/1004-fallback-share. It brings 6 main commits: 43ce370c (#1140), c5e1323a (#1165), a5a52d04 (#1150), 269b6676 (#1151), 41e3de8e (#1139), a7b975e0 (#1143). I did not review those main commits as PR code.
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Comment by boazdavid at 2026-11-16T16:46:27Z: human approval of the behavior change. I checked that it names the same change as the PR body: hero and part cards leave out the fallback requests, a line names them, other pages and token figures unchanged. The merge does not widen that change.
    • Reviewer 1's round-2 review (16:41:56Z): read. Its 3 non-blocking points do not need action from this merge.
    • The merge commit: see below.
  • How I read the merge: I compared the PR's own diff before the merge (a4d43d94..6122e433) with its diff after (43ce370c..HEAD), line by line. Every hunk that differs is in this review: dash/accountant_price.go and dash/fallback.go comments, dash/event.go context, dash/query.go, dash/schema.go, dash/store.go, the move to dash/ui/tabs/overview.js, dash/ui/savings.js, docs/dashboard.md, proxy/accountant_wire_test.go, proxy/dashcapture.go. I read the code around store.go:585-690, dashcapture.go:870-890 and accountant_responses_test.go:240-280.
  • I did not run Go or Node tests. Live tests are not approved, and Go is not installed.

…on test

The merge of main into #1173 dropped one "?" from the requests insert (acc_fallback
had a column and an arg but no placeholder), left two blank lines after
additiveColumns, and lost the only proxy test that a fallback request stores its
reason. This adds the "?", removes the blank line, and adds
TestResponsesFallbackStoresItsReason (previous_response_id -> server_held_history).

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

Copy link
Copy Markdown
Collaborator

Round 3 findings fixed in cc633ec.

  • Missing placeholder (dash/store.go). Added the ?. The requests insert now has the same count of columns, placeholders and args (110 plus the stored-token columns). dash/query.go is balanced: select and scan each gained acc_fallback.
  • gofmt (dash/schema.go). Removed the extra blank line after additiveColumns.
  • Lost test. Added TestResponsesFallbackStoresItsReason. A Responses request with previous_response_id falls back with server_held_history. The test checks the stored AccFallback holds that reason.

CI has not run these changes yet. No Go on the laptop.

@amiddavid amiddavid closed this Nov 16, 2026
@amiddavid amiddavid reopened this Nov 16, 2026
Keep both sides' sentences in the Dashboard database row: the
acc_fallback sentence (#1004) and the compaction reprice sentence (#1033).

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

@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 (claude, user of @amiddavid) Claude Code 2.1.325 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 dbb8f8007c5a approve

Verdict: approve

Findings

None.

Status of the round-3 findings

  • Reviewer 1, finding 1 (missing placeholder in dash/store.go): fixed in cc633eca. Line 603 now ends ,?,?,?). That gives 3 placeholders for the 3 trailing columns (backend, client_compaction, acc_fallback) and the 3 trailing args. CI build-test passed on dbb8f800, so the dash tests that write events ran.
  • Reviewer 2, finding 1: the same defect, fixed by the same change.
  • Reviewer 1, finding 2 (gofmt blank line in dash/schema.go): fixed. One blank line is left after additiveColumns.
  • Reviewer 2, finding 2 (the lost proxy test that a fallback stores its reason): fixed. TestResponsesFallbackStoresItsReason (proxy/accountant_responses_test.go:282) sends 2 Responses requests with previous_response_id and checks e.AccFallback == server_held_history on every event. It fails if RecordAccountantFallback is removed from proxy/dashcapture.go:883. It also fails on 0 events, so it cannot pass empty. This was my round-3 non-blocking point too.

Non-blocking

  • docs/data-dependence/features/dashboard-database.md (and the generated row) — the example codes are "unpriced, unsupported_wire and the like". #1150 removed unsupported_wire as a reason. server_held_history is a correct example now. This is a text fix only. The data level does not change.
  • The round-2 non-blocking points of both reviewers stay as they were (negative t.unpriced.saved, three zeros when every request falls back, the historical reorder credit, lean total_saved_usd).

What I checked

  • Last review: round 3, 9c13135, 2026-11-16T18:49:13Z
  • New commits read: 2 PR commits
    • cc633eca fix(dash): restore the lost placeholder, gofmt, and the fallback-reason test (3 files)
    • dbb8f800 Merge origin/main into fix/1004-fallback-share. It brings in 12fc5538 (#1172) from main. I read its log and stat, and reviewed how the merge combined it with this PR.
  • Read in full: 6 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-3 review (18:49:14Z): 2 findings. Both fixed; see the status list.
    • Comment by amiddavid (18:52:24Z): replies to round 3. I checked each one against cc633eca. All 3 claims are true.
  • The merge dbb8f800 (git show --cc):
    • proxy/dashcapture.go: RecordAccountantFallback() stays in the fallback gate. Main's cost block moved into e.PriceCG(...), after the gate. The order does not matter: the Overview reads cg_llm_cost_usd from the stored row, not from the call.
    • docs/data-dependence/features/dashboard-database.md and docs/data-dependence.md: both sentences kept (acc_fallback from this PR, compaction reprice from #1033). The row file and the generated row have the same text.
    • #1172 and fallback rows: the reprice pass can now price cg_llm_cost_usd on a row written before the price map loaded. That row keeps acc_fallback = 'unpriced'. fallbackTerms reads cost and cg_llm from the row, so the repriced amounts leave the spend and the saving together. The share stays the priced-only share.
  • Net PR diff 12fc5538..HEAD: 24 files. It is the round-3 diff plus the 3 files of cc633eca. No other change.
  • Check runs on dbb8f800: build, build-test, purego, CodeQL, analyze, trivy, record and DCO all passed.
  • Data dependence: unchanged in kind. The text point is above.
  • Fail open: no new request-path code. The new code is a placeholder, a blank line and a test.
  • I did not run Go or Node tests. Live tests are not approved, and Go is not installed.

@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 (claude, user of @amiddavid) Claude Code 2.1.325 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 dbb8f8007c5a approve

Verdict: approve

Findings

None.

Status of the earlier findings

  • Reviewer 2, round 3, finding 1 (lost placeholder in insertBatch): fixed in cc633eca. dash/store.go:603 now ends ,?,?,?). Line 599 has 3 trailing columns (backend, client_compaction, acc_fallback), and line 683 passes 3 args. Reviewer 1's round-3 finding 1 is the same defect, also fixed.
  • Reviewer 2, round 3, finding 2 (lost stored-reason test): fixed in cc633eca. TestResponsesFallbackStoresItsReason (proxy/accountant_responses_test.go:282) sends 2 Responses requests with previous_response_id. It checks e.AccFallback == server_held_history on each event. postN waits for both rows (waitForRows, line 146), and the test fails if there are no events. So the test cannot pass with no check. Reviewer 1 had this as non-blocking; same fix.
  • Reviewer 1, round 3, finding 2 (two blank lines in dash/schema.go): fixed in cc633eca. I checked: one blank line is left after additiveColumns.
  • Round 1 findings of both reviewers: still fixed. The new merge does not change dash/fallback.go, overviewTotals or leanWindowMainQuery.

Non-blocking

  • docs/data-dependence/features/dashboard-database.md:10 (and the generated page) still uses unsupported_wire as an example code for acc_fallback. #1150 removed that code. A better example is server_held_history. The row also says the Overview "leaves their cost out of the saving share". It now leaves out their saving too. These are text points only. The data level does not change.

What I checked

  • Last review: round 3, 9c13135, 2026-11-16T18:49:14Z
  • New commits read: 2 PR commits:
    • cc633eca fix(dash): restore the lost placeholder, gofmt, and the fallback-reason test
    • dbb8f800 Merge origin/main into fix/1004-fallback-share. It brings 1 main commit: 12fc5538 (#1172, reprice the compaction call). I reviewed only how the merge combined it with this PR.
  • Read in full: 6 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-3 review (18:49:13Z): 2 findings and 1 non-blocking point. I checked each one against cc633eca. All are fixed (see above).
    • Comment by amiddavid at 18:52:24Z (replies to round 3): I checked each claim against the diff. The placeholder, the blank line and the new test are as the comment says.
    • The 12fc5538 commit message records the owner's yes for the behavior change of #1173, too. This matches boazdavid's approval comment at 16:46:27Z.
  • How I read the second merge: I compared the PR's net diff before it (43ce370c..cc633eca) with its net diff after it (12fc5538..HEAD). The only differences are:
    • The data-dependence row: the merge keeps both sentences, the acc_fallback sentence (#1004) and the compaction reprice sentence (#1033). The row file and the generated page have the same reason text.
    • One context line in proxy/dashcapture.go (e.CGModel = cgModel, from #1172). The RecordAccountantFallback gate is not changed.
  • #1172 and this PR: a repriced row keeps its acc_fallback code. Its repriced cost_usd and cg_llm_cost_usd then go into fallback_cost_usd, and its saving stays $0. So the share stays consistent.
  • CI on dbb8f800 (run 43933998335, head_sha checked): build-test, purego, record, trivy, build, analyze, CodeQL and DCO all pass. So the Go tests ran on this head.
  • Data dependence: no change in level or Kind. Fail open: no new request-path code.
  • I did not run Go or Node tests. Live tests are not approved, and Go is not installed.

@amiddavid
amiddavid merged commit ea73ea7 into main Nov 16, 2026
9 checks passed
amiddavid added a commit that referenced this pull request Nov 16, 2026
#1178)

RELEASING.md, section 3 (Merge): merge each PR on its own green CI,
then watch main. A PR merges when it has its 2 approvals and green CI
at its head and git can merge it cleanly; its CI is not re-run only
because another PR merged first. After each merge, watch main's CI and
fix forward if it turns red. Exceptions: a merge of main that the
integrator resolved by hand in code gets its CI first (#1173 lost a
SQL placeholder that way), and main must be green at the tagged
commit. A note names GitHub's merge queue as the automatic form. The
"merge of main" item no longer says to wait for CI after every merge
of main.

Owner rule, 2026-11-16, in the integrator session: "what is the
benefit of waiting for each to be green, and wasting wallclock instead
of just merging one and then waiting to see if the other one remains
green. if it isn't we fix it?"

Behavior change: none (docs). Data dependence: none.

Reviews: 1 offload review round (Bob backend, GLM did not answer):
both approve at 3be6f72, which is the PR head.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard: show how many requests fell back, and keep fallback rows out of the saving share (B8 of #768)

2 participants