fix(kb-lint): a wikilink must not resolve into the quarantine

The resolver copied Obsidian's filename-anywhere semantics with a raw rglob, which
walked .AGENTTRASH/ as well. [[log]] therefore stayed "valid" by landing on the
quarantined core/log.md — a page that is out of circulation until a pruning session
and, being gitignored, does not exist on any other machine. The gate reported a
green bundle while pointing readers at a file git does not carry: exactly the #57
failure, hidden by the check that exists to catch it.

Resolution now uses the same filtered set linting uses (pages()), so the two can
never disagree about what exists. A companion test pins that filename-anywhere
resolution for live pages still works, so the narrowing costs nothing; mutating
the resolver back to rglob turns the new test red.

Refs #60
This commit is contained in:
Frank committed 2026-10-21 00:59:51 -07:00
1 parent 71601f72a8
commit 66fc40de65
2 files changed
+31 -2

No files matched your search

+9 -2
View File
@@ -20,6 +20,10 @@ def pages():
if ".AGENTTRASH" not in p.parts:
yield p
# Names that a wikilink may point at: exactly the pages pages() reports. Deriving this
# once keeps linting and link resolution from disagreeing about what exists.
live = {p.stem for p in pages()}
for p in pages():
rel = p.relative_to(kb)
text = p.read_text(errors="replace")
@@ -70,9 +74,12 @@ for p in pages():
if not Path(target).is_file():
violations.append(f"{rel}: broken relative link -> {m.group(1)}")
for m in re.finditer(r"\[\[([^\]|#]+)", text):
# wikilinks resolve by filename anywhere in the KB (Obsidian semantics)
# wikilinks resolve by filename anywhere in the KB (Obsidian semantics) — but only
# among pages that BELONG to the bundle. A raw rglob also walked .AGENTTRASH/, so a
# link to a quarantined page stayed "valid" here while pointing at nothing on every
# other machine (the trash is gitignored). Same exclusion as pages(), one source.
name = m.group(1).strip().rsplit("/", 1)[-1]
if not list(kb.rglob(name + ".md")):
if name not in live:
violations.append(f"{rel}: broken wikilink -> [[{m.group(1).strip()}]]")
for v in violations: