Skip to content

feat(code-review): fold Gate B route + partition into run-prefix (PLN-1229 Phase 2) - #174

Merged
wongk merged 3 commits into
mainfrom
feat/code-review-run-prefix-route-partition
Jul 2, 2026
Merged

feat(code-review): fold Gate B route + partition into run-prefix (PLN-1229 Phase 2)#174
wongk merged 3 commits into
mainfrom
feat/code-review-run-prefix-route-partition

Conversation

@wongk

@wongk wongk commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

PLN-1229 Phase 2. Extends cmd_run_prefix (Phase 1, #173) to run the whole deterministic prefix in one process — folding in Gate B route + stage_17_partition + derive-spawn-spec (Segment 3) — and returns the routing/cache decision the orchestrator needs. Zero orchestrator changes (start.md untouched); validated purely by the extended A/B parity oracle.

What's here

Runner (code_review_helpers.py)

  • After stage_19_cache_check, cmd_run_prefix invokes route itself (writing spawn.json.route), caches fast_path / max_bha_agents, and on fast-path deletes the cached-BHA replay artifact.
  • stage_17_partition is skipped 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.
  • 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 (prefix_golden_harness.py + test_prefix_golden.py)

  • The subprocess A-side gains a subprocess route runner 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_message read, and the ready_for_reviewers result fields.

DocsSCHEMA.md §7b rewritten for ready_for_reviewers + the new fields.

Testing

  • Full code-review suite: 1305 passed, 3 skipped
  • uv run ruff check . clean · uv run pyright 0 errors (repo-wide)
  • A/B parity + pause-sequence: 14 tests green (deterministic; no real-cache pollution)

Version: code-review 3.2.0 → 3.3.0 (MINOR — additive expansion of run-prefix).

Remaining: Phase 3 rewires start.md to call run-prefix (keeping the per-stage walk as the documented fallback); Phase 4 measures the turn/cost reduction.

🤖 Generated with Claude Code

wongk and others added 3 commits July 2, 2026 11:35
…-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>
@wongk
wongk merged commit 78ceb52 into main Jul 2, 2026
5 checks passed
@wongk
wongk deleted the feat/code-review-run-prefix-route-partition branch July 2, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant