Skip to content

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

feat(memory): make MODULE_ID public for test support

Steven Enamakel0e14878eb3ef
diff --git a/crates/openhuman-core/src/memory/binding.rs b/crates/openhuman-core/src/memory/binding.rs
index 75bae210ee..e9d5cfe939 100644
--- a/crates/openhuman-core/src/memory/binding.rs
+++ b/crates/openhuman-core/src/memory/binding.rs
@@ -52,8 +52,9 @@ use crate::core::subsystem::{
BoundDriver, DriverCapabilities, DriverClass, DriverHealth, SubsystemSlot,
};
-/// Registry id of the built-in TinyMemory module.
-pub(crate) const MODULE_ID: &str = "tinymemory";
+/// Registry id of the built-in TinyMemory module. Public so in-process test
+/// suites can wait out its load (`tests/support/memory_module.rs`).
+pub const MODULE_ID: &str = "tinymemory";
/// Why a bind fell back to the placeholder driver.
///
diff --git a/tests/support/memory_module.rs b/tests/support/memory_module.rs
new file mode 100644
index 0000000000..29d3c939ab
--- /dev/null
+++ b/tests/support/memory_module.rs
@@ -0,0 +1,39 @@
+//! Wait out the memory module's load in a suite that boots the core in-process.
+//!
+//! The module is loaded once per process, by whichever caller asks first, and
+//! for the whole of that load a memory call that reaches the driver answers
+//! "memory is still starting ... try again in a moment". A test sharing its
+//! process with earlier memory tests usually finds the module already loaded;
+//! one running in its own process (cargo nextest) always asks during the load.
+//! Call [`settle`] after the test's workspace env is in place and before its
+//! first memory call. This is the in-crate `memory::test_support::
+//! settle_memory_module` for suites outside the core.
+//!
+//! Include with `#[path = "support/memory_module.rs"] mod memory_module;`.
+
+#![allow(dead_code)]
+
+use std::time::Duration;
+
+/// Load the memory module for the core's current config, waiting up to 60 s.
+///
+/// A load that fails is left for the test to observe through its own calls;
+/// only a load still running after the bound panics, because every assertion
+/// after it would race that load.
+pub async fn settle() {
+ let config = openhuman_core::config::load_config_with_timeout()
+ .await
+ .expect("load config to settle the memory module");
+ match openhuman_core::modules::ops::ensure_loaded_within(
+ &config,
+ openhuman_core::memory::binding::MODULE_ID,
+ Some(Duration::from_secs(60)),
+ )
+ .await
+ {
+ Ok(()) | Err(openhuman_core::modules::ops::LoadError::Failed(_)) => {}
+ Err(openhuman_core::modules::ops::LoadError::StillLoading) => {
+ panic!("the memory module did not finish loading within 60s")
+ }
+ }
+}