JavaScript imports_from edges reference missing ref_* nodes
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:
- emit external-reference nodes for imported packages/modules; or
- omit these edges from the extraction; or
- 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.
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— 16ref_react_native— 16ref_testing_library_react_native— 9ref_react_native_safe_area_context— 5ref_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.