Skip to content

fix: deterministic demo, LLM fallback, engine provenance, pricing/ROI footer - #4

Merged
nitrimandylis merged 3 commits into
mainfrom
claude/cost-analysis-demo-fixes-gps25h
Aug 6, 2026
Merged

fix: deterministic demo, LLM fallback, engine provenance, pricing/ROI footer#4
nitrimandylis merged 3 commits into
mainfrom
claude/cost-analysis-demo-fixes-gps25h

Conversation

@nitrimandylis

@nitrimandylis nitrimandylis commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Demo-hardening fixes from the v2 plan (#3): the demo never depends on a live key, the rules keep computing the money, and every report says which engine produced it.

  • Step 1 — Deterministic demo mode: fixed seed (DEMO_SEED = 20260717) threaded through all demoAnthropic/demoOpenAI calls instead of Date.now(), so one demo run is one coherent org with a stable 6-month trend and hero savings number. Vitest test asserts two full 6-month runs produce byte-identical reports.
  • Step 2 — Graceful LLM degradation: analyzeWithFallback wraps findIssuesLLM; any failure falls back to the deterministic rule engine and stamps a visible "LLM unavailable, showing deterministic analysis" notice on the report. Test forces the LLM call to throw and asserts the rules ran and the notice is set.
  • Step 3 — Engine provenance: engine: "rules" | "llm" added to the stored report, set at every report-producing site (home analysis, demo, recommendations month-fetch, analytics year-fetch, and the Step 2 fallback), and shown as a badge in the recommendations report header. Toggle behavior unchanged (LLM still replaces rules when on).
  • Step 4 — Always-visible pricing date: "Prices as of 2026-06-14" line in the recommendations report footer; the existing >90-day staleness warning stays.
  • Step 5 — ROI footer: the NIM response usage field is now parsed, costed, and stored on the report; LLM-engine reports render a footer line comparing the analysis token cost to the identified monthly savings. Omitted on rules-engine reports.

Verification: npm run type-check, npm run lint, npm run format:check, npm test all pass — 52 tests (46 existing + 6 new).

claude added 3 commits August 5, 2026 20:32
Replace Date.now() PRNG seeding in demoAnthropic/demoOpenAI with a fixed
default seed (DEMO_SEED = 20260717) accepted as a parameter, so one demo run
generates one coherent org, a real 6-month trend, and an identical hero
savings number on every run. Add a determinism test asserting two full
6-month demo runs produce byte-identical reports.
findIssuesLLM now returns findings plus the NIM call's own token usage
(with an estimated cost for the ROI footer). New analyzeWithFallback wrapper
runs the LLM path and, on any failure, falls back to the deterministic rule
engine and stamps a visible notice on the report. Reports gain optional
engine ('rules' | 'llm'), notice, and llmUsage fields; the home page stamps
them everywhere it builds a report and threads DEMO_SEED through demo calls.
Add a test forcing the LLM call to throw, asserting the rules ran and the
notice is set.
Recommendations page: engine badge in the report header ('Rule engine' /
'LLM analysis'), a banner when the report carries a fallback notice, an
always-visible 'Prices as of <date>' footer line (the 90-day staleness
warning stays), and an ROI footer line on LLM-engine reports comparing the
analysis token cost to the identified monthly savings. Month-fetch paths on
the recommendations and analytics pages stamp engine: 'rules'.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokenpilot Ready Ready Preview Aug 5, 2026 8:33pm

@nitrimandylis
nitrimandylis merged commit 9f25ae2 into main Aug 6, 2026
3 checks passed
@nitrimandylis
nitrimandylis deleted the claude/cost-analysis-demo-fixes-gps25h branch August 6, 2026 07:52
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.

2 participants