Skip to content

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

feat(flows): add builder tools for draft editing and validation

Steven Enamakelc94b9a703b2c
diff --git a/crates/openhuman-core/src/flows/README.md b/crates/openhuman-core/src/flows/README.md
index 6d58b91cba..41aa0489a4 100644
--- a/crates/openhuman-core/src/flows/README.md
+++ b/crates/openhuman-core/src/flows/README.md
@@ -45,7 +45,7 @@ the engine, the capability seam).
### Saving a flow
A graph arrives as raw JSON, from the canvas, an import, a draft promotion or
-an agent tool. `ops::validate_and_migrate_graph` (in [`ops/validation.rs`](./ops/validation.rs)) runs
+an agent tool. `tinyflows::authoring::validate_and_migrate_graph` runs
it through `tinyflows::migrate::migrate` to upgrade older schemas, deserializes
it into a `WorkflowGraph`, and rejects anything `tinyflows::validate::validate`
refuses. Engine-compatibility checks map topology problems onto
@@ -289,7 +289,7 @@ Top level:
- `ops::flows_create` / `ops::flows_update` (`ops/definitions.rs`,
[`ops/updates.rs`](./ops/updates.rs)): the save paths that enforce born-disabled and forced
approval.
-- `ops::validate_and_migrate_graph` (`ops/validation.rs`): the one
+- `tinyflows::authoring::validate_and_migrate_graph`: the one
structural-validation door.
- `run_builder_gates` (`ops/builder_gates.rs`): the agent-authored hard-gate
stack.
diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs b/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs
index 0b38182848..d1c988da43 100644
--- a/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/draft_edit.rs
@@ -128,7 +128,7 @@ impl Tool for EditWorkflowTool {
(Some(id), _, _) => match ops::flows_draft_get(&self.config, id) {
Ok(outcome) => {
let draft = outcome.value;
- match ops::migrate_and_deserialize_graph(draft.graph.clone()) {
+ match tinyflows::migrate::deserialize_graph(draft.graph.clone()) {
Ok(graph) => {
write_back_draft = Some(draft.id.clone());
// A draft may already be linked to a saved flow —
@@ -198,7 +198,7 @@ impl Tool for EditWorkflowTool {
}
},
(None, None, Some(graph_json)) => {
- match ops::migrate_and_deserialize_graph(graph_json.clone()) {
+ match tinyflows::migrate::deserialize_graph(graph_json.clone()) {
Ok(graph) => {
let name = graph.name.clone();
(graph, name)
diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
index 2263a1a723..ce98ab6269 100644
--- a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
@@ -8,7 +8,7 @@ use serde_json::Value;
use crate::config::Config;
use crate::flows::ops;
-use crate::flows::ops::validate_and_migrate_graph;
+use tinyflows::authoring::validate_and_migrate_graph;
use tinytools::{PermissionLevel, Tool, ToolResult};
// ─────────────────────────────────────────────────────────────────────────────
diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_validate.rs b/crates/openhuman-core/src/flows/builder_tools/draft_validate.rs
index aa57ec9225..ac2a4e43d2 100644
--- a/crates/openhuman-core/src/flows/builder_tools/draft_validate.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/draft_validate.rs
@@ -145,7 +145,7 @@ impl Tool for ValidateWorkflowTool {
// "gates passed" previously reported `ok: true` while silently
// skipping every hard gate.
let (gate_errors, gate_check_failed) = if validation.valid {
- match ops::migrate_and_deserialize_graph(graph_json) {
+ match tinyflows::migrate::deserialize_graph(graph_json) {
Ok(graph) => (ops::run_builder_gates(&self.config, &graph).await, false),
Err(e) => {
tracing::warn!(
diff --git a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs b/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
index 3038a5ea35..e50c0251e8 100644
--- a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
@@ -9,7 +9,7 @@ use tinyflows::model::WorkflowGraph;
use crate::config::Config;
use crate::flows::ops;
-use crate::flows::ops::validate_and_migrate_graph;
+use tinyflows::authoring::validate_and_migrate_graph;
use tinytools::{PermissionLevel, Tool, ToolResult};
use tinyflows::authoring_report::{self, AuthoringReport};
diff --git a/crates/openhuman-core/src/flows/builder_tools/persistence.rs b/crates/openhuman-core/src/flows/builder_tools/persistence.rs
index be9673ac09..fc633195cf 100644
--- a/crates/openhuman-core/src/flows/builder_tools/persistence.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/persistence.rs
@@ -9,7 +9,7 @@ use serde_json::{json, Value};
use crate::config::Config;
use crate::flows::ops;
-use crate::flows::ops::validate_and_migrate_graph;
+use tinyflows::authoring::validate_and_migrate_graph;
use tinytools::{PermissionLevel, Tool, ToolResult};
/// `create_workflow`: the gated create tool (audit F4/F12). Persists a NEW
@@ -387,7 +387,7 @@ impl Tool for SaveWorkflowTool {
// Composio args) were previously computed by propose/revise but never
// surfaced again at save time — add them here so the agent sees any
// non-fatal wiring gaps that remain in the final persisted graph.
- let mut warnings = ops::graph_trigger_warnings(&graph);
+ let mut warnings = tinyflows::triggers::graph_trigger_warnings(&graph);
warnings.extend(ops::graph_wiring_warnings(&self.config, &graph).await);
tracing::info!(
diff --git a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
index 0e8586c8cb..e214ebf9ef 100644
--- a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
@@ -124,7 +124,7 @@ async fn edit_workflow_does_not_persist_an_incompatible_saved_child_reference()
{ "from_node": "c", "to_node": "m" }
]
});
- let child_graph = ops::migrate_and_deserialize_graph(legacy_child).unwrap();
+ let child_graph = tinyflows::migrate::deserialize_graph(legacy_child).unwrap();
tinyflows::validate::validate(&child_graph).unwrap();
let child = crate::flows::store::create_flow(
&config,
diff --git a/crates/openhuman-core/src/flows/ops/approval_manifest.rs b/crates/openhuman-core/src/flows/ops/approval_manifest.rs
index 796e3aae03..1e499017fe 100644
--- a/crates/openhuman-core/src/flows/ops/approval_manifest.rs
+++ b/crates/openhuman-core/src/flows/ops/approval_manifest.rs
@@ -236,7 +236,7 @@ pub async fn flows_approval_manifest(
// `store::get_flow` already returns a migrated, deserialized graph.
(flow.graph, Some(id.to_string()))
}
- (None, Some(graph_json)) => (migrate_and_deserialize_graph(graph_json)?, None),
+ (None, Some(graph_json)) => (tinyflows::migrate::deserialize_graph(graph_json)?, None),
(None, None) => return Err("provide 'id' or 'graph'".to_string()),
};
diff --git a/crates/openhuman-core/src/flows/ops/builder_gates.rs b/crates/openhuman-core/src/flows/ops/builder_gates.rs
index e93fe59420..22da9fd12d 100644
--- a/crates/openhuman-core/src/flows/ops/builder_gates.rs
+++ b/crates/openhuman-core/src/flows/ops/builder_gates.rs
@@ -162,7 +162,7 @@ pub(crate) async fn validate_required_arg_resolvability(graph: &WorkflowGraph) -
/// opts that call into the *same* gates an agent save must pass, so the two
/// planes converge on one definition instead of diverging.
pub(crate) async fn strict_gate(config: &Config, graph_json: &Value) -> Result<(), String> {
- let graph = migrate_and_deserialize_graph(graph_json.clone())?;
+ let graph = tinyflows::migrate::deserialize_graph(graph_json.clone())?;
let structural = tinyflows::validate::validate_all(&graph);
if !structural.is_empty() {
let messages: Vec<String> = structural.iter().map(ToString::to_string).collect();
diff --git a/crates/openhuman-core/src/flows/ops/connections.rs b/crates/openhuman-core/src/flows/ops/connections.rs
index 6bd0e95856..85417854d4 100644
--- a/crates/openhuman-core/src/flows/ops/connections.rs
+++ b/crates/openhuman-core/src/flows/ops/connections.rs
@@ -316,7 +316,7 @@ pub async fn flows_required_connections(
config: &Config,
graph_json: Value,
) -> Result<Outcome<Value>, String> {
- let graph = migrate_and_deserialize_graph(graph_json)?;
+ let graph = tinyflows::migrate::deserialize_graph(graph_json)?;
let required = compute_required_connections(config, &graph).await;
Ok(Outcome::single_log(
json!({ "required_connections": required }),
diff --git a/crates/openhuman-core/src/flows/ops/validation.rs b/crates/openhuman-core/src/flows/ops/validation.rs
index 9df2fec733..12daabf8af 100644
--- a/crates/openhuman-core/src/flows/ops/validation.rs
+++ b/crates/openhuman-core/src/flows/ops/validation.rs
@@ -27,7 +27,7 @@ pub(super) fn ensure_config_aware_engine_compatible(
/// member that caused it (`nodes[1]: missing field ...`). The implementation is
/// `tinyflows::migrate::deserialize_graph`; this alias keeps the host's
/// call sites (and the authoring tools' error text) unchanged.
-pub(crate) use tinyflows::migrate::deserialize_graph as migrate_and_deserialize_graph;
+pub(crate) use tinyflows::migrate::deserialize_graph as tinyflows::migrate::deserialize_graph;
/// Checks literal `workflow_id` children reachable from an authoring candidate.
///
@@ -58,7 +58,7 @@ pub(crate) fn config_aware_engine_compatibility_errors(
config: &Config,
graph: &WorkflowGraph,
) -> Vec<String> {
- let direct = engine_compatibility_errors(graph);
+ let direct = tinyflows_catalog::validation::engine_compatibility_errors(graph);
if !direct.is_empty() {
return direct
.into_iter()
@@ -84,7 +84,7 @@ pub fn flows_validate(graph_json: Value) -> Outcome<tinyflows_catalog::FlowValid
// failure short-circuits with one error; a deserializable graph is then run
// through `validate_all` so the author sees every structural problem in one
// pass instead of one round-trip per error.
- let graph = match migrate_and_deserialize_graph(graph_json) {
+ let graph = match tinyflows::migrate::deserialize_graph(graph_json) {
Ok(graph) => graph,
Err(error) => {
tracing::debug!(target: "flows", %error, "[flows] flows_validate: graph could not be migrated/parsed");
@@ -107,7 +107,7 @@ pub fn flows_validate(graph_json: Value) -> Outcome<tinyflows_catalog::FlowValid
let structural = tinyflows::validate::validate_all(&graph);
if !structural.is_empty() {
- let error_details: Vec<_> = structural.iter().map(to_flow_validation_error).collect();
+ let error_details: Vec<_> = structural.iter().map(tinyflows_catalog::validation::to_flow_validation_error).collect();
let errors: Vec<String> = error_details.iter().map(|e| e.message.clone()).collect();
tracing::debug!(
target: "flows",
@@ -125,7 +125,7 @@ pub fn flows_validate(graph_json: Value) -> Outcome<tinyflows_catalog::FlowValid
);
}
- let error_details = engine_compatibility_errors(&graph);
+ let error_details = tinyflows_catalog::validation::engine_compatibility_errors(&graph);
if !error_details.is_empty() {
let errors = error_details
.iter()
diff --git a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
index d809724798..3d227b3246 100644
--- a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
@@ -96,7 +96,7 @@ async fn compute_required_connections_flags_missing_composio_toolkits() {
],
"edges": [ { "from_node": "t", "to_node": "send" } ]
});
- let graph = migrate_and_deserialize_graph(graph_json).unwrap();
+ let graph = tinyflows::migrate::deserialize_graph(graph_json).unwrap();
let required = compute_required_connections(&config, &graph).await;
assert_eq!(required.len(), 1);
assert_eq!(required[0]["toolkit"], "gmail");
@@ -120,7 +120,7 @@ async fn compute_required_connections_skips_native_and_http_nodes() {
{ "from_node": "search", "to_node": "http" }
]
});
- let graph = migrate_and_deserialize_graph(graph_json).unwrap();
+ let graph = tinyflows::migrate::deserialize_graph(graph_json).unwrap();
let required = compute_required_connections(&config, &graph).await;
assert!(
required.is_empty(),
diff --git a/crates/openhuman-core/src/flows/ops_tests.rs b/crates/openhuman-core/src/flows/ops_tests.rs
index 76893e2ac0..af39ba6c64 100644
--- a/crates/openhuman-core/src/flows/ops_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_tests.rs
@@ -74,7 +74,7 @@ fn referenced_child_graph(workflow_id: &str) -> Value {
}
fn structurally_valid_graph(value: Value) -> WorkflowGraph {
- let graph = migrate_and_deserialize_graph(value).expect("graph should deserialize");
+ let graph = tinyflows::migrate::deserialize_graph(value).expect("graph should deserialize");
tinyflows::validate::validate(&graph).expect("fixture should be structurally valid");
graph
}
diff --git a/crates/openhuman-core/src/flows/tools.rs b/crates/openhuman-core/src/flows/tools.rs
index 53067f3d15..0bb1c057d3 100644
--- a/crates/openhuman-core/src/flows/tools.rs
+++ b/crates/openhuman-core/src/flows/tools.rs
@@ -4,7 +4,7 @@
//! The user asks the assistant in chat to build an automation; the agent
//! calls this tool with a candidate `tinyflows::model::WorkflowGraph`. The
//! tool runs the graph through the exact same
-//! [`crate::flows::ops::validate_and_migrate_graph`] path
+//! [`tinyflows::authoring::validate_and_migrate_graph`] path
//! `flows_create` uses, and returns a `workflow_proposal` summary for the
//! chat UI's `WorkflowProposalCard` — it never persists anything itself.
//!
@@ -23,7 +23,8 @@ use async_trait::async_trait;
use serde_json::{json, Value};
use crate::config::Config;
-use crate::flows::ops::{build_builder_proposal, validate_and_migrate_graph};
+use crate::flows::ops::build_builder_proposal;
+use tinyflows::authoring::validate_and_migrate_graph;
use tinytools::{PermissionLevel, Tool, ToolResult};
pub struct ProposeWorkflowTool {
diff --git a/crates/openhuman-core/src/flows/tools_tests.rs b/crates/openhuman-core/src/flows/tools_tests.rs
index 0979d1f73d..22e6a8042c 100644
--- a/crates/openhuman-core/src/flows/tools_tests.rs
+++ b/crates/openhuman-core/src/flows/tools_tests.rs
@@ -356,7 +356,7 @@ async fn propose_workflow_rejects_an_incompatible_saved_child_reference() {
{ "from_node": "c", "to_node": "m" }
]
});
- let child_graph = crate::flows::ops::migrate_and_deserialize_graph(legacy_child)
+ let child_graph = tinyflows::migrate::deserialize_graph(legacy_child)
.expect("legacy child should deserialize");
tinyflows::validate::validate(&child_graph)
.expect("legacy child should remain structurally valid");