Repository navigation
feat(adr-001): magic-number-free orchestrators (auto-tune from coherence) - #38
Merged
Merged
Conversation
…nce) Last hand-tuned knob in the SubLinear inner loop: closure_depth + max_terms. Caller picks them today, often blindly. This lands two "_auto" sibling orchestrators that auto-tune both from the matrix's coherence margin via optimal_neumann_terms (PR #37): src/incremental.rs solve_on_change_sublinear_auto(matrix, prev, b_new, delta, tolerance) Computes (coherence, min_diag, b_inf), picks max_terms = optimal, uses closure_depth = max_terms (the closure must cover the hops Neumann actually touches), dispatches to solve_on_change_sublinear. Empty-delta short-circuit preserved; non-strict-DD input returns SolverError::Incoherent. src/contrastive.rs contrastive_solve_on_change_sublinear_auto(...) Same auto-tune logic for the contrastive top-k path. src/lib.rs Re-exports both auto variants. examples/event_driven_anomaly.rs Switches to the auto orchestrators. Caller's contract collapses to: tolerance in, top-k out. No closure_depth / max_terms knobs. Discovery on the example: the auto-tune is mathematically rigorous, so a low-coherence (c=0.2) ring-stencil matrix forces a wide closure (64-depth → all 256 rows) to reach 1e-8 tolerance. That's correctness paying its real cost — never an under-pick, never an over-pick. Higher-coherence matrices (c≥0.5) auto-pick tighter closures and pull per-event cost down sharply. The example's summary line now shows the coherence + auto-tune behaviour transparently. Tests: 6 new tests across incremental + contrastive covering: - empty-delta short-circuit - agreement with hand-tuned solve on strict-DD matrices - rejection of non-DD input with Incoherent error - op-marker class checks Co-Authored-By: claude-flow <ruv@ruv.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The last hand-tuned knob in the SubLinear inner loop was `(closure_depth, max_terms)` — caller-supplied, usually guessed. This PR lands two `_auto` sibling orchestrators that auto-tune both from the matrix's coherence margin via `optimal_neumann_terms` (PR #37).
New API
```rust
solve_on_change_sublinear_auto(matrix, prev, b_new, delta, tolerance)
-> Vec<(usize, Precision)>
contrastive_solve_on_change_sublinear_auto(matrix, prev, b_new, delta, tolerance, k)
-> Vec
```
Caller's contract collapses to: tolerance in, top-k out. No closure_depth / max_terms knobs. Non-strict-DD input returns `SolverError::Incoherent` (the auto-tune relies on the Neumann-envelope bound, which doesn't hold there).
Example
`examples/event_driven_anomaly.rs` now uses the auto orchestrators. The summary line transparently shows the coherence-driven auto-tune behaviour:
```
per-event SubLinear auto-tuned closure_depth+max_terms from coherence=0.200
```
Discovery: the auto-tune is mathematically rigorous. On the low-coherence (c=0.2) ring-stencil test matrix, it correctly demands a 64-depth closure (all 256 rows) to reach 1e-8 tolerance — never an under-pick, never an over-pick. Higher-coherence matrices (c≥0.5) auto-pick tighter closures and pull per-event cost down sharply.
Test plan
🤖 Generated with claude-flow