Commit d4e6212
committed
fix: restore reflection dynamicKind for .call/.apply/.bind (docs check acknowledged)
Issue #1778: /parity found WASM emits dyn=0 (plain static call) while native
emits dyn=1/dynamicKind='reflection' for identifier.call(...)/.apply(...)/
.bind(...) call sites, even though both fully resolve the target (confidence
1). Root cause: PR #1693 (closing #1687) made the WASM extractor
unconditionally drop dynamic/dynamicKind for these calls on identifier
receivers, to fix a narrow dedup-collision bug in build-edges.ts's
dynZeroEdgeRows upgrade path. That fix overcorrected — it silenced the
`reflection` DynamicKind for every identifier-based .call/.apply/.bind, not
just the collision case, diverging from native (which never changed).
Chose Option A (revert + fix narrowly), not Option B (mirror WASM's drop in
Rust): ADR-002 defines `reflection` as informational metadata independent of
resolution/confidence, queryable via `codegraph roles --dynamic` — dropping it
for .call/.apply/.bind would erase real information about a genuinely
reflective invocation mechanism, and native's classification was never wrong.
Changes:
- src/extractors/javascript.ts: extractMemberExprCallInfo once again tags
.call/.apply/.bind on identifier receivers as dynamic:true,
dynamicKind:'reflection', matching the member-expression branch and native.
- src/domain/graph/builder/stages/build-edges.ts: emitDirectCallEdgesForCall's
dyn=0 -> dyn=1 upgrade (dynZeroEdgeRows) now compares source lines instead
of firing on any dynamicKind-tagged collision. It only upgrades when the
incoming call's line is EARLIER than the recorded dyn=0 call's line — which
only happens when the query path's two-phase collection (query matches,
then a supplementary walk pass for bare decorators, #1683) reorders a
genuinely-earlier call to arrive later. A later .call/.apply/.bind to an
already-called target is collected in the same phase as the direct call
(true source order already holds), so it must not flip an established dyn=0
edge — matching native's plain first-recorded-wins dedup.
- crates/codegraph-core/src/extractors/javascript.rs: no behavior change
(native was already correct); added 4 unit tests pinning the
identifier/member-expression reflection tagging so this doesn't regress.
- tests/parsers/javascript.test.ts, tests/engines/dynamic-call-ffi.test.ts:
updated to assert the restored dynamic/reflection tagging at the parser
level.
- tests/integration/issue-1778-reflection-dynamic-kind-parity.test.ts: new
engine-parity tests (wasm + native) covering the #1778 minimal repro (no
prior direct call -> dyn=1), the original #1687 dedup scenario (direct call
then .call() -> single dyn=0 edge), the reverse-order case, and a #1683
regression guard (bare decorator before call-expression decorator still
upgrades to dyn=1).
Verified: `node scripts/parity-compare.mjs` shows zero edge diffs across all
42 fixtures (previously 6/8/12 diffs on dynamic-javascript/javascript/
jelly-micro). Resolution-benchmark precision/recall unchanged for every
language. Full npm test suite green (3589 passed). cargo test green (479
passed, +4 new).
Fixes #1778
Impact: 6 functions changed, 13 affected1 parent ee6362c commit d4e6212
6 files changed
Lines changed: 343 additions & 53 deletions
File tree
- crates/codegraph-core/src/extractors
- src
- domain/graph/builder/stages
- extractors
- tests
- engines
- integration
- parsers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4246 | 4246 | | |
4247 | 4247 | | |
4248 | 4248 | | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
| 4264 | + | |
| 4265 | + | |
| 4266 | + | |
| 4267 | + | |
| 4268 | + | |
| 4269 | + | |
| 4270 | + | |
| 4271 | + | |
| 4272 | + | |
| 4273 | + | |
| 4274 | + | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
| 4286 | + | |
| 4287 | + | |
| 4288 | + | |
| 4289 | + | |
| 4290 | + | |
| 4291 | + | |
| 4292 | + | |
4249 | 4293 | | |
4250 | 4294 | | |
4251 | 4295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| |||
1395 | 1407 | | |
1396 | 1408 | | |
1397 | 1409 | | |
1398 | | - | |
1399 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
1400 | 1416 | | |
1401 | 1417 | | |
1402 | 1418 | | |
| |||
1405 | 1421 | | |
1406 | 1422 | | |
1407 | 1423 | | |
| 1424 | + | |
1408 | 1425 | | |
1409 | 1426 | | |
1410 | 1427 | | |
1411 | 1428 | | |
1412 | | - | |
| 1429 | + | |
1413 | 1430 | | |
1414 | 1431 | | |
1415 | 1432 | | |
| |||
1432 | 1449 | | |
1433 | 1450 | | |
1434 | 1451 | | |
1435 | | - | |
1436 | | - | |
1437 | | - | |
1438 | | - | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
1439 | 1472 | | |
1440 | | - | |
1441 | | - | |
1442 | | - | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
1443 | 1476 | | |
1444 | 1477 | | |
1445 | 1478 | | |
| |||
1463 | 1496 | | |
1464 | 1497 | | |
1465 | 1498 | | |
1466 | | - | |
1467 | | - | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
1468 | 1503 | | |
1469 | | - | |
| 1504 | + | |
1470 | 1505 | | |
1471 | 1506 | | |
1472 | 1507 | | |
| |||
1736 | 1771 | | |
1737 | 1772 | | |
1738 | 1773 | | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1744 | 1781 | | |
1745 | 1782 | | |
1746 | 1783 | | |
| |||
1773 | 1810 | | |
1774 | 1811 | | |
1775 | 1812 | | |
| 1813 | + | |
1776 | 1814 | | |
1777 | 1815 | | |
1778 | 1816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
357 | | - | |
358 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
| |||
3357 | 3359 | | |
3358 | 3360 | | |
3359 | 3361 | | |
3360 | | - | |
3361 | | - | |
3362 | | - | |
3363 | | - | |
3364 | | - | |
3365 | | - | |
3366 | | - | |
3367 | | - | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
3368 | 3371 | | |
3369 | | - | |
| 3372 | + | |
| 3373 | + | |
3370 | 3374 | | |
3371 | 3375 | | |
3372 | 3376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
78 | | - | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
82 | | - | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
89 | | - | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
0 commit comments