Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(flows): route trigger warnings through bus validation

Steven Enamakel3e680130db38
diff --git a/crates/openhuman-core/src/flows/ops/builder_gates.rs b/crates/openhuman-core/src/flows/ops/builder_gates.rs
index df103ae01c..f3cc931fd2 100644
--- a/crates/openhuman-core/src/flows/ops/builder_gates.rs
+++ b/crates/openhuman-core/src/flows/ops/builder_gates.rs
@@ -144,8 +144,12 @@ pub(crate) async fn build_builder_proposal(
));
}
- let summary = tinyflows::summary::summarize(graph);
- let mut warnings = graph_trigger_warnings(graph);
+ let graph_json = serde_json::to_value(graph).map_err(|error| error.to_string())?;
+ let analysis = super::validation::validate_over_bus(ctx, config, graph_json).await?;
+ let summary = analysis
+ .summary
+ .ok_or_else(|| "TinyFlows validation returned no graph summary".to_string())?;
+ let mut warnings = analysis.warnings;
match graph_wiring_warnings(ctx, config, graph).await {
Ok(wiring_warnings) => warnings.extend(wiring_warnings),
Err(error) => {
diff --git a/crates/openhuman-core/src/flows/ops/triggers.rs b/crates/openhuman-core/src/flows/ops/triggers.rs
index 74b273058b..89778f3e12 100644
--- a/crates/openhuman-core/src/flows/ops/triggers.rs
+++ b/crates/openhuman-core/src/flows/ops/triggers.rs
@@ -37,14 +37,38 @@ pub async fn flows_set_enabled(
// line — so an enable of a flow that will never fire itself (webhook,
// chat_message, form, …) is impossible to miss at the call site.
if enabled {
- for warning in graph_trigger_warnings(&flow.graph) {
- tracing::warn!(
+ match serde_json::to_value(&flow.graph) {
+ Ok(graph) => match super::validation::validate_over_bus(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ config,
+ graph,
+ )
+ .await
+ {
+ Ok(analysis) => {
+ for warning in analysis.warnings {
+ tracing::warn!(
+ target: "flows",
+ flow_id = %id,
+ warning = %warning,
+ "[flows] flows_set_enabled: enabling a flow whose trigger kind does not fire yet"
+ );
+ logs.push(format!("warning: {warning}"));
+ }
+ }
+ Err(error) => tracing::warn!(
+ target: "flows",
+ flow_id = %id,
+ %error,
+ "[flows] flows_set_enabled: TinyFlows warning analysis failed"
+ ),
+ },
+ Err(error) => tracing::warn!(
target: "flows",
flow_id = %id,
- warning = %warning,
- "[flows] flows_set_enabled: enabling a flow whose trigger kind does not fire yet"
- );
- logs.push(format!("warning: {warning}"));
+ %error,
+ "[flows] flows_set_enabled: graph serialization failed during warning analysis"
+ ),
}
}