Skip to content

Gates

Gates are your own test, lint, typecheck and build commands, which Astranize runs after every developer pass and which send the task back when they fail.

6 min read13 pages in Concepts

A gate is a command that has to succeed before the task can move on, such as npm test or npm run lint. After the developer writes code, Astranize runs your gates in the task’s worktree. If one fails, the task goes back to the developer with the error output, and the developer tries again.

Gates are plain shell commands that must exit with code 0. No agent decides whether the tests passed: the exit code does.

You list gates per repo in the workspace’s config.yaml. This repo has one gate that runs the tests:

config.yaml
repos:
api:
path: ~/code/notes/api
base_branch: main
gates:
- { name: tests, command: "npm test" }

That is all you need. The next time a task touching api finishes a developer cycle, the check step of the flow runs npm test in the task’s worktree. When it exits 0, the task moves on to review. When it does not, the task goes back to the developer.

Each repo can have several gates, and they run in the order you list them. You can also set a time limit per gate with timeout_seconds:

config.yaml
repos:
api:
path: ~/code/notes/api
base_branch: main
gates:
- { name: tests, command: "npm test", timeout_seconds: 900 }
- { name: lint, command: "npm run lint" }
web:
path: ~/code/notes/web
base_branch: main
gates:
- { name: typecheck, command: "npx tsc --noEmit" }
- { name: build, command: "npm run build" }

Only the repos the task actually touches run their gates. The ideator decides those repos when it writes the spec, so a task that only changes web never runs the api tests.

The check step works like this:

  1. For each repo in the task, in order, it runs that repo’s gates in the order you listed them, with the worktree as the working directory.
  2. Each line of output goes to a log file and to the live event stream.
  3. A gate passes when it exits 0 without running past its time limit.
  4. At the first failure, it stops. The remaining gates are recorded as skipped, so the next cycle starts from a clear picture.
  5. All results are saved for the cycle, where the reviewer also reads them.

When a gate fails, the task follows the check step’s fail route, set with on_fail in the flow. In the default flow that route is developer. Astranize then:

  • adds a gate_failed entry to the task history, with the repo and gate name;
  • counts one return against max_returns (see Tasks);
  • starts a new developer cycle with the failure in the prompt: the gate, the repo, the command, the exit code and the last lines of output.

How many output lines the developer sees is set by error_tail_lines in config.yaml (default 80).

Give every check step an on_fail. Without it, Astranize has nowhere to send the task and stops it with Step "<id>" has no route "fail". After the last allowed return, the task blocks with reason max_returns.

Here the developer wrote a file in the wrong folder. The tests gate failed, lint was skipped, and the task went back to the developer for cycle 2:

{"type":"step_started","taskId":"t-0001","step":"gates","cycle":1}
{"type":"gate_started","taskId":"t-0001","cycle":1,"repo":"api","name":"tests","command":"node -e \"process.exit(require('fs').existsSync('feature.txt') ? 0 : 1)\""}
{"type":"gate_result","taskId":"t-0001","cycle":1,"result":{"repo":"api","name":"tests","status":"failed","exitCode":1,"timedOut":false,"durationMs":33,"outputTail":"","culprits":[],"culpritsOutsideDiff":[]}}
{"type":"gate_result","taskId":"t-0001","cycle":1,"result":{"repo":"api","name":"lint","status":"skipped","exitCode":null,"timedOut":false,"durationMs":0,"outputTail":""}}
{"type":"step_finished","taskId":"t-0001","step":"gates","cycle":1,"outcome":"failed"}
{"type":"step_started","taskId":"t-0001","step":"developer","cycle":2,"model":"sonnet"}

The same results are saved on disk for the cycle:

runs/t-0001/cycle-1/gates.json
[
{
"repo": "api",
"name": "tests",
"command": "node -e \"process.exit(require('fs').existsSync('feature.txt') ? 0 : 1)\"",
"status": "failed",
"exitCode": 1,
"timedOut": false,
"durationMs": 33,
"outputTail": "",
"culprits": [],
"culpritsOutsideDiff": []
},
{
"repo": "api",
"name": "lint",
"command": "node -e \"process.exit(0)\"",
"status": "skipped",
"exitCode": null,
"timedOut": false,
"durationMs": 0,
"outputTail": ""
}
]

Gate commands are templates. Before running one, Astranize fills in values from the task:

  • {workspaceDir}, {taskId}, {repo} and {worktree};
  • {ports.<name>}, the port reserved for this task (see Queue and capacity).

For example, npm test -- --port {ports.web} lets two tasks run their tests at the same time without fighting over a port.

While the gates run, the task’s card on the board says “Gates for cycle N” and names the gate that is running. Open the task and go to its session to see the output: each gate appears in the timeline as a command line with its result (passed, failed, skipped or running) and how long it took. The Summary panel on the right shows the current step, the cycle and the returns so far.

The session of a running task during the gates of cycle 2. In the timeline, the Gates step lists pnpm test passed in 38s, pnpm lint passed in 6s, and tsc --noEmit still running. The Summary panel shows Gates as the current step, cycle 2 of 4 and 1 of 3 returns.
The gates of cycle 2 in the session: two passed, one still running.
Key Required Default Meaning
name yes Label shown in events, the log file name and the app.
command yes Run by the workspace shell in the repo’s worktree.
timeout_seconds no 900 The gate fails when it runs longer.

The keys are checked with the rest of the config, so a typo like timeout: 60 fails to load instead of being ignored.

Field Meaning
repo, name, command Which gate, and the command after the template values were filled in.
status passed, failed or skipped.
exitCode null when skipped.
timedOut true when the time limit stopped it.
durationMs Run time.
outputTail The last lines of output.
culprits On failure: file paths found in the output, such as FAIL src/notes.test.ts or src/notes.ts:12, relative to the repo.
culpritsOutsideDiff The culprits the task did not change. A failure there often means the base branch was already broken.
  • Output of each gate: runs/<task>/cycle-N/gates/<repo>-<gate>.log
  • All results of a cycle: runs/<task>/cycle-N/gates.json