Files
zesdex/apps/infrastructure/src/workflow/engine/execution.rs
T

28 lines
880 B
Rust
Raw Normal View History

//! Workflow execution — runs a parsed workflow script phase by phase.
use anyhow::Result;
use tracing::{info, instrument};
use crate::tools::ToolCtx;
use crate::workflow::engine::primitives::execute_primitive;
use zesdex_domain::workflow::WorkflowScript;
/// Execute each phase of a workflow script sequentially.
///
/// Flow: for each phase → execute_primitive → collect result.
#[instrument(skip(tool_ctx))]
pub async fn execute_workflow(script: &WorkflowScript, tool_ctx: &ToolCtx) -> Result<Vec<String>> {
info!(
"Executing workflow: {} ({} phases)",
script.name,
script.phases.len()
);
let mut results = Vec::new();
for phase in &script.phases {
info!("Executing phase: {}", phase.name);
let result = execute_primitive(&phase.directive, tool_ctx).await?;
results.push(result);
}
Ok(results)
}