Semantics, durable events, and projector
Add packages/contracts/src/usage.ts (typed facts: cumulative vs interval,
cache read vs write, native identity, reset generation; typed
modelUsage), emit durable model.usage-recorded orchestration
events from ingestion, and register a usage projector with its own
projection_state cursor. Schema migration creates tables only. Tests:
live-vs-replay equivalence, restart, duplicates, abort, steering, revert retention,
deletion redaction.
Codex and Claude live capture
Preserve providerRefs, per-model usage, and exact cost through ingestion
(ClaudeAdapter already emits them on turn.completed); finalize on
turn.aborted, session exit, and steering-superseded paths, not completion
alone. Extend the snapshot contract with cache-creation tokens.
Backfill and pricing
Versioned, resumable server-side backfill job (never inside migrations, no second DB
writer): event replay via the projector's empty cursor, then provider-log parse, then
opt-in transcript enrichment — same fact IDs, explicit upsert precedence. Versioned,
effective-dated pricing catalog in shared runtime code; estimates computed at query
time, never stored as truth.
RPC and aggregation
Add usage.query, environment capability negotiation, client-runtime query
atoms, partial errors, timezone grouping, and dataset de-duplication.
Web and desktop Usage page
Add the route, sidebar affordance, summary cards, accessible SVG/CSS charts, model and
environment tables, coverage states, filters, and empty/error states.
Coverage and mobile
Add OpenCode and ACP capture, all-local opt-in, cached offline aggregates, responsive
mobile UI, and the mobile integrated verification pass.