Replace the architecture stub with the overview and add link tests

architecture.md now carries the ADR table, both diagrams, scaling, risks
and the table of inputs from the legacy stack. Tests check contiguous ADR
numbers, that every ADR is linked, and that relative links resolve.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
torbenandClaude Sonnet 5.5 committed 2026-12-02 23:11:02 +01:00
1 parent 5ca64b177e
commit 980328ce2e
2 files changed
+227 -5

No files matched your search

+52 -1
View File
@@ -8,7 +8,9 @@ from typing import cast
import pytest
import yaml
DECISIONS = Path(__file__).resolve().parents[2] / "docs" / "decisions"
ROOT = Path(__file__).resolve().parents[2]
DECISIONS = ROOT / "docs" / "decisions"
ARCHITECTURE = ROOT / "docs" / "architecture.md"
REQUIRED_SECTIONS = (
"Kontext und Problemstellung",
"Betrachtete Optionen",
@@ -24,6 +26,8 @@ PLACEHOLDER = re.compile(r"\{[^{}\n]+\}")
FENCE = re.compile(r"\s*(`{3,}|~{3,})(.*)")
ADR_NAME = re.compile(r"\d{4}-[a-z0-9-]+\.md")
INLINE_CODE = re.compile(r"`[^`\n]*`")
MARKDOWN_LINK = re.compile(r"\[[^\]\n]*\]\(\s*<?([^)\s>]+)>?(?:\s+\"[^\"]*\")?\s*\)")
EXTERNAL_TARGET = re.compile(r"(https?:|mailto:|#)")
class _PlainLoader(yaml.SafeLoader):
@@ -327,3 +331,50 @@ INVALID = [
@pytest.mark.parametrize(("name", "text", "expected"), INVALID)
def test_invalid_adr_is_reported(name: str, text: str, expected: list[str]) -> None:
assert adr_problems(name, text) == expected
def broken_links(path: Path, text: str) -> list[str]:
"""Return relative Markdown link targets in text that do not exist next to path."""
broken: list[str] = []
for line in _prose_lines(text):
for target in MARKDOWN_LINK.findall(INLINE_CODE.sub("", line)):
if EXTERNAL_TARGET.match(target):
continue
file_part = target.split("#", 1)[0]
if not (path.parent / file_part).exists():
broken.append(target)
return broken
def markdown_files() -> list[Path]:
"""Return the Markdown files whose relative links are checked."""
files = sorted((ROOT / "docs").rglob("*.md"))
return [*files, ROOT / "README.md", ROOT / "CLAUDE.md"]
def test_adr_numbers_are_contiguous() -> None:
numbers = [int(path.name[:4]) for path in adr_files()]
assert numbers == list(range(1, len(numbers) + 1))
def test_architecture_links_every_adr() -> None:
text = ARCHITECTURE.read_text(encoding="utf-8")
targets = set(MARKDOWN_LINK.findall(text))
missing = [path.name for path in adr_files() if f"decisions/{path.name}" not in targets]
assert missing == []
@pytest.mark.parametrize("path", markdown_files(), ids=lambda p: str(p.relative_to(ROOT)))
def test_relative_links_resolve(path: Path) -> None:
assert broken_links(path, path.read_text(encoding="utf-8")) == []
def test_broken_link_is_reported(tmp_path: Path) -> None:
(tmp_path / "exists.md").write_text("x", encoding="utf-8")
text = (
"[ok](exists.md) [anchor](exists.md#abschnitt) [self](#oben) "
"[web](https://example.org/x.md) [mail](mailto:a@example.org) "
"`[code](missing-inline.md)` [gone](missing.md#a)\n"
"```\n[fenced](missing-fenced.md)\n```\n"
)
assert broken_links(tmp_path / "doc.md", text) == ["missing.md#a"]