Skip to main content

ergo_runtime/runtime/
mod.rs

1pub mod execute;
2pub mod types;
3pub mod validate;
4
5pub use execute::{execute, execute_with_metadata};
6pub use types::*;
7pub use validate::validate;
8
9#[cfg(test)]
10mod tests;
11
12use crate::cluster::{ExpandedGraph, PrimitiveCatalog};
13
14#[derive(Debug)]
15#[non_exhaustive]
16pub enum RuntimeError {
17    Validation(types::GraphValidationError),
18    Execution(types::ExecError),
19}
20
21/// Canonical execution entrypoint.
22/// Validates the expanded graph before executing it with the provided registries and context.
23pub fn run<C: PrimitiveCatalog>(
24    expanded: &ExpandedGraph,
25    catalog: &C,
26    registries: &types::Registries,
27    ctx: &types::ExecutionContext,
28) -> Result<types::ExecutionReport, RuntimeError> {
29    let validated = validate(expanded, catalog).map_err(RuntimeError::Validation)?;
30    execute(&validated, registries, ctx).map_err(RuntimeError::Execution)
31}