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
Give json_rpc_e2e one memory workspace, as production has\n\nThis target gave every case its own `HOME`, while the module host captures a\nworkspace once per process: `set_modules_policy` ignores later calls, and the\nloaded artifact takes its `workspace_dir` at load time. So the module served\none store while each case's RPC handlers resolved another.\n\nProduction is not split — boot publishes the runtime config, so the module and\nthe handlers name one object. The harness was the outlier.\n\nThat stayed invisible while every memory path was in-process. Routing recall,\nreset and flush through the contract made it visible: three cases mix\ncontract-routed access with direct-SQLite reads of the same data, and each was\nwriting to one store and reading from the other. `memory_diff_take_snapshot`\ncounted 0 items after a successful ingest, and `memory_sources_reconcile` saw 0\nof 2 planted raw files.\n\nPoint both sides at one path. `json_rpc_e2e_shared_workspace` is a per-binary\ntemp dir the seam's policy is built from, and the three mixing cases export it\nas `OPENHUMAN_WORKSPACE`, which the config env overlay honours — the seam five\nother cases in this file already use. Its basename is `workspace` so\n`resolve_config_dir_for_workspace` returns it unchanged rather than appending a\nsecond segment.\n\nSharing a store costs the cases that assert global emptiness.\n`memory_sources_reconcile` needed nothing: it already passes `source_id`, so\nits scope count was never global. `memory_sync_and_learn` did — namespaces\nprocessed, queue depth and "ingestion is idle" are properties of the whole\nstore and no re-scoping expresses them, so it wipes first. That wipe relies on\nthe lane running this target serially, and says so at the call site with the\nline to check.\n\nTests only; no production code changed.\n
M3gA-Mind8072f78c049c
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rsindex 1667d6c302..d5173ebe58 100644--- a/tests/json_rpc_e2e.rs+++ b/tests/json_rpc_e2e.rs@@ -5,7 +5,7 @@use std::collections::VecDeque;use std::net::SocketAddr;-use std::path::Path;+use std::path::{Path, PathBuf};use std::sync::{Arc, Mutex, OnceLock};use std::time::Duration;@@ -83,6 +83,32 @@ fn json_rpc_e2e_env_lock() -> std::sync::MutexGuard<'static, ()> {}}+/// The one memory workspace every case in this binary shares.+///+/// The module host captures a workspace **once per process** — `set_modules_policy`+/// ignores later calls, and the loaded artifact takes its `workspace_dir` at load+/// time — while each case below gets its own `HOME`. Production never has that+/// mismatch: boot publishes the runtime config, so the module and the RPC+/// handlers name one object. This reproduces that arrangement by pointing both+/// at a single path — the policy below is built from it, and the cases that mix+/// contract-routed writes with direct-SQLite reads export it as+/// `OPENHUMAN_WORKSPACE`, which `config::schema::load::env_overlay` honours.+///+/// The path ends in `workspace` on purpose: `resolve_config_dir_for_workspace`+/// treats such a path as the workspace dir itself rather than appending another+/// `workspace` segment, so the env var and this constant agree exactly.+fn json_rpc_e2e_shared_workspace() -> &'static Path {+ static SHARED: OnceLock<PathBuf> = OnceLock::new();+ SHARED.get_or_init(|| {+ let tmp = tempdir().expect("shared memory workspace tempdir");+ let path = tmp.path().join("workspace");+ std::fs::create_dir_all(&path).expect("shared memory workspace dir");+ // Outlives every case in the binary; the OS reaps it with the tmpdir.+ std::mem::forget(tmp);+ path+ })+}+/// The transport-only JSON-RPC router deliberately does not construct a core/// runtime context. Install its memory seams once for this integration-test/// binary before any router can dispatch a memory-backed method.@@ -92,7 +118,10 @@ fn ensure_json_rpc_e2e_memory_seams() {.name("json-rpc-e2e-memory-seams".to_string()).stack_size(8 * 1024 * 1024).spawn(|| {- let config = Arc::new(openhuman_core::openhuman::config::Config::default());+ let config = Arc::new(openhuman_core::openhuman::config::Config {+ workspace_dir: json_rpc_e2e_shared_workspace().to_path_buf(),+ ..openhuman_core::openhuman::config::Config::default()+ });openhuman_core::openhuman::memory::host_impls::install_memory_host_seams(config.clone(),);@@ -4199,7 +4228,11 @@ async fn json_rpc_memory_sync_and_learn() {let openhuman_home = home.join(".openhuman");let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");+ // Share the module's workspace: this case ingests through the memory+ // contract and reads back through direct SQLite, so the two must name+ // one store. See `json_rpc_e2e_shared_workspace`.+ let _workspace_guard =+ EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", json_rpc_e2e_shared_workspace());let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");let _embed_strict_guard = EnvVarGuard::set("OPENHUMAN_MEMORY_EMBED_STRICT", "false");@@ -4255,6 +4288,21 @@ async fn json_rpc_memory_sync_and_learn() {let init_resp = post_json_rpc(&rpc_base, 7003, "openhuman.memory_init", json!({})).await;assert_no_jsonrpc_error(&init_resp, "memory_init");+ // The assertions below are about an EMPTY store, and the workspace is now+ // shared with the other memory cases in this binary (see+ // `json_rpc_e2e_shared_workspace`), so whatever ran earlier is still in it.+ // Re-scoping cannot express these: `namespaces_processed`, `queue_depth`+ // and "ingestion is idle" are properties of the whole store, not of one+ // source. So clear it first.+ //+ // This is safe only because the coverage lane runs this target serially —+ // `scripts/ci/rust-coverage-changed.sh`, in `run_integration_target()`:+ // llvm_cov ... --test "${target}" -- --test-threads=1+ // If that ever stops being true, a concurrent case would have its store+ // wiped underneath it and this is the line that made that possible.+ 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");+// ── 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");@@ -4512,7 +4560,11 @@ async fn json_rpc_memory_diff_snapshot_diff_and_read_marker_lifecycle() {let openhuman_home = home.join(".openhuman");let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _workspace_guard = EnvVarGuard::unset("OPENHUMAN_WORKSPACE");+ // Share the module's workspace: this case ingests through the memory+ // contract and reads back through direct SQLite, so the two must name+ // one store. See `json_rpc_e2e_shared_workspace`.+ let _workspace_guard =+ EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", json_rpc_e2e_shared_workspace());let _backend_url_guard = EnvVarGuard::unset("BACKEND_URL");let _vite_backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");// Fall back to the inert (zero-vector) embedder; CI has no local Ollama.@@ -13119,7 +13171,11 @@ async fn json_rpc_memory_sources_reconcile_reports_pending_raw_files() {let tmp = tempdir().expect("tempdir");let home = tmp.path();let _home_guard = EnvVarGuard::set_to_path("HOME", home);- let _ws_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", home);+ // `reconcile_rpc` resolves the bound driver (`as_source_sync`), so it reads+ // the module's store while the raw files below are planted on disk. Both+ // must name one workspace — see `json_rpc_e2e_shared_workspace`.+ let _ws_guard =+ EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", json_rpc_e2e_shared_workspace());let _action_guard = EnvVarGuard::set_to_path("OPENHUMAN_ACTION_DIR", home);let _backend_guard = EnvVarGuard::unset("VITE_BACKEND_URL");@@ -13149,10 +13205,10 @@ async fn json_rpc_memory_sources_reconcile_reports_pending_raw_files() {// 2. Plant two uncovered raw archive files where a fetch would write// them: <workspace>/memory_tree/content/raw/github-com-owner-repo/.- // With OPENHUMAN_WORKSPACE=$home and no config.toml, the resolved- // workspace dir is $home/workspace (resolve_config_dir_for_workspace).- let commits_dir = home- .join("workspace")+ // `OPENHUMAN_WORKSPACE` is the shared workspace above, and its basename+ // is `workspace`, so `resolve_config_dir_for_workspace` returns it+ // unchanged rather than appending a second segment.+ let commits_dir = json_rpc_e2e_shared_workspace().join("memory_tree").join("content").join("raw")