Skip to content

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

Drain the shared store through the family the assertions read\n\n`json_rpc_memory_sync_and_learn` has been red on main since #5779:\n\n memory_learn_all: JSON-RPC error: memory_learn_all requires\n local_ai.runtime_enabled=true\n\nThat error is the symptom, not the cause. The case asserts `memory_learn_all`\nreturns zero processed on an empty store, and reaches "empty" by calling\n`memory_tree_wipe_all` first. When the store is not actually empty the handler\nwalks past its `target_ns.is_empty()` short-circuit and hits the\n`runtime_enabled` guard, which is what surfaces.\n\nIt only fails in the full serial target, never alone: a namespace another case\nleft — `conversation_raw` — survives the wipe. Measured: the wipe reports 14\nrows deleted, a second wipe reports `rows_deleted: 0`, and `namespace_list`\nstill answers `["conversation_raw"]` throughout.\n\n`wipe_all` reaches the driver through `binding::for_config(config)` — this\ncase's own workspace — while the assertions read through\n`active_memory_guard()`. Same binding here, but not the same store: the memory\nmodule is loaded once per process and captures the first workspace it is given,\nso every later binding in the binary (one per case, each with its own tempdir)\nis a different `MemoryBinding` over that one captured store. A `purge_all`\nscoped to this workspace cannot reach what another wrote. That asymmetry is the\none-workspace-per-process property, not a defect in `wipe_all` — a `purge_all`\nreaching across workspaces would be the real bug the day a host binds two.\n\n#5779 is what made it bite, by doing the right thing. Session memory used to\ncome from `create_session_memory_with_local_ai`, an engine-built store over\nthat case's own workspace files and invisible here; #5779 routed it onto\n`DriverMemory::for_subtree`, which is the shared module. So an agent turn in an\nearlier case now files `conversation_raw` where this case can see it. The split\nhad been hiding the collision, not preventing it.\n\nDraining through `memory_clear_namespace` is what makes this deterministic: it\ntakes `active_memory_guard()` + `as_documents()`, the exact path\n`list_namespaces` reads, so "cleared" and "listed" cannot disagree by\nconstruction. The wipe stays — the `queue_depth` and idle-ingestion assertions\nstill want it — and `memory_learn_all {}` keeps exercising the `None => all_ns`\nbranch rather than being retargeted at an explicit empty list, which would have\nduplicated the `does-not-exist` case below it and dropped that branch.\n\nVerified: the full target serially is 104 passed / 0 failed; before the drain\nthe same command fails on this case. The added `remaining.is_empty()` assertion\nis live in that run — `leftover` is `["conversation_raw"]`.\n

M3gA-Mindb353e2992d3a
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index d5173ebe58..8660efa13a 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -4303,6 +4303,68 @@ async fn json_rpc_memory_sync_and_learn() {
let wiped = post_json_rpc(&rpc_base, 7099, "openhuman.memory_tree_wipe_all", json!({})).await;
assert_no_jsonrpc_error(&wiped, "memory_tree_wipe_all before fresh-store checks");
+ // ── ...and the wipe is not enough on its own ────────────────────────────
+ //
+ // `memory_tree_wipe_all` reaches the driver through
+ // `binding::for_config(config)` — *this* case's workspace. The namespace
+ // assertions below read through `active_memory_guard()`. Those are the same
+ // binding here, but they are not the same **store**: the memory module is a
+ // native module loaded once per process, and it captures the first workspace
+ // it is given. Every later binding in this binary — one per case, each with
+ // its own tempdir — is a different `MemoryBinding` over that one captured
+ // store.
+ //
+ // So a namespace another case wrote is visible to `list_namespaces` here and
+ // is not reachable by a `purge_all` scoped to this workspace: after the wipe
+ // above reports its rows deleted, a second wipe reports `rows_deleted: 0`
+ // while `namespace_list` still answers with the other case's namespace. That
+ // asymmetry is the one-workspace-per-process property, not a defect in
+ // `wipe_all`; a `purge_all` that reached across workspaces would be the real
+ // bug the day a host binds two.
+ //
+ // openhuman#5779 is what made it bite. Before it, a session agent's memory
+ // came from `create_session_memory_with_local_ai` — an engine-built store
+ // over that case's own workspace files, invisible here. #5779 routed session
+ // memory onto `DriverMemory::for_subtree` (correctly: that is the point of
+ // #5560), and the driver is the shared module — so an agent turn in an
+ // earlier case now files `conversation_raw` where this case can see it.
+ //
+ // Draining through `memory_clear_namespace` is what makes this deterministic:
+ // it takes `active_memory_guard()` + `as_documents()`, the exact path
+ // `list_namespaces` reads through, so "cleared" and "listed" cannot disagree
+ // by construction. Do not replace this with a bigger wipe — no wipe scoped to
+ // a workspace can empty a store shared by every workspace in the process.
+ async fn list_namespaces(rpc_base: &str, id: i64) -> Vec<Value> {
+ let listed =
+ post_json_rpc(rpc_base, id, "openhuman.memory_namespace_list", json!({})).await;
+ assert_no_jsonrpc_error(&listed, "memory_namespace_list");
+ listed["result"]["result"]
+ .as_array()
+ .unwrap_or_else(|| panic!("namespace_list must answer an array, got: {listed}"))
+ .clone()
+ }
+
+ let leftover = list_namespaces(&rpc_base, 7100).await;
+ for namespace in &leftover {
+ let cleared = post_json_rpc(
+ &rpc_base,
+ 7101,
+ "openhuman.memory_clear_namespace",
+ json!({ "namespace": namespace }),
+ )
+ .await;
+ assert_no_jsonrpc_error(
+ &cleared,
+ "memory_clear_namespace draining a shared namespace",
+ );
+ }
+ let remaining = list_namespaces(&rpc_base, 7102).await;
+ assert!(
+ remaining.is_empty(),
+ "draining through the same family the assertions read through must empty the \
+ listing; started with {leftover:?}, still holding {remaining:?}"
+ );
+
// ── memory_learn_all: no namespaces → zero processed (empty store) ──────
let learn_all = post_json_rpc(&rpc_base, 7004, "openhuman.memory_learn_all", json!({})).await;
let learn_result = assert_no_jsonrpc_error(&learn_all, "memory_learn_all");