gate --help lists every flag. This file is what help cannot carry: where
gates come from, .gate.toml, layering, and exit codes.
Git's own semantics: leading only, repeats accumulating and read relative to
the last, an absolute path resetting, -C "" a no-op, glued -C<path>
refused.
for d in ~/src/*/; do gate -C "$d" --quiet || echo "FAIL $d"; done-q is --quiet: a pass prints nothing, a failure still narrates. There is
no -v / --verbose; --profile and the failure log are the extra detail.
Missing directory argument: 129. Unenterable: 128. A relative --log resolves
against it. Detected gates run at the project root; a command you name runs in
the -C directory.
A stored result that is still fresh skips the run: same HEAD and working-tree
status hash as now, not partial, exit 0, same root, younger than 10 minutes,
and the stored run was not --e2e. It prints
gate: ok (unchanged since <HH:MM:SS>) and exits 0 without starting anything.
--force always runs. A flag or gate selection that differs from the stored
run also runs. Isolation is part of that: a pre-push hook turns --isolate on
by itself, so it reuses only a pass that was isolated too. rgit land gates
with --isolate in a repo that has a pre-push hook, which is what lets the
push's hook run return at once instead of running everything a second time.
The stored run also keys on what it ran with: the version of each toolchain a
detected gate invokes (go, bun/bunx, node/npm/npx/pnpm/yarn,
cargo/rustc, uv, python) and of the toolchain each manifest in the
root names (so a gate behind make or sh -c is covered), the path, size and modification time of
the file each gate's program resolves to, the content of the .env* files, go.work and go.work.sum in the root,
in each gate's directory, and anywhere beneath the root that git ignores (so
the tree hash misses them), and these environment variables: GOFLAGS,
GOWORK, GOENV, MAKEFLAGS,
CGO_ENABLED, GOOS, GOARCH, GOEXPERIMENT, GOTOOLCHAIN, NODE_ENV,
NODE_OPTIONS, RUSTFLAGS, CC, CXX, CARGO_*, plus any env a gate
declares in .gate.toml, and the limit each gate runs under (--timeout, a
.gate.toml timeout, or off). A change to any of them runs the gates.
--list shows the decision and runs nothing. --json is the same listing for
a program: "schema": 1, then each gate's name, resolved argv, display,
source, shadows, group; plus root, config, notes, warnings. Gates
sharing a group run serially; groups run concurrently (--jobs,
--fail-fast: serial). --json is global:
gate doctor --json is the same document as gate --json doctor.
A scalar with nothing to say is omitted (a wrapped command has no root /
name / source; workspace only when it differs from root). Collections
are always [], never null.
A bare gate leaves e2e gates out and says so. gate --e2e runs them;
gate run <name> runs one. CI still runs them.
E2e when the name has an e2e segment, the command runs playwright test, or
it runs a package script / turbo task that is e2e by either test.
gates.<name>.e2e overrules. --list still names them (e2e, skipped by default); --json marks "e2e": true, "skipped": true and drops skipped
under --e2e. A project whose every gate is e2e refuses a bare run.
The convention fuzz gate is opt-in the same way: a bare local gate skips it
(fuzz, skipped by default, "skipped": true), gate --fuzz or GATE_FUZZ=1
runs it under the fuzz budget, and a git pre-push hook and CI run it without
asking. gate run fuzz runs it too. A pass with fuzz and one without are
different gate sets, so neither stands in for the other.
--json with doctor, fix, or record names that report instead.
gate --failed still detects, then runs only the gates whose last result
record for this root had status fail, timeout, error, cancelled, interrupted, or
not-found, plus those
skipped because a needs gate did not pass or an earlier gate failed (a serial
group or fail-fast). The record
must name the current HEAD and this tree's status hash. Missing, stale, or
no such gates, or none of them in this run (quick): the reason on stderr, exit 129. The re-run is a subset, so
the record it writes is partial. Not combined with gate run or a named
command.
A bare gate or gate run installs dependencies, which runs their lifecycle
scripts. So when the repo has no .gate.toml and its origin is outside the
trusted orgs, gate runs nothing and exits 129 with a one-line message naming
--trust; --trust restores the normal run for that invocation. A repo with
no origin is trusted. The origin host must be exactly github.com,
dev.azure.com or ssh.dev.azure.com; the org is the first path segment
(Azure DevOps: the namespace). Default orgs: Rethunk-Tech, Rethunk-AI,
Albino-Geek-Services, Citadel-Inc, PeleOs-LLC, AlbinoGeek, LethalModding,
Totative. Replace the list in ~/.config/gate/config.toml:
trusted-orgs = ["my-org"]. A wrapped command, --list and --json are not
gated.
A bare gate or gate run first runs the workspace lockfile's frozen install
once (and one per CI subdirectory package):
bun install --frozen-lockfile, yarn install --frozen-lockfile (--immutable on Yarn berry), npm ci, or
pnpm install --frozen-lockfile. A uv.lock (walked separately so it cannot
hide a Node lockfile) runs uv sync --locked in its directory; both run when
both exist. Prints gate: install: <command> (in <workspace>) on stderr. A
failed install is the run's verdict; no gate runs. A wrapped command, --list
and --json never install.
An install is bounded like a gate: it runs under --timeout in its own
process group, so a stop reaches the postinstall scripts it started, and a
stalled install is killed at the limit and reports 124 rather than hanging.
--json is what would run. --ndjson writes one JSON line per gate as it
finishes, arrival order. Text on stderr stays declaration order. Each line
is the same object a result record stores under gates, so it has no
schema of its own.
status is a word, never a code: ok, fail, timeout, interrupted,
cancelled, not-found, error, skipped. A command exiting 124 is not a timeout.
code and ms are absent for a gate that was skipped; a not-found gate
carries code 127 and ms 0. reason is skip/timeout
detail; error is gate's own failure beside the command's verdict. cache is
"cached" or "N/M cached", absent when unrecognised. dir and timeout
are the listing's configured values (off for 0), omitted where the listing
omits them.
stdout is the stream alone (--quiet). Cannot combine with --json or
--list. Exit status is unchanged.
for d in ~/src/*/; do gate -C "$d" --ndjson; done | jq -r 'select(.status != "ok") | "\(.name) \(.status) \(.log)"'Each line a gate writes is printed to stdout as it arrives, prefixed
[<gate name>], so concurrent gates interleave line by line. Logs are
unchanged and the end-of-run summary still prints, without re-quoting the
failure tail. A line over 8 KiB is emitted in prefixed chunks.
On by default when CI is set and not false/0, or GITHUB_ACTIONS=true.
--stream forces it on; --no-stream forces it off. Off under --json and
--ndjson, whatever else is set.
When GITHUB_ACTIONS=true, each gate that fails or times out prints one
workflow command, built only from that gate's metadata -- never by reading
the child's output:
::error title=gate <name>::<status> <exit/timeout> log: <path>
<status> is fail or timeout; the next field is the exit status, or
124 for a timeout. Off outside GitHub Actions and under --json /
--ndjson.
Before the first gate, while the 1-minute loadavg exceeds 3 x the CPU count,
gate waits (polled each second, at most 2m per run) and prints one
gate: waited T for load (L/N) line to stderr. GATE_MAX_LOAD=<load> sets the
ceiling absolutely. --no-load-wait or GATE_NO_LOAD_WAIT=1 skips it. Linux only: no /proc/loadavg, no wait.
A push that passes locally and fails in CI is usually the machine, not the
code: tests that read the global git identity, a signing file, ~/.cache, or
an XDG directory see a developer's setup here and a bare runner there.
--isolate runs every gate with a throwaway HOME (a fresh temp directory,
removed after the gate), GIT_CONFIG_GLOBAL=/dev/null, GIT_CONFIG_NOSYSTEM=1,
and the XDG_CONFIG_HOME / XDG_CACHE_HOME / XDG_DATA_HOME /
XDG_STATE_HOME variables unset.
It is on by itself inside a git pre-push hook. There is no hook-name variable
to read: git exports the same GIT_* variables to every hook, and lefthook
exports none, so gate walks its process ancestry and recognises the hook by the
git push or lefthook run pre-push above it. --no-isolate overrides that,
and --isolate asks for it anywhere else. Ordinary runs are untouched, which is
the point: an always-isolated gate is always cold.
The toolchain caches stay, resolved from the real HOME before it is swapped
and passed explicitly: GOPATH, GOMODCACHE, GOCACHE, npm_config_cache,
PNPM_CONFIG_STORE_DIR, BUN_INSTALL_CACHE_DIR, UV_CACHE_DIR, GOLANGCI_LINT_CACHE, PLAYWRIGHT_BROWSERS_PATH. PATH is
passed through. So an isolated run is what CI would see, at local speed.
[gates.sign]
run = "codesign ..."
isolate = falseisolate = false is a gate's own opt-out, for one that genuinely needs this
machine. Absent, the run's answer stands; --isolate does not override it.
--profile prints wall vs summed gate time, then slowest first. Output only.
Gates that never ran are omitted. Refused beside --list, --json, doctor,
fix, or record.
A pass over budget still exits 0 and names the three slowest. Default 10s, or
2m when an e2e gate ran. --budget D or top-level budget = "15s" replaces
it (flag wins); 0 silences it. A named command has no budget. Time spent waiting for load before the first gate is not counted; the line says (waited Ns for load) and the record keeps load_wait_ms.
A 0 can mean ran or cached. gate labels from the log; it never changes the
exit status.
| Tool | Marker |
|---|---|
| turbo | Cached: N cached, M total (every run) |
go test |
(cached) on a package ok/FAIL line |
| GNU make | '<target>' is up to date. on every line the gate printed |
(cached) is all units cached; (N/M cached) is some. Unrecognised output is
silent — this cannot tell "fresh" from "unknown marker".
--force-cache: TURBO_FORCE=1, GOFLAGS=-count=1, MAKEFLAGS including
-B; -count=1 on go test; -B on a Makefile target. A run string is
not parsed; the env vars reach a nested tool.
- Makefile targets
- turbo.json tasks (inside a workspace member, only that package's tasks)
- package.json scripts
- Conventions for remaining roles:
go build/go test/golangci-lint run --allow-parallel-runners/govulncheck;cargo build/test/clippy/audit, pluscargo fmt --checkasformat;dotnet build <sln-or-proj> -c Release,dotnet format <sln-or-proj> --verify-no-changes, and, with a test project,dotnet test … -c Release --no-build(--solutionor--projectwhenglobal.jsonselects Microsoft.Testing.Platform) where a*.sln/*.slnxis at the root or exactly one*.csproj/*.fsprojis at the root or one directory down (absentdotnetis a note);uv run pytest/ruff(withruff format --checkasformatwhere ruff is declared) /pyreflyplusuv auditwhereuv.lockexists (pytest only if a manifest names it ortests/,test/,conftest.py, orpytest.iniexists);biome/tsc --noEmitwheretsconfig.jsonexists (tsc -b --noEmitwhen it names project references — without-ba solution-style file exits 0 having checked nothing);actionlint, then everyuses:against the repo's allowed-actions settings and verified-creator rule (theworkflowsgate; needsghauth, and warns and skips when offline; answers are cached per UTC day, also under--isolateand the pre-push hook, andGATE_ACTIONS_REFRESH=1discards this repository's; a repo that requires SHA pins fails any ref that is not a full commit SHA); a bun workspace'svulngate (audit-bun, elsebun audit); a Go module'sfuzzgate (eachFuzz*target in the module forGATE_FUZZTIME, default2s, four at a time, each with a-parallelthat keeps the workers at half the CPUs, or at--jobswhere that is lower; a local run skips the gate, listed as skipped like e2e, unlessgate --fuzzorGATE_FUZZ=1asks, and a pre-push hook and CI always run it; locally only the targets that fitGATE_FUZZ_BUDGET/fuzz-budget(default8s,0= all) run, least recently fuzzed first, judged by the projected finish of the busiest of the four lanes, and CI runs all; the record fingerprint takes the whole target list, not the rotating subset, so a fresh pass still stands in on an unchanged tree; none declared: no gate; a crasher fails the gate andgo testprints itstestdata/fuzz/<Target>/<hash>path; with no--timeoutortimeoutkey the gate's limit isceil(targets/4)x (fuzztime + 60s), at least 1m, counting the targets that run);markdownlint-cli2where a.markdownlint-cli2.*config exists and no package script already runs it (bare when the config setsglobs, else over**/*.md);shellcheckover the project's.shfiles;canon verify .whencanonis on PATH (absent: silent). Absent actionlint / shellcheck / clippy / cargo-audit is a note naming the install, never a lesser gate.
No Rust typecheck gate: cargo build already type-checks.
Roles: build, format, typecheck, lint, knip, workflows, markdown, shell,
canon, test, fuzz, vuln. Aggregates ci, check, verify, validate (that
precedence) are not roles. all is a build target, never an aggregate.
- Declined if any aggregated role was claimed (
build,typecheck,lint,test,vuln). - Run, appended, if none were.
A note says which. knip, workflows, markdown, shell, canon, fuzz are not aggregated.
[detect]
exclude = ["python-app-broken", ".github/test-fixtures/*-unformatted"]path.Match against the gate's directory name and its last segment. User +
project entries join. Directory-named gates, and the canon role; turn other
roles off by configuring them. --list notes each; its frozen install is
skipped. Empty or unreadable patterns are refused. exclude = ["canon"]
turns the canon gate off.
--list, --json, and the start of a run warn, never fail, when a workflow
run: step runs a known tool no gate runs: go test, vet, build, mod tidy and
verify; golangci-lint; govulncheck; pytest; ruff; pyrefly; mypy; bun test;
vitest; knip; biome; tsc; cargo test, clippy and audit; dotnet build and test;
vsce; osv-scanner; actionlint; shellcheck; uv audit. Unknown commands, project
scripts and expressions never raise one. A tool counts if it appears in any
gate's command, a make recipe that gate names, or a workspace package script
behind turbo; golangci-lint covers go vet; CI go test -race needs a gate
that also passes -race. Once per tool, first line. gate run <name> omits
them.
A Go module, Python project or Rust crate one or two levels down is its own
one-gate project. Discovery asks git (so .gitignore is honoured); skips
node_modules, vendor, testdata, .venv, hidden dirs. Nested Python
under Python, or crate under crate, is a workspace member. JavaScript still
needs CI to name it.
Sharing a directory with a package.json that declares build, lint or test:
package scripts win those roles; the other toolchain runs as one gate named
for it (go) when CI runs that toolchain. //go:embed makes that gate follow
the build, serially. A Makefile wrapper wins without a second gate.
A root gate that cds into a Go module does not hide the roles it never
runs there (lint, vuln become a directory-named gate).
typescript, @biomejs/biome, knip in package.json are detected before
node_modules exists. tsconfig.<name>.json beside a reference-free
tsconfig.json is typechecked too (tsconfig.build.json excepted). knip is
its own gate unless a script already runs it. Bun projects with .test. files
and no test script run bun test.
Detection stops at the nearest manifest. A workflow working-directory that
is a JS package with its own lockfile, or a Go module with its own go.mod,
becomes one gate named for that directory, run there: roles only (a
turbo-only package is turbo run <roles...>; else sh -c, stop on first
failure). Its frozen install runs beside the workspace's.
Not added: no own lockfile (workspace member); a package a root gate already
enters (cd / -C / --cwd in a make recipe or script, or a configured
run/dir). A note names the covering gate. shell and workflows stay on
the repository. A configured gate of that name overrides it and runs from the
root.
A push/PR step whose whole command is <runner> run <script> at the root,
naming a script no role covers, becomes a gate; so does each extra task a
declined aggregate runs. Multi-line run, raw commands, working-directory,
and manual/schedule workflows are not read.
Serial, CI order, build first. Exception: go build -o /dev/null ./... stays concurrent
(it writes nothing a later step can read). Step and job env reach the gate
under .gate.toml, plus CI=true. ${{ }} values, or a job that starts
services (services:, supabase start, docker compose up, docker run),
become a note. Same-name config overrides.
Each gate is broken into steps (<runner> run <script>, root turbo tasks
including //#name, through &&) and each step runs once:
- Merged — same steps, same directory: one gate, more specific name.
- Instrumented wins — coverage flags or
-racedrop the plain run. - Script file wins — a one-file script cannot be split; it keeps steps
its lines run (
detect.ScriptLines, read never run). Comments do not count; a command under a condition does. - Split — a shared step stays in the smaller gate; an empty aggregate
drops; leftovers run as
sh -cwith tools resolved intonode_modules/.bin. They need every gate that took a step before them in the chain, so a reader afterbuildwaits for the distbuildwrites.
Any shell control but && (|, ;, ||, redirect, cd, $) is one step.
Each action is a note:. gate run names are checked first.
Files from git ls-files --cached --others --exclude-standard -- '*.sh'. No
repo / no git: walk, skip node_modules, .venv, vendor, target, dist,
build, .next, .turbo. Relative, sorted. Detection internals:
AGENTS.md.
Display is shellcheck (N scripts); --list runs and --json argv hold
the full command. A declared shellcheck suppresses the convention gate;
gate run shell still reaches it. Absent binary: a note, never a lesser
check.
.shellcheckrc at the repo root is read. severity= is not a directive
(shellcheck 0.11 ignores it silently). disable= works.
node_modules/.bin and .venv/bin before PATH; resolved path is argv.
Lockfile picks the runner: bun.lock/bun.lockb → bun even beside
pnpm-lock.yaml, then yarn, npm, pnpm, else bun.
Two declarations for one role: higher precedence runs, and says so. A convention losing to a declaration is silent.
canon verify . wherever canon is on PATH, in every repository. Absent:
silent, never a note. A declared command that already runs canon verify
(Makefile, package script, or .gate.toml) suppresses the convention, so
Rethunk-Tech/canon does not run the check twice. [detect] exclude = ["canon"] turns it off. canon verify exits non-zero on ERROR only; WARN
lines print but pass.
gate run lint test runs those two. One unknown name fails the whole run
without running anything (gate -- nosuch for a program by that name).
Unmet needs of the named gates are pulled in too, transitively, in
dependency order, and printed (gate: also running tools).
The fast check after an edit: format (write mode where the formatter has one), then lint, then typecheck. Test, build, knip, vuln and e2e stay out. Same one-line verdict and log as a normal run. Format, lint and typecheck run in that order, format first.
Changed files vs HEAD (staged, unstaged, untracked) are passed to tools that
take paths: biome, ruff, gofmt, and golangci-lint (--new-from-rev=HEAD).
tsc and go vet stay whole-project. gate quick --all drops the scoping.
No changed files matching a scoped tool skips that gate. When git cannot list
the changes (not a repository, a safe.directory refusal), quick prints why on
stderr and runs the gates over the whole project. Changes inside initialised
submodules count too, named from the project root.
Detection is the project's usual set. .gate.toml may name a different list:
[quick]
gates = ["format", "lint", "typecheck"]A program named like one of gate's own words (doctor, run, fix, record,
quick, completion, man, the hidden actions-allowed and the hidden isolate-env) is run as
gate -- <word>, for example gate -- quick.
gate actions-allowed --json takes no linter: it prints a JSON array with one
object per uses: the repository's allowed-actions settings refuse or cannot
judge (ref, file, line, level fail or warn, reason), and exits 1
when any is fail. An unreadable setting prints [] and a note on stderr.
gate isolate-env prints one JSON object, variable to path: the toolchain
caches --isolate keeps visible under its fresh HOME, resolved from the
caller's environment. A sandbox that runs gate binds these paths writable
instead of keeping its own list.
Needed only for a check detection cannot infer, or an order it cannot see.
[gates.e2e]
run = "bun run e2e"
[gates.build]
serial = true
timeout = "5m"
[gates.test]
serial = true
[gates.docs]
run = "mdbook build"
dir = "docs"
allow-failure = true
[gates.docs.env]
MDBOOK_VERSION = "0.4"Gate keys: run, serial, needs, timeout, dir, env, allow-failure, e2e, isolate.
Outside: budget, fuzz-budget, jobs, fail-fast, trusted-orgs (--trust), [detect] exclude, [lock] scope (Concurrent runs), [limits] memory (Memory cap), [quick] gates (gate quick). run is a shell string (sh / cmd). It runs under sh -c without -e, so in a multi-line run only the last command's status counts: guard earlier lines with || exit 1, or start the string with set -e.
timeout is the same grammar as --timeout (5m, 90s, 1m30s, 0).
jobs is an integer >= 1 (no cap when absent, unless the 1-minute loadavg
exceeds nproc, then nproc/2). fail-fast is a bool
(default off). Unknown keys, bad durations,
and a bad jobs refuse the file.
dir is relative to the project root; missing directory refuses the run.
env merges per variable, literal, no $VAR expansion, after the inherited
environment. GATE_ACTIVE_ROOTS is reserved.
allow-failure: aggregate ignores that gate (first non-allowed failure wins;
all-allowed exits 0); text still prints FAIL (allowed); NDJSON keeps the
real status plus "allowed": true; log trailer unchanged; serial groups
continue; interrupted/skipped and log-write failures are not excusable.
Adds and overrides, never replaces. A config run filling a role left empty
for want of a tool clears that missing-tool note.
- Flags
<project root>/.gate.toml$XDG_CONFIG_HOME/gate/config.tomlor~/.config/gate/config.toml
Merge per key (env per variable) from the detected project root.
--list / --json name configured dir, stable-order env keys (not values),
allow-failure, serial, and timeout (off for 0) only where they
differ from the default. Unreadable files are refused; every unknown key
in one report.
Concurrent by default; nothing infers order. --serial for the run, or
serial = true on gates that need another's result (build before test;
Next build and typecheck both write .next). Cache contention is not a
reason. --serial beats the file; serial = false turns off a user default
(absent ≠ false). -j N, --jobs N, GATE_JOBS, or top-level jobs = N caps how many gates
run at once across groups that would otherwise overlap; serial groups and turbo
edges keep their order. Flag wins, then GATE_JOBS, then the file. N>=1; a
bad value is exit 129. With none of those, there is no cap unless the
1-minute loadavg exceeds nproc, in which case the cap is nproc/2.
needs = ["tools"] makes a gate wait until the named gates have passed. Use it
for an order that is about one gate's work feeding another, such as building
a tool binary once so the gates that run it do not each build it at the same
time (measured on a cold cache: 9.8s built first, 20.3s when four start together).
Everything else still runs concurrently.
[gates.tools]
run = "go tool -n golangci-lint >/dev/null && go tool -n govulncheck >/dev/null"
[gates.lint]
run = "go tool golangci-lint run ./..."
needs = ["tools"]- A needed gate that fails, times out or is skipped skips this gate too, named
needs <gate>, which did not pass; anallow-failuregate that fails counts as passed. - A name must be a configured or detected gate: an unknown name refuses the file (exit 129), as does a cycle among configured gates. A nearer file's list replaces the further one's.
- A named subset (
gate run lint) also runs every unmet need, transitively, in dependency order, and prints the extra names (gate: also running tools). An e2e gate a default run skips is still left out; a need this run does not carry is ignored. - Waiting that could never end, because a needed gate sits behind this one in a
serialchain or under--serial, refuses the run (exit 129). --listshowsneedsper gate;--jsonhas aneedsarray.
A failure stops its group only. --fail-fast or top-level fail-fast = true
(flag wins; default off) cancels every still-running gate in every group
on the first non-allowed failure (SIGINT to the group, SIGKILL after the
grace; those gates are cancelled and still get a log trailer). The
aggregate is that failure, not Interrupted. allow-failure does not trigger
it. Gates that never started are skipped, have no verdict, and do not change
the exit status.
Read-only; exits 0 either way. --json is "schema": 1 then findings:
check, warn, what, why, fix, where (relative), path (absolute),
plus warnings ([] if none). Text omits warnings. --ndjson refused.
| Check | Fires when |
|---|---|
no-ci |
Gates to run and no .github/workflows |
go-no-govulncheck |
Go module, no vulnerability gate |
python-no-audit |
pyproject.toml, no gate named vuln |
rust-no-clippy |
Cargo.toml, no cargo clippy gate |
bun-no-audit |
bun lockfile, no vuln gate and no audit-bun argv |
go-test-no-race |
Go module, no go test -race |
ci-govulncheck-off |
setup-go used, no run-govulncheck |
ci-python-audit-off |
setup-python used, no run-audit on that step |
ci-clippy-off |
setup-rust used, no run-clippy |
ci-bun-audit-off |
setup-bun used, no run-audit on that step |
ci-no-final-gate |
Matrix checks, no aggregating job |
corepack-with-setup-bun |
corepack enable beside setup-bun |
npx-in-bun-workspace |
npx with a bun.lock |
dependabot-npm-in-bun |
Dependabot npm entry over a directory whose only lockfile is bun's |
actions-floating-ref |
Shared action pinned to main |
actions-stale-ref |
Shared action behind the known tag |
superseded-tooling |
eslint, mypy or black |
missing-gate-* |
No test or typecheck gate |
next-build-typecheck-race |
Next build and typecheck concurrent |
result-not-fresh |
A stored result exists and is not fresh. Missing stays quiet |
Judgements are repository-wide (a release workflow omitting run-govulncheck
while CI enables it is not a gap). gate --fix as a flag is refused.
Doctor stays read-only. fix applies findings that can prove a post-state
from path + fix. --dry-run writes nothing. --json is "schema": 1
then findings, each with outcome (applied, skipped, dry-run) and
reason when skipped. --ndjson refused. Exit 0 if nothing to apply or every
finding was applied/skipped; a failed write is a failure.
| Check | Apply |
|---|---|
next-build-typecheck-race |
serial = true on gates.build and gates.typecheck |
ci-govulncheck-off |
run-govulncheck: "true" on the named setup-go step |
ci-python-audit-off |
run-audit: "true" on the named setup-python step |
ci-clippy-off |
run-clippy: "true" on the named setup-rust step |
ci-bun-audit-off |
run-audit: "true" on the named setup-bun step |
corepack-with-setup-bun |
drop the corepack enable step |
npx-in-bun-workspace |
npx → bunx in the named workflow or package.json |
dependabot-npm-in-bun |
package-ecosystem: bun on each flagged entry in .github/dependabot.yml |
actions-floating-ref / actions-stale-ref |
pin named shared-action refs to doctor's tag |
go-no-govulncheck |
skip — go install is machine-wide |
python-no-audit / rust-no-clippy / bun-no-audit |
skip — the remedy is not a one-line repo edit |
go-test-no-race |
skip — Fix names a test target or a workflow step |
no-ci |
skip — a workflow needs a template choice |
missing-gate-* |
skip — adding a script is ambiguous |
ci-no-final-gate |
skip — an aggregating job is a design |
superseded-tooling |
skip — Fix and Path do not uniquely name a file move |
result-not-fresh |
skip — running gate is not a repo edit |
A program named fix is gate -- fix.
Default one minute per gate. Overrun is killed, not failed — exit 124. Trailer records the timeout. Process group: SIGINT, then SIGKILL after 5 s. Windows: killed outright. Why SIGINT: AGENTS.md.
gate: TIMEOUT after 1m0s make test (killed, not failed)
gate: raise it for that gate alone: .gate.toml [gates.test] timeout = "2m"With no timeout key and no --timeout, the limit is the gate's p95 passing duration (last 20 uncached runs, kept beside the result record) times 2, never under 60s, multiplied by 1-minute loadavg/nproc (max 4) when above 1. An ok line shows it when it is not 60s.
Gates run with GORACE=atexit_sleep_ms=0 unless GORACE is already set, so a race-built test binary skips its default 1 s sleep at exit.
--timeout is every gate; .gate.toml timeout is one. Absent inherits;
timeout = "0" removes the limit. --timeout 0 disables for the run.
The whole run sits under one memory ceiling so callers do not wrap gate in
systemd-run --user --scope -p MemoryMax=24G. Default 24G, swap 0.
.gate.toml [limits] memory = "16G" is the repo; --mem SIZE is the run
(flag wins); a wrapped gate -- CMD takes the [limits] memory of the project root above the directory too. --mem 0 and memory = "0" disable it.
On Linux with a user systemd, gate re-execs itself once, before the lock and any install, as
systemd-run --user --scope -q --collect -p MemoryMax=<SIZE> -p MemorySwapMax=0 -p OOMPolicy=continue -p CPUWeight=20 --unit=gate-<pid>-<rand> [-p CPUQuota=<N>%] [-p TasksMax=<N>] --
followed by its own argv (CPUQuota and TasksMax restate the tightest enclosing
cpu.max and pids.max, the quota rounded down to two decimals, and appear only
under such a limit), so every parallel gate shares one cgroup. Display,
logs and exit codes are the command's. <SIZE> is bytes or a number with an
uppercase K, M, G, T, P or E (24G); systemd takes no g or
GiB, so gate refuses them. Where systemd-run --user is missing (CI, macOS,
containers) the run is not capped and prints one gate: memory cap <SIZE> unused: systemd-run --user is unavailable line; that is not a failure. A gate
started directly in a systemd service's cgroup is not re-exec'd, so
systemctl stop still reaches it, and says so. Under an existing memory cap on
the process's cgroup or an ancestor, gate adds no scope for the default, and prints a note when an explicit --mem
(on a wrapped command too) or [limits] memory differs from the cap in force
(the default stays silent). An explicit size below the enclosing cap gets its
own scope, carrying the enclosing CPU quota and task limit; an explicit size at
or above it is not applied. Where no cgroup memory controller is
visible (no cgroup v2, or a container that hides it) it prints gate: memory cap <SIZE> unused: no cgroup memory controller visible.
The scope also carries CPUWeight=20 (default 100): under contention the run
yields to the desktop, and idle CPU is still used at full speed. Only scoped
runs get it: with no user systemd, or under an existing cap that gate does not
scope below, the run keeps its normal CPU priority.
A command the cap kills (exit 137 and the cgroup's oom_kill count rose during
the run) is reported killed: memory cap <SIZE>, not FAIL exit 137.
One run at a time per workspace, the git worktree root (separate worktrees of
one repo are separate workspaces; outside git, the directory). A bare run,
gate run <role> and a wrapped command all take an exclusive lock under the
user cache dir (gate/locks/, keyed by a hash of the path). A second run
prints one line to stderr and waits:
gate: waiting for the gate already running here (pid 4242, started 14:03:07)
It then takes the normal path: if the tree and gate set are unchanged it
returns the first run's result (gate: ok (unchanged since ...)), otherwise it
runs. --force still waits, then runs without the skip. Ctrl-C while waiting
exits 130. --list, --json, doctor, fix, record and --version take no
lock. The pid in the message is informational; the kernel releases the lock when
its holder dies, so a stale file never blocks. A run started by another gate
(GATE_ACTIVE_ROOTS set) takes no lock, since its parent holds one. Off unix
the lock is a no-op.
[lock] scope = "repo" in .gate.toml keys the lock on the repository's
common git dir instead, serialising every worktree of it; use it when the tests
share one resource such as a local database. Default is "worktree".
Ctrl-C stops each command's process group (SIGINT then SIGKILL). A second
signal ends gate. Interrupted, not failed; exit 128+the signal that reached
gate (130 for Ctrl-C).
$TMPDIR/gate/, or /var/tmp/gate/ if unset; Windows TMP/TEMP. Not
/tmp (tmpfs).
Filename is command plus a random suffix. 0600 in a 0700 directory.
--log PATH is one file; several gates refuse it. That parent is the
caller's (0755 if created, never 0700, never swept).
When any step failed, the report ends with one line per failure,
gate: failed: <name> (gate run <role>) -> <full log path>, after the summary, so
tail -3 names what failed and where.
--version prints a flags and defaults: line (built-in values and any flags given, not .gate.toml) naming timeout, budget, memory cap, log directory, retention.
One directory per run, /var/tmp/gr-<pid>-<random> (GATE_TMPDIR
moves the parent), and every gate runs with TMPDIR and GOTMPDIR pointing
at it. Whatever a step leaves there — a go-build work tree, a test's fixture
directory — goes with it when the run ends, however it ends: pass, fail,
Ctrl-C, or a step's own timeout. GOCACHE is untouched, so the Go build cache
stays shared and warm.
A run killed outright (SIGKILL) cannot remove its own directory, so each run
sweeps first, and prints one line:
gate: removed 2 dead run dir(s), 1 go-build dir(s), 3 log(s) older than 7 days
gr-* goes once its pid is gone and it is over an hour old; a
go-build* left loose in that parent goes after a day; logs in gate's own
directory go after 7 days. --quiet silences the line, not the sweep.
--log paths are never swept.
After bare gate or gate run <names>:
$XDG_STATE_HOME/gate/results/<sha256 of the root>.json
~/.local/state if XDG_STATE_HOME is unset or not absolute. Name is
lowercase hex SHA-256 of the resolved project-root path. Write temp + rename.
No record for a named command, a non-git tree, or a repo with no commit.
{
"schema": 3,
"root": "/usr/local/src/example",
"head": "35f23ab5255d6ac9e2804b7bc8ecea389a70aea6",
"dirty": false,
"status": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"partial": false,
"started": "2026-09-23T10:00:00.123456789-07:00",
"finished": "2026-09-23T10:00:04.5-07:00",
"exit": 0,
"gates": [
{ "name": "test", "argv": ["make", "test"], "display": "make test",
"status": "ok", "code": 0, "ms": 4200, "log": "/var/tmp/gate/make-test-123.log" }
]
}| Field | Meaning |
|---|---|
schema |
Bumped on any change a reader has to know about |
head |
git rev-parse HEAD at the start of the run |
dirty |
a raw git diff-index --cached HEAD, git diff-files, or git ls-files --others was non-empty (untracked counts) |
status |
SHA-256 of raw diff-index --cached HEAD, raw diff-files, raw ls-files --others, then git hash-object --no-filters (never -w) of every changed and untracked regular file (FIFOs, sockets, and devices are skipped), of each skip-worktree or assume-unchanged path whose worktree bytes differ from the index, then the head and status of each changed submodule (never ignored), over the whole worktree even for a project below the top |
partial |
A role left out for want of a tool (govulncheck not installed; the run prints gate: partial pass, vuln skipped for a missing tool, exit stays 0). A role skipped inside a nested project detect.exclude leaves out is not one: its gate never runs, so the run stays a full pass and only the note remains. gate run <names> or a named command other than the project's whole CI (<npm|pnpm|bun> run, yarn or make plus ci, check, verify or validate, defined by its package.json or Makefile): those write a full record |
exit |
gate's exit for the run |
gates |
Declaration order; each object is an --ndjson line |
Every read is plumbing, and the attributes source is the empty tree, so no
filter.<driver>.clean or diff.<driver>.textconv a repository names can run.
Clean tree: SHA-256 of no bytes.
Trust only when current HEAD equals head and a fresh hash equals status.
Two dirty trees at one HEAD do not share a pass.
gate record exits 0 iff schema 3, head matches, status matches, partial
is false, and exit is 0. Missing → 1 "missing". Tree/schema mismatch → 1
"stale". Match with non-zero exit → that status "failed". Match with
partial true → 1 "partial". --json adds fresh, reason
(missing/stale/partial/failed/null), and current
{head, status, dirty} (not stored; schema stays 3). Order: stale even if
the run failed; failed even if partial; else partial. Missing --json is
schema 3, fresh, and reason. A leftover schema-2 file is stale. Text:
$ gate record
schema 3
root /usr/local/src/example
head 35f23ab5255d6ac9e2804b7bc8ecea389a70aea6
dirty false
status e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
partial false
exit 0
started 2026-09-23T10:00:00.123456789-07:00
finished 2026-09-23T10:00:04.5-07:00
test okMissing/stale/partial/failed on stderr. --failed reads this file.
The wrapped command's status passes through including values that collide
with the codes below. These apply only when gate could not run it.
| Code | Meaning |
|---|---|
| 0 | The command succeeded |
| 124 | Timed out and was killed |
| 127 | Could not be executed |
| 128 | gate could not proceed (log, unresolved command line) |
| 129 | Wrong invocation; an untrusted origin without --trust; also --failed when the record is missing, stale, or has no fail/timeout/error/skipped-by-a-need gates |
| 130 | Interrupted; generally 128+the signal that reached gate |
Any other value is the command's own status.