Skip to content

[Bug]: incremental update gives same-stem files (math.c/math.h, index.ts/index.js) different ids than a full build #5464

Backlog

Description

@0xkaushik-ai

What happened?

When two files in the same folder produce the same raw node ids (math.c and math.h, or index.ts and index.js), a full build salts them apart with the source path, for example src_math_c_src_math. An incremental run (graphify update, or graphify extract on an existing graph) re-extracts only the changed file, so the salting never happens and the graph no longer matches a full build of the same tree:

  • Editing math.c gives its file node the bare id src_math instead of src_math_c_src_math. Anything holding the old id (MCP queries, saved links) breaks, and one calls edge is lost (8 edges instead of 9).
  • Deleting math.h leaves math.c on the salted id, where a full build gives it the bare one.
  • Deleting a file can also leave a sourceless reference node behind with no edges. Deleting a Kotlin file that declares class LoggingList<T> : MutableList<T> by ArrayList() keeps mutablelist, which a full build does not have.

Steps to reproduce

mkdir -p repro/src && cd repro
printf 'struct point { int x; int y; };\nint add(int a, int b);\n' > src/math.h
printf '#include "math.h"\nint add(int a, int b) { return a + b; }\nint twice(int a) { return add(a, a); }\n' > src/math.c
GRAPHIFY_BACKEND=none graphify update .
python3 -c "import json; print(sorted(n['id'] for n in json.load(open('graphify-out/graph.json'))['nodes'] if 'math' in n['id']))"
echo '// touched' >> src/math.c
GRAPHIFY_BACKEND=none graphify update .
python3 -c "import json; print(sorted(n['id'] for n in json.load(open('graphify-out/graph.json'))['nodes'] if 'math' in n['id']))"

The first print has src_math_c_src_math. After the edit it has src_math instead, though the file content changed only by a comment. Running rm -rf graphify-out && graphify update . brings back src_math_c_src_math.

Expected

An incremental run gives the same node ids and edges as a full build of the same tree.

Cause

_disambiguate_colliding_node_ids only sees the files in the current extract() batch. The incremental paths in watch._rebuild_code and the CLI's extract hand it just the changed files.

Graphify version

v8 @ ba33a18 (0.9.119), clean checkout

Operating System

Linux (Kali, kernel 6.19)

Python Version

3.13

Activity

  1. github-actions commented on Nov 24, 2026

    @github-actions

    Thanks for opening this issue, @0xkaushik-ai. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions