graphify icon indicating copy to clipboard operation
graphify copied to clipboard

Graph node still exists when deleting multiple files

Open lau1944 opened this issue 4 months ago • 2 comments

I am refactoring the current codebase, with a lot of deletion of the files, and i use graphify update . command to update the graph. But taking a look on the result, some nodes are deleted but it still exists on the graph.

What is the best practice in case of the file deletion, do I need to delete the /graphify-out and rebuild it again?

lau1944 avatar Jul 10 '26 14:07 lau1944

Good question — and I dug into this on current v8 (0.9.13) but couldn't reproduce genuine stale nodes. Here's what I found and the best practice.

graphify update . does handle deletions — you do not need to delete graphify-out/ and rebuild. I verified three scenarios, all correct:

  • Delete several files at once → their nodes are all evicted.
  • Delete a file whose classes/functions are still imported by a surviving file → the deleted file's nodes are still evicted.
  • Delete a base class's file while a surviving subclass still inherits from it → the base's real node (and its methods) are evicted.

The one case where a node looks like it 'survives': if a surviving file still references a symbol from the deleted file (e.g. class Sub(Base) after you delete base.py), you'll see a Base node remain — but check its source_file: it'll be empty (""), not base.py. That's a fresh unresolved-reference stub standing in for the now-external Base your code still names — the original base.py-sourced node was removed. It's expected (your code does still reference Base); once you delete the reference too, it goes away.

If you're seeing a genuinely stale node — one whose source_file still points at a file you deleted — that's a real bug and I'd like to fix it. Could you share:

  1. your graphify version (graphify --version),
  2. whether you ran plain graphify update . or the git-hook path, and
  3. one stale node's source_file value from graph.json after the update?

Leaving this open pending that. If it's the sourceless-stub case above, it's working as intended.

safishamsi avatar Jul 11 '26 10:07 safishamsi

Tried to reproduce this on v8 HEAD and hit a fork in the road that needs your setup details:

  • If the deleted files were code: graphify update's AST-ownership rule evicted their nodes on the next run in my repro — I could not reproduce any persistence there.
  • If they were docs/papers (.md, .pdf, …): the CLI-level graphify update is AST-only by design and never prunes semantic (LLM) nodes for deleted docs — the command's own trailing tip points doc changes to /graphify --update (the LLM-aware skill path). That documented gap would explain exactly what you're seeing.

Could you share (1) the file types of the deleted files, (2) the exact command you ran (graphify update CLI vs /graphify --update skill), and (3) one source_file value of a lingering node from your graph.json? That would pin down whether this is the documented AST-only limitation or a real pruning bug.

alphanury avatar Jul 16 '26 23:07 alphanury