|
| 1 | +# Agent Cargo Hygiene — one target dir, no 12× build residue |
| 2 | + |
| 3 | +## The problem |
| 4 | + |
| 5 | +When the orchestrator fans out a fleet of subagents (the Sonnet build/fix |
| 6 | +agents), each agent that runs a full `cargo build`/`check`/`test` in its **own** |
| 7 | +isolated working copy materialises its own `target/`. This workspace's |
| 8 | +`target/` is ~7 GB. Twelve agents in twelve worktrees = ~84 GB of duplicated |
| 9 | +build residue and twelve cold compiles competing for the same cores. |
| 10 | + |
| 11 | +## The rule |
| 12 | + |
| 13 | +- **Opus (orchestrator + Opus agents): run cargo freely.** No restriction. |
| 14 | +- **Sonnet fleet agents: do NOT each run a full compile.** They edit code and |
| 15 | + reason; they must not spawn isolated worktrees or trigger their own cold |
| 16 | + `cargo build`/`check`/`test` that each grow a separate 7 GB `target/`. |
| 17 | + - "tests yes, compile no": a targeted `cargo test`/`clippy` against the |
| 18 | + **shared** workspace `target/` is fine; a bare compile-only |
| 19 | + (`cargo check`/`build`) is wasted residue — clippy already compiles. |
| 20 | +- **Verification is centralised.** The orchestrator (Opus) runs |
| 21 | + `cargo fmt` + `cargo clippy` + `cargo test` **once**, in the single shared |
| 22 | + `target/`, after the fleet's edits land. One build, not twelve. |
| 23 | + |
| 24 | +## How the orchestrator fans out work |
| 25 | + |
| 26 | +- Spawn the fleet **without** `isolation: "worktree"` so all agents share the |
| 27 | + one repo checkout and one `target/`. |
| 28 | +- Tell each agent explicitly: *edit only; do not run `cargo build`/`check`; do |
| 29 | + not create a worktree; the orchestrator compiles and lints centrally.* |
| 30 | +- After edits, the orchestrator runs the gates (`cargo fmt -p <crate>`, |
| 31 | + `cargo clippy -p <crate>`, `cargo test -p <crate>`) — keeping the tree |
| 32 | + `cargo clippy -- -D warnings`-clean (see `CLAUDE.md` Hard Rules) and |
| 33 | + `cargo fmt`-clean on the pinned toolchain, with no residue blowup. |
0 commit comments