Skip to content

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

refactor(flows): introduce graph helper function and update tests

Steven Enamakel1179d267889a
diff --git a/crates/openhuman-core/src/flows/catalogue_tests.rs b/crates/openhuman-core/src/flows/catalogue_tests.rs
index 1f92923807..2faceb966b 100644
--- a/crates/openhuman-core/src/flows/catalogue_tests.rs
+++ b/crates/openhuman-core/src/flows/catalogue_tests.rs
@@ -16,15 +16,19 @@ fn node(id: &str, kind: NodeKind, config: serde_json::Value) -> Node {
}
}
+fn graph(nodes: Vec<Node>) -> serde_json::Value {
+ serde_json::json!({
+ "nodes": serde_json::to_value(nodes).unwrap(),
+ "edges": []
+ })
+}
+
fn flow(name: &str, enabled: bool, nodes: Vec<Node>) -> Flow {
Flow {
id: "flow-abc-123".to_string(),
name: name.to_string(),
enabled,
- graph: serde_json::json!({
- "nodes": serde_json::to_value(nodes).unwrap(),
- "edges": []
- }),
+ graph: graph(nodes),
created_at: String::new(),
updated_at: String::new(),
last_run_at: None,
@@ -179,20 +183,22 @@ fn a_saved_flow_reaches_the_catalogue_with_its_real_id() {
let tmp = TempDir::new().unwrap();
let config = store_config(&tmp);
- let graph = WorkflowGraph {
- nodes: vec![
+ let graph = graph(vec![
node(
"t",
NodeKind::Trigger,
serde_json::json!({ "trigger_kind": "manual" }),
),
node("a", NodeKind::Agent, serde_json::json!({})),
- ],
- ..Default::default()
- };
- let saved =
- super::super::store::create_flow(&config, "Weekly Report".to_string(), graph, false, true)
- .expect("flow saves");
+ ]);
+ let saved = super::super::store::create_flow(
+ &config,
+ "Weekly Report".to_string(),
+ graph,
+ false,
+ )
+ .expect("flow saves")
+ .workflow;
let entries = flow_entries(&config);
assert_eq!(entries.len(), 1, "the saved flow must appear: {entries:?}");
@@ -214,16 +220,13 @@ fn entries_are_sorted_by_name_so_the_prompt_prefix_is_stable() {
// unrelated to the conversation.
let tmp = TempDir::new().unwrap();
let config = store_config(&tmp);
- let graph = WorkflowGraph {
- nodes: vec![node(
+ let graph = graph(vec![node(
"trigger",
NodeKind::Trigger,
serde_json::json!({ "trigger_kind": "manual" }),
- )],
- ..Default::default()
- };
+ )]);
for name in ["Zebra", "Alpha", "Mango"] {
- super::super::store::create_flow(&config, name.to_string(), graph.clone(), false, true)
+ super::super::store::create_flow(&config, name.to_string(), graph.clone(), false)
.expect("flow saves");
}
let names: Vec<String> = flow_entries(&config).into_iter().map(|e| e.name).collect();
diff --git a/crates/openhuman-core/src/flows/ops.rs b/crates/openhuman-core/src/flows/ops.rs
index 978ecfc3cf..5efeed31c1 100644
--- a/crates/openhuman-core/src/flows/ops.rs
+++ b/crates/openhuman-core/src/flows/ops.rs
@@ -34,8 +34,6 @@ use std::collections::HashSet;
use std::sync::Arc;
use serde_json::{json, Value};
-#[cfg(test)]
-use tinyflows::model::{NodeKind, WorkflowGraph};
// Graphs and Catalog/Runs records cross the module boundary as bus DTOs.
use crate::config::Config;
use crate::core::Outcome;
diff --git a/crates/openhuman-core/src/flows/ops_support_tests.rs b/crates/openhuman-core/src/flows/ops_support_tests.rs
index 9a173b37b9..5043a3ae94 100644
--- a/crates/openhuman-core/src/flows/ops_support_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_support_tests.rs
@@ -1,12 +1,11 @@
use super::*;
// compute_approval_manifest (save-time pre-authorization card)
-pub(super) fn manifest_graph() -> WorkflowGraph {
- structurally_valid_graph(manifest_graph_json())
+pub(super) fn manifest_graph() -> Value {
+ manifest_graph_json()
}
-/// The same fixture in its wire form, for the RPCs that take a candidate
-/// `graph` payload rather than a deserialized [`WorkflowGraph`].
+/// The fixture as TinyFlows' normalized graph JSON, as required by the bus.
pub(super) fn manifest_graph_json() -> Value {
json!({
"name": "manifest-fixture",