Repository navigation
feat(cost): subscription usage outlook and quota forecasting (#870) - #943
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 (4)
📝 WalkthroughWalkthroughThis PR introduces a complete cost forecasting feature for subscription usage tracking. It defines typed Pydantic data models, implements a projection pipeline that aggregates daily costs, detects anomalies, and computes burn rates, then wires a new CLI command to fetch archived conversation summaries and render forecasts as JSON or formatted text. ChangesCost Forecast Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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: 40c2c76e2d
ℹ️ 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".
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
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
…rift (#944) (#959) ## Summary Restore the local verification baseline to green (format/lint/mypy/render/topology/budgets/manifests) and reconcile partially-implemented closed-scope work. Pytest goes from 346 failures to 0 (5859 passed, 1 pre-existing xfail). ## Problem `devtools verify --quick` was red across every gate. 95 mypy errors. 10 topology orphans. 346 test failures. Several closed issues landed scaffolding without reaching product closure. The underlying causes: schema/upsert drift from the #943 cost-attribution work, FTS external-content table incompatibility with SQLite >=3.50, and config-layer rot from multiple refactors. ## Solution **Schema v12** — messages table gains `input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_write_tokens`, `model_name` to match the UPSERT SQL already referencing them. **FTS fix** — Five code paths handled `DELETE FROM messages_fts` on external-content FTS5 tables. Replaced with FTS5-safe commands (`INSERT...VALUES('delete',...)` in triggers, `AND rowid IN (SELECT id FROM messages_fts_docsize)` guard in repair SQL, `'delete-all'` in rebuild paths). **source_name propagation** — `conversation_to_record` and `save_conversation_record` now extract from `provider_meta.source`. **Config surface** — API-default-on, pruned dead keys, TOML section-key round-trip, embedding cost cap, fixed `polylogue config` CLI. **Bug fixes** — daemon facets handler async-correctness, pidfile atexit ordering, `ConversationFormatter` db_path resolution, `PlainConsole` markup handling, `compute_session_cost` import path, attachment upsert column parity. ## Verification ``` $ devtools verify --quick verify: all checks passed $ pytest --ignore=tests/integration --ignore=tests/benchmarks 5859 passed, 1 xfailed ``` 116 files changed, +1345/-1396. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
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. |
SubscriptionCycle, UsageOutlookPayload, polylogue cost CLI command.
Summary by CodeRabbit