Repository navigation
Description
[Bug] Running /graphify . on a large repo triggers subdirectory prompt, causing AST cache to be written to <subdir>/graphify-out/cache/ instead of ./graphify-out/cache/
Description
When graphify's built-in large-corpus flow prompts the user to select a subfolder (e.g. src/), it internally re-runs detect() and extract() on that subdirectory. The AST extraction cache is then silently written to <subdir>/graphify-out/cache/ while check_semantic_cache() always reads from ./graphify-out/cache/. The two paths never overlap, so every subsequent run is a full cache miss — all AST extraction is repeated from scratch even though nothing changed.
Version
graphifyy 0.4.13
Steps to Reproduce
Note: this bug is triggered by graphify's own built-in large-corpus flow, not by manually passing a subdirectory path.
- Run
/graphify .on a project with more than 200 files - graphify detects the large corpus and — per its own built-in flow — asks the user to pick a subfolder to limit scope, presenting options like
src/,src/business/, etc. - User selects
src - graphify internally re-runs
detect()andextract()onsrc/
After the run completes, two separate cache directories exist:
./graphify-out/cache/ ← empty (where check_semantic_cache looks)
./src/graphify-out/cache/ ← 829 files (where extract() actually wrote)
This means the bug is triggered by graphify's own recommended workflow for large repos. Any project large enough to hit the "pick a subfolder" prompt will silently produce a broken cache on every run.
Root Cause
extract() infers root from the common prefix of the input file paths:
# graphify/extract.py ~line 3006
common_len = sum(
1 for i in range(min(len(p.parts) for p in paths))
if len({p.parts[i] for p in paths}) == 1
)
root = Path(*paths[0].parts[:common_len]) if common_len else Path(".")When all input files are under src/, this infers root = src. Cache entries are then written to src/graphify-out/cache/.
However, check_semantic_cache() and save_semantic_cache() both default to root=Path("."), so they always read from and write to ./graphify-out/cache/.
The two functions use different roots independently — there is no shared root value passed through the call chain.
Impact
- Cache is never hit on the second run, wasting tokens on re-extraction
- A stray
<subdir>/graphify-out/directory is created inside the user's source tree - The manifest, graph outputs, and cost tracker all land in
./graphify-out/(correct), but only the AST cache is misplaced — making the inconsistency hard to notice
Expected Behavior
All cache operations (read and write) should use a single consistent root, determined once at the pipeline entry point and passed explicitly through extract(), check_semantic_cache(), and save_semantic_cache(). The extract() function should not infer its own root independently.
Suggested Fix
Remove root auto-inference from extract() and require callers to pass it explicitly:
def extract(paths: list[Path], root: Path = Path(".")) -> dict:
# use caller-provided root instead of inferring from paths
...Then in the pipeline entry point, determine root once and thread it through:
root = Path(".") # always the working directory, regardless of input path
extract(code_files, root=root)
check_semantic_cache(all_files, root=root)
save_semantic_cache(nodes, edges, hyperedges, root=root)This is consistent with the fix direction in #311 / #313, which established that root should be stable and explicit rather than derived from file paths.
Workaround
Create a symlink so both paths resolve to the same physical directory:
ln -s ../graphify-out src/graphify-out
Activity
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…
safishamsi commentedon Apr 14, 2026
Implemented in v0.4.14.
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…
Fix 9 issues: kiro package data, betweenness perf, wiki step, opencod…