--update leaves stale graph nodes when files leave scan scope
Summary
The --update skill flow can leave stale graph nodes behind when a file
remains on disk but leaves the active scan scope, for example after being
added to .graphifyignore.
detect_incremental() correctly classifies the file as excluded_files,
but the skill update flow only passes deleted_files to build_merge().
At the end of the update, save_manifest(..., scan_corpus=...) removes the
excluded file from the manifest. This leaves the graph and manifest
inconsistent, and on subsequent runs the stale graph nodes are no longer
detectable through incremental manifest-based detection.
Reproduction
- Build a graph containing a file
A.py. - Confirm that
A.pyis present in both the graph and manifest. - Add
A.pyto.graphifyignorewhile leaving the file on disk. - Run the
--updateskill flow.
Observed:
deleted_files = []
excluded_files = [A.py]The current skill flow passes only deleted_files to build_merge():
prune = list(deleted) or None
G = build_merge(
[new_extraction],
...,
prune_sources=prune,
)As a result, A.py's existing graph nodes remain.
The subsequent manifest save uses the current scan scope and removes
A.py from the manifest.
After the first update:
graph.json:
A.py nodes still present
manifest.json:
A.py absentRun --update again without changing anything else.
The second run reports:
deleted_files = []
excluded_files = []because A.py is no longer present in the manifest.
The stale A.py graph nodes therefore remain indefinitely.
Expected behavior
When a previously indexed file leaves the scan scope, its graph contribution should be removed during the same incremental update that removes it from the manifest.
The expected transition is:
included file
↓
file becomes excluded
↓
excluded_files = [A.py]
↓
prune A.py from graph
↓
remove A.py from manifest
↓
clean steady stateIf the file is later brought back into the scan scope, it should be treated as a new file and indexed again.
CLI comparison
The CLI incremental path already includes both deleted_files and
excluded_files when constructing prune_sources:
_prune_sources = list(deleted_files)
for _src in list(excluded_files) + graph_stale_sources:
if _src not in _prune_sources:
_prune_sources.append(_src)Running the same scenario through the CLI correctly removes the graph
nodes for A.py while also removing its manifest entry.
The skill --update flow does not currently mirror this behavior.
Root cause
excluded_files was introduced to distinguish files that are still alive
on disk but have left the scan scope from files that have actually been
deleted.
The manifest handling was subsequently updated to remove excluded files
from the manifest, but the skill --update merge step continued to pass
only deleted_files to build_merge().
This creates an inconsistent transition:
graph:
A.py still present
manifest:
A.py removedOnce the manifest entry is removed, subsequent incremental runs have no manifest record from which to discover the stale graph contribution.
Evidence
Reproduced on current v8 with a minimal corpus containing:
def hello():
return "world"Initial state:
A.pyexists on diskA.pyis present in the manifestA.pycontributes 2 nodes to the graph
After adding A.py to .graphifyignore and running the skill update:
deleted_files = []excluded_files = [A.py]- graph still contains 2 nodes sourced from
A.py - manifest no longer contains
A.py
After a second unchanged update:
deleted_files = []excluded_files = []- graph still contains the 2
A.pynodes - manifest remains empty
The equivalent CLI flow prunes the nodes correctly.
Related
This was discovered while investigating #2870.
The original #2870 condition — incorrectly treating live files that leave
the scan scope as deleted_files — is already handled by the current
detect_incremental() implementation.
This issue concerns the downstream handling of those correctly identified
excluded_files in the skill --update flow.
Source: Graphify-Labs/graphify