Repository navigation
Track service tier and Codex credit consumption - #526
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements tracking and estimation of Codex credits and service tiers for provider calls. It adds fields to the TokenCountEvent protocol, updates the session runtime to populate these fields, introduces a new database migration (0005_usage_codex_credits.sql) with tables and views for credit rates, policies, and summaries, and adds comprehensive test coverage. The review feedback highlights three key areas for improvement: failing closed when fast_mode_used is unknown by avoiding a default speed mode, optimizing the SQL query by combining the rate_matches and model_matches CTEs, and resolving potential test flakiness caused by asserting on non-deterministic group_concat outputs in SQLite.
Summary
Rate-card handling
Fast requests use the
priorityservice tier. Codex credit rates remain versioned by model and effective date rather than applying one global multiplier. GPT-5.6 Fast rows use the current 2.5x Codex rate card; API-key Priority traffic remains outside the Codex-credit estimate view.Sources:
Validation
GitHub-hosted validation only (no local Rust compute), exact head
fab6ca8e5f6173062c55d37e90ef2a48087894a8:A comparison run on the unchanged base identified a pre-existing clippy failure; this branch includes the minimal lint correction required for the full suite to evaluate successfully: