Skip to content

Node merge/dedup doesn't match a code entity to a planning-doc node describing the same file (different source_file) #3246

Open

Description

@MattiasLinder

Summary

When a code file is both (a) AST-parsed directly and (b) described/referenced by
name in a semantic-extraction source (a markdown planning doc), the resulting two
nodes never merge — even after a full forced re-extract. They represent the same
underlying script but end up as two disconnected node identities in different
communities, which skews god-node / betweenness metrics.

Environment

  • OS: Windows
  • Invocation: /graphify slash command inside a claude (Claude Code) session
  • graphify version: <kör graphify --version och fyll i>

Repro

Corpus: a small repo containing

  • scripts/generate-testpilot-keys.mjs — a Node script (AST-parsed)
  • _PLANS/SLICE_2026-08-15_rotating-testpilot-keys.md — a markdown planning doc
    that names and describes that exact script (semantic-extracted)

After extraction, graph.json contains two nodes for the same script:

​json { "id": "scripts_generate_testpilot_keys", "label": "generate-testpilot-keys.mjs", "_origin": "ast", "community": 3, "community_name": "Testpilot Key Generation Script", "file_type": "code", "norm_label": "generate-testpilot-keys.mjs", "source_file": "scripts/generate-testpilot-keys.mjs", "source_location": "L1" } ​

​json { "id": "scripts_generate_testpilot_keys_module", "label": "generate-testpilot-keys.mjs script", "community": 2, "community_name": "Product Cards & Entitlement Docs", "file_type": "code", "norm_label": "generate-testpilot-keys.mjs script", "source_file": "_PLANS/SLICE_2026-08-15_rotating-testpilot-keys.md", "source_location": null } ​

No edge exists between these two node IDs anywhere in graph.json.

What I tried

  1. /graphify . --force inside the IDE session (full re-extract, no cache reads) —
    nodes still separate afterward, only the community labels changed.
  2. graphify extract . --force from a plain terminal — fails with
    no LLM API key found, since the IDE-session model routing isn't available
    outside /graphify. Didn't get to test --dedup-llm for the same reason
    (would need a separate paid API key just to test).

Expected

The two nodes should either merge into one, or at minimum get an explicit
references/describes edge between them, since they're the same script.

Suspected root cause

The merge/entity-resolution heuristic appears to key on exact source_file
match. When a semantic pass extracts an entity from a document that mentions
a code file, it seems to attribute source_file to the referring document
itself, not to the code file it's actually describing — so it never lines up
with the AST node's source_file and the "ghost duplicate" merge never fires.

This is a common pattern in doc-driven repos (a code file + a spec/plan doc
that names it), so it's likely not specific to this one corpus.

Activity

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