Skip to content

The Loop

Arnel Robles edited this page Oct 20, 2026 · 2 revisions

The Loop

One pass of the method, from an idea to a merged change. Each step links to the page that covers it and names the README section that holds the reasoning.

Step What happens Who or what README
1 Shape the ticket: one agent pass, agent-ready, risks answered. See Shaping a Ticket. You, with /lean-agent:shape-ticket 0
2 Triage inline. Sort into tiers, do the cheap ones by hand, close duplicates. You, no agents 1
3 Draft the change, with builds only. Open a brain agent item when the drafter starts and close it when it reports back. The cheap model 2, 14
4 Run the mechanical checks: the repository's full gate script, the holdout check, needs-review.sh. Scripts 4, 10
4a Run the tests once, as one phase. Each test project goes in with brain queue add, one test-phase drains the queue, and failures land in brain. The fix round works from brain list --open and closes each entry with its fix commit. See Test Queue. brain, test-phase 11, 14c
5 If needs-review.sh prints anything, the critic runs. See Review Rules. The diff decides 3
6 Critic: hunt, then refute. See Adversarial Review. Two fresh agents on the cheap model 2, 12
7 Findings go back to the agent that wrote the change. The same drafter, resumed 5
8 A finding not fixed in one round goes to the strong model. The strong model 2
9 Merge. At most four changes in flight. A person, or a standing authorisation 6, 14h
10 Measure the batch. See Measuring a Batch. workflow-cost.py, log-review.sh 7, 15
11 Retro. See Retro. /lean-agent:lean-retro, you approve 16

Tiers

Tier What
0 Docs, tests only, config, CI files, README sweeps
1 A feature inside one module, additive
2 Core, auth, tenancy, data shape, anything reachable without a login

The tier comes from the ticket and decides how you triage. It does not decide whether a critic runs. The diff does, because the tickets that read as small are the ones that touch auth.

Rules that hold through every step

  • Scripts, not instructions. Run the repository's full gate script, not the one gate that seems relevant.
  • The second time something is reasoned through, it becomes a script with a test. Fix the script, not the run.
  • No follow-up issues from review findings. A finding is fixed in the change or dropped. One that is real and cannot be fixed there goes on the checklist of the open issue that owns that area.
  • A task is not done until the pull request URL exists. An agent that hands back without one says so on the first line of its report.
  • Every agent writes under its own scratchpad subdirectory. Never a bare pr-body.md at the root.
  • Every wait loop has a deadline. Subagents run commands in the foreground, and every gate piece finishes under the 600 second tool timeout.
  • Nobody waits in a loop. Enqueue the test job and end the turn. The drainer's exit is the one notice. Never a sleep or pgrep loop.
  • State that changes lives in brain. Failures, deferred minors, questions for the person, blockers and running agents go in Brain, so they survive a compaction. Ledgers keep rulings only.
  • Heavy commands queue. Builds, installs, containers and browsers go through heavy.sh, one command per lane.
  • Parallel changes never append to one shared file. One fragment file per change.
  • Plan the steps that need a person up front. A run ends with one block of exact commands for the person.
  • Verify content and identity, not status codes. A page baked empty still answers 200. Use check-deployed-sha.sh to prove a deploy.

In one session

With LEAN_AGENTS=one, steps 3 to 8 happen in the one session, one ticket at a time. The critic still runs as two passes: write the candidates down, then refute each one from the code and a check. See Settings.

Clone this wiki locally