Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(config): add app environment configuration and composio integration support

Steven Enamakelfe5a2c43d46f
diff --git a/crates/openhuman-core/src/config/app_env.rs b/crates/openhuman-core/src/config/app_env.rs
index d32f235784..30ab350a76 100644
--- a/crates/openhuman-core/src/config/app_env.rs
+++ b/crates/openhuman-core/src/config/app_env.rs
@@ -63,12 +63,18 @@ fn compile_time_app_env_values() -> [Option<&'static str>; 2] {
/// backend-URL env vars. `std::env` is process-global, so a module-local lock
/// cannot stop tests in other modules racing on the same vars.
#[cfg(test)]
-pub(crate) fn env_test_lock() -> std::sync::MutexGuard<'static, ()> {
- use std::sync::{Mutex, OnceLock};
- static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
- LOCK.get_or_init(Mutex::default)
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
+static ENV_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+
+/// Blocking form for synchronous tests (panics inside a tokio runtime).
+#[cfg(test)]
+pub(crate) fn env_test_lock() -> tokio::sync::MutexGuard<'static, ()> {
+ ENV_TEST_LOCK.blocking_lock()
+}
+
+/// Async form for `#[tokio::test]` bodies, so the guard may be held across `.await`.
+#[cfg(test)]
+pub(crate) async fn env_test_lock_async() -> tokio::sync::MutexGuard<'static, ()> {
+ ENV_TEST_LOCK.lock().await
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index f2b3d0501d..b8b42c0db7 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -80,7 +80,7 @@ pub use schemas::{
/// `schema::load::tests`, etc. — can grab the same lock and avoid
/// interleaved mutations.
#[cfg(test)]
-pub(crate) static TEST_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
+pub(crate) static TEST_ENV_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
#[cfg(test)]
pub(crate) mod test_env;
diff --git a/crates/openhuman-core/src/inference/host_runtime/mod.rs b/crates/openhuman-core/src/inference/host_runtime/mod.rs
index 0bcc6f732b..c6e42f8ef3 100644
--- a/crates/openhuman-core/src/inference/host_runtime/mod.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/mod.rs
@@ -6,14 +6,18 @@
//! policy, controller wiring, and voice integration.
#[cfg(test)]
-pub(crate) static INFERENCE_TEST_MUTEX: once_cell::sync::Lazy<std::sync::Mutex<()>> =
- once_cell::sync::Lazy::new(|| std::sync::Mutex::new(()));
+pub(crate) static INFERENCE_TEST_MUTEX: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+/// Blocking form for synchronous tests (panics inside a tokio runtime).
#[cfg(test)]
-pub(crate) fn inference_test_guard() -> std::sync::MutexGuard<'static, ()> {
- INFERENCE_TEST_MUTEX
- .lock()
- .unwrap_or_else(|p| p.into_inner())
+pub(crate) fn inference_test_guard() -> tokio::sync::MutexGuard<'static, ()> {
+ INFERENCE_TEST_MUTEX.blocking_lock()
+}
+
+/// Async form for `#[tokio::test]` bodies, so the guard may be held across `.await`.
+#[cfg(test)]
+pub(crate) async fn inference_test_guard_async() -> tokio::sync::MutexGuard<'static, ()> {
+ INFERENCE_TEST_MUTEX.lock().await
}
mod core;
diff --git a/crates/openhuman-core/src/inference/mod.rs b/crates/openhuman-core/src/inference/mod.rs
index ad1c3825f2..eed6d679f9 100644
--- a/crates/openhuman-core/src/inference/mod.rs
+++ b/crates/openhuman-core/src/inference/mod.rs
@@ -120,6 +120,11 @@ impl tinyinference_local::models::LocalModelConfig for crate::config::Config {
// Test helpers (re-exported for sibling test files that use inference_test_guard)
#[cfg(test)]
-pub(crate) fn inference_test_guard() -> std::sync::MutexGuard<'static, ()> {
+pub(crate) fn inference_test_guard() -> tokio::sync::MutexGuard<'static, ()> {
host_runtime::inference_test_guard()
}
+
+#[cfg(test)]
+pub(crate) async fn inference_test_guard_async() -> tokio::sync::MutexGuard<'static, ()> {
+ host_runtime::inference_test_guard_async().await
+}
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations.rs
index 14dfa2e3f2..66de21ba33 100644
--- a/crates/openhuman-core/src/integrations/composio/connected_integrations.rs
+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations.rs
@@ -16,7 +16,7 @@ mod connectable_slug_tests;
mod catalog_description_tests;
#[cfg(test)]
-pub(crate) use cache::composio_cache_test_lock;
+pub(crate) use cache::{composio_cache_test_lock, composio_cache_test_lock_async};
pub(crate) use cache::sync_cache_with_connections;
pub use cache::{
cached_active_integrations, cached_active_integrations_including_expired, connected_set_hash,
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
index bf6cf2faaf..36010fab25 100644
--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs
@@ -39,13 +39,19 @@ pub(crate) static CACHE_GENERATION: AtomicU64 = AtomicU64::new(0);
/// Poison-recovery (`unwrap_or_else`) keeps a panicking test from
/// permanently blocking later ones.
#[cfg(test)]
-pub(crate) fn composio_cache_test_lock() -> std::sync::MutexGuard<'static, ()> {
- static LOCK: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
- LOCK.get_or_init(|| std::sync::Mutex::new(()))
- .lock()
- .unwrap_or_else(|e| e.into_inner())
+pub(crate) fn composio_cache_test_lock() -> tokio::sync::MutexGuard<'static, ()> {
+ COMPOSIO_CACHE_TEST_LOCK.blocking_lock()
}
+/// Async form for `#[tokio::test]` bodies, so the guard may be held across `.await`.
+#[cfg(test)]
+pub(crate) async fn composio_cache_test_lock_async() -> tokio::sync::MutexGuard<'static, ()> {
+ COMPOSIO_CACHE_TEST_LOCK.lock().await
+}
+
+#[cfg(test)]
+static COMPOSIO_CACHE_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+
/// Bind a cached integration list to its backend endpoint, backend credential,
/// and effective Composio credential identity. Digests keep secrets out of
/// cache keys and logs while preventing cross-agent cache hits after rotation.
diff --git a/crates/openhuman-core/src/skills/catalog/mod.rs b/crates/openhuman-core/src/skills/catalog/mod.rs
index 9ba49a675a..a9d0bbaef7 100644
--- a/crates/openhuman-core/src/skills/catalog/mod.rs
+++ b/crates/openhuman-core/src/skills/catalog/mod.rs
@@ -34,7 +34,7 @@ pub use schemas::{
/// Serializes tests that mutate the process-global `OPENHUMAN_SKILL_REGISTRY_CACHE_DIR`
/// env var, so cargo's parallel runner can't interleave their cache dirs.
#[cfg(all(test, feature = "skills"))]
-pub(crate) static TEST_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
+pub(crate) static TEST_ENV_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
// ---------------------------------------------------------------------------
// Disabled facade — compiled only when the `skills` feature is OFF.