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(workflow_runs): cover stale generation fencing on failure
Steven Enamakel0823be1e91ff
diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rsindex fe09f0b1ca..178f5e125d 100644--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs@@ -360,7 +360,10 @@ async fn drive_member(("memberId".to_string(), member_id.to_string()),("taskId".to_string(), task.id.clone()),("teamRunId".to_string(), run_id.to_string()),- ("teamWorkerThreadId".to_string(), worker_thread_id.to_string()),+ (+ "teamWorkerThreadId".to_string(),+ worker_thread_id.to_string(),+ ),].into_iter().collect(),diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rsindex c8bde2de37..4a4b08a74b 100644--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs@@ -361,7 +361,12 @@ async fn start_rpc_returns_owner_receipt_while_member_executor_is_blocked() {let _guard = crate::config::TEST_ENV_LOCK.lock().await;let (_dir, config) = test_config();seed_team(&config, "team-rpc");- seed_member(&config, "team-rpc", "member-rpc", Some("task_manager_agent"));+ seed_member(+ &config,+ "team-rpc",+ "member-rpc",+ Some("task_manager_agent"),+ );seed_task(&config,"team-rpc",diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex 5bbe232902..f90dde8f40 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -171,7 +171,8 @@ pub(super) fn router_pool() -> &'static CompletionRouterPool<RouterScope> {}#[cfg(test)]-pub(super) fn test_store_overrides() -> &'static Mutex<HashMap<RouterScope, Arc<dyn CompletionStore>>> {+pub(super) fn test_store_overrides(+) -> &'static Mutex<HashMap<RouterScope, Arc<dyn CompletionStore>>> {static STORES: OnceLock<Mutex<HashMap<RouterScope, Arc<dyn CompletionStore>>>> =OnceLock::new();STORES.get_or_init(|| Mutex::new(HashMap::new()))diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rsindex a82badcb52..338a85f9ff 100644--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs@@ -131,9 +131,8 @@ fn schedule_workflow_drive(}};let inherited_origin = crate::security::turn_origin::capture();- let origin = move |future| {- crate::security::turn_origin::with_inherited_origin(inherited_origin, future)- };+ let origin =+ move |future| crate::security::turn_origin::with_inherited_origin(inherited_origin, future);let make_future = move |cancel_token| {let run_id = drive_run_id.clone();let definition = drive_definition.clone();@@ -408,7 +407,6 @@ pub(crate) async fn run_engine_loop(// Best-effort terminal failure write, preserving partial phase state.record_failed_if_current(config, run_id, &handle, format!("engine error: {err}"));}-}#[cfg(test)]diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rsindex ad57b13ea5..9d78f62037 100644--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs@@ -40,3 +40,68 @@ async fn stop_fences_the_driver_and_makes_a_running_phase_resumable() {"stop must fence the old driver");}++#[tokio::test]+async fn stale_workflow_generation_cannot_fail_its_replacement() {+ let workspace = tempfile::tempdir().expect("workspace");+ let config = Config {+ workspace_dir: workspace.path().to_path_buf(),+ ..Config::default()+ };+ let run_id = format!("stale-generation-{}", uuid::Uuid::new_v4());+ let seeded = crate::storage::sessions::with_ledger(&config.workspace_dir, |ledger| {+ let row = WorkflowRunUpsert {+ id: run_id.clone(),+ definition_id: "parallel_research_cross_check".into(),+ parent_thread_id: None,+ input: json!({"question":"q"}),+ phase_states: json!({"research":{"status":"pending","outputs":[]}}),+ child_run_ids: Vec::new(),+ status: WorkflowRunStatus::Running,+ summary: None,+ started_at: None,+ completed_at: None,+ };+ async move { ledger.upsert_workflow_run(row).await }+ })+ .expect("seed run");++ let supervisor = workflow_supervisor().clone();+ let old = supervisor.start_scoped_with_handle(+ run_id.clone(),+ |token| async move { token.cancelled().await },+ |future| future,+ |future| future,+ |_handle, future| {+ tokio::spawn(future);+ },+ );+ let current = supervisor.start_scoped_with_handle(+ run_id.clone(),+ |token| async move { token.cancelled().await },+ |future| future,+ |future| future,+ |_handle, future| {+ tokio::spawn(future);+ },+ );+ assert!(!supervisor.is_current(&old));+ assert!(supervisor.is_current(¤t));++ record_failed_if_current(&config, &run_id, &old, "stale sentinel".into());+ let unchanged = crate::storage::sessions::with_ledger(&config.workspace_dir, |ledger| {+ let id = run_id.clone();+ async move { ledger.get_workflow_run(&id).await }+ })+ .expect("read row")+ .expect("run exists");+ assert_eq!(unchanged.revision, seeded.revision);+ assert_ne!(unchanged.summary.as_deref(), Some("stale sentinel"));++ let stopped = stop_workflow_run(&config, &run_id)+ .await+ .expect("stop succeeds")+ .expect("run exists");+ assert_eq!(stopped.status, WorkflowRunStatus::Interrupted);+ assert!(current.cancellation_token().is_cancelled());+}