You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(native): persist this/super dispatch via hybrid WASM post-pass (#1337)
* fix(native): persist this/super dispatch via hybrid WASM post-pass (#1326)
The native orchestrator resolves typed receiver calls but does not persist
raw unresolved call site receiver info (this/super) to the DB, so
runPostNativeCha could not resolve this.method() or super.method() calls.
Add runPostNativeThisDispatch: after the Rust pipeline completes, WASM-re-
parses JS/TS/TSX files to collect call sites with this/super receivers, then
resolves them through the DB class hierarchy (extends edges) using the
existing resolveThisDispatch function. Only runs when extends edges exist.
Removes the skipIf(engine === 'native') guards on the this-dispatch and
super-dispatch integration tests — both engines now produce identical edges
for ConcreteWorker.doWork → ConcreteWorker.prepare and Lion.speak →
Animal.speak. The two CHA transitive skips remain (pending abstract_class_
declaration fix in a future native binary).
Closes#1326
* fix(native): correct NULL ordering in findCallerByLine and remove self receiver
SQLite ASC ordering puts NULL values first, so (end_line - line) ASC would
pick unbounded nodes before any bounded node — inverting the intent. Replace
with COALESCE(end_line - line, 999999999) ASC so unbounded nodes sort last.
Also remove 'self' from the this/super receiver filter in runPostNativeThisDispatch.
In JS/TS files 'self' refers to WindowOrWorkerGlobalScope, not a class instance —
including it would produce spurious dispatch edges from Worker call sites.
* fix(native): scope this/super WASM re-parse to inheritance-hierarchy files only
On a full native build, runPostNativeThisDispatch was WASM-re-parsing every
JS/TS file in the project, adding a costly second parse pass on top of the
native Rust parse (measured: +358% ms/file on codegraph itself).
Narrow the file set to only files that appear in the class inheritance graph
(sources and targets of 'extends' edges). Files outside the hierarchy have no
class relationship, so this/super calls in them either resolve locally or are
skipped by resolveThisDispatch anyway — WASM re-parsing them adds cost with
zero benefit.
Also replace the hardcoded 0.1 confidence penalty with the CHA_DISPATCH_PENALTY
named constant (already imported), matching every other CHA confidence
calculation in native-orchestrator.ts and build-edges.ts.
Fixes: regression-guard failure "Build ms/file: 3.6 → 16.5 (+358%)" (#1337)
* fix(native): document incremental limitation and capture thisDispatchMs timing
Add a comment to the incremental-build branch of runPostNativeThisDispatch
documenting the known gap: if a parent-class method is replaced (new node ID)
but the child file is unchanged, the stale super.method() edge is not
refreshed until the next full rebuild.
Add wall-clock timing for the this/super dispatch post-pass. The function
now returns the elapsed milliseconds (Promise<number>), and the result is
threaded through formatNativeTimingResult as a new thisDispatchMs phase.
For large class hierarchies the WASM re-parse can be non-trivial, so
surfacing it in build diagnostics makes performance regressions visible.
* fix(native): re-classify node roles after this/super dispatch post-pass (#1337)
The Rust orchestrator runs role classification before the post-passes, so target
methods (e.g. Animal.speak, ConcreteWorker.prepare) that had no callers at Rust
build time were classified dead or dead-ffi. runPostNativeThisDispatch inserted
the correct call edges but never re-ran classifyNodeRoles, leaving stale role
labels visible to dead-code detection and API boundary analysis.
Mirror the pattern used after runPostNativeCha: change the return type from
Promise<number> to Promise<{ elapsedMs: number; targetIds: Set<number> }>,
collect target node IDs while building newEdges, then look up the affected files
and call classifyNodeRoles on them — same chunk-and-dedupe pattern as the CHA
post-pass.
0 commit comments