feat(610): teach the validator and catalog the split layout

Both surfaced in a trial migration against a disposable copy of the real corpus,
not from reading:

- Archive discovery was a NON-recursive glob. After the split, archived records
  live at archive/<area>/<topic>.md, so every one of them became invisible --
  which surfaced as four bogus "supersedes points to unknown key" errors rather
  than as an obvious "no archive found". rglob at both sites.

- Catalog links: a record is now a FILE, so the link is a plain relative path
  with no anchor -- nothing to slug, nothing to keep in sync with a heading. The
  legacy anchor form is kept for records still living inside a multi-record file,
  so the catalog is correct on either side of the migration.
This commit is contained in:
2026-07-25 19:08:58 +02:00
parent d52268f2ed
commit ef67be924c
2 changed files with 17 additions and 6 deletions
+15 -4
View File
@@ -17,12 +17,23 @@ BANNER = "<!-- GENERATED by scripts/build_decisions_catalog.py — do not edit b
def _rel(rec) -> str:
"""Link from docs/decisions/README.md to the record's heading."""
src = Path(rec.source).name
"""Link from docs/decisions/README.md to the record.
Split layout (#610): the record IS a file, so the link is a plain relative path with no
anchor — nothing to slug, nothing to keep in sync with a heading. Legacy layout: an anchor
into the file that holds it. Both forms are produced so the catalog is correct on either side
of the migration.
"""
src = Path(rec.source)
try:
# rec.source is absolute; TOPIC_DIR is docs/decisions, which is where README.md lives.
return str(src.relative_to(dl.TOPIC_DIR))
except ValueError:
pass
anchor = _anchor(rec.heading)
if src == "decisions.md":
if src.name == "decisions.md":
return f"../decisions.md#{anchor}"
return f"{src}#{anchor}"
return f"{src.name}#{anchor}"
def _anchor(heading: str) -> str:
+2 -2
View File
@@ -361,7 +361,7 @@ def _diff_findings(base: str, head: str) -> tuple[list[str], list[str], list[str
def _archive_keys() -> set[str]:
keys: set[str] = set()
if dl.ARCHIVE_DIR.exists():
for f in dl.ARCHIVE_DIR.glob("*.md"):
for f in dl.ARCHIVE_DIR.rglob("*.md"): # rglob: archive is nested by area after #610
for r in dl.parse_file(f):
if r.key:
keys.add(r.key)
@@ -409,7 +409,7 @@ def main(argv=None) -> int:
records = dl.all_active_records()
archive_records = []
if dl.ARCHIVE_DIR.exists():
for f in dl.ARCHIVE_DIR.glob("*.md"):
for f in dl.ARCHIVE_DIR.rglob("*.md"): # rglob: archive is nested by area after #610
archive_records += dl.parse_file(f)
removed, rewritten, demoted = _diff_findings(args.base, args.head) if args.base and args.head else ([], [], [])
budget_ok = _budget_ok(args.budget)