Agents and LLMsMethods and reviewreference
Running board cards through agent loops as waves with foreman
A sensor-gated loop makes one change and stops when objective checks pass. A backlog has dozens of cards. foreman is the tool that runs a named set of board cards (a wave) through such loops in parallel and tracks each card from board to worktree to graph node to review to landed commit. This page covers what a wave is, the order of its commands, the checks written into every card, how the judge’s tests are written first, and what four days of real waves measured. It sits beside the loop page, which owns the inner loop, and the model-routing page, which owns the ladder each card climbs.
Provenance
Section titled “Provenance”Everything here is read from the foreman repository’s own documents: its design contract, its judging notes, two research notes (the build-or-adopt survey of 2026-11-22 and the ladder comparison of 2026-11-23), the raw briefs and notes of its own two self-hosted waves of 2026-11-25, and the operator skill that drives it. The repository is private, so the citations name the document and are not linked. Counts are copied from those documents, not re-measured. The ladder comparison has three pairs of cards and its own note calls it a first reading. A number without a measured-or-asserted label in the evidence table is a record of what happened in a wave, not a test result.
- A wave is a named set of board cards. Each card gets a worktree, a loop manifest and one node in a single graph. A judge (the supervising person or agent) reviews each result and decides what lands. A green node is not a pass: in the first wave (18 cards), 17 nodes succeeded, 8 landed after review, 9 went back for rework and 1 failed1.
- Every card carries six sensors:
feature, the repo’s gates,discriminates,tests-kept,no-junk, andjudge-pinnedwhen the judge supplied tests. Each exists because a specific failure got through without it. - Judge-first means the judge writes a red black-box test per card before any coder starts, a second model family attacks those tests, and the coder works against a fixed oracle. Review of foreman’s own tests found blockers in 6 of 10 files before a coder saw them1.
- Cards that edit the same files go into a stacked wave: one shared worktree, a chain of nodes, landing in chain order.
- The cost driver is rounds to land, not token price. Starting cards on sonnet landed in 2.0 rounds on average against 4.3 for deepseek-first in a six-card comparison2.
- A wave is the wrong tool for a single card or for work with no objective sensor.
Topology
Section titled “Topology”As text: the board supplies the cards and the wave spec names them, the model ladder and the number of parallel jobs. For each card foreman creates a worktree and branch, writes a loop manifest with the six sensors, and adds a node to one graph that a detached process runs. The judge watches, reviews each finished node, records a verdict, sends cards back with redo, and lands passes through a gate that runs in a fresh clone of the branch.
Which do I pick
Section titled “Which do I pick”| Situation | Use | Why |
|---|---|---|
| One card, one repo | One worktree and one loop run | The wave machinery (baseline checks, event log, verdicts) is overhead for a single node |
| Several cards, each with a testable outcome, in separate files | A wave | Parallel nodes, one status view, one review queue |
| Several cards that edit the same files or regenerate the same tracked outputs | A stacked wave | Separate worktrees conflict at land; a chain does not |
| A card with no test or command that is red now and green when done | Not a wave; do it interactively | The loop has no oracle to gate on (see when not to use a wave) |
| A hand-built graph of loop manifests | A wave, once it has been done twice | Hand-built graphs piled up before foreman existed (see what problem a wave solves) |
What problem a wave solves
Section titled “What problem a wave solves”The loop page’s topology shows one loop run and a graph of several. Running a backlog that way by hand meant writing a card heredoc, creating a worktree per card, writing per-repo gate sensors and tracking by hand which branch answered which card. The 2026-11-22 survey recorded 15 hand-built graphs under the agent scratch area on the dev box (121 nodes, 57 manifests)3.
The same survey looked at 28 existing tools. Six were eliminated as software-as-a-service only or macOS only, none read Vikunja, the board used here, and none had a governor with rollback, a write-scope fence and a model ladder: their gates were shell exit codes or reviewer agents3. foreman was built as a thin Go command-line interface (CLI) over the board CLI, the worktree helper and the loop runner. It holds no credentials, and everything it does not own (card text, worktrees, node state, diffs) is read from the tool that does4.
Parallel agents also hit problems that a count of nodes does not show. The survey’s reading of public accounts lists six recurring failure modes: review becoming the bottleneck and turning into rubber-stamping; tests deleted or weakened to declare victory; merge conflicts and duplicated work across branches; prompt injection through task text; provider in-flight budgets; and orphaned worktrees and lost state3. In its own first sample, 3 of 8 worker results had a wrong core rule that their own tests encoded3.
The pipeline
Section titled “The pipeline”| Step | Command | What it does |
|---|---|---|
| Plan | foreman plan wave.json | Validates the spec, resolves each card and its repo, detects the gates and the feature sensor, writes one manifest per card, the graph and a planned event. Reads the board and git only. Refuses a wave name that already ran unless --reuse is passed |
| Baseline | foreman start wave.json --dry-run | Runs every sensor on the unchanged tree. Every feature sensor must be red and the gates green. A card whose feature is already green is refused, and so is a wave whose feature command is a bash syntax error |
| Start | foreman start wave.json (--checked when unattended) | Creates the worktrees, claims the cards and launches the detached graph. --checked launches nothing unless every baseline is right |
| Watch | foreman watch WAVE | Prints a line per node when its state changes: status, iteration, model and rung, failing sensors, agent cost |
| Review | foreman review WAVE REF | Shows the diff, the node summary, the log tail, the test-count delta and the files shared with other open branches |
| Verdict | foreman verdict WAVE REF pass|fail|redo "why" | Appends the judge’s call to an event log and posts it as a comment on the card |
| Redo | foreman redo WAVE REF... | Re-runs cards after redo verdicts, rebuilding their manifests from the edited spec |
| Land | foreman land WAVE REF | Refuses unless the latest code verdict is pass, runs the gates in a fresh clone, then lands the branch |
| Release | foreman release WAVE REF | Removes the worktree and moves the card back to To-Do |
foreman run wave.json chains plan, a lock on the local-model lane when the ladder starts there, start --checked and watch into one unattended command4. Starting a wave whose ladder begins on a local model queues behind the single GPU (graphics processing unit), which the llmc page covers.
Each card’s loop manifest carries fixed limits: 6 iterations, a stall patience of 1 and a stuck-sensor patience of 2, 30 minutes per sensor and 60 minutes per agent iteration4. Six fixed rules go into every task: read the exact current text before an edit; never delete, skip or weaken an existing test; no git commands that change anything and no deploys; never run find on the root or home directory; test a parser of a real tool’s output against a fixture captured from that tool; keep the Go cache and build output outside the repository4. Card text enters the task as quoted data, every line prefixed with > , under a fixed preamble that says it may contain instructions to ignore. That answers the prompt-injection failure mode, where a public issue-triage bot put an issue title straight into its prompt and the injected instructions led, through a poisoned build cache, to a stolen publish token and an unauthorised package release5.
The state lives outside every repo as one directory per wave: the spec, manifests, graph, per-node logs and an append-only events.jsonl. State survives a compacted or lost session because foreman reads the log on disk, never the conversation4.
Sensors every card gets
Section titled “Sensors every card gets”The loop runner treats every sensor as an exit code, so a red sensor rolls the work back and the next iteration sees the failure. foreman writes six into each manifest.
| Sensor | What it checks | The failure that put it there |
|---|---|---|
feature | The card’s test or command is red on the unchanged tree and green when the card is done. The loop refuses a feature that is already green | Agents satisfy the done-condition, not the card. A “named test passes” sensor was met by a test of behaviour that already existed1 |
| gates | The repo’s build, test, lint and vet commands, detected per repo or set per card; a registry setup step builds generated artifacts a fresh worktree lacks | Gates that never build: one repo’s make build broke while tests and lint passed. Fresh worktrees lacked a built web bundle1 |
discriminates | The feature test must fail on the base commit’s production code, so it needs the change it claims to test | The same test-of-existing-behaviour failure, caught mechanically instead of by reading1 |
tests-kept | No test name removed or renamed, no skip or only line added, compared against the merge base | A test was deleted although the task rules said never to1 |
no-junk | No cache directories, untracked build output, files over 1 MiB or binaries containing a zero byte; a per-card allow list covers intended binaries | Agents pointed the Go cache inside the worktree and the commit node committed thousands of cache files; in the redo of that wave two branches still did1 |
judge-pinned | The judge’s test files are byte-identical to their plan-time hash, minus a removable gate statement | tests-kept catches a deleted test but not an edited assertion4 |
A feature or gate command containing a pipe gets set -o pipefail, because A | tail -4 returned tail’s status and a piped feature passed with every suite failing4. discriminates is switched off per card, by the judge only, for a fix that lives in test or configuration files, since such a fix can never fail on base4. A feature command must not name source files, because discriminates overlays every file a command names and correct work then fails1.
Judge-first contracts
Section titled “Judge-first contracts”A cheap coder converges quickly on an oracle somebody else chose and badly on one it chooses itself. foreman’s own build is the record: against judge-written tests every node went green in one or two iterations1. Judge-first applies that to every card.
- The judge writes the contract: numbered behaviours and the design decisions, in prose.
- A test per card is written from the contract as a black-box test that drives the real binary or service, red on the current code. In foreman’s two self-hosted waves a sonnet worker wrote each file from a brief, and the judge reviewed the file6.
- A second model family reviews every test file, read-only, before the files are committed. The reviewer is briefed with the real tool sources the test stubs model.
- The files are committed in the card’s worktree and pinned with
feature.pin. The coder sees a failing test, cannot edit it, and may delete only the gate statement described below. - After the pass verdict,
foreman landstrips the gate in the fresh clone, runs the gates ungated and adds a commit namedtest: ungate judge filesto the branch before landing.
A red test cannot sit in a repo whose gates run it. The judge wraps each file in a gate keyed on one environment variable (JUDGE): skipped normally, run by the feature sensor. The worker may delete the whole gate statement and nothing else, since a rewritten gate could carry arbitrary code past the pin hash. Go, Python and JavaScript or TypeScript forms are stripped automatically at land. A gate form that cannot be stripped (a Rust feature flag, a required-features entry) refuses the land and names file and form, and --keep-judge-gate overrides it with a warning1.
Across ten judge-test files for foreman’s own two waves it found blockers in 6 and should-fix items in 3 more, and every blocker held up when checked1. The findings were of six kinds: a process-tree check that passed vacuously because foreman had already exited, a shell tail-exec that let a kill outside the process group pass, a stacked test that committed card k before measuring it, a stub stacked state the real graph runner never produces, a contract that left later stacked cards unlandable, and a sleep that hid whole-second timestamp bugs1.
The briefs also ask each worker to say where its card’s premise is wrong. Four of the ten cards had a wrong premise: redo already rebuilt manifests from the spec, foreman wrote no node arguments for the flag a card assumed, redo already reset the redone nodes, and one card needed changes in land and review, not only in redo1.
The judging notes record where judge-written tests fell short:
- The coder passes what the tests cover and no more. A stacked-mode card came back green with the plan step and one refusal done, because those were the only tests, and the mode was unusable1. A test for a mode or flow drives it end to end on a temporary repo.
- Judge tests carry wrong premises too. One requirement would have re-summarised every affected session at model cost. Trace what else reads a field before pinning a requirement1.
- Asks that live only in notes get skipped. Performance, comment and assertion requirements go into a test, or the judge fixes them as lead1.
Stacked waves
Section titled “Stacked waves”Separate worktrees give each card its own branch, and cards that edit the same files then conflict at land. Firmware id tables, layouts and cards that regenerate the same tracked outputs are the cases the notes name7. A wave with "stacked": true replaces them with one shared worktree per repo and a chain of nodes4:
- Each node commits on top of the previous one and writes a node branch,
agent/<wave>-n-<card>. - The
discriminatesbase is the previous card’s node branch, not main, so a card is measured against what the chain already contains. reviewdiffs a card against the previous node branch.landrefuses a card unless every earlier card in its chain has a pass. It runs the fresh-clone gate on the node branch and fast-forwards main. If main moved and the judge rebased the stack branch,landfinds each node’s commit by patch id and moves the node branch there.- So that the stack compiles card by card, each card’s judge file sits behind its own gate, such as a per-card Cargo feature1.
foreman’s own wave found that redoing card k after card k+1 had committed put k’s second attempt on top of k+1, so the node for k contained k+1’s work, discriminates measured against the wrong base and review showed both. The fix resets the shared worktree to the earliest redone card’s chain parent before relaunching, keeps later cards’ node branches, and holds those nodes until they land4. A redo on a stack whose tip already passes needs new red tests, or discriminates reports the feature as non-discriminating1.
Review, verdicts and landing
Section titled “Review, verdicts and landing”The judge reads every diff. The wave’s reviewer runs on a different family from the coders, one reviewer per about 5 cards, read-only, with a brief that asks it to find evidence a change is wrong, not to confirm it. The judge then re-checks each claim a verdict rests on, for passes and redos alike, because reviewers report false claims too: a hook bypass that never happened, a round-3 commit that was the judge’s own test1.
Landing runs the card’s gates in a fresh clone of its branch with no user git configuration and a fixed identity, so a stale worktree or a dependency on the developer’s configuration fails before the land, not in continuous integration (CI). The latest code verdict decides: a pass that a later redo or fail superseded does not land. A card marked as needing a hardware check also needs a board-ok verdict recorded after its latest code verdict4.
Record a verdict and run redo in separate calls, because batched, redo ran first and fed back the previous round’s verdict. After every land, watch the repo’s CI run for the landed commit: the land gate ran as the developer and CI ran as root, and a test that relied on file permissions passed one and failed the other. A CLI repo’s CI was red for 3 hours after a land before anyone noticed. Both rules come from the judging notes1.
Operational lessons and numbers
Section titled “Operational lessons and numbers”| Lesson | Number | Source |
|---|---|---|
| A green node is not a pass | Wave 1 (18 cards): 17 nodes succeeded, 8 landed on first review, 9 reworked, 1 failed | judging notes1 |
| Rounds to land decide cost, not token price | Six cards in three pairs: sonnet-first 2, 2, 2 rounds (mean 2.0); deepseek-first 4, 4, 5 (mean 4.3). Agent spend was about $0.3 to $0.9 per round in both arms | wave 3 note2 |
| A fresh Go cache per scratch directory rebuilds the standard library each time | About 17 minutes per card at baseline; checks now use the caller’s or the default cache | operator skill7 |
A cold Rust build is slow enough to run land in the background | 15 or more minutes for gates; --warm keeps a per-repo clone and its build directory | operator skill7 |
| Scratch directories fill the disk | A land ran out of space on the temp filesystem after killed runs left scratch behind; the root volume was at 99% used | design contract4 |
| Interrupted waves strand work | In the first self-hosted wave, 5 of 6 cards were complete inside the first, interrupted iteration | judging notes1 |
| A tight oracle makes a short wave | The second self-hosted wave went green in 21 minutes: 3 cards on sonnet’s first iteration, 1 on kimi’s second | judging notes1 |
| Test review pays before coding | Blockers in 6 of 10 test files, should-fix in 3 more | judging notes1 |
| Premises are often wrong | 4 of 10 cards had a premise the code contradicted | judging notes1 |
| A local model works under a tight oracle | Seven cards, unattended: the local model landed 3 in one iteration at no cost and a 4th after a judge fix; sonnet took 5 rounds on one card and 1 round on each of two | operator skill7 |
In the ladder comparison the extra deepseek rounds fixed real defects: a test that asserted the opposite of the spec, a path compared by spelling instead of resolved, a committed Makefile that moved every developer’s Go cache into the temp directory, and timestamps shifted by a timezone flag. Caveats from the note: three pairs, the last gap on one card per arm closed by judge tests instead of a coder round, and the deepseek arm escalated to sonnet in later rounds2. Agent spend per card cannot be recovered for that wave because the report kept only the last round’s log, which is fixed for later waves2.
Three operational behaviours came out of the interrupted waves and the disk failures.
- Interrupted wave recovery. A killed node leaves half-done work. A plain
redorefused it at baseline because the feature already passed on the unchanged tree.redonow adds--resumefor a node whose worktree holds uncommitted work outside the loop’s own files, or when forced. The graph itself is started through a short-lived launcher with its own session, so killing foreman,runorwatchleaves the wave running, and the judge must stop the graph to stop the wave4. - Disk preflight.
startandrunrefuse before any work when the root filesystem is over 90% used or the temp directory over 80%, andlandrefuses when the temp directory has under 4096 MB free. Scratch older than 6 hours is swept at the start ofdiscriminate,landand the preflight4. - Shared scratch. Reviewers share one memory-backed temp directory (24 GB). A review once filled it and killed a sibling reviewer. Each review gets one scratch directory and removes it at the end1.
A cheap first rung can raise the cost of a wave. Cheap first rungs went green fast on wrong or vacuous work and never escalated, because a green node does not trigger the ladder; each extra round cost a coder run, a review and the supervising model’s judging1. The recorded policy is a sonnet-class first rung, escalating to a stronger model, with a second family as reviewer for anything sensitive to security, migration or state7. The routing page covers how a ladder is configured and what a local-only ladder does when it stalls.
When not to use a wave
Section titled “When not to use a wave”- A single card. A worktree and one loop run give the same sensors without a spec, a graph or an event log. The operator notes say so directly7.
- Work with no objective sensor. The
featurecheck needs a command that is red now and green when the card is done. Documentation or layout cards can supply a custom command, but a card whose outcome is judgement (a design choice, a research question) gives the loop nothing to gate on. The loop page lists tasks with no spec to gate on as a case where a sensor-gated loop does not fit. - A card that spans repos. A wave resolves a card’s repo from its board project, so a card that spans two repos is split into one card per repo first7.
- Hardware that no test can reach. The
boardCheckflag still holds the card at a recorded manual check, so the wave only automates up to that gate4.
Decision guide
Section titled “Decision guide”As text: with one card, use a worktree and a loop run. With several cards and no red-then-green command for some of them, work those interactively or write the test first. Where cards edit the same files or regenerate the same outputs, stack them. Otherwise run a plain wave.
Evidence
Section titled “Evidence”| Claim | How it was checked | Status |
|---|---|---|
| Wave 1: 17 of 18 nodes green, 8 landed on first review | Counts in the judging notes, written the day of the wave | recorded, not re-run |
| Sonnet-first 2.0 rounds, deepseek-first 4.3 | Six cards, three pairs, a seeded coin per pair, rounds counted from the verdict log | measured, n = 3 pairs, a first reading |
| About 17 minutes per card baseline from a per-scratch Go cache | Operator note on the cause and the fix | recorded, not re-run for this page |
| Blockers in 6 of 10 judge-test files; 4 of 10 premises wrong | Second-family review and worker notes for foreman’s own two waves | recorded; each blocker checked by the judge |
| A 21-minute wave on a tight oracle | Wave notes in the judging document | recorded |
Sensor semantics (discriminates, tests-kept, no-junk, judge-pinned), defaults, disk limits, stacked behaviour | Read from the design contract | read from the contract; the repository’s tests exercise them, none were run for this page |
| The prompt-injection failure behind the quoted card text | Read from the public write-up | asserted from a primary source |
Related docs
Section titled “Related docs”- A sensor-gated coding-agent loop compared with 2026 harnesses - the loop each card runs, its governor and the graph layer a wave builds on.
- Model routing in a coding-agent harness - how the ladder each card climbs is configured and what the local rung costs.
- Subagents, worktrees, and parallel agent work - the worker kinds, the worktree rules and why workers never run mutating git.
- A kanban board for coding agents - the board a wave takes its cards from.
References
Section titled “References”-
foreman repository (private),
docs/judging.md, lessons from the first wave through the second self-hosted waves (2026-11-22 to 2026-11-25), and its adversarial pre-review brief. Not linked. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 ↩16 ↩17 ↩18 ↩19 ↩20 ↩21 ↩22 ↩23 ↩24 ↩25 ↩26 ↩27 -
foreman repository (private),
docs/research/2026-11-23-wave3-ab.md, “Wave 3: ladder A/B”. Not linked. ↩ ↩2 ↩3 ↩4 -
foreman repository (private),
docs/research/2026-11-22-agent-fleet.md, “Running a wave of board cards through agent loops: build foreman or adopt?”. Not linked. ↩ ↩2 ↩3 ↩4 -
foreman repository (private),
docs/design.md, sections “Model”, “Loop manifest”, “Commands” and “As built”. Read 2026-11-25. Not linked. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 -
S. Thoemmes, “How ‘Clinejection’ turned an AI bot into a supply chain attack,” Snyk, 2026-02-19. Read 2026-11-25. https://snyk.io/blog/cline-supply-chain-attack-prompt-injection-github-actions/ ↩
-
foreman repository (private),
docs/research/raw/2026-11-25-fm-waves/, the judge-test brief and per-card worker notes. Not linked. ↩ -
Operator skill for foreman (private), “Wave workflow”, “Sensors in every manifest” and “Model use”. Not linked. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7