Skip to content

fix(adr): resolve three dangling cross-ADR anchors, and teach the guard to catch them - #1460

Merged
thiras merged 2 commits into
mainfrom
claude/github-issue-1455-79tpbs
Jul 26, 2026
Merged

thiras merged 2 commits into
mainfrom
claude/github-issue-1455-79tpbs

Conversation

@altanoruc

@altanoruc altanoruc commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Both parts of #1455: correct the anchors, then make the class of drift catchable.

Part 1 — the broken links

Three, not two. The third was outside #1455's list because the ad-hoc resolver used there skipped link targets that do not exist on disk — which is exactly this case.

Location Was Now
adr/008-reputation.md:14 003-payments.md#adr-003-payments #adr-003-payment-model
adr/008-reputation.md:115 028-slashing-appeals.md#adr-028-slashing-appeals #adr-028-slashing-appeals-and-dispute-escalation
adr/011-content-takedown.md:585 013-wire-format.md#application-error-codes 013-schema-evolution.md#application-error-codes

The third is a renamed file, not just a retitled heading: ADR 013 became 013-schema-evolution.md and this link kept the old name. It reads as working for the same reason as the other two — GitHub ignores a fragment it cannot resolve — with the extra wrinkle that the file is gone too, so it 404s rather than landing on the wrong page.

Part 2 — check-anchor-targets

A sibling guard rather than an extension of check-md-anchors: the existing target's contract ("carries an anchor") is still worth stating on its own, and the CI job keeps one step per guard so a failure names the rule it broke.

It builds a heading-slug index per target file and asserts every file.md#anchor — and every same-file #anchor — names one of them. Wired into check-refs, so the existing CI job and pre-commit hook pick it up; both path filters extended to _build/*.awk so editing the guard re-runs it.

Red/green on a clean tree. Retitling ADR 003's H1 to # ADR 003: Payments and Settlement:

$ make -C adr check-anchor-targets
architecture.md:79: 003-payments.md#adr-003-payment-model -> no heading in 003-payments.md slugs to #adr-003-payment-model
005-protocol.md:55: 003-payments.md#adr-003-payment-model -> no heading in ...
008-reputation.md:14: ...
   … 21 links in total

$ make -C adr check-md-anchors        # same tree, unchanged guard
all ADR cross-links carry a #anchor

That is the failure mode the anchor rule exists to prevent, before and after.

On the two constraints flagged in the issue

Basic tools only. Pure awk, no perl/python. The resolver needs a per-file heading index, so it is one awk program over the whole set rather than a per-file grep like its siblings — which is why it lives in adr/_build/check-anchor-targets.awk rather than as ~35 continuation lines in a recipe, the same reason the lua filters live there.

GitHub's slug algorithm exactly, not an approximation. Lowercase, drop every character that is not a letter/digit/underscore/space/hyphen, spaces to hyphens — plus -1/-2 suffixes for repeated heading text, and inline links in a heading reduced to their rendered text (## Relationship to [ADR 002](…) slugs from Relationship to ADR 002, not from the URL). The double-hyphen artifact the tree already depends on falls out of this rather than being special-cased: a stripped character leaves its surrounding spaces behind, so ## Tier 1 — Minor (no coordination) → #tier-1--minor-no-coordination and ### `cdn/probe/v1` — latency probe → #cdnprobev1--latency-probe.

Verified rather than asserted: all 850 headings in the ADR set slug identically to [email protected], the library GitHub itself uses. Any systematic drift in the implementation would have surfaced as false positives on the ~1750 hand-authored links that currently resolve.

LC_ALL=C keeps the character class byte-oriented so multibyte punctuation (—, →, §) is stripped the same way under every awk. mawk 1.3.4 (CI) and gawk agree exactly; the program is POSIX awk throughout, so BSD awk on macOS is covered too.

Scope

  • Skipped, matching the sibling guards: fenced code blocks, on both the link and the heading side. That is 4 links, all inside Solidity/Rust comment bodies where GitHub renders no link at all.
  • Skipped: non-.md targets — 2 URLs with fragments (rfc8446#section-8, an OpenZeppelin API anchor).
  • Reported: a link naming a file that does not exist, which is how the ADR 013 rename surfaced.
  • README.md is scanned here though it is not in SRCS_REF — it links into the ADRs and out to CONTRIBUTING.md with anchors that rot identically, while not following the ADR prose conventions the other guards police. Commented at the ANCHOR_SRCS definition.

Every skip is accounted for: 1756 anchor-bearing links in the set, minus 4 in fences, minus 2 URLs = 1750 checked.

Verification

  • make -C adr check-refs check-book-list — all four guards + book list green
  • Red/green as shown above, and the three fixed links verified red before the fix
  • Slug parity against [email protected] across all 850 headings — identical
  • mawk / gawk parity — identical output
  • markdownlint-cli2 --config .markdownlint.yaml on both changed ADRs — 0 issues
  • .github/workflows/ci.yml and .pre-commit-config.yaml parse; the widened hook regex verified against the paths it must and must not match

Not run: the pandoc/typst PDF builds (unchanged recipes, and the ADR CI job does not build them), and the Rust/Solidity suites (no crates/** or contracts/** change).

Note for reviewers

The guard is strict about anchors that already exist in the tree, so an open docs PR that removes or retitles a heading will now fail this check instead of leaving a silent dangling link. Two in flight that touch anchor-bearing headings: #1447 (ADR 013 condensation — 013-schema-evolution.md#application-error-codes is a link target as of main) and #1456, which independently notes this same guard gap for #minimum-reputation-rejection-floor. That is the guard working as intended, but it is a rebase cost worth knowing about.

Closes #1455

🤖 Generated with Claude Code

https://claude.ai/code/session_016qu8rLCARqtS4fbwsnoTRE


Generated by Claude Code

Summary by CodeRabbit

  • Documentation

    • Clarified ADR guidance on reputation, persistent faults, and content takedowns.
    • Updated cross-references for payment, slashing, and stream error documentation.
  • Quality Improvements

    • Added automated validation for Markdown anchor links across ADRs and the README.
    • Expanded reference checks to cover generated ADR files and anchor targets.
    • Integrated the new validation into continuous integration and pre-commit checks.

@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.92% (2615/2908 lines)
▲ +0.00pp vs base (89.92% → 89.92%)
Run: 30203307234

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: b3546094-ea4d-4ca2-b6b6-5fdb2b536a14

📥 Commits

Reviewing files that changed from the base of the PR and between 4271c79 and 1df22e7.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • .pre-commit-config.yaml
  • adr/008-reputation.md
  • adr/011-content-takedown.md
  • adr/Makefile
  • adr/_build/check-anchor-targets.awk

Walkthrough

The PR adds Markdown anchor-target validation for ADR references, integrates it into the ADR Makefile, pre-commit hook, and CI workflow, and updates several ADR cross-references and explanations.

Changes

ADR anchor validation

Layer / File(s) Summary
Anchor validation implementation
adr/_build/check-anchor-targets.awk
Indexes GitHub-style Markdown heading slugs and validates same-file and cross-file fragment links.
Make target integration
adr/Makefile
Adds check-anchor-targets, includes README.md in scanned sources, and wires the check into check-refs.
Hook and CI enforcement
.pre-commit-config.yaml, .github/workflows/ci.yml
Runs the check for generated AWK changes and adds it to the ADR book-check job.
ADR reference corrections
adr/008-reputation.md, adr/011-content-takedown.md
Updates ADR anchors and corrects the ADR 013 cross-reference.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant Makefile
  participant AnchorValidator
  participant ADRSources
  CI->>Makefile: run check-anchor-targets
  Makefile->>AnchorValidator: scan ADRSources
  AnchorValidator->>ADRSources: index headings and fragment links
  ADRSources-->>AnchorValidator: Markdown headings and links
  AnchorValidator-->>CI: pass or report invalid targets
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.01% (was 81.07%, ▼ 0.06%) — 52384/64660 lines

No Rust files changed in this PR.

History
Commit Total Δ vs base
4d544b2 81.13% ▲ +0.06%
b041248 81.07% ● 0.00%
1df22e7 (HEAD) 81.01% ▼ 0.06%

@thiras
thiras force-pushed the claude/github-issue-1455-79tpbs branch from 4d544b2 to b041248 Compare July 26, 2026 12:04
claude added 2 commits July 26, 2026 16:03
All three land on the right file in a browser — GitHub ignores a fragment
it cannot resolve and renders the top of the page — so they read as working
links. `check-md-anchors` verifies a cross-ADR link *carries* an anchor,
never that the anchor *resolves*, so none of them were catchable.

- 008-reputation.md:14  `003-payments.md#adr-003-payments`
  -> `#adr-003-payment-model` (H1 is "ADR 003: Payment Model")
- 008-reputation.md:115 `028-slashing-appeals.md#adr-028-slashing-appeals`
  -> `#adr-028-slashing-appeals-and-dispute-escalation`
- 011-content-takedown.md:585 `013-wire-format.md#application-error-codes`
  -> `013-schema-evolution.md#...`; ADR 013 was renamed and this link kept
  the old filename, so the *file* is gone, not just the heading.

The third was not in #1455's list: the resolver used there skipped link
targets that do not exist on disk, which is exactly this case.

Refs #1455

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qu8rLCARqtS4fbwsnoTRE
…ading

`check-md-anchors` requires a cross-ADR link to carry a #anchor so that a
retitled ADR breaks the link visibly. It only greps for links that have *no*
anchor, so any fragment passes, resolving or not — the drift the rule exists
to catch is the one thing it lets through.

The new sibling guard builds a heading-slug index per target file and asserts
every `file.md#anchor` (and same-file `#anchor`) names one of them. Retitling
ADR 003's H1 on a clean tree now lists all 21 links that named the old
anchor; `check-md-anchors` still reports "all ADR cross-links carry a
#anchor" on that same tree.

The resolver needs a per-file heading index, so it is one awk program over
the whole set rather than a per-file grep like its siblings, and lives in
_build/ for the same reason the lua filters do. Still basic tools only —
awk, no perl/python — per the guards' standing constraint.

Slugs follow GitHub's algorithm exactly, not an approximation: lowercase,
drop every character that is not a letter/digit/underscore/space/hyphen,
spaces to hyphens, with `-1`/`-2` suffixes for repeated headings and inline
links in a heading reduced to their rendered text. The tree already depends
on the double-hyphen a stripped character leaves behind
(`#tier-1--minor-no-coordination`, `#cdnprobev1--latency-probe`), so an
approximation would flag correct links. Verified: all 850 headings in the
ADR set slug identically to [email protected], the library GitHub uses.
LC_ALL=C keeps the character class byte-oriented so multibyte punctuation
is stripped the same way under every awk; mawk and gawk agree exactly.

Scope: fenced code blocks are skipped on both the link and heading side, as
the sibling guards do, and non-.md targets (URLs, assets) are left alone. A
link naming a file that does not exist is reported too. README.md is scanned
here though it is not in SRCS_REF — it links into the ADRs and out to
CONTRIBUTING.md with anchors that rot identically, while not following the
ADR prose conventions the other guards police.

Wired into `check-refs`, so the existing CI job and pre-commit hook pick it
up; both path filters extended to _build/*.awk so editing the guard re-runs
it.

Closes #1455

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qu8rLCARqtS4fbwsnoTRE
@thiras
thiras force-pushed the claude/github-issue-1455-79tpbs branch from b041248 to 1df22e7 Compare July 26, 2026 13:04
@thiras
thiras merged commit 345b16f into main Jul 26, 2026
24 checks passed
@thiras
thiras deleted the claude/github-issue-1455-79tpbs branch July 26, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(adr): two unresolved cross-ADR anchors in ADR 008, and check-md-anchors can't catch them

3 participants