Repository navigation
test+docs(cost): contract suite and cost model docs (#1140) - #1173
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ 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 (5)
✨ 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: 116b1848ae
ℹ️ 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".
Problem: #1140 (cost-cluster capstone for #995) required a cross-cluster contract suite, a legacy-row migration helper, and documentation of the cost basis split, subscription plans, cycle outlook, and caveats. Per- module tests for #1132/#1136/#1137/#1138/#1139 pinned focused behavior but nothing pinned the cross-contracts that any one layer could silently break (basis independence, per-model reconciliation, partial coverage, quota absence, projection monotonicity, cycle-anchor determinism, shared CLI/MCP envelope). Solution: - tests/unit/cost/test_contract_suite.py: 18 contract tests covering basis independence, exact-provider preservation, estimated-flag, per-model breakdown sum reconciles to aggregate (both total_usd and per-axis), partial status when rows unpriced, curated-seed non-authoritative notice, QuotaPressureMissing when no quota, QuotaPressure when quota declared, projection monotonicity (both primitive and full build_cycle_outlook), cycle-anchor determinism across month-end/DST, aggregation excludes unpriced/untimestamped, shared CycleOutlook envelope across API and MCP. Each assertion- bearing test records bounded contract evidence via record_contract_evidence so PR-impact reports can attribute the exercised surface. - polylogue/maintenance/cost_migration.py: planner-driven migration helper. find_legacy_cost_rows filters session_profiles rows whose cost_provenance is in the legacy marker set ({"unknown", ""}) and total_cost_usd > 0; plan_cost_migration returns a typed BackfillOperation (DERIVED_REBUILD, STALE_MATERIALIZER_VERSION, scope tagged with cost_basis=legacy-single-basis). Pure-function- shaped so the executor stays in planner.execute_backfill. - docs/cost-model.md: new page covering basis taxonomy (provider_ reported, api_equivalent, subscription_equivalent, catalog_priced, tool_surcharge — independent axes, do not sum to total_usd), status and confidence, unavailable reasons, per-model breakdown, subscription plans, cycle outlook semantics, surfaces (CLI/MCP/API share typed envelope), legacy migration path, and the non-authoritative caveat. Verification: - pytest tests/unit/cost/test_contract_suite.py -q (18 passed) - pytest tests/unit/cost/ tests/unit/insights/ tests/unit/mcp/test_cost_outlook_tool.py -q (140 passed) - pytest tests/unit/maintenance/ -q (78 passed) - mypy --strict polylogue/maintenance/cost_migration.py tests/unit/cost/test_contract_suite.py (Success) - devtools verify --quick (exit_code: 0, all gates pass) Closes #1140 Ref #995 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
116b184 to
0289e71
Compare
|
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
Capstone for the cost cluster (#995 → #1140). Adds a cross-cluster contract
suite that pins invariants no per-module test owns, a planner-driven legacy-
row migration helper, and a
docs/cost-model.mdpage documenting the basissplit, subscription plans, cycle outlook semantics, surfaces, migration, and
the non-authoritative caveat.
Problem
#1140 (the cost-cluster capstone for #995) required:
feat(cost): cycle outlook engine — burn, projection, quota pressure, overage #1137/feat(cost): expose cycle outlook through CLI and MCP #1138/refactor(cost): remove provider_meta cost fallback reads outside extractors #1139 pin focused behavior, but nothing pinned the cross
contracts that any one layer could silently break (basis independence,
per-model reconciliation, partial coverage, quota absence, projection
monotonicity, cycle-anchor determinism, shared CLI/MCP envelope).
session_profiles.total_cost_usdrowsmaterialized before the feat(cost): split cost rollup by basis (API/subscription/catalog) with per-model breakdown #1136 basis split, marked with
source = legacy-single-basis.plan configuration, projection method, and the non-vendor-authoritative
caveat. test+docs(cost): contract suite, migration of legacy rows, cost model docs #1140 ACs explicitly required
docs/cost-model.mdcover this.Solution
tests/unit/cost/test_contract_suite.py(new): 18 contract tests groupedby basis split, plan/quota, outlook projection, cycle math, aggregation,
CLI/MCP/API exposure, and migration. Each assertion-bearing test records
bounded contract evidence via the
record_contract_evidencefixture soPR-impact reports can attribute the exercised surface. MCP test exercises
the live
cost_outlooktool by building the MCP server, mocking thefacade, and asserting the typed envelope matches
polylogue.cost.outlook.CycleOutlook.polylogue/maintenance/cost_migration.py(new): planner-driven migrationhelper.
find_legacy_cost_rows(reader)filterssession_profilesrowswhose
cost_provenanceis inLEGACY_COST_PROVENANCE_MARKERS(
{"unknown", ""}) ANDtotal_cost_usd > 0.plan_cost_migrationreturnsa typed
BackfillOperationwithkind = DERIVED_REBUILD,targets = ('session_profiles',),reason = STALE_MATERIALIZER_VERSION, and a scopefilter tagged
cost_basis = legacy-single-basisplus the conversation-idlist. Pure-function-shaped — the actual rebuild executes through the
existing
polylogue.maintenance.planner.execute_backfillpath; thismodule is the bridge that classifies the work and reasons about scope.
docs/cost-model.md(new): basis taxonomy (5 independent axes that do notsum to
total_usd), status & confidence, unavailable reasons, per-modelbreakdown, subscription plans (
polylogue-curated-seedvsuser-config),cycle outlook semantics (window, burn, projected total, quota pressure,
coverage, confidence), surfaces (CLI/MCP/API share the typed envelope),
legacy migration path, and the non-authoritative caveat (with explicit
call-out that subscription quota math is not vendor-authoritative).
Topology projection (
docs/plans/topology-target.yaml) and topology statusregenerated via
devtools build-topology-projectionanddevtools render-topology-status.Verification
Closes #1140
Ref #995