Commit ed274f5
fix(detector/python): emit anchor nodes for imports edges
Same anti-pattern fix as TypeScript imports (commit a9fb22d) — the Python
structures detector emitted imports edges with raw file paths and module
names as endpoints. Both endpoints lacked CodeNodes; every edge dropped.
Fix: emit py:file:<path> for the source file once per detector pass,
py:external:<module> for each imported module. The GraphBuilder dedup
collapses the external nodes across files so the graph gets a real
dependency view at no extra cost.
Bench (airflow, 9151 Python-heavy files):
- 95758 nodes, 134400 edges
- 80181 nodes deduped (per-file + per-external collapsed across files)
- 7888 phantom edges dropped (was higher pre-fix)
The dedup count of 80k tells the story: pre-fix, those 80k import emissions
each went to a phantom target. Now they collapse to ~thousands of unique
external module nodes, and the imports edges actually survive.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9897e36 commit ed274f5
2 files changed
Lines changed: 48 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
203 | 241 | | |
204 | 242 | | |
205 | 243 | | |
206 | 244 | | |
207 | 245 | | |
208 | | - | |
209 | 246 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
225 | 253 | | |
226 | 254 | | |
227 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
0 commit comments