/research — end-to-end pipeline conductor
You (the main agent) are the orchestrator. Drive the pipeline below in order.
The filesystem is the message bus: pass the run directory path in every
subagent task message; expect each subagent to end with
{"ok": ..., "outputs": [...], "notes": ...}.
Arguments received: $ARGUMENTS
0. Scaffold the run
python3 .claude/scripts/new_run.py $ARGUMENTS
Capture the printed run id; RUN = workspace/runs/<run-id>. Read
RUN/run-config.json for B (branches), I (iterations), offline flag, topic.
If new_run.py fails, report and stop.
1. Investigate
Launch the problem-investigator subagent: task message = run directory,
topic, offline flag; ask for brief.md + bibliography.jsonl +
literature/ + investigation/ per its protocol.
- If it returns
ok: false(relevance gate ABORT), report the reason to the user and STOP the pipeline. - Then:
python3 .claude/scripts/bib_validate.py RUNmust pass. - Ledger:
python3 .claude/scripts/ledger.py append '{"event":"stage_investigate","detail":"complete"}'
2. Discover — I iterations of Parallel Explore-Exploit
For each iteration iN in i1..iI:
- Ideate: launch
ideator(run dir, iteration, B; from i2 also point it at all previous distilled-feedback.md files — the ideator then applies top-K retention: p1..pK refine the previous iteration's top-K surviving branches). Expectiterations/iN/ideas.md+proposals/p1..pB.md. Ledger eventstage_ideate. - Solve — PARALLEL: launch ALL B
solversubagents IN ONE SINGLE MESSAGE (one Agent call per branch). Each task message: run dir, its own branch diriterations/iN/branches/bK/, its proposalproposals/pK.md. Never launch solvers sequentially. - Evaluate — PARALLEL: after all solvers finish, launch B
evaluatorsubagents in one message (one per branch). Expecteval.jsonper branch. - Audit — PARALLEL: launch B
auditorsubagents in one message. Expectaudit.mdper branch. - Rank + Select (you, the orchestrator): read every branch's eval.json +
audit.md. Disqualify audit-FAIL branches. Write
iterations/iN/ranking.md: table (branch, proposal one-liner, score, audit verdict, rank) + selection rationale. - Distill feedback (you): invoke the
distill-feedbackskill (Skill tool,skill: distill-feedback) and writeiterations/iN/distilled-feedback.mdwith exactly its section template — do not improvise the format from memory; the next ideator round consumes this file. Ledger eventstage_iteration_iN.
After the last iteration: pick the best surviving (audit-PASS) branch across
ALL iterations by official score. Copy its solution.py, eval.json,
solve.log, plan.md into RUN/best/ and write RUN/best/SELECTED.json:
{"iteration": "iN", "branch": "bK", "score": <score>}.
Ledger event stage_discover complete.
If ZERO branches survive audits in all iterations, report and stop.
Then launch ablation-analyst (run dir) → best/ablations/{ablations.json, ablation.md}; ledger event stage_ablation. Ablations are secondary
evidence — on ok: false, record and continue; never block the pipeline.
3. Write paper
- Launch
paper-writerwith stage=conceive →paper/research-representation.md. - Run
python3 .claude/scripts/ground_check.py RUN— if exit 1, relaunch paper-writer (stage=conceive, "fix every non-SUPPORTED check in paper/ground-report.json") once and re-run ground_check. If it still fails, STOP and show the user the unsupported list — never compose a draft on an ungrounded representation. - Launch
paper-critic→paper/critic-report.md. - Launch
paper-writerwith stage=resolve-compose →paper/draft.md. - Convergence round (Ground→Critic→Resolve, max 2 rounds total): if the
critic report contained any BLOCKER, relaunch
paper-criticagainstpaper/draft.md. If BLOCKERs remain, relaunchpaper-writer(stage=resolve-compose) once more with them, then stop regardless (plateau) and report residual issues honestly. Ledger eventstage_write_paper.
4. Verify claims
python3 .claude/scripts/extract_claims.py RUN- Launch
claim-verifier→ verdicts inpaper/claims.jsonl+paper/verification-report.md. Ifrun-config.json#verifier_votesis N ≥ 2, follow the best-of-N vote protocol in theverify-claimsskill instead of a single launch (sequential verifier launches interleaved withverdict_votes.py snapshot, thenverdict_votes.py merge). - If any claim is FAIL: launch
refiner; then re-runpython3 .claude/scripts/verify_claims.py RUN; if FAILs remain, one more refiner round (max 2), then accept honestly reported residuals. - Copy the final draft:
paper/draft.md→final/paper.md. python3 .claude/scripts/chain_of_evidence.py RUN— the four integrity checks. Ledger eventstage_verify.
5. Report
Summarize for the user: run id, best branch + official score, grounding
ratio (paper/ground-report.json), claim tally, chain-of-evidence table
result, and the path RUN/final/paper.md. Mention /paper-to-latex if they
want a .tex/PDF.