Skip to content

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

chore(ops): gate outbound side-effect check behind test-only import

Steven Enamakel5e5f0670a3fb
diff --git a/src/openhuman/flows/import_tests.rs b/src/openhuman/flows/import_tests.rs
new file mode 100644
index 0000000000..bc620b20cf
--- /dev/null
+++ b/src/openhuman/flows/import_tests.rs
@@ -0,0 +1,90 @@
+//! Host-side coverage for the n8n importer, for the one property the crate
+//! cannot assert on its own.
+//!
+//! `tinyflows_catalog::import::n8n` tests its own mapping. What it cannot test
+//! is that an imported graph then clears *this host's* gates: an import that
+//! produced a graph `propose_workflow` / `revise_workflow` / `save_workflow`
+//! would refuse is a broken import even though every mapping assertion passed.
+
+#[cfg(test)]
+mod tests {
+ use serde_json::json;
+ use tinyflows_catalog::import::n8n::map_n8n_workflow;
+
+
+
+ /// Imports a small n8n fixture that uses `$json` bindings end-to-end
+ /// through the exact same path `ops::flows_import` takes (map →
+ /// re-serialize → `validate_and_migrate_graph`), then runs the imported
+ /// graph through the domain's own binding-resolvability hard gate
+ /// (`ops::validate_binding_resolvability`, the same gate
+ /// `propose_workflow`/`revise_workflow`/`save_workflow` enforce before
+ /// accepting ANY graph — see `ops.rs`'s "Enforcing binding-resolvability
+ /// gate" section) and confirms it is accepted with zero errors, exactly
+ /// as `ops_tests.rs`'s `binding_to_agent_with_matching_schema_is_accepted`
+ /// exercises the gate for a hand-authored graph.
+ #[test]
+ fn imported_json_bindings_pass_binding_resolvability_and_resolve_the_real_item() {
+ use crate::openhuman::flows::ops::{
+ validate_and_migrate_graph, validate_binding_resolvability,
+ };
+
+ let wf = json!({
+ "name": "json-binding-import",
+ "nodes": [
+ { "id": "t", "name": "Webhook", "type": "n8n-nodes-base.webhook" },
+ { "id": "h", "name": "Notify", "type": "n8n-nodes-base.httpRequest",
+ "parameters": {
+ "url": "={{ $json.callback_url }}",
+ "requestMethod": "POST"
+ } }
+ ],
+ "connections": {
+ "Webhook": { "main": [[{ "node": "Notify", "type": "main", "index": 0 }]] }
+ }
+ });
+
+ let mapped = map_n8n_workflow(&wf).expect("map");
+ // No warning for the `$json.callback_url` binding — it's the trivial
+ // translatable case.
+ assert!(
+ !mapped
+ .warnings
+ .iter()
+ .any(|w| w.contains("callback_url") || w.contains("not automatically translated")),
+ "{:?}",
+ mapped.warnings
+ );
+
+ let http_node = mapped.graph.node("h").expect("http node");
+ assert_eq!(http_node.config["url"], json!("=.item.callback_url"));
+
+ // Re-enter the same migrate + validate path `flows_import` uses.
+ let value = serde_json::to_value(&mapped.graph).expect("serialize graph");
+ let graph =
+ validate_and_migrate_graph(value).expect("imported graph is structurally valid");
+
+ // The domain's hard binding-resolvability gate accepts the imported
+ // graph — the same gate a hand-authored graph must clear before
+ // `propose_workflow`/`save_workflow` will accept it.
+ assert!(
+ validate_binding_resolvability(&graph).is_empty(),
+ "{:?}",
+ validate_binding_resolvability(&graph)
+ );
+
+ // The direct proof this whole importer exists to guarantee: the
+ // translated binding actually resolves the real upstream item field
+ // at runtime, evaluated against a scope shaped like the tinyflows
+ // engine's real `expr_scope_for` — NOT null, which is exactly what
+ // the pre-fix `=.callback_url` translation would have produced.
+ let http_node = graph.node("h").expect("http node");
+ let scope = json!({
+ "item": { "callback_url": "https://example.com/hook" },
+ "items": [{ "callback_url": "https://example.com/hook" }],
+ "run": {},
+ "nodes": {},
+ });
+ let resolved = tinyflows::expr::evaluate(&http_node.config["url"], &scope);
+ assert_eq!(resolved, json!("https://example.com/hook"));
+ }}
diff --git a/src/openhuman/flows/ops.rs b/src/openhuman/flows/ops.rs
index 100b42813e..d8e80a918b 100644
--- a/src/openhuman/flows/ops.rs
+++ b/src/openhuman/flows/ops.rs
@@ -16,9 +16,13 @@ use tinyflows::model::{NodeKind, TriggerKind, WorkflowGraph};
// `ops::` scope because the agent tools and this module's tests already name
// them there.
pub(crate) use tinyflows_catalog::graph_policy::{
- enforce_side_effect_approval, graph_has_actionable_nodes, graph_has_outbound_side_effect,
- trigger_is_automatic,
+ enforce_side_effect_approval, graph_has_actionable_nodes, trigger_is_automatic,
};
+// Reached only by this module's own tests, which assert the host resolves the
+// predicate the two save rules are built on — `enforce_side_effect_approval`
+// is what production calls.
+#[cfg(test)]
+pub(crate) use tinyflows_catalog::graph_policy::graph_has_outbound_side_effect;
use tokio_util::sync::CancellationToken;
use crate::openhuman::agent::turn_origin::{with_origin, AgentTurnOrigin, TrustedAutomationSource};
diff --git a/vendor/tinyflows b/vendor/tinyflows
index 39b385ad4b..0dc36b7b69 160000
--- a/vendor/tinyflows
+++ b/vendor/tinyflows
@@ -1 +1 @@
-Subproject commit 39b385ad4ba8924284fb06b719ad26e813d52676
+Subproject commit 0dc36b7b69832b63c94da1aa585749b6b012a51b