Skip to main content

Module stream

Module stream 

Source
Expand description

Streaming event iterator over the SubLinear orchestrator.

ADR-001’s primitives (closure, single-entry Neumann, contrastive orchestrator, coherence gate, witness, budget) compose into a per-event call pattern. Real callers — RuView agents watching sensor / log / metric streams, Cognitum reflex loops over a learning system, Ruflo inner-loop planners — process an iterator of events, not a single one.

This module lifts the single-event call into a stdlib Iterator adapter: feed it an event stream, get back an iterator of (event_idx, Vec<AnomalyRow>, latency_us) tuples. Native composition with .filter(), .take(), .collect(), etc.

Each yielded event:

  1. Probes the crate::coherence::delta_below_solve_threshold skip gate first. If the gate trips, yields an empty Vec and a near-zero latency — the “no event, no work” path.
  2. Otherwise calls crate::contrastive_solve_on_change_sublinear_auto to compute the SubLinear top-k anomalies for the event.
  3. Optionally consumes a slot from a caller-supplied crate::PlanBudget; if the budget refuses, the iterator ends.

The whole pipeline stays SubLinear per event, with the gate + budget short-circuits letting callers cap end-to-end cost.

Structs§

EventStreamConfig
Configuration for the event-stream iterator.
EventStreamIter
Iterator returned by event_stream_iter.
EventStreamOp
Op marker for event_stream_iter. Per-event class is the orchestrator’s — SubLinear on a strict-DD matrix.
ProcessedEvent
One processed event: the original index in the input stream, the top-k anomalies (empty if the gate skipped or budget refused), the wall-time spent on this event, and a status flag.

Enums§

EventStatus
What the orchestrator did with a single event.

Functions§

event_stream_iter
Process an iterator of (SparseDelta, b_new) events through the SubLinear orchestrator, yielding ProcessedEvents. The optional budget argument tracks cumulative consumption across the stream; when it refuses, the iterator yields one final BudgetRefused event and ends.