Repository navigation
feat(insights): cost tracking with tokenizer, subscription pricing (#803) - #938
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR introduces session cost computation infrastructure for tracking conversation message costs with provider-reported or heuristic token estimation, subscription-aware credit calculations, and maintenance CLI/backend APIs for database backfill operations across multiple modules. ChangesSession Cost Tracking and Maintenance Infrastructure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe22590204
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Implements the trustworthy accounting substrate that #803 needs before the user-facing subscription outlook can be built. The previous cost-estimation path could not answer which model each assistant turn used, how tokens broke down across input / output / cached input / cache creation / reasoning / tools / multimodal, which numbers were provider-reported facts vs tokenizer-derived estimates, or what API-equivalent USD vs Claude Code subscription credits were consumed. - `archive/semantic/cost_compute.py`, `cost_records.py`, `subscription_pricing.py`: typed cost computation with per-model token classes, USD pricing estimates, subscription credit pricing, and explicit provenance fields distinguishing exact facts from estimates. - `archive/semantic/tokenizer.py`: client-side tokenizer fallback when provider metrics are missing. - `cli/commands/maintenance.py` and `maintenance/planner.py`: preview/execute hooks so cost recomputation is a maintenance operation, not a one-shot script. Refs #803
Polylogue's cost work was geared toward API billing logs, but the common local-chat/export use case has no provider-reported cost. The primary product value is subscription-oriented: plan cycle, estimated burn, quota/rate-limit pressure, model usage, anomaly detection, and what consumed the user's practical allowance. - Adds `polylogue/archive/semantic/outlook.py` and `subscription_models.py` defining `SubscriptionCycle` and the `UsageOutlookPayload` so cost data has a typed shape that can describe a plan cycle, not just per-API-call totals. - Wires a `polylogue cost` CLI command via `cli/click_command_registration.py` and `cli/commands/cost.py` so the outlook surface is reachable from the user CLI without going through ad-hoc reporting scripts. Builds on the cost-tracking substrate from #803 (PR #938) which supplies model assignment, token classes, and cost basis. Refs #870
Implements the trustworthy accounting substrate that #803 needs before the user-facing subscription outlook can be built. The previous cost-estimation path could not answer which model each assistant turn used, how tokens broke down across input / output / cached input / cache creation / reasoning / tools / multimodal, which numbers were provider-reported facts vs tokenizer-derived estimates, or what API-equivalent USD vs Claude Code subscription credits were consumed. - `archive/semantic/cost_compute.py`, `cost_records.py`, `subscription_pricing.py`: typed cost computation with per-model token classes, USD pricing estimates, subscription credit pricing, and explicit provenance fields distinguishing exact facts from estimates. - `archive/semantic/tokenizer.py`: client-side tokenizer fallback when provider metrics are missing. - `cli/commands/maintenance.py` and `maintenance/planner.py`: preview/execute hooks so cost recomputation is a maintenance operation, not a one-shot script. Refs #803
Polylogue's cost work was geared toward API billing logs, but the common local-chat/export use case has no provider-reported cost. The primary product value is subscription-oriented: plan cycle, estimated burn, quota/rate-limit pressure, model usage, anomaly detection, and what consumed the user's practical allowance. - Adds `polylogue/archive/semantic/outlook.py` and `subscription_models.py` defining `SubscriptionCycle` and the `UsageOutlookPayload` so cost data has a typed shape that can describe a plan cycle, not just per-API-call totals. - Wires a `polylogue cost` CLI command via `cli/click_command_registration.py` and `cli/commands/cost.py` so the outlook surface is reachable from the user CLI without going through ad-hoc reporting scripts. Builds on the cost-tracking substrate from #803 (PR #938) which supplies model assignment, token classes, and cost basis. Refs #870
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Token columns, cost models, credit pricing. 23 files.
Summary by CodeRabbit
Release Notes
New Features