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): restore the flows guards, and drop the seam installers' remains
Shanuf5fa3cc40b3d
diff --git a/src/openhuman/agent/agent_tests.rs b/src/openhuman/agent/agent_tests.rsindex fba4b26c0f..72aa3052e5 100644--- a/src/openhuman/agent/agent_tests.rs+++ b/src/openhuman/agent/agent_tests.rs@@ -225,15 +225,11 @@ impl Tool for CountingTool {/// The returned `TempDir` must be held alive for the duration of the test/// to prevent the directory (and its SQLite database) from being deleted.fn make_memory() -> (Arc<dyn Memory>, tempfile::TempDir) {- // The embedding seam fails loudly when unwired; before the memory- // extraction this was a direct call and needed no setup.+ // `backend: "none"` is what this fixture used to ask the engine's factory+ // for, and a no-op store is exactly what that produced — so the config is+ // gone rather than kept as an unused binding that reads like it still+ // selects something.let tmp = tempfile::TempDir::new().unwrap();- let _cfg = MemoryConfig {- backend: "none".into(),- ..MemoryConfig::default()- };- // The embedding seam fails loudly when unwired; before the memory- // extraction this was a direct call and needed no setup.let mem = crate::openhuman::memory::test_support::noop_memory();(mem, tmp)}diff --git a/src/openhuman/flows/tinyflows/memory_node_e2e_tests.rs b/src/openhuman/flows/tinyflows/memory_node_e2e_tests.rsindex 8d9dafc6f1..6b08e301cb 100644--- a/src/openhuman/flows/tinyflows/memory_node_e2e_tests.rs+++ b/src/openhuman/flows/tinyflows/memory_node_e2e_tests.rs@@ -263,8 +263,118 @@ async fn memory_node_remember_then_recall_round_trips_through_the_real_engine_an);}-// ── 3. security invariant end-to-end: scope:"user" writes are rejected,-// and the user's real memory store is never touched ────────────────────────+// ── 3. security invariant end-to-end: scope:"user" writes are rejected ─────-// ── 4. dry_run_workflow still works with a memory node: MockMemory returns-// shaped data without ever touching the real store ─────────────────────────+/// A `remember` node asking for `scope: "user"` is refused twice over.+///+/// This test used to assert a third thing: that the user's real+/// `GLOBAL_NAMESPACE` store held nothing under the key afterwards. That layer+/// needed `tinymemory_core::global::client_if_ready()` and+/// `tinycortex::memory::GLOBAL_NAMESPACE` — an in-process engine — and went+/// with it (openhuman#6161). It is not replaced here, and pretending otherwise+/// would be worse than saying so: the fake driver this crate now binds has no+/// user store to leave untouched, so an assertion against it would pass+/// whether or not the guard held.+///+/// The two layers that remain are the ones that do the refusing, and neither+/// needed an engine to begin with. Deleting them along with the third was the+/// mistake this restores.+#[tokio::test]+async fn memory_node_remember_user_scope_is_rejected_before_it_can_write() {+ let _serial = lock_shared_memory().await;+ let (_tmp, config) = full_autonomy_config();+ let flow_id = unique_flow_id("e2e-security");+ let caps = build_capabilities(config, format!("flow:{flow_id}"));+ let forbidden_key = format!("forbidden-{}", uuid::Uuid::new_v4());++ // ── (a) validate-time rejection: tinyflows' own structural validator+ // rejects a `remember`/`scope: "user"` node BEFORE compile ever succeeds,+ // so a graph shaped this way can never reach a run. Nothing else in this+ // crate asserts the compiler half. ──+ let user_scope_graph = trigger_to_memory(json!({+ "operation": "remember",+ "scope": "user",+ "key": forbidden_key,+ "value": "must never be written to user memory"+ }));+ let compile_err = tinyflows::compiler::compile(&user_scope_graph)+ .expect_err("scope: \"user\" on a remember node must be rejected at validate/compile time");+ assert!(+ compile_err.to_string().to_lowercase().contains("user"),+ "expected the validator's scope:\"user\" rejection, got: {compile_err}"+ );++ // ── (b) defense-in-depth: even bypassing tinyflows' validator entirely and+ // calling straight through to the adapter `build_capabilities` wired — the+ // exact instance a real run would dispatch to — `OpenHumanMemory::remember`+ // independently refuses anything but scope: "flow".+ //+ // `memory_adapter_tests::remember_rejects_user_scope` covers the same+ // refusal on a directly-constructed adapter. This one is not redundant with+ // it: what is under test here is that the capability a real run receives is+ // that adapter, rather than something assembled differently on the way. ──+ let direct_err = turn_origin::with_origin(+ workflow_origin(&flow_id),+ caps.memory+ .as_ref()+ .expect("build_capabilities must wire a memory capability")+ .remember("user", &forbidden_key, json!("must never be written")),+ )+ .await+ .expect_err("the adapter itself must independently refuse scope: \"user\"");+ assert!(direct_err+ .to_string()+ .contains("only supports scope \"flow\""));+}++// ── 4. dry_run_workflow still works with a memory node ─────────────────────++/// A graph containing a `memory` node dry-runs end to end against the mock+/// capabilities `DryRunWorkflowTool` wires, and comes back with `MockMemory`'s+/// shaped echo rather than store content.+///+/// The two assertions that read the real on-disk store before and after — "the+/// dry run never wrote there" — needed an in-process engine and went with it+/// (openhuman#6161). What survives still distinguishes the two paths, because+/// the echo is `MockMemory`'s and no real adapter produces it: a dry run that+/// had reached the real store would fail the `mem_1` assertion rather than+/// pass it quietly.+#[tokio::test]+async fn memory_node_dry_run_uses_mock_memory_end_to_end() {+ let mock_caps = tinyflows::caps::mock::mock_capabilities();++ let remember_graph = trigger_to_memory(json!({+ "operation": "remember",+ "scope": "flow",+ "key": "item-42",+ "value": "should never reach the real store in a dry run"+ }));+ let compiled_remember =+ tinyflows::compiler::compile(&remember_graph).expect("compile remember graph");+ let remember_outcome = tinyflows::engine::run(&compiled_remember, Value::Null, &mock_caps)+ .await+ .expect("dry-run remember should succeed against MockMemory");+ assert_eq!(+ remember_outcome.output["nodes"]["mem"]["items"][0]["json"]["json"]["ok"],+ json!(true)+ );++ let recall_graph = trigger_to_memory(json!({+ "operation": "recall",+ "scope": "flow",+ "query": "item-42"+ }));+ let compiled_recall =+ tinyflows::compiler::compile(&recall_graph).expect("compile recall graph");+ let recall_outcome = tinyflows::engine::run(&compiled_recall, Value::Null, &mock_caps)+ .await+ .expect("dry-run recall should succeed against MockMemory");+ let results = recall_outcome.output["nodes"]["mem"]["items"][0]["json"]["json"]["results"]+ .as_array()+ .cloned()+ .unwrap_or_default();+ assert!(+ results.iter().any(|hit| hit["id"] == json!("mem_1")),+ "expected MockMemory's fixed shaped echo (not real-store content), got: {results:?}"+ );+}diff --git a/src/openhuman/memory/ops/documents_tests.rs b/src/openhuman/memory/ops/documents_tests.rsindex 867dc87f4f..9d4037a504 100644--- a/src/openhuman/memory/ops/documents_tests.rs+++ b/src/openhuman/memory/ops/documents_tests.rs@@ -114,14 +114,21 @@ async fn direct_document_handlers_roundtrip_through_namespace() {}).await.expect("context_query");- // Only that the handler reached a driver and returned a body. **Not** that- // the body mentions "ownership": that is semantic retrieval — the driver- // ranking a query against document content — and it is the engine's- // behaviour, asserted upstream against the engine itself+ // The handler reached a driver and returned a rendered context body.+ //+ // **Not** that the body mentions "ownership": that is semantic retrieval —+ // the driver ranking a query against document content — which is the+ // engine's behaviour and is asserted upstream against the engine itself// (`tinymemory`'s `full_provider_conformance`). Pinning it from here made// this handler test pass or fail on whether the bound driver happens to// implement search, which is not what `context_query`'s wiring is.- let _ = &queried.value;+ //+ // What *is* this handler's own contract is that it forwards the driver's+ // `context_text` and tags the call — so that is what is asserted.+ // Borrowing the value and asserting nothing, which is what this line was+ // between deleting the content assertion and now, would let a handler that+ // stopped calling the driver entirely pass.+ assert_eq!(queried.logs, vec!["memory context queried".to_string()]);let recalled = context_recall(RecallNamespaceParams {namespace: namespace.clone(),diff --git a/tests/agent_turn_overrides_e2e.rs b/tests/agent_turn_overrides_e2e.rsindex a95392f713..a29566984d 100644--- a/tests/agent_turn_overrides_e2e.rs+++ b/tests/agent_turn_overrides_e2e.rs@@ -81,24 +81,6 @@ fn env_lock() -> std::sync::MutexGuard<'static, ()> {.unwrap_or_else(|poisoned| poisoned.into_inner())}-static MEMORY_SEAMS_INIT: OnceLock<()> = OnceLock::new();--/// `create_memory` requires the TinyMemory host seams and fails loudly when they-/// are unwired — a deliberate choice, since an unwired embedding host would-/// otherwise corrupt an embedding space quietly. Installed on a wide stack-/// because the seam installer recurses deeply.-fn ensure_memory_seams() {- MEMORY_SEAMS_INIT.get_or_init(|| {- std::thread::Builder::new()- .name("turn-overrides-e2e-seams".to_string())- .stack_size(8 * 1024 * 1024)- .spawn(|| {})- .expect("spawn turn-overrides seam installer")- .join()- .expect("turn-overrides seam installer panicked");- });-}-/// The agent turn loop needs the wide worker stack the product gives it.fn run_on_agent_stack<F, Fut>(name: &str, future_factory: F)where@@ -292,7 +274,6 @@ fn suppress_active_goal_keeps_the_thread_goal_out_of_the_prompt() {}async fn suppress_active_goal_keeps_the_thread_goal_out_of_the_prompt_inner() {- ensure_memory_seams();let _env = env_lock();// Control and measured agent get SEPARATE workspaces on purpose.@@ -387,7 +368,6 @@ fn suppress_transcript_autoload_does_not_replay_a_prior_threads_transcript() {}async fn suppress_transcript_autoload_does_not_replay_a_prior_threads_transcript_inner() {- ensure_memory_seams();let _env = env_lock();let (_temp, workspace_path) = workspace("suppress-transcript-autoload");let _workspace_guard = EnvGuard::set_path("OPENHUMAN_WORKSPACE", &workspace_path);@@ -490,7 +470,6 @@ fn turn_overrides_apply_to_exactly_one_turn_and_then_reset() {}async fn turn_overrides_apply_to_exactly_one_turn_and_then_reset_inner() {- ensure_memory_seams();let _env = env_lock();let (_temp, workspace_path) = workspace("overrides-reset");let _workspace_guard = EnvGuard::set_path("OPENHUMAN_WORKSPACE", &workspace_path);@@ -549,7 +528,6 @@ fn thread_goal_complete_and_clear_stop_the_goal_reaching_later_turns() {}async fn thread_goal_complete_and_clear_stop_the_goal_reaching_later_turns_inner() {- ensure_memory_seams();let _env = env_lock();// Separate workspaces, for the same reason asdiff --git a/tests/worker_c_modules_e2e.rs b/tests/worker_c_modules_e2e.rsindex 572c1ac008..9c28f0595b 100644--- a/tests/worker_c_modules_e2e.rs+++ b/tests/worker_c_modules_e2e.rs@@ -117,17 +117,6 @@ embedding_strict = falseasync fn setup() -> Harness {ensure_rpc_auth();- // Memory-source RPC handlers invoke the extracted tinymemory host seams- // from background work. Production startup installs these before building- // the router; mirror that wiring in this standalone transport harness.- std::thread::Builder::new()- .name("worker-c-memory-seams".to_string())- .stack_size(8 * 1024 * 1024)- .spawn(|| {})- .expect("spawn worker-c memory seam installer")- .join()- .expect("worker-c memory seam installer panicked");-let tmp = tempdir().expect("tempdir");let home = tmp.path();write_config(&home.join(".openhuman"));