Skip to main content

detect_top_k

Function detect_top_k 

Source
pub fn detect_top_k(
    baseline: &[Record],
    candidate: &[Record],
    k: usize,
) -> Vec<FirstDivergence>
Expand description

Detect up to k meaningful divergences between two traces, sorted by importance (kind severity × confidence, descending).

Returns an empty vec when the traces agree end-to-end. Returns at most k results; fewer if the walk produces fewer above-noise cells. Pass k = DEFAULT_K for the standard top-5.

Ranking: Structural > Decision > Style (by class), then by confidence within a class. This surfaces the most actionable regression first, not just the earliest. Walk order is preserved as a stable tiebreaker so identical-severity events are reported in temporal order (earlier turns before later ones).