Gates & enforcement ladder
Quality gates, agent-runtime and git hooks, grep gates and the rules for writing gates, CI authority, suppression registryMost teams have more rules than enforcement: “we always run the tests,” “we never commit secrets,” “new files need tests.” Whatever isn’t mechanically checked erodes — especially with AI agents generating high volumes of plausible-looking change. This module is the machinery that turns stated rules into checks, ordered along an explicit ladder from convention to hard gate, without collapsing into bureaucracy.
A canonical, ordered set of quality gates is stated in one place and enforced at (at least) two rungs: locally via git hooks for fast feedback, and in CI as the authority. Every additional rule names its rung; every gate has a tested implementation and a documented, justified escape hatch.
A gate has three outcomes: passed, found violations, or could not check (exit 0, 1 and 2). It never turns input it could not find or read into an empty, passing result, and a skipped or stale result is never evidence that a change passed. Each finding says which rule, where, what is wrong and how to fix it, and each exception carries a checked reason and fails the gate once it no longer suppresses anything.
Without the third outcome, a gate that could not read its input reports nothing found, which looks exactly like a clean change: a renamed folder, a section someone deleted or a command that failed quietly turns the check off while it keeps saying green. Without actionable findings, the person or agent who meets a red gate has to reverse-engineer the rule before fixing anything. Without self-pruning exceptions, an allowlist only grows, and each entry left behind is a place the rule silently no longer applies.
M1 Lite — minimum useful
gate set documented + runnable with one command; hooks optional; CI runs the gates on every PR.
- An ordered gate set (format, lint, types, tests, build) is stated in one canonical place and runnable with a single command.
gate-set-documentedWhat the audit looks for (2)- instruction file (or equivalent canonical doc) lists the ordered gates
- one script/task runs the whole set
- CI runs the gate set on every pull request and a failing run blocks the merge.
ci-runs-gates-on-prWhat the audit looks for (2)- CI workflow triggered on pull requests runs the gate set
- the workflow's jobs are required checks (branch protection or pipelines-must-succeed setting)
M1 Standard — production teams
full hook layer with auto-fix-and-stage; ≥ the team’s top-5 codebase rules as tested grep gates in hooks + CI; escape hatches documented; third-party CI automation is immutable and automatically updated; a release cooldown holds in the updater and in every installer, with exact-name exemptions; only listed packages run install scripts, and the updater never auto-merges them; a blocking CI secret scan covers each change’s commits; repository-written gates report could not check (exit 2) apart from findings; every exception entry carries a non-empty reason the gate checks, and a stale entry fails its gate.
- A managed pre-commit hook runs auto-fixing checks and re-stages what they fixed.
precommit-autofix-hooksWhat the audit looks for (2)- hook-manager config present (lefthook.yml, .husky/, or .pre-commit-config.yaml)
- pre-commit entry runs a fixer and stages its output (e.g. stage_fixed or an explicit git add)
- The team's top codebase-wide rules (target: five or more) exist as grep-gate scripts, each with a paired self-test, wired into both the pre-push hook and CI.
grep-gates-tested-and-wiredWhat the audit looks for (3)- check-<rule> scripts present
- each has a paired self-test (e.g. check-<rule>.test.ts) with fixtures
- both hook config and CI workflow invoke them
- The hook bypass (--no-verify) is documented next to the hooks, with when it is legitimate and the note that CI re-runs everything.
escape-hatch-documentedWhat the audit looks for (2)- hook config or gate docs mention --no-verify and its conditions
- every hook-enforced check also appears in CI
- Third-party CI automation is pinned to immutable revisions and an automated updater proposes pin changes through the normal gate set.
third-party-automation-pinned-and-updatedWhat the audit looks for (3)- external CI actions, remote includes, and containerized CI tools use immutable commit or digest references
- dependency-updater configuration covers those references
- proposed updates run the same required gates as other changes
- A minimum release age holds for application dependencies in the updater's configuration and in every package manager the repository installs with, and its exemptions are a list of exact package names.
dependency-release-cooldownWhat the audit looks for (3)- the updater's configuration sets a minimum release age for the application's dependencies (Renovate minimumReleaseAge, Dependabot cooldown)
- each installer's configuration sets the same age in its own unit (bunfig.toml, .npmrc, pnpm-workspace.yaml, .yarnrc.yml)
- the exemptions name exact packages, never a pattern
- Only the packages a list names may run lifecycle scripts at install time, every installer the repository uses blocks the rest, and the updater never auto-merges a listed package.
install-scripts-allowlistedWhat the audit looks for (2)- each installer's allowlist is present (package.json trustedDependencies, pnpm-workspace.yaml onlyBuiltDependencies, or ignore-scripts with the allowed packages rebuilt on purpose)
- the updater's configuration sets automerge off for the listed packages, or no auto-merge reaches them
- A required CI job scans exactly the commits a change introduces for secrets with a pinned scanner, and fails on a finding or on an empty commit range.
secret-scan-blocks-in-ciWhat the audit looks for (3)- a workflow runs a secret scanner over the merge-base-to-head range on pull requests, from a full-history checkout
- the job fails when the range resolves to zero commits
- the job is in the required set
- Every repository-written gate has three outcomes, passed, found violations and could not check (exit 0, 1 and 2), and reports a missing or unreadable input, an input empty where its format requires content, or a failed command as could not check, never as a pass.
gate-outcomes-distinguish-could-not-checkWhat the audit looks for (3)- check scripts exit with a distinct status (conventionally 2) and a could-not-check message when their input is missing or unreadable, empty where its format requires content, or a command they run fails
- self-tests assert that status for at least one such input per gate
- no gate prints a pass for a scan root that does not exist
- Every allowlist entry and suppression token a repository-written gate honors carries a non-empty reason the gate checks, and an entry that no longer suppresses anything fails the gate.
stale-exceptions-failWhat the audit looks for (3)- gates reject a suppression or allowlist entry without a reason
- gates report an entry that matched no finding in the run as stale and fail on it
- self-tests cover a stale entry
M1 Strict — regulated / compliance posture
suppression-token registry; commit-msg process markers for mandatory reviews; gate self-tests required, each including a case with nothing to examine (the input missing, or empty where its format requires content) that must not pass; advisory gates carry promotion conditions with dates; one supply-chain policy held to by a lockstep gate that runs before any install can run a script; the updater’s self-check; every agent-runtime hook self-tested, its tests discovered and run in CI; a pre-commit secret hook and the forge’s push protection beside the CI scan; a retry is taken only on an error classified as transient, by a classifier tested against messages recorded from the real tool; cross-worktree resource mutex where parallel agents share a machine (see M12).
- One policy file states the release cooldown, its exemptions and the install-script allowlist, and a gate in the required set checks that every installer and the updater state the same values, running before any install that could run a script.
supply-chain-policy-lockstepWhat the audit looks for (3)- a policy file names the three values once
- a gate compares each installer's and the updater's file with it and runs in the required CI set
- the gate's CI step precedes the dependency install, or the install runs with scripts disabled
- Range-valued version overrides are excluded from the updater's normal path, and every custom extraction pattern of the updater has a check that re-applies it to the tree and requires exactly one value.
updater-self-checkedWhat the audit looks for (3)- an updater rule leaves overrides that are not exact versions alone
- a check runs each custom manager's own patterns against the tree and fails on zero or several matches, in CI
- expected-absent where the repository has neither overrides nor custom extraction patterns
- Beside the CI scan, a pre-commit hook scans the staged changes for secrets on the committer's machine, and the forge's push protection is on.
secret-scan-local-and-forge-layersWhat the audit looks for (2)- the hook manager's pre-commit configuration runs a secret scanner over the staged changes
- push protection is enabled for the repository or its organization (a host setting the audit reads, or the team states)
- A single registry page lists every suppression token a live gate honors, with syntax, consuming gate, placement, and justification requirement, plus a registration rule for new tokens.
suppression-token-registryWhat the audit looks for (2)- registry doc present in the docs tree
- tokens parsed by check scripts appear in it
- Mandatory-review areas are enforced by a commit-msg hook requiring a review-marker tag when protected paths are staged, re-checked by a gate the committer cannot skip.
commit-msg-process-markersWhat the audit looks for (2)- commit-msg hook checks staged paths against a marker in the message
- CI (or another unskippable rung) re-verifies the marker
- CI runs each grep gate's self-test alongside the gate, so a silently broken gate fails the pipeline.
gate-self-tests-in-ciWhat the audit looks for (1)- CI workflow runs each gate's self-test, not only the gates
- Each repository-written gate's self-test includes a case where the gate has nothing to examine (its input or section missing, or empty where the input's format requires content, such as a scan root with no file) and asserts that the gate does not pass on it.
gate-self-tests-cover-empty-inputWhat the audit looks for (3)- every gate's test suite has a case where the input is missing, or empty where its format requires content, expecting the could-not-check status
- an input whose format allows zero entries may pass when empty, and the gate's output then says it examined zero
- those self-tests run in CI
- Every hook the repository registers in an agent runtime (around tool calls, on prompt and session events) has a self-test beside it that feeds it the runtime's payload and asserts each outcome, and one runner discovers every hook's test and runs it in CI.
agent-runtime-hooks-self-testedWhat the audit looks for (2)- each command a runtime's hook registration names (a settings file's hooks, a hooks.json, a plugin's hooks/) has a test beside it or in the hooks' test directory
- a runner discovers the tests by name rather than listing them, and a CI job in the required set runs it
- A rule that still has findings is ratcheted rather than left advisory: a required gate fails a change that adds a finding to it or loosens its configuration, measured against the merge base, and a rule whose count reaches zero is promoted to blocking.
existing-findings-ratchetedWhat the audit looks for (3)- a gate counts findings per rule in the change and in the merge base and fails when a count grows
- loosening a rule's configuration fails the gate unless explicitly acknowledged (a commit trailer or equivalent)
- the gate runs in the required CI set
- Every advisory (non-blocking) gate states its promotion condition and a review date; none is advisory indefinitely without one.
advisory-gates-carry-promotion-conditionsWhat the audit looks for (1)- continue-on-error / allow_failure gates carry a promotion condition and date in config comments or the gate catalog
- Every retry in the pipeline's steps and in the gates and scripts it runs retries only an error a classifier marks transient, aborts at once on any other with the command's own message and status, and the classifier is tested against messages recorded from the real tool.
retries-classify-errorsWhat the audit looks for (4)- each retry loop (a CI step, a gate, a script the pipeline runs) classifies the failure before retrying: a pattern list with reasons, a closed set of error codes, or the provider's own failure classes
- an error outside the transient set ends the step with the original message and exit status, not after the retry budget
- a test feeds the classifier messages recorded from the real tool (a fixture file, a copied log line) and asserts its answer
- expected-absent when nothing in the pipeline or its scripts retries
Adoption steps
- Write the ordered gate set once in the universal instruction file
(M0), make one command run all of it,
and run that command in CI on every pull request as a required check
(skeleton:
templates/ci-pr-gates.yml). This is Lite. - Add the hook layer from
templates/lefthook.yml(husky and pre-commit equivalents inmappings.md); turn your top codebase rules into grep gates with self-tests, followingreference/grep-gate/, and run them in both the pre-push hook and CI; write them, and bring the gates you already have, to the gate-authoring rules (core piece 3): three outcomes, a counted population, findings with a fix; require a reason on every exception and fail on stale ones; document the--no-verifyescape hatch next to the hooks; pin third-party CI automation to immutable revisions and configure an updater for the pins; state the supply-chain policy fromtemplates/supply-chain-policy.yamland make the updater and every installer state its cooldown, exemptions and install-script allowlist (mappings.mdsays which setting is which); add the blocking CI secret scan fromtemplates/secret-scan.yml. This is Standard. - Copy
templates/suppression-registry.mdand register every suppression token; add commit-msg markers for mandatory reviews withreference/commit-msg-marker/; run every gate’s self-test in CI, each with a case where the input is missing, or empty where its format requires content, that must not pass; give each advisory gate a promotion condition and a date; hold the installers and the updater to the policy withreference/supply-chain-lockstep/, run before the install step; self-check the updater’s custom patterns and keep range-valued overrides out of its normal path; give each agent-runtime hook a self-test and run them in CI throughtemplates/hook-self-tests.sh; add the pre-commit secret hook and turn on the forge’s push protection. This is Strict.
Core piecesOpen
- The gate set — the ordered commands (format → lint → types → tests → build) stated once (in the M0 instruction file) and identical everywhere they run. Cheapest first: the checks that take seconds run before the minutes of tests and build, so a failure is reported at the start of a run, not after the suite. The run goes to the end: a gate that depends on nothing but the tree runs whatever an earlier gate reported, the run closes with the list of what failed and exits non-zero if anything did, so two unrelated failures surface in one run rather than two. Only a gate that needs another’s output is left out once that one fails.
- Hook layer — pre-commit: auto-fixing checks that fix-and-stage
(formatting, regeneration); pre-push: cheap pattern gates + the heavy
build/test; commit-msg: process markers (e.g., “this migration was
reviewed” tokens that a later gate verifies). A
change-area catalog’s
validation:projection can scope the pre-push gate depth to what the change actually touched instead of always running the heaviest set. - Gate-authoring rules — one small script per codebase-wide rule
(“no direct fetch calls in frontend”, or
M15’s “a
merged migration never changes”), each with a
paired self-test and fixtures, wired into both pre-push and CI. Every
gate, a grep gate or any other, is written to these
rules:
- Fail closed. An input or section the gate cannot find, a row that cannot be decoded, a repeated key where keys must be unique, or a command the gate runs that failed is reported as could not check (exit 2), never skipped. So is an input found empty where its format requires content: a scan root with no file in it, a glossary that defines no term. A message for this outcome cannot be mistaken for a finding: the fix is to the input or the environment, not to the code under check.
- Empty is valid only where the format says so. An input that is present and legitimately allows zero entries (a registry with no metrics yet, a log with no events, a review with no threads) passes when empty, and the gate’s scope line says it examined zero entries. What fails closed is the gate not finding or not reading what it is meant to examine, never an empty list the format permits.
- Count what was read. The gate checks the size of the population it parsed (files scanned, rows read, entries found), so that reading nothing can never look like finding nothing.
- Match text only for questions about text. A text pattern is fine for “does this text appear”. Whether code executes or a value binds is a question about structure: answer it with a real parser (a YAML loader, a syntax tree, a structural lint rule such as a GritQL rule run by a pinned linter), or pin the exact expected text. A hand-written pattern that guesses at structure stays one counterexample behind for ever. A parser that meets input outside the subset it models refuses loudly, as could not check, rather than reporting nothing found. Each linter’s mechanism is in mappings.md.
- The self-test reads more than the gate. Where a self-test checks the gate’s coverage, its recognizer (the code that decides which lines or entries count as the thing being checked) is strictly broader than the gate’s, so a construct the gate cannot read still fails the test. A test that shares the gate’s recognizer agrees with it about what neither read.
- Every fixture is mutation-tested. A guard counts as tested only once removing it, in a scratch copy, turns its fixture red. In a chain of fail-closed checks, each clause gets a fixture that passes every other clause, so that clause alone decides the outcome.
- The output states its scope, on green runs too: what was examined and what the gate does not check (“142 files scanned; checks TODO comments only”). A green run is evidence about what the gate reached, and a reader of the summary should not have to open the source to learn how far that is.
- Findings are actionable. Each finding names the rule, the place (file and line), the problem and the remedy, or the document that states it. In CI the findings are also written as the platform’s annotations, so they appear on the changed lines (mappings.md).
- Classify before retrying. A step that retries a command retries
only an error it has classified as transient, and aborts at once on
any other with the command’s own message and status. The transient
patterns live in a list with the reason beside each, and the
error classifier is tested against messages
recorded from the real tool: wording written from memory never
matches, so an untested retry either never fires or retries
everything, and a permission error retried to the end of its budget
is reported as a timeout. The reference wrapper is
reference/retry-classified/(mappings.md places it per provider).
- CI as authority — every hook-enforced check re-runs in CI; local
bypasses (
--no-verify) exist for emergencies but change nothing about what merges. A check that was skipped, or that ran on an earlier commit, says nothing about the commit being merged: the required verdict counts it as not passed. - Suppression-token registry, and exceptions that prune themselves —
the documented set of inline markers and allowlists that legitimately
silence a specific gate at a specific spot. Ad-hoc suppressions are drift.
Every exception, an inline token or an allowlist entry alike, carries a
non-empty reason the gate checks, and an entry that no longer suppresses
anything (the code it excused is gone, or the rule no longer flags it) is
itself a finding. Exceptions therefore leave with what they excused,
instead of piling up as places the rule quietly stopped applying.
M14’s testing gates bring exceptions
that belong here, and both prune themselves: the
fixed-delay:token on a deliberate sleep, which its fixed-delay gate fails when no delay sits beside it, and the exemptions file of its tests-with-changes gate, which turns “changed files need tests” into a check and fails an exemption that matches no file. - Advisory→blocking pipeline and the gate lifecycle — new gates may
start advisory, but each advisory gate carries a promotion condition;
advisory-forever is a tracked smell. Between the two sits the
ratchet: a rule with existing findings blocks only
changes that add to them, measured against the merge base, and is promoted
to blocking when its count reaches zero. The rest of a gate’s life follows
the same care:
- Rules come from recurring findings. A review finding that keeps coming back, and whose shape is syntactic, becomes a lint rule with fixtures (the forms it catches, look-alikes it must leave alone, the misses it accepts), held by the ratchet. Existing violations are rewritten in bulk by a separate rewriting tool, applied on purpose in its own change and never run as a gate.
- A replacement earns its place. A tool meant to replace a gate (a faster linter, a new formatter) first runs in a non-blocking shadow job on every change, publishing parity counts: what each tool reports on the same tree, and where they differ. It takes over only once the differences are understood and closed; a release of the new tool alone is not a reason.
- Retiring a gate is recorded. Next to the list of gates, a retired one keeps a line saying what replaced it and which coverage was lost, so nobody assumes a check still runs that does not.
- Unused code (dead code) and duplication are measured on every change, with the entry points (the files nothing imports because a hook, a workflow, a test runner or a person runs them by path) declared one by one from how each is actually invoked. A folder-wide entry pattern marks every helper under it as used for ever, so the measurement can no longer find it once its last caller goes.
- Third-party automation and dependency integrity — what runs on the
team’s machines and in its pipeline from outside the repository (CI
actions, included automation, application dependencies) arrives only
through a reviewed commit, and late enough to have been seen:
- Immutable pins with an update path. External CI actions and included automation are pinned to immutable revisions, while an automated dependency updater proposes tested pin changes. An immutable pin without an update path becomes stale; an update bot without immutable pins leaves merge-time behavior changeable outside the reviewed commit. On GitHub Actions, M13’s workflow-convention lint checks the pins of workflows and composite actions.
- A release cooldown. A dependency release is
proposed by the updater, and resolved by every package manager at install
time, only once it is older than a minimum age (a few days), so a release
that is yanked or found compromised is usually gone before anyone here
sees it. The installer’s half matters: an updater alone leaves
addandupdateon a developer’s machine, and a lockfile refresh, free to take the newest release. The exemption list (a package version-locked to a runtime pin, which must move the day the pin moves) is short and names exact packages, never a pattern, since a pattern trusts whatever is published under it later. A fix for a known vulnerability takes the updater’s security path, which skips the wait. - An install-script allowlist. Only the packages a repository lists may run lifecycle scripts (preinstall, install, postinstall, prepare) at install time; the installer blocks every other package’s scripts. A package on the list is never auto-merged by the updater: its new release runs code on every machine that installs it, so a person reads the diff.
- Policy lockstep. The cooldown, its exemptions and the allowlist are stated once, in one policy file, and every installer and the updater state the same values in their own configuration and their own units (days, minutes, seconds); a gate checks they agree. That gate runs before any install that could run a script (before the install step, or with scripts disabled), because a change that adds a package to the allowlist would otherwise run that package’s script before the gate that judges it.
- The updater checks itself. Range-valued version overrides (a security floor, a major cap) are excluded from the updater’s normal path: it reads the cap as a dependency and proposes lifting it, which changes the range without fixing anything. Where the updater extracts a version with a custom pattern (a pin in source code, a workflow variable), a self-check re-applies each pattern to the tree and requires exactly one value, since zero matches is a successful run with nothing to update, not an error.
- Layered secret scanning. A secret is caught in layers: a
pre-commit hook on the committer’s machine; a blocking CI scan over
exactly the commits the change introduced, never the whole history, which
fails on an empty range because a scanner handed no commits passes; and
the forge’s push protection, which catches a push that reaches neither.
Each layer catches what the one before let through (
--no-verify, a machine without the hook, a push outside a pull request).
- Agent-runtime hooks — the rung between convention and the git hooks.
An agent-runtime hook is a command the agent’s
runtime runs at its own events: before or after a tool call, when a
prompt is submitted, when a session starts, resumes or compacts. It sees
what no git hook can (the command an agent is about to run, before it
runs; the prompt; the session’s own transcript), so a rule that git can
only catch once the damage is committed belongs here: a command that is a
hard error under the shell the tool runs, or a session about to be
aborted at the runtime’s turn cap with no handoff written. It is the
softer rung: the runtime loads a hook only where it is registered and
trusted, and a session without it has nothing, so a hook enforces nothing
CI does not re-check. Every hook holds to these rules:
- Local files only. It reads the payload the runtime hands it, the transcript and the repository, never the network: it runs before every tool call, so a network call would add its latency and its failures to each one.
- Bounded cost. It reads only what it must, such as the transcript since its last call (an offset kept in per-session state), never a whole file that grows to tens of megabytes in a long session; a line the runtime is still writing stays for the next call.
- Three outcomes, and it fails open loudly. Checked and clear is silence, or context handed to the agent. A denial is reserved for a command that would fail deterministically anyway, so that the denial replaces a failed round-trip with a correction and never blocks a valid command. Could not check (a transcript it cannot read, state it cannot write, a format it does not recognise) lets the action through and says so where the runtime shows hook errors: a guard that blocks because it could not check is worse than what it prevents, and one that is silent when broken reads as checked and clear.
- Registered identically in every runtime that supports hooks. One hook file and one registration shape, so a session in a second runtime carries the same guard; where a runtime does not supply what the hook reads, the hook reports could not check rather than counting nothing in silence.
- Self-tested, discovered in CI. Each hook has a self-test beside it
that feeds it the runtime’s payload shape and asserts each outcome, and
one runner (
templates/hook-self-tests.sh) discovers every hook’s test and runs it in CI, so a new hook enters the gate without a second list to maintain.
In your toolsThe same rule, wired into a specific CI provider, hook manager or tracker. Shows only your stack.Open
The module’s pieces are tool-independent; this page maps each onto the common hook managers and CI providers. Terms of art: see the glossary (git hook, CI, grep gate).
Hook managers
All three managers can run the same Bun commands; they differ in where the
wiring lives and what conveniences exist. The reference scripts in this
module (reference/grep-gate/, reference/commit-msg-marker/) run with Bun and Git under any of them.
| M1 piece | lefthook (lefthook.yml) | husky (.husky/* shell files) | pre-commit framework (.pre-commit-config.yaml) |
|---|---|---|---|
| Pre-commit fix-and-stage | pre-commit: command with stage_fixed: true; glob: scopes it | .husky/pre-commit script; re-stage manually with git add after the fixer | Hook entry with stages: [pre-commit]; auto-fix hooks fail the run and leave fixes unstaged by design — re-run to commit |
| File-pattern scoping | glob: per command | Manual (git diff --cached --name-only | grep …) | files:/types: regex per hook |
| Pre-push grep gates | pre-push: commands, one per rule, parallel: false for fail-fast ordering | .husky/pre-push calling each bun scripts/check-*.ts in order | Hook entries with stages: [pre-push], entry: bun scripts/check-<rule>.ts, pass_filenames: false |
| Heavy build/test phase | Last pre-push: command | Last line of .husky/pre-push | stages: [pre-push] entry with always_run: true |
| Commit-msg marker | commit-msg: command; message file path is {1} | .husky/commit-msg; path is $1 | Hook with stages: [commit-msg]; the framework passes the message file as the filename argument |
| Per-command timeout | timeout: per command | Not built in — wrap with timeout(1) or equivalent | Not built in — wrap in the script |
| Escape hatch | git commit/push --no-verify (all managers — it is a git feature, not a manager feature) | same | same, plus SKIP=<hook-id> to skip one hook by name |
CI providers
| M1 piece | GitHub Actions (templates/ci-pr-gates.yml) | GitLab CI (.gitlab-ci.yml) |
|---|---|---|
| Run on every PR | on: pull_request | workflow: rules: with $CI_PIPELINE_SOURCE == "merge_request_event" |
| Concurrency-cancel superseded runs | concurrency: group keyed on PR number + cancel-in-progress: true | interruptible: true on jobs + “Auto-cancel redundant pipelines” (project setting, on by default) |
| Cheap grep gates + self-tests | Steps at the top of the first job, before toolchain install | An early gates stage of small script: jobs |
| Select the work for a change | One resolver job reads the change-area catalog and writes job outputs; every other job reads them with needs:. Never on.pull_request.paths on a workflow whose checks are required: a workflow that does not run never reports | rules: changes: per job, with the patterns generated from the catalog rather than copied into each job |
| One required verdict | An aggregator job that needs: every selected job, runs on if: ${{ !cancelled() }}, fails when a selected job failed or was cancelled, and is the only required check. A skipped required job counts as passing, so the skips are judged here | “Pipelines must succeed” already judges the whole pipeline; a job left out by rules: is not run and not counted |
| Bound every job | timeout-minutes: on each job, about two to three times its slowest healthy run and at most 60 minutes (M13) | timeout: on each job |
| Format → lint → types → build | Sequential steps in one job (one runner setup) | One job with sequential script: lines, or one stage per gate |
| Tests in parallel | Second job, own runner | Job in the same stage as the build job |
| Advisory (non-blocking) gate | continue-on-error: true on the job/step | allow_failure: true |
| Blocking merge (the authority) | Branch protection → required status checks | Merge-request setting “Pipelines must succeed” |
| Run summary | $GITHUB_STEP_SUMMARY | Job log / MR widget (no direct equivalent; a comment bot if needed) |
| Shadow job for a replacement tool | A job with continue-on-error: true that runs both tools on the same tree and writes the parity counts to $GITHUB_STEP_SUMMARY; not a required check | A job with allow_failure: true that writes the counts to its log or a report artifact |
| A skipped or cancelled job | The aggregator job (above) counts a selected job that was skipped or cancelled as not passed, and accepts a skip only for a job the resolver did not select | A job left out by rules: is not run and not counted: keep a job that must run free of rules: that can skip it |
| Commit-msg marker re-check | Step iterating git rev-list over PR commits (see template) | Same script; diff range $CI_MERGE_REQUEST_DIFF_BASE_SHA..HEAD |
Cheapest first, every independent gate reports
The gate set runs its cheap stages before its slow ones and runs to the end: a failing stage does not stop the stages that do not depend on it, and the run closes with the list of what failed. The first half is the order the stages are written in; each runner has a switch for the second.
| Runner | Keep going after a failure | Note |
|---|---|---|
A runner script of your own (Jig’s scripts/gates.ts) | Collect each stage’s status and decide at the end | Name each stage by the command that reruns it alone, so the closing list is a list of commands |
| make | --keep-going (-k) | A target that depends on a failed one is still left out |
| turbo | --continue=dependencies-successful | A task whose dependency failed is left out; every other task runs |
| lefthook | The default: every command of a hook runs and the hook fails at the end; piped: true stops at the first failure | Keep piped for a sequence whose later commands need the earlier ones’ output |
| GitHub Actions | A step after a failed step runs only with if: ${{ !cancelled() }}; strategy.fail-fast: false keeps a matrix’s other jobs running | Separate jobs are independent already; the aggregator job (above) judges them together |
| GitLab CI | The jobs of one stage run independently of each other; a job in a later stage runs after a failure only with when: always | allow_failure is for an advisory gate, not for keeping the run going |
Actionable findings in CI
A finding names its rule, its place, its problem and its fix in the log on every platform. In CI it is also written in the form the platform shows on the changed lines; the gate detects the platform from its environment.
| GitHub Actions | GitLab CI | |
|---|---|---|
| Detect | GITHUB_ACTIONS=true | GITLAB_CI=true |
| Mechanism | A workflow command printed to standard output: ::error file=<path>,line=<n>,title=<rule>::<problem> Fix: <remedy> (::warning for an advisory gate) | No log command: the job writes a Code Quality report, a JSON array of {description, check_name, fingerprint, severity, location: {path, lines: {begin}}}, and declares it as artifacts: reports: codequality: <file> |
| Escaping | In the message, % → %25, carriage return → %0D, line feed → %0A; in a property value also : → %3A and , → %2C | Ordinary JSON; path is relative to the repository with no leading ./; fingerprint is stable for the same finding (a hash of rule, path and text) |
| Where it shows | The run’s summary and the pull request’s changed files | The merge request’s Code Quality widget |
| “Could not check” | ::error title=<gate>: could not check::<reason>, with exit 2 | The job fails with exit 2 and the reason in its log; a report entry needs a file to point at |
GitHub shows only a limited number of annotations per step and per job and drops the rest, so the log, not the annotations, is the complete list of findings: a gate always prints every finding there.
Jig’s helper lib/findings.ts formats findings and
writes the GitHub form; the grep-gate reference
uses it. A repository adopting the reference gate either runs it from a
pinned Jig checkout or vendors lib/ with it (it imports lib/cli.ts,
lib/files.ts and lib/findings.ts); see
Non-JavaScript repositories. The GitLab report
is not written by the reference gate yet.
Exceptions that prune themselves
| Exception form | Reason the gate checks | Stale when |
|---|---|---|
Inline token (todo-exempt: <reason>) | Non-empty text after the token | The line no longer has what the rule flags (the TODO is gone, or already cites an issue) |
Inline token beside a line (M14’s fixed-delay: <reason>) | Non-empty text after the token | No fixed delay on the token’s line or the line below |
Path exemptions file (M14’s tests-with-changes <glob> <reason> lines) | Text after the glob on the same line | The glob matches no file in the tree the gate reads |
Line-based allowlist (Jig’s scripts/glossary-allowlist.txt) | Each group of entries opens with # lines giving its reason | No checked file uses the entry, or the rule already accepts it |
Allow pattern (Jig’s ! lines in scripts/tracker-key-patterns.txt) | # lines above the pattern | It matches nothing on a line the rule flags |
Structured list in the gate ({ path, match, reason }) | reason non-empty, checked when the list is read | No finding matches the entry in this run |
Retries
A retry is classified before it is taken (README, core piece 3):
only an error the step has classified as transient is retried, anything
else aborts at once with the command’s own message, and the classifier is
tested against messages recorded from the real tool. The reference wrapper
is reference/retry-classified/.
| GitHub Actions | GitLab CI | |
|---|---|---|
| Step-level retry | None built in: the step runs the reference wrapper, or its own loop, around the command | retry: on the job, with when: naming the failure classes the runner itself tells apart (runner_system_failure, stuck_or_timeout_failure, api_failure); never when: always, which retries a permission error as readily as a dropped connection |
| What the classifier reads | The command’s standard error and output, matched line by line against the pattern list, each pattern under its reason | The runner’s failure class; a distinction the runner cannot make (a rate limit against a missing permission, both script_failure) still needs the wrapper inside the script |
| The classifier’s test | A test that feeds --classify the messages kept in fixtures/recorded/ and asserts the answer for each | The same, for the patterns the wrapper reads |
| What a retry must never hide | The original message and exit status: the last attempt’s output is printed as the command wrote it, and an error outside the transient set ends the step on its first attempt | The same; retry: keeps each attempt’s log |
Custom lint rules and the ratchet
A project-specific rule (a pattern the repository has decided against) is
written in the linter’s own extension mechanism where it has one, so it runs
with the linter’s other rules and its severity decides whether the ratchet
holds it. The ratchet gate reads Biome’s JSON
report, compiler output, plain-text patterns and any command that prints
its counts as JSON (json); a tool outside them is counted through a grep
counter, a small wrapper that prints its findings in the json shape, or a
new format added to the gate.
| Ecosystem | Custom rule mechanism | Ratchet counter |
|---|---|---|
| Biome (Jig’s own wiring) | GritQL plugins listed under plugins in biome.json, each with its own includes | biome-json: biome lint --reporter=json; a plugin’s findings are named by the <scope>/<name>: prefix of its message |
| TypeScript compiler | Compiler flags in a separate project file (Jig’s tsconfig.ratchet.json) | tsc: --pretty false output, or bun check --no-pretty |
| ESLint | A local plugin of custom rules | Not read directly: a grep counter, or a wrapper turning --format json into the json shape |
| Any language | Structural search rules (ast-grep, Semgrep) | Not read directly: a grep counter, or a wrapper turning the tool’s JSON output into the json shape |
| Skill files (Jig’s own wiring) | M0’s skill-authoring check | json with per: "file": check-skill-authoring.ts --json <skills-dir> |
| Suppression comments | — | grep: one pattern per suppression marker |
Unused code and duplication are measured by tools that read the import graph
from entry points: fallow (Jig’s, through entry in .fallowrc.jsonc) and
knip (entry in its configuration) for JavaScript and TypeScript. Both take a
list of entry points: list the files run by path (a script a hook, a workflow
or a skill runs) one by one, from where they are invoked, rather than a folder
pattern.
For source-file size, the portable file-lines counter counts excess physical
lines above a configured limit across source and tests, including untracked files Git does not ignore.
Biome’s noExcessiveLinesPerFile
can enforce an absolute limit, but its one diagnostic per oversized file
does not increase when that file grows further. Counting its diagnostics
would miss that growth. Fallow’s health.maxUnitSize limits function lines;
its --max-file-size option skips large files during discovery. Neither
substitutes for a file-size ratchet that measures excess lines.
Jig’s wiring uses a limit of 1,000 physical
lines for source and tests alike. Lowering the limit tightens the rule; raising
it is a loosening that requires a person to request the existing
Ratchet-Loosen acknowledgement.
Immutable third-party automation and updates
Pinning and updating are one mechanism with two halves:
| Provider | Immutable reference | Maintenance path |
|---|---|---|
| GitHub Actions | uses: owner/action@<full-commit-sha> # v<release> | Configure Renovate’s github-actions manager, Dependabot’s github-actions ecosystem, or an equivalent updater to propose new commits through the normal PR gates |
| GitLab CI components/includes | Pin a component release or project include to the provider’s immutable commit form; do not follow a default branch | Configure a dependency updater that understands the include syntax, or keep a machine-readable registry plus a scheduled stale-pin check |
| Containerized CI tools | Pin the image digest and retain the human-readable release in a comment or variable | Let the updater propose digest changes, then run the same gate/self-test contract before merge |
Keep compatibility restrictions next to the updater policy with a reason, owner, review date, tested range, and removal condition. A permanently ignored update or unexplained version ceiling is hidden maintenance debt.
Release cooldown
The cooldown is one number stated in the policy and repeated by the updater and by every installer, each in its own unit; the policy’s exemptions are exact names everywhere. The lockstep gate reads every row whose note does not say otherwise.
| Tool | The cooldown | The exemptions | Note |
|---|---|---|---|
Renovate (renovate.json5) | minimumReleaseAge: "3 days", with internalChecksFilter: "strict" set explicitly, so no branch and no green pull request exists before the age check passes | One package rule with matchPackageNames: [<names>], minimumReleaseAge: "0 days" and no other selector: without the names it exempts everything its other selectors match, and another selector exempts only some updates of the names | vulnerabilityAlerts is the security path and may set minimumReleaseAge: null with schedule: ["at any time"]; a registry without release timestamps needs minimumReleaseAgeBehaviour: "timestamp-optional" on its rule, or its updates never clear |
Dependabot (.github/dependabot.yml) | cooldown: { default-days: 3 } on each updates entry; semver-major-days (and minor, patch) for a longer wait per update type | cooldown.exclude: [<names>] | cooldown.include narrows the cooldown to the names it lists, which the gate refuses; security updates skip the cooldown |
Bun (bunfig.toml) | [install] minimumReleaseAge = 259200 (seconds) | minimumReleaseAgeExcludes = [<names>], exact names only | Applies when bun add or bun update resolves a version; a frozen-lockfile install resolves nothing |
pnpm (pnpm-workspace.yaml) | minimumReleaseAge: 4320 (minutes) | minimumReleaseAgeExclude: [<names>] | Current pnpm reads only authentication and registry settings from .npmrc, so the workspace file is the one the gate requires; for a version that still reads .npmrc, the gate also checks minimum-release-age=4320 and one minimum-release-age-exclude[]=<name> line per name there. No effect under --frozen-lockfile; a deliberate lockfile refresh passes --config.minimum-release-age=0 for that one run |
npm (.npmrc) | min-release-age=3 (days); older releases have only before=<date>, a fixed date rather than a rolling age | min-release-age-exclude[]=<name> | Not read by the gate yet |
yarn (.yarnrc.yml) | npmMinimalAgeGate: 3d | npmPreapprovedPackages: [<names>] | Not read by the gate yet |
Install-script allowlist
| Installer | The allowlist | Every other package | Which packages want scripts |
|---|---|---|---|
Bun (package.json) | trustedDependencies: [<names>]. A list that is set is the only list, an empty one included; omitted, Bun’s built-in list of trusted packages applies (bun pm default-trusted prints it), so the gate requires the field even when the policy allows none | Scripts blocked at install | bun pm untrusted lists the blocked ones; bun pm trust <name> adds one to the list |
pnpm (pnpm-workspace.yaml) | onlyBuiltDependencies: [<names>]; every other setting that grants builds (dangerouslyAllowAllBuilds, neverBuiltDependencies, onlyBuiltDependenciesFile, allowBuilds) can let packages outside it run scripts, and the gate refuses each, in .npmrc too | Scripts blocked at install | pnpm approve-builds lists them and adds the chosen ones |
npm (.npmrc) | None: ignore-scripts=true blocks every dependency script, and each allowed package is built on purpose with npm rebuild <name> --ignore-scripts=false after the install, since npm rebuild honours the setting too | Blocked by the same setting | npm query ":attr(scripts, [postinstall])" and the other script names |
yarn (.yarnrc.yml, package.json) | enableScripts: false in .yarnrc.yml blocks every build, and dependenciesMeta: { <name>: { built: true } } in package.json re-enables one | Scripts blocked at install | yarn install reports the packages it built |
The updater never auto-merges a package on the list:
| Updater | The rule |
|---|---|
| Renovate | One packageRules entry with matchPackageNames: [<the allowlist>], automerge: false and groupName: null (its own pull request, not diluted in a weekly group), selecting by nothing else, so every update of those packages is covered, and last in the list, because a later rule overrides an earlier one |
| Dependabot | Dependabot has no auto-merge of its own; the workflow or branch rule that auto-merges its pull requests leaves the allowlist’s packages out |
Policy lockstep
One policy file (templates/supply-chain-policy.yaml)
states the cooldown, its exemptions and the allowlist; the
lockstep gate holds each
installer’s and updater’s file to it. The gate judges which packages may run
scripts, so it runs before any install that could run one: before the
install step (it needs no installed dependency), or after an install with
scripts off.
| Installer | Install with scripts off |
|---|---|
| Bun | bun install --frozen-lockfile --ignore-scripts |
| pnpm | pnpm install --frozen-lockfile --ignore-scripts |
| npm | npm ci --ignore-scripts |
| yarn | yarn install --immutable --mode=skip-build |
The updater checks itself
| Concern | Renovate | Dependabot |
|---|---|---|
| Range-valued overrides (a security floor, a major cap) | A rule with matchDepTypes: ["overrides", "pnpm.overrides", "pnpm-workspace.overrides"], matchCurrentValue: "!/^\\d+\\.\\d+\\.\\d+([-+][0-9A-Za-z.+-]*)?$/" and enabled: false: anything that is not an exact version is left alone, and a floor is raised by hand, with the advisory | Overrides are not updated; nothing to exclude |
| Custom extraction (a pin in source code, a workflow variable) | customManagers with customType: "regex", managerFilePatterns and matchStrings; a repository check parses those patterns out of the configuration (never a copy of them) and re-applies each to the tree, failing unless exactly one file and one match come back, with the expected dependency name and a value of the expected shape | None: a pin it cannot read is not updated, so list such pins in a scheduled stale-pin check |
Layered secret scanning
Each layer catches what the one before let through; the CI layer is the blocking one. A hook that finds no scanner installed says so and passes, since CI blocks.
| Layer | gitleaks (and its forks) | trufflehog | The forge |
|---|---|---|---|
| Pre-commit hook, over the staged changes | gitleaks git --pre-commit --staged --redact --config <file> as a hook-manager command | trufflehog git file://. --since-commit HEAD --fail | — |
| CI, over exactly the change’s commits | gitleaks git . --log-opts="<base>..<head>" --redact --exit-code 1, from a full-history checkout; the range and its empty-range refusal are in templates/secret-scan.yml | trufflehog git file://. --since-commit <base> --branch <head> --fail | — |
| Push protection | — | — | GitHub: secret scanning with push protection, a repository or organization setting; GitLab: secret push protection |
| A known false positive | An inline gitleaks:allow comment, or an allowlist rule in the scanner’s configuration, each with a reason beside it | --exclude-paths <file>, or a detector left out, with a reason | The forge’s bypass, which asks for a reason and logs it |
Agent-runtime hooks
A hook is one script, registered in each runtime’s own file in the same
shape: an event, an optional matcher on the tool name, and a command the
runtime runs with a JSON payload on standard input. The two runtimes below
share the payload’s and the output’s field names, so one hook script
serves both. Each runtime registers it in its own way: a plugin’s
hooks/hooks.json for Claude Code, and for Codex an entry in the Codex
home’s hooks.json that jig upgrade writes, approved once in /hooks.
| Claude Code | Codex | |
|---|---|---|
| A repository’s hooks | hooks in .claude/settings.json | .codex/hooks.json, or [hooks] tables in .codex/config.toml; read only in a trusted project |
| A plugin’s hooks | hooks/hooks.json at the plugin root, or a hooks field in the manifest; the command reaches the plugin’s files through ${CLAUDE_PLUGIN_ROOT} | hooks/hooks.json at the plugin root, or a hooks field in the manifest; PLUGIN_ROOT, and CLAUDE_PLUGIN_ROOT for the same path |
| Trust | A plugin’s hooks run once the plugin is enabled | A hook runs only once its current definition is trusted (/hooks); a plugin’s hooks are skipped until then, and an edited hook is trusted again |
| Events | PreToolUse, PostToolUse, UserPromptSubmit, SessionStart (matcher startup, resume, clear, compact), PreCompact, Stop, SubagentStop, among others | PreToolUse, PostToolUse, PermissionRequest, UserPromptSubmit, SessionStart, SessionEnd, PreCompact, PostCompact, Stop, SubagentStart, SubagentStop, Interrupt |
| The payload | JSON on standard input: session_id, transcript_path, cwd, hook_event_name; tool_name and tool_input before a tool call; agent_id when the call is a subagent’s | The same names; transcript_path names Codex’s own transcript, whose records differ from Claude Code’s |
| Clear | Exit 0 with nothing on standard output | Same |
| Clear, with context | Exit 0 and {"hookSpecificOutput": {"hookEventName": "PreToolUse", "additionalContext": "…"}} on standard output | Same |
| Deny | Exit 2 with the reason on standard error, or permissionDecision: "deny" with permissionDecisionReason | Same |
| Timeout | timeout in seconds per command, default 600; a hook that runs before every tool call sets a short one | Same default |
Two behaviours are validated under Claude Code only. A hook exit other
than 0 and 2 lets the action proceed, and the transcript shows a hook error
with the hook’s standard error, which is how a could-not-check notice
reaches the agent. Hooks fire inside subagents too, with agent_id set.
Under Codex both are open (README.md § Status).
The hooks the practice has validated, each run before a tool call:
| Hook | What it does | Ships as |
|---|---|---|
| Turn-budget guard | Counts the session’s round-trips off the transcript since its last call and hands the agent a wrap-up instruction within a margin of the runtime’s turn cap | The plugin’s hooks/turn-budget-guard.ts |
| Shell-syntax guard (matcher: the shell tool) | Denies a command that is valid in one shell but a hard error in the shell the tool runs (an unquoted glob that matches nothing, a word starting with =, an unquoted variable holding a command and its arguments), each with a one-line correction; anything its lexer does not model passes | An example, written against the repository’s own shell |
| Test-output filter (matcher: the shell tool) | Rewrites a bare test-runner command, and only one with no shell metacharacter, to a wrapper that prints a summary when the run passes and the whole output when it fails, keeping the run’s exit code | An example |
| Refocus after compaction | Re-injects a session’s intent after a compaction and on later prompts | Future: it waits on the comparison in ROADMAP.md |
Where each piece lands
| M1 piece | This module ships | You install it at |
|---|---|---|
| Hook layer shape | templates/lefthook.yml | Repo root (or manager equivalent above) |
| Grep-gate framework | reference/grep-gate/ | scripts/check-<rule>.ts + Bun tests + fixtures, wired into pre-push and CI |
| CI gate set | templates/ci-pr-gates.yml | .github/workflows/ or .gitlab-ci.yml per the table above |
| Suppression registry | templates/suppression-registry.md | Your docs tree, one page, linked from the instruction file |
| Commit-msg marker | reference/commit-msg-marker/ | scripts/ + the manager’s commit-msg hook + a CI re-check |
| Classified retry | reference/retry-classified/ | Around a command a CI step or a hook retries, with the pattern list and its recorded messages beside the workflow |
| Ratchet gate | reference/ratchet/ | A wiring file of counters and configuration files (Jig’s: tools/quality/ratchet.jsonc), run by a package script in the gate set; CI checks out full history so the merge base exists |
| Supply-chain policy | templates/supply-chain-policy.yaml | One file every reader can see (Jig’s: .config/supply-chain-policy.yaml), repeated by the updater and each installer per the tables above |
| Policy lockstep gate | reference/supply-chain-lockstep/ | A wrapper script naming the policy and the repository’s installer and updater files (Jig’s: scripts/check-supply-chain-lockstep.ts), in the gate set and as a CI step before the install |
| Secret scan | templates/secret-scan.yml | .github/workflows/, with the scanner’s configuration at the root; the hook layer in the hook manager, push protection in the forge’s settings |
| Agent-runtime hook | The plugin’s hooks/turn-budget-guard.ts, registered for Claude Code by its hooks/hooks.json and for Codex by an entry jig upgrade writes into the Codex home, which needs approval once | Installed with the plugin for Claude Code; a hook of the repository’s own goes in the runtime’s hook file per the table above, with its test beside it |
| Hook self-test runner | templates/hook-self-tests.sh | A CI step in the required set, naming the hooks directory |
Non-JavaScript repositories
The invariant is that a gate has one reproducible implementation, independent
of the application’s language. Jig chooses a mise-managed Bun pin: run the complete pinned checkout with its mise.toml active,
install bun.lock with bun install --frozen-lockfile, and invoke bun <gate.ts>.
The consumer’s application can remain Python, Go or any other stack.
Standalone executables from bun build --compile are supported by Bun, but a
binary release matrix waits until distribution needs it. Source plus a
runtime pin keeps fixtures and dependencies together and avoids a second
packaging contract. Layout and adoption details:
tools/README.md.
What this module provides:
templates/lefthook.yml— the hook layer’s shape: fix-and-stage pre-commit, pre-push grep gates then the heavy phase, commit-msg markers.templates/ci-pr-gates.yml— a GitHub Actions pull-request workflow: one resolver job that selects the work from the change-area catalog (M3), grep gates with their self-tests first, the gate set, tests on a parallel runner, a timeout on every job, and one aggregator job that is the only required check. Why it has that shape, and how to keep a pipeline cheap without weakening it, is M13 pipeline economy: M1 decides what is checked, M13 how cheaply and how fast.templates/suppression-registry.md— the registry page for suppression tokens and process markers.templates/supply-chain-policy.yaml— the one statement of the release cooldown, its exemptions and the install-script allowlist, which every installer and the updater repeat.templates/secret-scan.yml— a GitHub Actions workflow for the blocking layer of the secret scan: a pinned, checksummed scanner over exactly the change’s commits, refusing an empty range.templates/hook-self-tests.sh— the runner that discovers every agent-runtime hook’s self-test in a directory and runs them, failing a hook without a test and refusing a directory that is not there, with its own self-test beside it (templates/hook-self-tests.test.ts).reference/grep-gate/— the grep-gate convention with one worked gate (a TODO must cite an issue) and its fixtures: three outcomes, a scope line on green runs, findings with a fix, GitHub annotations in CI, and a stale suppression as a finding. Its finding and annotation format comes from Jig’s shared helperlib/findings.ts.reference/commit-msg-marker/— the commit-msg hook script for review markers, with its design notes.reference/ratchet/— the ratchet gate: counts findings per rule in the working tree and the merge base, fails when a count grows or a configuration loosens a rule, and reports rules ready for promotion; with its self-tests.reference/supply-chain-lockstep/— the policy lockstep gate: reads the policy file and checks that each installer and updater file it is given states the same cooldown, exemptions and install-script allowlist, in that file’s own units; with its fixtures and self-test.plugin/hooks/turn-budget-guard.ts— the turn-budget guard, the plugin’s agent-runtime hook: before every tool call it counts the session’s round-trips off the transcript and hands the agent a wrap-up instruction within a margin of the runtime’s turn cap; registered for Claude Code byplugin/hooks/hooks.jsonand for Codex, whose per-release re-approval of a plugin’s hooks it avoids, by an entryjig upgradewrites into the Codex home that runs a stable shim; tested inplugin/hooks/__tests__/.reference/retry-classified/— the classified retry: runs a command, retries it only on an error the pattern list classifies as transient, aborts at once on any other with the command’s own output and status, and answers for a recorded message so the list is tested against the real tool’s wording; with its self-test.mappings.md— hook managers (lefthook, husky, pre-commit), CI providers (GitHub Actions, GitLab CI), pin-and-update providers, the cooldown, install-script and self-check settings of each package manager and updater, the secret scanners per layer, and the hook systems of the agent runtimes; and the module’s maturity criteria.
The self-tests for the grep gate and the commit-msg marker are in
scripts/freshness.test.ts; the
ratchet’s and the lockstep gate’s are beside each gate, in
reference/ratchet/ and
reference/supply-chain-lockstep/. Jig runs
this module on itself: bun run gates runs the repository’s gate set cheapest
first and to the end, CI runs the same command on every pull request, and the
order is stated in CONTRIBUTING.md.
Its ratchet covers Biome’s warnings
(including Jig’s GritQL rules in tools/quality/grit/), the compiler flags
being burned down, suppression comments and excess lines above the
configured source-file limit, including test code. File size uses total excess
lines, so growth in an already oversized file still fails; generated and
vendored files stay outside the source scope. The
/jig:github-actions
skill checks workflow changes against this module’s pin-and-update invariant,
and /jig:fix-ci repairs a red
gate run from its log and verifies the fix locally before pushing.
Of third-party automation and dependency integrity (core piece 7), the
pin-and-update half is the invariant, the provider table in
mappings.md
and a Standard criterion, with no reference script; the policy lockstep ships
as reference/supply-chain-lockstep/ and
the secret scan’s blocking layer as a workflow template, while the hook and
push-protection layers are rows in mappings.md.
The updater’s self-check has no reference either: the override rule is one
entry of the updater’s configuration, and the extraction check is a few
lines that re-apply that configuration’s own patterns to the repository’s
tree, so each is written against the repository’s own updater
(mappings.md). The lockstep gate
reads Bun’s, pnpm’s, Renovate’s and Dependabot’s files; npm’s and yarn’s
cooldown settings are future work for when a repository on them adopts it.
The gate lifecycle
(core piece 6) is stated as practice: no reference ships for the shadow job, the retirement record or the entry-point list, since each is a
few lines of the repository’s own CI and configuration. The reference gate
writes GitHub annotations only; mappings.md
names GitLab’s Code Quality report as the equivalent, and emitting one is
future work for when a GitLab repository adopts the gate.
Of agent-runtime hooks (core piece 8), the rung and its rules are the
invariant, the runtimes’ hook systems are rows in
mappings.md, and the plugin ships a
hook, the turn-budget guard, which
/jig:drive-pr
relies on to end a round before the runtime’s cap. Jig’s own CI runs the
hook’s tests through the gate set’s test stage, which discovers them by name;
the runner template is for a repository whose hooks are shell scripts or
whose tests sit outside its test runner’s discovery. The other hooks the
mappings name, a guard against shell syntax that fails under the tool’s
shell and a filter that trims a passing test run’s output, are examples of
the rung, not shipped. A hook that re-injects a session’s intent after a
compaction is future work: it waits on the comparison
ROADMAP.md lists. So is the guard under Codex:
whether a could-not-check exit surfaces its notice there, and whether hooks
fire inside Codex’s subagents, wait for a session that runs the hook in
Codex with the plugin trusted.
The audit scores these gate-authoring rules: the three outcomes, stale exceptions failing, a self-test with nothing to examine, and retries that classify. The other rules (a scope line on green runs, actionable findings, a self-test recognizer broader than the gate’s, mutation-tested fixtures, the size of the parsed population) and the gate lifecycle are not yet scored. Each needs an observable fact a criterion can name, and finding one is future work.
Jig’s own gates
How Jig’s own gate set meets these rules, and where it does not yet, is in CONTRIBUTING.md § Where Jig’s gates fall short.