feat(code-review): fold Gate B route + partition into run-prefix (PLN-1229 Phase 2) - #174
Merged
Merged
Conversation
…-1229 Phase 2) Extend cmd_run_prefix to run the WHOLE deterministic prefix in one process, through Gate B route + stage_17_partition + derive-spawn-spec, stopping at the reviewer fleet. - After stage_19_cache_check the runner invokes `route` itself (writing spawn.json.route), caches fast_path / max_bha_agents on the context, and on fast-path deletes the cached-BHA replay artifact. - stage_17_partition is skipped entirely in fast-path (no partitions.json / patches_p<N>.txt); otherwise its args are augmented with --loc-budget 500 --max-files 25 --max-bha-agents <N>, swapping --diff-data to uncached_diff_data.json when a cache dir is active. - The terminal return is now `ready_for_reviewers`, carrying fast_path, max_bha_agents, and cache_status_message so the orchestrator prints the routing + cache notices without re-reading spawn.json. A route failure surfaces as error with failed_stage="route". Parity oracle: the subprocess A-side gains a subprocess `route` runner and the same partition skip/augmentation, and both sides now run through to the reviewer fleet — so the A/B byte-equality test covers the full prefix (incl. partitions.json / spawn.json) across the fast-path and partitioned branches on all seven fixtures. Adds route/partition contract tests; SCHEMA.md §7b documents the ready_for_reviewers result and its fast_path / max_bha_agents / cache_status_message fields. Zero orchestrator changes (start.md untouched). Full code-review suite 1305 passed / 3 skipped; ruff + pyright clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…folding (PLN-1229 Phase 2) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…B route (PLN-1229 Phase 2) Addresses review of PR #174: - Route-failure error was non-resumable: it set failed_stage="route" (not a real plan stage) and resume_stage=stage_17_partition (which would skip route on retry). Anchor both on stage_19_cache_check so a per-stage fallback re-runs cache-check → route → partition, restoring the resume_stage == failed_stage == real-stage-id invariant every other error path holds. Adds a test that stubs route to fail and asserts the contract. - run-prefix gated the Gate B route call on `status != "skipped"`, diverging from start.md's Walker Contract (route reads the diff, not the cache result, so it fires unconditionally after cache-check) and from the parity oracle's A-side, which runs route unconditionally. Removed the guard so both sides — and the walker contract — agree; the A/B byte-equality oracle stays green. - SCHEMA.md §7b now states exactly which result fields (fast_path / max_bha_agents / cache_status_message) are present per next_action, and that they are omitted (not null) elsewhere, so consumers use .get(). Full code-review suite 1306 passed / 3 skipped; ruff + pyright clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
PLN-1229 Phase 2. Extends
cmd_run_prefix(Phase 1, #173) to run the whole deterministic prefix in one process — folding in Gate Broute+stage_17_partition+derive-spawn-spec(Segment 3) — and returns the routing/cache decision the orchestrator needs. Zero orchestrator changes (start.mduntouched); validated purely by the extended A/B parity oracle.What's here
Runner (
code_review_helpers.py)stage_19_cache_check,cmd_run_prefixinvokesrouteitself (writingspawn.json.route), cachesfast_path/max_bha_agents, and on fast-path deletes the cached-BHA replay artifact.stage_17_partitionis skipped in fast-path (nopartitions.json/patches_p<N>.txt); otherwise its args are augmented with--loc-budget 500 --max-files 25 --max-bha-agents <N>, swapping--diff-datatouncached_diff_data.jsonwhen a cache dir is active.ready_for_reviewers, carryingfast_path,max_bha_agents, andcache_status_messageso the orchestrator prints the routing + cache notices without re-readingspawn.json. Aroutefailure surfaces aserrorwithfailed_stage: "route".Parity oracle (
prefix_golden_harness.py+test_prefix_golden.py)routerunner and the same partition skip/augmentation; both sides now walk through to the reviewer fleet. The byte-equality test now covers the full prefix (incl.partitions.json/spawn.json) across the fast-path and partitioned branches on all 7 fixtures.Contract tests (
test_code_review_helpers.py) — partition arg augmentation (+ uncached swap), fast-path partition skip,cache_status_messageread, and theready_for_reviewersresult fields.Docs —
SCHEMA.md§7b rewritten forready_for_reviewers+ the new fields.Testing
uv run ruff check .clean ·uv run pyright0 errors (repo-wide)Version: code-review 3.2.0 → 3.3.0 (MINOR — additive expansion of
run-prefix).Remaining: Phase 3 rewires
start.mdto callrun-prefix(keeping the per-stage walk as the documented fallback); Phase 4 measures the turn/cost reduction.🤖 Generated with Claude Code