Skip to content

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

fix(memory): bind the test driver once, not once per caller

Shanu9ff833374a46
diff --git a/src/openhuman/memory/ops/test_support/mod.rs b/src/openhuman/memory/ops/test_support/mod.rs
index bb1a50818f..91e30171e9 100644
--- a/src/openhuman/memory/ops/test_support/mod.rs
+++ b/src/openhuman/memory/ops/test_support/mod.rs
@@ -31,6 +31,31 @@ pub(crate) fn shared_memory_test_workspace() -> PathBuf {
let path = tmp.path().join("workspace");
std::fs::create_dir_all(&path).expect("workspace dir");
std::mem::forget(tmp);
+
+ // Bind a driver over it, which is the half callers actually depend
+ // on, and bind it exactly once.
+ //
+ // This helper replaced `ensure_shared_memory_client`, which booted
+ // the in-process engine and bound *that*. Handing back only the
+ // directory was the wrong half of the trade: `memory::ops`
+ // handlers resolve through the bound driver, so with nothing bound
+ // they fall through to the module path and fail with "the memory
+ // module failed to load" — an error about a missing artifact, in a
+ // unit test that never wanted one.
+ //
+ // Binding must happen **inside** `get_or_init`. `install_for_test`
+ // *replaces* the cached binding rather than leaving an existing one
+ // alone (`BINDINGS.write().insert(key, ..)`), and the driver it
+ // installs stores rows in itself. Calling it per caller therefore
+ // hands every test a brand-new empty store, and — because most of
+ // these tests do not hold `GLOBAL_MEMORY_TEST_LOCK` — a second
+ // test's setup wipes the rows a first test has already written and
+ // is about to read back. That failed 16 handler tests as
+ // "the write is not visible", which reads like a driver that
+ // discards writes and is really a fixture that discards stores.
+ let mut config = crate::openhuman::config::Config::default();
+ config.workspace_dir = path.clone();
+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);
path
})
.clone()