Skip to content

Extraction noise: scope-blind identifier collision + over-eager markdown fragment nodes #1077

Closed

Description

@heitrix

Running /graphify --update on a TS monorepo (~10.6k nodes, 23.5k edges, 629 communities). Two recurring extractor issues surfaced when answering the auto-generated "Suggested Questions" — both inflate the god-node list and the surprising-connection list with false positives.

1. Local const/let identifiers form phantom god-nodes

A test file with const set = new Set(DOMAIN_EVENT_TYPES) produces a node labeled simply set. Across many test files, identical bare identifiers (set, sorted, getAttr, …) collide on the same node ID and accumulate edges to unrelated communities. Result: set reports betweenness 0.113 across ~23 communities even though it's a one-line local in a single file.

Repro signal: "Suggested Questions" surfaces questions like "Why does set connect Community 57 to Community 128 …" — the node turns out to be a local var, not an architectural bridge.

Fix: namespace local const/let/var identifiers by file or function scope (e.g. events_types_test::set) so they can't collide across files. Module-level / exported symbols should keep bare IDs.

2. Markdown fragmentation creates thousands of dead-end nodes

The doc extractor emits one node per fenced code block (code:bash (# Repo root)) and one per bare section heading (Stack, Design Context), each with a single contains edge to its parent doc. They never link to anything else and inflate the "weakly-connected nodes" warning. In my graph, 305 connected components total — giant = 7,439; next = 100; rest are mostly markdown fragments.

Repro signal: "Suggested Questions" surfaces "What connects Design Context, Stack, code:bash (# Repo root (Turborepo)) to the rest of the system?" The answer is "nothing, by design — they're markdown fragments."

Fix options (pick one):

  • Drop fenced code-block and bare-heading nodes entirely (low value).
  • Or: cross-link headings to code symbols when the heading text matches an exported symbol name.

3. Minor: covers edges between audit docs and "GAP" cells get tagged AMBIGUOUS

Lower priority. When a doc explicitly says "not covered — accessed via getDirectDb()", the covers edge from doc → table gets confidence AMBIGUOUS because the cell text reads as negation. It's an explicit architectural decision, not low confidence. A relation: intentionally_excludes (or documents_exclusion) variant would let the audit flow report "documented gaps" separately from "uncertain coverage."


Happy to PR fix #1 if useful — it should be a small change in the AST extractor's identifier-naming step. Fix #2 is a judgement call I'd defer to you.

Activity

  1. safishamsi commented on May 29, 2026

    @safishamsi
    Member

    Fixed in 925eb81. Two root causes addressed:

    1. JS/TS phantom god-nodes — _js_extra_walk now only emits lexical_declaration nodes at program scope (top-level or direct export). Arrow-function-local const assignments no longer generate graph nodes.

    2. Markdown code-block orphan nodes — extract_markdown no longer emits codeblock_N nodes. Fenced blocks had only contains edges and no semantic meaning in the graph; they were inflating node counts and showing up as disconnected orphans.

    Both fixes ship in v0.8.24. Thanks for the detailed report!

  2. added a commit that references this issue on May 29, 2026
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