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;
8pub mod remote;
9
10use somatize_compiler::ExecutionPlan;
11use somatize_core::cache::CacheStore;
12use somatize_core::error::Result;
13use somatize_core::value::Value;
14use std::collections::HashMap;
15
16use crate::EventBus;
17use crate::filter_library::FilterLibrary;
18use std::sync::Arc;
19
20/// Contract for executing plans. Every execution mode (local, remote, stream)
21/// implements this trait. One interface, polymorphic dispatch.
22pub trait Runner: Send + Sync {
23    /// Train: fit each filter, forward to propagate outputs.
24    /// Returns (last output, all node outputs).
25    fn fit(
26        &self,
27        plan: &ExecutionPlan,
28        filters: &FilterLibrary,
29        cache: &dyn CacheStore,
30        event_bus: &Arc<EventBus>,
31        input: &Value,
32        y: Option<&Value>,
33    ) -> Result<(Value, HashMap<String, Value>)>;
34
35    /// Inference: forward data through the compiled plan.
36    fn forward(
37        &self,
38        plan: &ExecutionPlan,
39        filters: &FilterLibrary,
40        cache: &dyn CacheStore,
41        event_bus: &Arc<EventBus>,
42        input: &Value,
43    ) -> Result<Value>;
44}
45
46pub use local::LocalRunner;
47pub use remote::{RemoteRunner, Transport};