Revision: 1 Last modified: 2026-12-04T19:00:00Z
gate_runner.sh is the fastcycle gate executor. It has two distinct modes:
- Mode 1 (default),
verdicts— run the gates selected for a change, ordered cheapest-failing-first by historical fail rate and cost, and write a machine-readable verdict document. - Mode 2,
--mode shard— partition the gate set into write-disjoint shards so several gates can run in parallel without one shard writing what another reads.
This is the tool you run to actually execute a gate set. You do not usually decide which gates — that
is affected_set.py — and you do not usually decide whether to trust a previous run — that is
verdict_cache.py. gate_runner.sh consumes both and produces the verdicts.
Two design commitments matter when reading its behaviour:
- Ordering never changes the answer. AS-013 requires that running the same members ordered vs. unordered yields the identical verdict set. Ordering is a wall-clock optimisation, not a filter. The script runs every member to completion regardless of order, so the fast lane cannot silently drop a gate.
- Concurrency is clamped by the host, never hardcoded. The
--n-shardsvalue is a partition count. The actual parallelism handed toxargs -Pis a separate value obtained fromlib/host_guard.sh(nproc, §12.12 thread headroom, §12.6 memory ceiling). A constrained host degrades to fewer parallel jobs instead of failing to fork.
sh,python3,xargs.lib/gate_runner_order.pyandlib/gate_runner_shard.pybeside it (resolved relative to the script, not the caller'scwd).lib/host_guard.shfor mode 2 (and for any mode that spawns parallel workers).- A gate config file whose
history_logprovides the historicalfail_rate/mean_costused for ordering, plus an--affecteddocument naming the members. - No environment variables are read by this script directly;
host_guard.shreads its ownFC_GUARD_*overrides.
# Mode 1: run the affected gates, cheapest-failing-first
sh scripts/fastcycle/gates/gate_runner.sh \
--config gate_config.json \
--affected affected.json \
--order history-cost \
--out verdicts.json
# Mode 1 with the verdict cache disabled (always re-execute)
sh scripts/fastcycle/gates/gate_runner.sh \
--config gate_config.json --affected affected.json --no-cache --out verdicts.json
# Mode 2: carve the gate set into 4 write-disjoint shards
sh scripts/fastcycle/gates/gate_runner.sh \
--mode shard --manifest gates.json --n-shards 4Reading the result: in mode 1 the exit status is the verdict (0 all PASS, 1 any FAIL, 4 any
BLIND). In mode 2 the exit status reflects the shard run, and the requested --n-shards is a
partition count — expecting exactly 4 concurrent processes on a constrained host is the
misreading this design explicitly avoids.
| Code | Meaning |
|---|---|
0 |
Every declared gate produced a verdict, all PASS, and the verdict set is complete. |
1 |
At least one gate produced FAIL. |
2 |
Usage or config error (bad/missing flag, unreadable config). |
4 |
At least one gate returned BLIND — no honest verdict was possible, which is never a pass. |
A shard is a group of gates that may run concurrently with other shards. Two gates whose declared
writes path sets intersect are always co-scheduled into the same shard (write-set-intersection
union-find). Beyond that, two paths are additionally treated as globally exclusive and force their
gates into a dedicated shard that runs strictly after the parallel batch, one at a time, never
overlapping anything:
- the tracker database
docs/workable_items.db - the agent registry
docs/requests/agent_registry.jsonl
Those two are the single-writer resources; parallel writes to them are the corruption risk this partition exists to prevent (§11.4.119 single-resource-owner).
- Ordering requested but no history. Members are still run — ordering degrades, selection does not.
- A gate that is both a member and a writer of a serialised path. The serial shard wins; it is never co-scheduled into the parallel batch.
--no-cache. Bypassesverdict_cache.py; every member is executed. Note the known--no-cachescope gap documented inlib/gate_runner_order.py's own header.- Host with no thread headroom. Concurrency falls (possibly to
N=0), which for a zero-width fan-out means the work must be serialised rather than attempted and failed. - A missing gate script. Surfaces as a per-gate verdict rather than an abort; the run still produces a document so the absence is visible.
- Parses the mode and its flags;
exit 2on any usage error. - Mode 1: delegates to
lib/gate_runner_order.py, which reads the history log, orders members, executes each (through the cache unless--no-cache), and assembles theverdicts/v1document. - Mode 2: delegates to
lib/gate_runner_shard.py, which builds the write-intersection union-find, extracts the serially-scheduled gates, askslib/host_guard.shfor the real concurrency, and fans out withxargs -P. - Writes
--outand exits with the aggregate verdict.
Called by scripts/fastcycle/gates/backstop.sh (the full uncached lane) and
scripts/fastcycle/gates/flake_ledger.py.
Calls scripts/fastcycle/gates/lib/gate_runner_order.py,
scripts/fastcycle/gates/lib/gate_runner_shard.py, scripts/fastcycle/lib/host_guard.sh,
scripts/fastcycle/gates/verdict_cache.py.
Guarded by scripts/fastcycle/tests/test_gate_order_red.sh (T054, ordering, AS-013) and
scripts/fastcycle/tests/test_gate_shard_red.sh (T055, sharding, AS-014). Contract:
specs/004-fast-dev-cycles/contracts/affected-set-and-verdict-cache.md.
See also docs/scripts/affected_set.py.md (which produces --affected), docs/scripts/verdict_cache.py.md
(which decides reuse) and docs/scripts/host_guard.sh.md (the clamp).
2026-12-04 — bash -n scripts/fastcycle/gates/gate_runner.sh → exit 0. sh scripts/fastcycle/gates/gate_runner.sh with no arguments prints its usage and exits 2.