Expand description
Contrastive search — find the rows whose solution diverged most from a baseline. ADR-001 roadmap item #6.
The architectural shape RuView, Cognitum, and Ruflo’s inner loops actually want: not “give me the whole solution vector”, but “tell me which entries crossed a boundary big enough to wake an agent”. This is the change-driven activation primitive the ADR’s thesis turns on.
§API
let top_k = find_anomalous_rows(&baseline, ¤t, 5);
for AnomalyRow { row, baseline, current, anomaly } in top_k {
println!("row {row}: was {baseline}, now {current} (Δ={anomaly})");
}§Complexity
The current implementation is O(n log k) — one pass over the
solution vectors with a k-sized min-heap. That’s already useful
(avoids O(n log n) of a full sort) but not yet the O(k · log n)
the ADR promised. The follow-up will land a direct path that
computes only the top-k entries of the new solution via the sublinear-
Neumann single-entry primitive, without ever materialising the full
current solution. Tracked as a // TODO(ADR-001 #6 phase 2): in the
source.
Structs§
- Anomaly
Row - One row’s anomaly report.
- Contrastive
Solve OnChange Op - Marker type with a
Complexityimpl forcontrastive_solve_on_change. - Contrastive
Solve OnChange Sublinear Op - Op marker for the SubLinear orchestrator variant.
- Find
Anomalous Rows Op - Marker type with a
Complexityimpl forfind_anomalous_rows.
Functions§
- contrastive_
solve_ on_ change - One-shot contrastive solve: given a previous solution + a sparse RHS
delta, return the top-
krows whose value diverged most under the new RHS, without scanning the full solution vector. - contrastive_
solve_ on_ change_ sublinear - SubLinear sibling of
contrastive_solve_on_change: skips the innersolve_on_changeand uses per-entry sublinear Neumann queries scoped to the closure of the delta’s support. End-to-endSubLinearinnfor sparse DD matrices with bounded depth — the phase-2B realisation of the ADR-001 contract. - contrastive_
solve_ on_ change_ sublinear_ auto - Magic-number-free sibling of
contrastive_solve_on_change_sublinear. Takes only(matrix, prev, b_new, delta, tolerance, k)and auto-tunes bothclosure_depthandmax_termsfrom the matrix’s coherence viacrate::coherence::optimal_neumann_terms. - contrastive_
solve_ on_ change_ sublinear_ auto_ with_ rho - Tightest-bound contrastive sibling: takes a caller-supplied
spectral-radius
rho(e.g. fromcrate::coherence::approximate_spectral_radius) and uses it for tighter Neumann-depth tuning than the loose(1 - coherence)bound. Seecrate::incremental::solve_on_change_sublinear_auto_with_rhofor the non-contrastive sibling. - find_
anomalous_ rows - Return the
krows whosecurrentvalue diverged most frombaseline. - find_
anomalous_ rows_ in_ subset - Top-k variant constrained to a caller-supplied candidate set. Skips the rest of the solution vector entirely.
- find_
rows_ above_ threshold - Return only the rows whose anomaly score exceeds
threshold. Useful as the boundary-crossing primitive for change-driven activation: an agent stays asleep until at least one entry crosses the threshold.