Skip to content

Edge building excludes constant nodes from dependency graph #487

@carlos-alm

Description

@carlos-alm

Bug

codegraph where BUILTIN_RECEIVERS -T --json returns empty results, and fn-impact reports 0 dependents — yet grep confirms 3 active consumers in core source files (incremental.js, build-edges.js).

Root Cause

The JS extractor does correctly extract export const declarations as constant-kind nodes and they are inserted into the nodes table. However, the edge-building stage in src/domain/graph/builder/stages/build-edges.js (line 31) excludes them from the node lookup:

SELECT id, name, kind, file, line FROM nodes
WHERE kind IN ('function','method','class','interface','struct','type','module','enum','trait')

'constant' is not in this list. As a result:

  • Constants exist in the DB but are never loaded into nodesByName / nodesByNameAndFile
  • No import/dependency edges are created for them
  • They are invisible to where, fn-impact, query, roles, and all other graph queries

Impact

  • codegraph roles --role dead misclassifies constants as dead (0 fan-in because no edges exist)
  • codegraph where can't find them at all
  • codegraph fn-impact reports 0 dependents for actively-used constants
  • Any downstream tooling (e.g. automated dead-code cleanup) that trusts codegraph data will incorrectly target these symbols for removal

Affected Symbols (examples from this repo)

  • BUILTIN_RECEIVERSexport const in src/domain/graph/builder/helpers.js, used in 3 source files
  • BATCH_CHUNKexport const in same file, actively imported
  • MAX_COL_WIDTHexport const, used in presentation layer

Fix

Add 'constant' to the WHERE kind IN (...) clause in build-edges.js line 31, so constants participate in edge resolution like any other symbol.

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