Skip to main content

somatize_runtime/runner/
mod.rs

1//! Runner module — trait-based execution contracts.
2//!
3//! A [`Runner`] defines the contract for executing plans (fit + forward).
4//! [`LocalRunner`] executes locally using the Executor.
5//! The worker's `RemoteRunner` prepares the environment and delegates to `LocalRunner`.
6
7pub mod local;
8
9use somatize_compiler::ExecutionPlan;
10use somatize_core::cache::CacheStore;
11use somatize_core::error::Result;
12use somatize_core::value::Value;
13use std::collections::HashMap;
14
15use crate::EventBus;
16use crate::filter_library::FilterLibrary;
17use std::sync::Arc;
18
19/// Contract for executing plans. Every execution mode (local, remote, stream)
20/// implements this trait. One interface, polymorphic dispatch.
21pub trait Runner: Send + Sync {
22    /// Train: fit each filter, forward to propagate outputs.
23    /// Returns (last output, trained states per node).
24    fn fit(
25        &self,
26        plan: &ExecutionPlan,
27        filters: &FilterLibrary,
28        cache: &dyn CacheStore,
29        event_bus: &Arc<EventBus>,
30        input: &Value,
31        y: Option<&Value>,
32    ) -> Result<(Value, HashMap<String, Value>)>;
33
34    /// Inference: forward data through the compiled plan.
35    fn forward(
36        &self,
37        plan: &ExecutionPlan,
38        filters: &FilterLibrary,
39        cache: &dyn CacheStore,
40        event_bus: &Arc<EventBus>,
41        input: &Value,
42    ) -> Result<Value>;
43}
44
45pub use local::LocalRunner;