You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extraction cache keys on the resolved path, so a symlink displaces its target on rebuild #2832
Extraction caches by resolved path, so a symlink and its target collide on any rebuild — and the link wins, silently reassigning the content of a real file to a link.
Reproduced on 0.9.45 (and 0.9.30) with no configuration, in three consecutive runs of the same extraction over the same two files:
frompathlibimportPathfromgraphify.extractimportcollect_files, extractimportcollections# repo/real.py is a real file# repo/sub/link.py -> ../real.py is a symlink to itroot=Path("repo").resolve()
files=collect_files(root)
forrunin (1, 2, 3):
res=extract(files, cache_root=root)
print(run, collections.Counter(n.get("source_file") forninres["nodes"]))
run 1 {'real.py': 2, 'sub/link.py': 2} <- both present
run 2 {'sub/link.py': 4} <- real.py has gone
run 3 {'sub/link.py': 4}
collect_files returns both paths every time. The difference is the cache: file_hash keys its stat index on str(resolved), so on a warm cache both paths hash to the same entry and one set of nodes is emitted — under whichever path was walked second.
Why this is worse than duplication
Run 1 is a visible problem: the same content twice under two paths, which inflates counts and can manufacture a hub. Runs 2 and 3 are an invisible one — the real file is absent from the graph, and its content is filed under a path that is a link.
The consequence for anything built on the graph:
"where is this declared?" returns the link
"what does real.py contain?" returns nothing at all
where several links share one target, every other link appears to contain nothing
So a graph built on a cold cache and one built on a warm cache disagree about which files exist, with no error, no warning, and identical node counts. The node total is the same in all three runs, which is why a count-based check cannot see it.
Suggested directions, in preference order
Key the cache by walked path rather than resolved path — or include the walked path in the salt, as file_hash already does for the root. That preserves the cache's purpose while keeping the two paths distinct.
Skip symlinks in collect_files by default, with a flag to follow them. Simpler, and arguably right: a symlink's target is almost always already in the scan.
At minimum, warn when a cache hit arrives via a different path than the one that populated it, so the collision is visible rather than silent.
Happy to test a fix against the reproduction above.
Activity
fix(cache): preserve symlink path identities (#2832)
chore: bump to 0.9.47
safishamsi commentedon Aug 19, 2026
Fixed in v0.9.47: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.47 (the cache no longer collapses symlinks, so an alias and its target keep distinct identities). Closing as resolved.
fix(cache): keep the \\?\ long-path spelling out of cache identity
fix(extract): keep source_file repo-relative under a symlinked scan r…