compound-engineering-plugin icon indicating copy to clipboard operation
compound-engineering-plugin copied to clipboard

ce-code-review: strict serial dispatch (#1159) makes large-diff reviews 45–70min — restore #1031's bounded concurrency as an opt-in `concurrency:` knob

Open EthycalOne opened this issue 4 months ago • 1 comments

Problem

Since #1159, ce-code-review dispatches the local roster strictly one reviewer at a time, foreground (SKILL.md: "dispatch the materialized local roster foreground, exactly one reviewer at a time. Local background tasks are forbidden"; dispatch-reviewers.md: "Dispatch exactly one reviewer with background execution off, consume its returned compact JSON, then dispatch the next").

On a large diff this serializes into very long wall-clock. A recent real run on a ~445KB staged diff:

  • correctness reviewer: ~12.5 min (~209k subagent tokens, 43 tool calls)
  • security reviewer: ~5.5 min
  • five more local personas still queued + peer fold-in + validator/finish stage
  • projected total: ~45–70 min

The same-shaped diff under the pre-#1159 bounded model completed far faster because up to N reviewers ran concurrently.

Root cause (and why the default is correct)

This is deliberate, not a regression, and I don't want to undo the reasoning behind it:

  • #1031 "handle bounded subagent dispatch" introduced cap-aware dispatch to keep the full roster intact on cap-limited harnesses (Codex) — "learn the limit from capacity responses, keep the selected reviewers queued, and retry after an active reviewer finishes." That model allowed up-to-cap concurrency ("after an active reviewer finishes").
  • #1159 "right-size review orchestration" tightened bounded → strictly one, optimizing for determinism ("deterministic mechanics own deterministic decisions… stable numbering… no longer depend on orchestration improvisation") and tokens (−17.2% median, 5/5 defect classes 20/20). #1159 explicitly measured tokens, not wall-clock — latency was knowingly traded away.

Strict-serial-foreground is the correct default: it never overruns a host cap, needs no background/notification/poll machinery (hence the ban on shell no-ops / scheduled wakeups / "still waiting" turns), and is fully deterministic.

Proposal: opt-in concurrency: knob (restores #1031's bounded model as a choice)

Add an argument token, default = today's behavior:

  • concurrency:1 (default) — exactly today's strict serial foreground dispatch. No behavior change.
  • concurrency:auto — bounded concurrent dispatch: a pool sized to the host's active-agent cap, using the harness's concurrent foreground wait where it exists (Claude Code Task: spawn N in one message, they return together, no polling; similar on omp/others). Serial fallback on harnesses without safe concurrent-wait.
  • concurrency:<N> — explicit pool cap for power users.

This is not a new design — it restores the bounded shape the skill itself shipped in #1031, gated behind an explicit opt-in so the deterministic/portable default is untouched.

Why it's safe with the rest of the pipeline

  • Determinism is preserved. Finding numbers are assigned after the post-merge sort (review-output-template.md: stable numbering after sorting), so reviewer completion order does not affect output. Merge/dedup (findings-mechanics.py) is order-independent.
  • Cap-safety is preserved. #1031's backpressure rule still applies per pool slot: capacity errors are backpressure, not reviewer failure; queue and retry. A pool of 1 degenerates to exactly today's path.
  • No poll/wakeup regression. concurrency:auto only engages where the harness supports a blocking concurrent wait (one call that returns when the batch completes). Where it doesn't, it stays serial — the anti-poll invariant holds.
  • Peer, validator, finish stages unchanged. The cross-model peer remains the single detached job; the validator batch and finish-review.md are downstream of the merged set and untouched.

Scope

references/dispatch-reviewers.md (the bounded-dispatch section), SKILL.md Stage 4 dispatch line + argument parsing, and the mode/argument table. No schema, persona, validator, or merge changes.

Question for maintainers

Was #1159's move from bounded (#1031) to strictly-one driven by anything beyond determinism + token efficiency? If strict serialism is a hard requirement of the deterministic-mechanics contract (not just the simplest portable default), that changes whether an opt-in pool is acceptable. If it was chosen as the safe default, an opt-in concurrency: knob restores large-diff throughput without touching the default's guarantees.

Happy to open a PR with the dispatch-reviewers.md + SKILL.md changes if the direction is welcome.

EthycalOne avatar Jul 20 '26 05:07 EthycalOne

Update: implemented the concurrency change locally against v3.19.0 and it works in Claude Code.

What was changed (the two authoritative dispatch statements, kept consistent so the orchestrator can't fall back to the stricter one):

  • SKILL.md execution-spine step 4: "exactly one reviewer at a time" → "at the resolved reviewer concurrency (default: bounded-concurrent to the host active-agent cap on harnesses with a non-polling concurrent wait, else exactly one at a time)."
  • references/dispatch-reviewers.md bounded-dispatch paragraph: pool of size C; dispatch up to C reviewers, await the batch with one blocking foreground call (no polling), then the next batch. C = 1 is exactly today's strict serial path. The existing backpressure rule is preserved and now applies per pool slot.

Result: the local roster now dispatches concurrently in Claude Code (multiple persona Agent calls in one message, results returning together), where v3.19.0 previously serialized. On a large diff this is the difference between a ~45–70 min serial run and overlapped batches.

Determinism is preserved by construction: finding numbers are assigned after the post-merge sort, so batch completion order does not affect output; merge/dedup is set-based. The anti-poll invariant holds because bounded dispatch only raises C above 1 where the harness offers a single blocking wait over concurrently-spawned subagents — no notifications, wakeups, or status polling.

This keeps the default (C = 1) byte-for-byte identical to current behavior, so the deterministic-mechanics and portability guarantees are untouched unless a user opts into a larger pool.

Happy to open a PR with these two edits plus regression guards (same-diff concurrency:auto vs concurrency:1 → identical findings/numbering; requested C > host cap clamps with no dropped reviewers; poll-only harness resolves to C = 1). Just let me know if the direction is welcome — the one open question from the issue still stands: was #1159's move to strictly-one a hard requirement of the deterministic-mechanics contract, or the safe default?

EthycalOne avatar Jul 20 '26 15:07 EthycalOne