Repository navigation
feat(insights): declare readiness/cost/degraded contracts for default projections - #3198
Conversation
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughAdds centralized projection readiness contracts and typed availability payloads for facets and cost-outlook analysis. Archive and CLI paths now report timing, cost, budget, prerequisites, and degraded or unavailable states, with updated tests and generated topology metadata. ChangesProjection readiness
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Archive
participant Contracts
participant Response
CLI->>Archive: request facets or cost-outlook analysis
Archive->>Archive: measure projection duration
Archive->>Contracts: compute availability state
Contracts-->>Archive: return readiness and budget metadata
Archive->>Response: serialize projection result and availability
Response-->>CLI: render JSON or terminal output
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 0e6a85b10f
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/cli/query_verbs.py`:
- Around line 154-165: The availability detail in the response-rendering block
currently sends Rich markup through click.echo, causing tags to display
literally. Update the avail.detail output in the query result display flow to
use the existing Rich console or click styling mechanism so the yellow
formatting renders correctly, while preserving the conditional output and
message text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5936011d-91e2-4d1a-b146-d2908f5d5789
📒 Files selected for processing (12)
docs/plans/topology-target.yamldocs/topology-status.mdpolylogue/api/archive.pypolylogue/cli/query_verbs.pypolylogue/insights/projection_contracts.pypolylogue/surfaces/payloads.pytests/unit/cli/__snapshots__/test_plain_cli_snapshots.ambrtests/unit/cli/test_click_app.pytests/unit/cli/test_cost_outlook_cli.pytests/unit/cli/test_plain_cli_snapshots.pytests/unit/daemon/test_web_reader.pytests/unit/insights/test_projection_contracts.py
…s in plain output CodeRabbit review fixes on #3198: (1) successful --cost-outlook JSON no longer nests the documented CycleOutlook envelope under 'outlook' — availability is additive alongside the existing top-level fields; (2) a deadline-exceeding plain run now prints the degraded readiness line before rendering the outlook instead of silently reporting success; (3) availability detail renders via click.secho instead of literal Rich markup.
|
All three CodeRabbit findings addressed in d7b5487: (1) successful --cost-outlook JSON keeps the documented CycleOutlook envelope top-level with availability additive; (2) plain output now prints the degraded readiness line (with elapsed/deadline) before rendering the outlook, covered by a new test; (3) availability detail renders via click.secho instead of literal Rich markup. |
…eceipts; add 6qjc judgment-automation bead
… projections
Problem: two production smokes exposed one missing contract on default
analysis projections. `analyze --cost-outlook` returned a syntactically
valid but operationally useless `null` with only an ad hoc `reason:
no_cycle_anchor` key and no remediation when a plan had no
`cycle_anchor_day`. `analyze --facets` took 17.8s with no signal that a
"cheap default" projection had blown any budget.
What changed:
- New `polylogue.insights.projection_contracts` registry declares, per
default projection, its cost/detail class (cheap/expensive), default
interactive deadline, and prerequisites with remediation text
(`cost-outlook`, `facets`, `facets-deferred`).
- New shared `ProjectionAvailabilityPayload`/`ProjectionPrerequisitePayload`
envelope (`polylogue/surfaces/payloads.py`) reports state
(ready/degraded/unavailable), reason, remediation, and measured
cost (deadline_s/elapsed_s/budget_exceeded) alongside a projection's data.
- `Polylogue.facets()` now measures wall-clock execution and reports the
declared cost class/deadline/elapsed/budget_exceeded on `FacetsResponse`
(`cost_class`, `deadline_s`, `elapsed_s`, `availability`); this
automatically reaches the `/api/facets` daemon/HTTP route since it
serializes the same response model.
- `analyze --cost-outlook` (CLI) replaces the ad hoc `{"reason":
"no_cycle_anchor"}` dict with the typed `availability` envelope on both
the missing-prerequisite and success paths, in JSON and plain-text output.
- `--explain` on `analyze --facets`/`--cost-outlook` surfaces the declared
contract (cost class, deadline, prerequisites) via the existing terminal
pipeline `args` payload.
Deferred (documented, not silently dropped):
- Bounded/resumable execution for expensive facet families is explicitly
out of scope here — that QoS mechanism belongs to the shared query
transaction (polylogue-z9gh.9). Expensive families satisfy AC #3's
"opt-in, or a bounded resumable reference" via the existing
`--include-deferred` opt-in gate, not a new resumable-reference type.
- MCP: no `cost_outlook`/`facets` MCP tool exists today (the standalone
`cost_outlook` tool was retired in polylogue-t46.8/#3095, tracked for a
design decision in polylogue-hg97), so there is nothing to wire there yet.
- Other `analyze` modes (count/by/postmortem/portfolio) have no declared
contract; `--explain` intentionally omits `projection_contract` for them
rather than fabricating one.
Verification:
- `devtools test tests/unit/insights/test_projection_contracts.py
tests/unit/cli/test_cost_outlook_cli.py tests/unit/cli/test_click_app.py
tests/unit/cli/test_plain_cli_snapshots.py` — 121 passed (the only
failures are `test_json_status_snapshot`, pre-existing drift unrelated to
this diff, and 8 `sqlite3.OperationalError: database is locked` errors in
postmortem/portfolio tests caused by a concurrent sibling worktree's
`devtools verify --seed-testmon` contending on the shared
`/dev/shm`/`/realm/tmp/polylogue-pytest` seeded-db cache).
- `devtools test tests/unit/daemon/test_web_reader.py -k facets` — 19
passed (route/facade parity test updated to also strip the now-volatile
`elapsed_s` wall-clock field, same treatment as the existing
`generated_at` exclusion).
- `mypy --strict` on touched files — clean.
- `devtools render all --check` — sync OK (new payload models picked up by
generated `cli-output-schemas`/`openapi` without extra registration; new
module regenerated `docs/plans/topology-target.yaml`).
- `devtools verify --quick` — exit 0.
Ref polylogue-duti
Co-Authored-By: Claude <[email protected]>
…s in plain output CodeRabbit review fixes on #3198: (1) successful --cost-outlook JSON no longer nests the documented CycleOutlook envelope under 'outlook' — availability is additive alongside the existing top-level fields; (2) a deadline-exceeding plain run now prints the degraded readiness line before rendering the outlook instead of silently reporting success; (3) availability detail renders via click.secho instead of literal Rich markup.
d7b5487 to
465b407
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. |
|
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
Default analysis projections (
analyze --facets,analyze --cost-outlook) now declare their cost/detail class, default interactive deadline, and prerequisites, and report an explicitready/degraded/unavailablestate instead of an opaque null or a silently slow success.Problem
Two production smokes exposed one missing
ProjectionSpeccontract (polylogue-duti):analyze --cost-outlookreturned a syntactically valid but operationally uselessnull(with only an ad hoc{"reason": "no_cycle_anchor"}key) when a plan had nocycle_anchor_day— no typed remediation.analyze --facetstook 17.8s with no signal that a "cheap default" projection had blown any budget.Solution
polylogue.insights.projection_contractsregistry:ProjectionContractdeclares cost class (cheap/expensive), default interactive deadline, and prerequisites with remediation forcost-outlook,facets, andfacets-deferred.ProjectionAvailabilityPayload/ProjectionPrerequisitePayloadenvelope (polylogue/surfaces/payloads.py):state(ready/degraded/unavailable),reason,detail,remediation,deadline_s/elapsed_s/budget_exceeded, and per-prerequisite satisfaction.Polylogue.facets()measures wall-clock execution and stampscost_class/deadline_s/elapsed_s/availabilityontoFacetsResponse— this reaches the/api/facetsdaemon/HTTP route for free since it serializes the same response model.analyze --cost-outlookCLI replaces the ad hoc{"reason": "no_cycle_anchor"}dict with the typedavailabilityenvelope on both the missing-prerequisite and success paths (JSON and plain text).--explainonanalyze --facets/--cost-outlooksurfaces the declared contract (cost class, deadline, prerequisites) through the existing terminal-pipelineargspayload.Deliberately deferred (not silently dropped)
--include-deferredopt-in gate, not a new resumable-reference type.cost_outlook/facetsMCP tool exists today (the standalonecost_outlooktool was retired in polylogue-t46.8/fix(mcp): harden six-tool cutover — session correlation, status(operation), SessionStart preamble #3095; MCP cost/usage design tracked in polylogue-hg97), so there is nothing to wire yet.analyzemodes (--count,--by,--postmortem,--portfolio) have no declared contract;--explainintentionally omitsprojection_contractfor them rather than fabricating one.AC matrix (polylogue-duti)
cost-outlook,facets); otheranalyzemodes deliberately out of scope (no evidence of a smoke against them).cost-outlookwithout a cycle anchor returns a typed unavailable result with remediation across CLI and machine payloads — satisfied.facetswith default families meets its declared interactive budget; expensive families are opt-in — satisfied (opt-in already existed; this PR adds the declared deadline + measuredbudget_exceededsignal so a regression is now visible instead of silent). Resumable-reference alternative deliberately not built (see deferred above).explainexposes prerequisite/cost decisions; all surfaces adapt the same outcome — satisfied for CLI (--explain+ JSON/plain output); HTTP gets it for free via the sharedFacetsResponsemodel; MCP has no tool to adapt (deferred, tracked in polylogue-hg97).test_no_cycle_anchor_returns_json_null_outlookasserts the typed unavailable envelope;test_analyze_facets_reports_degraded_when_it_misses_its_declared_budgetmonkeypatches the clock through the real CLI route and assertsdegraded/budget_exceeded— this is a genuine mutation-proof regression test for the exact 17.8s smoke.Verification
devtools test tests/unit/insights/test_projection_contracts.py tests/unit/cli/test_cost_outlook_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_plain_cli_snapshots.py— 121 passed. Remaining failures are pre-existing/environmental:test_json_status_snapshot(unrelated drift — this PR does not touch status.py and the diff to that test file is purely additive elsewhere) and 8sqlite3.OperationalError: database is lockederrors in postmortem/portfolio tests caused by a concurrent sibling worktree'sdevtools verify --seed-testmoncontending on the shared/dev/shm//realm/tmp/polylogue-pytestseeded-db cache.devtools test tests/unit/daemon/test_web_reader.py -k facets— 19 passed (route/facade parity test updated to also strip the now-volatileelapsed_sfield, same treatment as the existinggenerated_atexclusion).mypy --stricton touched files — clean.devtools render all --check— sync OK (new payload models picked up by generatedcli-output-schemas/openapiwith no extra registration needed; new module triggered adocs/plans/topology-target.yamlregeneration).devtools verify --quick— exit 0 (also re-ran clean via the pre-push hook).Ref polylogue-duti
Summary by CodeRabbit
New Features
analyze --explain.Documentation
Tests