Skip to content

docs(adr): anchor all cross-ADR links + enforce reference hygiene - #600

Merged
alpergundogdu merged 4 commits into
mainfrom
claude/jolly-kilby-7df787
May 19, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
claude/jolly-kilby-7df787

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #599. Closes the gap where cross-ADR links could rot silently.

  • Anchored every cross-ADR link to the target H1. 808 anchorless
    […](NNN-foo.md) links across 37 files now carry the file's H1 anchor
    (…NNN-foo.md#adr-nnn-title). A retitled/renamed ADR now breaks the
    link, so drift is caught instead of silently pointing at the wrong file.
    Slugs computed with the GitHub algorithm, verified 38/38 against
    pandoc gfm_auto_identifiers
    (the PDF renderer). Ugly-but-correct
    slugs (em-dash → --) kept as-is — nobody reads raw markdown.
  • Three Make guards (adr/Makefile, awk/sed/grep only — no perl/python):
    • check-bare-refs — every ADR NNN mention (with or without
      § Section) must be a markdown link, not bare prose/table text.
    • check-md-anchors — every cross-ADR *.md link must carry a #anchor.
    • check-section-spacing — §3 for numbers, § Word for names
      (locks in docs(adr): link bare ADR cross-references; normalize § spacing #599's § normalization).
    • check-refs — runs all three.
  • Enforced in CI and pre-commit. Guards run as separate steps in the
    ADR book-check job (job id unchanged) and via a new adr-ref-hygiene
    pre-commit hook mirroring the existing adr-book-list one.

Fenced code, ATX headings, inline code, and existing links are excluded
(references there either can't be links or already are).

Test plan

  • make -C adr check-refs → all three green
  • make -C adr check-book-list → still green (unaffected)
  • 38/38 H1 slugs match pandoc gfm_auto_identifiers; 0 unresolved anchors
  • markdownlint-cli2 on adr/*.md → 0 errors (MD013/MD051 off)
  • git diff --check clean; pre-commit hooks pass on both commits
  • CI ADR book check job green on this PR

alpergundogdu and others added 3 commits May 19, 2026 15:56
Every anchorless cross-ADR *.md link now carries its target file's H1
heading anchor (e.g. 016-contract-interactions.md ->
016-contract-interactions.md#smart-contract-interaction-model). 808
links across 37 files; slugs computed with the GitHub algorithm and
verified 38/38 against pandoc gfm_auto_identifiers (the PDF renderer).
A retitled/renamed ADR now breaks the link, so drift is caught instead
of silently pointing at the wrong file.

Adds adr/Makefile guards (awk/sed/grep only, no perl/python):
- check-bare-refs: every ADR mention (with OR without § Section) must
  be a markdown link, not bare prose/table text (was § only).
- check-md-anchors: every cross-ADR *.md link must carry a #anchor.
- check-section-spacing: §3 for numbers, § Word for names (locks in
  the #599 § normalization).
- check-refs: runs all three.

A new adr-ref-hygiene pre-commit hook mirrors them (same files: scope
as the existing adr-book-list hook). Fenced code, ATX headings, inline
code, and existing links are excluded; ugly but correct slugs
(em-dash -> --) are kept as-is.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds check-bare-refs, check-md-anchors, check-section-spacing as
separate steps in the adr-book-list job (renamed display "ADR book
check"; job id unchanged so ci-success needs/allowed-skips stay valid).
Separate steps so a failure points at the specific guard in the UI.
Still pure shell (awk/sed/grep), sub-second, gated on adr/** changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…f787

# Conflicts:
#	adr/001-network.md
#	adr/003-payments.md
#	adr/005-protocol.md
#	adr/008-reputation.md
#	adr/009-governance.md
#	adr/011-content-takedown.md
#	adr/014-on-chain-verification.md
#	adr/016-contract-interactions.md
#	adr/018-liquidity-strategy.md
#	adr/019-node-onboarding.md
#	adr/026-tokenomics.md
#	adr/028-slashing-appeals.md
#	adr/030-node-region-self-attestation.md
#	adr/032-safety-reserve-appeals-contract.md
#	adr/033-safety-insurance-reserve.md
#	adr/appendix-fraud-detection.md
#	adr/appendix-l2-deployment.md
#	adr/appendix-observability.md
#	adr/appendix-operator-key-rotation.md
#	adr/appendix-operator-upgrade-path.md
#	adr/architecture.md
#	adr/glossary.md

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new reference-hygiene checks in the Makefile and updates numerous cross-references across the ADR documentation to include specific section anchors. The reviewer provided actionable feedback to improve the regex for bare reference detection by including headings and offered guidance on maintaining stable Markdown anchor links in accordance with GitHub Flavored Markdown conventions.

Comment thread adr/Makefile
@bad=""; for f in $(SRCS_REF); do \
hits=$$(awk -v F="$$f" '/^```/{c=!c;next} c{next} /^#{1,6} /{next} {print F":"FNR": "$$0}' "$$f" \
| sed -e 's/`[^`]*`//g' -e 's/\[[^]]*\]([^)]*)//g' \
| grep -E '(^|[^[*])ADR ?[0-9]{1,3}' || true); \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex (^|[^[*])ADR used in check-bare-refs has gaps that prevent it from catching certain bare references. Specifically, it excludes matches where the preceding character is [ or *. This means bare references in brackets (e.g., [ADR 001]) or emphasized text (e.g., *ADR 001*) will be missed. Since the preceding sed command already removes valid inline links, using a word-boundary check is more robust and correctly identifies these cases as bare references.

	    | grep -E '\\bADR ?[0-9]{1,3}\\b' || true); \

Comment thread adr/Makefile Outdated

check-bare-refs:
@bad=""; for f in $(SRCS_REF); do \
hits=$$(awk -v F="$$f" '/^```/{c=!c;next} c{next} /^#{1,6} /{next} {print F":"FNR": "$$0}' "$$f" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check-bare-refs target currently skips ATX headings (/^#{1,6} /{next}). This allows bare ADR references to persist in section titles (e.g., ## Relationship to ADR 001). To maintain high reference hygiene throughout the documentation, headings should also be checked to ensure all ADR mentions are properly linked.

Comment thread adr/001-network.md
Comment on lines +101 to +102
2. **DHT FIND_VALUE.** Issue an iterative O(log N) `FindValueRequest` for H via `cdn/dht/v1` (see [ADR 022 §1.6](022-content-discovery.md#adr-022--content-discovery-at-scale)). Returns a `Vec<NodeId>` of known holders. The DHT bootstraps from `StakingRegistry.getActiveNodes()` — a node's first peers come from the on-chain registry and immediately participate in DHT lookups, so there is no separate bootstrap window.
3. **Probe the DHT candidate set.** Send `ProbeRequest {hash, timestamp_us}` in parallel to the NodeIds returned by the DHT. ALPN: `cdn/probe/v1` — `ProbeResponse {has_blob, rate_per_mb, timestamp_us, total_bytes?, slash_sig}`. If DHT returned no providers, fall back to the on-chain origin directory ([ADR 022 § Origin discovery](022-content-discovery.md#adr-022--content-discovery-at-scale)): resolve namespaces via `PublisherRegistry.namespaceOf(hash)` and union the operator-address sets via `OriginAssignment.getOrigins(namespaceId)` for each, then probe those NodeIds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Several links that refer to specific sections (e.g., §1.6 or § Origin discovery) have been updated to point to the target file's H1 anchor. While this satisfies the requirement for links to have anchors, it reduces the utility of the documentation by losing deep link specificity. Where the link text refers to a specific section, the link should use that section's anchor. Ensure these anchors follow GitHub Flavored Markdown (GFM) conventions: convert headers to lowercase, replace spaces with hyphens, and include numbers for numbered headings (e.g., #16-section-name for '1.6 Section Name'). Additionally, simplify target headings by removing backticks or mathematical symbols, and be aware that special characters like '+' or em-dashes are removed, which may result in double hyphens for sequences like ' + '.

References
  1. When creating Markdown anchor links for headings that include numbering, the slug must include the number and follow GitHub Flavored Markdown (GFM) conventions (e.g., use 'Add devcontainer for secure Claude Code sessions #1-section-name' for a heading titled '### 1. Section Name') to ensure link stability.
  2. When referencing ADR sections via Markdown links, use stable GitHub Flavored Markdown (GFM) anchor slugs and simplify the target headings (e.g., by removing backticks or mathematical symbols) to ensure link stability across different renderers.
  3. Verify that internal Markdown links use correct GitHub Flavored Markdown (GFM) anchor slugs, which are typically generated by converting headers to lowercase and replacing spaces with hyphens (e.g., '### HeaderName' becomes '#headername').
  4. When extracting historical content from documents, verify that section headings and their corresponding anchors are up-to-date, as they may have been renamed since the original draft.
  5. When referencing ADRs, ensure that anchor links are correctly formatted, especially when special characters like '+' or em-dashes ('—') are present. GFM slug generation replaces whitespace with hyphens and removes special characters, potentially leading to double hyphens.

@github-actions

github-actions Bot commented May 19, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 89.68% (was 89.68%, ● 0.00%) — 16110/17964 lines

No Rust files changed in this PR.

History
Commit Total Δ vs base
5618aeb 89.68% ▲ +0.01%
8a75bcd (HEAD) 89.68% ● 0.00%

check-bare-refs skipped ALL ATX headings, letting bare ADR refs
persist in section titles (e.g. "## Relationship to ADR 001"). Now
only the H1 title line is exempt (can't link a doc to its own title);
H2-H6 are checked. Linked the 5 sub-heading refs this surfaced
(026/005/012/002/013 + one self-ref) — adding the link keeps the
visible heading text, so section slugs are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit 4b0758c into main May 19, 2026
11 checks passed
@alpergundogdu
alpergundogdu deleted the claude/jolly-kilby-7df787 branch May 19, 2026 15:28
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.

1 participant