Recording a decision
A choice with alternatives and costs gets one immutable record, numbered next in line, and the build checks that it is there.
Why the log exists
docs/ARCHITECTURE.md says what the design is, in the present tense, with the reasoning compressed out. Six months on, nobody can tell which lines are considered choices and which are placeholders that survived because nobody revisited them. The decision log is the reasoning: one record per choice, with the forces that pushed on it, what was decided, what else was on the table, and what it costs. The point is that the reasoning survives the people who did it. The log is book/src/adr/, read on GitHub, and its index lists every record.
A record is reviewed in the same pull request as the code that implements it. Commit messages are keyed to changes, and a decision made across five commits is unrecoverable from them.
When a change needs one
A record is for a choice: there were alternatives, each had a cost, and the next maintainer could undo the choice without knowing what it was load-bearing for. A bug fix is a commit. It becomes a record when fixing it meant choosing between designs, or when the bug was invisible for a reason worth writing down.
Two tests of whether a change needs a record:
- Could a reviewer ask “why not the other way?” and need more than a sentence?
- Would someone a year from now be tempted to reverse it?
A record with no costs listed has not been thought through. If there is nothing to put under Consequences, there was no decision.
The template
Start from the template. Its sections, in order:
| Section | What goes there |
|---|---|
| Title | # ADR-NNNN: Title, or # NNN. Title. The log accepts both |
| Status | Proposed, Accepted, or Superseded by ADR-NNNN. A bullet, or a ## Status section |
| Date | The day it was recorded |
| Relates to | The ARCHITECTURE.md section, and the records it leans on or amends |
| Context | The forces at play. What makes this a decision rather than an obvious call. The constraints stated honestly, including the ones about time or taste |
| Decision | What was decided, in the active voice. One paragraph if possible |
| Alternatives considered | What else was on the table, and the specific reason each was rejected. “It was worse” is not a reason |
| Consequences | What becomes easy, what becomes hard, and what becomes expensive to reverse. The costs, not only the benefits. This is the section future readers come for |
Numbering
Take the next unused number across the index, release staging and
the retired register.
Name the file NNNN-kebab-case-title.md. Once assigned, a number stays with
its decision even when the file leaves the active log.
The build checks that each number is unique, each published or staged record has a matching heading and a status, and each published record appears once in the topic index.
./gradlew :build-logic:test --tests '*DecisionLogTest*'
At release, review the log and retire short operational notes and fixes whose rationale is preserved elsewhere. Record retired numbers and update links to cite a current decision or the original file at a fixed commit.
Status values
| Status | Meaning |
|---|---|
| Proposed | Written down and not agreed. An open question |
| Accepted | Agreed and in force |
| Superseded | Replaced. The record names what replaced it |
Supersession
Records are immutable once accepted. A decision that turns out to be wrong is not edited. A new record supersedes it, the old one gains a Superseded by ADR-NNNN line in its status, and the wrong turn stays visible.
A record may also amend one without superseding it: a matrix that lost two rows, a mechanism that stayed while the numbers changed. The amending record says so in its status, and the amended one gains a blockquote pointing forward.
The log contains records that are wrong. That is intended.
Where a record is linked from
A record is not built into the site, so a link to one is its GitHub address:
[ADR-0063](https://github.com/DigitalSmile/goldberry/blob/master/book/src/adr/0063-data-flows-down-events-flow-up.md)
From docs/, the path is ../book/src/adr/NNNN-slug.md. A chapter of this guide states what the toolkit does and cites no record. A Java doc comment does not cite one either: its reader has a tooltip or a javadoc site, not the repository, so the comment states the rule in plain words and links the chapter of this guide that covers it. Writing a doc comment is the house style.
The title
A title states the decision as a sentence, so the table of contents reads as a list of what was decided:
- A version is a year and a count
- A package is a role, and the module is the fence
- Every package says what it is, and is null-marked
- A preflight check that cannot fail is not a check
Not Versioning, and not Use calendar versions. The sentence is the decision, and a reader scanning the log should be able to stop at the title.
Status and TODO
Two pages in docs/ are updated when a record lands:
- Status says what is built. A record that completes a piece moves its row.
- TODO says what is left for later, what is broken, and what is specified and unbuilt. An entry leaves the top half when a record answers it and moves to Answered rather than being deleted, because each one records a trap somebody hit and the reasoning that got out of it. A record that closes an entry says so in its status.
docs/ARCHITECTURE.md §17.1 lists where the design documents disagree with each other, and a record that settles one strikes the entry through rather than deleting it.
Writing one
Take the next free number. Check the decision log, release staging and the retired register.
Copy 0000-template.md to NNNN-kebab-case-title.md and fill every section. Consequences last, and honestly.
Stage the record for the next release. Add it under its subject in the index when promoting it.
Link it from the status row or the TODO entry it changes, and from any record it supersedes or amends. A chapter of the guide does not cite it.
Run the build-logic tests and checkMarkdown. Put the record in the same pull request as the code.
./gradlew :build-logic:test checkMarkdown