Repository navigation
Description
Labels: bug, extract, astro, node-identity
Version: 0.9.40
Summary
extract_astro() mints nodes for frontmatter variables using a different ID recipe than the
one used for the enclosing file node. As a result:
- The symbol node does not carry the file node's stem as a prefix, breaking the
<file_stem>_<entity>convention the build layer relies on. - When the path handed to
extract()is absolute and norootis passed, the full
absolute filesystem path is baked into the symbol node's ID — the leak class of Node IDs for file / directory / project nodes embed the absolute scan path (leaks local username, makes committed graph.json non-portable / non-idempotent) #1789 /
Windows: absolute source_file from detect() breaks node identity on full rebuild and poisons the semantic cache #2197, still reachable in 0.9.38.
Steps to reproduce
src/pages/index.astro:
---
import { getPosts } from '../lib/content';
const posts = getPosts();
---
<h1>{posts.length}</h1>1. Stem mismatch (relative input)
extract([Path('src/lib/content.ts'), Path('src/pages/index.astro')])id=lib_content # file node for content.ts
id=lib_content_getposts # symbol -- correctly prefixed
id=pages_index # file node for index.astro
id=src_pages_index_posts # symbol -- NOT prefixed with "pages_index"
The file node is pages_index (2-component stem) but its own frontmatter variable is
src_pages_index_posts (3-component). They no longer share a prefix.
2. Absolute path leak (absolute input, no root)
extract([Path('src/pages/index.astro').resolve()])id=index # file node -- fine
id=c_users_asus_appdata_local_temp_claude_c_users_asus_desktop_os_gra
phify_accccdec_07ee_4c98_8664_8b2a39362228_scratchpad_astro_src_pa
ges_index_posts # symbol -- LEAK
Note both nodes come from the same file: the file node was correctly anchored to index,
the variable node was not anchored at all.
Expected behavior
The variable node should be pages_index_posts (case 1) and index_posts (case 2) — always
<file node stem>_<entity>, never containing the absolute path.
Reachability
Case 1 is reachable from python -m graphify.extract src/pages/index.astro ...
(graphify/extract.py:6523 calls extract(paths) with no root) and from any library
caller. Case 2 needs absolute inputs whose inferred common root sits below the project root —
e.g. extract([Path('/abs/src/pages/index.astro')]), a single-file call.
Passing an explicit root produces correct IDs in both cases:
extract(paths, root=Path('.').resolve())
# -> src_lib_content, src_lib_content_getposts, src_pages_index, src_pages_index_postsso the main graphify extract CLI is not affected. This is a library-API / module-entry-point
defect.
Impact
build._semantic_id_remapandgraph_has_legacy_idsrelate a symbol to its file with
norm_nid.startswith(new_stem + "_")(build.py:630,build.py:1057). A symbol that does
not carry its file's stem is invisible to that logic and never migrates.- The
containsedge still connects them, but ID-based reconciliation (dedup, incremental
re-key, cache replay) treats them as unrelated. - Case 2 makes
graph.jsonnon-portable and leaks the local username.
Suggested fix
extract_astro() (graphify/extract.py:1575) should mint frontmatter symbol IDs from the
same anchored stem the file node uses — i.e. reuse _make_id(_file_stem(rel), name) with the
already-computed relative path, rather than deriving from the raw input path. The safest
version is to have the extract() id-remap post-pass assert the invariant, so any extractor
that drifts is caught:
# post-pass sanity: every symbol node must sit under its file node's stem
assert sym_id.startswith(file_stem + "_"), (sym_id, file_stem)Related
- Node IDs for file / directory / project nodes embed the absolute scan path (leaks local username, makes committed graph.json non-portable / non-idempotent) #1789 (CLOSED) — absolute scan path embedded in file/dir/project node IDs. This is the
residual case for astro symbol nodes. - Windows: absolute source_file from detect() breaks node identity on full rebuild and poisons the semantic cache #2197 (CLOSED) — same leak class via
source_file.
Activity
ayushcodes10 commentedon Sep 14, 2026
This is already fixed — both reported symptoms are gone on current v8 (well past 0.9.61).
The root cause was the warm-cache round-trip asymmetry in
graphify/cache.pythat #2632 (closed, not merged via the GitHub button but applied and shipped per the maintainer's comment there) fixed in v0.9.41. Re-ran both of this issue's own repros directly against current code:Case 1 (stem mismatch, relative input)
produces:
Case 2 (absolute path leak, single absolute file)
produces:
Both match the issue's own "Expected behavior" section exactly. Since the fix already shipped and the acceptance criteria are met, closing this out rather than opening a duplicate PR — let me know if you'd like it reopened for any remaining edge case.