graphify icon indicating copy to clipboard operation
graphify copied to clipboard

JavaScript imports_from edges reference missing ref_* nodes

Open cgoulart21 opened this issue 4 months ago • 1 comments

JavaScript imports_from edges reference missing ref_* nodes

Environment

  • graphifyy 0.9.25
  • Python 3.11.7
  • Windows x86-64
  • undirected graph build

Public reproduction

Repository: https://github.com/levkropp/ClawSCAD at commit a7eeb66f20c13182e210498259eb86bf5457da55.

Run the normal code extraction over the repository and inspect the extraction result before build_from_json:

from pathlib import Path
from graphify.extract import collect_files, extract

root = Path("ClawSCAD")
files = collect_files(root)
result = extract(files, cache_root=root)
ids = {node["id"] for node in result["nodes"]}
dangling = [
    edge for edge in result["edges"]
    if edge.get("source") not in ids or edge.get("target") not in ids
]
print(len(result["nodes"]), len(result["edges"]), len(dangling))
print(dangling[:3])

Observed in this repository's JavaScript extraction:

  • 271 nodes
  • 403 edges
  • 29 dangling endpoint edges

Representative edges:

{"source":"main","target":"ref_electron","relation":"imports_from","source_file":"main.js","source_location":"L1"}
{"source":"main","target":"ref_path","relation":"imports_from","source_file":"main.js","source_location":"L2"}
{"source":"main","target":"ref_node_pty","relation":"imports_from","source_file":"main.js","source_location":"L5"}

The source nodes exist, but the ref_* target nodes are absent. diagnose_extraction() reports these as dangling, and build_from_json() drops the affected edges.

Expected behavior

One of the following consistent outcomes would avoid invalid extraction data:

  1. emit external-reference nodes for imported packages/modules; or
  2. omit these edges from the extraction; or
  3. classify external references separately so diagnostics/build do not treat them as malformed internal endpoints.

This issue is limited to the dangling import-reference behavior. Undirected same-endpoint collapses were not included because those appear to be expected graph normalization.

cgoulart21 avatar Jul 23 '26 12:07 cgoulart21

Independent confirmation from an Expo / React Native TypeScript repository on macOS with graphifyy 0.9.25.

A fresh code-only extraction produced 556 nodes and 1,257 raw edges. The multigraph diagnostic initially reported 114 dangling endpoints; separating missing targets by ID showed:

  • 93 intentional external references whose missing target starts with ref_
  • 21 genuinely internal missing endpoints (a separate producer issue)

The most frequent external targets were:

  • ref_react — 16
  • ref_react_native — 16
  • ref_testing_library_react_native — 9
  • ref_react_native_safe_area_context — 5
  • ref_expo_notifications — 5

Representative edges include imports_from -> ref_react, ref_react_native, ref_expo_camera, and ref_tanstack_react_query. The source endpoints exist; the external ref_* targets intentionally do not.

This matches the root cause described in draft PR #2132. Classifying these 93 edges as external_import_edges would make the diagnostic actionable: it would leave the 21 real internal endpoint defects visible instead of mixing both categories. I can test the PR branch against this corpus if useful.

kitsupanic avatar Jul 23 '26 22:07 kitsupanic