Recording and later superseding a messaging decision
In a scratch Git repository, record a messaging decision in MADR 4.0.0 backed by a weighted comparison, guard the decision log with a checker in a pre-commit hook, then supersede the decision eight months later and watch the hook enforce the status change and the link.
Contentsand lesson path
On this page
- Goal and setup
- Step 1: Create the repository and fetch the template
- Step 2: Compare the options (March 2026)
- Step 3: Write the first two records
- Step 4: Add the checker and a pre-commit hook
- Step 5: Eight months later, compare again
- Step 6: Write the new record and try to commit it
- Step 7: Supersede ADR-0002
- Step 8: Read the history
- Troubleshooting
- Check your understanding
- Apply it
- Review prompt
Lessons of Architecture Decision Records
- What makes a decision architectural: reversibility and blast radius Concept · 15 min
- Options analysis with weighted drivers Worked example · 25 min
- ADR anatomy, templates and the decision log Concept · 15 min
- Recording and later superseding a messaging decision Lab · 25 min
- Choosing technologies: criteria, spikes and exit costs Worked example · 25 min
- Decision quality check Knowledge check · 8 questions
What you will learn
- Compare at least three options, including doing nothing, against weighted drivers and make the trade-off explicit.
- Write and maintain ADRs (context, decision, status, consequences) in version control, including superseding an earlier one.
01. Goal and setup
You will play the Orders team of a small online shop, Parcelpoint, over eight months. In March 2026 the team decides how order events reach other services and records the decision as an ADR. In November the context has changed, and a new ADR supersedes the first one. Along the way you write a short checker that lists the decision log and fails when a superseded record does not point to its successor, and you install it as a Git pre-commit hook that stops commits with a broken log.
If at-least-once delivery is new to you, the delivery guarantees lesson explains it. One more term: an outbox is a table in a service's own database where an event is written in the same transaction as the business change, so the event is not lost if the service crashes. Consumers, or a relay process, read events from it later.
You need a Linux or macOS shell (on Windows, use WSL or Git Bash), Git 2.28 or newer for git init -b, Python 3.10 or newer, and curl. The lab was run with Git 2.34.1 and Python 3.12.13; the scripts use only the standard library, and no message broker is needed. At the end, the repository looks like this:
parcelpoint/
├── docs/decisions/
│ ├── adr-template.md step 1: MADR 4.0.0 template, for reference
│ ├── 0001-record-architecture-decisions-with-madr.md step 3
│ ├── 0002-deliver-order-events-through-a-polled-outbox.md steps 3, 7
│ ├── 0003-graphql-gateway-for-the-storefront.md step 5
│ └── 0004-publish-order-events-to-kafka.md step 6
└── tools/
├── score.py step 2: the weighted comparison
└── adrlog.py step 4: lists and checks the log02. Step 1: Create the repository and fetch the template
Work in a new scratch folder outside any repository. The commands set a Git identity for this repository only, create the folders, download MADR's full template from the 4.0.0 release tag, and print its headings and status line.
mkdir parcelpoint && cd parcelpoint
git init -q -b main
git config user.name "Lab User"
git config user.email "[email protected]"
mkdir -p docs/decisions tools
curl -fsSL -o docs/decisions/adr-template.md \
https://raw.githubusercontent.com/adr/madr/4.0.0/template/adr-template.md
grep -E '^(#|status:)' docs/decisions/adr-template.md# These are optional metadata elements. Feel free to remove any of them.
status: "{proposed | rejected | accepted | deprecated | … | superseded by ADR-0123"
# {short title, representative of solved problem and found solution}
## Context and Problem Statement
## Decision Drivers
## Considered Options
## Decision Outcome
### Consequences
### Confirmation
## Pros and Cons of the Options
### {title of option 1}
### {title of other option}
## More InformationThe first line is a YAML comment. The status line lists MADR's values, ending with superseded by ADR-0123: a successor named by its identifier. The records below are shorter but keep the required sections: title, context and problem statement, considered options and decision outcome.
03. Step 2: Compare the options (March 2026)
First compare the options, with the method from lesson 2. In March the shop has two consumers of order events, Inventory and Email, a peak of 30 orders per minute, and a team of four that has never run a message broker. Checkout calls both consumers over HTTP before it answers, so when Email was down for 40 minutes, checkouts failed. The team scores four options from 1 to 5 (higher is better) on five weighted drivers:
- no-loss: events survive a consumer outage;
- infra: little new infrastructure to run;
- skills: the team already knows how to operate it;
- headroom: room to grow without slowing checkout or loading the orders database;
- replay: consumers can re-read past events.
The file also holds the scores from a second review in November, which you will use in step 5. Save it as tools/score.py, then run it for March.
"""Weighted options for delivering order events, as scored in two reviews."""
import sys
OPTIONS = ["A sync HTTP calls", "B outbox table, polled",
"C RabbitMQ queues", "D Kafka topic"]
DRIVERS = ["no-loss", "infra", "skills", "headroom", "replay"]
# Weights 1-5 per driver; scores 1-5 per option (higher is better).
REVIEWS = {
"2026-03": {"weights": [5, 4, 3, 2, 1],
"scores": [[1, 5, 5, 2, 1], [4, 5, 4, 2, 3],
[4, 2, 2, 4, 1], [4, 1, 1, 5, 5]]},
# November: weights headroom 2->4 (7 consumers), replay 1->5 (Analytics needs
# 30 days). Changed scores: A headroom 2->1 (7 HTTP calls per checkout);
# B headroom 2->1 (polling uses 20% of DB CPU), replay 3->2 (rows kept 14 days);
# D infra 1->4, skills 1->3 (Platform team runs the cluster, coaches teams).
"2026-11": {"weights": [5, 4, 3, 4, 5],
"scores": [[1, 5, 5, 1, 1], [4, 5, 4, 1, 2],
[4, 2, 2, 4, 1], [4, 4, 3, 5, 5]]},
}
review = REVIEWS[sys.argv[1]]
weights = review["weights"]
print("weights: " + ", ".join(f"{d} {w}" for d, w in zip(DRIVERS, weights)))
best = 5 * sum(weights)
totals = [(sum(w * s for w, s in zip(weights, row)), name)
for name, row in zip(OPTIONS, review["scores"])]
for total, name in sorted(totals, reverse=True):
print(f" {name:<24}{total:>3} / {best}")python3 tools/score.py 2026-03weights: no-loss 5, infra 4, skills 3, headroom 2, replay 1
B outbox table, polled 59 / 75
A sync HTTP calls 45 / 75
C RabbitMQ queues 43 / 75
D Kafka topic 42 / 75The polled outbox table (B) wins clearly, 14 points ahead of doing nothing. The brokers lose on infrastructure and skills, weighted highly for a team of four with no broker experience, and replay has weight 1 because no consumer needs it yet. These weights describe Parcelpoint in March 2026, not Kafka or RabbitMQ in general.
04. Step 3: Write the first two records
Save the two records below in docs/decisions. ADR-0001 adopts MADR itself, a common first record. ADR-0002 is the messaging decision. Its consequences state at-least-once delivery and the need for duplicate checks instead of promising exactly-once delivery, and they admit what the choice costs. More Information ends with the revisit triggers: the conditions under which the team will look at the decision again. Save every file with a final newline, or step 8 will show two extra lines.
---
status: "accepted"
date: 2026-03-10
decision-makers: Orders team
---
# Record architecture decisions with MADR 4.0.0
## Context and Problem Statement
Decisions about the order platform live in chat threads and meeting notes, so new
team members cannot tell which choices still hold, or why they were made.
## Considered Options
* MADR 4.0.0 files in docs/decisions, reviewed in pull requests
* Michael Nygard's five-part format in the same folder
* Pages in the company wiki
## Decision Outcome
Chosen option: "MADR 4.0.0 files in docs/decisions", because the template asks for
drivers and options, and the files are versioned and reviewed with the code.---
status: "accepted"
date: 2026-03-10
decision-makers: Orders team
consulted: Inventory team, Email team
informed: Customer support
---
# Deliver order events through a polled outbox table
## Context and Problem Statement
Checkout calls Inventory and Email over HTTP before it answers the customer. When
Email was down for 40 minutes in February, about 1,200 checkouts failed. How should
Orders hand events to other services, so that a slow or failed consumer does not
fail checkout and no event is lost?
## Decision Drivers
* no-loss (weight 5): events survive a consumer outage of up to one day
* infra (4): a team of four already runs one PostgreSQL cluster on call
* skills (3): nobody in the team has operated a message broker
* headroom (2): peak load is 30 orders per minute
* replay (1): no consumer needs past events today
## Considered Options
* A: keep the synchronous HTTP calls (do nothing)
* B: outbox table in the orders database, polled by each consumer
* C: one RabbitMQ queue per consumer, fed from the outbox
* D: one Kafka topic, fed from the outbox
## Decision Outcome
Chosen option: "B: outbox table, polled", because it scores 59 of 75, against 45
for doing nothing and 43 or less for a broker (tools/score.py 2026-03). It removes
the coupling between checkout and consumer outages without new infrastructure.
### Consequences
* Good, because checkout writes the order and its event in one transaction.
* Good, because a consumer that was down reads what it missed from its position.
* Bad, because delivery is at least once: consumers must skip duplicate event ids.
* Bad, because every poll adds read load to the orders database.
* Bad, because rows are deleted after 14 days, so older events cannot be replayed.
### Confirmation
An integration test stops the Email consumer, places 50 orders, restarts it, and
checks that each order produced one email, with duplicates dropped by event id.
## More Information
Revisit this decision when more than four consumers read the table, when a consumer
needs more than 14 days of history, or when polling uses over 10% of database CPU
at peak.ls docs/decisions0001-record-architecture-decisions-with-madr.md
0002-deliver-order-events-through-a-polled-outbox.md
adr-template.md05. Step 4: Add the checker and a pre-commit hook
The checker reads every file in docs/decisions whose name starts with a digit. It takes status and date from the front matter and the title from the first line that starts with # , and it applies three rules:
- every record has a date and a known status;
- a record with status
superseded by ADR-NNNNnames a successor that exists, and contains a Markdown link to that successor's file; - when a record has a line starting
Supersedes ADR-NNNN, the older record's status must name it as the successor.
It prints the log, then any problems, and exits with code 1 if it found a problem. Save it as tools/adrlog.py.
"""List the decision log in docs/decisions and check its status links.
Exit code 0 when the log is consistent, 1 when any problem is found.
"""
import re
import sys
from pathlib import Path
LOG = Path("docs/decisions")
NAME = re.compile(r"^(\d{4})-[a-z0-9-]+\.md$")
PLAIN = {"proposed", "accepted", "rejected", "deprecated"}
SUPERSEDED_BY = re.compile(r"^superseded by ADR-(\d{4})$")
SUPERSEDES = re.compile(r"^Supersedes ADR-(\d{4})\b", re.MULTILINE)
def parse(path: Path) -> dict:
text = path.read_text(encoding="utf-8")
meta, body = {}, text
if text.startswith("---\n") and "\n---\n" in text[4:]:
header, body = text[4:].split("\n---\n", 1)
for line in header.splitlines():
key, _, value = line.partition(":")
meta[key.strip()] = value.strip().strip('"')
title = next((ln[2:] for ln in body.splitlines() if ln.startswith("# ")), "?")
return {"file": path.name, "status": meta.get("status", ""),
"date": meta.get("date", ""), "title": title, "body": body}
def check(records: dict[str, dict]) -> list[str]:
problems = []
for num, rec in records.items():
if not rec["date"]:
problems.append(f"ADR-{num}: no date in the front matter")
succ = SUPERSEDED_BY.match(rec["status"])
if succ:
new = records.get(succ[1])
if new is None:
problems.append(f"ADR-{num}: successor ADR-{succ[1]} does not exist")
elif f"]({new['file']})" not in rec["body"]:
problems.append(f"ADR-{num}: no link to its successor {new['file']}")
elif rec["status"] not in PLAIN:
problems.append(f"ADR-{num}: unknown status '{rec['status']}'")
for old in SUPERSEDES.findall(rec["body"]):
target, want = records.get(old), f"superseded by ADR-{num}"
if target is None:
problems.append(f"ADR-{num}: supersedes missing ADR-{old}")
elif target["status"] != want:
problems.append(f"ADR-{old}: status is '{target['status']}', "
f"expected '{want}'")
return problems
def main() -> int:
records, problems = {}, []
for path in sorted(LOG.glob("[0-9]*.md")):
match = NAME.match(path.name)
if not match:
problems.append(f"{path.name}: name is not NNNN-lowercase-title.md")
elif match[1] in records:
problems.append(f"{path.name}: number {match[1]} is already used")
else:
records[match[1]] = parse(path)
problems += check(records)
if "--quiet" not in sys.argv:
for num, rec in records.items():
print(f"{num} {rec['status']:<24}{rec['title']}")
for problem in problems:
print(f"problem: {problem}")
verdict = "FAIL" if problems else "OK"
plural = "" if len(problems) == 1 else "s"
print(f"{verdict}: {len(records)} records, {len(problems)} problem{plural}")
return 1 if problems else 0
if __name__ == "__main__":
sys.exit(main())Run it, install it as a pre-commit hook, and commit. Git runs .git/hooks/pre-commit before each commit and aborts the commit if the hook exits with a non-zero code. The hook copies the staged files, which are what the commit will contain, into a temporary folder and runs the checker there, so an unstaged fix cannot hide a broken log. The export line fixes the commit dates to match the story and the expected output.
python3 tools/adrlog.py
cat > .git/hooks/pre-commit <<'EOF'
#!/bin/sh
# Check the staged snapshot (what this commit will contain), not the working tree.
root=$(git rev-parse --show-toplevel)
tmp=$(mktemp -d) || exit 1
git checkout-index -a --prefix="$tmp/"
(cd "$tmp" && python3 "$root/tools/adrlog.py" --quiet)
status=$?
rm -rf "$tmp"
exit $status
EOF
chmod +x .git/hooks/pre-commit
export GIT_AUTHOR_DATE="2026-03-10T10:00:00Z" GIT_COMMITTER_DATE="2026-03-10T10:00:00Z"
git add . && git commit -q -m "ADR-0001, ADR-0002: adopt MADR, polled outbox"0001 accepted Record architecture decisions with MADR 4.0.0
0002 accepted Deliver order events through a polled outbox table
OK: 2 records, 0 problems
OK: 2 records, 0 problemsThe second OK comes from the hook, which runs the checker with --quiet during the commit.
06. Step 5: Eight months later, compare again
In June the team turned down a proposal for a GraphQL gateway. That record goes into the log too, as rejected, so the next person who suggests a gateway can read why. Save it. The commands run the November comparison, then commit ADR-0003 with its June date.
---
status: "rejected"
date: 2026-06-02
decision-makers: Orders team, Storefront team
---
# Put a GraphQL gateway in front of the storefront APIs
## Context and Problem Statement
The Storefront team asked for one GraphQL endpoint instead of three REST APIs,
because the product page makes three calls before it can render.
## Considered Options
* A GraphQL gateway owned by the Orders team
* Keep the REST APIs and add one aggregated endpoint for the product page
## Decision Outcome
The gateway is rejected. Only one screen needs aggregated data, and a gateway would
add a new runtime and open questions about who owns the schema. We add one
aggregated REST endpoint instead. Revisit if a second client needs flexible queries.python3 tools/score.py 2026-11
export GIT_AUTHOR_DATE="2026-06-02T10:00:00Z" GIT_COMMITTER_DATE="2026-06-02T10:00:00Z"
git add docs/decisions && git commit -q -m "ADR-0003: reject the GraphQL gateway"weights: no-loss 5, infra 4, skills 3, headroom 4, replay 5
D Kafka topic 90 / 105
B outbox table, polled 66 / 105
C RabbitMQ queues 55 / 105
A sync HTTP calls 49 / 105
OK: 3 records, 0 problemsAll three of ADR-0002's revisit triggers have fired: seven consumers poll the table, polling takes about 20% of the database's CPU at peak, and Analytics needs 30 days of history. Two weights rise for those reasons: headroom from 2 to 4 and replay from 1 to 5. Five scores change, each explained in score.py: A and B lose a headroom point (seven HTTP calls per checkout; the polling load), B loses a replay point (rows are kept 14 days, not 30), and Kafka gains on infra and skills because a Platform team now runs a cluster and coaches new users. Kafka scores 90 of 105, the current design 66. Kafka itself did not change: its context did, which is the usual reason to supersede a decision.
07. Step 6: Write the new record and try to commit it
Save ADR-0004. Its More Information section starts with Supersedes ADR-0002, the back link the checker looks for. Its consequences avoid two common overstatements about Kafka: the topic keeps events for its configured retention period (30 days here), not forever, and delivery to consumers is still at least once. Then try to commit it alone.
---
status: "accepted"
date: 2026-11-12
decision-makers: Orders team, Platform team
consulted: Inventory, Email, Analytics and Fraud teams
informed: Customer support
---
# Publish order events to a Kafka topic through the outbox
## Context and Problem Statement
ADR-0002 hit its revisit triggers: seven consumers now poll the outbox table, the
polling takes about 20% of database CPU at peak, and Analytics needs 30 days of
order events to rebuild its reports. The Platform team now runs a Kafka cluster
for two other products and coaches teams that start using it, which raises
Kafka's infra and skills scores. How should order events reach consumers now?
## Decision Drivers
* no-loss (weight 5), infra (4) and skills (3): unchanged from ADR-0002
* replay (5, was 1): Analytics must re-read 30 days of events
* headroom (4, was 2): seven consumers must not slow checkout or load the database
## Considered Options
* A: go back to synchronous HTTP calls
* B: keep the polled outbox table (do nothing)
* C: one RabbitMQ queue per consumer, fed from the outbox
* D: Kafka topic orders.events, fed from the outbox by a relay
## Decision Outcome
Chosen option: "D: Kafka topic", because it scores 90 of 105, against 66 for
keeping the polled table and 55 for RabbitMQ (tools/score.py 2026-11).
### Consequences
* Good, because consumers read from the broker, not from the orders database.
* Good, because the topic keeps 30 days of events (retention.ms, no size limit),
so consumers can replay that window. Older events are deleted unless archived.
* Bad, because the relay and the consumers still deliver at least once, so every
consumer keeps its duplicate check on event ids.
* Bad, because Orders now depends on the Platform team's cluster and upgrades.
### Confirmation
The ADR-0002 integration test runs against the topic, and a replay test rebuilds
the Analytics report from the start of the retention window in staging.
## More Information
Supersedes ADR-0002. The outbox table stays as the source that the relay reads;
polling consumers move to the topic one at a time. Revisit if a consumer needs
more than 30 days of history or the topic needs more than 12 partitions.export GIT_AUTHOR_DATE="2026-11-12T10:00:00Z" GIT_COMMITTER_DATE="2026-11-12T10:00:00Z"
git add docs/decisions
git commit -q -m "ADR-0004: publish order events to Kafka"; echo "commit exit code: $?"problem: ADR-0002: status is 'accepted', expected 'superseded by ADR-0004'
FAIL: 4 records, 1 problem
commit exit code: 1The hook blocked the commit, because the log would have shown two contradictory decisions as accepted at the same time. The new record and the change to the old one belong in one commit and one pull request.
08. Step 7: Supersede ADR-0002
Change the status of ADR-0002, then run the checker. The sed -i.bak form works with both GNU and BSD sed; you can also make the change in an editor.
sed -i.bak 's/^status: "accepted"/status: "superseded by ADR-0004"/' \
docs/decisions/0002-deliver-order-events-through-a-polled-outbox.md
rm docs/decisions/*.bak
python3 tools/adrlog.py0001 accepted Record architecture decisions with MADR 4.0.0
0002 superseded by ADR-0004 Deliver order events through a polled outbox table
0003 rejected Put a GraphQL gateway in front of the storefront APIs
0004 accepted Publish order events to a Kafka topic through the outbox
problem: ADR-0002: no link to its successor 0004-publish-order-events-to-kafka.md
FAIL: 4 records, 1 problemThe status now names the successor, but someone reading ADR-0002 has nothing to click. MADR 4.0.0 keeps only the identifier in the status, so add the link as a line of text. Then check again and try to commit. That commit fails although the checker on disk says OK: step 6 staged only ADR-0004, and the hook checks what the commit would contain. Stage the change and commit again.
cat >> docs/decisions/0002-deliver-order-events-through-a-polled-outbox.md <<'EOF'
Superseded by [ADR-0004](0004-publish-order-events-to-kafka.md) on 2026-11-12.
EOF
python3 tools/adrlog.py
export GIT_AUTHOR_DATE="2026-11-12T10:00:00Z" GIT_COMMITTER_DATE="2026-11-12T10:00:00Z"
git commit -q -m "ADR-0004: publish order events to Kafka"; echo "commit exit code: $?"
git add docs/decisions && git commit -q -m "ADR-0004: publish order events to Kafka"0001 accepted Record architecture decisions with MADR 4.0.0
0002 superseded by ADR-0004 Deliver order events through a polled outbox table
0003 rejected Put a GraphQL gateway in front of the storefront APIs
0004 accepted Publish order events to a Kafka topic through the outbox
OK: 4 records, 0 problems
problem: ADR-0002: status is 'accepted', expected 'superseded by ADR-0004'
FAIL: 4 records, 1 problem
commit exit code: 1
OK: 4 records, 0 problems09. Step 8: Read the history
Git now holds the whole story. The three commands show all commits, the commits that touched ADR-0002, and the lines of ADR-0002 that changed when it was superseded.
git log --format='%as %s'
git log --format='%as %s' -- docs/decisions/0002-*.md
git show --format= -U0 HEAD -- docs/decisions/0002-*.md | grep '^[-+][^-+]'2026-11-12 ADR-0004: publish order events to Kafka
2026-06-02 ADR-0003: reject the GraphQL gateway
2026-03-10 ADR-0001, ADR-0002: adopt MADR, polled outbox
2026-11-12 ADR-0004: publish order events to Kafka
2026-03-10 ADR-0001, ADR-0002: adopt MADR, polled outbox
-status: "accepted"
+status: "superseded by ADR-0004"
+Superseded by [ADR-0004](0004-publish-order-events-to-kafka.md) on 2026-11-12.Only the status changed and one line was added: a reader in 2028 can still see why a polled table was right in March, and why it stopped being right.
10. Troubleshooting
11. Check your understanding
12. Apply it
Take the lab towards the practice project for this skill:
- Write ADR-0005 for a decision that is later dropped with no replacement, mark it
deprecated, and extend the checker to require a line that gives the date and reason. - Make the checker also report gaps and duplicates in the numbering, and decide with your team whether a gap is acceptable. Nygard's rule only forbids reusing a number.
- Run the checker in CI as well as in the hook. Hooks are local, and
git commit --no-verifyskips them, while CI checks every pull request.
13. Review prompt
Without looking back: describe the two changes that supersede a record and why they belong in one commit. Name the three rules the checker enforces. Explain why the messaging decision changed between March and November even though the technologies did not, and say which two overstatements about Kafka the new record avoids.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.