Skip to content

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 ​

  1. The worker run is the main session. It writes context.md, spec.md and 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.
  2. 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.md itself, then the gate. Big (~10+ tasks or several layers): lanes, each run by one implementer that 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.
  3. The brief is files, not history. scripts/brief.sh cuts the lane block from plan.md and the lane's section from tasks.md. Implementers return a report with ## Decisions I made and insight candidates; the worker copies decisions into decisions.md and decides what becomes memory (note_insight).
  4. One review gate. A single reviewer (Opus, read-only, clean context) replaces plan-verifier and 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 most limits.reviewRounds (3) rounds; rounds 2–3 see only the fix diff. Reports are kept in review.md.
  5. 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.sh fails a Big run that touched files outside its lanes. The engine still runs the official checks at open_pr.
  6. No agent starts agents. implementer and reviewer have no Agent tool. Each preloads at most one skill; others are loaded with Skill on demand.
  7. 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-verifier is 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 in a071b26), 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).