feat(token-usage): speed-keyed buckets and repricing fields on the wire
Fast and standard usage of one model bill at different rates, so speed (0 standard, 1 fast) joins the bucket identity: bucket_state is keyed by (session_id, model, speed, bucket_ts) (schema v4 rebuilds just that table; entries and cursors survive) and aggregation groups by the entry's speed, with unmarked entries falling into the standard bucket. TokenUsage events gain positions 11-19 so the server can recompute a bucket's cost under a different pricing sheet: speed and whether it was inferred from configuration, the 1h cache-write split, the long-context token splits per class (tokens of requests that selected their model's long-context tier; whole-request selection already applied client-side, base-tier tokens are the totals minus these), and the transcript-priced portion of the cost, which is fixed under repricing (its tokens remain in the totals, so such buckets reprice approximately). The pricing catalog id rides custom_attributes on catalog-priced buckets. The bucket fingerprint covers every new emitted value, so any split changing re-emits the bucket at a higher revision; the catalog id alone is deliberately excluded (an id change without numeric change means identical rates). The spec's value table, bucket identity, and pricing sections are updated accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
S
Sasha Varlamov committed
5c6f2f4474493914fc0813cb09cac2d886f2091c
Parent: e0b68c9