Skip to content

fix(lint): don't hide same-stem orphans behind qualified links#147

Merged
KylinMountain merged 1 commit into
VectifyAI:mainfrom
jichaowang02-lang:fix/find-orphans-cross-dir-stem
Jun 29, 2026
Merged

fix(lint): don't hide same-stem orphans behind qualified links#147
KylinMountain merged 1 commit into
VectifyAI:mainfrom
jichaowang02-lang:fix/find-orphans-cross-dir-stem

Conversation

@jichaowang02-lang

Copy link
Copy Markdown
Contributor

Summary

find_orphans builds the set of linked pages by adding, for every wikilink, both its full path and its bare stem:

for lnk in links:
    incoming.add(lnk.strip().strip("/"))
for lnk in links:
    incoming.add(Path(lnk.strip()).stem)   # stem of EVERY link, even qualified ones

So a qualified link like [[concepts/foo]] also registers the bare stem foo. Any other page that merely shares that stem in a different directory — e.g. summaries/foo — is then treated as "linked" (stem in incoming) and excluded from orphan detection. A genuine orphan is silently missed.

Fix

Only register the bare stem when the link itself is a bare stem (no /). Qualified links register only their full path:

cleaned = lnk.strip().strip("/")
incoming.add(cleaned)
if "/" not in cleaned:
    incoming.add(Path(cleaned).stem)

Bare [[foo]] links still resolve by stem (a page named foo in any directory stays non-orphaned), so the intended bare-link behaviour is preserved.

Testing

$ pytest tests/test_lint.py::TestFindOrphans -q
6 passed
  • test_qualified_link_does_not_hide_same_stem_orphansummaries/dup is now flagged when only [[concepts/dup]] is linked (fails before the fix).
  • test_bare_stem_link_still_matches_same_stem_page — a bare [[dup]] link still marks a same-stem page as non-orphan.

(The 4 unrelated TestFindMissingEntriesRegistry failures are pre-existing on main and untouched by this change.)

find_orphans added the bare stem of *every* wikilink to the "incoming" set, so
a qualified link like `[[concepts/foo]]` also registered the stem `foo`. Any
other page that merely shared that stem in a different directory (e.g.
`summaries/foo`) was then treated as linked and excluded from orphan
detection — a genuine orphan was silently missed.

Only add the bare stem when the link itself is a bare stem (no `/`); qualified
links register only their full path. Bare `[[foo]]` links still resolve by
stem, so a page named `foo` in any directory remains non-orphaned.

Adds regression tests for both the qualified-link (orphan now flagged) and
bare-link (still matched) cases.
Copilot AI review requested due to automatic review settings June 27, 2026 02:16

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KylinMountain KylinMountain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thanks for the sharp catch and the clean fix! Much appreciated 🙏

@KylinMountain KylinMountain merged commit 6194c5e into VectifyAI:main Jun 29, 2026
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.

3 participants