Repository navigation
feat(maintenance): typed scope filters (#1196) - #1323
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 (17)
✨ 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 |
Replace the always-empty JSONDocument `MaintenanceScope.filter` with a typed `MaintenanceScopeFilter` Pydantic model carrying the named scope dimensions called out in #996 AC #1: `conversation_ids`, `provider`, `source_family`, `source_root`, `raw_artifact_id`, `time_range`, `failure_kind`, `parser_version`. The typed filter is plumbed through: - planner `preview_backfill` / `execute_backfill` accept `scope_filter` and surface it on the returned `BackfillOperation.scope`; - replay `execute_replay` forwards the filter to per-target repair dispatch; `repair_session_insights` now honors `conversation_ids` so a one-session scope only rebuilds that session; - CLI `polylogue maintenance plan` / `run` gain `--conversation-id` (repeatable), `--provider`, `--source-family`, `--source-root`, `--raw-artifact`, `--since`/`--until`, `--failure-kind`, `--parser-version`; - daemon HTTP `POST /api/maintenance/{plan,run}` parse the same fields from the body (both nested `scope.filter` and flat top-level shapes); - MCP `maintenance_preview` / `maintenance_execute` expose typed parameters mirroring the CLI flags; - the shared `MaintenanceOperationEnvelope` serializes the typed filter so every surface emits byte-identical JSON. `MaintenanceScope.from_dict` round-trips the typed filter back through the boundary. `tests/unit/maintenance/test_scope_filter.py` pins: - field/frozen-ness/extra-field-rejection contract on `MaintenanceScopeFilter`; - `to_dict`/`from_dict` round-trip across every dimension combination; - planner attaches the filter to the returned scope and narrows `affected_rows` when `conversation_ids` shrinks the scope; - cross-surface parity — CLI, daemon HTTP, MCP all serialize the same typed filter to the same envelope payload. P2 maintenance pipeline foundation — #1195/#1197/#1198 depend on this typed contract. Closes #1196 Ref #996 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
878f5b7 to
3ea0b03
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 878f5b7183
ℹ️ 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".
|
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
Replace the always-empty
JSONDocumentfilter onMaintenanceScopewith a typedMaintenanceScopeFilterPydantic model carrying the named scope dimensions called out in #996 AC #1, and plumb it through every maintenance surface (CLI, daemon HTTP, MCP) so the same shape round-trips end to end.Problem
polylogue/maintenance/planner.pydefinedMaintenanceScopewithtargets: tuple[str, ...]and a free-formfilter: JSONDocument. No surface (CLI maintenance plan/run,/api/maintenance/plan,/api/maintenance/run, MCPmaintenance_preview/maintenance_execute) accepted or emitted any filter content — the filter was always{}. #996 AC #1 explicitly requires the planner to "enumerate candidate replay scopes by source root, raw artifact, provider/source family, failure kind, parser/materializer version, time range." None of those dimensions were reachable, and the P2 follow-ups (#1195/#1197/#1198) depend on having this typed contract first.Solution
polylogue/maintenance/scope.pydefinesMaintenanceScopeFilter(frozen Pydantic model,extra="forbid") with eight typed dimensions:conversation_ids,provider,source_family,source_root,raw_artifact_id,time_range,failure_kind,parser_version. The model exposesto_dict/from_dictfor surface round-trips andis_empty()for fast-path checks.MaintenanceScope.filteris the typed model (no longerJSONDocument);MaintenanceScope.from_dictround-trips the typed filter back from a JSON payload.preview_backfill,execute_backfill, andexecute_replayall acceptscope_filter=...and surface it on the returnedBackfillOperation.scope. Preview narrowsaffected_rowswhenconversation_idsis set; replay forwards the filter into the per-target dispatch.repair_session_insightslearns to honorconversation_ids, narrowing the rebuild to that conversation set instead of touching the full archive.polylogue maintenance plan/rungain--conversation-id(repeatable),--provider,--source-family,--source-root,--raw-artifact,--since/--until,--failure-kind,--parser-version. The CLI parsing helper is shared so plan and run cannot drift.POST /api/maintenance/{plan,run}parse the same fields from the body. Both a nested{"scope":{"filter":{...}}}envelope and a flat top-level shape are accepted; invalid filters return 400.maintenance_preview/maintenance_executeexpose typed parameters mirroring the CLI flags.MaintenanceOperationEnvelope.scope.filtercarries the typed filter dict so CLI, daemon HTTP, and MCP all emit byte-identical JSON for the same operation.MaintenanceScopePayload's docstring now points at the typed model as the contract source.polylogue/maintenance/cost_migration.pyis migrated off the legacy free-form filter ontoMaintenanceScopeFilter(conversation_ids=...). The legacycost_basis/dry_runfields are kept on per-result rows where they belong.Non-honored dimensions (everything other than
conversation_idsonsession_insights) pass through the executor unchanged: each repair fn that learns to narrow on a new dimension pins that dimension's contract — the typed envelope is the place where each future PR (#1195/#1197/#1198) plugs in.Verification
python -m pytest tests/unit/maintenance/ tests/unit/cli/test_maintenance_registration.py tests/unit/daemon/test_maintenance_endpoints.py tests/unit/mcp/ tests/unit/cost/test_contract_suite.py -q→ 370 passed.devtools verify --quick→exit_code: 0(format, ruff, mypy strict, render-all check, all manifest/lint gates).tests/unit/maintenance/test_scope_filter.pycovers: field/frozen-ness/extra-field-rejection contract on the model;to_dict/from_dictround-trip across every dimension combination; planner attaches the filter to the returned scope;affected_rowsshrinks whenconversation_idsnarrows the scope; cross-surface parity — CLI, daemon HTTP, MCP all serialize the same typed filter to the same envelope payload.tests/data/witnesses/mcp-tool-schemas.jsonregenerated for the new MCP tool parameters.Closes #1196
Ref #996
🤖 Generated with Claude Code