Files
pxpipe/tests
teamchong d02a0f9baf feat(dashboard): fold output tokens into saved_pct (full-bill framing)
effectiveCost() previously summed only input + cache_create·1.25 +
cache_read·0.10, leaving output tokens out of the cost total. The
headline saved_pct was therefore "% saved on the input-side bill"
rather than "% saved on the full upstream bill." Output is small in
absolute terms on typical Claude Code traffic (≈0.4% of cost in
the sample events.jsonl), but the framing is what matters.

Changes:
- effectiveCost gains an outputTokens parameter and sums output ×
  OUTPUT_TOKEN_RATE (=5.0, the Opus/Sonnet output:input rate ratio).
- Totals fields renamed effectiveInput* → effectiveCost* to match
  the new full-bill semantics. Same on the JSON wire:
  effective_input_*  →  effective_cost_*.
- update() now also passes the event's output_tokens into
  effectiveCost so both actual and baseline grow consistently.
- replay() effective_actual computation includes output_tokens too,
  so historical rows align with the live formula.
- Headline subtitles updated to "share of total bill saved" and
  "effective tokens (full bill)" so the unit is self-documenting.

Math invariant: output is identical in actual and baseline (the model
produces the same response regardless of prompt compression), so it
cancels in the numerator saved = baseline - actual but inflates the
denominator. saved_pct therefore moves SMALLER and more conservative
when output is non-trivial — honest whole-bill terms.

New test pins the invariant: two identical input-side runs with 100×
different output_tokens give the SAME saved_effective_tokens but
strictly different saved_pct, with the higher-output run lower.

Tests: 273 → 274 (+1). Typecheck + build clean.
2026-05-19 15:09:17 -04:00
..