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
extract --out <dir>: semantic cache never saved, docs missing from manifest (relative source_file resolved against --out) #4831
Problem graphify extract <dir> --out <other> never reuses the semantic cache. Every run re-extracts every doc and reports 0 files cached/unchanged. <other>/graphify-out/cache/semantic/ stays empty.
Cause
The LLM returns source_file relative to the scanned dir (e.g. n1.md). In __main__.py (extract), two places treat it as a path under the output root (out_root) instead:
cache.save_semantic_cache(..., root=out_root) builds Path(root) / "n1.md", is_file() is false, so the entry is skipped. Nothing is saved.
_sem_extracted (used to build _manifest_files) is compared against the absolute paths in files_by_type. A relative source_file never matches, so no doc gets a semantic_hash in manifest.json and detect_incremental re-queues all of them.
When --out is omitted (out_root == target), (1) resolves correctly.
Repro
mkdir vault out cwd
for i in 1 2 3; do echo "# Note $i. Alice uses Redis." > vault/n$i.md; done
cd cwd
graphify extract ../vault --out ../out --backend claude-cli --max-concurrency 1 # run twice
Run 2: incremental summary: 0 files cached/unchanged, 3 re-extracted, tokens spent again, out/graphify-out/cache/semantic/ empty, manifest.json is {}.
Workaround
Omit --out and set GRAPHIFY_OUT=/abs/path/graphify-out. Run 2 then reports 3 files cached/unchanged, 0 re-extracted and spends no tokens. On a ~106-doc vault this took a nightly run from ~340k in / ~66k out tokens to ~17k / ~7k.
Suggested fix
Resolve relative source_file against target (the scanned dir) in save_semantic_cache and when building _sem_extracted, while keeping the cache key relative to out_root as check_semantic_cache already does.
Thanks for the detailed report. Your diagnosis is correct for 0.9.7: there, extract saved the semantic cache with root=out_root, so with --out the relative source_file paths resolved against the output dir, is_file() failed, and every entry was skipped. Separately, the manifest never stamped those docs.
The regression tests for this (tests/test_semantic_cache_out_root.py plus the manifest-stamping tests) pass on current v8 (0.9.97).
Please upgrade with uv tool upgrade graphifyy and drop the GRAPHIFY_OUT workaround. Run 2 of your repro should then report 3 files cached/unchanged, 0 re-extracted. If it still re-extracts on 0.9.20 or later, please reopen with the output and we'll dig in.
Reproduced this without a backend, against the v0.9.7 tag and current v8 (0.9.97). Both halves of the report check out.
At v0.9.7, __main__.py passed root=out_root to both _check_semantic_cache and _save_semantic_cache:
save_semantic_cache resolved the model's corpus-relative source_file against out_root, so is_file() was false for every group and no entry was written.
The manifest filter compared those same relative strings against detect()'s absolute paths, so no doc got a semantic_hash.
Measured on a 3-doc vault with --out (no LLM; same functions the CLI calls):
v0.9.7
v8 (0.9.97)
save_semantic_cache
0 saved, no cache dir
3 saved under --out
check_semantic_cache
3 uncached
0 uncached
docs stamped in manifest
0
3
corpus tree after run
clean
clean
The fixes from 0.9.17 (manifest stamping) and 0.9.20 (root=target, cache_root=out_root) are both present on v8.
One gap the reproduction exposed: mutating only the check call back to root=out_root leaves the current suite green, because no test consumes a cache entry that the manifest has not already stamped. I have two regression tests for that on a branch (two runs with --out and zero backend calls; an AST guard that pins both roots at every call site) and can open a PR if useful.
For the reporter: after uv tool upgrade graphifyy, run 2 of the repro should report 3 files cached/unchanged, 0 re-extracted, and the GRAPHIFY_OUT workaround can go. The cache now lands under <out>/graphify-out/cache/semantic and is content-keyed, so it stays portable if the corpus moves.
Activity
github-actions commentedon Oct 27, 2026
Thanks for opening this issue, @R-u-d. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
nothariharan commentedon Oct 28, 2026
Thanks for the detailed report. Your diagnosis is correct for 0.9.7: there,
extractsaved the semantic cache withroot=out_root, so with--outthe relativesource_filepaths resolved against the output dir,is_file()failed, and every entry was skipped. Separately, the manifest never stamped those docs.Both halves have been fixed since then:
source_fileis now normalized against the scanned root before matchingfiles_by_type.--out: 0816630 (graphify extract --outsaves recovery checkpoints in the wrong directory #1990, With --out, the final semantic-cache save resolves relative source_file paths against out_root and silently writes 0 entries #1991), first shipped in 0.9.20. The save now usesroot=target, cache_root=out_root, which matchescheck_semantic_cache, as you suggested. It also raises aRuntimeWarningif every group gets skipped, so this can't fail silently again.The regression tests for this (
tests/test_semantic_cache_out_root.pyplus the manifest-stamping tests) pass on currentv8(0.9.97).Please upgrade with
uv tool upgrade graphifyyand drop theGRAPHIFY_OUTworkaround. Run 2 of your repro should then report3 files cached/unchanged, 0 re-extracted. If it still re-extracts on 0.9.20 or later, please reopen with the output and we'll dig in.Deepjyoti-Sarmah commentedon Oct 28, 2026
Reproduced this without a backend, against the
v0.9.7tag and currentv8(0.9.97). Both halves of the report check out.At
v0.9.7,__main__.pypassedroot=out_rootto both_check_semantic_cacheand_save_semantic_cache:save_semantic_cacheresolved the model's corpus-relativesource_fileagainstout_root, sois_file()was false for every group and no entry was written.detect()'s absolute paths, so no doc got asemantic_hash.Measured on a 3-doc vault with
--out(no LLM; same functions the CLI calls):save_semantic_cache--outcheck_semantic_cacheThe fixes from 0.9.17 (manifest stamping) and 0.9.20 (
root=target, cache_root=out_root) are both present onv8.One gap the reproduction exposed: mutating only the check call back to
root=out_rootleaves the current suite green, because no test consumes a cache entry that the manifest has not already stamped. I have two regression tests for that on a branch (two runs with--outand zero backend calls; an AST guard that pins both roots at every call site) and can open a PR if useful.For the reporter: after
uv tool upgrade graphifyy, run 2 of the repro should report3 files cached/unchanged, 0 re-extracted, and theGRAPHIFY_OUTworkaround can go. The cache now lands under<out>/graphify-out/cache/semanticand is content-keyed, so it stays portable if the corpus moves.test(extract): assert --out reuses the semantic cache across runs (Gr…
test(cache): pin both roots on every semantic cache call site (Graphi…