fix: always report broken internal links + show source pages

Previously, broken links that were part of the baseline ("known broken")
disappeared from the terminal output (score=0, no Klartext mention).

- differ.py: build reverse link index to record which pages link to
  each broken URL; "pages" field added to new_broken/known_broken entries
- plain.py: klartext_befunde() now includes known_broken_urls alongside
  new_broken_urls — broken links are always reported until fixed
- __main__.py: report shows "gefunden auf: <page>" for every broken entry,
  known entries labelled "[bekannt, noch nicht behoben]"
- 3 new tests (169 total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-06-12 12:18:38 +02:00
commit b01344dcd8
5 changed files with 57 additions and 6 deletions

View file

@ -216,12 +216,27 @@ def compare_snapshots(baseline_pages: dict, current_pages: dict, cfg: dict) -> d
if p.get("status", 0) >= 400
}
current_broken = set(current_broken_map)
# Reverse index: broken_url → pages that contain a link to it
link_sources: dict[str, list[str]] = {}
for page_url, page in current_pages.items():
for link_list in page.get("links", {}).values():
if not isinstance(link_list, list):
continue
for link in link_list:
if isinstance(link, dict):
href = link.get("url", "")
if href:
link_sources.setdefault(href, []).append(page_url)
new_broken = [
{"url": url, "status": current_broken_map[url]}
{"url": url, "status": current_broken_map[url],
"pages": sorted(set(link_sources.get(url, [])))}
for url in sorted(current_broken - baseline_broken)
]
known_broken = [
{"url": url, "status": current_broken_map[url]}
{"url": url, "status": current_broken_map[url],
"pages": sorted(set(link_sources.get(url, [])))}
for url in sorted(current_broken & baseline_broken)
]