Skip to main content

noether_engine/executor/
mod.rs

1// Native-only executor backends: require Nix, OS processes, LLM, or SQLite.
2#[cfg(feature = "native")]
3pub mod composite;
4#[cfg(feature = "native")]
5pub mod isolation;
6#[cfg(feature = "native")]
7pub mod nix;
8#[cfg(feature = "native")]
9pub mod runtime;
10
11// Always-available executor implementations.
12pub mod budget;
13pub mod inline;
14pub mod mock;
15pub mod pure_cache;
16pub mod runner;
17pub mod stages;
18
19pub use inline::InlineRegistry;
20
21use noether_core::stage::StageId;
22
23#[derive(Debug, thiserror::Error)]
24pub enum ExecutionError {
25    #[error("stage {0:?} not found")]
26    StageNotFound(StageId),
27    #[error("stage {stage_id:?} failed: {message}")]
28    StageFailed { stage_id: StageId, message: String },
29    #[error("stage {stage_id:?} timed out after {timeout_secs}s")]
30    TimedOut {
31        stage_id: StageId,
32        timeout_secs: u64,
33    },
34    #[error("cost budget exceeded: spent {spent_cents}¢ of {budget_cents}¢ limit")]
35    BudgetExceeded { spent_cents: u64, budget_cents: u64 },
36    #[error("retry exhausted after {attempts} attempts for stage {stage_id:?}")]
37    RetryExhausted { stage_id: StageId, attempts: u32 },
38    #[error("remote call to {url} failed: {reason}")]
39    RemoteCallFailed { url: String, reason: String },
40}
41
42/// Pluggable execution interface for individual stages.
43pub trait StageExecutor {
44    fn execute(
45        &self,
46        stage_id: &StageId,
47        input: &serde_json::Value,
48    ) -> Result<serde_json::Value, ExecutionError>;
49}