Skip to content

graphify extract --out saves recovery checkpoints in the wrong directory #1990

Closed

Description

@tomipetteri-ops

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:

  1. Graphify creates an unwanted graphify-out/ directory inside the analyzed
    source tree even though the user selected another output directory.
  2. 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 HERE

To 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, ...) where root is the extract
    root kwarg (= target, wired in cli.py corpus_kwargs = {"root": target}).
    No cache_root is passed — save_cached therefore derives the cache
    directory from root, 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

Two companion reports cover related problems found during the same test:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions