Repository navigation
Description
Summary
[[wikilinks]] between Markdown docs are resolved sibling-only, so in a vault
that organizes notes into folders (Concepts/, Entities/, Guides/, Maps/ ...) every
cross-folder link is dropped from the graph. Obsidian resolves [[name]] against
the whole vault by filename, not relative to the linking note's directory.
On a real 499-file Obsidian vault this dropped 1,030 of 2,323 authored links (44%).
Where
graphify/extractors/markdown.py → _resolve_markdown_link():
candidate = Path(target)
if not candidate.is_absolute():
candidate = source_dir / candidate # sibling-only
return Path(os.path.normpath(str(candidate)))add_link() then existence-gates the target_file stamp:
target_file = None
try:
if resolved.is_file():
target_file = str(resolved)
except OSError:
passSo when the sibling guess misses, no stamp is written, the #2169 remap pass has
nothing to canonicalize, and the edge keeps an absolute-path-derived id that
matches no node — build_from_json drops it. This is the same failure shape as
#2211 (fixed in v0.9.28 for the incremental case), but here the target is not in
the sibling directory at all, so the stamp is never produced in the first place.
Reproduce
vault/
Concepts/alpha.md # contains: [[beta]]
Entities/beta.md
from graphify.extract import extract
res = extract([src, tgt], cache_root=root, root=root, parallel=False)
node_ids = {n["id"] for n in res["nodes"]}
refs = [e for e in res["edges"] if e["relation"] == "references"]
[e for e in refs if e["target"] in node_ids] # -> [] (expected: 1 edge)Observed target id: ..._entities_beta_md built from the sibling guess
Concepts/beta.md, which does not exist.
Measured impact (real vault, 499 notes, v0.9.32)
| before | after fix | authored baseline | |
|---|---|---|---|
valid references |
1,293 | 2,323 | 2,339 |
| recall | 55.3% | 99.3% | 100% |
| graph edges | 7,623 | 8,470 | — |
The residual 16 are links to files that genuinely do not exist in the vault, and
correctly stay dangling.
Why this matters beyond one vault
Note-type folders are the default layout for several popular Obsidian setups
(PARA, Zettelkasten with type folders, LYT/MOC). For those vaults the wikilinks
are the curated ground-truth relationships — the point raised in #295 — so
losing half of them silently makes the graph substantially sparser than what the
author already encoded, with no warning.
Proposed fix
Keep sibling resolution first (it is correct for path-qualified links and cheap),
and add a corpus-level fallback for wikilinks only:
markdown.py— when the sibling guess missed and the link came from
_MD_WIKILINK_RE, stamp the bare name (wikilink_name) on the edge.
Path-qualified[text](./other.md)links never get the stamp, so relative-link
semantics are unchanged.extract()— in the existing post-pass (the first point that knows every
in-root file), build astem -> [rel path]index and repoint stamped edges.
Ambiguity resolves deterministically: same folder as the linking note first
(mirrors Obsidian), then shallowest path, then lexicographic.
The stamp is transient and popped in the same pass, so graph.json is unchanged
in shape. No public interface changes.
Happy to send a PR — I have the patch and tests ready (59 lines across the two
files, 4 new tests, full suite green against the same baseline as v8 HEAD).
Activity