The merge gate
Rules in AGENTS.md are advice: an assistant can ignore them, and a busy reviewer can miss what it wrote. The gate is the part that runs on every pull request, whoever or whatever wrote it, and reports whether it is fit to merge.
Why a gate
A standard that nothing checks drifts. The gate is one workflow, pnpm redline init installs it, and it runs a handful of checks on every pull request. It reports one result, redline-gate / gate, that a branch rule can require.
Two kinds of check
The checks fall into two groups. The question that separates them: is merging the mistake already the damage?
| Process checks | Security floor | |
|---|---|---|
| Catches | an unticked checklist, a large change with no written decision, a broken rule | a dependency with a known vulnerability, a live credential in a commit |
| If it merges anyway | fix it in the next pull request | the damage is done: the credential is exposed, the vulnerable version shipped |
| How strict | set per repository by its rung | fails the gate at every rung |
| Can be waived | yes, with a recorded exemption | never |
The checks
| Check | Fails when | Kind |
|---|---|---|
| PR checklist | The ## Launch readiness section of the pull request description has an unticked box, or the section is missing. | process |
| ADR required for significant changes | The change is over 300 changed lines and its description links no decision record. | process |
| Deterministic policy | An added line breaks a rule a checker can decide without a model, at or above the severity the rung sets. | process |
| Dependency review | The pull request adds or changes a dependency with a known vulnerability rated high or worse. | security floor |
| Secret scan (diff) | TruffleHog finds a verified credential in the pull request's commits. | security floor |
On GitHub each check appears as redline-gate / <check>, beside the aggregate redline-gate / gate. Model review comments are not a check: they are posted on the pull request and measured, and never fail the gate.
The checklist check
The pull request template carries a ## Launch readiness section. Every box in it must be ticked, or deleted with a reason in the description. Deleting the whole heading does not get past it: a missing section fails too.
The ADR check
A change over 300 changed lines (additions plus deletions) must link a decision record under docs/adr/ in its description, such as docs/adr/0001-country-list-in-code.md. The template's own placeholder, docs/adr/NNNN-*.md, does not count. Two ways out, both on the record:
- the
no-adrlabel, for one pull request that is large but decides nothing, such as a lockfile update or a rename pnpm redline init --no-adr, to turn the check off for the repository
Learn step 05 walks through it.
The security floor
Dependency review is GitHub's dependency-review-action. It checks every package the pull request adds or changes against GitHub's advisory database. Advisories rated below high do not fail it.
The secret scan runs TruffleHog over the pull request's commits. It counts only credentials TruffleHog has verified are live. An unverified match is too often a false positive, and this is a check nobody can waive. Learn step 06 shows a failing dependency review and its fix.
Private repository Dependency review needs GitHub Code Security
On a public repository dependency review is free. On a private one it needs GitHub Code Security. Without it, onboarding can hand dependency checks to Dependabot instead, and the job is skipped.
A skipped job counts as a pass, so nothing in the pull request stops a vulnerable version: Dependabot alerts after it reaches main. The secret scan needs no licence and runs on every repository.
How the gate decides
The aggregate gate job reads every check's result. A skipped check counts as a pass. Then:
| What failed | At observe | At block-blocker or block-high |
|---|---|---|
| A security floor check | gate fails | gate fails, exemption or not |
| A process check | gate passes, with a warning | gate fails, unless a valid exemption covers every failing check |
| Nothing | gate passes | gate passes |
At observe a failing process check still shows red on its own line. Only the aggregate stays green. observe means “measured, not yet enforced”, not “off”.
The gate job's log says which case applied:
# the gate job's log, one line per case # a security floor check failed: fails at every rung Error: Redline gate failed on security checks (not label-exemptible, and not on the enforcement ladder): dependency-review # a process check failed at observe: passes, with a warning Warning: Process checks failed: policy. This repository is at rung 'observe', which reports and does not block. The findings are recorded either way. # a process check failed at a blocking rung, with a valid exemption: passes, with a warning Warning: Process checks failed but a valid exemption is recorded: checklist. A reviewer is accepting this deliberately, with a reason and an expiry. # a process check failed at a blocking rung, no exemption: fails Error: Redline gate failed: policy
A rung the gate does not recognise is treated as not enforcing, so a typo can never make a repository stricter than anyone chose.
Red is not the same as blocked
The gate turning red and the merge button being disabled are two separate settings:
- The rung decides what turns the gate red.
pnpm redline init --blockingmakesredline-gate / gatea required check, so a red gate stops the merge. A new onboarding is advisory: the gate shows red, and the merge button still works.
Turn blocking on once the team has watched the gate for a while. Learn step 07 does it, and Enforcement ladder explains how the two combine.
Gate settings and defaults
init writes these into the caller workflow, .github/workflows/redline.yml. The file is regenerated on every init, so change a setting with its flag rather than by hand.
| Setting | Default | Change it with |
|---|---|---|
rung | observe | pnpm redline init --rung <name>, if the evidence allows |
adr-diff-threshold | 300 changed lines | pnpm redline init --no-adr turns the check off |
fail-on-dependency-severity | high | no flag |
soft-fail-labels | redline-exempt,redline-sync | no flag: the labels that mark an exemption |
stand-down | empty: every check runs | pnpm redline init --integrations <list>; see below |
Who can change the gate
A gate the pull request can edit is not a gate. Where the workflow lives decides this:
--gate-source org(the default) references a reusable workflow in your organisation's<org>/.githubrepository. A pull request in a product repository cannot change it.--gate-source localcopies the workflow into.github/workflows/redline-gate.yml, for an organisation with no shared.githubrepository yet. A pull request runs the workflow from its own branch, so it can edit the gate that is judging it.initwarns about this on every run. Close the gap by requiring an owner's review on.github/workflows/with--with review-ownership --review-owners <team>, or move to the org gate.
No CI at all: the local-agent gate
pnpm redline init --pipeline local-agent installs no workflow. The gate is a git hook, .redline/hooks/pre-push, committed so it is reviewed, versioned and removed like any other file.
Before each git push it runs redline policy over the commits being pushed. The rung in .redline.json decides what a finding does: observe reports, block-blocker and block-high refuse the push. The judgement rules are left to whichever assistant you already use.
Each engineer turns it on once per clone:
$ git config core.hooksPath .redline/hooks
The trade-off: it publishes no check, so no branch rule can require it, and git push --no-verify skips it. In return it needs no CI, no credential and no host. If husky v4, lefthook or pre-commit already installed a hook in .git/hooks/pre-push, init reports denied rather than silently disabling it.
Branch policy
init also applies a branch policy, as a GitHub ruleset named Redline or an Azure DevOps branch policy, so no repository is set up by hand:
- Review threads must be resolved before merge.
- No approving review is required by default;
pnpm redline init --approvals <n>requires n. Automated review is advice and never approves. - The gate is required only after
pnpm redline init --blocking.
GitHub and Azure DevOps
The name a branch policy requires differs by host:
| Host | What the gate reports | Required as |
|---|---|---|
| GitHub | a check run, named from the caller and called job ids | redline-gate / gate |
| Azure DevOps | a pull request status, genre redline, name gate | redline/gate |
On GitHub, requiring the wrong string leaves every pull request waiting for a status that never arrives. Azure DevOps has no such derivation, so that failure cannot happen there.
Azure Repos ignores a pipeline's YAML pr: trigger. So init also registers the gate pipeline and a Redline: gate build Build Validation policy that queues it on every pull request. Without Build Administrator rights that step is recorded as pending, and the status is left advisory: requiring a status no pipeline can publish would block every pull request.
To confirm the name the host actually reported on a real pull request, rather than what a config file claims:
$ pnpm redline verify
$ npx redlinegate verify
$ yarn redline verify
$ bun run redline verify
Adding a check of your own
Three ways, in the order to reach for them. The first two need no change to Redline.
- Run it beside the gate. A check that is yours alone, such as a licence scan or a bundle-size budget, is an ordinary workflow. To make it block, require its check name in a second ruleset. Editing the ruleset named
Redlineby hand is drift, andverifyreports it. - Stand a Redline check down. When another tool already covers a check,
pnpm redline init --integrations <list>records the tools you declared and writesstand-down:into the caller. A stood-down check is skipped, and a skip counts as a pass.policy,dependenciesandsecretscan be stood down. The last two are the security floor: stand one down only because another scanner genuinely covers it, never to turn a red pull request green. - Add a job to the gate itself, for a check the whole organisation should get. Add the job to the
gatejob'sneeds:list, or the aggregate never reads its result. Do not rename theredline-gateorgatejob ids: the required check name is built from them, and renaming either leaves every pull request on “Expected — waiting for status”. A new job is a process check; the security floor is deliberately not a list a repository extends.
With --gate-source org the jobs live in <org>/.github, and one merge there reaches every repository. With --gate-source local, the copied file is overwritten by the next pnpm redline init --repair, so put the check in its own workflow or contribute it to the Redline source repository. Either way, prove it: Prove it shows a stood-down job reading as a pass, and a check that blocks next to one that only reports.
Related
- Enforcement ladder: rungs, evidence and blocking.
- Exemptions: waiving a process check on the record.
- The gate workflow: the file itself.