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(runtime): cover boot reconcile using the runtime captured config
Steven Enamakela7ab2ddd861d
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rsindex 44d30facf8..3e21a86862 100644--- a/crates/openhuman-core/src/core/runtime/services.rs+++ b/crates/openhuman-core/src/core/runtime/services.rs@@ -260,7 +260,10 @@ pub fn spawn_flows_boot_reconcile(ctx: std::sync::Arc<crate::core::runtime::Coreasync fn reconcile_flows_on_boot(dispatch: &crate::core::runtime::DispatchCtx,) -> Result<usize, String> {- let config = dispatch.load_config().await.map_err(|error| error.to_string())?;+ let config = dispatch+ .load_config()+ .await+ .map_err(|error| error.to_string())?;Ok(crate::flows::recovery::sweep_orphaned_runs_on_boot(dispatch, &config).await)}diff --git a/crates/openhuman-core/src/core/runtime/services_tests.rs b/crates/openhuman-core/src/core/runtime/services_tests.rsindex 1a02d9751e..fae6bde3bc 100644--- a/crates/openhuman-core/src/core/runtime/services_tests.rs+++ b/crates/openhuman-core/src/core/runtime/services_tests.rs@@ -1,5 +1,63 @@use super::*;+#[cfg(feature = "flows")]+#[tokio::test]+async fn flows_boot_reconcile_uses_the_runtime_captured_config() {+ let tmp = tempfile::tempdir().unwrap();+ let blocker = tmp.path().join("not-a-workspace-directory");+ std::fs::write(&blocker, b"not a directory").unwrap();+ let config = Config {+ workspace_dir: blocker.clone(),+ action_dir: blocker.clone(),+ config_path: tmp.path().join("runtime-config.toml"),+ ..Config::default()+ };+ let core = crate::core::runtime::CoreContext::for_test_with_config(+ crate::core::runtime::DomainSet::full(),+ config,+ );+ let dispatch = crate::core::runtime::DispatchCtx::new(core);++ #[derive(Clone, Default)]+ struct Capture(std::sync::Arc<std::sync::Mutex<Vec<u8>>>);++ impl std::io::Write for Capture {+ fn write(&mut self, bytes: &[u8]) -> std::io::Result<usize> {+ self.0.lock().unwrap().extend_from_slice(bytes);+ Ok(bytes.len())+ }++ fn flush(&mut self) -> std::io::Result<()> {+ Ok(())+ }+ }++ impl<'a> tracing_subscriber::fmt::MakeWriter<'a> for Capture {+ type Writer = Self;++ fn make_writer(&'a self) -> Self::Writer {+ self.clone()+ }+ }++ let capture = Capture::default();+ let subscriber = tracing_subscriber::fmt()+ .with_writer(capture.clone())+ .with_ansi(false)+ .finish();+ let _subscriber_guard = tracing::subscriber::set_default(subscriber);++ let swept = reconcile_flows_on_boot(&dispatch)+ .await+ .expect("captured runtime configuration loads");+ assert_eq!(swept, 0);+ let warning = String::from_utf8(capture.0.lock().unwrap().clone()).unwrap();+ assert!(+ warning.contains(&blocker.display().to_string()),+ "BootSweep must use the workspace captured by this runtime; got {warning:?}"+ );+}+/// desktop() must enable every bootstrap job.#[test]fn desktop_plan_enables_every_job() {@@ -96,10 +154,12 @@ async fn stopping_service_tasks_aborts_every_tracked_task() {tasks.stop();assert_eq!(tasks.len(), 0);// The sender drops when the aborted task is torn down.- assert!(tokio::time::timeout(std::time::Duration::from_secs(5), rx)- .await- .expect("the aborted task is torn down")- .is_err());+ assert!(+ tokio::time::timeout(std::time::Duration::from_secs(5), rx)+ .await+ .expect("the aborted task is torn down")+ .is_err()+ );}#[tokio::test]@@ -115,10 +175,12 @@ async fn dropping_service_tasks_aborts_them() {}),);}- assert!(tokio::time::timeout(std::time::Duration::from_secs(5), rx)- .await- .expect("the aborted task is torn down")- .is_err());+ assert!(+ tokio::time::timeout(std::time::Duration::from_secs(5), rx)+ .await+ .expect("the aborted task is torn down")+ .is_err()+ );}#[test]diff --git a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rsindex 2d5b5a41ea..e6c11c9e23 100644--- a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs+++ b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs@@ -122,14 +122,16 @@ fn profile_dispatch(config: &Config, profile: &str) -> crate::core::runtime::Disuse crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};let root = CoreContext::for_test_with_config(DomainSet::full(), config.clone());- crate::core::runtime::DispatchCtx::new(root.derive_with(- ContextOverlay::new(- config.clone(),- DomainSet::full(),- crate::tools::toolpacks::ToolGroups::default(),- )- .profile(profile),- ))+ crate::core::runtime::DispatchCtx::new(+ root.derive_with(+ ContextOverlay::new(+ config.clone(),+ DomainSet::full(),+ crate::tools::toolpacks::ToolGroups::default(),+ )+ .profile(profile),+ ),+ )}async fn scoped_run_status(@@ -219,7 +221,10 @@ async fn resume_uses_the_captured_profile_scope_for_identical_run_ids() {resumed_a.value["output"]["run"]["trigger"]["owner"],json!("owner-a"));- assert_eq!(scoped_run_status(&ctx_a, &config, run_id).await, "completed");+ assert_eq!(+ scoped_run_status(&ctx_a, &config, run_id).await,+ "completed"+ );assert_eq!(scoped_run_status(&ctx_b, &config, run_id).await,"pending_approval",@@ -240,7 +245,10 @@ async fn resume_uses_the_captured_profile_scope_for_identical_run_ids() {resumed_b.value["output"]["run"]["trigger"]["owner"],json!("owner-b"));- assert_eq!(scoped_run_status(&ctx_b, &config, run_id).await, "completed");+ assert_eq!(+ scoped_run_status(&ctx_b, &config, run_id).await,+ "completed"+ );}/// Migration safety (T-M1 requirement #4): a `flow_runs` row written before