Repository navigation
feat: add cost estimation products - #394
Conversation
Problem Polylogue had only a legacy session-cost float, which made provider/model cost analysis impossible to expose consistently across CLI, facade, and MCP surfaces. What changed Replace the pricing helper with typed usage, price, component, and estimate payloads backed by a curated LiteLLM-shaped seed catalog. Add session-cost and provider/model cost-rollup products to the shared product registry, facade, sync facade, operations layer, CLI reference, and MCP registry surface. Compatibility The existing harmonize_session_cost() helper remains as a compatibility adapter over the richer estimate contract. Verification passes locally. Ref #388 Co-Authored-By: Claude <[email protected]>
Problem The new cost-estimation contract needs coverage at the substrate and public product boundaries so uncertainty semantics do not regress. What changed Add pricing tests for exact provider costs, catalog-priced estimates, partial estimates, missing prices, and model normalization. Extend CLI, facade, and MCP product tests to assert session-cost and cost-rollup payloads are exposed through the shared registry surfaces. Verification bringing up nodes... bringing up nodes... ......... [100%] 9 passed in 10.67s passes locally. Success: no issues found in 10 source files passes locally. passes locally. Ref #388 Co-Authored-By: Claude <[email protected]>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 32 minutes and 49 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 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: ee8bbd3684
ℹ️ 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".
Summary Add a typed cost-estimation substrate and expose it through registry-backed archive products. Polylogue can now report session-level cost estimates and provider/model rollups through CLI, facade, sync facade, and MCP surfaces. Problem #388 asked for cost estimation across providers, models, and sessions. The repository had only a legacy `(cost_usd, is_estimated)` helper and no product contract for provenance, missing data, model normalization, or provider/model rollups. That made cost analysis ad hoc and encouraged false precision when token or price data was incomplete. Solution - replace the pricing helper internals with typed usage, price, component, and estimate payloads while preserving `harmonize_session_cost()` as a compatibility adapter - add a curated LiteLLM-shaped seed pricing catalog with explicit provenance and effective date; provider/archive-reported exact costs still win - add `session_costs` and `cost_rollups` product contracts, operations, facade methods, sync facade methods, CLI commands, and MCP tools through the shared product registry - represent estimate status as `exact`, `priced`, `partial`, or `unavailable`, with confidence and missing reasons - refresh generated CLI/quality/verification docs for the new product commands - cover exact archive cost, catalog-priced estimate, partial estimate, missing price, model normalization, CLI JSON, facade, and MCP contracts Verification - `pytest -q tests/unit/core/test_pricing.py tests/unit/cli/test_products.py::test_products_costs_json tests/unit/cli/test_products.py::test_products_cost_rollups_json tests/unit/core/test_facade_api.py::TestPolylogueArchiveProducts::test_durable_session_products_are_publicly_queryable tests/unit/mcp/test_tool_contracts.py::TestProductTools::test_product_list_tools_use_archive_queries` passed: 9 passed in 10.91s - `mypy --strict polylogue/lib/pricing.py polylogue/archive_products.py polylogue/operations/archive.py polylogue/products/registry.py polylogue/facade_products.py polylogue/sync_product_queries.py tests/unit/core/test_pricing.py tests/unit/cli/test_products.py tests/unit/core/test_facade_api.py tests/unit/mcp/test_tool_contracts.py` passed: Success, no issues found - `devtools render-all --check` passed: all generated surfaces sync OK - `devtools verify` passed: verify: all checks passed - `git push -u origin feature/feat/cost-estimation` passed pre-push quick verification: verify: all checks passed Closes #388
|
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. |
Summary
Add a typed cost-estimation substrate and expose it through registry-backed archive products. Polylogue can now report session-level cost estimates and provider/model rollups through CLI, facade, sync facade, and MCP surfaces.
Problem
#388 asked for cost estimation across providers, models, and sessions. The repository had only a legacy
(cost_usd, is_estimated)helper and no product contract for provenance, missing data, model normalization, or provider/model rollups. That made cost analysis ad hoc and encouraged false precision when token or price data was incomplete.Solution
harmonize_session_cost()as a compatibility adaptersession_costsandcost_rollupsproduct contracts, operations, facade methods, sync facade methods, CLI commands, and MCP tools through the shared product registryexact,priced,partial, orunavailable, with confidence and missing reasonsVerification
pytest -q tests/unit/core/test_pricing.py tests/unit/cli/test_products.py::test_products_costs_json tests/unit/cli/test_products.py::test_products_cost_rollups_json tests/unit/core/test_facade_api.py::TestPolylogueArchiveProducts::test_durable_session_products_are_publicly_queryable tests/unit/mcp/test_tool_contracts.py::TestProductTools::test_product_list_tools_use_archive_queriespassed: 9 passed in 10.91smypy --strict polylogue/lib/pricing.py polylogue/archive_products.py polylogue/operations/archive.py polylogue/products/registry.py polylogue/facade_products.py polylogue/sync_product_queries.py tests/unit/core/test_pricing.py tests/unit/cli/test_products.py tests/unit/core/test_facade_api.py tests/unit/mcp/test_tool_contracts.pypassed: Success, no issues founddevtools render-all --checkpassed: all generated surfaces sync OKdevtools verifypassed: verify: all checks passedgit push -u origin feature/feat/cost-estimationpassed pre-push quick verification: verify: all checks passedCloses #388