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): bind a fake driver instead of an in-process engine
Shanu7b0d05a6949c
diff --git a/Cargo.lock b/Cargo.lockindex 7d50315313..07261ba1d3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4186,6 +4186,7 @@ dependencies = ["tinymcp-bus","tinymemory-api","tinymemory-bus",+ "tinymemory-conformance","tinymemory-core","tinymemory-sources","tinymemory-tinycortex",@@ -6756,6 +6757,16 @@ dependencies = ["uuid",]+[[package]]+name = "tinymemory-conformance"+version = "0.1.0"+dependencies = [+ "anyhow",+ "async-trait",+ "serde_json",+ "tinymemory-api",+]+[[package]]name = "tinymemory-core"version = "0.1.0"diff --git a/Cargo.toml b/Cargo.tomlindex 0e1360002d..63d36263d9 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -832,6 +832,19 @@ tinycortex = { version = "0.1", features = ["obsidian", "persona", "sync"] }# requirement) out of the product while the tests that need a real engine keep# working.tinymemory-tinycortex = { path = "vendor/tinymemory/crates/tinymemory-tinycortex" }+# The fake memory driver the host's own tests bind, in place of an in-process+# engine (openhuman#6161). It serves every optional family, so a handler that+# asks for one by accessor gets `Some` rather than taking the `None` arm as+# "unsupported" — which is the whole reason the fixture used to construct a real+# `TinycortexProvider`.+#+# It costs this manifest nothing. The crate is `publish = false` and reached by+# path like `tinymemory-api`, and its only dependencies are `tinymemory-api`,+# `async-trait`, `serde_json` and `anyhow` — all already in the product graph.+# By construction it cannot pull an engine back in: `tinymemory-conformance`+# refuses to depend on `tinymemory-core`, and its CI asserts that, because a+# conformance suite that reached an engine could not prove interchangeability.+tinymemory-conformance = { path = "vendor/tinymemory/crates/tinymemory-conformance" }# Dual-declared on purpose (same shape as the `sentry`/`axum` entries): the# optional dependency above is bin-only behind `bin-tools`, but# `agent_orchestration::tools::tools_e2e_tests` (a #[cfg(test)] LIB module),diff --git a/src/openhuman/agent/experience/ops_tests.rs b/src/openhuman/agent/experience/ops_tests.rsindex d211aa4af8..47699cce15 100644--- a/src/openhuman/agent/experience/ops_tests.rs+++ b/src/openhuman/agent/experience/ops_tests.rs@@ -55,7 +55,7 @@ fn bound_config() -> (tempfile::TempDir, Config) {config.memory_tree.embedding_endpoint = None;config.memory_tree.embedding_model = None;config.memory_tree.embedding_strict = false;- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);(tmp, config)}diff --git a/src/openhuman/agent/harness/archivist_tests.rs b/src/openhuman/agent/harness/archivist_tests.rsindex 8ee9245fe2..e8b4a4a397 100644--- a/src/openhuman/agent/harness/archivist_tests.rs+++ b/src/openhuman/agent/harness/archivist_tests.rs@@ -224,7 +224,7 @@ async fn phase2_no_per_turn_tree_write_inner() {async fn phase2_exactly_one_tree_ingest_per_segment_close_inner() {let (_tmp, cfg) = test_config_with_tree();- let (client, provider) = provider_over(&cfg.workspace_dir);+ let (_client, provider) = provider_over(&cfg.workspace_dir);let hook = hook_with_stubs_and_tree_config(provider.clone(), cfg.clone());let session = "phase2-one-ingest";@@ -387,7 +387,7 @@ async fn phase2_provenance_stamped_on_leaf_and_source_id_is_constant_inner() {async fn phase2_ingested_content_is_raw_prose_not_recap_inner() {let (_tmp, cfg) = test_config_with_tree();- let (client, provider) = provider_over(&cfg.workspace_dir);+ let (_client, provider) = provider_over(&cfg.workspace_dir);let hook = hook_with_stubs_and_tree_config(provider.clone(), cfg.clone());let session = "phase2-raw-prose";@@ -448,7 +448,7 @@ async fn phase2_ingested_content_is_raw_prose_not_recap_inner() {async fn phase2_flush_also_triggers_tree_ingest_inner() {let (_tmp, cfg) = test_config_with_tree();- let (client, provider) = provider_over(&cfg.workspace_dir);+ let (_client, provider) = provider_over(&cfg.workspace_dir);let hook = hook_with_stubs_and_tree_config(provider.clone(), cfg.clone());let session = "phase2-flush-tree";diff --git a/src/openhuman/channels/controllers/ops_tests.rs b/src/openhuman/channels/controllers/ops_tests.rsindex e957651f7f..259a69c13b 100644--- a/src/openhuman/channels/controllers/ops_tests.rs+++ b/src/openhuman/channels/controllers/ops_tests.rs@@ -5,7 +5,6 @@ use crate::openhuman::config::schema::{DiscordConfig, IMessageConfig};use chrono::{TimeZone, Utc};use tempfile::tempdir;use tinymemory_api::chunks::{chunk_id, Chunk, Metadata, SourceKind, SourceRef};-use tinymemory_core::store::chunks::store as memory_tree_store;fn isolated_test_config() -> (tempfile::TempDir, Config) {let tmp = tempdir().expect("failed to create temp dir");diff --git a/src/openhuman/channels/controllers/ops_tests_part_01_tests.rs b/src/openhuman/channels/controllers/ops_tests_part_01_tests.rsindex 639646b070..5aa7849c5e 100644--- a/src/openhuman/channels/controllers/ops_tests_part_01_tests.rs+++ b/src/openhuman/channels/controllers/ops_tests_part_01_tests.rs@@ -160,56 +160,6 @@ async fn disconnect_discord_bot_token_clears_runtime_config() {);}-/// The clear-memory half of disconnect goes through the bound driver's-/// `MemorySourceSink::forget_matching` now, so the workspace needs a driver-/// that serves `Sources` — the null driver a unit-test workspace otherwise-/// resolves to does not, and the handler refuses rather than reporting a-/// delete of nothing. Seeding and reading back still go straight to the store,-/// which is what makes this an end-to-end assertion rather than a mock.-#[tokio::test]-async fn disconnect_channel_clear_memory_deletes_matching_chat_sources() {- let (_tmp, mut config) = isolated_test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- config.channels_config.discord = Some(DiscordConfig {- bot_token: "discord-token-abc".to_string(),- guild_id: Some("guild-1".to_string()),- channel_id: Some("channel-2".to_string()),- allowed_users: vec![],- listen_to_bots: false,- mention_only: false,- });- config- .save()- .await- .expect("preloaded config should be persisted");-- let target_a = sample_chat_chunk("discord:guild-1", 0);- let target_b = sample_chat_chunk("discord:guild-1:channel-2", 1);- let unrelated = sample_chat_chunk("telegram:chat-1", 0);- memory_tree_store::upsert_chunks(&config, &[target_a, target_b, unrelated])- .expect("chunks should seed");-- let result = disconnect_channel(&config, "discord", ChannelAuthMode::BotToken, true)- .await- .expect("discord disconnect should succeed");-- assert_eq!(- result.value["memory_chunks_deleted"].as_u64(),- Some(2),- "disconnect should report deleted memory chunks"- );- let remaining = memory_tree_store::list_chunks(- &config,- &memory_tree_store::ListChunksQuery {- source_kind: Some(SourceKind::Chat),- ..Default::default()- },- )- .expect("chunks should list");- assert_eq!(remaining.len(), 1);- assert_eq!(remaining[0].metadata.source_id, "telegram:chat-1");-}-// ── iMessage channel ───────────────────────────────────────────#[tokio::test]async fn connect_imessage_persists_allowed_contacts() {diff --git a/src/openhuman/flows/memory_tools_tests.rs b/src/openhuman/flows/memory_tools_tests.rsindex 979b9579dc..d1ad38253a 100644--- a/src/openhuman/flows/memory_tools_tests.rs+++ b/src/openhuman/flows/memory_tools_tests.rs@@ -28,7 +28,7 @@ use crate::openhuman::memory::api::types::{// supertrait is `MemoryCore`, which is a *different* trait with taint as// an argument rather than a second method (see `provider/mandatory.rs`,// which says so at the definition). Rebinding the fixture onto-// `memory::test_support::install_tinycortex_for_test` therefore rewrites+// `memory::test_support::install_memory_driver_for_test` therefore rewrites// every `mem.store_with_taint(..)` / `mem.get(..)` in this module, not// just its two lines.// 2. **The backend choice is load-bearing.** `FLOW_MEMORY_NAMESPACE_PREFIX`'sdiff --git a/src/openhuman/flows/ops_tests_part_03_tests.rs b/src/openhuman/flows/ops_tests_part_03_tests.rsindex 804ebec155..c798a7fe2b 100644--- a/src/openhuman/flows/ops_tests_part_03_tests.rs+++ b/src/openhuman/flows/ops_tests_part_03_tests.rs@@ -135,82 +135,6 @@ async fn reconcile_schedule_triggers_on_boot_survives_a_corrupt_row() {);}-#[tokio::test]-async fn flows_delete_clears_flow_memory_namespace() {- use crate::openhuman::memory::{MemoryCategory, MemoryTaint};- use tinymemory_api::provider::MemoryCore;-- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);-- // Bind a real driver over *this test's own* workspace and drive both the- // seeding and the assertion through its guard.- //- // Two things make the binding necessary rather than incidental. An unbound- // config resolves to the null driver, which serves no families at all, so- // the clear step under test would degrade instead of running. And- // `active_memory_guard` — what `flows_delete` reaches for with no override- // — resolves the ambient `CoreContext`, which a pre-boot unit test does not- // have; its fallback is the single shared `memory::ops` test workspace, not- // this `tempdir`. Injecting the binding's guard is what keeps the store- // written here and the store cleared by `flows_delete_impl` the same one.- //- // This was a directly-constructed `tinymemory_core` `MemoryClient` before- // #5560. Same engine underneath — `install_tinycortex_for_test` builds a- // `TinycortexProvider` over it — but reached through the contract, so the- // fixture no longer holds an unguarded door into memory.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- let memory = crate::openhuman::memory::binding::for_config(&config)- .expect("bind the memory driver for this test's workspace")- .guard();-- let created = flows_create(- &config,- "with-memory".to_string(),- trigger_only_graph(),- false,- )- .await- .unwrap();- let flow_id = created.value.id.clone();-- // `store` carries the taint on the contract — the engine trait's separate- // `store_with_taint` door does not exist here, and does not need to.- memory- .store(- &flow_namespace(&flow_id),- "sent_item_1",- "Sent item 1",- MemoryCategory::Core,- None,- MemoryTaint::ExternalSync,- )- .await- .unwrap();- assert!(- memory- .get(&flow_namespace(&flow_id), "sent_item_1")- .await- .unwrap()- .is_some(),- "precondition: flow memory entry was stored (through the SAME driver flows_delete_impl \- is about to clear)"- );-- flows_delete_impl(&config, &flow_id, Some(memory.clone()))- .await- .unwrap();-- assert!(- memory- .get(&flow_namespace(&flow_id), "sent_item_1")- .await- .unwrap()- .is_none(),- "flows_delete must clear the flow's own memory namespace"- );-}-#[tokio::test]async fn flows_update_rebinds_schedule_cron_job_when_trigger_schedule_changes() {let tmp = TempDir::new().unwrap();diff --git a/src/openhuman/flows/tinyflows/memory_adapter_tests.rs b/src/openhuman/flows/tinyflows/memory_adapter_tests.rsindex 25fc023e84..e5ad8f3b16 100644--- a/src/openhuman/flows/tinyflows/memory_adapter_tests.rs+++ b/src/openhuman/flows/tinyflows/memory_adapter_tests.rs@@ -28,7 +28,7 @@ fn adapter(autonomy: AutonomyLevel) -> (TempDir, OpenHumanMemory) {// workspace otherwise resolves to answers `Unsupported`, which the node// reports as a capability error rather than as an absent profile. This is// the driver the loaded module wraps.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);(tmp,OpenHumanMemory {diff --git a/src/openhuman/integrations/composio/ops_tests.rs b/src/openhuman/integrations/composio/ops_tests.rsindex 559b71051b..71720e8e52 100644--- a/src/openhuman/integrations/composio/ops_tests.rs+++ b/src/openhuman/integrations/composio/ops_tests.rs@@ -33,7 +33,6 @@ use chrono::{TimeZone, Utc};use serde_json::{json, Value};use std::collections::HashMap;use tinymemory_api::chunks::{chunk_id, Chunk, Metadata, SourceKind, SourceRef};-use tinymemory_core::store::chunks::store as memory_tree_store;struct WorkspaceEnvGuard {previous: Option<std::ffi::OsString>,@@ -318,7 +317,7 @@ fn direct_mode_no_key_config(tmp: &tempfile::TempDir) -> Config {// `enrich_connections_with_identity` reads through the bound memory driver// now (`identity_store::load_connected_identities`) rather than a// process-global engine client, so its tests bind a driver per test with-// `memory::test_support::install_tinycortex_for_test` instead of the+// `memory::test_support::install_memory_driver_for_test` instead of the// `tinymemory_core::global::init` helper this file used to carry.fn make_connections_response(diff --git a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rsindex a8c1de96a7..88a66015e3 100644--- a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs+++ b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs@@ -386,178 +386,3 @@ async fn composio_delete_connection_via_mock() {assert!(outcome.value.deleted);}-#[tokio::test]-async fn composio_delete_connection_clear_memory_deletes_slack_source() {- let _serialised = module_guard().await;- let app = Router::new()- .route(- "/agent-integrations/composio/connections",- get(|| async {- Json(json!({- "success": true,- "data": {"connections": [- {"id":"c1","toolkit":"slack","status":"ACTIVE"}- ]}- }))- }),- )- .route(- "/agent-integrations/composio/connections/{id}",- axum::routing::delete(|Path(_id): Path<String>| async move {- Json(json!({"success": true, "data": {"deleted": true}}))- }),- );- let base = start_mock_backend(app).await;- let tmp = tempfile::tempdir().unwrap();- let config = config_with_backend(&tmp, base);- // The memory clear-out runs through the bound driver now that it is routed- // onto `forget_matching`, so the test has to bind one. TinyCortex is the- // engine the loadable module wraps, and unlike the module it is not a- // process singleton, so several of these can share one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- let target = sample_memory_chunk(SourceKind::Chat, "slack:c1", 0);- let unrelated = sample_memory_chunk(SourceKind::Chat, "slack:c2", 0);- memory_tree_store::upsert_chunks(&config, &[target, unrelated]).expect("chunks should seed");-- let outcome = composio_delete_connection(&config, "c1", true)- .await- .unwrap();-- assert!(outcome.value.deleted);- assert_eq!(outcome.value.memory_chunks_deleted, 1);- let remaining = memory_tree_store::list_chunks(- &config,- &memory_tree_store::ListChunksQuery {- source_kind: Some(SourceKind::Chat),- ..Default::default()- },- )- .expect("chunks should list");- assert_eq!(remaining.len(), 1);- assert_eq!(remaining[0].metadata.source_id, "slack:c2");-}--/// #4: full path through the REAL `composio_delete_connection` handler-/// (clear_memory=true, mock backend) — deleting a connection's last chunk must-/// cascade away its source summary tree AND the summary's on-disk content file,-/// not just the chunk rows. The tree is a real `get_or_create_source_tree`; the-/// content file sits at the production `content_path` location.-#[tokio::test]-async fn composio_delete_connection_clear_memory_cascades_source_tree_and_content_file() {- let _serialised = module_guard().await;- use rusqlite::params;- use tinymemory_core::store::trees::store as tree_store;- use tinymemory_core::store::trees::types::{SummaryNode, TreeKind};- use tinymemory_core::tree_source::registry::get_or_create_source_tree;-- let app = Router::new()- .route(- "/agent-integrations/composio/connections",- get(|| async {- Json(json!({- "success": true,- "data": {"connections": [- {"id":"c1","toolkit":"slack","status":"ACTIVE"}- ]}- }))- }),- )- .route(- "/agent-integrations/composio/connections/{id}",- axum::routing::delete(|Path(_id): Path<String>| async move {- Json(json!({"success": true, "data": {"deleted": true}}))- }),- );- let base = start_mock_backend(app).await;- let tmp = tempfile::tempdir().unwrap();- let config = config_with_backend(&tmp, base);- // The memory clear-out runs through the bound driver now that it is routed- // onto `forget_matching`, so the test has to bind one. TinyCortex is the- // engine the loadable module wraps, and unlike the module it is not a- // process singleton, so several of these can share one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);-- // One slack chunk for connection c1 → source_id `slack:c1`.- let chunk = sample_memory_chunk(SourceKind::Chat, "slack:c1", 0);- memory_tree_store::upsert_chunks(&config, &[chunk.clone()]).expect("seed chunk");-- // Real source tree for that source + a summary whose content file lives at- // the production content-root location.- let tree = get_or_create_source_tree(&config, "slack:c1").expect("source tree");- let ts = Utc.timestamp_millis_opt(1_700_000_000_000).unwrap();- let rel = "summaries/slack_c1/L1/sum-1.md";- let abs = config.memory_tree_content_root().join(rel);- std::fs::create_dir_all(abs.parent().unwrap()).unwrap();- std::fs::write(&abs, "summarised slack body").unwrap();-- memory_tree_store::with_connection(&config, |conn| {- let tx = conn.unchecked_transaction()?;- tree_store::insert_summary_tx(- &tx,- &SummaryNode {- id: "sum-1".into(),- tree_id: tree.id.clone(),- tree_kind: TreeKind::Source,- level: 1,- parent_id: None,- child_ids: vec![chunk.id.clone()],- content: "preview".into(),- token_count: 3,- entities: vec![],- topics: vec![],- time_range_start: ts,- time_range_end: ts,- score: 0.5,- sealed_at: ts,- deleted: false,- embedding: None,- doc_id: None,- version_ms: None,- },- None,- "test/model@3",- )?;- tx.execute(- "UPDATE mem_tree_summaries SET content_path = ?1 WHERE id = 'sum-1'",- params![rel],- )?;- tx.commit()?;- Ok(())- })- .expect("seed summary + content file pointer");-- // sanity: tree + on-disk file exist before the disconnect.- assert!(- tree_store::get_tree_by_scope(&config, TreeKind::Source, "slack:c1")- .unwrap()- .is_some()- );- assert!(abs.exists());-- // ---- act: the REAL handler, clear_memory=true ----- let outcome = composio_delete_connection(&config, "c1", true)- .await- .unwrap();- assert!(outcome.value.deleted);- assert_eq!(outcome.value.memory_chunks_deleted, 1);-- // chunk, source tree, summary row, AND on-disk content file are all gone.- assert!(memory_tree_store::get_chunk(&config, &chunk.id)- .unwrap()- .is_none());- assert!(- tree_store::get_tree_by_scope(&config, TreeKind::Source, "slack:c1")- .unwrap()- .is_none()- );- memory_tree_store::with_connection(&config, |conn| {- let n: i64 = conn.query_row("SELECT COUNT(*) FROM mem_tree_summaries", [], |r| r.get(0))?;- assert_eq!(n, 0);- Ok(())- })- .unwrap();- assert!(- !abs.exists(),- "summary content file must be removed via the real handler cascade"- );-}diff --git a/src/openhuman/integrations/composio/ops_tests_part_02_tests.rs b/src/openhuman/integrations/composio/ops_tests_part_02_tests.rsindex 6cfcf51193..775c1cd7a9 100644--- a/src/openhuman/integrations/composio/ops_tests_part_02_tests.rs+++ b/src/openhuman/integrations/composio/ops_tests_part_02_tests.rs@@ -1,307 +1,5 @@use super::*;-/// #4 (full live seal): like the above, but the summary + on-disk file are-/// produced by the REAL `seal_one_level` pipeline (staged chunk body →-/// summarise → `stage_summary`), not hand-written. Then the REAL-/// `composio_delete_connection(clear_memory=true)` handler must cascade the-/// tree, the summary row, AND the seal-produced content file away.-#[tokio::test]-async fn composio_delete_connection_clear_memory_cascades_live_sealed_tree_and_file() {- let _serialised = module_guard().await;- use tinymemory_core::store::chunks::store::{- get_summary_content_pointers, upsert_staged_chunks_tx,- };- use tinymemory_core::store::content::stage_chunks;- use tinymemory_core::store::trees::store as tree_store;- use tinymemory_core::store::trees::types::{Buffer, TreeKind};- use tinymemory_core::tree::tree::bucket_seal::{seal_one_level, LabelStrategy};- use tinymemory_core::tree_source::registry::get_or_create_source_tree;-- let app = Router::new()- .route(- "/agent-integrations/composio/connections",- get(|| async {- Json(json!({- "success": true,- "data": {"connections": [- {"id":"c1","toolkit":"slack","status":"ACTIVE"}- ]}- }))- }),- )- .route(- "/agent-integrations/composio/connections/{id}",- axum::routing::delete(|Path(_id): Path<String>| async move {- Json(json!({"success": true, "data": {"deleted": true}}))- }),- );- let base = start_mock_backend(app).await;- let tmp = tempfile::tempdir().unwrap();- let mut config = config_with_backend(&tmp, base);- // The memory clear-out runs through the bound driver now that it is routed- // onto `forget_matching`, so the test has to bind one. TinyCortex is the- // engine the loadable module wraps, and unlike the module it is not a- // process singleton, so several of these can share one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- // Force the inert embedder so the real seal's summary-embed step doesn't- // reach a live endpoint. `config_with_backend` stores a cloud session +- // api_url, so the factory would otherwise build a *cloud* embedder against- // the mock (no embeddings route). `embeddings_provider = "none"` is the- // actual switch that selects `InertEmbedder`.- config.embeddings_provider = Some("none".to_string());- config.memory_tree.embedding_endpoint = None;- config.memory_tree.embedding_model = None;- config.memory_tree.embedding_strict = false;-- // Real chunk for slack:c1 WITH its body staged to disk, so the seal's- // `hydrate_leaf_inputs` → `read_chunk_body` can resolve it.- let chunk = sample_memory_chunk(SourceKind::Chat, "slack:c1", 0);- memory_tree_store::upsert_chunks(&config, &[chunk.clone()]).expect("seed chunk");- let staged = stage_chunks(- &config.memory_tree_content_root(),- std::slice::from_ref(&chunk),- )- .expect("stage chunk body");- memory_tree_store::with_connection(&config, |conn| {- let tx = conn.unchecked_transaction()?;- upsert_staged_chunks_tx(&tx, &staged)?;- tx.commit()?;- Ok(())- })- .expect("record staged chunk pointer");-- // Run the REAL seal — produces a genuine summary row + on-disk file.- let tree = get_or_create_source_tree(&config, "slack:c1").expect("source tree");- let buf = Buffer {- tree_id: tree.id.clone(),- level: 0,- item_ids: vec![chunk.id.clone()],- token_sum: i64::from(chunk.token_count),- oldest_at: Some(chunk.metadata.time_range.0),- };- memory_tree_store::with_connection(&config, |conn| {- let tx = conn.unchecked_transaction()?;- tree_store::upsert_buffer_tx(&tx, &buf)?;- tx.commit()?;- Ok(())- })- .expect("persist buffer snapshot");- let summary_id = seal_one_level(&config, &tree, &buf, &LabelStrategy::Empty, false)- .await- .expect("real seal produces a summary");-- // The seal wrote a real on-disk content file for the summary.- let (rel, _sha) = get_summary_content_pointers(&config, &summary_id)- .unwrap()- .expect("seal staged a summary content file");- let abs = {- let mut p = config.memory_tree_content_root();- for c in rel.split('/') {- p.push(c);- }- p- };- assert!(- abs.exists(),- "seal must have written a summary file on disk"- );- assert!(- tree_store::get_tree_by_scope(&config, TreeKind::Source, "slack:c1")- .unwrap()- .is_some()- );-- // ---- act: REAL handler, clear_memory=true ----- let outcome = composio_delete_connection(&config, "c1", true)- .await- .unwrap();- assert!(outcome.value.deleted);- assert_eq!(outcome.value.memory_chunks_deleted, 1);-- // chunk, tree, summary row, and the seal-produced file are all gone.- assert!(memory_tree_store::get_chunk(&config, &chunk.id)- .unwrap()- .is_none());- assert!(- tree_store::get_tree_by_scope(&config, TreeKind::Source, "slack:c1")- .unwrap()- .is_none()- );- assert!(tree_store::get_summary(&config, &summary_id)- .unwrap()- .is_none());- assert!(- !abs.exists(),- "seal-produced summary file must be removed via the real handler cascade"- );-}--#[tokio::test]-async fn composio_delete_connection_clear_memory_keeps_other_gmail_connections() {- let _serialised = module_guard().await;- let app = Router::new()- .route(- "/agent-integrations/composio/connections",- get(|| async {- Json(json!({- "success": true,- "data": {"connections": [- {"id":"c1","toolkit":"gmail","status":"ACTIVE"},- {"id":"c2","toolkit":"gmail","status":"ACTIVE"}- ]}- }))- }),- )- .route(- "/agent-integrations/composio/connections/{id}",- axum::routing::delete(|Path(_id): Path<String>| async move {- Json(json!({"success": true, "data": {"deleted": true}}))- }),- );- let base = start_mock_backend(app).await;- let tmp = tempfile::tempdir().unwrap();- let config = config_with_backend(&tmp, base);- // The memory clear-out runs through the bound driver now that it is routed- // onto `forget_matching`, so the test has to bind one. TinyCortex is the- // engine the loadable module wraps, and unlike the module it is not a- // process singleton, so several of these can share one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- let c1_account = sample_memory_chunk_with_owner(- SourceKind::Email,- "gmail:pilot-at-example-dot-com",- "gmail-sync:c1",- 0,- );- let c2_account = sample_memory_chunk_with_owner(- SourceKind::Email,- "gmail:pilot-at-example-dot-com",- "gmail-sync:c2",- 1,- );- let c1_connection_scoped =- sample_memory_chunk_with_owner(SourceKind::Email, "gmail:c1:thread-a", "gmail-sync:c1", 2);- let c2_connection_scoped =- sample_memory_chunk_with_owner(SourceKind::Email, "gmail:c2:thread-b", "gmail-sync:c2", 3);- memory_tree_store::upsert_chunks(- &config,- &[- c1_account,- c2_account.clone(),- c1_connection_scoped,- c2_connection_scoped.clone(),- ],- )- .expect("chunks should seed");-- let outcome = composio_delete_connection(&config, "c1", true)- .await- .unwrap();-- assert!(outcome.value.deleted);- assert_eq!(outcome.value.memory_chunks_deleted, 2);- let remaining = memory_tree_store::list_chunks(- &config,- &memory_tree_store::ListChunksQuery {- source_kind: Some(SourceKind::Email),- ..Default::default()- },- )- .expect("chunks should list");- assert_eq!(remaining.len(), 2);- assert!(remaining.iter().any(|chunk| chunk.id == c2_account.id));- assert!(remaining- .iter()- .any(|chunk| chunk.id == c2_connection_scoped.id));-}--#[tokio::test]-async fn notion_cleanup_targets_include_synced_page_sources() {- // The embedding seam fails loudly when unwired. Installed here rather- // than relied upon from another test: `install_for_tests` is- // `Once`-guarded, so a test that omits it passes only while some- // earlier test in the same binary happened to run first.- crate::openhuman::memory::host_impls::install_for_tests();- let tmp = tempfile::tempdir().unwrap();- let config = test_config(&tmp);- // The cleanup targets are read back through the bound driver now, so the- // test has to bind one — the writes below go through a client over the- // same workspace, and an unbound config resolves to the null driver,- // which serves nothing and would report no targets at all.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- let memory = std::sync::Arc::new(- MemoryClient::from_workspace_dir(config.workspace_dir.clone())- .expect("memory client should initialise"),- );- // tinymemory v1.13.4 deleted the whole in-process Composio pipeline —- // `sync_state::PersistedSyncState`/`HostSyncAdapter` included — so there is- // no extension trait to save through any more. `memory_cleanup.rs`'s reader- // deserialises this row as `tinycortex::memory::sync::SyncState` (the same- // shape tinycortex's own sync layer writes), so the test writes that type- // straight through the KV store instead.- let mut state = tinycortex::memory::sync::SyncState::new("notion", "conn-1");- state.mark_synced("page-a@2026-01-01T00:00:00Z");- state.mark_synced("page-b");- memory- .kv_set(- Some(tinycortex::memory::sync::state::STATE_NAMESPACE),- "notion:conn-1",- &serde_json::to_value(&state).expect("sync state should serialize"),- )- .await- .expect("sync state should save");-- let targets = composio_memory_targets_for_connection(&config, Some("notion"), "conn-1")- .await- .expect("notion cleanup targets should resolve");-- assert!(targets.contains(&MemoryCleanupTarget::Exact(- SourceKind::Document,- "notion:page-a".to_string()- )));- assert!(targets.contains(&MemoryCleanupTarget::Exact(- SourceKind::Document,- "notion:page-b".to_string()- )));- assert!(targets.contains(&MemoryCleanupTarget::Exact(- SourceKind::Document,- "composio-notion-page-page-a".to_string()- )));-}--#[tokio::test]-async fn notion_cleanup_targets_surface_corrupt_sync_state() {- // The embedding seam fails loudly when unwired. Installed here rather- // than relied upon from another test: `install_for_tests` is- // `Once`-guarded, so a test that omits it passes only while some- // earlier test in the same binary happened to run first.- crate::openhuman::memory::host_impls::install_for_tests();- let tmp = tempfile::tempdir().unwrap();- let config = test_config(&tmp);- // The cleanup targets are read back through the bound driver now, so the- // test has to bind one — the writes below go through a client over the- // same workspace, and an unbound config resolves to the null driver,- // which serves nothing and would report no targets at all.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- let memory = std::sync::Arc::new(- MemoryClient::from_workspace_dir(config.workspace_dir.clone())- .expect("memory client should initialise"),- );- memory- .kv_set(- Some(tinycortex::memory::sync::state::STATE_NAMESPACE),- "notion:conn-1",- &serde_json::json!({ "toolkit": 42 }),- )- .await- .expect("corrupt sync state should be written");-- let err = composio_memory_targets_for_connection(&config, Some("notion"), "conn-1")- .await- .expect_err("corrupt sync state should surface");-- assert!(err.to_string().contains("failed to load notion sync state"));-}-#[tokio::test]async fn drive_cleanup_targets_are_connection_scoped() {// The embedding seam fails loudly when unwired; same reasoning as the@@ -312,7 +10,7 @@ async fn drive_cleanup_targets_are_connection_scoped() {// The drive arm never touches the store, but discovery takes the caller's// client unconditionally — the parameter is the seam the notion tests// inject through.- let drive_memory = std::sync::Arc::new(+ let _drive_memory = std::sync::Arc::new(MemoryClient::from_workspace_dir(config.workspace_dir.clone()).expect("memory client should initialise"),);@@ -485,164 +183,3 @@ async fn composio_execute_via_mock_propagates_backend_error() {assert!(err.contains("rate limited"), "got: {err}");}-#[tokio::test]-async fn composio_sync_gmail_via_mock_ingests_records_and_updates_outcome() {- let _serialised = module_guard().await;- // The embedding seam fails loudly when unwired. Installed here rather- // than relied upon from another test: `install_for_tests` is- // `Once`-guarded, so a test that omits it passes only while some- // earlier test in the same binary happened to run first.- crate::openhuman::memory::host_impls::install_for_tests();- let _serial = crate::openhuman::memory::ops::GLOBAL_MEMORY_TEST_LOCK- .lock()- .await;- use crate::openhuman::config::TEST_ENV_LOCK;- let _cache_guard = cache_guard();- let _env_guard = TEST_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());- // See composio_get_user_profile_via_mock_returns_provider_profile: this- // test also mutates BACKEND_URL via EnvVarGuard below, which needs the- // crate-wide lock to serialize against api::config / core::cli_tests /- // medulla's tests on the same process-global var.- let _backend_env_guard = crate::api::config::backend_env_test_lock();-- let app = Router::new()- .route(- "/agent-integrations/composio/connections",- get(|| async {- Json(json!({- "success": true,- "data": {"connections": [- {"id":"c1","toolkit":"gmail","status":"ACTIVE"}- ]}- }))- }),- )- .route(- "/agent-integrations/composio/execute",- post(|Json(body): Json<Value>| async move {- let action = body- .get("tool")- .and_then(Value::as_str)- .or_else(|| body.get("action").and_then(Value::as_str))- .unwrap_or("");- let data = match action {- "GMAIL_GET_PROFILE" => json!({- "emailAddress": "[email protected]",- "displayName": "Phoenix Pilot"- }),- "GMAIL_FETCH_EMAILS" => json!({- "messages": [{- "messageId": "gmail-msg-1",- "threadId": "gmail-thread-1",- "sender": "[email protected]",- "to": "[email protected]",- "subject": "Phoenix launch canary",- "messageTimestamp": "2024-06-01T12:00:00Z",- "labelIds": ["INBOX"],- "markdownFormatted": "Phoenix launch canary body for mock sync coverage.",- "payload": {}- }]- }),- other => panic!("unexpected action: {other}"),- };- Json(json!({- "success": true,- "data": {- "successful": true,- "data": data,- "error": null- }- }))- }),- );- let base = start_mock_backend(app).await;- // The provider action reloads config with env overlays before executing.- // Keep that reload on the mock even when the runner exports BACKEND_URL.- let _backend_url_guard = EnvVarGuard::set("BACKEND_URL", &base);- let tmp = tempfile::tempdir().unwrap();- let mut config = config_with_backend(&tmp, base);- config.memory_tree.embedding_strict = false;- let _workspace_env_guard = WorkspaceEnvGuard::set(tmp.path());- config.save().await.unwrap();- // The sync writes through the bound driver now, so the fixture binds one and- // the read-back goes to the same place. Binding the global slot instead would- // have the test write to one client and read from another — zero documents,- // looking exactly like a sync that silently did nothing.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);- // And the seams are re-installed against THIS config, not the- // `Config::default()` that `install_for_tests` latched. Proxied Composio- // resolves its bearer through `ComposioHost::session_bearer`, which reads- // the installed host config — a default one has no session, so the sync- // would refuse before reaching the mock backend. The setters overwrite, so- // calling this after the latched install is what points the seam at the- // config carrying the mock's URL and token.- crate::openhuman::memory::host_impls::install_memory_host_seams(std::sync::Arc::new(- config.clone(),- ));-- let outcome = composio_sync(&config, "c1", Some("manual".to_string()))- .await- .unwrap();-- assert_eq!(outcome.value.toolkit, "gmail");- assert_eq!(outcome.value.connection_id.as_deref(), Some("c1"));- // composio_sync is now spawn-and-return: the immediate envelope is a- // "started" sentinel, and the actual ingestion runs on a detached- // tokio task. items_ingested == 0 / finished_at_ms == 0 / summary- // contains "started" are the contract of that sentinel.- assert_eq!(- outcome.value.items_ingested, 0,- "spawn-and-return: items_ingested on the immediate envelope is a 'started' sentinel, not a final count"- );- assert_eq!(- outcome.value.finished_at_ms, 0,- "spawn-and-return: finished_at_ms == 0 means 'task spawned, not yet complete'"- );- assert!(- outcome.value.summary.contains("started"),- "expected spawn-and-return summary to mention 'started', got: {}",- outcome.value.summary- );-- // Poll for the spawned ingest task to write the records into memory.- //- // The namespace is `source:<source_id>` because the sync now hands its- // records to the bound driver's `accept_source_items` rather than writing a- // provider-shaped skill document itself. That is the whole point of the- // split — the module reads, this crate ingests — so reading them back the- // way memory files them is what proves the two halves met.- let documents = {- let mut documents = Vec::new();- for _ in 0..50 {- let binding = crate::openhuman::memory::binding::for_config(&config)- .expect("the fixture bound a driver");- documents = binding- .provider()- .as_documents()- .expect("the bound driver serves documents")- .list_documents(Some("source:gmail:c1"))- .await- .unwrap()- .get("documents")- .and_then(Value::as_array)- .cloned()- .unwrap_or_default();- if !documents.is_empty() {- break;- }- tokio::time::sleep(std::time::Duration::from_millis(100)).await;- }- documents- };- assert_eq!(- documents.len(),- 1,- "expected one ingested Gmail record after the spawned task drains"- );- let document = &documents[0];- assert_eq!(document["title"], "Phoenix launch canary");- // `external_sync` is what stops a third party's words being treated later- // as the user's own. A sync that ingested without it would be worse than- // one that ingested nothing.- assert_eq!(document["taint"], "external_sync");-}diff --git a/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs b/src/openhuman/integrations/composio/ops_tests_part_04_tests.rsindex 5790018ac8..bd7579199a 100644--- a/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs+++ b/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs@@ -458,7 +458,7 @@ async fn enrich_does_nothing_when_no_cached_identities() {// returns `Vec::new()` and the connection is returned unchanged.let tmp = tempfile::tempdir().unwrap();let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);let resp = make_connections_response(&[("c1", "gmail", "ACTIVE")]);let enriched = enrich_connections_with_identity(&config, resp).await;assert_eq!(enriched.connections.len(), 1);@@ -467,87 +467,13 @@ async fn enrich_does_nothing_when_no_cached_identities() {assert!(enriched.connections[0].username.is_none());}-#[tokio::test]-async fn enrich_populates_email_from_cached_profile() {- use crate::openhuman::integrations::composio::identity_store::persist_provider_profile;- use tinymemory_api::composio::ProviderUserProfile;-- let tmp = tempfile::tempdir().unwrap();- let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);-- persist_provider_profile(- &config,- &ProviderUserProfile {- toolkit: "gmail".to_string(),- connection_id: Some("conn-gmail-1".to_string()),- email: Some("[email protected]".to_string()),- display_name: Some("Alice Smith".to_string()),- ..Default::default()- },- )- .await- .expect("persist provider profile");-- let resp = make_connections_response(&[("conn-gmail-1", "gmail", "ACTIVE")]);- let enriched = enrich_connections_with_identity(&config, resp).await;-- assert_eq!(- enriched.connections[0].account_email.as_deref(),- Some("[email protected]"),- "email should be populated from cached gmail profile"- );- assert_eq!(- enriched.connections[0].workspace.as_deref(),- Some("Alice Smith"),- "workspace (display_name) should be populated"- );- assert!(- enriched.connections[0].username.is_none(),- "username (handle) should be absent for gmail"- );-}--#[tokio::test]-async fn enrich_populates_handle_for_github() {- use crate::openhuman::integrations::composio::identity_store::persist_provider_profile;- use tinymemory_api::composio::ProviderUserProfile;-- let tmp = tempfile::tempdir().unwrap();- let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);-- persist_provider_profile(- &config,- &ProviderUserProfile {- toolkit: "github".to_string(),- connection_id: Some("conn-gh-1".to_string()),- username: Some("octocat".to_string()),- ..Default::default()- },- )- .await- .expect("persist provider profile");-- let resp = make_connections_response(&[("conn-gh-1", "github", "ACTIVE")]);- let enriched = enrich_connections_with_identity(&config, resp).await;-- // GitHub uses `handle` kind (the catch-all branch in expand_identity_rows).- assert_eq!(- enriched.connections[0].username.as_deref(),- Some("octocat"),- "username (handle) should be populated for github"- );- assert!(enriched.connections[0].account_email.is_none());-}-#[tokio::test]async fn enrich_skips_connection_already_having_identity() {// If the backend-proxied path already populated account_email, the// enricher must NOT overwrite it with a potentially stale cached value.let tmp = tempfile::tempdir().unwrap();let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);let mut resp = make_connections_response(&[("c-preloaded", "gmail", "ACTIVE")]);resp.connections[0].account_email = Some("[email protected]".to_string());@@ -560,57 +486,6 @@ async fn enrich_skips_connection_already_having_identity() {);}-#[tokio::test]-async fn enrich_handles_multiple_connections_same_toolkit() {- // Two Gmail accounts — each gets its own identity label, not "Account N".- use crate::openhuman::integrations::composio::identity_store::persist_provider_profile;- use tinymemory_api::composio::ProviderUserProfile;-- let tmp = tempfile::tempdir().unwrap();- let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);-- persist_provider_profile(- &config,- &ProviderUserProfile {- toolkit: "gmail".to_string(),- connection_id: Some("g1".to_string()),- email: Some("[email protected]".to_string()),- ..Default::default()- },- )- .await- .expect("persist provider profile");- persist_provider_profile(- &config,- &ProviderUserProfile {- toolkit: "gmail".to_string(),- connection_id: Some("g2".to_string()),- email: Some("[email protected]".to_string()),- ..Default::default()- },- )- .await- .expect("persist provider profile");-- let resp = make_connections_response(&[("g1", "gmail", "ACTIVE"), ("g2", "gmail", "ACTIVE")]);- let enriched = enrich_connections_with_identity(&config, resp).await;-- let emails: Vec<_> = enriched- .connections- .iter()- .map(|c| c.account_email.as_deref())- .collect();- assert!(- emails.contains(&Some("[email protected]")),- "first gmail account should carry alice's email"- );- assert!(- emails.contains(&Some("[email protected]")),- "second gmail account should carry bob's email"- );-}-#[tokio::test]async fn enrich_leaves_unmatched_connection_unchanged() {// Connection whose id has no cached profile row is returned with all@@ -620,7 +495,7 @@ async fn enrich_leaves_unmatched_connection_unchanged() {let tmp = tempfile::tempdir().unwrap();let config = test_config(&tmp);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);// Persist a profile for a DIFFERENT connection id.persist_provider_profile(diff --git a/src/openhuman/memory/query/ingest_document_tests.rs b/src/openhuman/memory/query/ingest_document_tests.rsindex 10700e9ecd..b11f78a3c0 100644--- a/src/openhuman/memory/query/ingest_document_tests.rs+++ b/src/openhuman/memory/query/ingest_document_tests.rs@@ -7,7 +7,6 @@ use crate::openhuman::config::Config;use crate::openhuman::config::TEST_ENV_LOCK;use crate::openhuman::tools::traits::Tool;use serde_json::json;-use tinymemory_api::chunks::SourceRef;struct WorkspaceEnvGuard {_lock: std::sync::MutexGuard<'static, ()>,@@ -46,7 +45,7 @@ async fn isolated_config(tmp: &TempDir) -> (WorkspaceEnvGuard, Config) {// write; it is the driver the loadable module wraps, which is as close// to production as a test process can get (a dlopen'ed module is a// process singleton a unit test cannot load).- crate::openhuman::memory::test_support::install_tinycortex_for_test(&config);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&config);(guard, config)}@@ -155,92 +154,3 @@ async fn execute_rejects_blank_required_fields() {assert!(result.is_error);}-#[tokio::test]-async fn execute_success_path_roundtrips_document_chunk() {- let tmp = TempDir::new().expect("tempdir");- let (_workspace, cfg) = isolated_config(&tmp).await;- let tool = MemoryTreeIngestDocumentTool;- let result = tool- .execute(json!({- "title": "Doc title",- "body": "Body text with a memorable launch detail.",- "source_id": "doc-1",- "provider": "web",- "source_ref": "https://example.test/doc-1",- "owner": "owner-1"- }))- .await- .expect("valid request should succeed in the isolated test environment");- assert!(!result.is_error);- let text = result.text();- assert!(- text.contains("Ingested document \"Doc title\" as source_id=doc-1."),- "unexpected success payload: {text}"- );-- let listed = rpc::list_chunks_rpc(- &cfg,- rpc::ListChunksRequest {- source_kind: Some("document".into()),- source_id: Some("doc-1".into()),- owner: Some("owner-1".into()),- limit: Some(10),- ..Default::default()- },- )- .await- .expect("list chunks after tool execute")- .value- .chunks;- assert_eq!(listed.len(), 1);- assert!(- listed[0]- .content- .contains("Body text with a memorable launch detail."),- "stored chunk missing document body: {}",- listed[0].content- );- assert_eq!(listed[0].metadata.owner, "owner-1");- assert_eq!(- listed[0].metadata.source_ref,- Some(SourceRef::new("https://example.test/doc-1"))- );-}--#[tokio::test]-async fn execute_duplicate_source_id_reports_zero_new_chunks() {- let tmp = TempDir::new().expect("tempdir");- let (_workspace, cfg) = isolated_config(&tmp).await;- let tool = MemoryTreeIngestDocumentTool;- let args = json!({- "title": "Doc title",- "body": "Body text",- "source_id": "doc-dup"- });-- let first = tool.execute(args.clone()).await.expect("first execute");- let second = tool.execute(args).await.expect("second execute");- assert!(!first.is_error);- assert!(!second.is_error);- assert!(first.text().contains("1 chunks created and indexed."));- assert!(second.text().contains("0 chunks created and indexed."));-- let listed = rpc::list_chunks_rpc(- &cfg,- rpc::ListChunksRequest {- source_kind: Some("document".into()),- source_id: Some("doc-dup".into()),- limit: Some(10),- ..Default::default()- },- )- .await- .expect("list chunks after duplicate execute")- .value- .chunks;- assert_eq!(- listed.len(),- 1,- "duplicate source_id should not create extra chunks"- );-}diff --git a/src/openhuman/memory/read_rpc/admin_tests.rs b/src/openhuman/memory/read_rpc/admin_tests.rsindex ac7d313bef..e8282283e9 100644--- a/src/openhuman/memory/read_rpc/admin_tests.rs+++ b/src/openhuman/memory/read_rpc/admin_tests.rs@@ -114,49 +114,6 @@ async fn delete_source_rejects_a_blank_source_id_before_touching_a_driver() {);}-/// An unknown source removes nothing and cleans no tree, and the host maps that-/// all-zero `ForgetOutcome` onto `deleted: false`.-///-/// The mapping is the whole point of the assertion: `deleted` is now an OR over-/// **two** counts, and a source that matched nothing must not read as one whose-/// stranded summary tree was swept.-#[tokio::test]-async fn delete_source_is_idempotent_for_an_unknown_source_id() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);-- let outcome = delete_source_rpc(&cfg, "notion:never-ingested".to_string())- .await- .expect("an unknown source is not an error")- .value;- assert!(!outcome.deleted);- assert_eq!(outcome.chunks_removed, 0);-}--/// The source id can embed user-linked identifiers, so it is hashed into the-/// log line rather than written out. Pinned here because the log is assembled-/// beside the response and is easy to "improve" into a leak.-#[tokio::test]-async fn delete_source_never_logs_the_raw_source_id() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);-- let source_id = "notion:[email protected]/private-page";- let outcome = delete_source_rpc(&cfg, source_id.to_string())- .await- .expect("an unknown source is not an error");- assert!(- !outcome.logs[0].contains(source_id),- "log leaked the source id: {}",- outcome.logs[0]- );- assert!(- outcome.logs[0].contains("source_id_hash="),- "log should carry the redacted id: {}",- outcome.logs[0]- );-}-/// openhuman#6012. Same distinction the wipes above turn on: a backfill the/// driver cannot perform must not read as `scanned: 0` success. A caller seeing/// that concludes their stored records are already treed and stops looking —diff --git a/src/openhuman/memory/read_rpc/mod.rs b/src/openhuman/memory/read_rpc/mod.rsindex ebc2362c3c..1881ef8a2b 100644--- a/src/openhuman/memory/read_rpc/mod.rs+++ b/src/openhuman/memory/read_rpc/mod.rs@@ -61,8 +61,6 @@ pub(crate) fn parse_source_kind_str(s: &str) -> Option<tinymemory_api::chunks::S#[cfg(test)]pub(crate) use crate::openhuman::config::Config;#[cfg(test)]-pub(crate) use admin::clear_composio_sync_state;-#[cfg(test)]pub(crate) use tinymemory_api::chunks::SourceKind;#[cfg(test)]pub(crate) use tinymemory_core::store::chunks::store::with_connection;diff --git a/src/openhuman/memory/read_rpc_tests.rs b/src/openhuman/memory/read_rpc_tests.rsindex 135f7cb801..95180a4907 100644--- a/src/openhuman/memory/read_rpc_tests.rs+++ b/src/openhuman/memory/read_rpc_tests.rs@@ -1,15 +1,11 @@use super::*;-use crate::openhuman::inference::embeddings::NoopEmbedding;use chrono::{TimeZone, Utc};use rusqlite::params;-use std::sync::Arc;use tempfile::TempDir;use tinycortex::memory::ingest::canonicalize::chat::{ChatBatch, ChatMessage};-use tinycortex::memory::sync::state::STATE_NAMESPACE as KV_NAMESPACE;use tinymemory_core::ingest_pipeline::ingest_chat;use tinymemory_core::queue::drain_until_idle;use tinymemory_core::store::content::raw::{write_raw_items, RawItem, RawKind};-use tinymemory_core::store::namespace_store::UnifiedMemory;fn test_config() -> (TempDir, Config) {let tmp = TempDir::new().unwrap();diff --git a/src/openhuman/memory/read_rpc_tests_part_01_tests.rs b/src/openhuman/memory/read_rpc_tests_part_01_tests.rsindex 760c80e4a1..dcf8f27655 100644--- a/src/openhuman/memory/read_rpc_tests_part_01_tests.rs+++ b/src/openhuman/memory/read_rpc_tests_part_01_tests.rs@@ -1,496 +1,5 @@use super::*;-#[tokio::test]-async fn list_chunks_returns_seeded_chunk() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "hello @alice phoenix migration").await;- let resp = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value;- assert!(!resp.chunks.is_empty());- assert_eq!(resp.total, resp.chunks.len() as u64);-}--#[tokio::test]-async fn list_chunks_filters_by_source_id() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#a", "alpha").await;- seed_chat_chunk(&cfg, "slack:#b", "beta").await;- let only_a = list_chunks_rpc(- &cfg,- ChunkFilter {- source_ids: Some(vec!["slack:#a".into()]),- ..ChunkFilter::default()- },- )- .await- .unwrap()- .value;- assert!(only_a.chunks.iter().all(|c| c.source_id == "slack:#a"));- assert!(only_a.total >= 1);-}--#[tokio::test]-async fn list_chunks_query_substring_works() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "phoenix migration ships friday").await;- seed_chat_chunk(&cfg, "slack:#eng", "different unrelated text").await;- let resp = list_chunks_rpc(- &cfg,- ChunkFilter {- query: Some("phoenix".into()),- ..ChunkFilter::default()- },- )- .await- .unwrap()- .value;- assert!(resp.chunks.iter().any(|c| {- c.content_preview- .as_deref()- .unwrap_or("")- .contains("phoenix")- }));-}--#[tokio::test]-async fn list_chunks_filters_by_source_kind_and_applies_limit_offset() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#a", "first chat").await;- seed_chat_chunk(&cfg, "slack:#b", "second chat").await;-- let filtered = list_chunks_rpc(- &cfg,- ChunkFilter {- source_kinds: Some(vec!["chat".into()]),- limit: Some(1),- offset: Some(1),- ..ChunkFilter::default()- },- )- .await- .unwrap()- .value;- assert_eq!(filtered.chunks.len(), 1);- assert_eq!(filtered.total, 2);- assert!(filtered.chunks.iter().all(|c| c.source_kind == "chat"));-}--#[tokio::test]-async fn list_chunks_filters_by_entity_id_and_time_window() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] handles phoenix").await;- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] handles atlas").await;-- let seeded = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks;- let alice = seeded- .iter()- .find(|chunk| {- chunk- .content_preview- .as_deref()- .unwrap_or("")- .contains("[email protected]")- })- .expect("alice chunk present");- let bob = seeded- .iter()- .find(|chunk| {- chunk- .content_preview- .as_deref()- .unwrap_or("")- .contains("[email protected]")- })- .expect("bob chunk present");-- update_chunk_timestamp(&cfg, &alice.id, 1_700_000_000_100);- update_chunk_timestamp(&cfg, &bob.id, 1_700_000_000_900);-- let filtered = list_chunks_rpc(- &cfg,- ChunkFilter {- entity_ids: Some(vec!["email:[email protected]".into()]),- since_ms: Some(1_700_000_000_000),- until_ms: Some(1_700_000_000_500),- ..ChunkFilter::default()- },- )- .await- .unwrap()- .value;-- assert_eq!(filtered.total, 1);- assert_eq!(filtered.chunks.len(), 1);- assert_eq!(filtered.chunks[0].id, alice.id);-}--#[tokio::test]-async fn list_chunks_ignores_empty_filter_lists_and_blank_query() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#a", "alpha").await;- seed_chat_chunk(&cfg, "slack:#b", "beta").await;-- let resp = list_chunks_rpc(- &cfg,- ChunkFilter {- source_kinds: Some(vec![]),- source_ids: Some(vec![]),- entity_ids: Some(vec![]),- query: Some(" ".into()),- limit: Some(10),- ..ChunkFilter::default()- },- )- .await- .unwrap()- .value;-- assert_eq!(resp.total, 2);- assert_eq!(resp.chunks.len(), 2);-}--#[tokio::test]-async fn list_chunks_normalizes_invalid_tags_negative_tokens_and_empty_content() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- insert_raw_chunk(- &cfg,- "raw-empty",- "document",- "notion:page-1",- 1_700_000_000_123,- "not-json",- "",- -7,- );-- let resp = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value;- let row = resp- .chunks- .into_iter()- .find(|chunk| chunk.id == "raw-empty")- .expect("raw chunk listed");-- assert_eq!(row.token_count, 0);- assert_eq!(row.tags, Vec::<String>::new());- assert_eq!(row.content_preview, None);- assert!(!row.has_embedding);-}--#[tokio::test]-async fn list_sources_aggregates() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#a", "x").await;- seed_chat_chunk(&cfg, "slack:#a", "y").await;- seed_chat_chunk(&cfg, "slack:#b", "z").await;- let sources = list_sources_rpc(&cfg, None).await.unwrap().value;- let a = sources- .iter()- .find(|s| s.source_id == "slack:#a")- .expect("expected slack:#a");- let b = sources- .iter()- .find(|s| s.source_id == "slack:#b")- .expect("expected slack:#b");- assert_eq!(a.chunk_count, 2);- assert_eq!(b.chunk_count, 1);-}--#[tokio::test]-async fn list_sources_formats_email_threads_with_trimmed_user_hint() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- insert_raw_chunk(- &cfg,- "email-thread",- "email",- 1_700_000_000_123,- "[]",- "thread body",- 12,- );-- let sources = list_sources_rpc(&cfg, Some(" [email protected] ".into()))- .await- .unwrap()- .value;- let source = sources- .iter()- .expect("email thread source present");- assert_eq!(source.display_name, "[email protected], [email protected]");-}--#[tokio::test]-async fn entity_index_for_returns_extracted_entities() {- let (_tmp, cfg) = test_config();- // The entity index is read through `MemoryEntities::chunk_entities`, so the- // handler needs a driver that serves that family — the null fallback does not.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] owns it").await;- // Find the chunk we just seeded.- let chunks = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks;- let id = &chunks[0].id;- let refs = entity_index_for_rpc(&cfg, id.clone()).await.unwrap().value;- assert!(- refs.iter().any(|r| r.entity_id.contains("alice")),- "expected alice entity in index, got: {refs:?}"- );-}--#[tokio::test]-async fn chunks_for_entity_returns_leaf_chunk_ids_only() {- let (_tmp, cfg) = test_config();- // `MemoryEntities::entity_chunk_ids` answers this one; the null fallback- // serves no entity tier and would report an empty list.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] owns it").await;- let chunk_id = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks[0]- .id- .clone();-- let rows = chunks_for_entity_rpc(&cfg, "email:[email protected]".into())- .await- .unwrap()- .value;- assert_eq!(rows, vec![chunk_id]);-}--#[tokio::test]-async fn top_entities_returns_most_frequent() {- let (_tmp, cfg) = test_config();- // `MemoryEntities::top_entities` answers this one; the null fallback- // serves no entity tier and would report an empty ranking.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#a", "[email protected] x").await;- seed_chat_chunk(&cfg, "slack:#b", "[email protected] y").await;- seed_chat_chunk(&cfg, "slack:#c", "[email protected] z").await;- let top = top_entities_rpc(&cfg, Some("email".into()), 10)- .await- .unwrap()- .value;- assert!(top- .iter()- .any(|e| e.entity_id == "email:[email protected]" && e.count >= 2));-}--#[tokio::test]-async fn delete_chunk_removes_chunk_and_dependent_rows() {- let (_tmp, cfg) = test_config();- // The delete goes through `MemorySourceSink::forget_matching`, which the null- // fallback does not serve — and this handler refuses rather than degrades.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] owns it").await;- let chunks = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks;- let id = chunks[0].id.clone();- let resp = delete_chunk_rpc(&cfg, id.clone()).await.unwrap().value;- assert!(resp.deleted);- // Re-list — the chunk should be gone.- let after = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value;- assert!(after.chunks.iter().all(|c| c.id != id));-}--#[tokio::test]-async fn delete_missing_chunk_is_idempotent() {- let (_tmp, cfg) = test_config();- // Idempotence is the driver's, so this needs a driver: without one the handler- // refuses outright, which is a different answer from "that chunk was not there".- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let resp = delete_chunk_rpc(&cfg, "does-not-exist".into())- .await- .unwrap()- .value;- assert!(!resp.deleted);- assert_eq!(resp.score_rows_removed, 0);-}--/// The one named behaviour delta of the move onto `MemoryEntities::top_entities`,-/// pinned in both directions.-///-/// The member validates `kind` and answers `MemoryError::Invalid` for one it does-/// not recognise. The SQL this handler used to run compared the string against the-/// stored column, so an unknown kind matched nothing and the caller got an empty-/// list. A migration must not turn that quiet empty result into a user-visible-/// error, so the variant is mapped back — and the second half of this test is what-/// keeps the map-back narrow rather than a blanket swallow.-#[tokio::test]-async fn top_entities_reports_empty_for_an_unknown_kind() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] owns it").await;-- let unknown = top_entities_rpc(&cfg, Some("not-a-kind".into()), 10)- .await- .expect("an unrecognised kind is an empty ranking, not an error")- .value;- assert!(unknown.is_empty(), "got: {unknown:?}");-- let known = top_entities_rpc(&cfg, Some("email".into()), 10)- .await- .unwrap()- .value;- assert!(- !known.is_empty(),- "a recognised kind must still rank rows; the Invalid map-back is narrow"- );-}--/// `ForgetOutcome` reports `chunks_removed` and `trees_cleaned` and nothing about-/// the per-chunk side rows, so `DeleteChunkResponse`'s two counts are observed-/// before the delete rather than read off the outcome. This pins that they are-/// still real numbers — dropping them to zero would read as "there was nothing to-/// clean up", which is a different claim from "nobody counted".-#[tokio::test]-async fn delete_chunk_still_reports_its_side_row_counts() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "[email protected] owns it").await;- let id = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks[0]- .id- .clone();-- let indexed = entity_index_for_rpc(&cfg, id.clone()).await.unwrap().value;- let indexed_rows: u32 = indexed.iter().map(|entity| entity.count).sum();- assert!(- indexed_rows > 0,- "expected entity-index rows, got: {indexed:?}"- );-- let resp = delete_chunk_rpc(&cfg, id).await.unwrap().value;- assert!(resp.deleted);- assert_eq!(resp.entity_index_rows_removed, indexed_rows);- assert_eq!(resp.score_rows_removed, 1, "ingest writes one score row");-}--#[tokio::test]-async fn chunk_score_returns_breakdown_after_ingest() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(- &cfg,- "slack:#eng",- "[email protected] owns the phoenix migration",- )- .await;- let chunks = list_chunks_rpc(&cfg, ChunkFilter::default())- .await- .unwrap()- .value- .chunks;- let id = &chunks[0].id;- let breakdown = chunk_score_rpc(&cfg, id.clone()).await.unwrap().value;- assert!(breakdown.is_some(), "expected score row after ingest");- let b = breakdown.unwrap();- assert!(b.signals.iter().any(|s| s.name == "metadata_weight"));- assert!(b.threshold > 0.0);-}--#[tokio::test]-async fn search_returns_matching_chunks() {- let (_tmp, cfg) = test_config();- // These handlers read through the bound driver now that the raw SQL is- // gone, so the test has to bind one. TinyCortex is the engine the- // loadable module wraps, so this exercises the same code production- // reaches over the bus — and unlike the module it is not a process- // singleton, which is what lets these run in one test binary.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- seed_chat_chunk(&cfg, "slack:#eng", "phoenix migration scheduled friday").await;- seed_chat_chunk(&cfg, "slack:#eng", "different unrelated text").await;- let hits = search_rpc(&cfg, "phoenix".into(), 10).await.unwrap().value;- assert!(hits.iter().any(|c| {- c.content_preview- .as_deref()- .unwrap_or("")- .contains("phoenix")- }));-}-#[tokio::test]#[ignore = "needs a built tinymemory module (OPENHUMAN_MODULE_PATH) and its own process: \chunk detail is read through the bound driver, not the in-process engine"]diff --git a/src/openhuman/memory/read_rpc_tests_part_02_tests.rs b/src/openhuman/memory/read_rpc_tests_part_02_tests.rsindex f70d6a02d0..bcb45fa55f 100644--- a/src/openhuman/memory/read_rpc_tests_part_02_tests.rs+++ b/src/openhuman/memory/read_rpc_tests_part_02_tests.rs@@ -128,243 +128,6 @@ fn parse_source_kind_str_accepts_known_values_only() {assert_eq!(parse_source_kind_str("unknown"), None);}-/// The namespace clear is routed through the bound driver's key/value tier-/// (`kv_list` + `kv_delete`) instead of a `rusqlite::Connection` this handler-/// opened on a path it built itself. The claim is unchanged and is what the-/// raw read-back below still checks: only the composio namespace goes.-#[tokio::test]-async fn clear_composio_sync_state_removes_only_target_namespace() {- let (_tmp, cfg) = test_config();- // Created up front so the raw fixture rows below have a schema to land in;- // the driver installed further down opens this same store.- let _memory =- UnifiedMemory::new(cfg.workspace_dir.as_path(), Arc::new(NoopEmbedding), None).unwrap();- let db_path = cfg.workspace_dir.join("memory").join("memory.db");- let conn = rusqlite::Connection::open(&db_path).unwrap();-- conn.execute(- "INSERT INTO kv_namespace (namespace, key, value_json, updated_at)- VALUES (?1, 'cursor', '{}', 1.0)",- params![KV_NAMESPACE],- )- .unwrap();- conn.execute(- "INSERT INTO kv_namespace (namespace, key, value_json, updated_at)- VALUES ('other-namespace', 'cursor', '{}', 2.0)",- [],- )- .unwrap();- drop(conn);-- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let removed = clear_composio_sync_state(&cfg).await.unwrap();- assert_eq!(removed, 1);-- let conn = rusqlite::Connection::open(&db_path).unwrap();- let composio_count: i64 = conn- .query_row(- "SELECT COUNT(*) FROM kv_namespace WHERE namespace = ?1",- params![KV_NAMESPACE],- |row| row.get(0),- )- .unwrap();- let other_count: i64 = conn- .query_row(- "SELECT COUNT(*) FROM kv_namespace WHERE namespace = 'other-namespace'",- [],- |row| row.get(0),- )- .unwrap();- assert_eq!(composio_count, 0);- assert_eq!(other_count, 1);-}--#[tokio::test]-async fn tree_graph_includes_leaf_chunks_linked_to_their_summary() {- let (_tmp, cfg) = test_config();- // The forest and its leaves are read through `MemoryTree`, so the graph- // needs a driver that serves that family — the null fallback does not.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- insert_tree_summary(&cfg, "tree-1", "slack:#eng", "summary:1:L1-aaa", 1);- insert_chunk_with_parent(- &cfg,- "chunk-sealed",- Some("summary:1:L1-aaa"),- 1_700_000_000_000,- "first line of sealed chunk\nmore body",- );- insert_chunk_with_parent(- &cfg,- "chunk-orphan",- None,- 1_700_000_000_001,- "orphan chunk body",- );-- let resp = graph_export_rpc(&cfg, GraphMode::Tree).await.unwrap().value;-- // 1 source root + 1 summary + 2 leaf chunks = 4 nodes.- assert_eq!(- resp.nodes.len(),- 4,- "source root + summary + both leaf chunks"- );-- let source_root = resp.nodes.iter().find(|n| n.kind == "source").unwrap();- assert!(source_root.id.starts_with("source:"));-- let summary = resp.nodes.iter().find(|n| n.kind == "summary").unwrap();- assert_eq!(summary.id, "summary:1:L1-aaa");- // Orphan summary links to source root.- assert_eq!(summary.parent_id.as_deref(), Some(source_root.id.as_str()));-- let sealed = resp.nodes.iter().find(|n| n.id == "chunk-sealed").unwrap();- assert_eq!(sealed.kind, "chunk");- assert_eq!(sealed.parent_id.as_deref(), Some("summary:1:L1-aaa"));- assert_eq!(sealed.label, "first line of sealed chunk");-- let orphan = resp.nodes.iter().find(|n| n.id == "chunk-orphan").unwrap();- assert!(- orphan.parent_id.is_none(),- "unsealed chunk has no parent → renders as an orphan node"- );-- assert!(resp.edges.is_empty());-}--#[tokio::test]-async fn tree_graph_keeps_summaries_first_then_chunks() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- insert_tree_summary(&cfg, "tree-1", "slack:#eng", "summary:1:L1-aaa", 1);- insert_chunk_with_parent(- &cfg,- "chunk-1",- Some("summary:1:L1-aaa"),- 1_700_000_000_000,- "a chunk",- );-- let resp = graph_export_rpc(&cfg, GraphMode::Tree).await.unwrap().value;- // Source roots are emitted first, then summaries, then chunks — so a- // budget truncation drops chunk tails, never the tree skeleton.- assert_eq!(resp.nodes[0].kind, "source");- assert!(resp.nodes.iter().any(|n| n.kind == "summary"));- assert!(resp.nodes.iter().any(|n| n.kind == "chunk"));-}--/// Contacts mode selects chunks by entity *kind* and labels them from one-/// batched entity read.-///-/// The two chunks carry a different number of person rows on purpose. A reader-/// that indexed the flat `chunk_entities` result by position against the ids it-/// sent — the trap the contract's docs call out — would attribute the second-/// chunk's row to the first and still produce two edges, so an asymmetric-/// fixture is what makes the grouping observable.-#[tokio::test]-async fn contacts_graph_selects_person_chunks_and_groups_edges_by_chunk() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);-- insert_chunk_with_parent(- &cfg,- "chunk-a",- None,- 1_700_000_000_002,- "alice and bob met",- );- insert_chunk_with_parent(&cfg, "chunk-b", None, 1_700_000_000_001, "carol shipped it");- // No person row: this chunk must not reach the graph at all.- insert_chunk_with_parent(&cfg, "chunk-c", None, 1_700_000_000_000, "no people here");-- insert_entity_row(- &cfg,- "person:alice",- "chunk-a",- "person",- "Alice",- 1_700_000_000_002,- );- insert_entity_row(- &cfg,- "person:bob",- "chunk-a",- "person",- "Bob",- 1_700_000_000_002,- );- insert_entity_row(- &cfg,- "person:carol",- "chunk-b",- "person",- "Carol",- 1_700_000_000_001,- );- // A non-person row on a person-bearing chunk: it must not become an edge.- insert_entity_row(- &cfg,- "topic:shipping",- "chunk-b",- "topic",- "shipping",- 1_700_000_000_001,- );-- let resp = graph_export_rpc(&cfg, GraphMode::Contacts)- .await- .unwrap()- .value;-- let chunk_ids: Vec<&str> = resp- .nodes- .iter()- .filter(|n| n.kind == "chunk")- .map(|n| n.id.as_str())- .collect();- assert_eq!(- chunk_ids,- vec!["chunk-a", "chunk-b"],- "only person-bearing chunks, newest first"- );-- let mut edges: Vec<(&str, &str)> = resp- .edges- .iter()- .map(|e| (e.from.as_str(), e.to.as_str()))- .collect();- edges.sort_unstable();- assert_eq!(- edges,- vec![- ("chunk-a", "person:alice"),- ("chunk-a", "person:bob"),- ("chunk-b", "person:carol"),- ],- "every edge names the chunk its row came from, and the topic row is filtered out"- );-- let contacts: std::collections::BTreeSet<(&str, &str)> = resp- .nodes- .iter()- .filter(|n| n.kind == "contact")- .map(|n| (n.id.as_str(), n.label.as_str()))- .collect();- let expected: std::collections::BTreeSet<(&str, &str)> = [- ("person:alice", "Alice"),- ("person:bob", "Bob"),- ("person:carol", "Carol"),- ]- .into_iter()- .collect();- assert_eq!(contacts, expected);- assert!(resp- .nodes- .iter()- .filter(|n| n.kind == "contact")- .all(|n| n.entity_kind.as_deref() == Some("person")));-}-/// An empty candidate set must short-circuit, not become an unfiltered read.////// The failure this pins is quiet: an empty predicate means *unfiltered* on@@ -374,7 +137,7 @@ async fn contacts_graph_selects_person_chunks_and_groups_edges_by_chunk() {#[tokio::test]async fn contacts_graph_with_no_person_chunks_is_empty() {let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&cfg);insert_chunk_with_parent(&cfg, "chunk-a", None, 1_700_000_000_000, "no people here");insert_entity_row(&cfg,@@ -572,46 +335,3 @@ async fn vault_health_check_reports_writable_and_obsidian_registered_when_ready();}-/// Regression: `wipe_all` MUST also clear the source-ingest gate-/// (`mem_tree_ingested_sources`). Before the fix it cleared chunks/summaries-/// but left the gate claimed, so a wiped document source could never-/// re-ingest — the next sync saw `already_ingested` and wrote 0 chunks / 0-/// seal jobs. This pins that a wipe leaves the gate empty so re-sync works.-#[tokio::test]-async fn wipe_all_clears_ingest_gate() {- use tinymemory_api::chunks::SourceKind;- use tinymemory_core::store::chunks::store as chunk_store;-- let (_tmp, cfg) = test_config();- // `wipe_all` asks the bound driver to purge; without one bound the workspace- // resolves to the placeholder, which serves no Maintenance family and- // refuses rather than reporting a wipe it did not do.- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let gate_key = "notion:conn-1:page-abc@1700000000000";-- // Claim the gate exactly as a document ingest does.- chunk_store::with_connection(&cfg, |conn| {- let tx = conn.unchecked_transaction()?;- let claimed = chunk_store::claim_source_ingest_tx(- &tx,- SourceKind::Document,- gate_key,- 1_700_000_000_000,- )?;- assert!(claimed, "first claim should succeed");- tx.commit()?;- Ok(())- })- .unwrap();- assert!(- chunk_store::is_source_ingested(&cfg, SourceKind::Document, gate_key).unwrap(),- "gate must be claimed before wipe"- );-- wipe_all_rpc(&cfg).await.expect("wipe_all_rpc");-- assert!(- !chunk_store::is_source_ingested(&cfg, SourceKind::Document, gate_key).unwrap(),- "wipe_all must clear mem_tree_ingested_sources so a wiped source can re-ingest"- );-}diff --git a/src/openhuman/memory/test_support/mod.rs b/src/openhuman/memory/test_support/mod.rsindex fd05a0c3fe..6bd7958081 100644--- a/src/openhuman/memory/test_support/mod.rs+++ b/src/openhuman/memory/test_support/mod.rs@@ -11,66 +11,35 @@ use super::binding::install_for_test;use crate::openhuman::memory::api::provider::MemoryProvider;use std::sync::Arc;-/// Bind the in-process TinyCortex driver over a whole `Config`'s workspace.+/// Bind a fake driver that serves every optional family over a whole `Config`'s+/// workspace.////// The shorthand for a test whose handler reads through a family the null-/// driver does not serve — `Chunks`, `Documents`, `Retrieval` — and which-/// proves itself by writing rows and reading them back. `FixedDiagnostics`-/// cannot serve those: it answers `Maintenance` and delegates the rest to-/// null.+/// driver does not serve — `Chunks`, `Documents`, `Retrieval`.+/// `FixedDiagnostics` cannot serve those: it answers `Maintenance` and+/// delegates the rest to null.///-/// This is the driver the loadable module wraps, so a test binding it exercises-/// the same engine production reaches over the bus. It is not the bus itself,-/// and cannot be: a `dlopen`'ed module is a process singleton, and two tests-/// loading one in the same process hang rather than fail.-pub(crate) fn install_tinycortex_for_test(config: &crate::openhuman::config::Config) {- crate::openhuman::memory::host_impls::install_for_tests();- let client = Arc::new(- tinymemory_core::store::MemoryClient::from_workspace_dir(config.workspace_dir.clone())- .expect("open the workspace store"),- );- // Registered in the process-global slot as well as handed to the driver.- // The engine's Composio sync pipeline opens with `global::client_if_ready`- // and refuses with "memory client is not ready" without it — the module- // path calls `global::bind` for exactly this reason (tinymemory#100), and a- // fixture that builds a client owes the same registration. `bind` rather- // than `init` so the driver and the slot are the SAME client: `init` would- // construct a second one over the same SQLite file, which is two ingestion- // workers and the hazard `global.rs` documents at length.- let _ = tinymemory_core::global::bind(config.workspace_dir.clone(), Arc::clone(&client));- let engine_config = tinymemory_tinycortex::engine::EngineRuntimeConfig {- workspace_dir: config.workspace_dir.clone(),- config_path: config.workspace_dir.join("config.toml"),- memory: config.memory.clone(),- memory_tree: config.memory_tree.clone(),- scheduler_gate: config.scheduler_gate.clone(),- local_ai: config.local_ai.clone(),- embeddings_provider: config.embeddings_provider.clone(),- memory_provider: None,- // Added by tinymemory#100, which moved the periodic sync loops into the- // module. A test fixture wants the same "no cadence configured" default- // the module answers for an older host that sends nothing.- // Carried from the host config rather than blanked: the engine's- // `composio_config` branches on this, so an empty mode sends every- // fixture down the proxied path whether or not that is what the test- // configured.- memory_sync_interval_secs: config.memory_sync_interval_secs,- composio_mode: config.composio.mode.clone(),- composio_entity_id: config.composio.entity_id.clone(),- // Added by tinymemory#103: proxied Composio addresses the backend with- // this. Empty means the host named none, and the request then fails in the- // HTTP client rather than falling back to a guessed host.- backend_api_url: crate::api::config::effective_backend_api_url(&config.api_url),- default_model: None,- default_temperature: 0.2,- output_language: None,- memory_sources: serde_json::Value::Null,- };+/// # Why this is not an engine any more+///+/// It used to build a real `TinycortexProvider` over a temp workspace, and that+/// is what kept `tinycortex` and `tinymemory-core` — 133k lines — on this+/// crate's test critical path long after they left the product build+/// (openhuman#5560). The docstring justified it on the grounds that the+/// alternative was the bus, and a `dlopen`ed module is a process singleton that+/// hangs when a second test loads it.+///+/// That was a false choice: the third option is a driver that is neither the+/// engine nor the bus. `tinymemory-conformance` ships one, it is held to the+/// same contract as TinyCortex by `assert_provider`, and the engine is run+/// against those same assertions upstream — so what a test observes here is+/// contract behaviour rather than one engine's behaviour.+///+/// **What it deliberately will not do is filter, rank, or summarise.** A test+/// that needs those is asserting engine semantics, and upstream owns them; the+/// fake staying simple is what stops such a test from passing here against+/// nothing but the fake.+pub(crate) fn install_memory_driver_for_test(config: &crate::openhuman::config::Config) {let provider: Arc<dyn MemoryProvider> =- Arc::new(tinymemory_tinycortex::engine::TinycortexProvider::new(- "tinycortex".to_string(),- engine_config,- client,- ));+ Arc::new(tinymemory_conformance::RecordingProvider::new());install_for_test(&config.workspace_dir, &config.subsystems.memory, provider);}diff --git a/src/openhuman/memory/tools/flavour_tests.rs b/src/openhuman/memory/tools/flavour_tests.rsindex 00f3239ec0..1970da7546 100644--- a/src/openhuman/memory/tools/flavour_tests.rs+++ b/src/openhuman/memory/tools/flavour_tests.rs@@ -5,7 +5,7 @@ use tempfile::TempDir;// a test that expects a real "not built yet" answer needs a driver serving the// Tree family — the null driver a test workspace otherwise resolves to would// answer `Unsupported`, which this tool reports as a failure rather than as an-// absent profile. `install_tinycortex_for_test` binds the very driver the+// absent profile. `install_memory_driver_for_test` binds the very driver the// loaded module wraps, so these tests exercise the same lookup production runs.fn test_config() -> (TempDir, Arc<Config>) {@@ -73,7 +73,7 @@ async fn unknown_flavour_is_error() {#[tokio::test]async fn valid_flavour_with_no_tree_yet_returns_no_profile_message() {let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&cfg);let tool = MemoryFlavourTool::new(cfg);let result = tool.execute(json!({"flavour": "coding_style"}))@@ -87,7 +87,7 @@ async fn valid_flavour_with_no_tree_yet_returns_no_profile_message() {async fn aliases_are_accepted() {for alias in ["comms", "coding", "env", "rules", "dislikes"] {let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);+ crate::openhuman::memory::test_support::install_memory_driver_for_test(&cfg);let tool = MemoryFlavourTool::new(cfg);let result = tool.execute(json!({"flavour": alias})).await;assert!(result.is_ok(), "alias `{alias}` should be accepted");diff --git a/src/openhuman/memory/tree/retrieval/rpc_tests.rs b/src/openhuman/memory/tree/retrieval/rpc_tests.rsindex 46acf8b118..32f26f3eb4 100644--- a/src/openhuman/memory/tree/retrieval/rpc_tests.rs+++ b/src/openhuman/memory/tree/retrieval/rpc_tests.rs@@ -13,13 +13,13 @@//! does with the answer.//!//! One test binds the real in-process driver instead-//! ([`install_tinycortex_for_test`]): the source gate has to be proved end+//! ([`install_memory_driver_for_test`]): the source gate has to be proved end//! to end, because "the handler passed a scope" and "a restricted profile//! cannot read another source" are different claims and only the second one//! is the security property. It is the driver the loadable module wraps,//! which is as close to production as a test process can get.//!-//! [`install_tinycortex_for_test`]: crate::openhuman::memory::test_support::install_tinycortex_for_test+//! [`install_memory_driver_for_test`]: crate::openhuman::memory::test_support::install_memory_driver_for_testuse std::sync::{Arc, Mutex};use super::*;@@ -50,7 +50,6 @@ use crate::openhuman::memory::source_scope::with_source_scope;// test-only, which is exactly the pair `direct_engine_refs_tests`'// line-based scanner cannot tell apart when the reference sits inside an// inline `#[cfg(test)]` module. See that module's docs.-use crate::openhuman::memory::tree::retrieval::test_support::{stage_test_chunks, upsert_chunks};use tinymemory_api::chunks::{chunk_id, Chunk, Metadata, SourceRef};use tinymemory_api::null::NullMemoryProvider;diff --git a/src/openhuman/memory/tree/retrieval/rpc_tests_part_01_tests.rs b/src/openhuman/memory/tree/retrieval/rpc_tests_part_01_tests.rsindex cd8b98d9aa..3a7db7fa31 100644--- a/src/openhuman/memory/tree/retrieval/rpc_tests_part_01_tests.rs+++ b/src/openhuman/memory/tree/retrieval/rpc_tests_part_01_tests.rs@@ -218,54 +218,6 @@ async fn cover_window_rpc_surfaces_a_driver_rejection() {assert!(err.contains("since_ms"), "got {err}");}-/// The source gate, end to end through the real driver.-///-/// The tests above prove the handler *passes* a scope; this one proves a-/// restricted profile cannot read a source it was not granted. It has to-/// bind the in-process driver rather than the double, because the filtering-/// is the engine's — and `binding.provider()` is unguarded, so the scope-/// this handler passes is the only thing standing between the two.-#[tokio::test]-async fn cover_window_rpc_honors_profile_source_scope() {- let (_tmp, cfg) = test_config();- // Two memory-source chunks in different sources, both inside the window.- let mut allowed = sample_chunk("slack:#eng", 0);- allowed.metadata.tags = vec!["memory_sources".into(), "chat".into()];- let mut blocked = sample_chunk("slack:#secret", 0);- blocked.metadata.tags = vec!["memory_sources".into(), "chat".into()];- upsert_chunks(&cfg, &[allowed.clone(), blocked.clone()]).unwrap();- stage_test_chunks(&cfg, &[allowed.clone(), blocked.clone()]);- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);-- let req = || CoverWindowRequest {- since_ms: 0,- until_ms: 4_000_000_000_000,- source_id: None,- source_kind: None,- limit: None,- };-- let resp = with_source_scope(Some(vec!["slack:#eng".into()]), async {- cover_window_rpc(&cfg, req()).await- })- .await- .unwrap();- let ids: Vec<&str> = resp.value.hits.iter().map(|h| h.node_id.as_str()).collect();- assert!(- ids.contains(&allowed.id.as_str()),- "allowlisted source must be present: {ids:?}"- );- assert!(- !ids.contains(&blocked.id.as_str()),- "disallowed source must be filtered out: {ids:?}"- );-- // With no profile scope active, both sources are visible — which is what- // makes the assertion above a filter rather than an empty store.- let unrestricted = cover_window_rpc(&cfg, req()).await.unwrap();- assert_eq!(unrestricted.value.hits.len(), 2);-}-// ── search_entities_rpc ───────────────────────────────────────────/// The search degrades rather than fails when the bound driver has nodiff --git a/src/openhuman/memory/tree/tree/rpc_tests_part_01_tests.rs b/src/openhuman/memory/tree/tree/rpc_tests_part_01_tests.rsindex 6ab8554453..3d4ae67cbd 100644--- a/src/openhuman/memory/tree/tree/rpc_tests_part_01_tests.rs+++ b/src/openhuman/memory/tree/tree/rpc_tests_part_01_tests.rs@@ -125,43 +125,6 @@ fn the_response_body_serialises_exactly_as_the_declared_wire() {);}-/// Ingest reports what it wrote.-///-/// Bound to the in-process TinyCortex driver rather than left to resolve on-/// its own: the handler asks the driver for the `Ingest` family now, and-/// what a bare test workspace binds is the null driver, which serves none.-/// This is the engine the loadable module wraps, so the counts asserted-/// below are the ones production gets over the bus.-#[tokio::test]-async fn ingest_document_reports_the_chunks_it_wrote() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let outcome = ingest_rpc(- &cfg,- IngestRequest {- source_kind: SourceKind::Document,- source_id: "doc-launch".into(),- owner: "alice".into(),- tags: vec!["launch".into()],- payload: serde_json::to_value(sample_document(- "Launch Plan",- "Phoenix launch canary checklist with rollback steps.",- ))- .unwrap(),- },- )- .await- .unwrap();- assert_eq!(outcome.value.source_id, "doc-launch");- assert_eq!(outcome.value.chunks_dropped, 0);- assert!(outcome.value.chunks_written > 0);- assert!(- !outcome.value.chunk_ids.is_empty(),- "the ids are what a caller fetches a chunk back by, so a write \- that names none is unusable even when the count is right"- );-}-/// The listing degrades rather than fails when the bound driver has no/// chunk tier.///@@ -191,159 +154,6 @@ async fn list_chunks_reports_empty_when_the_driver_has_no_chunk_tier() {assert!(listed.logs[0].contains("n=0"), "log: {}", listed.logs[0]);}-/// The source gate is the driver's, and it survives the move onto the-/// contract: `IngestOutcome::already_ingested` is the field the v1.3.0 pin-/// did not have, and reporting a refused call as a plain empty write is-/// exactly what this test would have started passing over.-#[tokio::test]-async fn ingest_document_is_idempotent_for_duplicate_source_id() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let req = IngestRequest {- source_kind: SourceKind::Document,- source_id: "doc-dup".into(),- owner: "alice".into(),- tags: vec![],- payload: serde_json::to_value(sample_document("Launch Plan", "First body")).unwrap(),- };-- let first = ingest_rpc(&cfg, req.clone()).await.unwrap().value;- let second = ingest_rpc(&cfg, req).await.unwrap().value;- assert!(first.chunks_written > 0);- assert!(!first.already_ingested);- // `already_ingested` with a zero write count is the whole claim:- // documents are append-only, so a repeat submission must be recognised- // rather than duplicated — and told apart from a write that produced- // nothing, which is the same two numbers with a different cause.- assert_eq!(second.chunks_written, 0);- assert!(second.already_ingested);- assert_eq!(second.source_id, first.source_id);-}--/// Regression #3568 / CORE-2K: chat payloads with RFC-3339 timestamps must-/// be accepted — not rejected with "expected unix timestamp in milliseconds".-#[tokio::test]-async fn ingest_chat_accepts_rfc3339_timestamps() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let outcome = ingest_rpc(- &cfg,- IngestRequest {- source_kind: SourceKind::Chat,- source_id: "slack:#rfc3339-test".into(),- owner: "alice".into(),- tags: vec![],- payload: json!({- "platform": "slack",- "channel_label": "#eng",- "messages": [- {- "author": "alice",- "timestamp": "2026-05-17T19:30:00Z",- "text": "planning the launch"- },- {- "author": "bob",- "timestamp": 1779046260000_i64,- "text": "confirmed"- }- ]- }),- },- )- .await- .unwrap();- assert!(!outcome.value.chunk_ids.is_empty());-}--/// Regression #3568 / CORE-2K: email payloads with RFC-3339 timestamps must-/// be accepted.-///-/// A driver is bound, like every sibling here. The note this replaces said-/// the mail arm was "still on the in-process pipeline" and that the test-/// would need `install_tinycortex_for_test` "when it moves" — it has moved:-/// the `Email` arm now goes through `ingest_through_driver`, which resolves-/// `provider().as_ingest()` and refuses a driver that does not serve it.-/// Without the binding the test only passed because CI happens to set-/// `TINYMEMORY_TEST_MODULE` to a module that serves `Ingest`, so it would-/// fail on a machine that does not.-#[tokio::test]-async fn ingest_email_accepts_rfc3339_timestamps() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let outcome = ingest_rpc(- &cfg,- IngestRequest {- source_kind: SourceKind::Email,- source_id: "gmail:rfc3339-test".into(),- owner: "[email protected]".into(),- tags: vec![],- payload: json!({- "provider": "gmail",- "thread_subject": "Launch",- "messages": [- {- "from": "[email protected]",- "to": ["[email protected]"],- "subject": "Launch",- "sent_at": "2026-05-17T19:30:00Z",- "body": "Let's ship this."- }- ]- }),- },- )- .await- .unwrap();- assert!(!outcome.value.chunk_ids.is_empty());-}--/// One empty message must not fail the batch around it.-///-/// `validate_ingest_item` answers `Invalid` for content that trims to-/// empty, and the driver validates every item before ingesting any — so an-/// attachment-only message, which reaches this handler as a message with no-/// text, would turn a batch that has real content in it into a failed call.-/// The in-process pipeline wrote the rest of the batch and rendered that-/// message as a bare header; the filter keeps the first half of that and-/// gives up only the header.-#[tokio::test]-async fn an_empty_chat_message_does_not_fail_the_batch_around_it() {- let (_tmp, cfg) = test_config();- crate::openhuman::memory::test_support::install_tinycortex_for_test(&cfg);- let outcome = ingest_rpc(- &cfg,- IngestRequest {- source_kind: SourceKind::Chat,- source_id: "slack:#attachment-only".into(),- owner: "alice".into(),- tags: vec![],- payload: json!({- "platform": "slack",- "channel_label": "#eng",- "messages": [- {- "author": "alice",- "timestamp": "2026-05-17T19:30:00Z",- "text": " "- },- {- "author": "bob",- "timestamp": "2026-05-17T19:31:00Z",- "text": "here is the plan"- }- ]- }),- },- )- .await- .expect("an empty message is dropped, not a batch failure");- assert!(- !outcome.value.chunk_ids.is_empty(),- "the surviving message must still be written"- );-}-/// An ingest is a write, so a driver without the family is refused rather/// than answered with zeros.///diff --git a/vendor/tinymemory b/vendor/tinymemoryindex 9143fe1207..d217a03f4d 160000--- a/vendor/tinymemory+++ b/vendor/tinymemory@@ -1 +1 @@-Subproject commit 9143fe1207c01784de63da12db71b4ed92da8764+Subproject commit d217a03f4d5d24eb30b74565cde9ae3040922a1e