Skip to content

fix(cache): scope semantic cache writes to extracted files#1835

Closed
TPAteeq wants to merge 1 commit into
Graphify-Labs:v8from
TPAteeq:fix/1757-semantic-cache-source-scope
Closed

fix(cache): scope semantic cache writes to extracted files#1835
TPAteeq wants to merge 1 commit into
Graphify-Labs:v8from
TPAteeq:fix/1757-semantic-cache-source-scope

Conversation

@TPAteeq

@TPAteeq TPAteeq commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an allowed_source_files boundary to save_semantic_cache.
  • Prevent semantic results from replacing cache entries for files outside the dispatched extraction batch.
  • Apply the boundary to both native CLI extraction and every generated agent workflow.
  • Preserve out-of-scope nodes in the graph while skipping and warning about unsafe cache writes.
  • Preserve backward compatibility for callers without an allowlist.

Validation

  • 3117 passed, 30 skipped
  • ruff check passed
  • tools.skillgen --check passed
  • Monolith round-trip validation passed
  • graphify update . completed successfully

Closes #1757

@safishamsi

Copy link
Copy Markdown
Collaborator

Landed on v8 (579ba1d, your commit preserved) plus a follow-up (da9616d) — ships in 0.9.14. Thanks @TPAteeq, the allowlist design is right and the skillgen threading was clean.

One gap I fixed on top: the guard covered the final CLI write, but the per-chunk incremental checkpoint in llm.py:_checkpoint_chunk — the write that actually runs on every extract/update via extract_corpus_parallel — was still calling save_semantic_cache without an allowlist (merge_existing=True), so a stray mis-attributed node could still pollute a victim file's entry before the final write. I scoped that call to the chunk's own dispatched files and added an extract_corpus_parallel integration test proving an out-of-chunk attribution leaves the victim's cache untouched. Also hoisted the import warnings to module level. Credited your commit in the history.

@safishamsi safishamsi closed this Jul 12, 2026
safishamsi added a commit that referenced this pull request Jul 13, 2026
The #1835 fix scoped save_semantic_cache's final CLI write to an
allowed_source_files allowlist, but the per-chunk incremental checkpoint
in llm.py `_checkpoint_chunk` — the write that actually runs on every
`graphify extract`/`update` via extract_corpus_parallel — still called
save_semantic_cache with no allowlist. A chunk whose model result
mis-attributes a node's source_file to another corpus file would merge
that stray fragment into the victim's cache entry (merge_existing=True).

Scope the checkpoint write to the chunk's own dispatched files (FileSlice
-> .rel, bare Path -> the relative source_file). Also hoist the
`import warnings` in cache.py to module level.

Adds an extract_corpus_parallel integration test: a chunk dispatching
only A.py that returns a node attributed to already-cached B.py must
leave B.py's cache entry untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save_semantic_cache silently overwrites another file's legitimate cache when a subagent mis-attributes source_file to a file outside the current chunk

2 participants