Problem
In runPostNativeCha (src/domain/graph/builder/stages/native-orchestrator.ts), the incremental optimization Gate B checks:
WHERE e.kind = 'calls' AND tgt.kind = 'class'
However, the RTA evidence collection (just above Gate B) has a two-tier fallback:
- First tries
tgt.kind = 'class'
- Falls back to
tgt.kind IN ('constructor', 'function') for older native engine schemas
Edge case: If a changed file adds new constructor calls where tgt.kind = 'constructor' (from a database built by an older native engine version), Gate B will NOT fire even though the instantiated set has grown. This causes scopeToChangedFiles = true, meaning CHA expansion would be incorrectly scoped to only changed files, missing expansions for unchanged call sites.
Impact
- Only affects incremental builds (full builds run the full scan unconditionally)
- Only triggered by databases built by older native engine versions that emit
constructor-kind call targets
- Does not affect CI/fresh builds
Fix
Gate B should mirror the two-tier RTA fallback:
// Gate B: calls from changed-file sources to class-OR-constructor/function-kind targets?
const row = db
.prepare(
`SELECT 1 FROM edges e
JOIN nodes src ON e.source_id = src.id
JOIN nodes tgt ON e.target_id = tgt.id
WHERE e.kind = 'calls'
AND tgt.kind IN ('class', 'constructor', 'function')
AND src.file IN (${ph})
LIMIT 1`,
)
.get(...chunk);
Noted in the Greptile review of PR #1503 (confidence 4/5). The fix was out of scope for that PR.
References
Problem
In
runPostNativeCha(src/domain/graph/builder/stages/native-orchestrator.ts), the incremental optimization Gate B checks:However, the RTA evidence collection (just above Gate B) has a two-tier fallback:
tgt.kind = 'class'tgt.kind IN ('constructor', 'function')for older native engine schemasEdge case: If a changed file adds new constructor calls where
tgt.kind = 'constructor'(from a database built by an older native engine version), Gate B will NOT fire even though the instantiated set has grown. This causesscopeToChangedFiles = true, meaning CHA expansion would be incorrectly scoped to only changed files, missing expansions for unchanged call sites.Impact
constructor-kind call targetsFix
Gate B should mirror the two-tier RTA fallback:
Noted in the Greptile review of PR #1503 (confidence 4/5). The fix was out of scope for that PR.
References
src/domain/graph/builder/stages/native-orchestrator.ts~lines 527-545