Skip to content

fix: Gate B RTA check misses constructor/function-kind targets on older native schemas #1515

@carlos-alm

Description

@carlos-alm

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:

  1. First tries tgt.kind = 'class'
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions