Add swarm dispatch scope and dispatch-mode benchmark harness

Merged
KH
4mo ago
+1504-26

Change

Adds a new swarm triage scope alongside single/team: a lead + workers share one checkout and a live relay channel (agent-relay MCP messaging — already fully plumbed via AgentSpec.channel -> SpawnInput.channel, just previously unpopulated) instead of team's isolated parallel fan-out. Opt-in only via the agent:swarm label, never inferred heuristically, so existing single/team behavior is unchanged. renderAgentTask now briefs the lead/workers with their coordination channel and each other's names.

Also adds benchmark/ machinery to actually measure whether team/swarm beat a single agent, and whether swarm's live collaboration beats team's isolated fan-out: a task corpus schema + loader, a resumable (task x mode x repeat) matrix builder, a real-dispatch runner (gh + factory dispatch + verify.sh scoring) behind a testable DispatchRunner interface, and a markdown report generator grouped by coordination-benefit difficulty tier. Pure logic is unit-tested; the real-IO adapter is proven by running it (not by mocking child_process) — see benchmark/README.md for what's still required operationally before a real run (a disposable sandbox repo, authored tasks, a live workspace). Includes a SWE-bench Verified adapter script, tested live against 2 real instances, for an externally-comparable subset, with loud caveats about repointing to a controlled fork before dispatching.

Verification

  • Required package check passed on the current head SHA.
  • factory-e2e-<head-sha> attestation artifact was inspected.
  • All actionable review threads are resolved.

Verification tier: Tier 1 (package boundary) — this PR adds new opt-in surface area (a new label-gated scope, a standalone benchmark/ tooling package) with no change to default single/team dispatch behavior; no live/load evidence applies.

Head SHA tested: 42b5a86ba0571c0877e80f14cd452d84e8a287d8

Adapter/preview evidence: N/A — no adapter or preview surface touched.

Live canary issue / PR / run: N/A — swarm scope requires an explicit agent:swarm label to activate, so there is no live canary path until a real workspace opts in; benchmark/run.ts is the intended live-canary vehicle for a future run against a real sandbox repo, not run in this PR.

Failure-injection or load evidence: N/A — no runtime/infra behavior change for existing scopes.

Cleanup receipt: N/A — no disposable resources created; npm run verify:e2e's packed-consumer install/tarball are cleaned up by the script itself.


npx tsc -p tsconfig.build.json --noEmit, npx tsc -p benchmark/tsconfig.json --noEmit, and npx vitest run all pass (1422/1428, the 6 failures are pre-existing/environmental — git-sandbox remote-parsing issues and a missing dist/ fixture — unrelated to this diff and reproduce on main).


Generated by Claude Code


Summary by cubic

Adds an opt‑in swarm dispatch scope and a benchmark harness to compare single/team/swarm. This matters because it enables live collaboration (lead + workers in one checkout) and gives real numbers on whether multi‑agent modes outperform a single agent. Default single/team/workflow behavior is unchanged.

  • Swarm dispatch
    • Opt‑in via agent:swarm; never inferred. Uses only the first matched repo route and caps members by triage.maxImplementers.
    • Lead and workers share one checkout and a relay channel; prompts name roles/peers. Workers commit locally but do not push, open PRs, or DM the reviewer; only the lead publishes and completes.
    • Worker prompts split “done” vs “blocked”; if durable question routing is available, point to it, else fall back to reporting one concrete question in the final outcome.
    • Orchestrator suppresses worker exits from publishing/completing; the lead exit drives the normal completion path.
  • Benchmark harness (benchmark/)
    • Runs a resumable (task × mode × repeat) matrix against live infra, shells out to gh and Factory dispatch, repo‑qualifies owner/repo#N, and records durationMs for successes and failures to JSONL; renders a markdown report.
    • Refuses team on single‑repo tasks and tasks with a non‑default baseRef (avoids null tests and wrong‑revision scoring).
    • Includes a SWE‑bench Verified adapter to generate tasks, with a loud note to repoint targetRepo to a controlled fork.
    • Adds npm run benchmark.

Rollout

  • To try swarm: add the agent:swarm label and set triage.maxImplementers > 1.
  • To run benchmarks: author tasks under benchmark/tasks/, then run npm run benchmark -- --config ./factory.config.json (use --only-task, --only-mode, --repeats to narrow).
  • For SWE‑bench tasks: repoint targetRepo in generated tasks to a fork you control before dispatching.