Skip to content

docs(adr-001): event-driven anomaly example using SubLinear primitives - #33

Merged
ruvnet merged 1 commit into
mainfrom
adr/event-driven-example
May 19, 2026
Merged

ruvnet merged 1 commit into
mainfrom
adr/event-driven-example

Conversation

@ruvnet

@ruvnet ruvnet commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds `examples/event_driven_anomaly.rs` — the canonical RuView / Cognitum inner-loop demo using every SubLinear primitive shipped in this session (#26–#32). Other repos can grep this for the pattern.

What it demonstrates

  1. Build a 256-node strict-DD ring-stencil network (`nnz ≈ 1280`).
  2. Compute baseline `x_prev = A⁻¹·b_prev` once (89 µs, Linear, one-shot).
  3. Stream 5 single-sensor events as sparse RHS deltas.
  4. For each event:
    • `closure_indices` over `delta.indices` at depth 4 → 17 rows
    • `solve_on_change_sublinear` over the closure (no `n`-scan)
    • `contrastive_solve_on_change_sublinear` for top-3 anomalies

Sample output

```
event closure latency_us top_anomaly score
──────────────────────────────────────────────────────────────────────────
sensor #42 spike 17 1102 42 0.2520
sensor #117 drift 17 1026 117 0.0672
sensor #200 spike 17 1046 200 0.3528
sensor #7 dropout 17 1891 7 0.5391
sensor #155 outlier 17 1436 155 0.5460
```

Architectural property holds:

  • Closure size (17 rows) is independent of `n=256`.
  • Each event resolves in ~1-2 ms regardless of perturbation site.
  • Top anomaly is correctly identified at every perturbation point.

This is the runnable proof that ADR-001's "wake on event, never scan n" claim is real working code.

Run

```bash
cargo run --release --example event_driven_anomaly
```

Test plan

  • `cargo run --release --example event_driven_anomaly` succeeds + prints expected output
  • Full CI

🤖 Generated with claude-flow

The canonical RuView / Cognitum inner-loop demo. ADR-001 thesis:
intelligence is sparse, event-driven, sub-linear, coherence-gated
activation. This example concretises the thesis on a sensor-network
workload that other repos (RuView, Cognitum, Ruflo) can grep for the
pattern.

Workflow:
  1. Build a 256-node strict-DD ring-stencil network (nnz ≈ 1280).
  2. Compute baseline x_prev = A⁻¹·b_prev once (89 µs, Linear).
  3. Stream 5 single-sensor events as sparse RHS deltas.
  4. For each event:
     - closure_indices over delta.indices at depth 4 → 17 rows
     - solve_on_change_sublinear over the closure (no n-scan)
     - contrastive_solve_on_change_sublinear for top-3 anomalies

Output demonstrates the architectural property:
- Closure size (17 rows) is independent of n=256
- Each event resolves in ~1-2 ms regardless of where in the network
- Top anomaly is correctly identified at the perturbation site

Run:
  cargo run --release --example event_driven_anomaly

This is the runnable proof that ADR-001's "wake on event, never scan
n" claim is real working code.

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