fix(wfe-yaml): replace SubWorkflow placeholder with real implementation

The YAML compiler was using SubWorkflowPlaceholderStep that returned
next() immediately. Replaced with real SubWorkflowStep from wfe-core
that starts child workflows and waits for completion events.

Added regression test verifying the compiled factory produces a step
that calls host_context.start_workflow() and returns wait_for_event.
This commit is contained in:
2026-03-26 15:58:47 +00:00
parent 20f32531b7
commit fe65d2debc
3 changed files with 95 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ use crate::executors::deno::{DenoConfig, DenoPermissions, DenoStep};
use wfe_buildkit::{BuildkitConfig, BuildkitStep};
#[cfg(feature = "containerd")]
use wfe_containerd::{ContainerdConfig, ContainerdStep};
use wfe_core::primitives::sub_workflow::SubWorkflowStep;
use crate::schema::{WorkflowSpec, YamlErrorBehavior, YamlStep};
/// Configuration for a sub-workflow step.
@@ -23,30 +24,6 @@ pub struct SubWorkflowConfig {
pub output_keys: Vec<String>,
}
/// Placeholder step body for sub-workflow steps.
///
/// This is a compile-time placeholder. When wfe-core provides a real
/// `SubWorkflowStep`, it should replace this. The placeholder always
/// returns `ExecutionResult::Next` so compilation and basic tests work.
#[derive(Debug, Default)]
pub struct SubWorkflowPlaceholderStep {
pub workflow_id: String,
pub version: u32,
pub output_keys: Vec<String>,
}
#[async_trait::async_trait]
impl StepBody for SubWorkflowPlaceholderStep {
async fn run(
&mut self,
context: &wfe_core::traits::StepExecutionContext<'_>,
) -> wfe_core::Result<wfe_core::models::ExecutionResult> {
let _ = context;
// Placeholder: a real implementation would start the child workflow.
Ok(wfe_core::models::ExecutionResult::next())
}
}
/// Factory type alias for step creation closures.
pub type StepFactory = Box<dyn Fn() -> Box<dyn StepBody> + Send + Sync>;
@@ -346,10 +323,13 @@ fn build_step_config_and_factory(
})?;
let config_clone = sub_config.clone();
let factory: StepFactory = Box::new(move || {
Box::new(SubWorkflowPlaceholderStep {
Box::new(SubWorkflowStep {
workflow_id: config_clone.workflow_id.clone(),
version: config_clone.version,
output_keys: config_clone.output_keys.clone(),
inputs: serde_json::Value::Null,
input_schema: None,
output_schema: None,
}) as Box<dyn StepBody>
});
Ok((key, value, factory))