05 · A big change needs an ADR
A large change usually carries a decision that someone will later want to understand. Past 300 changed lines, Redline asks for that decision to be written down and linked from the pull request.
You will learn
- What an ADR is, and why big changes need one
- How the gate decides a change is big, and what counts as a link
- When to skip it, on the record, with the no-adr label
Why write a decision down
Six months from now, someone opens src/countries.ts, finds 249 countries typed into the code, and asks: why not a package from npm? The answer was in the head of whoever wrote it, and maybe in a pull request comment nobody will find. They either spend an afternoon working it out again, or they "fix" it and bring back the problem the table was there to avoid.
New term ADR (Architecture Decision Record)
A short markdown file that records one decision: the context, the options considered, the choice, and its consequences. It lives in the repository, in docs/adr/, next to the code it explains, and answers "why is it done this way?" without anyone having to remember.
The gate cannot tell whether a pull request made a decision. It can count lines, and a big change usually carries one, so it asks on size. When a big change decides nothing, you say so with a label instead.
What the check reads
The job is redline-gate / ADR required for significant changes. It fails when the change is over the threshold, has no ADR link, and has no no-adr label:
| Input | Where it comes from |
|---|---|
| Changed lines | Additions plus deletions on the pull request |
| Threshold | adr-diff-threshold: 300 in .github/workflows/redline.yml |
| ADR link | A real file name under docs/adr/ in the description, such as docs/adr/0001-country-list-in-code.md, as a path or a URL. The template's placeholder, docs/adr/NNNN-*.md, does not count. |
| Opt-out | The no-adr label, for a change that is large but decides nothing: a generated lockfile, a rename, the onboarding pull request. Say why in a comment. |
Make a big change
Add an address parser that refuses a country that is not real, checked against a 249-entry ISO 3166 table. Download the files from the demo rather than typing them:
$ git checkout -b feat/addresses $ curl -fsSL --remote-name-all --output-dir src "https://raw.githubusercontent.com/moelzanaty3/redline-demo/step-05/src/{countries,countries.test,address,address.test}.ts" $ pnpm test $ git add src $ git commit -m "feat: parse addresses, with the country checked against ISO 3166" $ git push -u origin feat/addresses $ gh pr create --title "feat: parse addresses, with the country checked against ISO 3166" --body-file .github/pull_request_template.md $ gh pr checks --watch ✓ test ✓ redline-gate / Deterministic policy X redline-gate / PR checklist until you tick the boxes X redline-gate / ADR required for significant changes ✓ redline-gate / Dependency review ✓ redline-gate / Secret scan (diff) ✓ redline-gate / gate passes, with a warning
On GitHub, tick the ## Launch readiness boxes that hold, as in step 02. The ADR job stays red. Open it: with its tests, the change is 352 lines, and the description still has only the template's placeholder:
# from the ADR job's log changed=352 threshold=300 adr-links=0 no-adr-label=0 Error: 352 changed lines with no ADR link. Add docs/adr/NNNN-*.md and link it in the PR body, or apply the 'no-adr' label with a justification comment.
The gate still passes, because the repository is at observe. But the job is red on the pull request, and that is the prompt to write the decision down.
Write the decision down
On the same branch, create docs/adr/0001-country-list-in-code.md. Paste this into your terminal:
$ mkdir -p docs/adr $ cat > docs/adr/0001-country-list-in-code.md <<'EOF' # 0001 · The country list lives in code ## Context parseAddress has to refuse an address whose country does not exist. That needs the ISO 3166-1 list, and the list has to come from somewhere. ## Options 1. A dependency: maintained by someone else, but every upgrade is a supply-chain change to review. 2. A lookup service: always current, but parsing would need the network. 3. A table in code, generated once from the CLDR data that ships with Node. ## Decision Option 3. src/countries.ts holds 249 entries, and a test pins the count. ## Consequences - No new dependency and no network call. - When ISO 3166 changes, someone regenerates the table on purpose. EOF
It is a shortened version of the demo's. Read the full one for what each section looks like with real reasoning in it. Number the next one 0002: the number keeps them in the order they were decided.
Push the file to the pull request:
$ git add docs/adr $ git commit -m "docs(adr): 0001 the country list lives in code" $ git push
Then point the description at it. This swaps the template's placeholder for the link and keeps everything else, including the boxes you ticked:
$ gh pr view --json body -q .body | sed 's|`docs/adr/NNNN-\*\.md`|[docs/adr/0001-country-list-in-code.md](../blob/main/docs/adr/0001-country-list-in-code.md)|' | gh pr edit --body-file -
Or edit the description on GitHub, so the ADR line reads:
## Architecture decision
ADR: [docs/adr/0001-country-list-in-code.md](../blob/main/docs/adr/0001-country-list-in-code.md)
Editing the description re-runs the gate, so no new commit is needed for the link. The link points at main, so it opens only after you merge; the gate reads the file name, not the page behind it.
$ gh pr checks --watch ✓ test ✓ redline-gate / Deterministic policy ✓ redline-gate / PR checklist ✓ redline-gate / ADR required for significant changes ✓ redline-gate / Dependency review ✓ redline-gate / Secret scan (diff) ✓ redline-gate / gate
The ADR job's log now counts the link:
# from the ADR job's log changed=374 threshold=300 adr-links=1 no-adr-label=0
Merge it
Every check is green. Merge, and bring main back for the next step:
$ gh pr merge --squash $ git checkout main $ git pull
When there is no decision
Not every big change decides something. For one pull request, label it and say why, as you did for the onboarding pull request in step 01:
$ gh pr edit --add-label no-adr $ gh pr comment --body "Regenerated lockfile. No design decision."
A repository that does not keep decision records at all turns the check off, and --adr turns it back on:
$ pnpm redline init --no-adr --no-commit
$ npx redlinegate init --no-adr --no-commit
$ yarn redline init --no-adr --no-commit
$ bun run redline init --no-adr --no-commit
That is a team decision, so it goes through a pull request like the rest of the configuration. Before you take it, remember the afternoon someone spends rediscovering why the country list is in code.
Check your understanding
A pull request regenerates pnpm-lock.yaml: 2,000 changed lines and no decision. What is the right move?