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
refactor: extract deserialize and subagent tests into separate files
Steven Enamakel1eae0646a2f1
diff --git a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rsindex b0b5da715f..6db288e368 100644--- a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs+++ b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs@@ -696,99 +696,5 @@ fn migrate_and_deserialize_graph_does_not_blame_a_node_for_a_top_level_fault() {);}-/// The member scan covers four arrays, and until now only `nodes` was ever-/// exercised — the other three arms were unreachable in the test suite while-/// looking correct by inspection.-///-/// Each case supplies a graph whose *only* fault is one member of one array, so-/// a failure here cannot be the top-level guard firing instead.-#[test]-fn migrate_and_deserialize_graph_names_the_member_in_inputs_agents_and_edges() {- // `WorkflowInput::name` is required; every other field defaults.- let bad_input = json!({- "inputs": [ { "type": "string" } ]- });- let err = migrate_and_deserialize_graph(bad_input).expect_err("input without `name`");- assert!(- err.starts_with("inputs[0]: "),- "expected the inputs arm to name the member, got: {err}"- );-- // `AgentDefinition::id` is required — `name` is #[serde(default)] here, so- // this is a different required field from the node case on purpose.- let bad_agent = json!({- "agents": [ { "name": "no id" } ]- });- let err = migrate_and_deserialize_graph(bad_agent).expect_err("agent without `id`");- assert!(- err.starts_with("agents[0]: "),- "expected the agents arm to name the member, got: {err}"- );-- // `Edge::from_node` / `to_node` are required.- let bad_edge = json!({- "edges": [ { "from_port": "main" } ]- });- let err = migrate_and_deserialize_graph(bad_edge).expect_err("edge without endpoints");- assert!(- err.starts_with("edges[0]: "),- "expected the edges arm to name the member, got: {err}"- );-}--/// The fallback: the graph's own fields are fine and no member is individually-/// at fault, yet the parse still fails — here `nodes` is a string rather than an-/// array, so the member scan has nothing to iterate.-///-/// This is the case that must NOT invent a location. Emptying the arrays for-/// the top-level probe also masks this fault, which is exactly why the bare-/// message has to survive as the last resort.-#[test]-fn migrate_and_deserialize_graph_falls_back_when_no_member_is_at_fault() {- let nodes_not_an_array = json!({- "name": "valid",- "nodes": "this is not an array"- });-- let err = migrate_and_deserialize_graph(nodes_not_an_array)- .expect_err("a non-array `nodes` must not deserialize");-- assert!(- !err.contains("nodes["),- "no member is at fault, so none may be named: {err}"- );- assert!(- err.contains("invalid type"),- "the original serde detail must survive the fallback: {err}"- );-}--/// A graph that is not a JSON object at all.-///-/// `tinyflows::migrate::migrate` passes it through rather than rejecting it —-/// it reads `schema_version` with `Value::get`, which is `None` on a non-object,-/// and stamps the version back only `if let Value::Object`. So this reaches the-/// error path with nothing to probe: no members, and no fields to iterate.-///-/// The requirement is negative. There is no location to report, so none may be-/// invented, and the caller must still get serde's own explanation.-#[test]-fn migrate_and_deserialize_graph_reports_a_non_object_graph_without_inventing_a_location() {- let not_an_object = json!("this is a string, not a workflow graph");-- let err = migrate_and_deserialize_graph(not_an_object)- .expect_err("a non-object graph must not deserialize");-- assert!(- !err.contains('['),- "nothing can be indexed here, so no index may appear: {err}"- );- assert!(- !err.contains(": invalid") || !err.starts_with("name"),- "no field may be named for a value that has no fields: {err}"- );- assert!(- err.contains("invalid type"),- "serde's own explanation must survive: {err}"- );-}+#[path = "ops_migration_deserialize_tests.rs"]+mod deserialize_tests;diff --git a/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs b/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rsnew file mode 100644index 0000000000..cf5d03e790--- /dev/null+++ b/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs@@ -0,0 +1,37 @@+use super::*;++/// The member scan covers four arrays, and until now only `nodes` was ever+/// exercised — the other three arms were unreachable in the test suite while+/// looking correct by inspection.+#[test]+fn migrate_and_deserialize_graph_names_the_member_in_inputs_agents_and_edges() {+ let bad_input = json!({ "inputs": [ { "type": "string" } ] });+ let err = migrate_and_deserialize_graph(bad_input).expect_err("input without `name`");+ assert!(err.starts_with("inputs[0]: "), "got: {err}");++ let bad_agent = json!({ "agents": [ { "name": "no id" } ] });+ let err = migrate_and_deserialize_graph(bad_agent).expect_err("agent without `id`");+ assert!(err.starts_with("agents[0]: "), "got: {err}");++ let bad_edge = json!({ "edges": [ { "from_port": "main" } ] });+ let err = migrate_and_deserialize_graph(bad_edge).expect_err("edge without endpoints");+ assert!(err.starts_with("edges[0]: "), "got: {err}");+}++#[test]+fn migrate_and_deserialize_graph_falls_back_when_no_member_is_at_fault() {+ let nodes_not_an_array = json!({ "name": "valid", "nodes": "this is not an array" });+ let err = migrate_and_deserialize_graph(nodes_not_an_array)+ .expect_err("a non-array `nodes` must not deserialize");+ assert!(!err.contains("nodes["), "got: {err}");+ assert!(err.contains("invalid type"), "got: {err}");+}++#[test]+fn migrate_and_deserialize_graph_reports_a_non_object_graph_without_inventing_a_location() {+ let err = migrate_and_deserialize_graph(json!("this is a string, not a workflow graph"))+ .expect_err("a non-object graph must not deserialize");+ assert!(!err.contains('['), "got: {err}");+ assert!(!err.contains(": invalid") || !err.starts_with("name"), "got: {err}");+ assert!(err.contains("invalid type"), "got: {err}");+}diff --git a/crates/openhuman-core/src/threads/transcript_view/transcript_view_subagent_tests.rs b/crates/openhuman-core/src/threads/transcript_view/transcript_view_subagent_tests.rsnew file mode 100644index 0000000000..81935b52d6--- /dev/null+++ b/crates/openhuman-core/src/threads/transcript_view/transcript_view_subagent_tests.rs@@ -0,0 +1,37 @@+use super::*;++#[test]+fn subagent_anchors_to_parent_turn_by_spawn_timestamp() {+ let dir = TempDir::new().unwrap();+ let root_stem = "800_orchestrator";+ let thread_id = "thr_anchor";+ let t1 = chrono::DateTime::from_timestamp(1_000_000, 0).unwrap().to_rfc3339();+ let t2 = chrono::DateTime::from_timestamp(2_000_000, 0).unwrap().to_rfc3339();+ let root_body = vec![+ r#"{"role":"user","content":"one","request_id":"req-1"}"#.to_string(),+ format!(r#"{{"role":"assistant","content":"a1","provider":"anthropic","model":"m","usage":{{"input":1,"output":1,"cached_input":0,"cost_usd":0.0}},"ts":"{t1}","iteration":1,"request_id":"req-1"}}"#),+ r#"{"role":"user","content":"two","request_id":"req-2"}"#.to_string(),+ format!(r#"{{"role":"assistant","content":"a2","provider":"anthropic","model":"m","usage":{{"input":1,"output":1,"cached_input":0,"cost_usd":0.0}},"ts":"{t2}","iteration":1,"request_id":"req-2"}}"#),+ ];+ let root_refs: Vec<&str> = root_body.iter().map(String::as_str).collect();+ write_raw(dir.path(), root_stem, thread_id, &root_refs);+ write_raw(dir.path(), &format!("{root_stem}__999950_coder"), thread_id, &[r#"{"role":"assistant","content":"coder work"}"#]);+ write_raw(dir.path(), &format!("{root_stem}__1000050_planner"), thread_id, &[r#"{"role":"assistant","content":"planner work"}"#]);++ let projected = project_thread(dir.path(), thread_id).expect("project thread");+ let mut anchors: Vec<(String, Option<String>)> = projected.items.iter().filter_map(|item| match item {+ DisplayItem::Subagent { request_id, items, .. } => {+ let marker = items.iter().find_map(|inner| match inner {+ DisplayItem::AssistantMessage { content, .. } => Some(content.clone()),+ _ => None,+ })?;+ Some((marker, request_id.clone()))+ }+ _ => None,+ }).collect();+ anchors.sort();+ assert_eq!(anchors, vec![+ ("coder work".to_string(), Some("req-1".to_string())),+ ("planner work".to_string(), Some("req-2".to_string())),+ ]);+}diff --git a/crates/openhuman-core/src/threads/transcript_view/transcript_view_tests.rs b/crates/openhuman-core/src/threads/transcript_view/transcript_view_tests.rsindex 2c5de789f2..680306fb1b 100644--- a/crates/openhuman-core/src/threads/transcript_view/transcript_view_tests.rs+++ b/crates/openhuman-core/src/threads/transcript_view/transcript_view_tests.rs@@ -706,75 +706,5 @@ fn append_transcript_turn_projects_full_display_shape() {assert!(!assistants[1].4, "final answer is not interim");}-#[test]-fn subagent_anchors_to_parent_turn_by_spawn_timestamp() {- let dir = TempDir::new().unwrap();- let root_stem = "800_orchestrator";- let thread_id = "thr_anchor";-- let t1 = chrono::DateTime::from_timestamp(1_000_000, 0)- .unwrap()- .to_rfc3339();- let t2 = chrono::DateTime::from_timestamp(2_000_000, 0)- .unwrap()- .to_rfc3339();-- // Two turns: req-1 (assistant ts t1), req-2 (assistant ts t2).- let root_body = vec![- r#"{"role":"user","content":"one","request_id":"req-1"}"#.to_string(),- format!(- r#"{{"role":"assistant","content":"a1","provider":"anthropic","model":"m","usage":{{"input":1,"output":1,"cached_input":0,"cost_usd":0.0}},"ts":"{t1}","iteration":1,"request_id":"req-1"}}"#- ),- r#"{"role":"user","content":"two","request_id":"req-2"}"#.to_string(),- format!(- r#"{{"role":"assistant","content":"a2","provider":"anthropic","model":"m","usage":{{"input":1,"output":1,"cached_input":0,"cost_usd":0.0}},"ts":"{t2}","iteration":1,"request_id":"req-2"}}"#- ),- ];- let root_refs: Vec<&str> = root_body.iter().map(String::as_str).collect();- write_raw(dir.path(), root_stem, thread_id, &root_refs);-- // Stems encode the spawn time; rows carry their turn's *commit* time, so- // coder (999_950) ran in turn 1 and planner (1_000_050) in turn 2.- write_raw(- dir.path(),- &format!("{root_stem}__999950_coder"),- thread_id,- &[r#"{"role":"assistant","content":"coder work"}"#],- );- write_raw(- dir.path(),- &format!("{root_stem}__1000050_planner"),- thread_id,- &[r#"{"role":"assistant","content":"planner work"}"#],- );-- let projected = project_thread(dir.path(), thread_id).expect("project thread");- // The seeded sub-agent files share the `orchestrator` meta agent name, so- // key the anchoring by each sub-agent's inner work content instead of `id`.- let mut anchors: Vec<(String, Option<String>)> = projected- .items- .iter()- .filter_map(|i| match i {- DisplayItem::Subagent {- request_id, items, ..- } => {- let marker = items.iter().find_map(|inner| match inner {- DisplayItem::AssistantMessage { content, .. } => Some(content.clone()),- _ => None,- })?;- Some((marker, request_id.clone()))- }- _ => None,- })- .collect();- anchors.sort();-- assert_eq!(- anchors,- vec![- ("coder work".to_string(), Some("req-1".to_string())),- ("planner work".to_string(), Some("req-2".to_string())),- ],- "each sub-agent anchors to the turn active at its spawn time"- );-}+#[path = "transcript_view_subagent_tests.rs"]+mod subagent_tests;