openai / openai/codex-plugin-cc
Proposal: sharded map-reduce review for large diffs — k concurrent background tasks + a cross-shard integration pass (working prototype, ~4.3× measured)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Problem
A single /codex:review / adversarial-review is single-threaded end-to-end. On a real 24-file, ~1.8k-changed-line multi-workstream diff, one review ran 40+ minutes and its worker died silently mid-run — total loss, nothing recoverable. Large diffs are exactly where users most need review help, and exactly where one sequential run is slowest and most fragile. #68 asks for parallel reviews directly; #517 / #540 / #509 document the silent-death modes that make a long single run risky.
What we built (working prototype, zero plugin changes)
A Claude Code user skill that orchestrates the existing companion CLI:
- Gate. Below ~300 changed lines or 8 files → one plain
adversarial-review(parallel costs ~k× tokens; small diffs don't earn it). - Map. Shard the diff by directory/file-ownership into k ≤ 4
task --backgroundjobs; a directory that dwarfs the rest is split per-file and re-balanced so no shard becomes the bottleneck. Every shard receives the same shared invariant list but attacks only its own files (read-only repo access); each prompt embeds only that shard's hunks plus thereview-outputschema. - Supervision. A watcher reads per-job files (not
state.json), verifies the worker pid is actually alive, detects log-mtime stalls, and on death cancels +--resume-lastso the thread keeps the analysis it already did. Each shard runs under its own syntheticCODEX_COMPANION_SESSION_IDnamespace — that is what makes--resume-lastdeterministic when several tasks are in flight. - Reduce (mandatory). One cheap (
--effort low) integration task over the merged findings + mechanical seam hints (imports and style tokens that cross shard boundaries) + a fixed seam checklist. It confirms/rejects every finding and hunts cross-shard defects no single shard could see whole. - Output. One merged, deduped, ranked report with per-shard wall-times.
Measured results (real production repo, real historical diff)
| Metric | Single run (baseline) | Sharded k=4 + reduce |
|---|---|---|
| Wall time | 40+ min, died mid-run | 9.4 min end-to-end (~4.3×) |
| Worker SIGKILLed mid-run | total loss | detected in one 20s tick → cancel + resume kept the thread's prior analysis; shard completed normally |
| Findings | — (lost) | 11 confirmed (3 high), 0 parse failures |
| Leftover jobs/processes | stale "running" forever (#517) | 6/6 jobs terminal, zero orphans |
The single most valuable finding was cross-shard: one shard changed a global CSS token to a translucent value, silently breaking bg-*/NN opacity-modifier consumers in files owned by other shards (effective alpha 5–7%). A monolithic review can see that class; blind shards cannot — the shared-invariant + reduce design is what recovers it.
Why bring this upstream
Demand exists (#68), and today an orchestrator must engineer around known sharp edges instead of fixing them:
- The shared broker is single-tenant; concurrency works only via the
BROKER_BUSY→ dedicated-app-server fallback. It works, but it's implicit and undocumented. --resume-lastis session-scoped and picks the newest resumable thread, so recovering one specific dead task among several requires synthetic session namespaces. A first-classtask --resume <thread-id>would remove the hack.state.jsonconcurrent writers race and can wipe job state (#286, #517) — we cope by reading per-job files and staggering spawns.statustrusts the broker's "running" with no pid-liveness check (#517), so host-killed jobs look alive forever; our watcher re-checks the pid.
A native parallel-review subcommand could reuse the existing infrastructure (enqueueBackgroundTask, per-job files, the review schema, the adversarial prompt) and solve these properly instead of routing around them.
Proposed shape
codex-companion.mjs parallel-review [--base <ref>] [--max-shards 4] [--scope auto|working-tree|branch]plus a/codex:parallel-reviewcommand doc; heuristic gate falls back to the existing single review.- Internals: shard planner (gate + directory sharding + oversize split + seam-hint extraction), per-shard background tasks in isolated session namespaces, watcher with pid/stall recovery, one mandatory reduce turn, merged JSON report.
- Enabling primitives worth landing first (each valuable standalone):
task --resume <thread-id>; pid-liveness instatus; atomic/locked state writes (also fixes #286).
I'm sending a PR that ports the prototype's core (shard planner, supervision loop, reduce pass) into the companion as a parallel-review subcommand — will link it here. Happy to split it into the standalone primitives above if maintainers prefer smaller slices.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at codex-companion.mjs, the existing enqueueBackgroundTask infrastructure, and the adversarial-review entry point. Review the proposed parallel-review command doc and standalone primitives, then verify that sharding, supervision and the mandatory reduce pass produce one merged report while preserving the existing small-diff fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100