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
test(memory): cover hosted memory's families end to end
Shanu588ef6e33446
diff --git a/tests/memory_engine_e2e.rs b/tests/memory_engine_e2e.rsindex 7bf58b28d0..26555e9078 100644--- a/tests/memory_engine_e2e.rs+++ b/tests/memory_engine_e2e.rs@@ -226,21 +226,26 @@ fn engine_set_binds_the_hosted_engine_without_a_restart_and_switches_back() {"graph must be gated with the stable error: {message}");- // An unsupported family degrades to a clean error, not a panic.+ // The hosted engine serves documents (tinymemory's hosted-families+ // spec): a titled document round-trips beside the stored note.let doc = fx.call("openhuman.memory_doc_put",json!({- "namespace": NS, "key": "k", "title": "t", "content": "c",+ "namespace": NS, "key": "k", "title": "A title", "content": "c","source_type": "doc", "priority": "medium", "tags": [],"metadata": null, "category": "core"}),).await;+ result_of(&doc, "doc_put on the hosted engine");+ let v = fx+ .call("openhuman.memory_doc_list", json!({ "namespace": NS }))+ .await;+ let docs = result_of(&v, "doc_list after doc_put on hosted");assert!(- error_message(&doc, "doc_put on the hosted engine")- .contains("memory driver does not support the documents family"),- "doc_put must name the missing family: {doc}"+ docs.to_string().contains("A title") && docs.to_string().contains("engine-note"),+ "doc_list must list the titled document and the stored note: {docs}");// And back to the module, live.diff --git a/tests/memory_hosted_surface_e2e.rs b/tests/memory_hosted_surface_e2e.rsindex 978aadab0f..d610e49d73 100644--- a/tests/memory_hosted_surface_e2e.rs+++ b/tests/memory_hosted_surface_e2e.rs@@ -4,10 +4,11 @@//! The four memory suites (`memory_roundtrip_e2e`, `memory_sources_e2e`,//! `memory_graph_roundtrip_e2e`, `memory_tree_health_e2e`) run on the local//! module, whose engine serves every family. The hosted engine serves the-//! mandatory families plus ingestion and answers; this suite holds it to what-//! that means for a user: what it serves works, what it does not serve answers-//! a clean refusal rather than failing some other way, auto-recall reaches the-//! notes a user saved, and a refused lookup says why.+//! mandatory families, ingestion and answers, and goals, tool rules, documents,+//! the source sink and maintenance (tinymemory's hosted-families spec); this+//! suite holds it to what that means for a user: what it serves works, what it+//! does not serve answers a clean refusal rather than failing some other way,+//! auto-recall reaches the notes a user saved, and a refused lookup says why.//!//! ```text//! RUST_MIN_STACK=67108864 cargo test -p openhuman-cli \@@ -119,12 +120,10 @@ fn a_refused_credential_and_an_outage_have_their_own_names() {});}-/// The handler answers from the host log when the driver keeps no run log-/// (`SourceSync` is absent), for a driver that serves the `Sources` sink-/// without owning pipelines. This fixture builds no `CoreContext`, so the-/// registry's capability gate stays open and the handler is reachable here.-/// In the app, an engine without `Sources` (hosted among them) has no-/// `memory_sources.*` methods at all, and Brain gates the panel on that.+/// The handler answers from the host log when the driver keeps no run log:+/// hosted memory serves the `Sources` sink without owning pipelines+/// (`SourceSync` is absent), so its `memory_sources.*` methods are registered+/// and Sync History reads what the host recorded.#[test]fn sync_history_answers_from_the_host_log_on_an_engine_without_one() {run_on_big_stack("hosted-sync-history", || async {@@ -139,6 +138,77 @@ fn sync_history_answers_from_the_host_log_on_an_engine_without_one() {});}+/// The first `documentId` anywhere in `value`.+fn document_id(value: &serde_json::Value) -> Option<String> {+ match value {+ serde_json::Value::Object(map) => map+ .get("documentId")+ .and_then(serde_json::Value::as_str)+ .map(str::to_string)+ .or_else(|| map.values().find_map(document_id)),+ serde_json::Value::Array(items) => items.iter().find_map(document_id),+ _ => None,+ }+}++/// The families hosted memory serves beyond the mandatory ones, through the+/// app's RPCs: documents and tool rules round-trip.+#[test]+fn the_hosted_engine_serves_documents_and_tool_rules() {+ run_on_big_stack("hosted-families", || async {+ let fx = Fixture::new().await;+ bind_hosted(&fx).await;++ let v = fx+ .call(+ "openhuman.memory_doc_put",+ json!({+ "namespace": NS, "key": "tea", "title": "Tea",+ "content": "The user drinks oolong.", "source_type": "doc",+ "priority": "medium", "tags": [], "metadata": null,+ "category": "core"+ }),+ )+ .await;+ result_of(&v, "doc_put on hosted");+ let v = fx+ .call("openhuman.memory_doc_list", json!({ "namespace": NS }))+ .await;+ let listed = result_of(&v, "doc_list on hosted").clone();+ assert!(listed.to_string().contains("Tea"), "{listed}");+ let id = document_id(&listed).unwrap_or_else(|| panic!("no document id: {listed}"));+ let v = fx+ .call(+ "openhuman.memory_doc_delete",+ json!({ "namespace": NS, "document_id": id }),+ )+ .await;+ let deleted = result_of(&v, "doc_delete on hosted");+ assert!(+ deleted.to_string().contains("\"deleted\":true"),+ "{deleted}"+ );++ let v = fx+ .call(+ "openhuman.memory_tool_rule_put",+ json!({ "tool_name": "shell", "rule": "quote every path" }),+ )+ .await;+ result_of(&v, "tool_rule_put on hosted");+ let v = fx+ .call(+ "openhuman.memory_tool_rule_list",+ json!({ "tool_name": "shell" }),+ )+ .await;+ let rules = result_of(&v, "tool_rule_list on hosted");+ assert!(rules.to_string().contains("quote every path"), "{rules}");++ unbind(&fx).await;+ });+}+/// What the hosted engine does not serve answers cleanly: the RPCs that need/// a missing family name it, and the tree health reads degrade to an empty or/// unhealthy answer rather than an error.@@ -154,15 +224,6 @@ fn what_the_hosted_engine_does_not_serve_is_refused_cleanly() {json!({ "namespace": NS, "subject": "a", "predicate": "knows", "object": "b" }),),("openhuman.memory_graph_query", json!({ "namespace": NS })),- // memory_roundtrip_e2e- (- "openhuman.memory_doc_put",- json!({- "namespace": NS, "key": "k", "title": "t", "content": "c",- "source_type": "doc", "priority": "medium", "tags": [],- "metadata": null, "category": "core"- }),- ),];// Collected rather than asserted one by one, so a run names every// method that answers some other way.@@ -189,12 +250,14 @@ fn what_the_hosted_engine_does_not_serve_is_refused_cleanly() {.call("openhuman.memory_tree_list_sources", json!({})).await;assert_eq!(result_of(&v, "tree list_sources on hosted"), &json!([]));+ // Hosted memory serves Maintenance: the doctor answers from the+ // service's health probe rather than naming a missing family.let v = fx.call("openhuman.memory_tree_doctor", json!({})).await;let doctor = result_of(&v, "tree doctor on hosted");- assert_eq!(doctor["healthy"], false, "{doctor}");+ assert_eq!(doctor["healthy"], true, "{doctor}");assert!(- doctor.to_string().contains("does not serve Maintenance"),- "the doctor names the missing family: {doctor}"+ doctor.to_string().contains("\"service\""),+ "the doctor reports the hosted service stage: {doctor}");let v = fx.call("openhuman.memory_tree_pipeline_status", json!({}))diff --git a/tests/support/memory_engine_fixture.rs b/tests/support/memory_engine_fixture.rsindex 8360927b45..7b7a9ffea8 100644--- a/tests/support/memory_engine_fixture.rs+++ b/tests/support/memory_engine_fixture.rs@@ -18,7 +18,7 @@ use std::sync::atomic::{AtomicU16, AtomicU64, Ordering};use std::sync::{Arc, Mutex, OnceLock};use std::time::Duration;-use axum::extract::{Query, State};+use axum::extract::{Path as UrlPath, Query, State};use axum::http::{header::AUTHORIZATION, HeaderMap, StatusCode};use axum::routing::{get, post};use axum::{Json, Router};@@ -125,14 +125,25 @@ pub async fn experience(.lock().unwrap().insert(key, (text, id.clone()));- state.events.lock().unwrap().push(json!({+ // The engine keeps the caller's context (labels, `observed_at`) and stamps+ // its own `recorded_at`; the hosted families look records up by label.+ let mut context = body["context"].clone();+ if !context.is_object() {+ context = json!({});+ }+ context["recorded_at"] = json!("2026-09-02T00:00:00Z");+ let mut event = json!({"id": id,"scope": body["scope"],"modality": body["modality"],"wal_offset": offset,"content": body["content"],- "context": { "recorded_at": "2026-09-02T00:00:00Z" },- }));+ "context": context,+ });+ if !body["directives"].is_null() {+ event["directives"] = body["directives"].clone();+ }+ state.events.lock().unwrap().push(event);ok(json!({ "event_id": id, "status": "captured", "replayed_from_idempotency": false }))}@@ -153,9 +164,24 @@ pub async fn events(.get("limit").and_then(|v| v.parse().ok()).unwrap_or(50);+ // The engine splits its label filter on commas and keeps an event carrying+ // any one of the pieces.+ let wanted: Vec<String> = params+ .get("labels")+ .map(|labels| labels.split(',').map(|l| l.trim().to_string()).collect())+ .unwrap_or_default();+ let labelled = |event: &Value| {+ wanted.is_empty()+ || event["context"]["labels"].as_array().is_some_and(|labels| {+ labels+ .iter()+ .filter_map(Value::as_str)+ .any(|label| wanted.iter().any(|w| w == label))+ })+ };let mut stream = Vec::new();for event in state.events.lock().unwrap().iter().rev() {- if event["scope"].as_str() == Some(scope.as_str()) {+ if event["scope"].as_str() == Some(scope.as_str()) && labelled(event) {stream.push(event.clone());stream.push(event.clone());}@@ -210,12 +236,19 @@ pub async fn scopes(.get("limit").and_then(|v| v.parse().ok()).unwrap_or(50);+ // A prefix names a scope and everything under it.+ let prefix = params.get("prefix").cloned();let mut paths: Vec<String> = state.events.lock().unwrap().iter().filter_map(|e| e["scope"].as_str().map(str::to_string))+ .filter(|path| {+ prefix+ .as_deref()+ .is_none_or(|p| path == p || path.starts_with(&format!("{p}/")))+ }).collect();paths.sort();paths.dedup();@@ -223,6 +256,27 @@ pub async fn scopes(ok(json!({ "items": paths.into_iter().map(|p| json!({ "path": p })).collect::<Vec<_>>() }))}+pub async fn event_by_id(+ State(state): State<Hosted>,+ headers: HeaderMap,+ UrlPath(id): UrlPath<String>,+) -> (StatusCode, Json<Value>) {+ if let Some(early) = gate(&state, &headers) {+ return early;+ }+ let found = state+ .events+ .lock()+ .unwrap()+ .iter()+ .find(|e| e["id"].as_str() == Some(id.as_str()))+ .cloned();+ match found {+ Some(event) => ok(event),+ None => err(404, "NOT_FOUND"),+ }+}+pub async fn forget(State(state): State<Hosted>,headers: HeaderMap,@@ -254,6 +308,7 @@ pub async fn start_hosted() -> (String, Hosted) {let app = Router::new().route("/memory/experience", post(experience)).route("/memory/events", get(events))+ .route("/memory/events/{id}", get(event_by_id)).route("/memory/recall", post(recall)).route("/memory/forget", post(forget)).route("/memory/scopes", get(scopes))