Skip to content

feat: a price file names its currency; show Bob's costs in Bobcoins - #1127

Merged
amiddavid merged 17 commits into
mainfrom
feat/price-currency
Nov 17, 2026
Merged

amiddavid merged 17 commits into
mainfrom
feat/price-currency

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1118 (Bob priced in Bobcoins). Merge #1118 first.

Behavior change. Approved by the repo owner, @vz-ibm, on 2026-11-12 (the Bobcoin display design, option A).

  • Who: Bob users with bob-ultrahigh, and anyone who reads the dashboard.
  • Old: the dashboard showed every cost with a $ sign, also Bob's Bobcoins (fix(bob-plugin): price Bob in Bobcoins, output at the input rate #1118).
  • New: a price file can name its unit (currency: Bobcoins). The dashboard then shows Bob's costs as "1.75 Bobcoins" (with a coins icon on the tiles). Dollars look exactly as today. A view whose priced rows are in more than one unit shows "—" for money, with a note; token figures stay.
  • New minimum: bob-ultrahigh needs proxy v0.7.4. An older proxy refuses the new currency key and does not start, so the Bob plugin refuses or downloads, as it does for v0.7.2 today (fix(bob): setup skips a proxy that cannot list cache strategies #1111).
  • Turn it off: a price file without currency is USD, as today.

Summary

Bob bills in Bobcoins, and Bob users see Bobcoins in Bob IDE. The dashboard now shows Bob's costs in Bobcoins too. The unit comes from the price file, which already holds the numbers, so no code names Bob.

What changed

  • internal/modelinfo: a file-level key currency (1 to 16 ASCII letters; absent means USD; mixed is reserved). It is carried on Price.Currency (not on the wire) and read through Price.Unit().
  • bob-plugin/context-guru/prices.yaml: currency: Bobcoins. PRESET_MINIMUM_RELEASE["bob-ultrahigh"] is now v0.7.4.
  • Dashboard row: a new column currency, default USD (an additive column, no schema version change). Each row stores the unit of the price it used.
  • Dashboard API: 25 money routes carry currency at the top level: one unit, mixed, or USD when no row is priced. One SELECT DISTINCT query per view, cached for 30 s. Unpriced rows do not count. If the unit cannot be read, the reply says mixed, so money is hidden, not shown with a wrong unit.
  • Dashboard UI: usd() uses the page's unit. The ~230 call sites are unchanged. The saving chart's title, the campaign column heads and 2 table heads follow the unit.
  • Not changed: the *_usd field names in the API, /stats and the Prometheus metrics. Their docs say the value is in the price file's unit.

Data dependence

The new column holds a unit name, which is configuration, not user data. The dashboard database row in docs/data-dependence/ says so.

How it was tested

  • go build ./..., go vet ./...: OK.
  • go test ./dash/... ./internal/modelinfo/ ./bob-plugin/ ./components/all/ ./config/ ./proxy/ ./proxyapp/: OK, except TestRateFillTableAndPrice (see Known failure).
  • Node UI tests: 45 pass. The Bob plugin suite: 197 tests, OK, with HTTPS blocked.
  • New tests, red first:
    • modelinfo: USD by default; Bobcoins kept; a bad unit refused; mixed refused.
    • every Bob tier says Bobcoins;
    • a recorded row stores its price's unit;
    • the money replies say Bobcoins for Bob rows, USD for Claude rows and mixed for both, also with a filter;
    • every money route is in the currency list;
    • the UI: dollars are unchanged for 9 values; Bobcoins gives 1.75 Bobcoins; mixed gives —;
    • the Bob plugin refuses v0.7.3 for bob-ultrahigh and accepts v0.7.4.
  • TestCacheStateCurrencyContract pins the contract that the Bob status bar (feat(bob-statusbar): show Bob's savings in Bobcoins, not dollars #1124) reads: currency at the top level, "USD" (never empty) and "mixed" in lower case.
  • Not verified: the dashboard in a real browser (the icon, the note, the layout).

Known failure, not from this change

TestRateFillTableAndPrice (internal/modelinfo) fails on this Mac on the base branch too, with and without -race: a float rounding difference (0.00042 against 0.00042000000000000007). It fails the same way without this PR. It likely needs its own issue.

Technical notes

  • Money routes left out on purpose: /api/requests/{id} (each row has its own currency), the keep-alive ledger, the transcript and archive reads (no money), /api/me/* (subscription figures, always API dollars), and /api/events (a stream; its rows carry currency).
  • The 27 golden test replies each gain only the currency key. They were edited by a script, not regenerated, to keep their floats stable across machines.

Bob's prices.yaml held dollar estimates, with output at 5x input. Our
own measurement says Bob charges 2.0 Bobcoins per million tokens for
input and output alike: IBM's per-call credits fit 2.0 x (prompt +
completion) / 1e6 on 20 calls, with 0.0000% error. Bob users see
Bobcoins, not dollars.

- prices.yaml: 2.0 per million for in, out, cache read and cache write,
  for every tier. The file says its unit is Bobcoins. The tiers were not
  measured apart, so all have the same rate.
- The test checks 2.0 per million and output = input for every tier.
- README and the preset-picker and status skills: Bob's cost figures
  are Bobcoins, even where the dashboard still shows a $ sign.

The repo owner decided on 2026-11-12: Bobcoins only, no dollar
conversion, and the rate may be public.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
The README's dashboard paragraph still said Bob is priced in estimated
dollar rates. It now says Bobcoins, and that the dashboard and the
status bar still show a $ sign. The status skill names the status bar
too. The prices.yaml header no longer says no gate changes: the output
rate makes CG's own model calls look cheaper to extract_llm's gate. The
test's doc comment is back on the test.

Both round-1 reviewers of #1118 raised the README paragraph.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
Raised by both round-2 reviewers of #1118. No text change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
A file-level key `currency` names the unit of every rate in the file.
Absent or empty means USD. Each entry's Price carries it (Price.Currency,
not on the wire), and Price.Unit() reads it, USD when empty. The public
map and the built-in table stay USD.

A value that is not 1 to 16 ASCII letters is a load error: the name is
shown on the dashboard, so a typo or markup must not reach the screen.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
prices.yaml now says `currency: Bobcoins`, so every cost the proxy
computes from it carries that unit, and the dashboard shows Bobcoins.
The test checks every Bob tier.

A proxy older than the currency key refuses the file and does not
start. So bob-ultrahigh now needs context-guru-proxy v0.7.4 or newer
(was v0.7.2). The README and the skills say so.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
Each request row stores the unit of the price that costed it: a new
column `currency`, default 'USD', added as an additive column (no
schema version change). An unpriced row keeps the default.

Every money reply also says `currency` at its top level: the one unit
of the priced rows in its filter, "USD" when there are none, or
"mixed" when there is more than one. One wrapper does it for the
routes in currencyRoutes, with one DISTINCT query, cached per view for
the replies' 30 s TTL (the query takes about 0.2 s on 200,000 rows).
The *_usd field names do not change. The golden replies gain the key.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
usd() reads a page-wide unit, set from the API's `currency`:
- USD: exactly the old output (pinned by moneyunit.test.mjs).
- another unit: "1.75 Bobcoins" (2 decimals, 4 below 0.01), with
  lucide's coins icon on the tiles, built as SVG nodes.
- mixed: money figures show "—", and one note says why.
A unit name that is not 1 to 16 letters reads as mixed. The 230 call
sites do not change. Two column heads, the campaign heads and the
saving chart's title follow the unit.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
- reference and prices.example.yaml: the `currency` key, its rule
  (1 to 16 letters) and that it needs v0.7.4.
- dashboard: every *_usd field is in the row's currency; money
  replies say `currency`, or "mixed".
- data dependence: the dashboard row keeps a unit name, which is
  configuration, not user data; Bob's price file holds its unit.
  docs/data-dependence.md rebuilt with gen-datadep.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
"mixed" is the dashboard's word for a view in more than one unit, and
such a view hides every money figure. A price file that named it as its
unit would hide money everywhere, so it is a load error, in any case.

The view-unit query also passes the accounting value as a parameter.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm 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 @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 7651930943fd blocking

Verdict: blocking

The server side is sound. Two UI paths do not follow the unit: the Cache detail (KV-cache) tab, and the net-saving chart in a mixed view.

Findings

  1. dash/ui/kvcache.js:385 — the Cache detail tab never reads currency, so it shows Bobcoins with a $ sign

    • What fails: kvFetch calls fetch directly and returns res.json(). It does not go through api(), so applyMoneyUnit never runs. refresh() (app.js:5279) runs only the current tab's loader. So:
      • A Bob-only proxy, page opened at #kvcache: moneyUnit stays at its default 'USD'. usd(c.cost_usd) (kvcache.js:618, and :221, :236, :242, :261, :643) shows "$1.75" for 1.75 Bobcoins.
      • A mixed proxy (Bob and Claude), page opened at #kvcache: the tab shows the sum of Bobcoins and dollars with a $ sign. This is the result the PR wants to prevent.
      • From another tab: the KV tab keeps the unit of the last tab. dash/currency.go:229-230 names this exact problem ("a tab that read none of these would keep the unit of the page before it").
    • Proof: the server adds currency to /api/kvcache, /api/kvcache/rows, /api/kvcache/simulate and /api/kvcache/pricing (currency.go:236-237), and TestEveryMoneyRouteSaysTheUnit checks that. No UI code reads it on this path. grep -n applyMoneyUnit dash/ui/*.js finds only app.js.
    • Fix: in kvFetch, read the body and call applyMoneyUnit(body.currency) when the key is there, as api() does. Better: move that step into one helper that both use. Add a test that pins it, for example a node test that cuts kvFetch and checks it sets the unit.
  2. dash/ui/charts.js:97 — in a mixed view, the net-saving chart still draws the sum of two units and says "in dollars"

    • What fails: a view with Bob and Claude rows has currency: mixed. netSaving still adds baseline_cost_usd - cost_usd - cg_llm_cost_usd across the buckets, so it adds Bobcoins to dollars. It draws that line and area. Its colour (good or bad) comes from the sign of that sum. moneyWord() returns 'dollars' for mixed (app.js:125), so the frame's label says "Cumulative net saving over time, in dollars". Only the axis and end labels go to "—".
    • Proof: charts.js:90-108. app.js:125 moneyWord() { return moneyUnit === 'USD' || moneyUnit === 'mixed' ? 'dollars' : moneyUnit; }. The PR description says a mixed view "shows '—' for money".
    • Fix: when moneyUnit === 'mixed', show an empty state (for example "Costs are in more than one unit") in place of the chart. Check the other money charts that columns() draws from *_usd keys for the same case.

Non-blocking

  • dash/reprice.go:106 — applyReprice does not write currency. priceCost sets e.Currency, but the UPDATE sets only the cost columns. The row keeps USD. In the proxy this path cannot get a Bob row today: MODEL_PRICES loads at start, before any traffic (proxyapp/main_run.go:1574), so a Bob tier is priced at write time. A library host with a resolver that loads a non-USD table late would store Bobcoin costs as USD. Fix: add currency = ? to the UPDATE, and a test.
  • /api/adapt/compaction, /api/adapt/settings, /api/adapt/tools carry money (usd, usd_low, ... in adapttools.go:64-69). They are not in currencyRoutes, and not in the PR's "left out on purpose" list. docs/dashboard.md says "Every money reply ... also says currency". Add them, or name them in the doc as left out.
  • /api/requests is not cached, so a new row shows at once, but its unit is cached for 30 s. On a new proxy the first read stores USD. For 30 s after the first Bob row, the list says USD. Each row has its own currency, so the impact is small.
  • In a mixed view, the Requests table hides every row's cost. Each row has one known unit (currency on the row). The table could show each row in its own unit. This is a design choice; I note it only.
  • Live rows from /api/events render with the page unit. A Claude row that lands on a Bob-only page shows "Bobcoins" until the next refresh.
  • The mixed note stays visible on a tab that reads no money route (for example Settings), until a money reply resets it.
  • TestEveryMoneyRouteSaysTheUnit does not list /api/kvcache/suggest/holdout, which is in currencyRoutes.
  • DB.Currency scans the whole window when there is one unit (DISTINCT with LIMIT 2 stops only at the second unit). The PR measures 0.2 s on 200,000 rows. Each /api/requests page has a new query string (before), so each page pays this once.
  • bob-plugin/context-guru/README.md:24 is one very long line; the other lines wrap at about 100 characters.

What I checked

  • Every changed line of the diff, except the 27 golden files, where I read two (components.json, series_day.json); each adds only currency.
  • internal/modelinfo: currency parses with KnownFields(true), so v0.7.3 refuses the key, and the plugin minimum of v0.7.4 is right (git describe: v0.7.3-9). Price.Resolved copies the struct, so Currency survives the table lookup. Zero() does not compare the new field. No code compares Price with ==.
  • priceCost is the one place that sets AccountingComplete at write time, and it sets Currency. Both Price and PriceMode, and the ping path (main_run.go:1117), go through it.
  • withCurrency: wraps inside cachedRoute, so a cached body keeps its unit. capture copies headers; no dash handler sets Content-Length. /api/events (SSE) is not wrapped. No money route already has a top-level currency key, and no reply embeds Event. addCurrency handles {}.
  • cacheKey has no path, but every route takes its filter from the same scope, so sharing the unit across routes is correct.
  • DB.Currency uses Filter.where(), so it excludes pings and follows tenant, agent, session and time filters.
  • UI: el() skips a null icon and still turns a number into text, so tile() keeps its output. $$ takes a root. setMoneyUnit refuses a non-letter name. campaigns.js and insights.js use api(), so they read the unit.
  • Data dependence: both row files changed, and the generated page matches them word for word. No Kind or level changed.
  • The behavior-change block at the top of the PR names who, old, new, the minimum release and how to turn it off, with the owner's approval.
  • I did not run Go or node tests (not approved, and Go is not installed).

@vz-ibm vz-ibm 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 @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 7651930943fd blocking

Verdict: blocking

Findings

  1. dash/reprice.go:109 — a row that the late-price pass prices keeps currency = 'USD', also when its cost is in Bobcoins
    • What fails: a Bob request on bob-ultrahigh arrives with incomplete usage (usageOK=false, for example a cut stream) but with some token counts. PriceMode(price, false) makes it partial at $0, and priceCost returns before it sets e.Currency (dash/event.go:939-946). insertBatch stores rowCurrency("") = USD. noteUnpriced queues the row (partial, cost 0, tokens > 0). On the next pass, repricePass calls e.priceCost(p, true) with Bob's table price, so the cost is now Bobcoins and the row is complete. applyReprice writes cost_usd, baseline_cost_usd, cache_saved_usd, billed_token_factor and token_accounting, but not currency. The row is now a complete Bobcoins cost marked USD.
    • Result: DB.Currency for the Bob view finds {Bobcoins, USD} and says mixed. One such request hides every money figure on the Bob view for its whole window. It also adds Bobcoins to tenant_spend as if they were dollars. This is the one write path for token_accounting = 'complete' that the PR did not change (grep "UPDATE requests SET" dash/*.go: only reprice.go:109 sets cost and accounting).
    • Proof: dash/reprice.go:77 (priceCost(p, true) sets e.Currency = p.Unit() on the copy), dash/reprice.go:109-113 (the UPDATE has no currency). The copy in noteUnpriced (reprice.go:31-33) starts with an empty Currency, so the value from priceCost is the only correct one.
    • Fix: add currency = ? to the UPDATE with rowCurrency(e.Currency). Add a test: queue an unpriced row, run repricePass with a Bobcoins price, then assert that Requests gives Currency == "Bobcoins" and that /api/stats says Bobcoins, not mixed.

Non-blocking

  • Upgrade transition. Rows that bob-ultrahigh priced on v0.7.3 (its prices.yaml then had 3.00/15.00 dollar rates) get the new column's default, USD. New Bob rows are Bobcoins. A Bob view whose range covers the upgrade says mixed and shows no money until the old rows leave the range. This is honest, but a Bob user will see it at once. One line in the Bob README or the PR's behavior note would help. The schema comment "USD on every earlier row, which is true" (dash/schema.go:954-955) is also false for any row that #1118's Bobcoins file priced before this release.
  • Stale body with a fresh unit. dash/api.go:831 says "Inside the cache, so a cached body carries the unit it was computed with". That is true only for cachedRoutes. /api/stats, /api/components, /api/insights, /api/spend/explain, /api/tools and /api/toolfilter have their own stale-while-revalidate caches inside the handler, so withCurrency puts a unit from at most 30 s ago on a body up to 10 min old. Most changes go to mixed, which hides money, so the risk is small. Correct the comment, or name this case.
  • README claim ahead of #1124. bob-plugin/context-guru/README.md:133-134 says the Bob status bar shows Bobcoins with a proxy that sends currency. In this tree, bob-plugin/statusbar/src/model.ts:102 still prints $${usd.toFixed(2)} and does not read currency. The status skill still says "even where a $ sign shows", which is correct. Make the README match until #1124 merges.
  • KV-cache labels still say dollars. dash/ui/kvcache.js:784 (' $/MTok' column heads) and dash/ui/kvcache.js:462 ("Rates in USD per million tokens") do not follow the unit. With Bob's file, /api/kvcache/pricing gives Bobcoin rates under a $/MTok head.
  • Request drawer. /api/requests/{id} has the row's own currency, but the drawer formats it with the page unit. In a mixed view, a single row's cost shows — although its unit is known. Each row in /api/requests has the same problem. You could format a row with its own unit.
  • Case of the unit. The server accepts usd (the regexp allows any case). The UI then treats it as a unit that is not USD and shows 1.75 usd. You could normalize usd to USD in ParseTable, or refuse it.
  • withCurrency calls a.scope(r) again, so a hosted deployment runs auth twice for each money request. This is small, but you can avoid it.
  • /stats, the cg_*_usd metrics and tenant_spend add Bobcoins and dollars into one number on a mixed proxy. This was already true before (since #1118) and the docs now say so. No change is needed in this PR.

What I checked

  • CLAUDE.md, the full diff (32 non-golden files, 1105 lines), and the 27 golden files. The golden files only get "currency": "USD" (24 + 3 lines) and 2 comma fixes.
  • internal/modelinfo: currency key, KnownFields(true) (so an older proxy refuses the key, and the v0.7.4 minimum is necessary), the regexp, the reserved mixed in any case, and Price.Unit(). v0.7.3 is the newest tag, so v0.7.4 is the next release.
  • Each write path for cost: priceCost (used by Price, PriceMode, and the ping row in proxyapp/main_run.go:1117-1118), the insert column and placeholder count (store.go: 1 column, 1 ?, 1 arg), scanRequest and requestCols, the additive column, and applyReprice (finding 1).
  • DB.Currency: Filter.where() uses only the r. alias and EXISTS subqueries, so every filter works in this query. The query counts only complete rows, and it excludes keep-alive pings the same way as the views.
  • withCurrency and addCurrency: a non-200 or non-object body passes unchanged, {} gives no extra comma, the headers are copied, and no money route streams or sets Content-Length (SSE is /api/events, which is not wrapped). The order in Mount (currency inside cachedRoute) and the 30 s currencyCache keyed by principal and query.
  • UI: usd() gives the same USD output (the 9 values in the test), setMoneyUnit refuses a name that is not letters, the note and .money-sym heads, moneyIcon adds a separate SVG node (no markup from the unit name), tile() with el() children, subLabels with cloned heads, charts.js and campaigns.js. Every money api() call uses the page filter, so concurrent replies do not set different units. I found no api() call scoped to one session.
  • Tests: the Go tests for the unit on rows, the routes, the filter and the cachestate contract; moneyunit.test.mjs with its Go wrapper; the estrange.test.mjs fix; the Python version tests (v0.7.3 refused, v0.7.4 accepted).
  • Data dependence: the 2 row files changed, and the generated page rows match them word for word. No Kind or level changed. The behavior change is named at the top of the PR, with the owner's approval.
  • I did not run Go or node tests. Live tests are not approved.

The late-price pass (#920) wrote the cost and `complete` but not the
currency, so a Bob row priced late kept the USD default. One such row
made the whole Bob view say "mixed" and hid every money figure.
applyReprice now writes `currency` too. No other path writes a cost.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
kvFetch read its money routes with its own fetch and never applied
`currency`, so a Bob proxy showed Bobcoins with a `$` sign there. One
helper, readMoneyUnit, now applies the unit for api() and kvFetch.
No other direct fetch reads a money route with the page's filter.
(The hook also removed one trailing space in kvcache.js.)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
In a view with more than one unit, the net-saving chart still drew
Bobcoins and dollars added into one line, titled "in dollars". Every
money chart (net saving, the saving bars, the daily columns, the
keep-alive cost line) now shows an empty state with the reason. A
subscription's keep-alive line is in tokens and is still drawn.
moneyWord() says "mixed units", not "dollars", for a mixed view.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
/api/adapt/compaction, /settings and /tools carry money (usd,
usd_low), so they join currencyRoutes. Two comments now say what is
true: a handler with its own cache can get a unit up to 30 s old on an
older body, and a row a Bobcoins file costed before the column existed
reads USD.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
Rows written before v0.7.4 are stored as dollars, so a Bob dashboard
range that covers the upgrade reads as more than one unit. The README
says so. The Cache detail rate heads also follow the unit now (they
said `$/MTok` for Bobcoin rates).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
The dashboard shows dollars only for "USD". A file that wrote usd or
Usd would have shown "1.75 usd". The loader now stores the one
spelling.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. All 3 findings are fixed, test-first, in f674a29..cc3f20e:

  1. A row priced late keeps USD (reviewer 1): fixed (f674a29). applyReprice writes currency = rowCurrency(e.Currency). No other write path sets a cost or complete (setBypassTokens only moves missing to partial; there is no upsert). New test TestRepricedRowTakesTheCurrencyOfItsPrice: red first (repriced row currency = "USD", want Bobcoins; /api/stats currency = mixed).
  2. The Cache detail tab never reads the unit (reviewer 2): fixed (762b27c). One helper, readMoneyUnit(body), now applies the unit for both api() and kvFetch. No other fetch( reads a money route (/api/requests?limit=1 drops a filter on purpose, so it must not set the page unit). New test dash/kvfetch.test.mjs: red first.
  3. A mixed view still charts a sum of 2 units (reviewer 2): fixed (a1674a3). noMoneyChart(host) shows "Costs are in more than one unit, so money is not charted. Token figures are correct." for every chart drawn from *_usd keys: netSaving, savingsBars, dailyColumns and the keep-alive cost line. moneyWord() says "mixed units". New test dash/mixedcharts.test.mjs: red first. TestMoneyUnitFormatting now runs all 3 node files, so CI runs them.

Also fixed:

  • /api/adapt/compaction, /settings and /tools now say their unit (dbd9bcc). The route-walk test was red first.
  • The Cache detail rate heads use the unit (/MTok).
  • The comments in dash/api.go and dash/schema.go are exact.
  • The Bob README says a time range across the upgrade shows no money, because older rows are stored as dollars (540f0e6).
  • A price file's usd in any case is stored as USD (cc3f20e), so usd cannot show "1.75 usd". Test red first.

Left as is, with why:

  • The KV-cache note "Rates in USD per million tokens" is built when the script loads, before any unit is known.
  • Request rows and the drawer use the page unit; one unit per row is a later design choice.
  • withCurrency runs the scope check twice per money request: a small cost.
  • /stats, cg_*_usd and tenant_spend add the 2 units on a mixed proxy; one Bob proxy per install is the normal case.
  • /api/requests: its unit is cached for 30 s, its rows are not.

Checks: go build ./..., go vet OK; go test ./dash/... ./components/all/ OK; ./bob-plugin/ OK; node UI tests 49 pass. ./internal/modelinfo/: only the known TestRateFillTableAndPrice failure (#1128).

@vz-ibm vz-ibm 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 @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 cc3f20e1940f approve

Verdict: approve

All 3 round-1 findings (2 from me, 1 from reviewer 1) are fixed, each with a test. The 6 new commits add no new defect.

Findings

None.

Earlier findings

  • Reviewer 2, finding 1 (the Cache detail tab ignores the unit): fixed in 762b27c. kvFetch now returns readMoneyUnit(await res.json()) (kvcache.js:400), the same helper that api() uses (app.js:402-412). dash/kvfetch.test.mjs cuts both functions and checks that the stub applyMoneyUnit gets Bobcoins. The /MTok rate heads now use moneySym() (kvcache.js:784).
  • Reviewer 2, finding 2 (a mixed view charts a sum of 2 units): fixed in a1674a3. noMoneyChart(host) draws the empty state when the unit is mixed. netSaving, savingsBars, dailyColumns and the keep-alive cost line call it first. emptyState clears the host (app.js:427), so no old chart stays. moneyWord() says "mixed units" for a mixed view. I checked the other charts: CGCharts.columns (app.js:2078, :2089), cacheShare, trend and the other lineChart calls draw tokens, counts, percentages or ms, not money. dash/mixedcharts.test.mjs pins each money chart.
  • Reviewer 1, finding 1 (a repriced row keeps USD): fixed in f674a29. The UPDATE in reprice.go:109-114 sets currency = rowCurrency(e.Currency). TestRepricedRowTakesTheCurrencyOfItsPrice uses the existing lateLoader and partialEvent helpers (reprice_test.go:16-45). It checks the row's unit and /api/stats?agent=bob.

Non-blocking

  • The round-1 point from reviewer 1 about bob-plugin/context-guru/README.md:133-134 is not answered. The README says "The Bob status bar shows Bobcoins with a proxy that sends currency". In this tree, bob-plugin/statusbar/src/model.ts:102 still prints $${usd.toFixed(2)}. That is true only after #1124 merges. Say "after #1124", or merge #1124 first.
  • kvcache.js:462 still says "Rates in USD per million tokens" while the heads below it now say "Bobcoins/MTok". The author's reason (the note is built before any unit is known) is correct. The text is still wrong on a Bob page. A .money-sym span, refreshed by applyMoneyUnit, would fix it at low cost.
  • TestEveryMoneyRouteSaysTheUnit adds /api/adapt/tools and /api/adapt/settings, but not /api/adapt/compaction, which dbd9bcc also adds to currencyRoutes.
  • The author's other "left as is" reasons (one unit per page for rows and the drawer, the second scope check, /stats sums, the 30 s unit cache on /api/requests) are design choices. I accept them.
  • The extra top-level currency key on /api/adapt/settings does not break its readers: costly.py:188 reads named keys only.

What I checked

  • Last review: round 1, 7651930, 2026-11-12T09:47:16Z
  • New commits read: 6
    • f674a29 fix(dash): a row priced late keeps the unit of its price
    • 762b27c fix(dash-ui): the Cache detail tab reads the reply's unit
    • a1674a3 fix(dash-ui): a mixed view charts no money
    • dbd9bcc fix(dash): the adapt replies say their unit too
    • 540f0e6 docs(bob-plugin): say a range across the upgrade shows no money
    • cc3f20e fix(modelinfo): read a price file's usd in any case as USD
  • 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 (09:47:35Z). I checked its finding 1 (above) and its non-blocking points: the upgrade note (now in README and in the schema.go comment), the stale-body comment (api.go:831-833 now names it), the KV heads (fixed), the usd case (fixed in cc3f20e), the README claim ahead of #1124 (not answered, see Non-blocking).
    • The author's round-1 reply (10:10:23Z). I checked each "fixed" claim against the diff, and each "left as is" reason (see Earlier findings and Non-blocking).
  • git diff 76519309..HEAD: 427 lines outside the golden files, all read. Code around each change read: emptyState, the reprice test helpers, the chart call sites in app.js, the costly.py reader.
  • cc3f20e: strings.EqualFold(f.Currency, USD) runs after the regexp and before the mixed check, so usd and Usd become USD. The new test covers 3 spellings.
  • Data dependence: no new feature and no new stored data in these commits. The row files and the generated page are unchanged since round 1.
  • I did not run Go or node tests. Live tests are not approved.

@vz-ibm vz-ibm 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 @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 cc3f20e1940f approve

Verdict: approve

All 3 round-1 findings are fixed, and each fix has a test. The 6 new commits add no new defect.

Earlier findings

  • Reviewer 1, finding 1 (a row priced late keeps USD): fixed in f674a29. applyReprice now writes currency = rowCurrency(e.Currency) (dash/reprice.go:110-114). TestRepricedRowTakesTheCurrencyOfItsPrice seeds one Bob row priced at write time and one partial row, loads the price late, and then checks that the late row is Bobcoins and that /api/stats?agent=bob says Bobcoins. Without the fix, the view would say mixed, so the test can fail. partialEvent and lateLoader already exist in dash/reprice_test.go:16-33. lateLoader prices any model, so the row's model name does not matter.
  • Reviewer 2, finding 1 (the Cache detail tab does not read currency): fixed in 762b27c. readMoneyUnit (dash/ui/app.js:299) is now the one step for api() and kvFetch (kvcache.js:400). kvcache.js loads after app.js, so the global is defined. dash/kvfetch.test.mjs pins it. The one other direct fetch of a money route (suggestDrop, /api/requests?limit=1 with one filter left out) does not set the unit on purpose. That is correct, because its filter is not the page's filter.
  • Reviewer 2, finding 2 (a mixed view still charts a sum of 2 units): fixed in a1674a3. noMoneyChart calls emptyState, which clears the host (app.js:427), so a refresh does not stack messages. It now guards netSaving, savingsBars, dailyColumns and the keep-alive cost line, and a subscription line (in tokens) is still drawn. I checked every other chart call in the UI (grep for lineChart, CGCharts.*, columns and echarts.init, 14 hits). The token, volume, cache-share, latency, expiry, KV ladder and feedback charts draw no money. The Insights bars plot usage, and their totals go through usd(), which gives — in a mixed view. moneyWord() now says "mixed units".
  • Non-blocking items from round 1:
    • Fixed: the adapt routes now carry the unit. The kvcache $/MTok heads and the comments in dash/api.go and dash/schema.go are correct now. The README describes the upgrade range. usd in any case is stored as USD.
    • Left as is, with a reason: the static "Rates in USD" note, the per-row unit in the drawer and the Requests table, the double scope check, and the mixed /stats and metrics totals. I accept these reasons. Each item is small and none is a defect of this PR.

Non-blocking

  • TestEveryMoneyRouteSaysTheUnit now lists /api/adapt/tools and /api/adapt/settings but not /api/adapt/compaction, which dbd9bcc also added to currencyRoutes. The map entry is correct (dash/adaptcompaction.go:2037 registers that pattern). Only its test is missing. That route has a 5-minute timeout, so you may have left it out on purpose. If so, a comment would say why.
  • In a mixed view, moneySym() returns $, so the kvcache rate heads read $/MTok above rates that can be Bobcoins. This happens only when one deployment has both price units.
  • README line 168 (`currency: Bobcoins`, so the proxy sends…) is still one long line. Reviewer 2 noted this in round 1.

What I checked

  • Last review: round 1, 7651930, 2026-11-12T09:47:35Z
  • New commits read: 6
    • f674a29 fix(dash): a row priced late keeps the unit of its price
    • 762b27c fix(dash-ui): the Cache detail tab reads the reply's unit
    • a1674a3 fix(dash-ui): a mixed view charts no money
    • dbd9bcc fix(dash): the adapt replies say their unit too
    • 540f0e6 docs(bob-plugin): say a range across the upgrade shows no money
    • cc3f20e fix(modelinfo): read a price file's usd in any case as USD
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-1 review (09:47:16Z). I checked both of its findings against the new code. Both are fixed, as described above. I also checked its non-blocking list.
    • The author's reply comment (10:10:23Z). I checked each "fixed" claim against the diff, and each "left as is" reason. I accept all of them.
  • The full diff 7651930943fd..cc3f20e1 (427 lines), with the code around each change: applyReprice and the reprice test helpers, emptyState, the chart call sites, the adapt route registrations, the order of the regexp, the USD case fold and the mixed check in ParseTable, and the order in which the UI scripts load.
  • I did not run Go or node tests. Live tests are not approved.

@vz-ibm

vz-ibm commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Round 2: both reviewers approve.

The review budget (2 rounds) is used. Ready to merge after #1124 and #1118.

@amiddavid
amiddavid changed the base branch from fix/bob-prices-bobcoins to main November 17, 2026 11:29
Main now holds #1118 squashed. Hand-resolved files:

- bob-plugin/context-guru/README.md, skills/preset-picker/SKILL.md,
  skills/status/SKILL.md: kept this PR's wording (the dashboard now
  says Bobcoins, v0.7.4 minimum).
- bob-plugin/context-guru/prices.yaml: kept the comment about the
  `currency` key and the `currency: Bobcoins` line.
- bob-plugin/prices_test.go: kept the Unit() == Bobcoins check.
- bob-plugin/context-guru/scripts/test_bob_control.py: tests added on
  main named v0.7.2 as the minimum; now v0.7.4.
- dash/schema.go: kept the `currency` column and main's backend,
  client_compaction and acc_fallback columns and backfill.
- dash/store.go: INSERT has 108 columns and 111 placeholders in the
  literal text, as on main plus one for `currency`; args add
  rowCurrency after RestoredTokens.
- dash/query.go: `r.currency` after restored_tokens, and `&e.Currency`
  in the same place in scanRequest.
- dash/reprice.go: main's cg_llm_cost_usd update plus `currency = ?`.
- dash/ui/app.js: took main's shell, then moved this PR's changes to
  app.js (usd, unit helpers, api), tabs/overview.js (tile),
  tabs/usage.js (dailyColumns), tabs/sessions.js (subLabels) and
  tabs/keepalive.js (keep-alive chart).
- dash/mixedcharts.test.mjs: reads the moved functions from their new
  files.
- docs/data-dependence/features/{bob-plugin,dashboard-database}.md:
  main's text plus this PR's sentence about the unit.
- docs/data-dependence.md: rebuilt by hand for those two rows (Go is
  not installed here).

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Main removed the local waitFor helper in #1182. dash/currency_test.go
still called it, so go vet failed in CI (build-test, record).

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.326 offload-review skill, @amiddavid's session fresh 1 of 2 3 of 3 051976da62ba approve

Verdict: approve

The merge of main keeps every change of this PR, and the test fix is correct. I found no new defect.

Findings

None.

Earlier findings

  • Reviewer 1, round 1, finding 1 (a repriced row keeps USD): still fixed. Main changed the UPDATE in #1172 (cg_llm_cost_usd = cg_llm_cost_usd + ?). The merge adds currency = ? after it, and the argument rowCurrency(e.Currency) is in the same place (dash/reprice.go:123-126).
  • Reviewer 2, round 1, finding 1 (the Cache detail tab ignores the unit): still fixed. readMoneyUnit is in app.js, and kvcache.js is unchanged by the merge.
  • Reviewer 2, round 1, finding 2 (a mixed view charts money): still fixed. #1151 moved dailyColumns to tabs/usage.js and the keep-alive cost line to tabs/keepalive.js. The noMoneyChart guards moved with them. dash/mixedcharts.test.mjs now reads those two files.
  • README claim ahead of #1124 (round 1 and 2 non-blocking): resolved. #1124 is on main, and bob-plugin/statusbar/src/model.ts:109-110 now reads currency. The merge order in the author's comment of 2026-11-12T10:12:45Z (#1124, then #1118, then this PR) is met.

Non-blocking

  • bob-plugin/context-guru/README.md:175 is still one long line (about 150 characters). Both reviewers noted it before.
  • The small follow-ups the author listed on 2026-11-12 are still open: a route-walk test row for /api/adapt/compaction, $/MTok heads in a mixed view, and the static "Rates in USD" note in kvcache.js.

What I checked

  • Last review: round 2, cc3f20e, 2026-11-12T10:12:11Z
  • New commits read: 2 on the PR's first-parent line, plus 46 main commits that the merge brings in
    • 16a37bf chore: merge main into feat/price-currency
    • 051976d fix(dash): use testutil.WaitFor in the currency test
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • The author's comment of 2026-11-12T10:12:45Z (merge order and follow-ups). I checked that #1124 and #1118 are on main, and that the listed follow-ups are still non-blocking.
    • No other review or comment is newer than my last review.
  • Merge check. I compared the PR's net change at cc3f20e (against c4b284e) with its net change now (against d008870), file by file. 19 files differ:
    • bob-plugin files: the difference is #1118 and #1124, which are now on main. What is left is this PR's own text: the currency: Bobcoins key, the v0.7.4 minimum, and the README and skill wording.
    • test_bob_control.py: the tests main added now say v0.7.4. The v0.7.3 refusal test and the v0.7.4 accept tests are consistent with PRESET_MINIMUM_RELEASE.
    • dash/ui: the sorted set of added and removed lines in app.js plus tabs/*.js now is the same as the set in app.js at cc3f20e (diff exit 0). No change was lost in the move to the tab files.
    • dash/store.go: a script counts 111 columns (without the token columns) and 111 ? in the literal text. The argument rowCurrency(e.Currency) follows RestoredTokens, as the column follows restored_tokens.
    • dash/query.go: r.currency and &e.Currency are both after restored_tokens and before the token columns.
    • dash/schema.go: the column and the additive column are as before, beside main's new columns.
    • Golden files: all are valid JSON. Each adds only "currency": "USD" (27 lines) and 3 comma fixes.
    • docs/data-dependence.md: the two rows match their row files word for word (grep -F finds each body one time).
  • 051976d: internal/testutil.WaitFor(t testing.TB, what string, cond func() bool) has the same signature as the removed helper. No waitFor( call is left in dash/*.go.
  • Main's new code since c4b284e: no new /api/ route, so currencyRoutes still covers every money route. #1173's Overview line for requests that could not be priced uses usd(), so it follows the unit.
  • I did not run Go or node tests. Live tests are not approved.

@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.326 offload-review skill, @amiddavid's session fresh 2 of 2 3 of 3 051976da62ba approve

Verdict: approve

The 2 new commits are a merge of main and a one-line test fix. The merge keeps every change of the PR. I found no new defect. CI is green at this head.

Findings

None.

Earlier findings

  • Reviewer 2, round 1, finding 1 (the Cache detail tab ignores the unit): still fixed. kvFetch returns readMoneyUnit(await res.json()) (dash/ui/kvcache.js:400).
  • Reviewer 2, round 1, finding 2 (a mixed view charts a sum of 2 units): still fixed. After the split of app.js (#1151), the guards are in their new files: netSaving and savingsBars (charts.js), dailyColumns (tabs/usage.js:24), the keep-alive cost line (tabs/keepalive.js:726). dash/mixedcharts.test.mjs now reads tabs/usage.js and tabs/keepalive.js, so it still checks each guard.
  • Reviewer 1, round 1, finding 1 (a repriced row keeps USD): still fixed. The merged applyReprice keeps currency = ? beside the new cg_llm_cost_usd term from #1172 (dash/reprice.go:123-127). The argument order matches the columns.
  • Round 2 non-blocking, README line ahead of #1124: now true. #1124 is merged and in this head. bob-plugin/statusbar/src/model.ts:109-110 reads currency.
  • The other round-2 non-blocking items (no test row for /api/adapt/compaction, $/MTok in a mixed view, the static "Rates in USD" note, one long README line at bob-plugin/context-guru/README.md:175) are not changed. The author listed them as follow-ups. I accept that.

Non-blocking

  • proxyapp/main_run.go:1141-1157: a timed-out Bob ping row stores currency = USD with a Bobcoins cost. #1186 (now merged in) books a timed-out ping at its projected cost: ev.CostUSD = r.CostUSD with no tokens. So ev.Price(price, false) does not reach priceCost's e.Currency = p.Unit(), and insertBatch stores USD. The view's unit is correct: DB.Currency counts only complete rows and leaves out pings. Only the row's own currency field is wrong. Fix: set ev.Currency = price.Unit() when priced, in KeepAlivePing. This came with the merge, so a follow-up is enough.
  • bob-plugin/context-guru/skills/status/SKILL.md:36 still says "even where a $ sign shows". With #1124 merged, the status bar shows Bobcoins. The text is still safe advice.

What I checked

  • Last review: round 2, cc3f20e, 2026-11-12T10:11:56Z
  • New commits read: 2
    • 16a37bf chore: merge main into feat/price-currency (parents cc3f20e and d008870)
    • 051976d fix(dash): use testutil.WaitFor in the currency test
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-2 review (10:12:11Z). Its 3 non-blocking points are the same as mine. Nothing new to check.
    • The author's round-2 comment (10:12:45Z): merge #1124, then #1118, then this PR. Both are now in main and in this head. I checked the README line against the merged status bar (see above).
  • The merge: I compared every changed UI line of c4b284e2..cc3f20e1 with d008870e..HEAD. The 2 sets of +/- lines are the same, so no UI change was lost in the split into tabs/*.js. The 11 new top-level names (moneyUnit, setMoneyUnit, noMoneyChart, readMoneyUnit, ...) are declared once, in app.js, so TestDashboardScriptsDeclareEachTopLevelNameOnce holds. $$, svgEl and emptyState exist in app.js.
  • The merged Go code: requestCols and scanRequest put r.currency and &e.Currency at the same place. insertBatch has one more column, one more ? and one more argument, in the same order. The additive column, priceCost, withCurrency and currencyRoutes match round 2. No new UPDATE in main sets a cost or complete (setBypassTokens moves only missing to partial). Main added no new money route and no new money chart (grep for yFmt: usd and direct fetch( calls in dash/ui).
  • The rest of d008870e..HEAD outside dash/: bob-plugin, modelinfo, deploy and docs. The prices.yaml from #1118 keeps currency: Bobcoins. The two data-dependence rows and the generated page match word for word.
  • 051976d: testutil.WaitFor(t, what, cond) has the same signature as the removed local helper. No other waitFor( call or sleep is left in the new tests.
  • CI at this head: build-test, record, purego, build, analyze, CodeQL, trivy and DCO pass.
  • I did not run Go or node tests. Live tests are not approved.

@amiddavid
amiddavid merged commit cd90d55 into main Nov 17, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 17, 2026
amiddavid added a commit that referenced this pull request Nov 19, 2026
Plugin versions for v0.7.4:
- Claude Code plugin 0.7.3 -> 0.7.4 (#1096, #1135, #1174, #1177, #1199,
  #1216).
- Codex plugin 0.2.12 -> 0.2.13 (#1115, #1135).
- Pi package 0.1.1 -> 0.1.2 (#1113).
- Bob plugin 0.1.1 -> 0.1.2 (#1093, #1111, #1118, #1124, #1126, #1127).
  The owner's Bob hold (#1221) covers release tests only.
- OpenCode: PINNED_VERSION v0.7.3 -> v0.7.4 in opencode-plugin/index.js,
  its README, docs/how-to/install-opencode-plugin.md and 3 tests.

Behavior change: the version numbers; the OpenCode plugin's first start
downloads proxy v0.7.4. Release bumps are approved by the owner ("I
approve version bumps").

Data dependence: none.

Reviews: 2 offload review rounds (GLM): both approve at ab79001. After
it: 1422093, a merge of main with no hand resolution (remerge-diff 0;
approval-still-valid: SAME CHANGE).

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

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants