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
chore: files changed tests/in_process/agent_prompt_comprehension_e2e.rs,tests/in_process/memory_sour
Steven Enamakel8ddee6040972
diff --git a/tests/in_process/agent_prompt_comprehension_e2e.rs b/tests/in_process/agent_prompt_comprehension_e2e.rsindex 4299838b2f..210e4afb33 100644--- a/tests/in_process/agent_prompt_comprehension_e2e.rs+++ b/tests/in_process/agent_prompt_comprehension_e2e.rs@@ -25,7 +25,7 @@ use std::path::Path;use std::sync::{Mutex, OnceLock};use std::time::Duration;-use axum::http::{header::AUTHORIZATION, HeaderMap};+use axum::http::header::AUTHORIZATION;use axum::routing::{get, post};use axum::{Json, Router};use futures_util::StreamExt;diff --git a/tests/in_process/memory_sources_e2e.rs b/tests/in_process/memory_sources_e2e.rsindex b6e45ae079..348f7c87c1 100644--- a/tests/in_process/memory_sources_e2e.rs+++ b/tests/in_process/memory_sources_e2e.rs@@ -6,81 +6,27 @@//!//! Run with: `cargo test -p openhuman-cli --test in_process_all`+use crate::memory_rpc::{ok, serve, write_config};use crate::env_guard::EnvVarGuard;use crate::env_guard::env_lock;-use crate::memory_module;-use crate::rpc_auth::{ensure_rpc_auth, rpc_token};+use crate::rpc_auth::rpc_token;use std::path::Path;-use std::sync::{Arc, OnceLock};+use std::sync::OnceLock;use std::time::Duration;use axum::http::header::AUTHORIZATION;use serde_json::{json, Value};use tempfile::tempdir;-use openhuman_rpc::server::build_core_http_router;-static MEMORY_SEAMS_INIT: OnceLock<()> = OnceLock::new();static TEST_HOME: OnceLock<tempfile::TempDir> = OnceLock::new();-/// The transport-only JSON-RPC router does not create a core runtime context,-/// so memory-backed routes need their host seams installed explicitly.-fn ensure_memory_seams() {- MEMORY_SEAMS_INIT.get_or_init(|| {- std::thread::Builder::new()- .name("memory-sources-e2e-seams".to_string())- .stack_size(8 * 1024 * 1024)- .spawn(|| {- let config = Arc::new(openhuman_core::config::Config::default());- #[cfg(feature = "modules")]- openhuman_core::modules::memory::set_modules_policy(config);- })- .expect("spawn memory sources seam installer")- .join()- .expect("memory sources seam installer panicked");- });-}-fn test_home() -> &'static Path {TEST_HOME.get_or_init(|| tempdir().expect("memory sources tempdir")).path()}-fn write_config(dir: &Path) {- std::fs::create_dir_all(dir).expect("mkdir");- let cfg = r#"-default_model = "e2e-mock-model"-default_temperature = 0.7--[secrets]-encrypt = false--[memory_tree]-embedding_strict = false-"#;- std::fs::write(dir.join("config.toml"), cfg).expect("write config");-- let user_dir = dir.join("users").join("local");- std::fs::create_dir_all(&user_dir).expect("mkdir user dir");- std::fs::write(user_dir.join("config.toml"), cfg).expect("write user config");-}--async fn serve() -> (String, tokio::task::JoinHandle<Result<(), std::io::Error>>) {- ensure_memory_seams();- ensure_rpc_auth();- // Every flow here reaches the memory module; wait out its load so a test- // running in its own process does not race it (tests/support/memory_module.rs).- memory_module::settle().await;- let listener = tokio::net::TcpListener::bind("127.0.0.1:0")- .await- .expect("bind");- let addr = listener.local_addr().expect("addr");- let handle =- tokio::spawn(async move { axum::serve(listener, build_core_http_router(false)).await });- (format!("http://{addr}"), handle)-}-async fn rpc(base: &str, id: i64, method: &str, params: Value) -> Value {let client = reqwest::Client::builder().timeout(Duration::from_secs(30))@@ -110,21 +56,6 @@ async fn rpc(base: &str, id: i64, method: &str, params: Value) -> Value {.unwrap_or_else(|e| panic!("json parse for {method}: {e}"))}-fn ok(v: &Value, ctx: &str) -> Value {- if let Some(err) = v.get("error") {- panic!("{ctx}: JSON-RPC error: {err}");- }- let outer = v- .get("result")- .unwrap_or_else(|| panic!("{ctx}: missing result: {v}"));- // Outcome wraps the payload under an inner "result" key alongside "logs".- if let Some(inner) = outer.get("result") {- inner.clone()- } else {- outer.clone()- }-}-// ── Tests ─────────────────────────────────────────────────────────#[tokio::test]diff --git a/tests/in_process/memory_tree_health_e2e.rs b/tests/in_process/memory_tree_health_e2e.rsindex dc6049db57..df01187dcc 100644--- a/tests/in_process/memory_tree_health_e2e.rs+++ b/tests/in_process/memory_tree_health_e2e.rs@@ -24,10 +24,10 @@//! cross-method invariant that IS reachable and says so in a comment, rather//! than asserting `0 == 0` and calling it coverage.+use crate::memory_rpc::{ok, serve, write_config};use crate::env_guard::EnvVarGuard;use crate::env_guard::env_lock;-use crate::memory_module;-use crate::rpc_auth::{ensure_rpc_auth, rpc_token};+use crate::rpc_auth::rpc_token;use std::path::Path;use std::sync::{Arc, OnceLock};use std::time::Duration;@@ -36,7 +36,6 @@ use axum::http::header::AUTHORIZATION;use serde_json::{json, Value};use tempfile::tempdir;-use openhuman_rpc::server::build_core_http_router;static MEMORY_SEAMS_INIT: OnceLock<()> = OnceLock::new();static TEST_HOME: OnceLock<tempfile::TempDir> = OnceLock::new();@@ -66,40 +65,6 @@ fn test_home() -> &'static Path {.path()}-fn write_config(dir: &Path) {- std::fs::create_dir_all(dir).expect("mkdir");- let cfg = r#"-default_model = "e2e-mock-model"-default_temperature = 0.7--[secrets]-encrypt = false--[memory_tree]-embedding_strict = false-"#;- std::fs::write(dir.join("config.toml"), cfg).expect("write config");-- let user_dir = dir.join("users").join("local");- std::fs::create_dir_all(&user_dir).expect("mkdir user dir");- std::fs::write(user_dir.join("config.toml"), cfg).expect("write user config");-}--async fn serve() -> (String, tokio::task::JoinHandle<Result<(), std::io::Error>>) {- ensure_memory_seams();- ensure_rpc_auth();- // Every flow here reaches the memory module; wait out its load so a test- // running in its own process does not race it (tests/support/memory_module.rs).- memory_module::settle().await;- let listener = tokio::net::TcpListener::bind("127.0.0.1:0")- .await- .expect("bind");- let addr = listener.local_addr().expect("addr");- let handle =- tokio::spawn(async move { axum::serve(listener, build_core_http_router(false)).await });- (format!("http://{addr}"), handle)-}-async fn rpc(base: &str, id: i64, method: &str, params: Value) -> Value {let client = reqwest::Client::builder().timeout(Duration::from_secs(30))@@ -129,21 +94,6 @@ async fn rpc(base: &str, id: i64, method: &str, params: Value) -> Value {.unwrap_or_else(|e| panic!("json parse for {method}: {e}"))}-fn ok(v: &Value, ctx: &str) -> Value {- if let Some(err) = v.get("error") {- panic!("{ctx}: JSON-RPC error: {err}");- }- let outer = v- .get("result")- .unwrap_or_else(|| panic!("{ctx}: missing result: {v}"));- // Outcome wraps the payload under an inner "result" key alongside "logs".- if let Some(inner) = outer.get("result") {- inner.clone()- } else {- outer.clone()- }-}-// ── Tests ──────────────────────────────────/// Ingest one source under `home`, returning the chunk count written.diff --git a/tests/in_process/tree_summarizer_e2e.rs b/tests/in_process/tree_summarizer_e2e.rsindex 507c2db694..c69047170e 100644--- a/tests/in_process/tree_summarizer_e2e.rs+++ b/tests/in_process/tree_summarizer_e2e.rs@@ -20,10 +20,10 @@//!//! Run with: `cargo test -p openhuman-cli --test in_process_all`+use crate::memory_rpc::{serve, write_config};use crate::env_guard::EnvVarGuard;use crate::env_guard::env_lock;-use crate::memory_module;-use crate::rpc_auth::{ensure_rpc_auth, rpc_token};+use crate::rpc_auth::rpc_token;use std::path::{Path, PathBuf};use std::sync::OnceLock;use std::time::Duration;@@ -33,11 +33,9 @@ use chrono::{DateTime, SecondsFormat, TimeZone, Utc};use serde_json::{json, Value};use tempfile::TempDir;-use openhuman_rpc::server::build_core_http_router;const NAMESPACE: &str = "tree-summarizer-e2e";-static MEMORY_SEAMS_INIT: OnceLock<()> = OnceLock::new();static TEST_HOME: OnceLock<TempDir> = OnceLock::new();fn test_home() -> &'static Path {@@ -46,71 +44,6 @@ fn test_home() -> &'static Path {.path()}-/// Publish the module host policy for this process.-///-/// `tree_summarizer_ingest` reaches the loaded tinymemory module through-/// `tree_guard`, and without this every call fails with "the module host policy-/// was never published ... call modules::memory::set_modules_policy during-/// boot". Installed on its own 8 MB thread for the same reason the sibling-/// suites do: the policy build recurses deeper than a default test stack.-///-/// The `#[cfg(feature = "modules")]` body is evaluated against **openhuman-cli**'s-/// features, not the core's. `openhuman-cli`'s own `modules` flag is OFF in its-/// default set even though `openhuman-core/modules` is on transitively, so a-/// bare `cargo test -p openhuman-cli --test in_process_all` compiles this-/// to a no-op and every test here fails on the message above. Run it the way-/// `scripts/test-rust-e2e.sh` does:-///-/// RUST_MIN_STACK=67108864 cargo test -p openhuman-cli \-/// --features "$(bash scripts/ci/product-features.sh)" \-/// --test in_process_all-fn ensure_memory_seams() {- MEMORY_SEAMS_INIT.get_or_init(|| {- std::thread::Builder::new()- .name("tree-summarizer-e2e-seams".to_string())- .stack_size(8 * 1024 * 1024)- .spawn(|| {- let config = std::sync::Arc::new(openhuman_core::config::Config::default());- #[cfg(feature = "modules")]- openhuman_core::modules::memory::set_modules_policy(config);- })- .expect("spawn tree summarizer seam installer")- .join()- .expect("tree summarizer seam installer panicked");- });-}--fn write_config(dir: &Path) {- std::fs::create_dir_all(dir).expect("mkdir openhuman home");- let cfg = r#"-default_model = "e2e-mock-model"-default_temperature = 0.7--[secrets]-encrypt = false--[memory_tree]-embedding_strict = false-"#;- std::fs::write(dir.join("config.toml"), cfg).expect("write config");- let user_dir = dir.join("users").join("local");- std::fs::create_dir_all(&user_dir).expect("mkdir user dir");- std::fs::write(user_dir.join("config.toml"), cfg).expect("write user config");-}--async fn serve() -> (String, tokio::task::JoinHandle<Result<(), std::io::Error>>) {- ensure_memory_seams();- ensure_rpc_auth();- memory_module::settle().await;- let listener = tokio::net::TcpListener::bind("127.0.0.1:0")- .await- .expect("bind");- let addr = listener.local_addr().expect("addr");- let handle =- tokio::spawn(async move { axum::serve(listener, build_core_http_router(false)).await });- (format!("http://{addr}"), handle)-}-async fn rpc(base: &str, id: i64, method: &str, params: Value) -> Value {let client = reqwest::Client::builder().timeout(Duration::from_secs(30))diff --git a/tests/in_process_all.rs b/tests/in_process_all.rsindex b01896350c..9340c78c2d 100644--- a/tests/in_process_all.rs+++ b/tests/in_process_all.rs@@ -29,6 +29,8 @@pub mod env_guard;#[path = "support/memory_module.rs"]pub mod memory_module;+#[path = "support/memory_rpc.rs"]+pub mod memory_rpc;#[path = "support/noop_memory.rs"]pub mod noop_memory;#[path = "support/rpc_auth.rs"]diff --git a/tests/support/memory_rpc.rs b/tests/support/memory_rpc.rsnew file mode 100644index 0000000000..64bed26f0d--- /dev/null+++ b/tests/support/memory_rpc.rs@@ -0,0 +1,92 @@+//! Boilerplate shared by the memory RPC suites that serve the core router+//! in-process (`memory_sources_e2e`, `memory_tree_health_e2e`,+//! `tree_summarizer_e2e`): the memory-module policy seam, a minimal workspace+//! config, a served router with the memory module settled, and the+//! `Outcome`-unwrapping `ok`.+//!+//! Declare it at the root of an aggregated target next to `rpc_auth` and+//! `memory_module`.++#![allow(dead_code)]++use std::path::Path;+use std::sync::{Arc, OnceLock};++use openhuman_rpc::server::build_core_http_router;+use serde_json::Value;++use crate::memory_module;+use crate::rpc_auth::ensure_rpc_auth;++static MEMORY_SEAMS_INIT: OnceLock<()> = OnceLock::new();++/// Install the memory module's policy once per process, on a thread with a+/// stack deep enough for the policy build (a default test stack overflows).+pub fn ensure_memory_seams() {+ MEMORY_SEAMS_INIT.get_or_init(|| {+ std::thread::Builder::new()+ .name("memory-e2e-seams".to_string())+ .stack_size(8 * 1024 * 1024)+ .spawn(|| {+ let config = Arc::new(openhuman_core::config::Config::default());+ #[cfg(feature = "modules")]+ openhuman_core::modules::memory::set_modules_policy(config);+ })+ .expect("spawn memory seam installer")+ .join()+ .expect("memory seam installer panicked");+ });+}++/// Write the minimal workspace config (plus the `users/local` copy) under `dir`.+pub fn write_config(dir: &Path) {+ std::fs::create_dir_all(dir).expect("mkdir");+ let cfg = r#"+default_model = "e2e-mock-model"+default_temperature = 0.7++[secrets]+encrypt = false++[memory_tree]+embedding_strict = false+"#;+ std::fs::write(dir.join("config.toml"), cfg).expect("write config");++ let user_dir = dir.join("users").join("local");+ std::fs::create_dir_all(&user_dir).expect("mkdir user dir");+ std::fs::write(user_dir.join("config.toml"), cfg).expect("write user config");+}++/// Serve the core router with the memory module loaded; returns the base URL.+///+/// Every flow reaches the memory module, so wait out its load: a test running+/// in its own process would otherwise race it (see `memory_module`).+pub async fn serve() -> (String, tokio::task::JoinHandle<Result<(), std::io::Error>>) {+ ensure_memory_seams();+ ensure_rpc_auth();+ memory_module::settle().await;+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0")+ .await+ .expect("bind");+ let addr = listener.local_addr().expect("addr");+ let handle =+ tokio::spawn(async move { axum::serve(listener, build_core_http_router(false)).await });+ (format!("http://{addr}"), handle)+}++/// The envelope's payload: `result.result` when the `Outcome` wraps one next to+/// its `logs`, else `result`. Panics with `ctx` on a JSON-RPC error.+pub fn ok(v: &Value, ctx: &str) -> Value {+ if let Some(err) = v.get("error") {+ panic!("{ctx}: JSON-RPC error: {err}");+ }+ let outer = v+ .get("result")+ .unwrap_or_else(|| panic!("{ctx}: missing result: {v}"));+ if let Some(inner) = outer.get("result") {+ inner.clone()+ } else {+ outer.clone()+ }+}