Skip to content

feat(adr-001 #2): solve_on_change_sublinear — SubLinear delta-solve - #29

Merged
ruvnet merged 1 commit into
mainfrom
adr/solve-on-change-sublinear
May 19, 2026
Merged

ruvnet merged 1 commit into
mainfrom
adr/solve-on-change-sublinear

Conversation

@ruvnet

@ruvnet ruvnet commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Extends ADR-001 item #2 (change-driven solve) with a SubLinear sibling of `IncrementalSolver::solve_on_change` that returns only the closure entries as `Vec<(usize, Precision)>`, never materialising the full `n`-vector. Generalises the inner primitive of `contrastive_solve_on_change_sublinear` so non-contrastive callers (Kalman updates, sensor-deduplicated controllers, change-tracked HVAC loops) can use it directly.

What's new

  • `solve_on_change_sublinear(matrix, prev, b_new, delta, closure_depth, max_terms, tolerance)` in `src/incremental.rs`. Composes `closure::closure_indices` + `entry::solve_single_entries_neumann`. Empty delta short-circuits to an empty result — the "no event, no work" path is free.
  • `SolveOnChangeSublinearOp` op marker declaring `SubLinear`.
  • ADR-001 item ✨ Add Temporal Neural Solver (TNS) - Sub-microsecond Neural Network Inference #2 row updated to reflect the phase-2 SubLinear path.

Correctness gate

`incremental::tests::sublinear_delta_solve_matches_full_solve_at_closure_entries` — on an 8×8 strict-DD chain, perturbing `b[3]` and running `solve_on_change_sublinear` yields entries that match the full `NeumannSolver` solve at every closure index within `1e-6`.

Test plan

  • 191 lib tests pass (was 188; +3 in incremental)
  • `cargo check --lib` clean
  • Full CI

🤖 Generated with claude-flow

Extends the change-driven solve API with a SubLinear sibling that
returns ONLY the closure entries as Vec<(usize, Precision)>, never
materialising the full n-vector. Generalises the inner primitive of
contrastive_solve_on_change_sublinear so non-contrastive callers
(Kalman updates, sensor-deduplicated controllers, change-tracked
HVAC loops) can use it directly.

Lands:

  src/incremental.rs (+108 LOC)
    solve_on_change_sublinear(matrix, prev, b_new, delta,
                              closure_depth, max_terms, tolerance)
      Returns Vec<(row, x_new[row])> for every row in the bounded-depth
      closure of delta.indices, computed via per-entry sublinear-Neumann.
      Output sorted ascending by row index.

      Empty delta short-circuits to empty result without touching the
      matrix (the "no event, no work" path).

    SolveOnChangeSublinearOp op marker — SubLinear class.

  src/lib.rs
    Re-exports solve_on_change_sublinear + SolveOnChangeSublinearOp.

  docs/adr/ADR-001-complexity-as-architecture.md
    Item #2 row updated to reflect phase-2 SubLinear path.

  .github/complexity-baseline.txt
    Adds SolveOnChangeSublinearOp (SubLinear).

Critical correctness test:
incremental::tests::sublinear_delta_solve_matches_full_solve_at_closure_entries
— on an 8×8 strict-DD chain, perturbing b[3] and running
solve_on_change_sublinear yields entries that match the full
NeumannSolver solve at every closure index within 1e-6.

Tests: 191 lib tests pass (was 188; +3 in incremental).

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet
ruvnet merged commit e905ffd into main May 19, 2026
11 of 12 checks passed
@ruvnet
ruvnet deleted the adr/solve-on-change-sublinear branch May 19, 2026 13:35
ruvnet added a commit that referenced this pull request May 19, 2026
…trator

The SubLinear orchestrator shipped in Rust (PR #29) had MCP preview
primitives (coherenceScore, closureIndices, estimateComplexityClass)
and a wire-callable witness (PR #52). But the orchestrator itself
wasn't wire-callable — agents had to fall back to `solve` (which
returns the full n-vector) instead of the closure-restricted entries
the SubLinear path produces.

This closes the gap with a pure-TS handler that chains:

  1. closure_indices(matrix, delta.indices, closure_depth)
  2. for each closure entry: truncated Neumann iteration
     restricted to the closure (mirrors src/entry.rs math)
  3. return Vec<{row, value}>

Lands in src/mcp/server.ts:
  - New `solveOnChangeSublinear` tool with x-complexity = SubLinear
  - Input schema: matrix, vector (b_new), delta_indices: number[],
    closure_depth (default 4), max_terms (default 32), tolerance (default 1e-8)
  - Dispatch case + handleSolveOnChangeSublinear method
  - Returns {entries: Array<{row, value}>, closure_size, max_terms,
    closure_depth, note}
  - Supports both dense and sparse-COO matrix formats

Matches Rust solve_on_change_sublinear semantics exactly:
  - Early-exit when |delta_k[target]| < tolerance
  - Zero-diagonal in closure → InvalidParams
  - Empty closure → empty entries
  - note field warns when closure covers full matrix

This completes the wire surface for the change-driven inner loop.
Agents can now run the full pipeline over MCP:

  1. coherenceScore             (PR #53)  — is the matrix solvable?
  2. closureIndices             (PR #54)  — how wide is the work?
  3. estimateComplexityClass    (PRs #30, #42)  — what class?
  4. solveOnChangeSublinear     (THIS PR) — actual SubLinear solve
  5. verifySparseSolution       (PR #52)  — audit output

All 5 tools are pure-TS. No Rust/WASM bridge required for any of them.

Co-Authored-By: claude-flow <ruv@ruv.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant