The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(flows): validate host gate input shape
Steven Enamakel6cb59670ba04
diff --git a/crates/openhuman-core/src/flows/authoring_host.rs b/crates/openhuman-core/src/flows/authoring_host.rsindex 2dca3bb342..33089c4208 100644--- a/crates/openhuman-core/src/flows/authoring_host.rs+++ b/crates/openhuman-core/src/flows/authoring_host.rs@@ -64,6 +64,7 @@ impl Callbacks {let config = Arc::clone(&self.config);let context = self.context.clone();self.in_context(async move {+ crate::flows::host_gates::validate_host_gate_input_shape(&graph)?;match stage.as_str() {tinyflows_bus::host::TOOL_POLICY => {Ok(crate::flows::host_gates::validate_upload_paths(&graph))diff --git a/crates/openhuman-core/src/flows/authoring_host_tests.rs b/crates/openhuman-core/src/flows/authoring_host_tests.rsindex 6e4273f32b..899d037314 100644--- a/crates/openhuman-core/src/flows/authoring_host_tests.rs+++ b/crates/openhuman-core/src/flows/authoring_host_tests.rs@@ -51,6 +51,32 @@ async fn check_gate_rejects_a_tool_node_without_its_id() {).unwrap();+ let valid = proxy+ .call::<Vec<String>>(+ tinyflows_bus::host::CHECK_GATE,+ (+ tinyflows_bus::host::TOOL_POLICY,+ json!({+ "nodes": [{+ "id": "upload",+ "kind": "tool_call",+ "name": "Upload",+ "config": {+ "slug": "oh:storage_upload_file",+ "args": {"path": "report.html"}+ }+ }],+ "edges": []+ }),+ ),+ )+ .await+ .expect("a valid normalized graph reaches the registered host callback");+ assert!(+ valid.is_empty(),+ "valid relative upload should pass: {valid:?}"+ );+let result = proxy.call::<Vec<String>>(tinyflows_bus::host::CHECK_GATE,@@ -71,9 +97,10 @@ async fn check_gate_rejects_a_tool_node_without_its_id() {).await;+ let error = result.expect_err("a node without an id is malformed");assert!(- result.is_err(),- "a node without an id is malformed: {result:?}"+ error.to_string().contains("node 0"),+ "expected a node-shape error, got {error}");}diff --git a/crates/openhuman-core/src/flows/host_gates/graph_json.rs b/crates/openhuman-core/src/flows/host_gates/graph_json.rsindex ed3446740f..902c14a524 100644--- a/crates/openhuman-core/src/flows/host_gates/graph_json.rs+++ b/crates/openhuman-core/src/flows/host_gates/graph_json.rs@@ -8,6 +8,29 @@ pub(crate) struct GraphNode<'a> {pub(crate) config: &'a Value,}+/// Rejects malformed node identity fields before a host callback evaluates a+/// gate. TinyFlows has already normalized the graph; this preserves the bus+/// boundary's required JSON shape without parsing an engine-owned AST here.+pub(crate) fn validate_host_gate_input_shape(graph: &Value) -> Result<(), String> {+ let nodes = graph+ .get("nodes")+ .and_then(Value::as_array)+ .ok_or_else(|| "workflow graph must contain a node array".to_string())?;+ for (index, node) in nodes.iter().enumerate() {+ if node.get("id").and_then(Value::as_str).is_none() {+ return Err(format!(+ "workflow graph node {index} must have a string `id`"+ ));+ }+ if node.get("kind").and_then(Value::as_str).is_none() {+ return Err(format!(+ "workflow graph node {index} must have a string `kind`"+ ));+ }+ }+ Ok(())+}+/// Iterates structurally valid nodes from TinyFlows' normalized graph JSON.pub(crate) fn nodes(graph: &Value) -> impl Iterator<Item = GraphNode<'_>> {graphdiff --git a/crates/openhuman-core/src/flows/host_gates/mod.rs b/crates/openhuman-core/src/flows/host_gates/mod.rsindex e8522e7256..80bcba5fdb 100644--- a/crates/openhuman-core/src/flows/host_gates/mod.rs+++ b/crates/openhuman-core/src/flows/host_gates/mod.rs@@ -10,6 +10,7 @@ pub(crate) use agent_refs::validate_agent_refs;pub(crate) use connections::validate_connection_refs;#[cfg(test)]pub(crate) use connections::validate_connection_refs_against;+pub(crate) use graph_json::validate_host_gate_input_shape;pub(crate) use tool_contracts::validate_tool_contracts;pub(crate) use upload_paths::validate_upload_paths;