Skip to content

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

Refuse a null driver on import, and assert memory routing on the binding

M3gA-Mindb026e7bbe020
diff --git a/5560-remaining.md b/5560-remaining.md
index 1f00bd1375..496d0f8e85 100644
--- a/5560-remaining.md
+++ b/5560-remaining.md
@@ -21,6 +21,18 @@ Two acceptance criteria:
Criterion 1 is nearly done. **Criterion 2 is not reachable yet**, and section 4
explains exactly what blocks it. That is the headline finding of this work.
+**Which count decides criterion 1.** The literal `grep` above and the 37
+references section 4 reports are not the same number, and only one of them is
+the gate. The `grep` is a raw hit count: it includes doc comments that merely
+name the crate, `#[cfg(test)]` and dev-only references, and the retained
+`pub use tinymemory_core::…` re-export shims that exist precisely so call sites
+elsewhere do not name the engine. **Criterion 1 is met when no *production*
+call site outside `modules/memory.rs` and `memory/binding.rs` reaches the engine
+directly** — shims and test-only references do not count against it, because
+neither is a caller. Section 4's table is the authoritative classification;
+`memory/direct_engine_refs_tests.rs` is the ratchet that keeps the production
+number honest. Read the table, not the raw `grep`.
+
---
## 2. State of play
@@ -29,12 +41,19 @@ explains exactly what blocks it. That is the headline finding of this work.
| What | Where | State |
| --- | --- | --- |
-| Host work, phase 1 | openhuman PR **#5725**, branch `feat/5560-queue-and-recall-through-the-contract` | open |
-| Host work, phase 2 | branch `feat/5560-close-the-last-six` (stacked on #5725) | **draft PR — this work** |
+| Host work, phase 1 | openhuman PR **#5725**, branch `feat/5560-queue-and-recall-through-the-contract` | **merged** |
+| Host work, phase 2 | branch `feat/5560-close-the-last-six` (was stacked on #5725) | **this work** |
| `BootstrapConnection` | tinymemory **#105** | merged, released **v1.11.0** |
| `IsToolkitSyncable` | tinymemory **#106** | merged, released **v1.12.0** |
-The host is pinned to **tinymemory v1.12.0** across all five pin sites.
+The host is pinned to **tinymemory v1.12.0** across **six** concrete locations,
+in five logical groups: the `vendor/tinymemory` gitlink, `modules/registry.rs`
+(release tag + per-platform digests), `modules/memory.rs` (the assumed
+capability set), and the three CI workflow files that install the module for
+tests (`ci-lite.yml`, `ci-full.yml`, `e2e-reusable.yml`) — which are one group
+but three files. Bump all six; missing a workflow leaves CI installing a
+different module than the host pins, and that mismatch only shows up as a
+runtime `Unsupported`.
### What phase 2 did
@@ -84,7 +103,15 @@ nothing; check.
dependencies. Measured: the product build compiles **clean** without both, no
`ctor`/`inventory`/`linkme` registration exists in either, nothing in the
product build names them, and `binding::admit` refuses `DriverClass::Embedded`
- outright. Either that entry gets rewritten or the deps stay — leaving two
+ outright. **That evidence is not sufficient on its own, and the entry stays
+ until a process-level smoke test says otherwise.** `admit` maps both the
+ default `tinymemory` driver and the legacy `tinycortex` alias to
+ `DriverClass::Module`, and the provider then loads the module through
+ `ops::ensure_loaded` — a `dlopen` at runtime. A clean compile and a host-side
+ source scan cannot observe that path, so they cannot prove removing the deps
+ leaves module admission working. Run a build with them dropped and drive one
+ real module-backed memory call before rewriting the entry. Either it gets
+ rewritten on that evidence or the deps stay — leaving two
documented decisions contradicting each other is how the next person is misled.
---
@@ -93,7 +120,7 @@ nothing; check.
`tinymemory-core` is reached two ways:
-```
+```text
tinymemory-core
├── openhuman ← via 13 `pub use tinymemory_core::…::*` shims
└── tinymemory-tinycortex ← transitive
@@ -219,13 +246,21 @@ cargo clippy -p openhuman -- -D warnings
# tests/ targets are NOT built by PR CI (test.yml is workflow_dispatch-only),
# so this is the only place they get checked before a release lane sees them
-cargo check -p openhuman --features "$(bash scripts/ci/product-features.sh)" --tests
+cargo check --locked -p openhuman --features "$(bash scripts/ci/product-features.sh)" --tests
cargo test -p openhuman --lib -- memory:: modules:: # multi-filter needs `-- a b`
-cargo metadata --locked # and app/src-tauri: two Cargo worlds
-# criterion 2, the real gate
-cargo tree -i tinymemory-core --features "$(bash scripts/ci/product-features.sh)" --no-default-features -e normal
+# Two Cargo worlds, two lockfiles — the root command does NOT validate the
+# shell's. Check both, or a stale `app/src-tauri/Cargo.lock` fails the release
+# lane in "Enforce Linux TLS dependency policy" with a --locked error that
+# names neither the lockfile nor the pin that moved.
+cargo metadata --locked
+cargo metadata --locked --manifest-path app/src-tauri/Cargo.toml
+
+# criterion 2, the real gate. NOT `cargo tree -i`: it exits non-zero when the
+# crate is absent (so "gone" and "command failed" are the same signal) and
+# `-e normal` still matches a dev-dependency-only survivor.
+bash scripts/assert-shed.sh "$(bash scripts/ci/product-features.sh)" tinymemory-core
```
macOS notes: set `GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign
diff --git a/src/openhuman/agent/harness/session/builder/builder_tests.rs b/src/openhuman/agent/harness/session/builder/builder_tests.rs
index ffa5284b0b..8399f2a5f5 100644
--- a/src/openhuman/agent/harness/session/builder/builder_tests.rs
+++ b/src/openhuman/agent/harness/session/builder/builder_tests.rs
@@ -460,16 +460,28 @@ async fn build_session_agent_routes_dedicated_memory_to_profile_subtree() {
)
.expect("build_session_agent_inner with a dedicated-memory profile should succeed");
- // The session's capture/recall store (UnifiedMemory) is rooted at
- // `<workspace>/memory-alice`, not the shared `memory/` tree.
- assert!(
- config
- .workspace_dir
- .join("memory-alice")
- .join("memory.db")
- .exists(),
+ // Asserted on the binding, not on a file. Session memory is bound through
+ // `DriverMemory::for_subtree`, and a module-backed driver opens its subtree
+ // lazily on the first `OpenStore` call — so building an agent puts nothing
+ // on disk, and the one call that would is a module round trip that times
+ // out in a unit test. The binding knows the answer at bind time, which is
+ // where the routing decision is actually made.
+ let bound = crate::openhuman::memory::binding::for_subtree(
+ &config.workspace_dir,
+ "memory-alice",
+ &config.subsystems.memory,
+ )
+ .expect("the dedicated subtree must be bound");
+ assert_eq!(
+ bound.memory_subdir(),
+ "memory-alice",
"a dedicatedMemory profile must route session memory to memory-<id>"
);
+ assert_ne!(
+ bound.memory_subdir(),
+ "memory",
+ "a dedicatedMemory profile must not share the common memory subtree"
+ );
}
#[tokio::test]
@@ -487,18 +499,25 @@ async fn build_session_agent_profile_less_uses_shared_memory_subtree() {
let _agent = Agent::build_session_agent_inner(&config, "orchestrator", None, None, false, None)
.expect("build_session_agent_inner without a profile should succeed");
- assert!(
- config
- .workspace_dir
- .join("memory")
- .join("memory.db")
- .exists(),
+ // Same reasoning as the dedicated-memory case above: the routing decision
+ // lives on the binding, and nothing reaches disk until memory is used.
+ let bound = crate::openhuman::memory::binding::for_subtree(
+ &config.workspace_dir,
+ "memory",
+ &config.subsystems.memory,
+ )
+ .expect("the shared subtree must be bound");
+ assert_eq!(
+ bound.memory_subdir(),
+ "memory",
"the profile-less session must use the shared memory subtree"
);
- assert!(
- !config.workspace_dir.join("memory-alice").exists(),
- "no per-profile memory subtree should exist for a profile-less session"
- );
+ // The companion "and no per-profile subtree exists" check is deliberately
+ // gone rather than repointed. It asserted the ABSENCE of a directory that a
+ // module-backed driver no longer creates for anyone at bind time, so it
+ // passed whatever the routing did — vacuous, and worse than nothing because
+ // it read like coverage. The positive assertion above is the whole property
+ // this test can honestly make.
}
// ── Finding #2 (Codex): profile SOUL.md injected into the live session prompt ─
diff --git a/src/openhuman/config/migration_helpers/core.rs b/src/openhuman/config/migration_helpers/core.rs
index 632195a21d..8a7c6e076e 100644
--- a/src/openhuman/config/migration_helpers/core.rs
+++ b/src/openhuman/config/migration_helpers/core.rs
@@ -141,7 +141,37 @@ pub async fn migrate_openclaw_memory(
/// **unguarded** driver — the binding keeps the guarded one separately behind
/// `binding.guard()`. So an import writes full bodies here exactly as the
/// engine constructor did, and no policy has to be special-cased to allow it.
+///
+/// # A null driver is refused, not imported into
+///
+/// `binding` answers the null driver in two situations: `[subsystems.memory]
+/// driver = "null"` is configured, and a configured driver failed to bind and
+/// fell back. In both, every write below is discarded. An import that reports
+/// "migrated N entries" having written none is silent data loss of the worst
+/// kind — the source workspace may be deleted on the strength of that report,
+/// and the user only discovers it later, with nothing left to re-run against.
+/// So this refuses up front and names which of the two it was.
fn target_memory_backend(config: &Config) -> Result<Arc<dyn Memory>> {
+ let binding = crate::openhuman::memory::binding::for_config(config)
+ .map_err(|e| anyhow::anyhow!("bind memory for migration import: {e}"))?;
+ if binding.class() == crate::core::subsystem::DriverClass::Null {
+ let because = binding.fallback().map_or_else(
+ || {
+ "memory is disabled by configuration ([subsystems.memory] driver = \"null\")"
+ .to_string()
+ },
+ |fallback| {
+ format!(
+ "driver '{}' refused to bind: {}",
+ fallback.configured_driver, fallback.reason
+ )
+ },
+ );
+ anyhow::bail!(
+ "refusing to import OpenClaw memory into the null driver — {because}. \
+ Nothing was imported; the source workspace is untouched."
+ );
+ }
crate::openhuman::agent::experience::ops::DriverMemory::for_config(config)
.map_err(|e| anyhow::anyhow!("bind memory for migration import: {e}"))
}
diff --git a/src/openhuman/memory/binding.rs b/src/openhuman/memory/binding.rs
index 260669ad28..b6373c6798 100644
--- a/src/openhuman/memory/binding.rs
+++ b/src/openhuman/memory/binding.rs
@@ -76,6 +76,9 @@ pub struct MemoryBinding {
provider: Arc<dyn MemoryProvider>,
guard: Arc<MemoryGuard>,
driver_id: String,
+ /// The memory subtree this binding serves — `"memory"` for the shared tree,
+ /// `"memory-<id>"` for a profile that opted into dedicated memory.
+ memory_subdir: String,
class: DriverClass,
/// Asked **once**, at bind time, and cached here. The contract's
/// `MemoryProvider::capabilities` doc is normative on this ("asked once at
@@ -109,6 +112,22 @@ impl MemoryBinding {
&self.driver_id
}
+ /// The memory subtree this binding resolved to.
+ ///
+ /// `"memory"` is the shared tree; `"memory-<id>"` is a profile that opted
+ /// into dedicated memory, and keeping the two apart is what makes
+ /// `dedicatedMemory` isolation hold.
+ ///
+ /// Worth an accessor because the routing decision is made **here**, at bind
+ /// time, but only reaches disk lazily: a module-backed driver opens the
+ /// subtree on its first call (`OpenStore`), so nothing observes the choice
+ /// until memory is actually used. Callers that need to report or assert
+ /// which tree they were bound to — status output, and the session-builder
+ /// tests — have no other way to see it.
+ pub fn memory_subdir(&self) -> &str {
+ &self.memory_subdir
+ }
+
/// How the bound driver was reached. A host fact, never self-reported.
pub fn class(&self) -> DriverClass {
self.class
@@ -286,7 +305,13 @@ fn build(workspace_dir: &Path, memory_subdir: &str, cfg: &MemorySubsystemConfig)
} else {
module_provider(workspace_dir, memory_subdir)
};
- let binding = bind_provider(provider, driver_id, reported_class, None);
+ let binding = bind_provider(
+ provider,
+ driver_id,
+ memory_subdir.to_string(),
+ reported_class,
+ None,
+ );
log::info!(
"[memory:binding] workspace={} bound driver='{}' class={} capabilities=[{}]",
workspace_dir.display(),
@@ -321,6 +346,7 @@ fn build(workspace_dir: &Path, memory_subdir: &str, cfg: &MemorySubsystemConfig)
bind_provider(
Arc::new(NullMemoryProvider::new()),
NULL_DRIVER_ID.to_string(),
+ memory_subdir.to_string(),
DriverClass::Null,
Some(fallback),
)
@@ -395,6 +421,7 @@ fn module_provider(
fn bind_provider(
provider: Arc<dyn MemoryProvider>,
driver_id: String,
+ memory_subdir: String,
class: DriverClass,
fallback: Option<FallbackReason>,
) -> MemoryBinding {
@@ -412,6 +439,7 @@ fn bind_provider(
provider,
guard,
driver_id,
+ memory_subdir,
class,
capabilities,
fallback,
@@ -428,7 +456,7 @@ pub(crate) fn bind_provider_for_test(
class: DriverClass,
) -> MemoryBinding {
let driver_id = provider.driver_id().to_string();
- bind_provider(provider, driver_id, class, None)
+ bind_provider(provider, driver_id, "memory".to_string(), class, None)
}
/// Per-workspace binding cache. Same shape as
diff --git a/src/openhuman/memory/sync/composio/bus_tests.rs b/src/openhuman/memory/sync/composio/bus_tests.rs
index 43f7a4191b..ce7902c2db 100644
--- a/src/openhuman/memory/sync/composio/bus_tests.rs
+++ b/src/openhuman/memory/sync/composio/bus_tests.rs
@@ -19,11 +19,27 @@ use super::toolkit_is_memory_source_registrable;
/// — the host must treat the toolkit as *not* registrable rather than assume
/// it is fine.
///
-/// A unit test has no loaded module, so every answer here is the
-/// cannot-answer case, which is exactly the branch worth pinning.
+/// The cannot-answer driver is **installed**, not assumed. This note used to
+/// say "a unit test has no loaded module, so every answer here is the
+/// cannot-answer case" — that is not true: `binding::module_provider`'s
+/// `cfg(test)` arm loads `TINYMEMORY_TEST_MODULE`, which CI sets to the pinned
+/// module, so the test could reach the module's real `SourceSync` and pass
+/// while pinning nothing. It also used `Config::default()`, whose workspace is
+/// the developer's own `~/.openhuman`.
+///
+/// So bind `NullMemoryProvider` — which serves no `SourceSync` family — against
+/// a workspace this test owns. The cannot-answer branch is then the branch
+/// under test by construction, on any machine, with or without the module.
#[tokio::test]
async fn a_driver_that_cannot_answer_makes_a_toolkit_not_registrable() {
- let config = crate::openhuman::config::Config::default();
+ let tmp = tempfile::TempDir::new().expect("tempdir");
+ let mut config = crate::openhuman::config::Config::default();
+ config.workspace_dir = tmp.path().to_path_buf();
+ crate::openhuman::memory::binding::install_for_test(
+ &config.workspace_dir,
+ &config.subsystems.memory,
+ std::sync::Arc::new(tinymemory_api::null::NullMemoryProvider::new()),
+ );
for toolkit in ["gmail", "slack", "github", "googlecalendar", ""] {
assert!(
diff --git a/src/openhuman/memory/tree/tree/rpc.rs b/src/openhuman/memory/tree/tree/rpc.rs
index ad3a8de6d3..135a58bcf0 100644
--- a/src/openhuman/memory/tree/tree/rpc.rs
+++ b/src/openhuman/memory/tree/tree/rpc.rs
@@ -1839,13 +1839,18 @@ mod tests {
/// Regression #3568 / CORE-2K: email payloads with RFC-3339 timestamps must
/// be accepted.
///
- /// No driver is bound: the mail arm is the one still on the in-process
- /// pipeline, for the two reasons on [`ingest_rpc`]. When it moves, this
- /// test needs `install_tinycortex_for_test` like its siblings — and the
- /// header lines it does not assert are what has to be checked first.
+ /// A driver is bound, like every sibling here. The note this replaces said
+ /// the mail arm was "still on the in-process pipeline" and that the test
+ /// would need `install_tinycortex_for_test` "when it moves" — it has moved:
+ /// the `Email` arm now goes through `ingest_through_driver`, which resolves
+ /// `provider().as_ingest()` and refuses a driver that does not serve it.
+ /// Without the binding the test only passed because CI happens to set
+ /// `TINYMEMORY_TEST_MODULE` to a module that serves `Ingest`, so it would
+ /// fail on a machine that does not.
#[tokio::test]
async fn ingest_email_accepts_rfc3339_timestamps() {
let (_tmp, cfg) = test_config();
+ crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);
let outcome = ingest_rpc(
&cfg,
IngestRequest {