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