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: isolate two process-global slots that raced under parallel tests
M3gA-Mind1b53d17015c2
diff --git a/crates/openhuman-core/src/modules/memory_host_tests.rs b/crates/openhuman-core/src/modules/memory_host_tests.rsindex 805710bfe3..535adde276 100644--- a/crates/openhuman-core/src/modules/memory_host_tests.rs+++ b/crates/openhuman-core/src/modules/memory_host_tests.rs@@ -363,6 +363,9 @@ impl tinyinference::model::ChatModel<()> for StubModel {/// `memory_tree.cloud_summarization_opt_in`.#[test]fn summarization_role_is_refused_without_local_ai_or_cloud_opt_in() {+ // The override is process-global: serialise against every other test that+ // installs one or needs none installed.+ let _serial = crate::inference::inference_test_guard();let _guard = crate::inference::provider::factory::test_provider_override::install_model(std::sync::Arc::new(StubModel),);@@ -384,6 +387,9 @@ fn summarization_role_is_refused_without_local_ai_or_cloud_opt_in() {/// the summarization role, not to the seam.#[test]fn non_summarization_roles_keep_the_role_factory() {+ // The override is process-global: serialise against every other test that+ // installs one or needs none installed.+ let _serial = crate::inference::inference_test_guard();let _guard = crate::inference::provider::factory::test_provider_override::install_model(std::sync::Arc::new(StubModel),);diff --git a/crates/openhuman-session/src/identity.rs b/crates/openhuman-session/src/identity.rsindex 552e232b38..153fa87229 100644--- a/crates/openhuman-session/src/identity.rs+++ b/crates/openhuman-session/src/identity.rs@@ -4,14 +4,30 @@//! manager, so the manager mirrors the current user id into this slot on every//! state change. Only the id is kept — never a token, never the profile.-use std::sync::{OnceLock, RwLock};--static USER_ID: OnceLock<RwLock<Option<String>>> = OnceLock::new();+#[cfg(not(test))]+use std::sync::OnceLock;+use std::sync::RwLock;+#[cfg(not(test))]fn slot() -> &'static RwLock<Option<String>> {+ static USER_ID: OnceLock<RwLock<Option<String>>> = OnceLock::new();USER_ID.get_or_init(|| RwLock::new(None))}+// One slot per thread under test. Every `#[tokio::test]` here runs on its own+// current-thread runtime, so this isolates each test (and the tasks it spawns)+// from every other test's login/logout without a lock anyone must remember. A+// shared slot let a parallel login land between `logout()` and its assertion.+// A `multi_thread` test that writes from a worker thread would not see its own+// write here — keep manager tests on the default flavour.+#[cfg(test)]+fn slot() -> &'static RwLock<Option<String>> {+ thread_local! {+ static USER_ID: &'static RwLock<Option<String>> = Box::leak(Box::new(RwLock::new(None)));+ }+ USER_ID.with(|slot| *slot)+}+/// Record the signed-in user id (or clear it with `None`).pub fn set_user_id(user_id: Option<String>) {let mut guard = slot().write().unwrap_or_else(|p| p.into_inner());