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
fix(storage): serialize concurrent module attachments in tests
Steven Enamakelef9783f70d80
diff --git a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rsindex 0680a25c90..b31fae2723 100644--- a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs+++ b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs@@ -360,6 +360,7 @@ async fn a_loaded_module_cannot_name_or_reach_another_scope() {let read = rig.call("Documents", "Get", get("mcp_servers", "victim")).await;+ assert!(read["ok"].is_null(), "{read}");assert!(!read.to_string().contains("OTHER-SCOPE-SECRET"), "{read}");// A scope smuggled into the request is not a selector the wire knows.for field in ["scope", "agent", "module", "profile"] {diff --git a/crates/openhuman-core/src/modules/storage_host_linked.rs b/crates/openhuman-core/src/modules/storage_host_linked.rsindex 44995e656e..03cd870354 100644--- a/crates/openhuman-core/src/modules/storage_host_linked.rs+++ b/crates/openhuman-core/src/modules/storage_host_linked.rs@@ -34,6 +34,13 @@ static PENDING: Mutex<Option<(Arc<StorageHost>, tokio::runtime::Handle)>> = Mute#[cfg(test)]pub(super) static TEST_TURN: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());+/// Held by [`attach`] from publishing `PENDING` until the module serves, so two+/// concurrent attachments (any test that starts a runtime, not only the ones+/// taking `TEST_TURN`) cannot overwrite each other's slot before `setup`+/// reads it.+#[cfg(test)]+static ATTACH_GUARD: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());+/// How long [`attach`] waits for the module to claim the interface name.const READY_DEADLINE: Duration = Duration::from_secs(5);@@ -69,6 +76,8 @@ pub(super) async fn attach(connection: &tinybus::Connection,host: Arc<StorageHost>,) -> tinybus::Result<()> {+ #[cfg(test)]+ let _attaching = ATTACH_GUARD.lock().await;*PENDING.lock().unwrap_or_else(|poison| poison.into_inner()) =Some((host, tokio::runtime::Handle::current()));modules.attach_linked_with_config(export::linked_module()?, serde_json::json!({}))?;