Repository navigation
Description
Summary
At the end of a successful extraction, cli.py persists the fresh semantic
results with _save_semantic_cache(..., root=out_root, ...). Inside
save_semantic_cache, each result group's source_file (commonly a
corpus-relative path such as report.md) is resolved against that same root
— i.e. against the --out directory:
def resolved_source_path(value):
path = Path(value)
if not path.is_absolute():
path = root_path / path # root_path = out_root here
...
# write loop:
p = resolved_source_path(fpath)
if p.is_file(): # <out>/report.md does not exist -> False
... # group silently skipped, no warning<out>/report.md does not exist, p.is_file() is False, and the group is
skipped without any warning (the out-of-scope warning only covers the
allowed_source_files branch, not the not-a-file branch). Net effect with
--out pointing outside the corpus: the semantic cache the reader would
consult is never populated at all. The loss becomes visible whenever semantic
files must be reconstructed or redispatched, such as recovery from an
interrupted first build or rebuilding without the prior graph/manifest. An
ordinary unchanged incremental run may instead preserve the existing graph
without consulting the cache, so it does not necessarily re-bill. Combined with
#1990 (checkpoints written to the corpus root), the semantic cache round-trip
needed for reconstruction and recovery is fully broken in the --out
configuration, invisibly: the successful run itself builds the graph from the
in-memory merge.
This is a write-side sibling of #826 (0.7.13: absolute-vs-relative
source_file mismatch broke cache lookup); here the wrong anchor root
breaks the cache write.
Environment
- graphifyy 0.9.18 (PyPI,
uv tool install), Python 3.14 (uv-managed), Windows 11 - backend: claude-cli (Sonnet); mechanism is backend-independent
Reproduction
graphify extract <corpus> --backend claude-cli --token-budget 15000 --out <scratch>
# run succeeds, graph.json written, log shows NO cache warnings, then:
find <scratch>/graphify-out/cache/semantic -name '*.json' # -> nothingObserved identically on two corpora (8 markdown files; 1 sliced 54k-char file).
The per-file stat-index.json under <scratch> does get 1 entry per doc,
which makes the empty semantic cache easy to miss.
Expected
Either the fresh entries are written under out_root keyed/anchored correctly
(resolve source_file against the corpus target, write under cache_root=out_root
— the split the AST path already uses), or at minimum a loud warning when every
group is skipped ("0 of N semantic result groups written — source_file paths do
not resolve under root").
Suggested fix
Same plumbing as #1990: give save_semantic_cache separate root
(source-key/source_file anchor = corpus target) and cache_root
(cache location = out_root) parameters; cli.py's final save passes both.
Add a warning when a group is dropped because resolved_source_path(...) is
not a file. Add a separate regression test for the final-save call site: after
a successful extraction with external --out, assert that the out-root semantic
cache contains every dispatched document and that a fresh cache-only replay
returns hits without an LLM call. This is distinct from the interrupted-
checkpoint recovery test in #1990 even though both use the same
root/cache_root split.
Related
- save_semantic_cache reports "Cached 0 files" — chunk JSONs use absolute source_file paths, preventing cache hits on subsequent --update runs #826 (closed) — read-side variant of the same anchor mismatch (0.7.13)
- save_semantic_cache silently overwrites another file's legitimate cache when a subagent mis-attributes source_file to a file outside the current chunk #1757 (closed) — the
allowed_source_filesguard this save already uses;
its warning path does not cover the not-a-file skip - Companion reports:
graphify extract --outsaves recovery checkpoints in the wrong directory #1990 (checkpoint location),file_hashstat-index memo omits the root anchor: same (file, root) call returns different digests depending on call order #1989 (file_hashmemo)
Activity
chore: begin 0.9.20 cycle + changelog for #1986/#1987/#1990/#1991/#1983
fix(cache): anchor semantic cache writes to cache_root so --out round…
fix(cache): anchor semantic cache writes to cache_root so --out round…
chore: begin 0.9.20 cycle + changelog for Graphify-Labs#1986/Graphify…