code-review: make DOMAIN_CRITIC_CAP operator-tunable - #184
Conversation
The domain-critic cap was a hardcoded 3 with no settings path, and it drops by (priority asc, reviewer asc). A repo whose critic-gates.json uses the legacy moduleCritics[] schema gets every entry migrated as required:False with no priority, so all of them sit at the default 2 and the tiebreak degenerates to alphabetical by reviewer name. That deterministically cuts the critic the coverage critic proposed FOR the diff: on two symphony-alpha cost/metric PRs, logical-metric-reconciliation-auditor was accepted by consolidate and then dropped, while api-architect, caching-strategist and database-architect survived on their first letter. Adds domain_critic_cap to code-review.json (the file that already hosts bha_unified_threshold_loc and out_of_hunk_confidence_floor), plus an --domain-critic-cap namespace override and --settings for test isolation on arbitrate-budget. Precedence mirrors bha_unified_threshold_loc: flag > settings file > built-in default. 0 is a valid kill switch (no domain critics; source:"core" reviewers stay exempt); negative and non-int values fall back to the default rather than crashing the stage. Raising the cap is the blunt remedy — the precise one is migrating rules to the canonical coverage[] schema, which supports explicit priority and required. Both are now documented in README and start.md. Tests: 9 new (5 loader validation, 4 arbitrate-budget behavior incl. precedence, the 0 kill switch, and malformed-value fallback). The shared _run_arbitrate_budget harness now always points --settings at a test-local path so a code-review.json in the CWD cannot leak into a run. Full suite 1339 passed / 3 skipped. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Beginning a code-review. Please allow time for me to finish before merging the PR |
| if ( | ||
| isinstance(raw_critic_cap, int) | ||
| and not isinstance(raw_critic_cap, bool) | ||
| and raw_critic_cap >= 0 |
There was a problem hiding this comment.
This makes review policy controllable by the PR being reviewed. In GitHub mode this settings path is read from the checked-out PR tree, so a contributor can add domain_critic_cap: 0 and suppress every rule/critic reviewer with no coverage-gap finding (or raise it to amplify review work). Can we load this budget from a trusted base/external operator source and add a test proving a head-only settings change cannot alter that PR’s fleet?
| | `impact_analyzer` (FEA-1401, on exported-symbol change/deletion) | ✗ | ✗ | ✓ (on signal) | | ||
|
|
||
| **Standard-mode budget arithmetic.** With PLN-807 Phase 4, `arbitrate-budget` reserves BHA partitions FIRST (from `_max_bha_partitions_by_loc`) and then allocates the remaining budget to critics and best-effort. The total domain-critic count across both required and best-effort buckets is capped uniformly at `DOMAIN_CRITIC_CAP = 3` (by priority asc, reviewer asc) for both standard and deep tiers. Required-bucket critics dropped by the cap emit coverage-gap findings; cap-deferred entries carry `defer_reason: "domain_critic_cap"` in `deferred_for_budget`. PRs with sparse critic-gates rosters see identical fleet to pre-PLN-807. | ||
| **Standard-mode budget arithmetic.** With PLN-807 Phase 4, `arbitrate-budget` reserves BHA partitions FIRST (from `_max_bha_partitions_by_loc`) and then allocates the remaining budget to critics and best-effort. The total domain-critic count across both required and best-effort buckets is capped uniformly at `DOMAIN_CRITIC_CAP` (default 3, operator-tunable via `.closedloop-ai/settings/code-review.json:domain_critic_cap`; by priority asc, reviewer asc) for both standard and deep tiers. Required-bucket critics dropped by the cap emit coverage-gap findings; cap-deferred entries carry `defer_reason: "domain_critic_cap"` in `deferred_for_budget`. PRs with sparse critic-gates rosters see identical fleet to pre-PLN-807. |
There was a problem hiding this comment.
This still says required critics dropped by this cap emit coverage-gap findings, but the new zero-cap test explicitly asserts gaps["findings"] == [], and arbitration records them only in deferred_for_budget. An operator lowering the cap could rely on a safety signal that never appears. Please make this line and commands/start.md match the implemented no-gap behavior, or change the implementation if gaps are intended.
| if verify_doc is not None: | ||
| _write_coverage_section(tmp_path, "verify", verify_doc) | ||
|
|
||
| # ISS-5122: always point --settings at a test-local path so a |
There was a problem hiding this comment.
These tests bypass the production config path by always passing a test-local settings path into a hand-built namespace. The real stage omits --settings and relies on parser/default-path wiring, so that wiring can regress while this suite stays green. Can we add a run-prefix or real-parser fixture that creates .closedloop-ai/settings/code-review.json and proves the final spawn plan honors a raised or zero cap?
| reviewer asc)``, so on a roster where every entry sits at the | ||
| default ``priority: 2`` the tiebreak is alphabetical, which | ||
| favors early reviewer names over relevance to the diff. | ||
|
|
There was a problem hiding this comment.
This adds shipped plugin behavior, but plugins/code-review/.claude-plugin/plugin.json is unchanged at 3.7.0. The required Plugin Version Bump check is already failing on this exact head. Please bump the code-review plugin version once relative to main (the repo guidance classifies a backward-compatible new setting/CLI surface as a minor bump).
| Operator-tunable reviewer behavior. | ||
|
|
||
| | Key | Default | Behavior | | ||
| |---|---|---| |
There was a problem hiding this comment.
The repo marks this README as generated and requires /update-documentation for plugin changes, including the root changelog entry. CHANGELOG.md is unchanged on this head, so the release docs are incomplete even though the README was edited. Please run the existing documentation workflow and commit its generated README/changelog output after the version bump.
Summary
Makes
DOMAIN_CRITIC_CAPoperator-tunable via.closedloop-ai/settings/code-review.json, the file that already hostsbha_unified_threshold_locandout_of_hunk_confidence_floor.The problem. The cap was a hardcoded
3with no settings path, and it drops by(priority asc, reviewer asc). A repo whosecritic-gates.jsonuses the legacymoduleCritics[]schema gets every entry migrated by_migrate_module_criticsasrequired: Falsewith nopriority— so all of them sit at the default2and the tiebreak degenerates to alphabetical by reviewer name.That is not a theoretical edge. On two
symphony-alphacost/metric PRs (#4330, #4349), the coverage critic proposedlogical-metric-reconciliation-auditorspecifically because of the diff's tally/cost semantics, consolidate accepted it, and the cap then dropped it — whileapi-architect,caching-strategist, anddatabase-architectsurvived on their first letter. The reviewer best matched to the change was the one systematically excluded, on every such PR.The change.
_load_code_review_settingsgainsdomain_critic_cap(int, ≥ 0) with the same validation discipline as its siblings: bool rejected (it is anintsubclass), negative and wrong-type fall back to the default rather than crashing the stage.cmd_arbitrate_budgetreads it with precedence mirroringbha_unified_threshold_loc:--domain-critic-capflag →code-review.json→ built-inDOMAIN_CRITIC_CAP.arbitrate-budgetgains--settings(test isolation, mirroringvalidate) and--domain-critic-cap.0is a valid, documented kill switch — no domain critics spawn;source: "core"reviewers (Design Critic, Impact Analyzer) stay exempt as before.Docs. README and
commands/start.mdno longer state the cap as a fixed3. Both now explain when raising it is the right call — and note that raising the cap is the blunt remedy, while migrating rules to the canonicalcoverage[]schema (which supports explicitpriorityandrequired) is the precise one.Test plan
0kill switch, negative → default, wrong type → default, bool rejected). Four coverarbitrate-budgetbehavior: the settings file actually raising the cap,--domain-critic-capbeating the settings file (precedence pinned so a refactor cannot silently invert it),0spawning zero domain critics with all of them cap-deferred and no coverage-gap findings, and a malformed value leaving the fleet at the default 3._run_arbitrate_budgetharness now always points--settingsat a test-local path, so acode-review.jsonin the CWD can never leak into a run.cli_parser_resolved.jsonregenerated. The diff is exactly the two newarbitrate-budgetflags and nothing else — I diffed parser-by-parser before writing to confirm no collateral drift.test_code_review_helpers.py,test_code_review_schema.py,test_golden_fixtures.py,test_prefix_golden.py— including the golden-fixture and prefix-parity harnesses.HEADfailure set, restored, and diffed. Exactly one new failure (the CLI snapshot, expected and then updated) and zero others. (An earlier run showed 95 failures on both sides — that was my venv missingpyyaml, not the repo.)What could still break: the cap remains tier-uniform, so
--depth deepstill does not widen it — deep's extra breadth continues to come from the cap-exempt core reviewers. Settingdomain_critic_capabove the total reviewer--caphas no additional effect, since total-cap arbitration still runs first.🤖 Generated with Claude Code