SIGN IN SIGN UP

feat(token-usage): extract request speed / Codex service tier per entry

UsageEntry's has_speed dedup marker becomes speed: Option<Speed> plus a
speed_inferred flag, and entries carry which of ccusage's two cost
formulas prices them (pricing_shape), so the cost side can apply fast
multipliers and per-shape tiering. Replacement-policy semantics are
unchanged (a present marker still breaks ties).

Codex now records the service tier: thread_settings_applied events set
a sticky tier exactly like ccusage's parser (an event without a
service_tier says nothing; a present-but-unknown value resets rather
than inheriting stale state; default/standard and fast/priority map as
spelling pairs). Unmarked entries resolve through an injected fallback
read from the rollout's codex-home config.toml (ccusage's auto speed
policy) — resolved by the worker per pass and cached by config mtime,
never per line — else standard, with speed_inferred recording that the
tier did not come from the transcript. Unlike ccusage, resolution
happens at extraction time and is stored, so a later config change
never retroactively reprices history.

The token database's v3 schema is a pre-release rebuild adding the
per-entry pricing dimensions (speed, speed_inferred, the 1h cache-write
split, transcript-vs-catalog cost provenance, and columns for the
long-context decision and catalog id that the tiered cost change will
write). Dropping the cursors makes the next pass re-extract every
transcript under the new rules; dedup keeps that idempotent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
S
Sasha Varlamov committed
bf08e5ffd8b50c49a11d65e4a1eb795ba9596a6f
Parent: 564e92c