Repository navigation
feat(adr-001): streaming event iterator over SubLinear orchestrator - #45
Merged
Merged
Conversation
The single-event call (auto-tuned contrastive orchestrator + coherence gate + PlanBudget) was complete after PR #40. Real callers — RuView agents watching sensor / log / metric streams, Cognitum reflex loops over a learning system — process an *iterator* of events, not a single one. This module lifts the single-event call into a stdlib Iterator adapter. Lands: src/stream.rs (new, 280 LOC) pub fn event_stream_iter<'a, I>(matrix, prev, events, config, budget) -> EventStreamIter<'a, I> where I: Iterator<Item = (SparseDelta, Vec<Precision>)> pub struct ProcessedEvent { event_idx, anomalies, latency, status } pub enum EventStatus { Solved, Skipped, BudgetRefused, Errored } pub struct EventStreamConfig { tolerance, k, skip_threshold (optional gate inputs) } pub struct EventStreamOp; // SubLinear class marker Pipeline per event: 1. delta_below_solve_threshold skip gate (if configured) 2. PlanBudget::try_consume (if supplied) — ends iterator on refusal 3. contrastive_solve_on_change_sublinear_auto for top-k Native composition with stdlib iterators: for event in event_stream_iter(matrix, prev, events, &cfg, Some(&mut budget)) { if event.status == EventStatus::Skipped { continue; } if event.status == EventStatus::BudgetRefused { break; } // process event.anomalies } src/lib.rs Re-exports event_stream_iter, ProcessedEvent, EventStatus, EventStreamConfig, EventStreamOp. .github/complexity-baseline.txt Adds EventStreamOp (SubLinear). Tests: 5 covering empty input, one-event-per-input with Solved status, skip-gate short-circuit on tiny delta, budget-exhausted terminating the stream, and op class compile-time check. Co-Authored-By: claude-flow <ruv@ruv.net>
1 of 2 tasks
ruvnet
added a commit
that referenced
this pull request
May 19, 2026
Companion to event_driven_anomaly.rs. The earlier example called the per-event primitives directly; this one uses the iterator adapter (PR #45) and composes it with stdlib's iterator chain — the native Rust pattern RuView / Cognitum / Ruflo would adopt. Demonstrates: - One event stream → one iterator chain → reports. - Coherence-gated skip on tiny deltas (latency 0). - PlanBudget cap on cumulative ops; iterator ends gracefully when budget exhausted. - Per-event latency tracked by the iterator. Sample output (10-event stream, budget=4 SubLinear ops): event # status latency_us top-anomaly ──────────────────────────────────────────── 0 Solved 73 row 7 1 Skipped 0 row — 2 Solved 43 row 22 3 Skipped 0 row — 4 Solved 41 row 40 5 Solved 42 row 51 6 Skipped 0 row — 7 BudgetRefused 0 row — Summary: 4 solved, 3 skipped by gate, 1 budget-refused The architecture line is fully realised: streaming surface with stdlib iterator composition, per-event SubLinear cost, O(|δ|) gate, O(1) budget consume. Co-Authored-By: claude-flow <ruv@ruv.net>
1 of 2 tasks
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 single-event call pattern (auto-tuned contrastive orchestrator + coherence gate + `PlanBudget`) was complete after PR #40. Real callers — RuView agents, Cognitum reflex loops — process an iterator of events, not a single one. This PR lifts the single-event call into a stdlib `Iterator` adapter.
API
```rust
pub fn event_stream_iter(
matrix: &dyn Matrix,
prev_solution: &[Precision],
events: I,
config: &EventStreamConfig,
budget: Option<&mut PlanBudget>,
) -> impl Iterator<Item = ProcessedEvent>
where I: Iterator<Item = (SparseDelta, Vec)>;
pub struct ProcessedEvent {
pub event_idx: usize,
pub anomalies: Vec,
pub latency: Duration,
pub status: EventStatus,
}
pub enum EventStatus { Solved, Skipped, BudgetRefused, Errored }
```
Pipeline per event
Composition
```rust
for event in event_stream_iter(matrix, prev, events, &cfg, Some(&mut budget)) {
match event.status {
EventStatus::Skipped => continue,
EventStatus::BudgetRefused => break,
EventStatus::Solved => process(event.anomalies),
EventStatus::Errored => log_and_continue(),
}
}
```
Native composition with `.filter()`, `.take()`, `.collect()`, etc.
Test plan
🤖 Generated with claude-flow