Commit 602bedc
fix(detector/typescript): emit anchor nodes for imports edges
The TypeScript structures detector was emitting imports edges with free-form
strings (file path → module name) as endpoints, but no matching CodeNode
existed for either side. Every imports edge got silently dropped at
GraphBuilder.Snapshot's phantom-edge filter.
On nuxt (1269 files, mostly TS): 3507 phantom edges out of 6923 total
emissions — half of all edges were dropped because the imports detector
was sending them into the void.
Fix:
- Emit a NodeModule for the current file (`ts:file:<path>`) once per file.
- Emit a NodeExternal for each imported module (`ts:external:<mod>`) once.
- Wire the imports edge through these node IDs.
Dedup via the GraphBuilder map collapses the per-file external nodes
across files (every file importing "react" gets one shared
ts:external:react target), so the graph also gets a real dependency
view at no extra cost.
Bench (nuxt re-index):
- Before: 4902 nodes, 2416 edges, 3507 phantom drops
- After: 5914 nodes, 4770 edges, 1153 phantom drops (-67% phantoms)
- Deduped: 1807 nodes (external modules collapsed across files)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 83e9493 commit 602bedc
2 files changed
Lines changed: 48 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
150 | 181 | | |
151 | 182 | | |
152 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
83 | 96 | | |
84 | 97 | | |
85 | 98 | | |
| |||
0 commit comments