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(storage): isolate test workspaces from shared temp dir
Steven Enamakelc23b260d23b4
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 12389ff010..0414669419 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@@ -97,7 +97,7 @@ fn mock_parent(model: Arc<dyn ChatModel<()>>) -> ParentExecutionContext {subagent_tool_ceiling_names: std::collections::HashSet::new(),model_name: "test-model".to_string(),temperature: 0.0,- workspace_dir: std::env::temp_dir(),+ workspace_dir: crate::storage::test_support::isolated_workspace(),agent_config: AgentConfig::default(),workflows: Arc::new(Vec::new()),memory_context: Arc::new(None),diff --git a/crates/openhuman-core/src/agent/orchestration/ops_tests.rs b/crates/openhuman-core/src/agent/orchestration/ops_tests.rsindex aa437055ce..5fc3201eb4 100644--- a/crates/openhuman-core/src/agent/orchestration/ops_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/ops_tests.rs@@ -35,7 +35,7 @@ fn parent_context(model: Arc<dyn ChatModel<()>>) -> ParentExecutionContext {subagent_tool_ceiling_names: std::collections::HashSet::new(),model_name: "test-model".to_string(),temperature: 0.2,- workspace_dir: std::env::temp_dir(),+ workspace_dir: crate::storage::test_support::isolated_workspace(),agent_config: AgentConfig::default(),workflows: Arc::new(Vec::new()),memory_context: Arc::new(None),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rsindex c6dc20b0a6..6a0cd8819f 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs@@ -69,7 +69,7 @@ fn parent_context(max_parallel_tools: usize) -> ParentExecutionContext {subagent_tool_ceiling_names: std::collections::HashSet::new(),model_name: "test-model".into(),temperature: 0.2,- workspace_dir: std::env::temp_dir(),+ workspace_dir: crate::storage::test_support::isolated_workspace(),agent_config,workflows: Arc::new(Vec::new()),memory_context: Arc::new(None),diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests.rsindex d460fcc043..566e0d439a 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs@@ -277,7 +277,7 @@ fn make_parent(subagent_tool_ceiling_names: std::collections::HashSet::new(),model_name: "test-model".into(),temperature: 0.5,- workspace_dir: std::env::temp_dir(),+ workspace_dir: crate::storage::test_support::isolated_workspace(),agent_config: crate::config::AgentConfig::default(),workflows: Arc::new(vec![]),memory_context: Arc::new(None),diff --git a/crates/openhuman-core/src/storage/test_support.rs b/crates/openhuman-core/src/storage/test_support.rsindex 9b35e2ffce..dcdd6f2079 100644--- a/crates/openhuman-core/src/storage/test_support.rs+++ b/crates/openhuman-core/src/storage/test_support.rs@@ -1,6 +1,7 @@//! Test-only storage backends backed by the real TSD testkit and drivers.-use std::sync::{Arc, Mutex, MutexGuard};+use std::path::PathBuf;+use std::sync::{Arc, Mutex, MutexGuard, OnceLock};#[cfg(feature = "storage-sqlite")]use crate::storage::block_on_anyhow;@@ -12,6 +13,22 @@ pub fn memory_backend() -> Arc<dyn StorageBackend> {Arc::new(tinystoragedrivers_testkit::MemoryBackend::new())}+static TEST_WORKSPACES: OnceLock<Mutex<Vec<tempfile::TempDir>>> = OnceLock::new();++/// Returns a private workspace path retained until the test process exits.+/// Use it when a test context can open durable storage: sharing the system+/// temp directory lets unrelated tests declare conflicting storage indexes.+pub fn isolated_workspace() -> PathBuf {+ let directory = tempfile::tempdir().expect("create isolated test workspace");+ let path = directory.path().to_path_buf();+ TEST_WORKSPACES+ .get_or_init(Default::default)+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)+ .push(directory);+ path+}+static STORAGE_SLOT_TEST_LOCK: Mutex<()> = Mutex::new(());/// Serializes a test that reads or mutates the process-wide installed storage