CSE Roadmap

Common tier · about 5 hours · 12 parts

Part 9 of 12 · 5 min read

Scaling from one task to many

Scaling from one task to many: a spec before the diff, a worktree per agent

Think of a construction site with one crew and one blueprint, versus a site with five crews. Without five separate, clearly marked work areas and a blueprint each crew actually followed before breaking ground, five crews do not finish a building five times faster. They get in each other's way and build five different, half-matching buildings.

In plain words: part 1's harness bounds what one agent can touch on one task. Two problems show up the moment there is more than one task or more than one agent. First, an agent given a vague instruction fills the gaps with guesses, and a wrong guess costs more the longer the agent runs before anyone checks it -- spec-driven development's fix is to write a short specification first (what the change should do, and what counts as done) and have the agent build against that spec rather than against an open-ended prompt, so there is something concrete to check the diff against before it ever reaches part 3's review gate. Second, two agents editing the same working directory at once will clobber each other's files; a git worktree gives each agent its own working directory checked out from the same repository, so parallel agents can run against the same codebase without the harness's own single-task guarantees from part 1 having to hold across tasks that were never isolated from each other in the first place.

A worked example. The standard worktree commands are git worktree add .worktrees/task-auth -b agent/auth and git worktree add .worktrees/task-api -b agent/api, each creating a separate directory on its own branch from the same repository history; a coding agent started in each directory edits only its own files, and the two branches merge back independently once each is reviewed. This does not isolate everything: two agents whose worktrees both start a dev server will collide on the same port regardless of having separate files, and two agents running database migrations against one shared database can still corrupt it, because a worktree isolates the working directory, not a runtime environment or a database. A spec-driven task adds a step before any of this: the agent (or a person) first writes a short spec stating the intended behaviour and what "done" means, and only after that spec is agreed does the agent produce a diff -- turning "did the agent do something plausible" into "does the diff match what the spec said it would do," a sharper question for a human reviewing the pull request in part 3's sense to actually answer.

About this example About this part

This module's mini-coding workspace has no worktree support and no spec step; nothing here is run. Git worktrees as a standard pattern for isolating parallel coding agents, and spec-driven development as a named alternative to unstructured "vibe coding," are both described across many 2026 practitioner write-ups; neither is unique to one vendor's tool. Last checked: 15 November 2026.

Git worktree, spec-driven development

A git worktree is a second working directory checked out from the same repository, on its own branch, sharing one underlying git history -- so commits in one are visible from the others, but files on disk do not collide. Spec-driven development is writing a specification of the intended behaviour and its done-criteria before an agent produces any code, so the spec, not an open-ended prompt, is what the resulting diff gets checked against.

Example: two worktrees running agent/auth and agent/api never touch the same files on disk, which is exactly part 1's "the harness decides what can be touched" guarantee, extended to cover two agents instead of assuming there is only ever one.

For the curious What a worktree does not solve

A worktree isolates the filesystem, nothing else. Two agents in separate worktrees can still fight over a shared port, a shared database, or a shared external API with a rate limit -- the kind of collision module 3 of level 8 covers for multi-agent systems generally. Treating "it has its own worktree" as "it is fully isolated" is the mistake; a worktree answers exactly one question (whose files are these) and no others.

What the example does not do

About this example What the example does not do
  • There is no model. The candidate patches are scripted, so nothing here measures how often a real model games tests.
  • Six toy functions, no packages, build systems, dependencies, multi-file changes or flaky tests.
  • The runner is a temporary directory and a subprocess, not a real sandbox: do not run untrusted code with it.
  • The gate is a string heuristic; it misses obfuscated gaming (a lookup table slips through, shown in a test) and can flag legitimate comparisons to literals.
  • No retrieval over large repositories, no planning or multi-file refactors, no code review comments. Part 8 covers git worktrees and spec-driven development, without running either.
  • Optional real experiment: give a real model five small bugs in a repository you own with held-out tests, run it with and without the gate, and record merged versus truly correct and the cost per merged change.

Check yourself

An agent changes a function, the visible tests pass, and it merges. Is it correct?

Show answer

Not necessarily. In the six-task experiment, a test loop alone gave 5 merged and 3 truly correct: the other two were hard-coded for the visible input or had the test edited. Truly correct means passing held-out tests the agent never saw.

For the curious A gate is a heuristic, so keep held-out tests and a human

With protected test files and a review gate, 5 merged and all 5 were truly correct, and the task nobody could fix was reported as unsolved after 3 attempts. The gate flags common shortcuts (touching tests or CI, removing assertions, adding skips, special-casing a literal from the tests), but a lookup table instead of an if slips past it. The proposer is a script standing in for a model, so this tests the harness, not a model.

What you will use daily at work

Practice What it looks like
Make edits match exactly one place Refuse zero or several matches and large edits.
Protect tests, CI config and secrets Check paths after normalising them.
Run tests in a sandbox With a timeout and output cap.
Show the reviewer a pull-request summary Files, lines, test result and gate findings.