Files
pxpipe/tests
teamchong 5b5f48919d fix(dashboard): correct pricing/image constants from docs.anthropic.com
Audit against published Anthropic docs (pricing + vision pages,
verified 2026-05-19 via WebFetch) found three constants in this file
that were either wrong or hand-picked without citation. Replace them
with documented values and add a PROVENANCE block so the lineage is
auditable.

Corrections:

1. saved_usd headline rate: $15/Mtok → $5/Mtok.
   Opus 4.7 base input rate per docs is $5/Mtok, not $15. The old
   value was Opus 3 pricing repurposed by the field name "_opus47".
   The headline dollar number was therefore overstated by 3× on any
   Opus 4.x deployment. Renamed field to saved_usd_estimated and
   exposed pricing_assumptions{input_per_mtok, multipliers, source}
   on /proxy-stats so the operator can verify what we multiplied by.

2. Per-image token cost: drop fixed OPUS_IMAGE_TOKEN_COST=2500 in
   favor of the published formula tokens ≈ width × height / 750
   (docs-vision). estImageTokens now prefers (in order): live β fit
   → published 1/750 → FALLBACK_IMAGE_TOKEN_COST (=1690, computed
   from the formula at our default 808×1568 render). The old 2,500
   constant traced to an in-house measurement that didn't reconcile
   with the docs; pending a fresh per-renderer-config measurement
   under post-walker-fix code.

3. FALLBACK_ALPHA point estimate: 0.25 → 0.33. Opus 4.7's tokenizer
   note in [docs-pricing] explicitly states ~35% denser than older
   models for the same text. CHARS_PER_TOKEN=4 (the older English
   average) is therefore biased for Opus 4.7 traffic; 3 chars/tok
   matches the documented behavior. The low/high brackets (0.15 /
   0.50) span both tokenizer regimes and are left alone.

Added:
- PROVENANCE comment block at the top of the pricing/image-cost
  section citing the three doc URLs and the verification date, with
  each downstream constant footnoting back to one of the labels.
- pricing_assumptions object in /proxy-stats payload exposing every
  multiplier and the source URL.
- Test pinning the pricing_assumptions shape and the
  saved_usd_estimated = saved_tokens × input_per_mtok / 1e6 identity.

What this does NOT yet correct:
- Live α and per-renderer β still require fresh measurement post-
  walker-fix. The fallback brackets keep saved_pct conservative
  until the regression converges.
- 1-hour cache writes (2× input) are exposed in pricing_assumptions
  but not yet distinguished from 5-minute writes in the cost math —
  needs an upstream signal we don't currently capture per-event.

Tests: 274 → 275 (+1). Typecheck + build clean.
2026-05-19 15:44:07 -04:00
..