Repository navigation
Description
Summary
Upgrading in place from 0.5.4 → 0.9.62 leaves stale state behind in two separate places,
because both manifest.json and graph.json are merged into rather than replaced. The result
is a graph that keeps entries pointing at files that no longer exist at those paths, indefinitely,
with no warning.
The graph.json half is the more damaging of the two, and it survives --force.
1. save_manifest merges, so stale keys are never dropped
Before the upgrade, manifest.json held 38 keys, all absolute paths. After the upgrade wrote
new repo-relative keys, the file held 301 — the 263 new relative keys plus all 38 stale
absolute ones. Nothing was removed.
So one file ends up describing the same tree twice, under two different key conventions, and the
stale half never expires.
Workaround: delete manifest.json before the first update. Doing so produced a clean
263 keys, 0 absolute, confirming the new code path is correct and only the merge is at fault.
2. graphify update --force merges graph.json too — this is the bigger one
--force reads as "discard and rebuild", and the guard message reinforces that reading:
WARNING: new graph has 4809 nodes but existing graph.json has 8473.
Refusing to overwrite — you may be missing chunk files from a previous session.
Pass --force to override.
It does not discard. Measured against a byte-identical backup of the pre-force graph.json:
| count | |
|---|---|
nodes after --force |
4809 |
| of those, already present before | 3708 |
| newly created this run | 1101 |
| dropped | 4765 |
Among the survivors, 219 nodes carry an absolute source_file under a directory the project was
checked out at previously and no longer is. Zero of those 219 were newly created — every one
is a carry-over. They cannot be regenerated, because nothing exists at those paths now; they can
only persist.
Deleting manifest.json does not help here, because these live in graph.json.
Why this is worth fixing rather than documenting
- The guard counts nodes only. On another repo in the same rollout the node count rose 61%
while hyperedges fell 81% — the headline number hid the loss entirely. A merge that silently
preserves unreachable nodes makes that harder to notice, not easier. - A tool that reports a knowledge graph of a codebase is expected to describe the current
codebase. Nodes keyed to a path the code has not lived at for months are indistinguishable, to a
consumer ofgraph.json, from live ones. - The only reliable remedy found was
rm -rfof the whole output directory and a full rebuild,
which also discards every LLM-derivedrationalenode — an expensive price for what reads like
a cache-invalidation bug.
Reproduction
- On 0.5.4, build a graph for a project at path A.
- Move or re-clone the project to path B.
- Upgrade to 0.9.62.
graphify update <B>→ the guard refuses (fewer nodes without an LLM run, sincerationale
nodes cannot be reproduced).graphify update <B> --force.- Inspect
graph.json: nodes whosesource_filestill begins with path A are present, and
none of them are new.
Expected
save_manifestreplaces the manifest for the paths it rewrites, rather than unioning old and
new key conventions.--forcereplaces the graph, or the flag/message says plainly that it merges and that stale
nodes are retained.- Ideally, nodes whose
source_fileno longer resolves are pruned on rebuild regardless of flag.
Environment
- graphify 0.9.62 (upgraded in place from 0.5.4), installed as a uv tool
- macOS, Python 3.14
- Python project, ~160 source files, AST-only extraction (no LLM key configured at update time)
Activity
L4XB commentedon Sep 15, 2026
I reproduced part 1 on
v8(c7ec108, 0.9.62) and it splits into two cases that behave differently, which I think narrows the fix quite a bit.Harness: write a 0.5.4-shaped manifest at A (absolute keys, no
root), copy the tree withgraphify-out/to B, then save from B the waycli.pydoes (kind="both", root=B, scan_corpus=<full detect corpus>).So move is already clean today and only re-clone reproduces. The difference is that after a re-clone the old checkout still exists, so the stale rows survive the
Path(f).exists()prune in the seed loop. Might be worth confirming whether A was still on disk in your run, since that decides whether this is the same bug you hit or a third one.Once the row is past the
exists()prune, two things keep it alive for ever:save_manifest's seed loop prunes a row that the full scan no longer covers only when it is in root:_to_relative_for_storagekeeps out-of-root keys absolute, so the row is rewritten in the old convention on every save and never collides with the new relative key.The
_in_rootguard looks deliberate rather than accidental:test_save_manifest_full_scan_keeps_out_of_root_rowspins it, with the rationale that out-of-root entries (--includesources, symlinked corpora) are never walked bydetect, so their absence from the corpus is not exclusion evidence. A stale key from a previous checkout is indistinguishable from a legitimate--includesource by that test alone, which is why I have not sent a patch for this half: whichever way it goes is a call about what an out-of-root row means, not a bug fix.The options I can see, in case it is useful:
scan_corpusnor the stampedfilesof a full-scan save. Smallest change, but it invertstest_save_manifest_full_scan_keeps_out_of_root_rows, so--includesources would have to be re-stamped on every run to survive.Happy to implement whichever you prefer.
One adjacent case did turn out to have no trade-off, so I sent it separately as #3583: a key that names a file which really is under
rootbut spells it differently (symlinked checkout path, or a case variant on APFS/NTFS) also relativizes to../…, stays absolute, and ends up duplicated beside the fresh relative key. That one is unambiguous, and it is a second way to arrive at the "one file describing the same tree twice" shape you saw. It does not touch the re-clone case, and does not close this issue.I have not looked into part 2 (
--forceongraph.json) yet.Merge upstream v8 into fix-3426-detect-incremental-deleted-files
Resolve the upstream v8 merge for detect.py and test_detect.py
Merge upstream v8 into fix 3426 detect incremental deleted files
Resolve the upstream v8 merge for detect.py and test_detect.py
Merge upstream v8 into fix 3426 detect incremental deleted files
Resolve the upstream v8 merge for detect.py and test_detect.py