Repository navigation
Description
Summary
detect_incremental derives its deleted set as "manifest key not in the scanned file set", while
save_manifest retains a manifest entry whenever "the file exists on disk". The two predicates
disagree. A file that leaves the scan scope — because .graphifyignore grew, for instance — but stays on
disk therefore satisfies the retain test and fails the deleted test, so it is reported deleted on every
subsequent run, permanently.
That set flows straight into build_merge(prune_sources=...), so a completed --update evicts live
sources from the graph. The failure is silent and looks like a normal incremental.
Mechanism
Two lines, in graphify/detect.py (0.8.33):
save_manifest, in the seed-from-existing block (detect.py:1190-1205) — retains on existence:
for f, entry in existing.items():
...
if Path(f).exists():
manifest[f] = normaliseddetect_incremental (detect.py:1322) — deletes on scan membership:
current_files = {f for flist in full["files"].values() for f in flist}
deleted_files = [f for f in manifest if f not in current_files]detect() honours .graphifyignore / .gitignore (detect.py:707-711), so scan membership can shrink
while the file is still on disk. Nothing ever removes the orphaned entry, because the only prune test is
existence.
The sink is graphify/__main__.py:4183:
prune_sources=deleted_files or None,and the same call appears in the --update skill flow
(graphify/skills/*/references/update.md, the build_merge step).
Reproduction
- Build a graph over a repo. The manifest now holds every scanned file.
- Add a directory to
.graphifyignorethat the manifest already covers, and leave the files on disk. - Run the
--updatedetect step.
deleted_files now holds every file under that prefix. Every one exists.
Observed on a repository where .graphifyignore gained three prefixes while their files stayed on disk.
The pre-run manifest held 3,808 entries; entries under the three newly-ignored prefixes numbered
620 + 612 + 6 = 1,238, which is exactly the deleted count --update reported. After 1,220 of those
files were later deleted from disk, the count fell to 18 on its own, with no fix applied — which is
the mechanism confirming itself.
A useful diagnostic:
from pathlib import Path
from graphify.detect import detect, load_manifest, _MANIFEST_PATH
cur = {f for v in detect(Path('.'))['files'].values() for f in v}
man = load_manifest(_MANIFEST_PATH, root=Path('.'))
d = [f for f in man if f not in cur]
print('deleted:', len(d), 'of which still on disk:', sum(1 for f in d if Path(f).exists()))Any non-zero second number is a set of phantom deletions.
Two things this is NOT
Both were proposed and both are wrong, so they may save you a wrong turn:
- Not a path-format mismatch between writers. Every in-product
save_manifestcall passesroot=
(watch.py:603/641/712,__main__.py:4152/4241), so the on-disk manifest is uniformly relative, and
detect_incrementalre-anchors it on read atdetect.py:1268. The key sets are format-compatible.
The arithmetic also rules it out: zero key overlap would make every scanned file new, whereas the
failing run reported 766 changed against a 3,808-entry manifest — 67 percent overlap. - Not a missing relativize inside
detect_incremental. It already passesrootto
load_manifest.
Suggested fix
Restrict the deleted set to entries whose file is actually gone:
deleted_files = [
f for f in manifest
if f not in current_files and not Path(f).exists()
]prune_sources exists to evict nodes for files that no longer exist. A file that exists but left the
scan scope has no nodes to evict, because the graph was never built from it.
Optionally, and separately: have save_manifest also drop entries outside the current scan scope, so the
manifest stops accumulating orphans. The reader change above is the safety half; that is the cleanup
half.
Two lower-severity observations from the same investigation
--update's merge step callssave_manifest(incremental['files'])with noroot=
(graphify/skills/*/references/update.md), so it writes the legacy absolute-keyed manifest while
watch.pywrites the relative form. It self-heals on the nextwatchrun and it is not the cause
of the bug above, but the two writers disagreeing on format is confusing to anyone debugging this
area — it sent our first two analyses down the wrong path.- The
to_jsonnode-count guard and_check_shrinkboth fired correctly and are what prevented
real damage here. Worth keeping. Neither sits inside--updateitself, so a prune arriving through
build_mergeis not covered by them.
Environment
graphifyy0.8.33, installed viauv tool install, Python 3.13.7- Windows 11
.graphifyignorepresent at the scan root
Activity
abhay-codes07 commentedon Aug 20, 2026
This does not reproduce on current
v8(0.9.48) — the two predicates were reconciled by #1908, which split the manifest-minus-corpus set in two.Ran the exact scenario: build a graph, then add a directory to
.graphifyignorewhile its files stay on disk.The live-but-now-ignored files land in
excluded_files, anddeleted_filesis empty — so nothing feeds them toprune_sourcesas deletions and the eviction you describe cannot happen.detect.pynow reads:Your analysis was right for 0.8.33 — the single-predicate version you quote is genuinely there in that release. It looks like this was fixed between then and now without the issue being closed.
Worth flagging the flip side, though, because it is still live and it is the same seam: the
--updaterunbook reads onlydeleted_filesand neverexcluded_files, so where 0.8.33 pruned too much, current versions prune too little — an added.graphifyignorerule never removes what it excluded, and after one more run the manifest row is gone so nothing can prune it again. That is #2773, with a fix open at #2806.So the seam you found is real; the direction it fails in flipped. This one can probably be closed as fixed by #1908 — happy to be told otherwise if you can still reproduce it on 0.9.48.
ayushcodes10 commentedon Sep 16, 2026
Already fixed on current
v8, via #1908.save_manifest'sscan_corpusparameter is wired through every caller that matters (cli.pyandwatch.py, three call sites each). Reproduced directly: seeded a manifest withscan_corpus, excluded a live file via.graphifyignorewhile leaving it on disk, then re-randetect_incremental—deleted_filescomes back empty, so a live-but-newly-excluded file is no longer misreported as deleted.ayushcodes10 commentedon Oct 20, 2026
Reproduced this issue's exact scenario against current upstream v8 (post 0.9.9x, well past the 0.8.33 this was filed against) and the described bug no longer occurs.
detect_incrementalingraphify/detect.pynow splits the manifest rows that left the scan into two sets by disk existence, exactly as this issue's own suggested fix proposes:A direct repro confirms it: two files tracked in the manifest, then one excluded via a fresh
.graphifyignoreentry while staying on disk.The CLI (
graphify/cli.py) keeps the two sets separate end to end: they're reported separately ("N deleted, M excluded"), and while both do feedprune_sourcesforbuild_merge(an excluded file's nodes are correctly removed from the graph, since it's no longer part of the corpus), a file that merely left scope is never counted or reported as deleted, matching this issue's actual complaint about misreporting, not about whether its nodes should be pruned.This was fixed by #1908/#1909 (commit
75cf56bf, "excluded files are pruned from graph and manifest, not misreported as deleted"), filed and merged on 2026-07-15, about a month before this issue (#2870) was opened on 2026-08-19 — looks like a duplicate filed against an older install that predated that fix. The code comments atdetect.pyand two sites incli.pycite #1908 directly.No code change needed; suggest closing as a duplicate of #1908.