Skip to content

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

feat(host_gates): introduce graph_json module for path validation

Steven Enamakel4c902f5d8562
diff --git a/crates/openhuman-core/src/flows/host_gates/graph_json.rs b/crates/openhuman-core/src/flows/host_gates/graph_json.rs
new file mode 100644
index 0000000000..ed3446740f
--- /dev/null
+++ b/crates/openhuman-core/src/flows/host_gates/graph_json.rs
@@ -0,0 +1,25 @@
+//! Read-only traversal helpers for TinyFlows' normalized workflow JSON.
+
+use serde_json::Value;
+
+pub(crate) struct GraphNode<'a> {
+ pub(crate) id: &'a str,
+ pub(crate) kind: &'a str,
+ pub(crate) config: &'a Value,
+}
+
+/// Iterates structurally valid nodes from TinyFlows' normalized graph JSON.
+pub(crate) fn nodes(graph: &Value) -> impl Iterator<Item = GraphNode<'_>> {
+ graph
+ .get("nodes")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .filter_map(|node| {
+ Some(GraphNode {
+ id: node.get("id")?.as_str()?,
+ kind: node.get("kind")?.as_str()?,
+ config: node.get("config").unwrap_or(&Value::Null),
+ })
+ })
+}
diff --git a/crates/openhuman-core/src/flows/host_gates/mod.rs b/crates/openhuman-core/src/flows/host_gates/mod.rs
index 083df9ec74..e8522e7256 100644
--- a/crates/openhuman-core/src/flows/host_gates/mod.rs
+++ b/crates/openhuman-core/src/flows/host_gates/mod.rs
@@ -2,6 +2,7 @@
mod agent_refs;
mod connections;
+mod graph_json;
mod tool_contracts;
mod upload_paths;
diff --git a/crates/openhuman-core/src/flows/host_gates/upload_paths.rs b/crates/openhuman-core/src/flows/host_gates/upload_paths.rs
index 353291bb54..19cadf4008 100644
--- a/crates/openhuman-core/src/flows/host_gates/upload_paths.rs
+++ b/crates/openhuman-core/src/flows/host_gates/upload_paths.rs
@@ -1,5 +1,5 @@
use serde_json::Value;
-use tinyflows::model::{NodeKind, WorkflowGraph};
+use super::graph_json::nodes;
/// Author-gate for `oh:storage_upload_file`: its literal `path` arg must be
/// workspace-relative. Uploads are confined to the agent workspace by the
@@ -13,11 +13,11 @@ use tinyflows::model::{NodeKind, WorkflowGraph};
/// Only LITERAL paths are checked: a `=`-expression resolves from upstream data
/// at runtime and is out of scope here (the runtime check still applies). An
/// absent `path` is left to the required-arg gate.
-pub(crate) fn validate_upload_paths(graph: &WorkflowGraph) -> Vec<String> {
+pub(crate) fn validate_upload_paths(graph: &Value) -> Vec<String> {
const UPLOAD_SLUG: &str = "oh:storage_upload_file";
let mut errors = Vec::new();
- for node in &graph.nodes {
- if node.kind != NodeKind::ToolCall {
+ for node in nodes(graph) {
+ if node.kind != "tool_call" {
continue;
}
if node.config.get("slug").and_then(Value::as_str) != Some(UPLOAD_SLUG) {