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
test(tests): update flow resume decision tests to use clearer error messages and improve stale graph
Steven Enamakelf0f2f6229a31
diff --git a/crates/openhuman-core/src/flows/ops_resume_decision_tests.rs b/crates/openhuman-core/src/flows/ops_resume_decision_tests.rsindex 6cd5f25f67..36201468be 100644--- a/crates/openhuman-core/src/flows/ops_resume_decision_tests.rs+++ b/crates/openhuman-core/src/flows/ops_resume_decision_tests.rs@@ -1,15 +1,10 @@use super::*;-// ── flows_resume host-side approval guard (issue B2 finding #3) ──────────+// ── TinyFlows-owned resume decision validation ──────────────────────────//-// tinyflows 0.2's `resume_with_checkpointer` treats the resume call itself-// as approval of whatever gate paused the run — its `approvals` argument is-// advisory, not enforced by the crate. Live testing confirmed-// `flows_resume(..., approvals: [])` on a paused run still completed it.-// These tests exercise the host-side guard added in `flows::ops::flows_resume`-// that requires `approvals` to actually name a currently-pending gate,-// straight from the persisted `flow_runs` row, before ever calling into the-// engine.+// Resume decisions are checked against the persisted run's pending gate ids+// before the owner module admits the continuation. Invalid decisions must+// leave the parked row and flow summary untouched.#[tokio::test]async fn flows_resume_with_empty_approvals_is_rejected_and_does_not_complete_the_run() {@@ -42,7 +37,7 @@ async fn flows_resume_with_empty_approvals_is_rejected_and_does_not_complete_the.await.expect_err("an empty approvals list must not silently approve the pending gate");assert!(- err.contains("no pending approval matches"),+ err.contains("resume decisions do not name a currently pending gate"),"expected a clear approval-mismatch error, got: {err}");@@ -90,7 +85,7 @@ async fn flows_resume_with_mismatched_approvals_is_rejected() {).await.expect_err("approvals naming no actually-pending gate must be rejected");- assert!(err.contains("no pending approval matches"));+ assert!(err.contains("resume decisions do not name a currently pending gate"));}#[tokio::test]@@ -190,7 +185,7 @@ async fn flows_resume_denying_a_gate_routes_to_its_error_port() {}#[tokio::test]-async fn flows_resume_returns_failed_step_output_when_denial_has_no_error_port() {+async fn flows_resume_fails_and_persists_the_run_when_denial_has_no_error_port() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);// `approval_gated_graph()` has only a `main` edge out of the gate — no@@ -211,7 +206,7 @@ async fn flows_resume_returns_failed_step_output_when_denial_has_no_error_port().unwrap();let thread_id = run.value["thread_id"].as_str().unwrap().to_string();- let resumed = flows_resume(+ let error = flows_resume(&crate::core::runtime::DispatchCtx::ambient(),&config,&created.value.id,@@ -220,18 +215,18 @@ async fn flows_resume_returns_failed_step_output_when_denial_has_no_error_port()vec!["gate".to_string()],).await- .expect("step-level failure still has a successful engine outcome");- assert_eq!(resumed.value["pending_approvals"], json!([]));- assert_eq!(resumed.value["thread_id"], json!(thread_id));+ .expect_err("denial without an error port must fail the resumed engine run");assert!(- resumed.value["output"].is_object(),- "a failed step outcome must preserve the engine output in the legacy RPC response"+ error.contains("approval gate 'gate' was denied and has no `error` port"),+ "{error}");let reloaded = flows_get(&config, &created.value.id).await.unwrap();assert_eq!(reloaded.value.last_status.as_deref(), Some("failed"));let run_row = flows_get_run(&config, &thread_id).await.unwrap();assert_eq!(run_row.value.status, "failed");+ assert!(run_row.value.pending_approvals.is_empty());+ assert_eq!(run_row.value.error.as_deref(), Some(error.as_str()));}#[tokio::test]@@ -304,7 +299,7 @@ async fn flows_resume_of_a_non_paused_run_errors_clearly() {.await.expect_err("resuming an already-completed run must be a clear error, not a silent no-op");assert!(- err.contains("not pending approval") || err.contains("no paused run"),+ err.contains("flow run is not parked for approval (status: completed)"),"expected a clear non-paused-run error, got: {err}");}diff --git a/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs b/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rsindex 923168cb56..ffbd5b55bd 100644--- a/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs+++ b/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs@@ -23,7 +23,7 @@ async fn create_parked_run(config: &Config, name: &str) -> (Flow, String, Vec<St}#[tokio::test]-async fn flows_resume_rejects_a_stale_graph_without_mutating_the_parked_run_summary() {+async fn flows_resume_rejects_a_stale_graph_and_settles_the_parked_run() {let tmp = TempDir::new().unwrap();let config = test_config(&tmp);let (flow, run_id, pending) = create_parked_run(&config, "stale-graph").await;@@ -57,9 +57,20 @@ async fn flows_resume_rejects_a_stale_graph_without_mutating_the_parked_run_summ);let after_run = flows_get_run(&config, &run_id).await.unwrap().value;- assert_eq!(after_run.status, before_run.status);+ assert_eq!(before_run.status, "pending_approval");+ assert_eq!(after_run.status, "cancelled");+ assert!(after_run.pending_approvals.is_empty());+ assert_eq!(+ after_run.error.as_deref(),+ Some("workflow graph changed after the run parked; refusing resume")+ );+ assert!(+ !after_run.steps.iter().any(|step| step.node_id == "downstream"),+ "the stale approval must not execute the replacement graph: {after_run:?}"+ );let after_flow = flows_get(&config, &flow.id).await.unwrap().value;- assert_eq!(after_flow.last_status, before_flow.last_status);+ assert_eq!(before_flow.last_status.as_deref(), Some("pending_approval"));+ assert_eq!(after_flow.last_status.as_deref(), Some("cancelled"));}#[tokio::test]diff --git a/crates/openhuman-core/src/flows/ops_run_rows_and_notifications_tests.rs b/crates/openhuman-core/src/flows/ops_run_rows_and_notifications_tests.rsindex fbe29adae1..6cb7fb32d2 100644--- a/crates/openhuman-core/src/flows/ops_run_rows_and_notifications_tests.rs+++ b/crates/openhuman-core/src/flows/ops_run_rows_and_notifications_tests.rs@@ -18,7 +18,7 @@ async fn flows_resume_with_no_recorded_run_for_thread_id_errors_clearly() {).await.expect_err("must error when no run is recorded for this thread_id");- assert!(err.contains("no paused run to resume"));+ assert!(err.contains("flow run does not exist in this owner scope"));}// ── run history (flows_list_runs / flows_get_run) ────────────────────────@@ -604,7 +604,10 @@ async fn flows_cancel_run_cancels_a_parked_pending_approval_run() {let run_row = flows_get_run(&config, &thread_id).await.unwrap();assert_eq!(run_row.value.status, "cancelled");assert!(run_row.value.pending_approvals.is_empty());- assert_eq!(run_row.value.error.as_deref(), Some("run cancelled"));+ assert_eq!(+ run_row.value.error.as_deref(),+ Some("parked run cancelled")+ );let reloaded = flows_get(&config, &created.value.id).await.unwrap();assert_eq!(reloaded.value.last_status.as_deref(), Some("cancelled"));@@ -620,7 +623,10 @@ async fn flows_cancel_run_cancels_a_parked_pending_approval_run() {).await.expect_err("a cancelled run must not be resumable");- assert!(err.contains("not pending approval") || err.contains("no paused run"));+ assert!(+ err.contains("flow run is not parked for approval (status: cancelled)"),+ "{err}"+ );}#[tokio::test]diff --git a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rsindex 91d232a141..c3ff9e6e9b 100644--- a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs+++ b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs@@ -570,10 +570,7 @@ async fn flows_resume_refuses_when_the_graph_changed_after_park() {).await.expect_err("resume must refuse once the graph changed after park");- assert!(- error.contains("changed after this run was paused"),- "{error}"- );+ assert!(error.contains("workflow graph changed after the run parked"), "{error}");// Must NOT have executed: the engine must never have run, so "downstream"// must not appear among the run's persisted steps.@@ -587,7 +584,7 @@ async fn flows_resume_refuses_when_the_graph_changed_after_park() {run_row.error.as_deref()- .is_some_and(|e| e.contains("changed after this run was paused")),+ .is_some_and(|e| e.contains("workflow graph changed after the run parked")),"the terminal run row should retain the refusal reason: {run_row:?}");let flow = flows_get(&config, &created.value.id).await.unwrap().value;