ADR-0030: The worker is the main session; implementers per lane; one review gate
Context and problem
Until now a build task's worker ran a small factory: context-researcher per source group, plan-verifier before the owner saw the plan, an implementer per task from tasks.md, and a Sonnet reviewer before the PR. Field data from comparable pipelines (an MVP run with an agent per task: 84 agents, ~204M input tokens) and community reports point the same way: an agent per task pays for orientation and for writing a fresh prompt prefix into the cache each time, and several reviewers in a row cost more without catching more. The alternative — one main session doing the work, a few short-lived helpers for what only a clean context does well, deterministic checks for what scripts can check — reports the same quality for 40–60% less (hypothesis to measure here, not a given).
Decision
- The worker run is the main session. It writes
context.md,spec.mdand the plan itself (never a subagent), chooses a mode in the plan and owns the run. The engine's stages and the owner's approval of the spec stay as they are (ADR-0022): the owner decides on the spec and plan, and later on a PR whose checks are green. - Modes. Quick (1–3 files, no contract change): the worker does it, no subagents except the gate. Small (up to ~10 tasks, one layer): the worker works through
tasks.mditself, then the gate. Big (~10+ tasks or several layers): lanes, each run by oneimplementerthat writes the code and its tests; a lane hands off after 5–8 tasks, ~500k context, 5 red attempts or a block, and the worker starts a fresh implementer for the rest (never resumed). Lane 0 holds contracts and runs first. Lanes run in order for now; parallel lanes in separate worktrees are a later, measured change. - The brief is files, not history.
scripts/brief.shcuts the lane block fromplan.mdand the lane's section fromtasks.md. Implementers return a report with## Decisions I madeand insight candidates; the worker copies decisions intodecisions.mdand decides what becomes memory (note_insight). - One review gate. A single
reviewer(Opus, read-only, clean context) replacesplan-verifierand the old reviewer: acceptance criteria with evidence, the target repository's rules, code and architecture, every finding proven with an input and the wrong result. Severities Must (blocks), Should (fixed in round 1 only), Consider (listed in the PR). At mostlimits.reviewRounds(3) rounds; rounds 2–3 see only the fix diff. Reports are kept inreview.md. - Deterministic checks over prompt rules. The repository's check commands (from its
AGENTS.md, as today) are run by the worker before the gate;scripts/check-owned-paths.shfails a Big run that touched files outside its lanes. The engine still runs the official checks atopen_pr. - No agent starts agents.
implementerandreviewerhave noAgenttool. Each preloads at most one skill; others are loaded withSkillon demand. - Cache.
subagentPromptCacheTtl: "1h"in the worker settings, so a long implementer is not rewritten into the cache after every pause over five minutes.
context-researcher (an isolated search helper), ui-tester (WRK-10) and the dispatcher are unchanged.
Consequences
- Fewer agents per task; the worker's context holds the spec and plan for the whole run.
plan-verifieris removed: the owner reviews the plan, and the gate checks the result against the ACs.- A Big task's run is longer per worker turn; hand-offs keep implementer contexts bounded.
- Measure before keeping. The previous pipeline is the commit before this ADR (
91c70bf). Compare one feature of similar size on both: tokens and notional cost per task (Usage page, per-model breakdown fixed ina071b26), number of runs and subagents, review rounds, wall time, gate result. Revert this change if it does not pay off.
Relies on
ADR-0009 (agent plugin), ADR-0022 (engine runs the checks and opens the PR), ADR-0026 (engine knows no target project: everything stack-specific comes from the target repository).