Skip to content

feat(dash): on a Claude subscription show saved tokens, with the 5-hour share as an estimate - #988

Merged
amiddavid merged 8 commits into
mainfrom
feat/dash-subscription
Nov 10, 2026
Merged

amiddavid merged 8 commits into
mainfrom
feat/dash-subscription

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #985. Part 2 of #998 for the dashboard. #991, #992 and #999 are in main.

Behavior change. Who: users on a Claude subscription who open the dashboard Overview. Old: every saving shows in dollars. New: every saving shows in tokens, by kind, with a dim estimate of the 5-hour limit share below the total. No dollars show on a subscription. How to turn it off: nothing to turn off. API-key, Bedrock and Vertex users, managers, and hosted users (#997) see no change. The owner decided this on #985 and #998.

Data dependence: metadata only (token counts by tier, the auth kind and the rate-limit numbers). The same at each storage level. docs/data-dependence.md has the row.

Summary

A subscription does not bill per token, so dollars mean little to that user. On a subscription the Overview now shows the total and each card in tokens, from the accountant's tier tokens in /api/stats (#999). The total reads, for example, saved 85.0k wr · 12.0k in · cost 40.0k rd. Below it, dim: ≈ 3% of the 5-hour limit (estimate at API-price weights).

What changed

  • One display rule for tokens (dash/ui/savings.js, shared with feat(plugin): status and insights savings show saved tokens on a subscription #989 and feat(mod): subscription band in tokens, this session only #981):
    • Only the tiers that are not 0, in the order wr (5-minute cache write), wr1h (1-hour cache write), rd (cache read), in (fresh input).
    • The caused tiers follow as cost. Tiers are never added into one number.
    • Functions: tierText, addTiers, tokenLine, hasTokens.
  • Zero or not measured: one rule (tokenFigure, returns {text, measured}), for every token figure:
  • The total: tokens.saved and tokens.caused (totalTokens).
  • Keep-alive pings on a line of their own (pingLine), under the total and on the Cache card: Keep-alive pings (not in the total): cost 900 wr · 410.0k rd. The words match feat(plugin): status and insights savings show saved tokens on a subscription #989. A ping is not agent traffic, so keepalive_ping_tokens is not in the total or in any card's cost. Every screen follows this rule: the band's lean read has no ping tokens.
  • The cards read tokens.by_feature (featureTokens):
    • Cache: "Keep-alive rescue" (keepalive), cachesplit and ttl, one row each, and the pings line. cachesplit stays one entry. With no rows, the list does not show.
    • Preset: every other entry (the preset's components and ended_change).
    • Tools and skills filter: toolfilter. Tool deferral: tooldefer.
    • The cards add up to the total, tier by tier.
  • No dollars on a subscription. The replay-cap note and the "estimated requests" note leave out their dollar figures. The cache card's "≈ tokens read instead of rewritten" (derived from dollars) does not show.
  • Not measured. When tokens_unmeasured_requests > 0, a note under the total says how many requests have no token figure.
  • When the token view starts (isSubscription): /api/me/limits says subscription: true, or a 5-hour window is open. Before, only an open window counted, so a subscription user idle for 5 hours saw dollars. The estimate still needs an open window.
  • The estimate: min(used% × saved_usd / cost_usd, 100 − used%) for the window, shown after $0.50 of spend and 2% used. It is for the whole account, so it is hidden while a page filter (a session, a time range, a model...) is on. The info text explains the cap, the "would have hit the 5-hour limit" line and the filter rule.
  • Managers keep dollars and show no estimate. The page does not ask them for the limits.
  • saved_unique and replay_tokens are no longer used for the subscription view.
  • docs/dashboard.md: new section "On a subscription, the Overview shows tokens".

How it was tested

  • node --test dash/savings.test.mjs (local): 21 pass, 0 fail. New tests:
    • the display rule: order, zero tiers left out, cost after, an empty flow gives '';
    • by_feature split into the cards; the cards add up to the total, tier by tier; the pings are on their own line and in no cost; a server with no tokens gives empty lines, not NaN;
    • subscription: true with a window that is over shows tokens and no estimate;
    • the capped note with no dollars.
  • TestOverviewSubscriptionHeadlineIsWired (Go) checks that app.js calls isSubscription, featureTokens and the token cards, reads tokens_unmeasured_requests, and draws the two pings lines.
  • CGO_ENABLED=1 go test -race -count=1 -timeout 30m ./dash/... on the eval box, on 407534d, in 8 foreground runs by first letter: 993 pass, 0 fail, 12 skip (all Test*). The skips are live, demo, node and browser tests.

Open questions

  1. Manual pings have no token figure, so they do not show on a subscription.
  2. The Cache strategy, Usage and Sessions tabs still show dollars. This PR changes the Overview only.

🤖 Generated with Claude Code

…ur share as an estimate

On a Claude subscription the Overview headline now shows saved tokens,
not dollars: `saved 1.2M rd / 85k wr`. A dim line below it shows
`≈ 3% of the 5-hour limit (estimate at API-price weights)`.

- The page reads GET /api/me/limits (#984). A live `five_hour` window
  turns on the token headline. `{}`, a failed call or a window that is
  over keeps the dollar view, unchanged.
- The estimate is used% x saved / spent for the 5-hour window, read from
  /api/stats?lean=1&since=<window start>. It shows only after $0.50 of
  spend and 2% used in the window.
- A manager's Overview spans other accounts, so it keeps the dollar view.
- The cards below the headline keep their dollar figures.

Data dependence: metadata only (token counts and limit numbers), the
same at each storage level.

Closes #985

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

Copy link
Copy Markdown
Collaborator Author

Eval box result: CGO_ENABLED=1 go test -race -count=1 -timeout 30m ./dash/... on commit e3c6dc5 passed (ok github.com/rossoctl/context-guru/dash 644.7s, rc=0).

  • The first run with the default 10-minute go test timeout failed on time only: the box was loaded (load average 6.6), and the package took 645 s. No test failed before the timeout.
  • node is not on the box, so TestSavingsPartsAddUp skips there. I ran node --test dash/savings.test.mjs locally: 13 pass, 0 fail.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 e3c6dc535102 blocking

Verdict: blocking

Findings

  1. dash/ui/savings.js:99 — the 5-hour estimate can show more than 100% of the limit, and more than the most that can be saved
    • What fails: a subscriber at ~60% of the 5-hour limit whose saving is ~2x their spend in the window sees ≈ 120% of the 5-hour limit (estimate at API-price weights). No user can save 120% of a limit. The line then reads as broken, not as an estimate.
    • Proof: fiveHourSavedPct returns (used * saved) / cost with no upper bound. Under the code's own assumption (limit usage tracks API-priced tokens), the without-context-guru usage is used * (cost + saved) / cost, so the points saved are used * saved / cost — the same formula, so it is right while the counterfactual stays under 100%. But the provider stops a user at 100% of the limit. So the points actually saved can never exceed 100 - used. Example: used = 60, cost = $10, saved = $20 → the function returns 120; the most savable is 40. The inputs are normal for this product: saved / cost is s / (1 - s), so a 67% saving share gives 2x, and the repo's own Overview quotes saving shares around and above that. The low end is guarded (cost < 0.5 || used < 2); the top end is not.
    • Fix: clamp the returned percent to 100 - used (the throttled counterfactual), or cap the display at 100 and say "more than the limit". Add a test for the case used * saved / cost > 100 - used.

Non-blocking

  • Merge order. ctl('/api/me/limits') has no route in this tree. The server half is PR #991, still open. Until it merges, the call 404s and the page keeps the dollar view — I traced the fail-open path (app.js:1892-1907, the catch leaves state.sub null). Merge #991 first, or say so in the PR.
  • The manager guard has no test. app.js:1896 throws for a manager so their Overview keeps the dollar view. The Go test checks wiring strings only; nothing covers this branch. The mjs tests cover subscriptionHeadline, not this.
  • A stale loadOverviewLimits can overwrite a newer one. Two refreshes in a row: the slower first call lands last and sets state.sub from older data. keepAliveLedger guards this with state.kaLedgerKey; this loader has no such guard. The data is at most one refresh stale, so the effect is small.
  • An unpriced deployment never shows the token headline. renderSavedLedger gates the hero on priced (app.js:1713,1742). Token counts need no prices, but a subscription user with no price table sees "Nothing priced yet in this period." This matches the rest of the page, so I leave it as a note.

What I checked

  • Read the full diff (6 files) and the code around each change: renderSavedLedger, loadOverview, loadOverviewLimits, savings.js, both test files, style.css, the data-dependence row.
  • Verified the /api/me/limits contract against PR #991's dash/limits.go (read from the local feat/limit-headers branch): field names and units match the mocked shape (utilization 0..1, reset_s unix seconds). Confirmed the route does not exist in this tree, and that the 404 fails open to the dollar view.
  • Verified the stats fields the code reads exist: replay_tokens and saved_unique in the full Overview (dash/overview.go:103,101); cost_usd and total_saved_usd in the lean window read (dash/overview_lean.go:68,77). Checked the lean branch's precondition (since != 0, dash/api.go:1354) and that since is epoch ms (filterFrom), which fiveHourStartMs returns.
  • Checked the first-paint path: the lean read omits replay_tokens, but the hero body only draws when ready = priced && !partial, so no "saved 0 rd" flash.
  • Checked the manager-guard timing: probeAccount() resolves before applyURL() starts the loaders, so account.tenant.role is known when loadOverviewLimits runs.
  • Checked probeAccount/gate interplay, script load order (savings.js before app.js), compact formatting against the test's fmt, stripComments/readUI helpers, CSS specificity for .ov-hero-v.ov-hero-sub, and the mjs test arithmetic by hand (all assertions consistent with the code).
  • Checked the data-dependence row: present, metadata only, decided-by filled.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 e3c6dc535102 blocking

Verdict: blocking

Findings

  1. dash/ui/savings.js:99 — the 5-hour estimate can show more than 100% of the limit, in context-guru's own normal regime
    • What fails: a window where context-guru saves more than it costs (its normal result), with the limit partly used, renders ≈ 135% of the 5-hour limit. A share of a limit cannot be above 100%. The reader sees an impossible figure stated with confidence.
    • Proof: fiveHourSavedPct returns (used * saved) / cost with no upper bound, and subscriptionHeadline renders Math.round(p) as-is (savings.js:110). Example: cost_usd 15, total_saved_usd 45 (a 75% cut), utilization 0.45 → 45 × 45 / 15 = 135 → ≈ 135% of the 5-hour limit (estimate at API-price weights). The formula linearizes the counterfactual as uncapped spend. Past the limit the counterfactual is throttled, so the true saved share is at most 100% − used (here ≤ 55%). The replay cap does not prevent the regime: dash/replaycap.go caps replay credit per conversation, never at cost, so saved > cost stays possible — and it is the product's pitch. The $0.50 and 2% gates do not bound saved / cost.
    • Fix: bound the rendering. When the raw value is ≥ 100, show ≈ the whole 5-hour limit (or ≥ 100%); or estimate the saved share of the counterfactual, used × saved / (saved + cost), which stays below the used share.

Non-blocking

  • The PR body says "Depends on #984". #984 is the issue. The PR that adds GET /api/me/limits is #991, still open. Name #991, so the merge order is unambiguous. Until it merges, the route 404s and every subscription user silently keeps the dollar view — fail-open, so safe.
  • The window read /api/stats?lean=1&since=… can be up to 10 minutes old (the server's stale-while-revalidate cache). The estimate line does not say its age; the Overview's other figures do.
  • The token headline and the estimate cover two different periods: the page's filter vs the current 5-hour window. PR open questions 2 and 3 already name this.
  • A manager who filters to their own tenant (tenant=me) still gets the dollar view. PR open question 4 names this.
  • savings.test.mjs re-implements compact() as its own local fmt, so a drift in compact() would not fail these tests.
  • loadOverviewLimits uses throw new Error('manager') for control flow inside its own try. An early return reads clearer.

What I checked

  • The full diff (6 files) and the code around each change: app.js loadOverview/renderSavedLedger, savings.js, both test files, style.css, docs/data-dependence.md.
  • Hand-checked the arithmetic of every new .mjs assertion; each passes by hand (I ran nothing — live tests are not approved). Checked the liveness boundary: a reset at this exact moment counts as over.
  • Verified each string TestOverviewSubscriptionHeadlineIsWired pins sits on a code line of app.js (stripComments drops only comment lines), and that the test compiles against the existing helpers.
  • Verified the /api/me/limits contract against PR #991: shape {subscription, at_ms, five_hour: {utilization, reset_s, status}}, utilization 0..1, reset_s unix seconds, {} for an API key. liveFiveHour handles a missing reset_s (null) and a missing utilization (estimate hidden, tokens still show).
  • Verified since is epoch milliseconds server-side (r.ts >= since), matching fiveHourStartMs.
  • Verified the lean window read returns cost_usd and total_saved_usd (overviewLeanWindow), and that a manager's /api/stats spans all tenants — the manager exclusion is therefore right.
  • Verified the hero is gated on ready (the full stats read), so replay_tokens comes from the full Overview(), which fills it (overview.go:720); the lean read does not, and the PR body says so.
  • Verified savings.js loads before app.js (index.html, both defer), no global name collisions with the other page scripts, all output goes through el()/textContent (no innerHTML), no inline styles (CSP).
  • Verified the sign-out/sign-in path re-runs loadOverviewLimits, so state.sub cannot outlive an account switch, and every failure path sets it to null (dollar view).
  • Verified the data-dependence row matches the table's columns, is metadata only, and names the decider (#985, David Amid, 2026-11-09).

The provider stops a user at 100% of the 5-hour limit, so the share
saved can never be more than 100 - used. Before, used 45%, $15 spent
and $45 saved showed "≈ 135% of the 5-hour limit".

- The share is now min(used x saved / cost, 100 - used).
- At the cap the line reads "≈ without context-guru you would have hit
  the 5-hour limit (estimate at API-price weights)".
- loadOverviewLimits returns early for a manager (readsLimits) and
  drops an answer that a newer call replaced.
- New tests: the cap (used 45, cost 15, saved 45), just below it, and
  the manager rule.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 9, 2026
Review round 1 of #989.

- The estimate is min(used x saved / cost, 100 - used). The provider
  stops a user at 100%. At the cap the line says "without context-guru
  you would have hit the 5-hour limit", with the same words as #988.
- /api/me/limits is read once per run; `insights` draws three screens.
- _statusline() accepts only a module that has _saved_tokens_text, so a
  stray statusline module in the Codex copy cannot crash the screens.
- Tests: over, at and just below the cap; one limits read per run;
  subscription with no session id and no open window.

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

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. Fixed in 0558248.

  1. Blocking: the 5-hour share had no upper bound. Fixed. fiveHourSavedPct now gives min(used × saved / cost, 100 − used). At the cap the line reads ≈ without context-guru you would have hit the 5-hour limit (estimate at API-price weights). New test: used 45, cost $15, saved $45 shows that line (raw 135%, cap 55%). A second test just below the cap: saved $18 shows ≈ 54% of the 5-hour limit. Exactly at the cap counts as a hit.
  2. PR body: dependencies. Done. It now says "Depends on feat(proxy): record the subscription limit headers and serve GET /api/me/limits #991 (the PR that adds GET /api/me/limits) and fix(dash): lean /api/stats fills replay_tokens and saved_gross #992 (lean replay_tokens fix)". I edited it with gh api -X PATCH and read it back.
  3. loadOverviewLimits: early return, and a guard against stale answers. Done. A manager returns early through readsLimits(tenant), with no throw. Each call takes a sequence number (state.subSeq), so an older answer that lands after a newer call is dropped.
  4. A test for the manager branch. The rule moved into readsLimits in savings.js, and savings.test.mjs tests it (manager: no; member: yes; local proxy with no tenant: yes). The DOM function itself has no harness here, so TestOverviewSubscriptionHeadlineIsWired checks that app.js calls readsLimits and the sequence guard.
  5. fix(dash): lean /api/stats fills replay_tokens and saved_gross #992 and lean replay_tokens. Noted. This PR keeps the full read for rd.

Tests: node --test dash/savings.test.mjs locally, 15 pass, 0 fail. The eval box result follows in a separate comment.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Eval box result on 0558248: ./dash/... passes. I ran CGO_ENABLED=1 go test -race -count=1 -timeout 30m -v in two halves.

  • -run '^Test[A-H]': ok, 281 s. 397 pass, 0 fail, 3 skip.
  • -run '^Test[^A-H]': ok, 352 s. 575 pass, 0 fail, 9 skip.
  • The skips are live, demo and node or browser tests. node is not on the box, so TestSavingsPartsAddUp skips there. Locally, savings.test.mjs has 15 pass, 0 fail.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 0558248dc3bf approve

Verdict: approve

Findings

None.

Earlier findings

  • My finding 1 (estimate above 100% of the limit) — fixed. fiveHourSavedPct now returns min(used × saved / cost, 100 − used) with a hit flag (savings.js:97-103). At the cap the line reads "≈ without context-guru you would have hit the 5-hour limit". I checked the math by hand: used 45, cost $15, saved $45 → raw 135, room 55, hit. Saved $18 → raw 54, no hit. room = max(0, 100 − used) also holds at used = 100 (always a hit, which is right). Both callers were updated to the new {pct, hit} shape; no other caller exists.
  • Reviewer 1's finding 1 — same defect, fixed the same way. Agree with their analysis; nothing to add.
  • My non-blocking notes: manager guard now has a test (readsLimits in savings.js:109, tested in the mjs file) — fixed. Stale-answer overwrite now guarded by state.subSeq (app.js:1894-1897) — fixed. Merge order — the PR body now says "Depends on #991 … and #992. Merge those first."; I read the body back from the API. The unpriced-deployment note stands as accepted behavior.
  • Author's rejections: none. Every finding and note was fixed or noted.

Non-blocking

  • The info text under the headline (app.js:1760-1765) still describes only the raw formula ("the share of the limit used, times what context-guru saved, divided by what you spent"). It does not mention the 100 − used cap or the "would have hit the limit" line. A reader who opens the info box next to that line finds no explanation of it.

What I checked

  • Last review: round 1, e3c6dc5, 2026-11-09T17:10:41Z.
  • New commits read: 1 (0558248d fix(dash): cap the 5-hour share saved at the room that was left).
  • Read in full: 2 reviews, 3 comments, 0 inline comments (from the three files).
  • New items since my last review, and what I did about each:
    • Commit 0558248d: read the full diff and the final state of savings.js, app.js loadOverviewLimits, and both test files. Verified the cap arithmetic, the {pct, hit} return shape against every caller, the readsLimits manager rule (manager: no read, dollar view; member and local proxy: read), and the sequence guard (an older answer is dropped when a newer call has started).
    • Author's round-1 reply (17:15:11): checked each claim against the code — all five hold.
    • Eval-box comments (16:51:46 on e3c6dc53, 17:26:04 on 0558248d): ./dash/... passes with -race; savings.test.mjs 15 pass locally. I ran nothing myself.
    • The two new Go wiring pins (readsLimits call, seq !== state.subSeq) match code lines in app.js; stripComments drops only comment lines, so both pins sit on code.
    • PR body: dependency line names #991 and #992, as the author said.
  • Hand-checked the new mjs assertions: cap case (135 → 55, hit), below-cap case (54), the threshold case re-shaped to {pct: 2, hit: false}, and the readsLimits cases. All consistent with the code.
  • Confirmed the earlier pinned strings in TestOverviewSubscriptionHeadlineIsWired still match the new app.js.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 0558248dc3bf approve

Verdict: approve

Findings

None new. The fix commit changes only what the reviews asked for, and I found no defect in it.

Earlier findings

  1. Reviewer 1, round 1 — the estimate could show more than 100% of the limit. Fixed. fiveHourSavedPct now returns min(used × saved / cost, 100 − used) with a hit flag (savings.js:101-103). At the cap the line reads "≈ without context-guru you would have hit the 5-hour limit (estimate at API-price weights)". The wording is right: raw ≥ room means the counterfactual reaches 100%, which is exactly "would have hit the limit". I checked the new tests by hand, including the floating-point boundary: at exactly the cap (saved = 15 × 55 / 45, used = 45), the product rounds to 825.0 and raw = 55 = room, so hit is true as the test asserts. Reviewer 2 raised the same finding; same verdict.
  2. Reviewer 1, round 1 (non-blocking) — "Depends on #984" named the issue, not the PR. Fixed. The PR body now says #991 and #992, and both exist and are open. Note: #992 (lean replay_tokens) is not strictly needed by this PR — it reads rd from the full /api/stats — but merge order stays safe either way.
  3. Reviewer 1, round 1 (non-blocking) — throw for control flow in the manager branch. Fixed. readsLimits(tenant) returns early, no throw, and it is tested in savings.test.mjs (manager no, member yes, no tenant yes).
  4. Reviewer 2, round 1 (non-blocking) — a stale loadOverviewLimits could overwrite a newer one. Fixed. Each call takes a sequence number (state.subSeq); an older answer is dropped in done(). I traced the sign-out/sign-in path: a new Overview load bumps the sequence, so an in-flight old answer cannot land.
  5. Reviewer 2, round 1 (non-blocking) — the manager guard had no test. Fixed (item 3 above), plus two new pinned strings in TestOverviewSubscriptionHeadlineIsWired.
  6. Reviewer 2, round 1 (non-blocking) — an unpriced deployment never shows the token headline. Not changed. The author left it matching the rest of the page. I agree: the hero already gates on priced for everyone, so a subscription user without a price table sees the same "Nothing priced yet" as an API-key user. No change needed.

Non-blocking

  • The estimate line still does not say its age. The window read can be up to 10 minutes old (the server's stale-while-revalidate cache). The Overview's other figures show data age.
  • The token headline (the page's period) and the estimate (the 5-hour window) still cover two periods. PR open questions 2 and 3 name this; it is a wording choice, not a defect.

What I checked

  • Last review: round 1, e3c6dc5, 2026-11-09T17:12:21Z.
  • New commits read: 1 — 0558248d "fix(dash): cap the 5-hour share saved at the room that was left".
  • Read in full: 2 reviews, 3 comments, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Commit 0558248d: read the full diff and the final state of app.js loadOverviewLimits, savings.js fiveHourSavedPct/readsLimits/subscriptionHeadline, both test files. Checked the cap arithmetic, the hit boundary, the sequence guard, and the export list.
    • Comment at 17:15:11 (author's round-1 replies): checked each claim against the code; all five hold.
    • Comment at 17:26:04 (eval box on 0558248d): ./dash/... with -race passes in both halves, 972 pass, 0 fail; savings.test.mjs 15 pass locally. Nothing to act on.
    • PR body edit: read it back from the server; the dependency line now names #991 and #992, both open PRs.
  • Hand-checked every new and changed .mjs assertion, including the exact floating-point values of 100 × 0.45, 100 × 0.02 and 45 × (825 / 45) (all round to the exact values the tests assert). I ran nothing — live tests are not approved.
  • Verified the two new strings pinned by TestOverviewSubscriptionHeadlineIsWired sit on code lines of app.js (lines 1896 and 1900), so stripComments keeps them.
  • Checked readsLimits and state.subSeq for name collisions with the other page scripts: none.
  • Checked that the return-shape change of fiveHourSavedPct (number → {pct, hit}) reaches every caller: only subscriptionHeadline and the tests.
  • Re-checked the cap semantics at the edges: used at 100% gives room 0 and hit true; a small raw with little room left also reads "would have hit the limit", which is correct — the counterfactual still crosses 100%.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

On hold (owner's decision, 2026-11-09). This PR is approved, but it waits for #998 part 1.

#998 stores the accountant's tier tokens, so that every saving can be shown in tokens: compaction, cache split, keep-alive and TTL. Today only compaction has a token count. Once #998 part 1 merges, this PR switches its token source to those fields, and the dollar figures go away on a subscription.

amiddavid added a commit that referenced this pull request Nov 10, 2026
The lean stats read never set saved_gross or replay_tokens. It always
answered 0. The status line, the mod band and the status screens
then showed only "wr", never "rd".

overviewLeanWindow now computes both as the full read does, from the
columns it already scans. No new query.

Closes #990

Behavior change: a fix of wrong output.
- Who: everyone who reads /api/stats?lean=1 with a session or a time
  window (status line, mod band, subscription screens in #988, #989).
- Old: "saved 593 wr". The "rd" half never showed.
- New: "saved 1.2M rd / 593 wr".
- Turn off: no switch. Revert this PR.
Owner's yes, 2026-11-10, in the integrator session: "I approve the chhange in 981, 991 and 992".

Data dependence: metadata only (token counts). No change.

Reviews: 2 offload reviews (GLM), round 1, both approve at 0cbd4d7. c3662e6 changes only comment lines (approval-still-valid: comments only).

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
amiddavid added a commit that referenced this pull request Nov 10, 2026
…pi/stats (#999)

Part 1 of #998. The dashboard stored only the dollars of each saving.
The tokens were lost after the write. This PR stores the tokens
by tier beside the dollars.

- 8 new columns in request_components and 32 in requests
  (default 0). Tokens follow the same attribution as the dollars.
- /api/stats (full and lean=1) now returns tokens,
  tokens_unmeasured_requests and the two keepalive_ping token fields.
  Both paths call one function, DB.AccTokens.
- PRs #988 and #989 use the new fields as their token source.

Behavior change: none stated; new fields in /api/stats. No existing
figure, field or column changes its value.
Owner's yes, 2026-11-10, in the integrator session: "999 approve".

Data dependence: metadata only. The new columns are token counts.
They are the same at each storage level. docs/data-dependence.md
row "Accountant savings" is updated.

Reviews: 2 offload reviews (GLM), round 4 (owner granted round 4), both approve at 3ae7056. Round 4 reviewed the rebase onto main after #991, which merged #991's limit columns and #999's token columns by hand in 4 files.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
The Overview on a Claude subscription now reads the accountant's tier
tokens from /api/stats (#999), not saved_unique and replay_tokens.

- The total: tokens.saved, and tokens.caused plus the keep-alive ping
  tokens as cost. One display rule: tiers that are not 0, in the order
  wr, wr1h, rd, in; the cost after. Tiers are never added.
- Each card shows tokens from tokens.by_feature: Cache (keepalive,
  cachesplit, ttl; the pings as keep-alive cost), Preset (every other
  component and ended_change), Tools and skills filter (toolfilter),
  Tool deferral (tooldefer).
- The subscription view starts on the auth kind (subscription: true),
  not only on an open 5-hour window. The estimate still needs one.
- A note under the total counts requests not measured in tokens.
- No dollars on a subscription: the replay-cap and estimated-request
  notes leave them out.

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

Copy link
Copy Markdown
Collaborator Author

Part 2 of #998, on a268464. The subscription view now reads the accountant's tier tokens (#999). Changes since review round 1 (0558248):

  1. Merged origin/main (with feat(dash): store the accountant's tier tokens and serve them from /api/stats #999). No conflicts.
  2. Every saving in tokens on a subscription. The total and each card read /api/stats tokens, not saved_unique / replay_tokens.
    • One display rule: tiers that are not 0, in the order wr, wr1h, rd, in; cost after. Example: saved 85.0k wr · cost 40.0k rd.
    • Cache card: keepalive, cachesplit, ttl, one row each. The keep-alive cost includes keepalive_ping_tokens.
    • Preset: every other by_feature entry. Filter: toolfilter. Deferral: tooldefer.
    • The total's cost is tokens.caused plus the ping tokens, so the cards add up to it, tier by tier.
  3. No dollars on a subscription. The replay-cap and "estimated requests" notes leave the dollars out. The "≈ tokens read instead of rewritten" figure does not show.
  4. "N requests not measured in tokens" under the total when tokens_unmeasured_requests > 0.
  5. The token view also starts on subscription: true, not only on an open 5-hour window. The estimate is unchanged and still needs an open window.
  6. Docs: docs/dashboard.md has a new section, "On a subscription, the Overview shows tokens". The docs/data-dependence.md row names dash: store the accountant's tier tokens, so every saving can be shown in tokens #998.

Tests

  • node --test dash/savings.test.mjs (local): 19 pass, 0 fail (was 15).
  • CGO_ENABLED=1 go test -race -count=1 -timeout 30m ./dash/... on the eval box, in two halves:
    • ^Test[A-H]: ok, 382 s. 407 pass, 0 fail, 3 skip.
    • ^Test[^A-H]: ok, 436 s. 586 pass, 0 fail, 9 skip.

For the owner: items 5 and the ping tokens in the total's cost (item 2) are choices I made from "on a subscription, tokens". Please confirm.

The owner's rule for every screen: the keep-alive ping tokens are not
in the total and not in any card's cost. The band's lean read has no
ping tokens, so this is the one rule all screens can follow.

- totalTokens: the cost is tokens.caused only.
- featureTokens: the keep-alive and Cache flows leave the pings out.
- A line "Keep-alive pings (not in the total): cost ..." shows under
  the total and on the Cache card, with the same words as #989.

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

Copy link
Copy Markdown
Collaborator Author

Keep-alive pings on their own line, on f9227dc. This follows the owner's rule for every screen.

What changed:

  1. The total's cost is tokens.caused only. totalTokens no longer adds keepalive_ping_tokens.
  2. A pings line under the total: Keep-alive pings (not in the total): cost 20 wr · 9.0k rd. The words match feat(plugin): status and insights savings show saved tokens on a subscription #989.
  3. The Cache card has the same line as its own row. The "Automatic pings" row and the card's total show the rescue's own cost only.
  4. Tests: the "cards add up to the total" test now checks that the total's cost equals tokens.caused, that no card's cost includes the pings, and that the pings line shows only when the pings paid something. The Go wiring test checks the two pings lines.
  5. Docs: docs/dashboard.md says the pings show apart and why.

The subscription: true start rule is unchanged. The owner is still deciding it.

Tests

  • node --test dash/savings.test.mjs (local): 19 pass, 0 fail.
  • TestOverviewSubscriptionHeadlineIsWired on the box: pass.
  • CGO_ENABLED=1 go test -race -count=1 -timeout 30m ./dash/... on the box, on f9227dc:
    • ^Test[A-H]: ok, 360 s. 407 pass, 0 fail, 3 skip.
    • ^Test[^A-H]: ok, 427 s. 586 pass, 0 fail, 9 skip.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 3 of 3 f9227dc9d66d approve

Verdict: approve

Findings

None.

Earlier findings

  • Round 1/2, the estimate cap — still fixed. fiveHourSavedPct keeps min(used × saved / cost, 100 − used) with the hit flag; the new subscriptionHeadline carries it over unchanged (savings.js). The docs page now states the formula and the cap line (docs/dashboard.md, "On a subscription, the Overview shows tokens").
  • My round-2 non-blocking note (the info text omits the cap) — still open, still non-blocking. See below.
  • Reviewer 1's round-2 non-blocking notes (estimate age, two periods) — not addressed. Both are wording choices the PR's open questions already name. I agree they stay.
  • No earlier finding was rejected.

What the new commits do, and what I verified

  • 9b078a61 (merge of main). Brings in #991 (/api/me/limits), #999 (tier tokens), #996, #1009, #981. I read the two this PR depends on:
    • dash/limits.go (#991, merged version): subscription now comes from the auth kind (LatestAuthSubscription, requests' auth_subscription), not from the limit headers. This closes the stale-flag edge I worried about: an account that moves from a subscription to an API key gets {} at once, so the dollar view returns. The response shape matches isSubscription and liveFiveHour exactly.
    • dash/acctokens.go (#999): tokens.saved / tokens.caused are the sums over by_feature (addFeature adds to both), so the cards' add-up claim holds. A ping row stores zeros in every token column (requestStoredTokenArgs), so no feature's caused ever contains the pings; keepalive_ping_tokens is read separately from the ping rows' own usage. That is exactly the rule f9227dc9 displays. The lean read has the totals and the unmeasured count, no by_feature and no ping tokens — and the UI never reads those on a partial render (cards say "Loading…", the hero waits for ready).
  • a268464f (every saving in tokens). Verified the display rule (tierText, tokenLine: nonzero tiers in the order wr, wr1h, rd, in, cost after), the partition (featureTokens: cache = keepalive + cachesplit + ttl; filter = toolfilter; defer = tooldefer; compaction = every other by_feature key — exhaustive, so the cards cover the whole map), totalTokens (tokens.saved / tokens.caused only), and the no-dollar paths (capNote with a null formatter, the estimated-requests note). Hand-checked every new .mjs assertion, including the card/total add-up tier by tier and the ping line. All consistent.
  • f9227dc9 (pings on their own line). The total's cost is tokens.caused only; the pings show under the total and on the Cache card with one label (PING_LABEL), only when they paid something. Matches the server rule above and the docs.

Non-blocking

  • The subscription: true start rule awaits the owner's yes. The token view now starts on the auth kind alone, with no open 5-hour window (no estimate then). The author flagged this themselves (comment at 08:45:03, "Please confirm"; at 12:02:11, "The owner is still deciding it"). Confirm before merge. The merged #991 makes this rule sound — the auth kind is fresh, not a stale header — so my only point is the pending decision, not the code.
  • The in-page info text (app.js subInfo) still does not mention the 100 − used cap or the "would have hit the limit" line. The docs page explains both. Carried from round 2.
  • The hero's kind line reads "wr cache write, rd cache read, in fresh input" — wr1h is missing from the list, though it can appear in the lines. The info box explains it.
  • On a server from before #999 (no tokens at all), the Cache card's split box can render as an empty sunken <ul>: every row is null because no feature has tokens. Cosmetic, and only until the server is updated.

What I checked

  • Last review: round 2, 0558248, 2026-11-09T17:28:35Z.
  • New commits read: 3 on the branch (9b078a61 merge origin/main; a268464f feat(dash): on a subscription show every saving in tokens; f9227dc9 fix(dash): show the keep-alive pings on a line of their own). The merge also brought main's #991, #999, #996, #1009 and #981; I read #991's and #999's code in full because this PR depends on both, and the merge-conflict surface (dash files both touch) reads clean in the final tree.
  • Read in full: 4 reviews, 6 comments, 0 inline comments (from the three files).
  • New items since my last review, and what I did about each:
    • Comment 20:07:57 (on hold for #998 part 1): noted; #999 has since merged and this PR now builds on it.
    • Comment 08:45:03 (part 2 changes): checked each of the six claims against the code and against #999's server fields — all hold.
    • Comment 12:02:11 (pings line): checked the five claims — all hold.
    • Commits a268464f and f9227dc9: full diff read (7 files); verified the JSON field names against dash/overview.go (tokens, tokens_unmeasured_requests, keepalive_ping_tokens), the tier JSON names against TierTokens, and EndedChangeComponent = ended_change.
    • The new Go wiring pins (8 new strings in TestOverviewSubscriptionHeadlineIsWired): each matches a code line of app.js; stripComments drops only comment lines.
    • Eval-box and local test results in the comments (19 pass mjs; ./dash/... with -race passes on both heads): read; I ran nothing myself.
  • Hand-checked the arithmetic of every new and changed .mjs assertion (token lines, the feature split, the add-up per tier, the ping line, capNote with a null formatter). All pass by hand.
  • Checked for name collisions of the new globals (isSubscription, tierText, addTiers, tokenLine, hasTokens, featureTokens, totalTokens, pingLine, PING_LABEL, TOKEN_TIERS, CACHE_FEATURES) against the other page scripts: none.
  • The data-dependence row now names #998 beside #985, still metadata only, decider filled.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 3 of 3 f9227dc9d66d approve

Verdict: approve

Findings

None new. Part 2 (a268464f) and the pings line (f9227dc9) rework what the reviews already saw, on the #999 token fields. I found no defect in either commit.

Earlier findings

  1. Round 1 (blocking) — the estimate could show more than 100% of the limit. Still fixed. Part 2 did not touch fiveHourSavedPct; the min(used × saved / cost, 100 − used) cap and the hit flag are as verified in round 2.
  2. Round 1 (non-blocking) — the PR body named the issue, not the PRs. Fixed in round 2. The rewritten body names #991, #992 and #999. All three are in main now.
  3. Round 1 (non-blocking) — throw for control flow in the manager branch. Still fixed. readsLimits returns early. Part 2 kept it.
  4. Round 2 (reviewer 2, non-blocking) — a stale limits answer could overwrite a newer one. Still fixed. state.subSeq guards loadOverviewLimits, and part 2 kept the guard when it added the isSubscription gate.
  5. Round 2 (reviewer 2, non-blocking) — the manager guard had no test. Still fixed. readsLimits is tested in savings.test.mjs; the Go wiring test pins the call.
  6. Round 2 (reviewer 2, non-blocking) — an unpriced deployment never shows the token headline. Accepted in round 2. Part 2 keeps the same hero gate (priced), so the behavior matches the rest of the page. No change needed.

Non-blocking

  1. The subscription: true start rule still needs the owner's yes. The author's comment at 12:02:11 says the owner is still deciding it (PR open question 1). The repo rule says an agent never decides a behavior change. Merge only after the owner answers. The rest of the change — tokens on a subscription, no dollars — is decided on #985 and #998.
  2. The info text still does not explain the cap. Reviewer 2 raised this in round 2; it stands. The info text under the headline describes only the raw formula. It does not mention the 100 − used cap or the "would have hit the limit" line.
  3. Two token figures on the Preset and Filter cards. On a subscription these cards show the new tier figure and the old "Tokens removed" figure. The Cache card drops its old derived figure. The old figures are measured (tokens_before − tokens_after, decl_filter_reads), so the PR-body claim holds: saved_unique and replay_tokens are out of the subscription view. A presentation choice, not a defect.
  4. The Cache card's breakdown can render empty. On a subscription, cacheRan can be true while every token row is null. Example: only manual pings ran, and no request has accountant tokens or ping tokens. The ov-split list then renders with no rows. Cosmetic.
  5. The hero's "by kind" explainer omits wr1h. The hero line under the total says "wr cache write, rd cache read, in fresh input". The info button does explain wr1h. Minor.
  6. The estimate line still does not say its age. Carried from round 2. The window read can be up to 10 minutes old.

What I checked

  • Last review: round 2, 0558248, 2026-11-09T17:29:44Z.
  • New commits read: 2 PR commits (a268464f part 2, f9227dc9 the pings line), plus the merge 9b078a61. The other commits in 0558248d..HEAD came from main through the merge; each was reviewed in its own PR (#979, #983, #987, #968, #977, #971, #982, #992, #981, #991, #996, #1009, #999).
  • Read in full: 4 reviews, 6 comments, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Comment at 20:07:57 (on hold for #998 part 1): noted. #999 is in main now, so the hold is over.
    • Comment at 08:45:03 (part 2 on a268464f): checked each claim against the code. All hold, with one exception the author fixed himself in the next commit: at a268464f the total's cost still included the ping tokens, against the owner's rule that a ping is not agent traffic.
    • Comment at 12:02:11 (the pings line on f9227dc9): checked each claim. totalTokens no longer adds keepalive_ping_tokens. The pings show on their own line under the total and as a row on the Cache card. The words match PING_LABEL, which #989 also uses.
    • Commit a268464f: read the full diff and the final state of savings.js, app.js (renderSavedLedger, loadOverviewLimits), savings.test.mjs, savingsparts_test.go, style.css, docs/dashboard.md, docs/data-dependence.md.
    • Commit f9227dc9: read the full diff. The pings line, the Cache card row, both test files, the docs.
    • Merge 9b078a61: main merged with no conflict into the subscription view.
    • PR body (rewritten): read in full. Checked each claim against the code. All hold (see non-blocking 3 for the "no longer used" claim).
  • Verified the frontend/backend contract end to end: /api/stats tokens (saved, caused, by_feature, keepalive_ping_tokens, tokens_unmeasured_requests) against dash/acctokens.go; the by_feature keys against the accountant's component names and envelopeComponents; the lean read (no by_feature, no ping tokens) against the hero's ready gate, so the token view waits for the full read.
  • Hand-checked every assertion in savings.test.mjs (19 tests) by arithmetic: the display rule, the by_feature split into cards, the cards-add-up invariant (the total's cost is tokens.caused; no card's cost has the pings; the pings line shows only when the pings paid something), the cap cases, readsLimits, isSubscription with a window that is over, capNote without dollars. I ran nothing — live tests are not approved.
  • Verified the 13 strings pinned by TestOverviewSubscriptionHeadlineIsWired sit on code lines of app.js, so stripComments keeps them.
  • Checked for name collisions of the new globals (TOKEN_TIERS, PING_LABEL, and the new functions) across the page scripts: none.
  • Checked the fail-open path: a /api/me/limits failure leaves state.sub null, so the Overview falls back to the dollar view.
  • Checked the data-dependence row ("Subscription headline", metadata only, decided by David Amid on #985 and #998): it matches the code. Token counts, auth kind and rate-limit numbers only.

Review round 2 on #988.

- tokenFigure in savings.js: one rule for every token figure. A priced
  zero reads "saved 0 tokens"; an all-zero figure with unpriced
  requests, or a server with no tokens, reads "not measured". The
  Overview cards and the headline use it: a feature left out of
  by_feature on a priced period now reads "saved 0 tokens".
- The 5-hour estimate hides while a page filter is on: it is for the
  whole account. The info text says so, and explains the 100 - used
  cap and the "would have hit the 5-hour limit" line.
- The hero legend names wr1h.
- The Cache card: no empty list; the pings line is computed once; the
  rescue row reads "Keep-alive rescue"; the info text describes the
  token figures on a subscription.
- Drop the "net is the rescue less the pings" claim: the tiers have no
  common unit.

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

Copy link
Copy Markdown
Collaborator Author

Round 2 fixes, on 407534d.

Owner decisions (2026-11-10)

  • The token view starts on subscription: true OR an open 5-hour window. Approved as built.
  • One more review round is granted.
  • Earlier: the keep-alive pings show on a line of their own, not in the total (f9227dc).

What changed

  1. One rule for zero against "not measured": tokenFigure(flow, scope, fmt) in savings.js returns {text, measured}.
  2. Subscription info text explains the 100 − used cap and the "would have hit the 5-hour limit" line.
  3. Hero legend names wr1h (1-hour cache write).
  4. Cache card: with no rows, the list does not show. Before, an empty <ul> showed.
  5. pingLine is computed once per row. The "net is the rescue less the pings" claim is gone from the code comment and from docs/dashboard.md, in both the feat(dash): store the accountant's tier tokens and serve them from /api/stats #999 section and this PR's section. The tiers have no common unit.
  6. Cache card info text on a subscription describes the token figures: rescue, pings, reorder, 1-hour cache. The rescue row is now called "Keep-alive rescue", so it does not read like the pings line below it.
  7. 5-hour estimate and page filters: the estimate is hidden while a filter or a time range narrows the page (pageFiltered()). The tenant pick does not count as a filter. The info text says so.

Tests

  • node --test dash/savings.test.mjs (local): 21 pass, 0 fail. New tests cover the zero rule (priced zero, unpriced zero, server with no tokens) and the hidden estimate under a filter.
  • TestOverviewSubscriptionHeadlineIsWired checks tokenFigure, pageFiltered() and the no-empty-list guard.
  • CGO_ENABLED=1 go test -race -count=1 ./dash/... on the box, in 8 foreground runs by first letter: 993 pass, 0 fail, 12 skip. gofmt is clean and go vet is OK.

amiddavid added a commit that referenced this pull request Nov 10, 2026
Merges #988 at 407534d, which adds tokenFigure: one rule for zero
against "not measured" on every screen.

Conflict resolution and the follow-up change:
- kaTokenLines takes the rescue text and its `measured` flag from
  tokenFigure. The three sentences still branch on the flag.
- A ledger with no `tokens` (a server from before #999) now reads
  "not measured", as tokenFigure says.
- The "Cache rewrites avoided" fact reads "up to 85.0k wr · cost
  40.0k rd", without a second "saved".
- savings.test.mjs keeps both sides' new tests.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 10, 2026
The Tokens saved cell now follows #988's shared rule for zero against
"not measured" (tokenFigure), scoped to the session row. An all-zero
figure with any unpriced request of the session, or a row with no
tokens, reads "not measured". The dagger shows on a measured figure
only.

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

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 407534d103ac approve

Verdict: approve

Findings

None.

Earlier findings and notes

  • Round 1/2, the estimate cap — still fixed, unchanged by this commit.
  • My round-3 non-blocking notes — all fixed in 407534d1:
    • The subscription: true start rule: the owner approved it as built (comment at 13:13:00, "Owner decisions (2026-11-10)"). The merge gate is closed.
    • The info text now explains the 100 − used cap, the "would have hit the limit" line, and that the estimate is account-wide and hides under a filter.
    • The hero legend names wr1h.
    • The Cache card no longer renders an empty <ul>: subRows is filtered and the list is drawn only when a row exists.
  • Reviewer 1's round-3 notes: the info-text cap (fixed), the empty list (fixed), wr1h (fixed), the owner's yes (given). Their note 3 (two token figures on the Preset and Filter cards) is a presentation choice they already accepted; note 6 (the estimate's age) stays open as a wording choice. I agree with both dispositions.
  • No earlier finding was rejected.

What the new commit does, and what I verified

  • tokenFigure(flow, scope, fmt) — one rule for zero against "not measured". I traced every branch: a flow with tokens shows its line; an all-zero flow reads saved 0 tokens only when the scope has tokens and tokens_unmeasured_requests is 0; otherwise not measured. This errs toward "not measured", which is the right direction (a missing figure never claims a measured zero). It matches the server: addFeature leaves a zero feature out of by_feature, and both reads always carry tokens post-#999. The headline and all four cards now go through it; I hand-checked both new .mjs tests, including the changed {tokens: {}} fixture (correct under the new rule: a scope with no tokens reads "not measured").
  • pageFiltered() hides the account-wide estimate while a filter narrows the page. I checked it against the real filter model: state.filter keys come from DIMS (model, provider, agent, preset, mode, component, reason, accounting, effort, thinking, stop_reason, session, tenant) plus q, project and the time range. All narrow except tenant, which the function excludes on purpose — and the tenant pick is a manager feature (wideScope()), while managers never see the estimate (readsLimits). Correct. subscriptionHeadline takes the flag as a sixth parameter; the one production caller passes pageFiltered(), and an omitted flag stays falsy, so the tests and any other caller keep the old behavior.
  • The Cache card computes pingLine once, renames the rescue row to "Keep-alive rescue" (it no longer reads like the pings line below it), and draws the list only with rows. The subscription info text for the card now describes the token figures.
  • The "net is the rescue less the pings" claim is gone from the code comment and both docs sections. Right call: the tiers have no common unit, so the subtraction was not well defined.
  • The two new Go wiring pins (tokenFigure(flow, o, compact).text, subRows.length ? el('ul') and the updated pageFiltered() pin all match code lines of app.js.

Non-blocking

  • Reviewer 1's carried note: the estimate line still does not say its age (the window read can be up to 10 minutes old from the server's stale-while-revalidate cache). A wording choice, still open.
  • tokenFigure's measured flag is exported but unused by this PR (the comment names #1041 and #1042 as its consumers). Not a defect.

What I checked

  • Last review: round 3, f9227dc, 2026-11-10T12:07:16Z.
  • New commits read: 1 (407534d1 fix(dash): one rule for zero against not measured, and round 2 fixes). git log f9227dc9..HEAD lists exactly this one commit.
  • Read in full: 6 reviews, 7 comments, 0 inline comments (from the three files).
  • New items since my last review, and what I did about each:
    • Reviewer 1's round-3 review (12:11:20, approve): read in full; their six non-blocking notes checked against the code — items 1, 2, 4, 5 are now fixed by 407534d1, items 3 and 6 stand as accepted choices.
    • Comment 13:13:00 (round 2 fixes and owner decisions): checked all seven claims against the diff — all hold. The owner's approval of the subscription: true start rule closes my round-3 merge gate.
    • Commit 407534d1: read the full diff (5 files) and the final state of savings.js, app.js (pageFiltered, renderSavedLedger, the Cache card), both test files, and both docs sections.
  • Hand-checked the arithmetic of both new .mjs tests and the one changed assertion. All pass by hand. The author reports 21 pass locally and ./dash/... with -race passing on the box; I ran nothing myself.
  • Verified pageFiltered() against DIMS, qs(), setFilter and wideScope(); no non-narrowing filter key is missed.
  • Checked every caller of the changed signatures (subscriptionHeadline sixth parameter, tokenFigure): the production caller, the mjs tests, and the Go pin all updated in the same commit.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 407534d103ac approve

Verdict: approve

Findings

None new. The commit 407534d1 answers the review notes and the owner's round 2. I found no defect in it.

Earlier findings

  1. Round 1 (blocking) — the estimate could show more than 100% of the limit. Still fixed. This commit did not touch fiveHourSavedPct.
  2. Round 1 (non-blocking) — the PR body named the issue, not the PRs. Fixed in round 2. The body still names #991, #992 and #999, all in main.
  3. Round 1 (non-blocking) — throw for control flow in the manager branch. Still fixed. readsLimits returns early.
  4. Round 2 (reviewer 2, non-blocking) — a stale limits answer could overwrite a newer one. Still fixed. state.subSeq guards loadOverviewLimits.
  5. Round 2 (reviewer 2, non-blocking) — the manager guard had no test. Still fixed.
  6. Round 2 (reviewer 2, non-blocking) — an unpriced deployment never shows the token headline. Accepted. The hero gate is unchanged.
  7. My round-3 note 1 — the subscription: true start rule needed the owner's yes. Resolved. The author's comment at 13:13:00 records the owner's decision of 2026-11-10: approved as built. The PR body's open question is gone.
  8. My round-3 note 2 and reviewer 2's round-2/3 note — the info text did not explain the cap. Fixed. subInfo now has two new paragraphs: the 100 − used cap with the "would have hit the limit" line, and the filter rule.
  9. My round-3 note 4 and reviewer 2's round-3 note — the Cache card's list could render empty. Fixed. subRows.filter(Boolean), and the <ul> draws only when a row exists.
  10. My round-3 note 5 and reviewer 2's round-3 note — the hero legend omitted wr1h. Fixed. The hero line now reads "wr cache write, wr1h 1-hour cache write, rd cache read, in fresh input".

Non-blocking

  • Two token figures beside each other. The Preset and Filter cards still show the old "Tokens removed" figure next to the new tier figure on a subscription, and the hero keeps "Input tokens removed" next to the tier total. The old figures are measured (tokens_before − tokens_after, decl_filter_reads). A presentation choice, carried from round 3.
  • The estimate line still does not say its age. Carried from round 2. The window read can be up to 10 minutes old.
  • tokenFigure returns a measured flag this PR does not use. Only .text is read here. The comment says #1041 and #1042 will switch to it. Harmless.

What I checked

  • Last review: round 3, f9227dc, 2026-11-10T12:11:20Z.
  • New commits read: 1 — 407534d1 "fix(dash): one rule for zero against not measured, and round 2 fixes".
  • Read in full: 6 reviews, 7 comments, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Commit 407534d1: read the full diff (5 files) and the final state of savings.js, app.js (renderSavedLedger, pageFiltered, the hero and the Cache card), both test files, docs/dashboard.md.
    • Author's comment at 13:13:00 (round-2 fixes, owner decisions): checked each of the seven claims against the code. All hold.
    • Reviewer 2's round-3 review (12:07:16, posted while my round 3 was in flight, so I read it now for the first time): read in full. Its four non-blocking notes match mine from round 3. This commit addresses three of them; the fourth (the start rule) the owner decided.
    • PR body edit: read it back in full. Line 32 now names the hidden estimate and the new info text. The open question about the start rule is gone, matching the owner's decision. Every claim I checked holds.
  • The zero rule (tokenFigure). Verified the premise server-side: addFeature in dash/acctokens.go adds no by_feature entry for an all-zero figure, so a missing feature on a priced period is a measured zero. Verified the three branches against the code: tokens → its line; all-zero with tokens present and no unmeasured request → saved 0 tokens; otherwise → not measured. The conservative direction is right: with unmeasured requests, an all-zero figure can be a true zero or an unknown, and the rule says unknown.
  • The hidden estimate (pageFiltered). Verified state.filter (starts {}, values are set strings, cleared keys are deleted), so v && k !== 'tenant' is safe. The window read carries no filter params (lean=1&since=…), so the estimate was always account-wide; hiding it under a filter stops a wrong reading. The tenant pick is a manager control, and a manager never sees the estimate, so excluding it is right. The dollar view is untouched: pageFiltered feeds only the subscription headline.
  • Hand-checked every new and changed .mjs assertion (21 tests now): the zero-rule cases (priced zero, unpriced zero, no tokens, a figure with tokens while unmeasured), the headline on the same rule, and the estimate under a filter (used 54, cost $90, saved $5 → raw 3, room 46 → ≈ 3%). The changed saved 0 tokens assertion now passes a scope with tokens present, which the new rule requires. I ran nothing — live tests are not approved.
  • Verified the three new Go pins sit on code lines of app.js: the pageFiltered() argument (line 1751), tokenFigure(flow, o, compact).text (line 1811), subRows.length ? el('ul' (line 1827).
  • Checked tokenFigure and pageFiltered for name collisions across the page scripts: none. pageFiltered sits beside hasRange, both function declarations.
  • Checked the fail-open paths again: state.sub null → dollar view; tokenFigure on a scope without tokens → not measured, never NaN.
  • Checked the Cache card's new subscription info text and the "Keep-alive rescue" rename against the rows that draw: the row list and the info text name the same four things (rescue, pings, reorder, 1-hour cache).
  • Checked the docs against the code: the zero rule, the no-empty-list rule, the pings-apart rule without the old "net is the rescue less the pings" claim, and the filter rule all match savings.js and app.js.

Resolve the one conflict in dash/ui/app.js: keep the "Not counted in
Your preset." text from main and the saving() cell from this branch.

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 Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 5 of 6 6da758398741 approve

Verdict: approve

Findings

None new. The branch's only new commit is a merge of origin/main. It changes one line of this PR's code besides the merge itself, and I found no defect in the resolution or in its interaction with the subscription view.

Earlier findings

All earlier findings and notes stay as tracked in round 4. The merge touches none of the code behind them: the cap, readsLimits, state.subSeq, tokenFigure, pageFiltered, the hero legend and the Cache card are all unchanged. The owner's approval of the subscription: true start rule (comment at 13:13:00) still stands.

Non-blocking

  • Two token figures beside each other. Carried from round 3. The Preset and Filter cards show the old "Tokens removed" figure next to the tier figure, and the hero keeps "Input tokens removed". Presentation choice.
  • The estimate line still does not say its age. Carried from round 2.
  • tokenFigure's measured flag is still unused here. #1041 and #1042 are named as its consumers. Harmless.

What I checked

  • Last review: round 4, 407534d, 2026-11-10T13:17:50Z.
  • New commits read: 1 — 6da75839 "Merge origin/main into feat/dash-subscription". The main-line commits it brought (#1002, #1046, #720, #483, #1034, #1003, #1035, #1011, #1018, #1014, #989, #1020, #1012, #1010) each went through its own PR review; I read their commit messages and checked the two that touch this PR's files.
  • Read in full: 8 reviews, 7 comments, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review, and what I did about each:
    • Merge commit 6da75839: read the full diff of the branch's own files across the merge (app.js, savings.js, style.css, both test files, docs/dashboard.md) and the code around each change. Only app.js changed, in two places.
    • Reviewer 2's round-4 review (13:17:16, posted 34 s before my round-4 post, so it was not in my round-4 snapshot): read it now in full. Verdict approve. Its verification of tokenFigure and pageFiltered matches mine; it adds one detail I re-checked, that state.filter can also hold a project key — pageFiltered's generic check counts it, so no narrowing filter is missed. Nothing to act on.
    • PR body: read it back and diffed it against my round-4 copy. Unchanged.
  • The one hand resolution. dash/ui/app.js:1896-1900: the merge keeps main's "Not counted in Your preset." on the Tool deferral card's what-text and this branch's saving('saved-defer-usd', parts.defer, ft && ft.defer, true) cell. Both intents survive. The kept claim is also true in the token view: featureTokens puts tooldefer in its own group, outside the Preset card's group, so the deferral's tokens are not counted in the Preset card either.
  • The merge's other app.js change is #720's warm-sweep reason labels in REASON_TEXT. The subscription view does not read them. No interaction.
  • The interaction with #1003 (the defer split, merged through this merge): it moves deferral dollars from "Your preset" to "Tool deferral" on the priced rows. The token view is unaffected: by_feature still carries tooldefer as its own key, so the cards-add-up invariant and the defer card's tokens hold as before.
  • The interaction with #1002 (the repricing, the new base): I checked whether a repriced row could turn into a false "measured zero". It cannot. tokens_unmeasured_requests counts rows with acc_priced = 0 (dash/acctokens.go, unmeasuredTerm), and dash/reprice.go never writes acc_priced — it sets token_accounting=complete and the dollar columns only. So the zero rule's premise is untouched.
  • Verified the Go pins from TestOverviewSubscriptionHeadlineIsWired still sit on code lines: the merge touched only the defer card's what-text (line 1899) and REASON_TEXT (line 2345+), far from every pinned line.
  • Verified the branch's other files are byte-identical to round 4's head: the merge diff shows no change to savings.js, style.css, savings.test.mjs, savingsparts_test.go, docs/dashboard.md.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 5 of 6 6da758398741 approve

Verdict: approve

Findings

None.

Earlier findings and notes

  • Round 1/2, the estimate cap — still fixed. The merge did not touch fiveHourSavedPct or any of savings.js; the file is byte-identical to the round-4 head.
  • My round-4 non-blocking notes — unchanged, still open as accepted: the estimate line does not say its age; tokenFigure's measured flag waits for #1041 and #1042.
  • Reviewer 1's round-4 notes — unchanged. Their two token figures beside each other (presentation choice) and the estimate's age stand. I agree with both.
  • No earlier finding was rejected.

What the new commit does, and what I verified

The branch has one new commit: 6da75839, a merge of origin/main (87b29db). The PR's own files are otherwise unchanged: savings.js, savings.test.mjs, savingsparts_test.go, docs/dashboard.md and style.css are not in the merge diff. What I checked:

  • The one conflict (dash/ui/app.js, the Tool deferral card). The merge keeps main's "Not counted in Your preset." sentence (from #1003, which moved the deferral dollars out of the preset's saving) and this branch's saving(...) cell (the subscription token view). Both sit on the merged line and read together correctly. The card's gate parts.defer !== 0 || (ft && hasTokens(ft.defer)) is unchanged.
  • #1003 (tool deferral priced by the library) — the main change that touches this PR's view. The library now prices deferral from the bodies, under the component name tooldefer (DeferComponent). That is exactly the key this PR's featureTokens maps to the Tool deferral card, so the subscription card can now show a token figure where before #1003 it always read "not measured". No double count: by_feature["tooldefer"] is its own entry, and the Preset card's bucket is "every other entry", so the token view keeps the deferral out of the preset — the same split the new card text states for dollars. The baseline loses deferFig, so the dollar side does not count it twice either.
  • #1002 (reprice loop) — no effect on this PR's figures. dash/reprice.go updates only cost_usd, baseline_cost_usd, cache_saved_usd, billed_token_factor and token_accounting. It does not touch acc_priced, the tok_* columns or keepalive, so tokens_unmeasured_requests and every token figure this PR reads are unchanged by repricing.
  • #720 (sweep warm path) — falls in the existing buckets. It adds sweep reason labels to REASON_TEXT in app.js and warm counters to the sweep ledger, but no new by_feature key and no new card. A sweep component's tokens land in the Preset bucket ("every other entry"), so the partition stays exhaustive and the cards still add up to the total.
  • The column changes in dash/query.go and dash/store.go (defer_cost_usd, sweep_false_expands_warm) insert the new columns before the token columns in both the SELECT list and the INSERT list, with the scan targets and args in the same order. requestTokenSelect, requestTokenDest and requestStoredTokenArgs are untouched.
  • All 12 wiring pins in TestOverviewSubscriptionHeadlineIsWired still sit on code lines of the merged app.js (I grepped each string; every one matches). The merge changed no pinned line.
  • docs/dashboard.md is unchanged and still accurate: the card list ("Tool deferral: tooldefer", "Preset: every other entry") matches the merged server, and the zero rule's premise (a zero feature is left out of by_feature) still holds.

Non-blocking

  • The Tool deferral card's description on the token view. The merged text ends "Net of the names list and the searches. Not counted in Your preset." On a subscription the card shows by_feature["tooldefer"]: saved = the definitions left out, cost = the names list growth. The searches come back in the response, so they have no request-token figure at all. The sentence is exact for the dollar view and approximate for the token view. Wording only; the Cache card's subscription info text shows the pattern to follow if the author wants it.
  • Reviewer 1's carried notes stand: two token figures beside each other on the Preset and Filter cards, and the estimate line's age.

What I checked

  • Last review: round 4, 407534d, 2026-11-10T13:17:16Z.
  • New commits read: 1 (6da75839 Merge origin/main into feat/dash-subscription). git log --first-parent 407534d1..HEAD lists exactly this one commit.
  • Read in full: 9 reviews, 7 comments, 0 inline comments (from the three files).
  • New items since my last review, and what I did about each:
    • Reviewer 1's round-4 review (13:17:50, approve): read in full. Nothing addressed to me; their carried notes match mine.
    • Merge 6da75839 (the base moved from 7fd26dcd to 87b29db): read the conflict resolution (git show), then git diff 407534d1..HEAD for every dash file the merge changed — app.js, tools.js, overview.go, query.go, store.go, sweepattr.go, event.go, accountant_price.go — and dash/reprice.go in full. Confirmed savings.js, both test files and docs/dashboard.md are absent from that diff (unchanged).
    • The main commits the merge carries (#1002, #1003, #720, #1046 and the plugin/Pi/test PRs) were each reviewed in their own PRs; I read the three that touch this PR's data (#1002, #1003, #720) at the level of their interaction with the subscription view, as described above.
  • Verified all 12 wiring-pin strings from savingsparts_test.go against the merged app.js — all match.
  • Verified the merged defer card line in the final tree (app.js:1897-1900): both parents' changes present, gate unchanged.
  • Checked the data-dependence rows the merge touched (#1002, #1003, #720 updated their own rows); this PR's row is unchanged.
  • I ran nothing — live tests are not approved. The author's merge message and the main PRs' comments report ./dash/... green on the merged tree.

No conflicts. Second merge, after 6da7583 landed on the branch.
Earlier hand resolution (Tool deferral card in dash/ui/app.js) is kept
by 6da7583 and is intact.

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

Copy link
Copy Markdown
Collaborator Author

The approval of 6da7583 still counts.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged origin/main into this branch (head 138324a). No rebase.

Hand resolution (1 file, 1 line)

Adapted fields: none.

Semantic check

  • No function defined twice in dash/ui/app.js. The two kv definitions are on main too.
  • go vet ./... passes. node --check passes.

Tests (shared box, -race)

  • ./dash/... first merge: both halves pass.
  • After the second merge of main: go vet and the dashboard subset pass.
  • A second merge was needed because 6da7583 landed on the branch during the work.

@amiddavid
amiddavid merged commit 6b6aa0d into main Nov 10, 2026
9 checks passed
amiddavid added a commit that referenced this pull request Nov 10, 2026
It carries the main changes #988 took before its squash merge.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 10, 2026
#988 is now on main as a squash. Each conflicted file was unchanged on
main since the #988 head 138324a, so this branch keeps its own version.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 10, 2026
It carries the main changes #988 took before its squash merge.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 10, 2026
#988 is now on main as a squash. Each conflicted file was unchanged on
main since the #988 head 138324a, so this branch keeps its own version.

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

On a Claude subscription, the dashboard Cache strategy tab shows the
measured rescue and the ping cost in tokens, by tier, not dollars.
The source is the accountant's tier tokens stored by #999. The
forecast, "Ahead"/"Behind", the winner/loser split and the "costs more
than it saves" banner keep the same dollar rule, and say they are at
API-price weights. A ledger with no token rows shows "saved 0 tokens"
and the "not measured" note. Fixes #1022.

Behavior change: members and local proxies on a Claude subscription
(/api/me/limits says subscription: true, or a 5-hour window is open).
Old: every measured figure in dollars. New: tokens by tier, as above.
Managers, API-key, Bedrock and Vertex users and hosted mode keep
dollars. No switch; it follows the subscription signal, as #988 does.
Owner's yes, 2026-11-11, in the integrator session: "1042 has my approval".

Data dependence: metadata only (token counts by tier, already stored
by #999). No change at any storage level.

Reviews: 2 offload reviews (GLM), round 5 (owner granted it), both
approve at f893c22; round 5 confirmed the PR's own change is
byte-identical to the round-4 approval at 6b586a6. After it: a merge
of main with no hand resolution (remerge-diff 0), tested on the
merged tree.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
…1041)

On a Claude subscription, the Sessions tab shows tokens, not dollars,
in its three dollar columns: Cost becomes Tokens used, Net saved
becomes Tokens saved (a dagger marks a session with unmeasured
requests), and Keep-alive net becomes Keep-alive, with the pings on a
line of their own, never added into a total. /api/sessions adds five
fields to each row for every caller: tokens, keepalive_tokens,
keepalive_ping_tokens, used_tokens and tokens_unmeasured_requests.
One formatter, sessionTokenCells in savings.js, reuses #988's
helpers. Closes #1023.

Behavior change: only the one #1023 asks for: on a subscription the
Sessions tab shows tokens. Managers, API-key users and hosted mode
(#997) keep dollars.
Owner's yes, 2026-11-11, in the integrator session: "#1041 (Sessions tab): approved, but merge it after #1042".

Data dependence: metadata only (token counts by tier, already stored
by #999). No change at any storage level.

Reviews: 2 offload reviews (GLM), round 4 (pre-approved by the
owner), both approve at 7e454bc. Round 4 reviewed the merge of main
after #1042, which kept both sides by hand in dash/ui/savings.js,
dash/savings.test.mjs, dash/savingsparts_test.go and
docs/dashboard.md.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
On a Claude subscription with enough history, the dashboard learns how
the 5-hour limit weighs each token tier, and uses those weights in
place of API prices for two figures: the Overview's 5-hour estimate
(#988) and the Cache strategy tab's yes/no forecast and range (#1042).

- dash/fivehourfit.go: a pure Go fit, one non-negative weight per tier
  (input, cache read, 5-minute write, 1-hour write, output), from the
  stored 5-hour share and the billed tokens by tier. Change points
  remove most whole-percent rounding; spans with outside traffic are
  dropped by a robust residual test. A tier it cannot learn takes its
  API price, scaled to the account's spend.
- The gate: at least 200 requests, 3 windows and 30 spans, fit error at
  most 0.25, and a learned cache-read and cache-write weight.
- GET /api/me/fivehour-weights serves the fit for the caller's own
  account, cached 15 minutes.
- No real data was available; the fit was tested on synthetic data.

Behavior change: members and local proxies on a Claude subscription,
only after the fit passes its gate. Old: "estimate at API-price
weights". New: "estimate at learned 5-hour weights (from N requests)".
Below the gate or on any error, both figures and labels stay as
before. Managers, API-key, Bedrock, Vertex and hosted users see no
change. No switch: a fit that fails the gate is the off state.
Owner's yes, 2026-11-11: "#1068 (Fixes #1047, learned 5-hour weights):
approved." Data dependence: metadata only (shares, token counts and the
model per row); docs/data-dependence.md row "Decided by: David Amid,
#1047 (2026-11-11)".

Fixes #1047.

Reviews: 5 offload review rounds (GLM). Round 5: both approve at
57d38f7, which is the PR head (a merge of main with an empty
remerge-diff).

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: on a subscription show saved tokens, with the 5-hour share as an estimate

1 participant