Repository navigation
Description
Summary
When graphify extract is run with --out <dir>, completed semantic chunks are
saved in the source corpus instead of the requested output directory:
written to: <corpus>/graphify-out/cache/semantic/
read from: <out>/graphify-out/cache/semantic/
Because Graphify writes and reads from different directories, it cannot find
these recovery checkpoints later.
This has two user-visible effects:
- Graphify creates an unwanted
graphify-out/directory inside the analyzed
source tree even though the user selected another output directory. - If extraction is interrupted, the next recovery attempt cannot reuse the
completed chunks. Those chunks must be extracted and billed again.
The AST cache already keeps these two concepts separate: root identifies the
source corpus and cache_root selects where cache files are stored. Semantic
checkpoints do not currently have that separation. Their single root value is
used for both purposes, which places the files in the corpus.
Environment
- graphifyy 0.9.18 (PyPI,
uv tool install), Python 3.14 (uv-managed), Windows 11 - backend: claude-cli (Sonnet), but the mechanism is backend-independent
- observed identically in two separate corpora/runs (8-file corpus; 1-file sliced corpus)
Reproduction
graphify extract <corpus> --backend claude-cli --token-budget 15000 --out <scratch>
# after a successful run:
ls <scratch>/graphify-out/cache/semantic/pf*/ # EMPTY
ls <corpus>/graphify-out/cache/semantic/pf*/ # checkpoint entries are HERETo exercise recovery rather than the normal unchanged-manifest no-op, interrupt
the first build after at least one chunk checkpoint (or remove its incomplete
output state while retaining the checkpoint). The recovery run reports cache
misses and redispatches the completed work because it looks under <scratch>.
An ordinary unchanged incremental run may simply preserve its existing graph
without consulting the semantic cache, so it is not a valid recovery repro.
Mechanism (0.9.18 source)
graphify/llm.py,extract_corpus_parallel→_checkpoint_chunk:
save_semantic_cache(..., root=root, ...)whererootis the extract
rootkwarg (=target, wired in cli.pycorpus_kwargs = {"root": target}).
Nocache_rootis passed —save_cachedtherefore derives the cache
directory fromroot, i.e. from the corpus.graphify/cli.py(extract): reader is
_check_semantic_cache(sem_paths_str, root=out_root, ...)— location anchored
to--out.
Expected
Checkpoint entries land under the same cache root the reader consults
(out_root), and no graphify-out/ is created inside the analyzed corpus
(same contract #1774 established for the AST cache).
Suggested fix
Add a cache_root parameter to save_semantic_cache (mirroring
load_cached's existing cache_root), plumb it from cli.py through
extract_corpus_parallel into _checkpoint_chunk, and pass
cache_root=out_root alongside root=target — the same split the AST path
already uses. Add a regression test that runs with an external --out, captures
a completed per-chunk checkpoint, and proves a recovery read finds it without
creating <corpus>/graphify-out/.
Related issues
- graphify-out/ written to corpus/CWD despite --out / --graph pointing elsewhere #1747 (closed) — previously reported unwanted cache directories in the source tree
- extract() writes AST cache into the analyzed source tree, bypassing CWD (pollutes read-only corpora) #1774 (closed) — fixed the corresponding output-directory handling for the AST cache
- multiple ./graphify-out/cache folders created in workspace #1012 (open) — reports multiple
graphify-out/cachedirectories - Incremental semantic cache checkpoint fails on sliced docs: _checkpoint_chunk reads FileSlice.rel, which does not exist #1870 / incremental cache checkpoint failed: ... not 'FileSlice' on nearly every chunk during semantic extraction (v0.9.15, Windows/uv) #1892 (closed) — earlier checkpoint bugs in the same function
Two companion reports cover related problems found during the same test:
- The final semantic-cache save also mishandles
--out: it checks source paths
relative to the output directory and consequently saves no cache entries.
(With --out, the final semantic-cache save resolves relative source_file paths against out_root and silently writes 0 entries #1991) - The
file_hashoptimization caches one hash per file without accounting for
the root directory used to calculate it. Hash results can therefore depend on
which root was used first. (file_hashstat-index memo omits the root anchor: same (file, root) call returns different digests depending on call order #1989)
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…