Repository navigation
fix(code-review): keep every BHA partition within the agent budget - #381
Open
mikeangstadt wants to merge 7 commits into
Open
mikeangstadt wants to merge 7 commits into
mikeangstadt wants to merge 7 commits into
Conversation
- route handed partition --max-bha-agents = 9 - 2 - <domain critics> (7 with none), while arbitrate-budget reserved min(ceil(LOC / 1200), 5) Bug Hunter A agents. Above the unified threshold (or with it disabled) the partitioner kept up to 7 partitions, and derive-spawn-spec / derive-static-spec prefix-took the cap and dropped the rest as budget_capped, so those files were never bug-hunted - _max_bha_partitions_by_loc is now the single source: route calls it with its fleet-slot cap, arbitrate-budget calls it on the same diff_data.json, so partitions <= bha_partitions on every path; the partitioner's force-merge folds the extra files into fewer partitions - derive-static-spec now reports a budget_capped partition as a required coverage gap, as derive-spawn-spec already did, so a drop can no longer pass silently on shallow - Prefix goldens: route.max_bha_agents 7 -> 1 for the small fixtures Testing: pytest plugins/code-review/tools/python/ (1483 passed, 3 skipped); new route->arbitrate->partition->spawn regression cases fail on the unfixed source (7 or 6 partitions for 5 agents, 7 for 2) Risks: Diffs between 5001 and ~6000 LOC with impl/test splits now get 5 larger partitions instead of 6-7, one of which was previously dropped Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Pass 2b force-merge now merges the two smallest partitions of one type, falling back to a cross-type pair only when no type has two left; with the route cap it is the normal path for partitioned diffs, and the old any-type merge folded test files into Opus impl partitions - derive-static-spec resets coverage_gaps.json before writing its spawn gaps (shallow has no arbitrate-budget to reset it), so a resumed or clean re-run neither duplicates nor keeps a gap - One module-level _SPAWN_BENIGN_REQUIRED_SKIPS shared by derive-spawn-spec and derive-static-spec - Docstring, SCHEMA.md and CHANGELOG state the cache-path bound: the partitioner may read uncached_diff_data.json (LOC <= full diff) and still force-merges to the route's value - Tests: dropped the non-independent domain-critic parameter and fixed its comment; renamed the cross-type force-merge test to assert same-type merges, added the cross-type fallback case, an even 10 impl / 10 test 5,500 LOC case, and static-spec re-run cases Testing: pytest plugins/code-review/tools/python/ (1485 passed, 3 skipped); new force-merge and re-run tests fail on 44f837f; the main regression still fails on 44f837f^ Risks: slot_cap kept: a negative reviewBudget makes it bind below 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- route clamps defaults.reviewBudget at 0. A negative value made [:max_domain_critics] a tail-drop slice (-1 kept 6 of 7 matching critics) and, through 9 - 2 - critics, shrank the BHA count - With at most one domain critic, 9 - 2 - critics >= 6 exceeds DEFAULT_MAX_BHA_AGENTS, so route now calls _max_bha_partitions_by_loc(diff_data) exactly as arbitrate-budget does; the slot_cap parameter, branch and test are gone - Docstring notes BHB + Auditor + critic + 5 BHA = 8 stays within the 9-agent route fleet; SCHEMA.md and CHANGELOG updated to match Testing: pytest plugins/code-review/tools/python/ (1486 passed, 3 skipped); the negative-budget route test fails on 930a6a5 and the main regression still fails on 44f837f^ Risks: None identified; no other path reads reviewBudget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- derive-spawn-spec and derive-static-spec fold a partitions.json with more partitions than a positive BHA cap: the partitioner's force-merge (_force_merge_to_cap) runs again down to the cap, partitions.json and patches_p<N>.txt are rewritten, and the spec records folded_partitions plus a fleet note. budget_capped remains for a zero cap and for a fold without a diff scope to rebuild patches, both still required coverage gaps - run-prefix passes _max_bha_partitions_by_loc(diff_data.json) when no route value exists instead of omitting --max-bha-agents - The partitioner merges trivial partitions before the force-merge, and the force-merge takes the smallest combined-LOC pair, preferring a same-type pair only on a tie - setup writes an empty coverage_gaps.json per run; the spawn-spec stages replace their own spawn_* findings (_replace_spawn_gaps) - Comments and SCHEMA.md name docs-only as the intentional exception to partitions <= bha_partitions; benign-skip comment lists the set - Tests: fold, cache path, missing route value, both balance reproductions, critic-independent route count; the even 10/10 split test now asserts balance instead of impl/test purity Testing: pytest plugins/code-review/tools/python/ (1491 passed, 3 skipped); the fold, balance and fallback tests fail on 40b62d8; the main regression still fails on 44f837f^ Risks: The fold shells out to git diff for patches with the diff scope from scope.json / auto_incremental.json and cwd as the partition stage does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
arbitrate-budget runs before stage_17_partition, so run-prefix now passes the partitioner coverage.json final.budget.bha_partitions (floored at 1), falling back to the LOC count on shallow. The post-hoc fold in the spawn-spec stages and folded_partitions are removed; budget_capped with its required coverage gap stays as the guard for an externally produced partitions.json. The golden harness uses the same helper. Spawn-spec and verify-spawn gap findings carry gap_producer and producer-prefixed ids; each stage replaces only its own entries on a re-run, so a resume neither duplicates a gap nor collides ids with arbitrate-budget's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
partition derives its Bug Hunter A cap from --cr-dir when --max-bha-agents is omitted (arbitrated budget.bha_partitions, else the LOC count, floored at 1), through one bool-rejecting budget reader shared with derive-spawn-spec. run-prefix and the golden harness no longer pass it. Trivial partitions fold before the budget-respecting merge, so they no longer drive a merge or take a slot. coverage_gaps.json has one writer, _write_coverage_gaps, keyed on gap_producer for every producer (arbitrate-budget, spawn-spec, verify-spawn, verify-consolidate). Each clears its own gaps on every return path. setup creates the file only when absent and warns on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r run setup no longer pre-creates coverage_gaps.json, so the file stays arbitrate-budget's own completion signal for resume. Untagged gaps from a 3.13.0 run directory are attributed to their producer by shape and replaced. The spawn-spec stages write their gaps once per run, after the review-root check. An explicit --max-bha-agents below 1 is floored with a warning. The golden harness drops its unread max_bha_agents field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
/code-reviewcould leave Bug Hunter A partitions with no agent on diffs above the unified threshold (5,000 changed LOC). Two caps were computed independently:--max-bha-agents = 9 - 2 - domain_critics(up to 7)bha_partitions = min(ceil(LOC/1200), 5)When the partitioner emitted more partitions than arbitrate reserved,
_derive_spawn_agents_from_planprefix-took the cap and dropped the rest asbudget_capped. Those files were never bug-hunted. On standard/deep this surfaced as a required coverage gap (false CHANGES_REQUESTED); on shallow it was silent.What changed (plugins/code-review, v3.13.0 → 3.13.1)
--cr-dir: arbitrate-budget'sbudget.bha_partitionswhen present, else_max_bha_partitions_by_loc(diff_data)(shallow). run-prefix and the golden harness no longer compute or pass it; an explicit--max-bha-agentsstill overrides._budget_bha_partitionsis the one reader (rejects bools), used by partition and derive-spawn-spec.reviewBudgetclamp. A negativereviewBudgetno longer turns the critic slice into a tail-drop._write_coverage_gaps) keyed bygap_producer; every producer (arbitrate-budget, spawn-spec, verify-spawn, verify-consolidate) replaces only its own findings on every return path, so a resumed walk neither duplicates nor keeps a stale gap.derive-static-specnow recordsbudget_cappedas a required gap likederive-spawn-spec.setupcreatescoverage_gaps.jsononly when absent.Commands run
Counterfactual:
test_large_diff_without_domain_critic_spawns_every_partitionfails on the pre-fix tree ("partitioner emitted 7 partitions for 5 BHA agents");test_arbitrated_cap_below_loc_count_bounds_the_partitionerand the trivial/balance tests fail on the intermediate commits.Reviewed locally with
/code-reviewacross four rounds; a final local review of 88bf000 is still running and any findings will land as follow-up commits on this branch.🤖 Generated with Claude Code