Skip to main content

compute_diff

Function compute_diff 

Source
pub fn compute_diff(
    old: &GraphSnapshot,
    new: &GraphSnapshot,
    opts: &DiffOptions,
) -> DiffOutput
Expand description

Entry point: computes the semantic diff between old and new.

The algorithm is the same one the pre-DB20 MCP GraphComparator used:

  1. Build two qualified_name -> NodeSnap maps, skipping nodes without qualified names (call sites, imports, etc.).
  2. Walk the “new” map: nodes absent from “old” are added candidates; nodes present on both sides are checked for signature / body changes (producing SignatureChanged or Modified).
  3. Walk the “old” map: nodes absent from “new” are removed candidates.
  4. Run heuristic rename detection between the remaining removed and added sets (same kind, signature similarity >= 0.7, location scoring, confidence threshold 0.9). Matched pairs emit Renamed records and are removed from the added/removed pools.
  5. Emit the remaining Added and Removed records.

Output is pre-filter; callers apply their own include_unchanged / change_types / symbol_kinds filters.