pub fn reduce_nary(coverage: &[(u32, u32)], k: u32) -> Vec<KeptNaryPattern>Expand description
Reduce per-pattern (positives_covered, negatives_covered) counts to
the final ordered top-K.
The binary reduction law with the topology dimension removed and the canonical enumeration index as the final tie-breaker:
- Sort pattern indexes by
(-positives_covered, negatives_covered, pattern_idx). The enumeration is deterministic lexicographic, so the index tie-break is as stable across calls as the binary engine’s(left_idx, right_idx)tie-break. - Filter to
positives_covered > 0, keep the firstk. local_rank/next_*over the positive-filtered list;tie_class_sizeover the FULL batch (including zero-coverage).