Skip to content

Commit 7eda366

Browse files
committed
fix(native): extend Gate B RTA check to cover constructor/function kinds (#1503)
The incremental scoping gate in runPostNativeCha only checked tgt.kind = 'class' for new RTA evidence, but the adjacent two-tier RTA collection also falls back to constructor/function kinds for databases written by older native engine versions. On such incremental builds Gate B would never fire, causing the scan to be wrongly scoped to changed files and missing CHA expansion for unchanged-file call sites.
1 parent 4aced08 commit 7eda366

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/domain/graph/builder/stages/native-orchestrator.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,11 @@ async function runPostNativeAnalysis(
407407
* - array → incremental; two cheap gate queries decide scope:
408408
* Gate A: any class/interface/trait/struct/record nodes in changed files?
409409
* If yes, a new implementor may have appeared — full scan required.
410-
* Gate B: any `calls` edges from changed-file sources targeting class-kind
411-
* nodes? If yes, the RTA set may have grown, enabling previously
412-
* filtered expansions in unchanged caller files — full scan required.
410+
* Gate B: any `calls` edges from changed-file sources targeting class/constructor/
411+
* function-kind nodes? If yes, the RTA set may have grown (older native
412+
* engine versions store constructor calls under constructor/function kinds),
413+
* enabling previously filtered expansions in unchanged caller files —
414+
* full scan required.
413415
* If neither gate fires: scope `callToMethods` to `src.file IN changedFiles`
414416
* (safe because no hierarchy or RTA evidence changed).
415417
*
@@ -499,9 +501,11 @@ function runPostNativeCha(
499501
// valid expansions, so the full scan is required.
500502
//
501503
// Gate B: did a changed file add new RTA evidence (`new ConcreteX()`)?
502-
// A new `calls` edge to a class-kind target means the instantiated set grew —
503-
// previously RTA-filtered expansions in unchanged caller files become
504-
// admissible, so the full scan is required.
504+
// A new `calls` edge to a class/constructor/function-kind target means the
505+
// instantiated set may have grown (older native engine versions store constructor
506+
// calls under constructor/function kinds rather than class) — previously
507+
// RTA-filtered expansions in unchanged caller files become admissible, so the
508+
// full scan is required.
505509
//
506510
// If neither gate fires, the hierarchy and RTA set are unchanged for all files
507511
// outside changedFiles, so restricting to changed-file sources is safe.
@@ -524,7 +528,11 @@ function runPostNativeCha(
524528
if (row) gateAFired = true;
525529
}
526530

527-
// Gate B: calls from changed-file sources to class-kind targets?
531+
// Gate B: calls from changed-file sources to class/constructor/function-kind targets?
532+
// Mirrors the two-tier RTA collection above: primary checks class-kind, but
533+
// older native engine versions store constructor calls under constructor/function
534+
// kinds. If either tier has new evidence, the instantiated set may have grown and
535+
// a full scan is required.
528536
let gateBFired = false;
529537
if (!gateAFired) {
530538
for (let i = 0; i < changedFiles.length && !gateBFired; i += CHUNK_SIZE) {
@@ -535,7 +543,8 @@ function runPostNativeCha(
535543
`SELECT 1 FROM edges e
536544
JOIN nodes src ON e.source_id = src.id
537545
JOIN nodes tgt ON e.target_id = tgt.id
538-
WHERE e.kind = 'calls' AND tgt.kind = 'class'
546+
WHERE e.kind = 'calls'
547+
AND tgt.kind IN ('class', 'constructor', 'function')
539548
AND src.file IN (${ph})
540549
LIMIT 1`,
541550
)

0 commit comments

Comments
 (0)