Files
ruv bc71480402 feat(swarm): streaming multi-agent execution for swarm start (ADR-385)
`swarm start` previously only printed a plan and deferred; nothing ran
(#1423). It now EXECUTES the objective as a streaming, bounded, multi-agent
flow, default-on with a `--no-execute` escape to the old plan-only behavior.

- I1: each planned worker is spawned as a real headless `claude -p
  --output-format stream-json` subprocess; reshaped output streams live to
  stdout as NDJSON `{agent,role,kind,data,ts,file?}`, interleaved across a
  bounded worker pool; deterministic fan-out -> reduce.
- I2: terminal `overview` NDJSON event + human card (stderr) + `--format json`
  object, carrying objective, roster, artifacts (tool_use file_path union git
  delta, absolute paths), per-worker status, transcript path, elapsed, next
  steps.
- I3: `swarm guide <id> "<msg>"` appends to `.swarm/sessions/<id>/inbox.jsonl`;
  the running executor injects it into the next worker prompt.

Security: objective is piped over stdin (argv array, shell:false) so it never
reaches a shell; bounded concurrency + per-worker timeout + `--deadline-secs`
global deadline (process-group kill) + `--max-agents` cap; secrets redacted
from every streamed byte; capability bounded by `--allowedTools`, never
skip-permissions; every failure surfaced as a `kind:"error"` event.

Engine split into `services/swarm-executor.ts` (spawn/pool/deadline) and
`swarm-executor-events.ts` (pure prompts/reshaping/redaction/overview) to keep
`swarm.ts` thin and the pure pieces unit-testable. 20 unit tests (fixture-script
seam, real stream-json capture) green; real e2e confirmed live streaming +
artifact creation + overview.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-09-09 22:50:32 -04:00
..