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
feat(memory): route the runtime tree and flavour profile over the bus\n\nSeven doors merged upstream as tinymemory#123 (contract 4.0, 138 members),\nall on the `Tree` family and all **defaulted** — which is what makes wiring\nthem a decision rather than a compile error. This is the host half.\n\n`ModuleMemoryProvider` forwards all seven, and `GuardedTree` overrides all\nseven. The second half is not optional: a decorator that omits a defaulted\nmember still compiles and then answers `Unsupported` for a driver that\nserves it perfectly well, which is the bug `MemoryMaintenance::diagnose`\nshipped once. Both guard-rails now name the seven —\n`the_defaulted_members_dispatch_to_the_module_instead_of_refusing` and\n`the_defaulted_doors_are_forwarded_rather_than_refused` — and a new\nmodule-backed `#[ignore]` test round-trips five of them against a real\nartifact, which is the only thing that can catch a mistyped wire name.\n\n`memory::tree::tree_runtime` loses its glob. Its five `tree_summarizer_*`\nhandlers, the `tree-summarizer` CLI, `memory::ops::learn` and the\nchannels-startup subscriber ran the markdown time tree in *this* process;\nthey go through the doors now. The doors are six rather than the four\ncoarser members that already existed because `seal` folds the produced node\ninto tree state and `drill_down` folds absence into its own `NotFound` — a\ndoor that changes what the host reports is a new surface, not a migration.\n\n`memory::tools::flavour` is why `FlavourProfile` exists: it needed a\n`tinycortex::memory::MemoryConfig` no host could build without reproducing\nthe engine's own mapping. The driver builds it on its own side now.\n\nTwo behaviours are deliberate and neither is invisible:\n\n- The RPC surface reaches the **guarded** driver, so the seven policy steps\n run over an ingest that carries user prose and two passes that spend on a\n model. That is `memory::ops::guard`'s stated rule for a handler with a\n typed contract twin.\n- `run`/`rebuild` still resolve `create_provider` and drop it. The fold's\n provider is the driver's now, and the driver's role routing has no notion\n of `memory_tree.cloud_summarization_opt_in` — dropping the call would turn\n an explicit privacy refusal into a silent cloud send. The residual gap\n (local AI on no longer folds locally) is documented where the resolver is.\n\nRatchet: 11 entries -> 10. `tree_runtime/mod.rs` is drained — the first\nentry to complete the loop of upstream door, host migration, entry deleted —\nand `host_impls.rs`'s reason is corrected, since its seams now have no\nin-process caller at all and survive only for the far side of the bus. The\nlint's docs gain the blind spot the shed has to work around: the needle is\n`tinymemory_core::` alone, so repointing a file to `tinycortex::` clears an\nentry while an engine stays linked.\n\nThe submodule advances to the merge commit so the contract compiles. The\nmodule registry still pins v1.13.5, so the seven answer `Unsupported`\nagainst the shipped artifact until the re-pin — four raw-coverage cases that\ndrive `tree_summarizer_*` through the real module are red on that gate.\n\nRefs #5560\n\n
Shanucb822e8b484e
diff --git a/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs b/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rsindex d62fb73cd9..68a596af7e 100644--- a/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs+++ b/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs@@ -162,10 +162,10 @@ async fn collect_tree_root_summaries_maps_namespace_body_and_timestamp() {// caller-named workspace. The shared `"memory"` arm now answers from the// bound driver, which has no way to be pointed at this temp directory.use crate::openhuman::config::Config;- use crate::openhuman::memory::tree::tree_runtime::store::write_node;use tinycortex::memory::tree::runtime::{derive_parent_id, estimate_tokens, level_from_node_id, TreeNode,};+ use tinymemory_core::tree::tree_runtime::store::write_node;let tmp = tempfile::TempDir::new().unwrap();let workspace = tmp.path().join("workspace");@@ -206,10 +206,10 @@ async fn collect_tree_root_summaries_maps_namespace_body_and_timestamp() {#[tokio::test]async fn collect_tree_root_summaries_reads_only_profile_memory_subtree() {use crate::openhuman::config::Config;- use crate::openhuman::memory::tree::tree_runtime::store::write_node;use tinycortex::memory::tree::runtime::{derive_parent_id, estimate_tokens, level_from_node_id, TreeNode,};+ use tinymemory_core::tree::tree_runtime::store::write_node;let tmp = tempfile::TempDir::new().unwrap();let workspace = tmp.path().join("workspace");diff --git a/src/openhuman/flows/tinyflows/memory_adapter.rs b/src/openhuman/flows/tinyflows/memory_adapter.rsindex 1b908f145d..a5ca29abaa 100644--- a/src/openhuman/flows/tinyflows/memory_adapter.rs+++ b/src/openhuman/flows/tinyflows/memory_adapter.rs@@ -347,7 +347,7 @@ impl MemoryProvider for OpenHumanMemory {tracing::debug!(target: "flows", flavour = slug, "{LOG_PREFIX} flavour: entry");self.tier_gate_read("flavour")?;- match lookup_flavour(&self.config, slug) {+ match lookup_flavour(&self.config, slug).await {Err(hard) => {tracing::debug!(target: "flows", flavour = slug, "{LOG_PREFIX} flavour: rejected (bad slug)");Err(EngineError::Capability(format!("memory node: {hard}")))diff --git a/src/openhuman/flows/tinyflows/memory_adapter_tests.rs b/src/openhuman/flows/tinyflows/memory_adapter_tests.rsindex 13b1c7085a..25fc023e84 100644--- a/src/openhuman/flows/tinyflows/memory_adapter_tests.rs+++ b/src/openhuman/flows/tinyflows/memory_adapter_tests.rs@@ -23,6 +23,12 @@ fn test_config() -> (TempDir, Arc<Config>) {fn adapter(autonomy: AutonomyLevel) -> (TempDir, OpenHumanMemory) {let (tmp, config) = test_config();+ // `flavour` reads through `MemoryTree::flavour_profile` since #5560, so the+ // workspace needs a driver serving the Tree family — the null driver a test+ // 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);(tmp,OpenHumanMemory {diff --git a/src/openhuman/memory/direct_engine_refs_tests.rs b/src/openhuman/memory/direct_engine_refs_tests.rsindex 168d91fa71..f525ac9455 100644--- a/src/openhuman/memory/direct_engine_refs_tests.rs+++ b/src/openhuman/memory/direct_engine_refs_tests.rs@@ -193,6 +193,20 @@//!//! # Known weaknesses, stated rather than hidden//!+//! - **One needle, two crates — and #5560 sheds both.** [`NEEDLE`] is+//! `tinymemory_core::` alone, but `tinycortex` is a direct dependency of this+//! crate in its own right, not something reached through the engine crate. So+//! repointing a file from `tinymemory_core::x` to `tinycortex::x` clears its+//! entry here while leaving an engine linked, and the ratchet reads as+//! progress. **That is not a migration; it is the lint losing sight of the+//! file.** `memory::tree::health` moved that way legitimately — the taxonomy+//! was always `tinycortex`'s and the engine crate only re-exported it — and+//! `memory::tools::flavour` was a `tinycortex` caller this lint never saw at+//! all until it moved onto `MemoryTree::flavour_profile`. Before concluding+//! the crates have left the build, run the scan for **both** spellings; at+//! the time of writing `tinycortex::` finds one production file+//! (`src/bin/library_profile/scenarios/memory_ingest.rs`) and it is already+//! listed below for the other needle.//! - **The lint sees text, not types.** A reference reached through a//! re-export under another name is invisible to it — and the memory tree is//! full of those on purpose: `memory/mod.rs` re-exports twenty-five engine@@ -321,21 +335,24 @@ const ALLOWED: &[(&str, Verdict, &str)] = &[),// ── Re-export shims: `pub use tinymemory_core::<domain>::*;` ────────────//- // These are the historical-path aliases `memory/mod.rs` documents. They- // name the crate once each and call nothing. Removing them is the- // re-export problem, not the direct-call problem.+ // **Drained.** Four of these existed — `tree/mod.rs`, `tree/health/mod.rs`,+ // `tree/tree/mod.rs` and `tree/tree_runtime/mod.rs` — carrying the+ // historical-path aliases `memory/mod.rs` documented. The first three had+ // no production consumer left, only tests; those tests name the engine+ // crates directly now (served by the `[dev-dependencies]` tinymemory-core+ // entry) and the globs went with them.+ //+ // `tree_runtime` was the last, and the only one that was still production-+ // live: five `tree_summarizer_*` RPC handlers, the `tree-summarizer` CLI,+ // `memory::ops::learn` and the channels-startup subscriber ran the markdown+ // time tree in-process through it. It is gone because the seam grew the six+ // doors it needed — `RuntimeBufferWrite`, `RuntimeReadNode`,+ // `RuntimeReadChildren`, `RuntimeTreeStatus`, `RuntimeSummarize`,+ // `RuntimeRebuild` — in tinymemory PR #123 (contract 4.0). That is the+ // shape every remaining `NeedsWiderSeam` entry below is waiting for, and+ // the first one to complete the loop: upstream door, host migration,+ // entry deleted.//- // Three siblings used to sit here — `tree/mod.rs`, `tree/health/mod.rs`,- // `tree/tree/mod.rs` — whose globs had no production consumer left, only- // tests. Those tests name the engine crates directly now (served by the- // `[dev-dependencies]` tinymemory-core entry) and the globs are deleted,- // so the files no longer reference the engine at all. `tree_runtime` is- // the one still production-live; a parallel round is building its doors.- (- "src/openhuman/memory/tree/tree_runtime/mod.rs",- Verdict::HostSide,- "re-export shim: pub use tinymemory_core::tree::tree_runtime::*",- ),// ── Host-seam installation: the host handing itself TO the engine ───────//// The direction of these is inbound, not outbound: they install embedding /@@ -346,7 +363,7 @@ const ALLOWED: &[(&str, Verdict, &str)] = &[("src/openhuman/memory/host_impls.rs",Verdict::HostSide,- "installs the seven host seams (embedding, chat, config, nlp, scheduler gate, shutdown, error reporter), plus the in-process chunk-store recovery door modules/memory_host.rs calls on StoreCorruptQuarantined — only this process can drop this process's cached handle. The seams are mirrored over the bus by modules/memory_host.rs, and since the tree/health/tree-tree globs were deleted their last in-process caller is the tree_runtime glob below. Composio had an eighth seam here until tinymemory v1.13.4 deleted ComposioHost with the rest of the in-process pipeline",+ "installs the seven host seams (embedding, chat, config, nlp, scheduler gate, shutdown, error reporter), plus the in-process chunk-store recovery door modules/memory_host.rs calls on StoreCorruptQuarantined — only this process can drop this process's cached handle. The seams have no in-process caller left at all now that the tree_runtime glob is deleted: they are reached from the far side of the bus, where modules/memory_host.rs serves the same seven for the loaded module, and unwiring them would fail that module's summariser run with 'no ChatHost installed'. Composio had an eighth seam here until tinymemory v1.13.4 deleted ComposioHost with the rest of the in-process pipeline",),// ── Retrieval: filters the seam's tree family has no room for ───────────// ── Agent tools: chunk reads, source listing, people, source scope ──────diff --git a/src/openhuman/memory/guard/families_part_01.rs b/src/openhuman/memory/guard/families_part_01.rsindex b02f388892..49009f9b59 100644--- a/src/openhuman/memory/guard/families_part_01.rs+++ b/src/openhuman/memory/guard/families_part_01.rs@@ -47,7 +47,7 @@ use crate::openhuman::memory::api::provider::{};use crate::openhuman::memory::api::tool_memory::ToolMemoryRule;use crate::openhuman::memory::api::tree::{- IngestRequest, QueryResult, SummaryForest, TreeLeaf, TreeStatus,+ IngestRequest, QueryResult, SummaryForest, TreeLeaf, TreeNode, TreeStatus,};use crate::openhuman::memory::api::types::NamespaceMemoryHit;use crate::openhuman::memory::api::types::{@@ -598,6 +598,127 @@ impl MemoryTree for GuardedTree {.root_summaries_with_caps(per_namespace_cap, total_cap).await}++ // ── The runtime-tree and flavour doors ──────────────────────────────────+ //+ // **Forwarding these is not optional.** All seven are defaulted on+ // [`MemoryTree`], so a decorator that omits one still compiles — and then+ // answers `Err(Unsupported)` for a driver that serves the member perfectly+ // well, because the guard *is* the handle every product caller holds and+ // its own default is what runs. That exact bug shipped once, on+ // `MemoryMaintenance::diagnose`. The rule this family follows: a new+ // defaulted member on a wrapped trait is a new override here, in the same+ // change.+ //+ // None of them takes a [`SourceScope`], so step 2 does not apply — the+ // contract members carry no scope parameter and the guard does not invent+ // one; see [`Self::root_summaries_with_caps`] for the same reasoning.++ /// Buffering raw content is [`Self::append`]'s write at a finer grain, so+ /// it takes `append`'s admission exactly: the write tier, against the+ /// namespace it names, `carries_content: true`, and the same outbound+ /// scrub applied to the body before it crosses.+ async fn runtime_buffer_write(+ &self,+ namespace: &str,+ content: &str,+ timestamp: chrono::DateTime<chrono::Utc>,+ metadata: Option<serde_json::Value>,+ ) -> Result<String, MemoryError> {+ self.policy.admit_write(+ Capability::Tree,+ "tree.runtime_buffer_write",+ namespace,+ true,+ )?;+ let content = self.policy.redact_outbound(content);+ trace_allowed(+ &self.policy,+ "tree.runtime_buffer_write",+ namespace,+ content.chars().count(),+ );+ self.family()?+ .runtime_buffer_write(namespace, &content, timestamp, metadata)+ .await+ }++ /// A single node read, admitted like [`Self::drill_down`] — the same tree+ /// at the same grain, minus the child list.+ async fn runtime_read_node(+ &self,+ namespace: &str,+ node_id: &str,+ ) -> Result<Option<TreeNode>, MemoryError> {+ self.policy+ .admit_read(Capability::Tree, "tree.runtime_read_node", namespace, false)?;+ self.family()?.runtime_read_node(namespace, node_id).await+ }++ /// The other half of [`Self::drill_down`], admitted identically.+ async fn runtime_read_children(+ &self,+ namespace: &str,+ parent_id: &str,+ ) -> Result<Vec<TreeNode>, MemoryError> {+ self.policy.admit_read(+ Capability::Tree,+ "tree.runtime_read_children",+ namespace,+ false,+ )?;+ self.family()?+ .runtime_read_children(namespace, parent_id)+ .await+ }++ /// Counts and timestamps for one namespace: a read, and one that carries+ /// no prose either way.+ async fn runtime_tree_status(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ self.policy.admit_read(+ Capability::Tree,+ "tree.runtime_tree_status",+ namespace,+ false,+ )?;+ self.family()?.runtime_tree_status(namespace).await+ }++ /// The **write** tier, unlike [`Self::summarise`]: this drains the buffer+ /// into hour leaves and persists them, which is what [`Self::seal`] does+ /// and why `seal` takes the write tier too. `summarise` hands a fold back+ /// and leaves the tree as it found it; this one does not.+ ///+ /// `carries_content: false`: the caller supplies a namespace and an+ /// instant, never prose. The content the pass folds is already in the+ /// driver's own buffer, put there by [`Self::runtime_buffer_write`], which+ /// scrubbed it on the way in.+ async fn runtime_summarize(+ &self,+ namespace: &str,+ timestamp: chrono::DateTime<chrono::Utc>,+ ) -> Result<Option<TreeNode>, MemoryError> {+ self.policy+ .admit_write(Capability::Tree, "tree.runtime_summarize", namespace, false)?;+ self.family()?.runtime_summarize(namespace, timestamp).await+ }++ /// As [`Self::runtime_summarize`], on [`Self::cascade`]'s terms.+ async fn runtime_rebuild(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ self.policy+ .admit_write(Capability::Tree, "tree.runtime_rebuild", namespace, false)?;+ self.family()?.runtime_rebuild(namespace).await+ }++ /// A compiled profile read. The scope is the caller's naming scheme rather+ /// than a namespace, and it is what this call acts on, so it is what the+ /// admission names — the reasoning [`Self::flush_source_tree`] gives for+ /// admitting against its own label instead of `NO_NAMESPACE`.+ async fn flavour_profile(&self, scope: &str) -> Result<Option<String>, MemoryError> {+ self.policy+ .admit_read(Capability::Tree, "tree.flavour_profile", scope, false)?;+ self.family()?.flavour_profile(scope).await+ }}// ── Entities ─────────────────────────────────────────────────────────────────diff --git a/src/openhuman/memory/guard/families_tests.rs b/src/openhuman/memory/guard/families_tests.rsindex b7cff66f9b..741614e263 100644--- a/src/openhuman/memory/guard/families_tests.rs+++ b/src/openhuman/memory/guard/families_tests.rs@@ -584,6 +584,35 @@ async fn the_defaulted_doors_are_forwarded_rather_than_refused() {.await.expect("diagnose must reach the driver");+ // The seven the runtime-tree round added (contract 4.0). Six of them carry+ // the `tree_summarizer_*` RPC surface and the `tree-summarizer` CLI; the+ // seventh is what `memory_flavour` reads. A `GuardedTree` that forgot one+ // would refuse a driver that serves it perfectly well — the shape of the+ // `diagnose` bug this test was written for.+ let tree = guard.as_tree().expect("tree family");+ let at = chrono::Utc::now();+ tree.runtime_buffer_write("team", "hello", at, None)+ .await+ .expect("runtime_buffer_write must reach the driver");+ tree.runtime_read_node("team", "root")+ .await+ .expect("runtime_read_node must reach the driver");+ tree.runtime_read_children("team", "root")+ .await+ .expect("runtime_read_children must reach the driver");+ tree.runtime_tree_status("team")+ .await+ .expect("runtime_tree_status must reach the driver");+ tree.runtime_summarize("team", at)+ .await+ .expect("runtime_summarize must reach the driver");+ tree.runtime_rebuild("team")+ .await+ .expect("runtime_rebuild must reach the driver");+ tree.flavour_profile("persona/communication")+ .await+ .expect("flavour_profile must reach the driver");+let methods: Vec<String> = driver.calls().into_iter().map(|call| call.method).collect();assert_eq!(methods,@@ -594,6 +623,13 @@ async fn the_defaulted_doors_are_forwarded_rather_than_refused() {"chunks.source_ingest_status","maintenance.degraded_state","maintenance.diagnose",+ "tree.runtime_buffer_write",+ "tree.runtime_read_node",+ "tree.runtime_read_children",+ "tree.runtime_tree_status",+ "tree.runtime_summarize",+ "tree.runtime_rebuild",+ "tree.flavour_profile",]);}diff --git a/src/openhuman/memory/guard/test_support_part_01.rs b/src/openhuman/memory/guard/test_support_part_01.rsindex d868f44433..d66f380431 100644--- a/src/openhuman/memory/guard/test_support_part_01.rs+++ b/src/openhuman/memory/guard/test_support_part_01.rs@@ -495,6 +495,80 @@ impl MemoryTree for RecordingProvider {self.record(Call::plain("tree.root_summaries_with_caps"));Ok(Vec::new())}++ // ── The runtime-tree and flavour doors ──────────────────────────────────+ //+ // Overridden for the same reason `summarise` and `root_summaries_with_caps`+ // are: each is defaulted on the trait, so a `GuardedTree` that forgot to+ // forward one still compiles and answers `Unsupported`. A driver that+ // *succeeds* here is what makes `the_defaulted_doors_are_forwarded_rather_than_refused`+ // able to tell the two apart.++ /// Records the buffered body, so a redaction test can assert what the+ /// driver's buffer would have been handed — [`Self::append`]'s twin.+ async fn runtime_buffer_write(+ &self,+ _namespace: &str,+ content: &str,+ _timestamp: chrono::DateTime<chrono::Utc>,+ _metadata: Option<serde_json::Value>,+ ) -> Result<String, MemoryError> {+ self.record(Call {+ method: "tree.runtime_buffer_write".into(),+ content: Some(content.to_string()),+ taint: None,+ scoped: None,+ });+ Ok("/buffer/2026/01/01/00.md".to_string())+ }++ async fn runtime_read_node(+ &self,+ _namespace: &str,+ _node_id: &str,+ ) -> Result<+ Option<crate::openhuman::memory::api::tree::TreeNode>,+ MemoryError,+ > {+ self.record(Call::plain("tree.runtime_read_node"));+ Ok(None)+ }++ async fn runtime_read_children(+ &self,+ _namespace: &str,+ _parent_id: &str,+ ) -> Result<Vec<crate::openhuman::memory::api::tree::TreeNode>, MemoryError> {+ self.record(Call::plain("tree.runtime_read_children"));+ Ok(Vec::new())+ }++ async fn runtime_tree_status(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ self.record(Call::plain("tree.runtime_tree_status"));+ Ok(tree_status(namespace))+ }++ async fn runtime_summarize(+ &self,+ _namespace: &str,+ _timestamp: chrono::DateTime<chrono::Utc>,+ ) -> Result<+ Option<crate::openhuman::memory::api::tree::TreeNode>,+ MemoryError,+ > {+ self.record(Call::plain("tree.runtime_summarize"));+ Ok(None)+ }++ async fn runtime_rebuild(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ self.record(Call::plain("tree.runtime_rebuild"));+ Ok(tree_status(namespace))+ }++ async fn flavour_profile(&self, _scope: &str) -> Result<Option<String>, MemoryError> {+ self.record(Call::plain("tree.flavour_profile"));+ Ok(None)+ }}#[async_trait]diff --git a/src/openhuman/memory/host_impls.rs b/src/openhuman/memory/host_impls.rsindex ec5cebfb00..ca49c7fc00 100644--- a/src/openhuman/memory/host_impls.rs+++ b/src/openhuman/memory/host_impls.rs@@ -25,57 +25,61 @@//! should be live. Seams that must be live (`ConfigLoader`) take a `&Config`//! argument and re-read instead.//!-//! # They are not dead code, and the check is not the driver class (#5560)+//! # What is left alive here, and what stopped being a reason (#5560)//!//! `memory::binding` refuses `DriverClass::Embedded` outright — "embedded//! memory drivers are no longer supported; use the 'tinymemory' module driver"//! — and `modules::memory_host` serves this same set of seven over the bus for//! the module. Both facts together read like an argument that the in-process//! installs below are only reached from tests, and #5560 acted on exactly that-//! reading once and had to be reverted. **The driver class is the wrong thing-//! to check.** It governs what answers a `MemoryProvider` call; it says nothing-//! about the free-function engine surface this crate still reaches through the-//! surviving `memory::tree::tree_runtime` re-export, which bypasses the binding-//! entirely — the "second unpoliced door" `memory::direct_engine_refs` is a-//! ratchet over.+//! reading once and had to be reverted. **The driver class was the wrong thing+//! to check**: it governs what answers a `MemoryProvider` call and says nothing+//! about the free-function engine surface a call site can reach around the+//! binding entirely — the "second unpoliced door" `memory::direct_engine_refs`+//! is a ratchet over.//!-//! **Both production paths this section used to name are gone, and the reason-//! the installs survive has moved with them.** `agent::harness::archivist::-//! recap` folds through `MemoryTree::summarise` and `memory::tools::doctor`-//! through `MemoryMaintenance::diagnose`, so neither reaches [`ChatHost`]-//! in-process any more; the `memory::tree::summarise` path they went through-//! does not resolve at all now that the glob carrying it is deleted.+//! **Every production path this section used to name is now gone.** They went+//! one contract round at a time, and the list is worth keeping because it is+//! the shape the remaining work takes://!-//! What keeps the in-process engine live is **`memory::tree::tree_runtime`**,-//! the last production glob (`pub use tinymemory_core::tree::tree_runtime::*`).-//! Its five `tree_summarizer_*` RPC handlers, the `openhuman tree-summarizer`-//! CLI subcommand, `memory::ops::learn` and the channels-startup event-//! subscriber all run the markdown time-tree in **this** process, and that fold-//! builds its provider through `chat::build_chat_provider` →-//! `chat_host::{provider_for_role, create_chat_model_with_model_id}`. It is-//! also why [`ChatHost::summarizer_available`] is implemented below by-//! delegating straight back into `tree_runtime::ops`: the seam and its last-//! remaining caller are two ends of the same module.+//! - `agent::harness::archivist::recap` folds through `MemoryTree::summarise`.+//! - `memory::tools::doctor` runs through `MemoryMaintenance::diagnose`.+//! - `memory::tree::tree_runtime` — the last production glob+//! (`pub use tinymemory_core::tree::tree_runtime::*`) — is deleted. Its five+//! `tree_summarizer_*` RPC handlers, the `openhuman tree-summarizer` CLI,+//! `memory::ops::learn` and the channels-startup subscriber ran the markdown+//! time tree in *this* process and built its fold through+//! `chat_host::create_chat_model_with_model_id`; they go over the bus now,+//! through the six runtime-tree doors.+//! - `memory::tools::flavour` reached `tinycortex::memory::tree` directly and+//! is on `MemoryTree::flavour_profile`.//!-//! The seams fail **loudly** when unwired rather than degrading, so removing-//! the installs would not silently misbehave — it would break every summariser-//! run with "no ChatHost installed". That is the failure #5560 shipped once, as-//! "no EmbeddingHost installed" on the chat hot path.+//! So **no production caller reaches an in-process engine fold any more**, and+//! [`ChatHost`] below is reached only from the far side of the bus, where+//! `modules::memory_host` serves it for the loaded module. That is not the same+//! thing as the installs being dead: unwire them and the module's own+//! summariser run fails with "no ChatHost installed", which is the failure+//! #5560 shipped once as "no EmbeddingHost installed" on the chat hot path. The+//! seams fail **loudly** rather than degrading, which is a property to keep.//!-//! [`reset_in_process_chunk_store`] survives independently, and its reason has-//! moved too. It was justified by `memory::sources::status` reading the-//! engine's chunk store over raw SQLite; that handler asks-//! `MemoryChunks::source_ingest_status` now and names no engine. What keeps the-//! function is `modules::memory_host`'s `StoreCorruptQuarantined` arm — only-//! this process can drop **this** process's cached handle, so no contract-//! method can stand in for it however small the in-process reader set becomes.+//! [`ChatHost::summarizer_available`] still delegates into+//! `tree_runtime::ops::summarizer_available`, and that is now the *only* edge+//! left between this file and that module: the host owns the local-AI /+//! cloud-opt-in precedence, and the seam is how the driver asks about it.//!-//! **So the question to re-ask is not "is the driver embedded" but "does any+//! [`reset_in_process_chunk_store`] is the one function here with a caller that+//! is not a seam install. It was originally justified by `memory::sources::+//! status` reading the engine's chunk store over raw SQLite; that handler asks+//! `MemoryChunks::source_ingest_status` now and names no engine. What keeps it+//! is `modules::memory_host`'s `StoreCorruptQuarantined` arm — only this+//! process can drop **this** process's cached handle, so no contract method can+//! stand in for it however small the in-process reader set becomes.+//!+//! **The question to re-ask is not "is the driver embedded" but "does any//! production caller still reach an engine free function".** `grep -rn//! 'tinymemory_core::' src --include='*.rs'` outside comments is the inventory-//! for *this* file's installs, now that `tree_runtime` is the only re-export-//! shim left; when it is empty they are dead and go with the manifest entry, in-//! the same change.+//! for *this* file's installs; when it is empty they are dead and go with the+//! manifest entry, in the same change.//!//! **That grep is not the inventory for #5560 as a whole, and the difference//! matters.** #5560 sheds two crates, and `memory::direct_engine_refs` ratchets@@ -84,9 +88,10 @@//! file from `tinymemory_core::x` to `tinycortex::x` drops it out of that lint//! while the engine stays linked. `memory::tree::health` did exactly that, on//! the sound reasoning that the taxonomy was always `tinycortex`'s and the-//! engine crate only re-exported it; it is still a production `tinycortex`-//! reference afterwards, as is `memory::tools::flavour`. Add `tinycortex::` to-//! the grep before concluding the engine has left the build.+//! engine crate only re-exported it. Add `tinycortex::` to the grep before+//! concluding the engine has left the build — at the time of writing the only+//! production file it still finds is `src/bin/library_profile/scenarios/+//! memory_ingest.rs`, which names both crates.//!//! # Composio no longer has a seam here//!diff --git a/src/openhuman/memory/ops/learn_tests.rs b/src/openhuman/memory/ops/learn_tests.rsindex b4c3bcee2c..32f9a9d5a2 100644--- a/src/openhuman/memory/ops/learn_tests.rs+++ b/src/openhuman/memory/ops/learn_tests.rs@@ -91,6 +91,18 @@ async fn write_config_with_runtime_enabled(.expect("load config");config.local_ai.runtime_enabled = runtime_enabled;config.save().await.expect("save config");+ // `memory_learn_all` reaches the tree through+ // `tree_runtime::ops::tree_summarizer_run`, which resolves a driver for+ // *this* config's workspace since #5560 — the handler used to run the+ // markdown time tree in-process. Enumeration is unaffected (it goes through+ // `active_memory_guard`, whose test fallback is the shared fixture+ // workspace the namespaces were seeded in); it is the per-namespace+ // summarisation pass that now needs a binding here.+ //+ // The double resolves its summariser through `ops::create_provider`, the+ // same resolver the handler used before the migration, so these tests keep+ // asserting against the local-AI ladder `runtime_enabled` is flipping.+ crate::openhuman::memory::tree::tree_runtime::test_support::bind_tree_driver(&config);guard}diff --git a/src/openhuman/memory/tools/flavour.rs b/src/openhuman/memory/tools/flavour.rsindex 336fedfb85..ad4c981311 100644--- a/src/openhuman/memory/tools/flavour.rs+++ b/src/openhuman/memory/tools/flavour.rs@@ -1,27 +1,36 @@//! Agent tool: read a compiled persona flavour profile (issue #5172).//!-//! Persona ingestion (engine-side, `tinycortex::memory::persona`) distills a-//! person's coding-agent history into seven [`PersonaFacet`] flavoured trees-//! (communication, coding style, stack, workflow, environment, directives,-//! anti-preferences), each compiled into a small prompt-ready markdown-//! profile via [`compile_flavoured_root`]. Until this tool, nothing surfaced-//! those compiled profiles to the agent loop — the ingested data sat unread.-//! `memory_flavour` lets an agent pull one facet's profile on demand.+//! Persona ingestion (driver-side) distills a person's coding-agent history+//! into seven [`PersonaFacet`] flavoured trees (communication, coding style,+//! stack, workflow, environment, directives, anti-preferences), each compiled+//! into a small prompt-ready markdown profile. Until this tool, nothing+//! surfaced those compiled profiles to the agent loop — the ingested data sat+//! unread. `memory_flavour` lets an agent pull one facet's profile on demand.//!//! Strictly read-only: it never ingests, seals, or otherwise creates persona-//! evidence. The only disk write it can trigger is `compile_flavoured_root`-//! re-staging the fixed-path compiled artifact — a pure, idempotent-//! projection of the tree's existing root node (see-//! `vendor/tinycortex/src/memory/tree/flavoured.rs`), not new memory content.+//! evidence. The only disk write it can trigger is the driver re-staging the+//! fixed-path compiled artifact — a pure, idempotent projection of the tree's+//! existing root node, not new memory content.+//!+//! # This file is why `FlavourProfile` exists (#5560)+//!+//! It reached `tinycortex::memory::tree::{store::get_tree_by_scope,+//! compile_flavoured_root, flavoured_root_abs_path}` directly, and all three+//! take a `tinycortex::memory::MemoryConfig` — so the file was pinned not by a+//! missing capability but by the fact that nothing host-side could build that+//! config without reproducing the engine's own mapping. `MemoryTree::+//! flavour_profile` collapses the entire lookup behind one scope-shaped+//! question, and the config is built on the driver's side of the bus where it+//! belongs. What stays here is the vocabulary ([`PersonaFacet`] and its three+//! string mappings) and the presentation ([`body_after_front_matter`]).use std::sync::Arc;use async_trait::async_trait;use serde_json::json;-use tinycortex::memory::tree::store::{get_tree_by_scope, TreeKind};-use tinycortex::memory::tree::{compile_flavoured_root, flavoured_root_abs_path};use crate::openhuman::config::Config;+use crate::openhuman::memory::api::provider::MemoryProvider;use crate::openhuman::tools::traits::{PermissionLevel, Tool, ToolResult};/// The seven persona facets, host-side (#5560).@@ -136,10 +145,16 @@ impl MemoryFlavourTool {}}-/// Strip the YAML front matter written by [`compile_flavoured_root`]+/// Strip the YAML front matter the flavoured-root compile writes/// (`---\n...\n---\n<body>`) and return just the body. Front-matter field-/// values are single-line (`yaml_quote` collapses interior newlines), so the-/// first `\n---\n` after the opening delimiter is always the closing one.+/// values are single-line (the compiler's `yaml_quote` collapses interior+/// newlines), so the first `\n---\n` after the opening delimiter is always the+/// closing one.+///+/// This is presentation, and presentation is the caller's:+/// [`MemoryTree::flavour_profile`](crate::openhuman::memory::api::provider::MemoryTree::flavour_profile)+/// answers with the **full** artifact because the front matter is part of what+/// was compiled, and only this side knows it wants prose.fn body_after_front_matter(content: &str) -> &str {match content.strip_prefix("---\n") {Some(rest) => match rest.find("\n---\n") {@@ -169,18 +184,24 @@ pub(crate) enum FlavourLookup {Failed(String),}-/// Pure lookup shared by [`MemoryFlavourTool::execute`] and the tinyflows+/// The lookup shared by [`MemoryFlavourTool::execute`] and the tinyflows/// `memory` node's `flavour` operation/// (`OpenHumanMemory::flavour` in `crate::openhuman::flows::tinyflows::memory_adapter`)/// — both surfaces read the exact same flavoured-tree path, so there is only/// one place that knows how a `flavour` slug resolves to a compiled profile.///+/// `async` since #5560: the read crosses the module bus rather than running+/// in-process. Both call sites were already `async fn`s, so nothing is bridged.+////// `Err` is reserved for input the caller should have caught before ever/// reaching the store (empty/unknown `flavour_raw`); everything the store/// itself can report — hit, miss, or lookup failure — comes back as `Ok` of/// the matching [`FlavourLookup`] variant so callers can shape each case/// (tool result vs. node output) however their surface needs.-pub(crate) fn lookup_flavour(config: &Config, flavour_raw: &str) -> Result<FlavourLookup, String> {+pub(crate) async fn lookup_flavour(+ config: &Config,+ flavour_raw: &str,+) -> Result<FlavourLookup, String> {let flavour_raw = flavour_raw.trim();if flavour_raw.is_empty() {return Err("'flavour' cannot be empty".to_string());@@ -190,37 +211,6 @@ pub(crate) fn lookup_flavour(config: &Config, flavour_raw: &str) -> Result<Flavoformat!("Unknown flavour '{flavour_raw}'. Valid flavours: {VALID_FLAVOURS}")})?;- // The `MemoryConfig` the three TinyCortex calls below take, built here- // rather than through `tinymemory_core::tinycortex::memory_config_from` —- // the engine crate's `Config` → `MemoryConfig` mapping, and what used to be- // the one `tinymemory_core::` reference in this file (#5560).- //- // That mapping sets three fields. Two of them are read on this path and are- // reproduced verbatim: `workspace`, which is where `get_tree_by_scope` and- // `compile_flavoured_root` open the shared chunk/tree connection, and- // `content_root`, which `flavoured_root_abs_path` resolves the compiled- // artifact under (`memory_tree.content_dir` when the user set one, else- // `<workspace>/memory_tree/content`). `Config::memory_tree_content_root` is- // the host's own single source of truth for that path, so this reads the- // same value the engine mapping read.- //- // The third — `embedding`, whose `provider` the engine derives from its- // `effective_embedder_slug` ladder — is deliberately left at its default,- // and this is the one reduction to be aware of. That field is the signature- // per-model embedding sidecar rows are keyed by, so it matters wherever a- // vector is written or matched; **nothing on this path is.** `memory_flavour`- // is strictly read-only over the flavoured tree: `get_tree_by_scope` and- // `store::get_summary` are plain SQL over `mem_tree_trees` /- // `mem_tree_summaries`, and `compile_flavoured_root` clamps the root node's- // stored content to `tree.flavour_root_token_budget` and stages it as- // markdown. None of the three reads `config.embedding`.- //- // So: if a call that embeds, re-embeds, or matches a vector is ever added- // to this file, this config is no longer sufficient and the embedder ladder- // has to come with it. A defaulted signature would file rows under the- // wrong provider, which is silent rather than loud.- let mut mc = tinycortex::memory::MemoryConfig::new(config.workspace_dir.clone());- mc.content_root = Some(config.memory_tree_content_root());let scope = facet.tree_scope();let heading = facet.heading();@@ -231,32 +221,57 @@ pub(crate) fn lookup_flavour(config: &Config, flavour_raw: &str) -> Result<Flavo"[memory_flavour] entry");- // Fast path: the compiled artifact already exists on disk with a- // non-empty body — read it directly without touching the tree store.- let abs_path = flavoured_root_abs_path(&mc, &scope);- if abs_path.is_file() {- if let Ok(content) = std::fs::read_to_string(&abs_path) {- let body = body_after_front_matter(&content);- if !body.trim().is_empty() {+ // The whole lookup this function used to run in-process — build a+ // `MemoryConfig`, try the compiled artifact on disk, fall back to+ // `get_tree_by_scope` + `compile_flavoured_root` — is one contract member+ // now (#5560). That is why the door exists: the three TinyCortex calls all+ // took a `tinycortex::memory::MemoryConfig`, and building one host-side+ // meant reproducing the engine's `Config` → `MemoryConfig` mapping field by+ // field, including an `embedding.provider` this path did not read but the+ // next edit to it might have.+ //+ // The driver runs the same two steps in the same order and applies the same+ // built/not-built rule (a tree whose compiled root has an empty body is+ // "not built", never an empty profile), so the three outcomes below are the+ // three this function always had.+ let guard = crate::openhuman::memory::binding::for_config(config)?.guard();+ let Some(tree) = guard.as_tree() else {+ tracing::warn!(+ target: "memory_flavour",+ driver = %guard.driver_id(),+ "[memory_flavour] driver does not serve Tree"+ );+ return Ok(FlavourLookup::Failed(format!(+ "Failed to look up the {heading} profile: driver '{}' does not serve Tree",+ guard.driver_id()+ )));+ };++ match tree.flavour_profile(&scope).await {+ // The member answers the **full compiled artifact, front matter+ // included** — presentation is deliberately the caller's — so the strip+ // stays here, exactly as it was.+ Ok(Some(markdown)) => {+ let body = body_after_front_matter(&markdown);+ if body.trim().is_empty() {+ // Unreachable against a conforming driver, which folds this+ // into `Ok(None)`. Kept because the alternative is handing a+ // model an empty string that reads as "this person has no+ // communication style".+ Ok(FlavourLookup::NotBuilt(format!(+ "No profile built yet for {heading}. Run persona ingestion first, then try \+ again."+ )))+ } else {tracing::debug!(target: "memory_flavour",flavour = flavour_raw,body_len = body.len(),- "[memory_flavour] fast path hit: returning stripped body from disk"+ "[memory_flavour] compiled profile returned");- return Ok(FlavourLookup::Profile(body.to_string()));+ Ok(FlavourLookup::Profile(body.to_string()))}}- }-- tracing::debug!(- target: "memory_flavour",- flavour = flavour_raw,- "[memory_flavour] fast path missed or empty, falling to tree lookup"- );-- // Slow path: look up the flavoured tree and (re)compile its root.- match get_tree_by_scope(&mc, TreeKind::Flavoured, &scope) {Ok(None) => {tracing::debug!(target: "memory_flavour",@@ -268,43 +283,6 @@ pub(crate) fn lookup_flavour(config: &Config, flavour_raw: &str) -> Result<Flavoagain.")))}- Ok(Some(tree)) => {- tracing::debug!(- target: "memory_flavour",- flavour = flavour_raw,- tree_id = %tree.id,- "[memory_flavour] tree found, compiling root"- );- match compile_flavoured_root(&mc, &tree.id) {- Ok(markdown) => {- let body = body_after_front_matter(&markdown);- if body.trim().is_empty() {- Ok(FlavourLookup::NotBuilt(format!(- "No profile built yet for {heading}. Run persona ingestion \- first, then try again."- )))- } else {- tracing::debug!(- target: "memory_flavour",- flavour = flavour_raw,- body_len = body.len(),- "[memory_flavour] compiled profile returned"- );- Ok(FlavourLookup::Profile(body.to_string()))- }- }- Err(err) => {- tracing::warn!(- %err,- flavour = flavour_raw,- "[memory_flavour] failed to compile flavoured profile"- );- Ok(FlavourLookup::Failed(format!(- "Failed to compile the {heading} profile: {err}"- )))- }- }- }Err(err) => {tracing::warn!(%err,@@ -366,7 +344,7 @@ impl Tool for MemoryFlavourTool {.and_then(|v| v.as_str()).ok_or_else(|| anyhow::anyhow!("Missing 'flavour' parameter"))?;- match lookup_flavour(&self.config, flavour_raw) {+ match lookup_flavour(&self.config, flavour_raw).await {Err(hard) => Err(anyhow::anyhow!(hard)),Ok(FlavourLookup::Profile(body)) => Ok(ToolResult::success(body)),Ok(FlavourLookup::NotBuilt(msg)) => Ok(ToolResult::success(msg)),diff --git a/src/openhuman/memory/tools/flavour_tests.rs b/src/openhuman/memory/tools/flavour_tests.rsindex 5a415d6440..00f3239ec0 100644--- a/src/openhuman/memory/tools/flavour_tests.rs+++ b/src/openhuman/memory/tools/flavour_tests.rs@@ -1,6 +1,13 @@use super::*;use tempfile::TempDir;+// `lookup_flavour` reads through `MemoryTree::flavour_profile` now (#5560), so+// 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+// loaded module wraps, so these tests exercise the same lookup production runs.+fn test_config() -> (TempDir, Arc<Config>) {let tmp = TempDir::new().unwrap();let mut cfg = Config::default();@@ -66,6 +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);let tool = MemoryFlavourTool::new(cfg);let result = tool.execute(json!({"flavour": "coding_style"}))@@ -79,6 +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);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/tree_runtime/cli_tests.rs b/src/openhuman/memory/tree/tree_runtime/cli_tests.rsindex 19949cea68..bd80a50a13 100644--- a/src/openhuman/memory/tree/tree_runtime/cli_tests.rs+++ b/src/openhuman/memory/tree/tree_runtime/cli_tests.rs@@ -67,6 +67,26 @@ impl Drop for EnvVarGuard {}}+/// Bind a tree driver for the workspace these subcommands will resolve to.+///+/// The subcommands go through the contract's runtime-tree doors now (#5560), so+/// each one asks `memory::binding` for a provider. With none installed the+/// binding tries to load the compiled TinyMemory module, which in a test+/// process can *block* rather than fail — so every test that reaches a handler+/// has to put one there first.+///+/// The config is resolved exactly the way [`load_config`] resolves it, rather+/// than being constructed here: `OPENHUMAN_WORKSPACE` is set by+/// [`WorkspaceEnvGuard`] and the env overlay is what turns it into the+/// `workspace_dir` the binding is keyed on. Building a `Config::default()` and+/// pointing it at the tempdir would key the binding on a *different* path than+/// the one the CLI then asks for.+fn bind_workspace_driver() {+ let runtime = build_runtime().expect("runtime");+ let config = runtime.block_on(load_config()).expect("config");+ super::super::test_support::bind_tree_driver(&config);+}+#[test]fn is_help_matches_supported_aliases() {assert!(is_help("-h"));@@ -154,6 +174,7 @@ fn help_paths_for_subcommands_return_ok() {fn ingest_status_and_query_run_against_isolated_workspace() {let tmp = TempDir::new().unwrap();let _workspace = WorkspaceEnvGuard::set(tmp.path());+ bind_workspace_driver();assert!(run_ingest(&["ns".to_string(),@@ -171,6 +192,7 @@ fn ingest_status_and_query_run_against_isolated_workspace() {fn ingest_reads_from_file_path() {let tmp = TempDir::new().unwrap();let _workspace = WorkspaceEnvGuard::set(tmp.path());+ bind_workspace_driver();let input = tmp.path().join("input.txt");std::fs::write(&input, "from file").unwrap();@@ -222,6 +244,7 @@ fn run_summarize_errors_cleanly_without_provider() {fn query_prefers_explicit_node_flag_over_positional_node() {let tmp = TempDir::new().unwrap();let _workspace = WorkspaceEnvGuard::set(tmp.path());+ bind_workspace_driver();let err = run_query(&["ns".to_string(),@@ -287,6 +310,7 @@ fn run_and_rebuild_no_longer_block_on_local_ai_precondition() {// precondition. This test asserts that specific regression is gone.let tmp = TempDir::new().unwrap();let _workspace = WorkspaceEnvGuard::set(tmp.path());+ bind_workspace_driver();// Seed a namespace so the commands go through the runtime path// rather than failing argument validation.diff --git a/src/openhuman/memory/tree/tree_runtime/mod.rs b/src/openhuman/memory/tree/tree_runtime/mod.rsindex 9309126b7f..64dae19992 100644--- a/src/openhuman/memory/tree/tree_runtime/mod.rs+++ b/src/openhuman/memory/tree/tree_runtime/mod.rs@@ -1,43 +1,38 @@-//! Host layer over [`tinymemory_core::tree::tree_runtime`].+//! The markdown time tree's host surface — JSON-RPC handlers, controller+//! schemas, the `tree-summarizer` CLI, and the event subscriber.//!-//! The domain itself lives in the extracted crate; what stays here is its-//! JSON-RPC surface — handlers and controller schemas name OpenHuman's-//! `RpcOutcome` and `ControllerSchema`, which the engine crate cannot see.-//! The glob re-export keeps every historical `memory::tree::tree_runtime::…` path resolving.+//! # The glob is gone (#5560)//!-//! # What is left of the glob, and the one thing that pins it (#5560)+//! This module was a host layer *over* `tinymemory_core::tree::tree_runtime`,+//! and `pub use tinymemory_core::tree::tree_runtime::*;` was the last+//! production re-export of the engine crate in this tree. It supplied two+//! modules — `engine` (`run_summarization` / `rebuild_tree` /+//! `run_hourly_loop`) and `store` (~18 `Config`-taking wrappers over+//! `tinycortex::memory::tree::runtime::store`) — and both were pinned by one+//! call, `engine_config(config)`, because nothing host-side could build a+//! `tinycortex::memory::MemoryConfig`.//!-//! Everything below this line is already off the engine crate: the node model-//! is named on the contract (see the next comment), and `ops.rs` reaches the-//! summarisation entry points at `tinycortex::memory::tree::runtime::*`-//! directly. What the glob still supplies is exactly two modules:+//! That is no longer the blocker it was, because the host no longer needs to+//! build one: the tree is reached through the **contract's** six runtime doors+//! (`runtime_buffer_write`, `runtime_read_node`, `runtime_read_children`,+//! `runtime_tree_status`, `runtime_summarize`, `runtime_rebuild`), and the+//! driver that serves them builds the engine config on its own side of the bus,+//! through its own embedder ladder. `ops.rs` carries the per-member mapping.//!-//! - `engine` — `run_summarization` / `rebuild_tree` / `run_hourly_loop`,-//! thin adapters that wrap the host `Config` around tinycortex's `*_observed`-//! entry points and publish `TreeSummarizer*` events.-//! - `store` — ~18 `Config`-taking wrappers over-//! `tinycortex::memory::tree::runtime::store`.+//! `memory::tools::flavour` was blocked on the same call and took the same+//! route out, through `MemoryTree::flavour_profile`.//!-//! Both are one step: they call `engine_config(config)`, which is-//! `tinymemory_core::tinycortex::memory_config_from`. So the blocker here is-//! not a capability family, it is that **nothing host-side can build a-//! `tinycortex::memory::MemoryConfig`.** That function resolves the embedder-//! slug through the engine's own resolution ladder (`effective_embedder_slug`),-//! and keying a vector sidecar on the wrong provider files local vectors under-//! the cloud one — so it is not a helper worth reimplementing from the outside.-//! `memory::sync::sync_status::rpc` and `memory::tools::flavour` are blocked on-//! the same call.--pub use tinymemory_core::tree::tree_runtime::*;+//! What is left here is what could only ever have lived host-side: the handlers+//! and schemas name OpenHuman's `RpcOutcome` and `ControllerSchema`, the CLI+//! names its argument parsing, and the subscriber names `DomainEvent`.// The summary-tree node model is **contract** vocabulary, not engine-// vocabulary: it is defined in `tinymemory-bus` and the engine crate re-exports-// the same items, so these names and the ones the glob above would supply are-// one set of types, not two. Naming the contract explicitly (an explicit `use`-// shadows a glob, and here it shadows it with itself) records which half of-// this shim survives the engine leaving the build — and means the call sites on-// `memory::tree::tree_runtime::estimate_tokens` and friends need no edit when-// it does.+// vocabulary: it is defined in `tinymemory-bus`, and the engine crate — while+// it was still re-exported here — merely re-exported the same items, so these+// names were never a second set of types. They are now the only set, and the+// call sites on `memory::tree::tree_runtime::estimate_tokens` and friends+// needed no edit when the glob went, which is what naming the contract+// explicitly bought.pub use crate::openhuman::memory::api::tree as types;pub use crate::openhuman::memory::api::tree::{derive_node_ids, derive_parent_id, estimate_tokens, level_from_node_id, node_id_to_path,@@ -47,6 +42,10 @@ pub use crate::openhuman::memory::api::tree::{pub mod ops;pub mod schemas;+/// The driver the handler and CLI tests bind, now that both resolve one.+#[cfg(test)]+pub(crate) mod test_support;+pub use ops as rpc;pub mod bus;diff --git a/src/openhuman/memory/tree/tree_runtime/ops.rs b/src/openhuman/memory/tree/tree_runtime/ops.rsindex 7b5dc6e80c..8acc61b37d 100644--- a/src/openhuman/memory/tree/tree_runtime/ops.rs+++ b/src/openhuman/memory/tree/tree_runtime/ops.rs@@ -3,7 +3,11 @@use chrono::{DateTime, Utc};use serde_json::{json, Value};+use std::sync::Arc;+use crate::openhuman::config::Config;+use crate::openhuman::memory::api::error::MemoryError;+use crate::openhuman::memory::api::provider::{MemoryProvider, MemoryTree};// The summary-tree node vocabulary, named at the **contract** (#5560).//// This was `use tinycortex::memory::tree::runtime::*;`, a glob whose entire@@ -16,13 +20,81 @@ use crate::openhuman::config::Config;// under the path the module contract already uses, and no wire byte changes.// The sibling `tree_runtime/mod.rs` re-exports the same set for the same// reason; see its comment on the node model.-//-// Everything else this file reaches still comes from `engine` / `store` below,-// which are `tinymemory-core`'s and are what actually pins that crate here.use crate::openhuman::memory::api::tree::{estimate_tokens, QueryResult};-use crate::openhuman::memory::tree::tree_runtime::{engine, store};+use crate::openhuman::memory::guard::MemoryGuard;use crate::rpc::RpcOutcome;+// ── How these handlers reach the tree ───────────────────────────────────────+//+// Every one of them used to call `tree_runtime::{engine, store}` — the glob+// over `tinymemory_core::tree::tree_runtime` — and run the markdown time tree+// in *this* process. They ask the bound driver now, through the six runtime+// doors the contract grew for exactly this surface (#5560):+//+// | was | is |+// | ---------------------------- | ------------------------------ |+// | `store::buffer_write` | `MemoryTree::runtime_buffer_write` |+// | `store::read_node` | `MemoryTree::runtime_read_node` |+// | `store::read_children` | `MemoryTree::runtime_read_children`|+// | `store::get_tree_status` | `MemoryTree::runtime_tree_status` |+// | `engine::run_summarization` | `MemoryTree::runtime_summarize` |+// | `engine::rebuild_tree` | `MemoryTree::runtime_rebuild` |+//+// The doors are shaped to *this* reply, which is why they are six rather than+// the four coarser members that already existed. `seal` runs the same pass as+// `runtime_summarize` and answers with tree state; `drill_down` folds "no such+// node" into a `NotFound` of its own wording and always pays for the child+// read. Either would have changed what this RPC reports, and a door that+// changes what the host reports is a new surface rather than a migration.+//+// `store::validate_namespace` / `validate_node_id` went with them: the driver+// makes the same two refusals, in the same order, with the same message —+// which is why [`driver_error`] unwraps `Invalid` rather than rendering it.++/// The guarded driver for `config`'s workspace.+///+/// Returned as the owning `Arc` because [`MemoryProvider::as_tree`] hands back+/// a *borrow* of the guard; a helper that resolved the family in one step would+/// be returning a reference to a temporary. Each handler binds this, then asks+/// [`tree_of`] for the family.+///+/// Guarded rather than raw: these five handlers now have typed contract twins,+/// which is the condition `memory::ops::guard` states for taking the guarded+/// door — an ingest that carries user prose and two passes that spend on a+/// model are exactly the calls the seven policy steps exist for. Resolved from+/// the caller's `Config` (as `memory::tree::health::report::run_doctor` does)+/// rather than from the ambient context, because the `tree-summarizer` CLI+/// loads its own config and has no context to be ambient in.+fn tree_guard(config: &Config) -> Result<Arc<MemoryGuard>, String> {+ crate::openhuman::memory::binding::for_config(config).map(|binding| binding.guard())+}++/// The `Tree` family on a bound guard.+fn tree_of(guard: &MemoryGuard) -> Result<&dyn MemoryTree, String> {+ guard+ .as_tree()+ .ok_or_else(|| format!("driver '{}' does not serve Tree", guard.driver_id()))+}++/// A driver error in the string shape this RPC surface has always returned.+///+/// [`MemoryError::Invalid`] is **unwrapped, not rendered**. The refusals this+/// surface used to make host-side — a namespace `validate_namespace` rejects,+/// content that is blank after trimming, a node id that is not `root` or+/// `YYYY[/MM[/DD[/HH]]]` — are the same refusals the doors answer `Invalid`+/// for, carrying the same message, because the driver calls the same+/// validators. Rendering it would prefix every one of them with "invalid+/// input: " and change strings the callers and their tests match on.+///+/// Everything else keeps the handler's own context prefix, which is what the+/// `map_err` at each call site used to supply.+fn driver_error(context: &str, error: MemoryError) -> String {+ match error {+ MemoryError::Invalid(message) => message,+ other => format!("{context}: {other}"),+ }+}+/// Append raw content to the ingestion buffer.pub async fn tree_summarizer_ingest(config: &Config,@@ -31,14 +103,18 @@ pub async fn tree_summarizer_ingest(timestamp: Option<DateTime<Utc>>,metadata: Option<&Value>,) -> Result<RpcOutcome<Value>, String> {- store::validate_namespace(namespace)?;- if content.trim().is_empty() {- return Err("content must not be empty".to_string());- }-+ // Defaulted here rather than driver-side, exactly as before: the reply+ // echoes the instant the content was filed under, and a timestamp the+ // driver resolved would disagree with the one reported here by however+ // long the call took to cross. The contract makes the parameter required+ // for that reason.let ts = timestamp.unwrap_or_else(Utc::now);- let path = store::buffer_write(config, namespace.trim(), content, &ts, metadata)- .map_err(|e| format!("buffer write failed: {e}"))?;++ let guard = tree_guard(config)?;+ let path = tree_of(&guard)?+ .runtime_buffer_write(namespace, content, ts, metadata.cloned())+ .await+ .map_err(|error| driver_error("buffer write failed", error))?;Ok(RpcOutcome::single_log(json!({@@ -46,7 +122,9 @@ pub async fn tree_summarizer_ingest("namespace": namespace.trim(),"timestamp": ts.to_rfc3339(),"tokens": estimate_tokens(content),- "path": path.display().to_string(),+ // The driver's own `display()` of the `PathBuf` it wrote — the same+ // string this handler produced when it held the path itself.+ "path": path,"has_metadata": metadata.is_some(),}),format!("content buffered for namespace '{}'", namespace.trim()),@@ -58,12 +136,22 @@ pub async fn tree_summarizer_run(config: &Config,namespace: &str,) -> Result<RpcOutcome<Value>, String> {- store::validate_namespace(namespace)?;+ // #002 FR-007's consent gate stays **host-side**, and this is the one thing+ // the door does not carry across. `runtime_summarize` builds the fold's+ // provider driver-side, "the way every scheduled seal builds it" — which is+ // `chat_host::create_chat_model_with_model_id("summarization", …)`, this+ // host's ordinary role routing. That routing has no notion of+ // `memory_tree.cloud_summarization_opt_in`, so dropping this call would+ // turn an explicit privacy refusal into a silent cloud send. Resolving here+ // (and discarding the model — construction is cheap and network-free, as+ // `summarizer_available` already documents) keeps the refusal, and its+ // exact wording, unchanged.+ let _ = create_provider(config)?;- let (provider, _model) = create_provider(config)?;let ts = Utc::now();+ let guard = tree_guard(config)?;- match engine::run_summarization(config, provider.as_ref(), namespace.trim(), ts).await {+ match tree_of(&guard)?.runtime_summarize(namespace, ts).await {Ok(Some(node)) => Ok(RpcOutcome::single_log(serde_json::to_value(&node).map_err(|e| e.to_string())?,format!(@@ -80,7 +168,7 @@ pub async fn tree_summarizer_run(namespace.trim()),)),- Err(e) => Err(format!("summarization failed: {e:#}")),+ Err(error) => Err(driver_error("summarization failed", error)),}}@@ -90,13 +178,19 @@ pub async fn tree_summarizer_query(namespace: &str,node_id: Option<&str>,) -> Result<RpcOutcome<Value>, String> {- store::validate_namespace(namespace)?;-let target_id = node_id.unwrap_or("root");- store::validate_node_id(target_id)?;- let node = store::read_node(config, namespace.trim(), target_id)- .map_err(|e| format!("read node: {e}"))?+ let guard = tree_guard(config)?;+ let tree = tree_of(&guard)?;++ // Absence is `Ok(None)` on the door, so the "not found" message is shaped+ // here — where it always was. `drill_down` would have raised its own+ // `NotFound` instead, which is the reason this pair of reads is two members+ // rather than that one.+ let node = tree+ .runtime_read_node(namespace, target_id)+ .await+ .map_err(|error| driver_error("read node", error))?.ok_or_else(|| {format!("node '{}' not found in namespace '{}'",@@ -105,8 +199,10 @@ pub async fn tree_summarizer_query()})?;- let children = store::read_children(config, namespace.trim(), target_id)- .map_err(|e| format!("read children: {e}"))?;+ let children = tree+ .runtime_read_children(namespace, target_id)+ .await+ .map_err(|error| driver_error("read children", error))?;let result = QueryResult { node, children };Ok(RpcOutcome::single_log(@@ -124,10 +220,11 @@ pub async fn tree_summarizer_status(config: &Config,namespace: &str,) -> Result<RpcOutcome<Value>, String> {- store::validate_namespace(namespace)?;-- let status =- store::get_tree_status(config, namespace.trim()).map_err(|e| format!("get status: {e}"))?;+ let guard = tree_guard(config)?;+ let status = tree_of(&guard)?+ .runtime_tree_status(namespace)+ .await+ .map_err(|error| driver_error("get status", error))?;Ok(RpcOutcome::single_log(serde_json::to_value(&status).map_err(|e| e.to_string())?,@@ -140,13 +237,14 @@ pub async fn tree_summarizer_rebuild(config: &Config,namespace: &str,) -> Result<RpcOutcome<Value>, String> {- store::validate_namespace(namespace)?;-- let (provider, _model) = create_provider(config)?;+ // The consent gate, for the reason `tree_summarizer_run` gives.+ let _ = create_provider(config)?;- let status = engine::rebuild_tree(config, provider.as_ref(), namespace.trim())+ let guard = tree_guard(config)?;+ let status = tree_of(&guard)?+ .runtime_rebuild(namespace).await- .map_err(|e| format!("rebuild failed: {e:#}"))?;+ .map_err(|error| driver_error("rebuild failed", error))?;Ok(RpcOutcome::single_log(serde_json::to_value(&status).map_err(|e| e.to_string())?,@@ -180,13 +278,38 @@ pub async fn tree_summarizer_rebuild(/// the user must opt in to cloud summarization via the/// `memory_tree.cloud_summarization_opt_in` setting.///-/// Visibility note: `pub(crate)` so the embedded memory driver's-/// [`MemoryTree`](crate::openhuman::memory::api::provider::MemoryTree)-/// `seal`/`cascade` reach-/// the **same** resolver the RPC path uses. Duplicating the local-AI /-/// cloud-opt-in precedence in the driver would be new policy logic, and the-/// `summarizer_available` doc below is explicit that this function is the-/// single source of truth.+/// # What this still decides, and what it no longer does (#5560)+///+/// It used to *be* the summariser: the model it built ran the fold. It does not+/// any more. `tree_summarizer_run` and `tree_summarizer_rebuild` go through+/// `MemoryTree::{runtime_summarize, runtime_rebuild}`, and the contract is+/// explicit that the fold runs on **the driver's** chat provider, built the way+/// every scheduled `seal` builds it — `chat_host::create_chat_model_with_model_id`,+/// i.e. this host's `"summarization"` role route.+///+/// So what survives here is the *precondition*, and it survives because the+/// driver's route cannot express it. The role ladder resolves+/// `config.memory_provider` and knows nothing about+/// `memory_tree.cloud_summarization_opt_in`; without this call an opted-out+/// user's memory summaries would go to a cloud provider on the first "run now".+/// The two handlers therefore resolve a provider and drop it, purely for the+/// refusal.+///+/// **One consequence is not preserved and should be fixed upstream:** with+/// local AI enabled this returns a local Ollama model, but the driver still+/// builds the cloud-routed `"summarization"` model, so an explicit run no+/// longer folds locally. `MemoryTree::seal` has behaved that way since it+/// landed — this makes `run`/`rebuild` consistent with it rather than+/// introducing the divergence — and the fix belongs where the fold is: the+/// driver resolving its summariser through the host's ladder (which+/// [`summarizer_available`] already crosses the seam to answer) rather than+/// through role routing alone.+///+/// Visibility note: `pub(crate)` is historical. It was widened so an in-process+/// embedded driver's `seal`/`cascade` could reach the same resolver; there is+/// no embedded driver (`memory::driver` is a doc-only namespace and+/// `memory::binding` refuses `DriverClass::Embedded`), so the only callers are+/// in this module.pub(crate) fn create_provider(config: &Config,) -> Result<diff --git a/src/openhuman/memory/tree/tree_runtime/ops_tests.rs b/src/openhuman/memory/tree/tree_runtime/ops_tests.rsindex 678f5e6c46..e127f4a721 100644--- a/src/openhuman/memory/tree/tree_runtime/ops_tests.rs+++ b/src/openhuman/memory/tree/tree_runtime/ops_tests.rs@@ -9,6 +9,11 @@ use tempfile::TempDir;// same crate the sibling `tree_runtime/mod.rs` re-exports them from.use crate::openhuman::memory::api::tree::{derive_parent_id, level_from_node_id, TreeNode};+// The handlers under test resolve a `MemoryProvider` now, so these tests bind+// one. See `tree_runtime::test_support` for what it is and why it is backed by+// the real engine store rather than a fake.+use crate::openhuman::memory::tree::tree_runtime::test_support::{bind_tree_driver, engine_store};+fn rfc3339_z(ts: DateTime<Utc>) -> String {ts.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)}@@ -86,6 +91,7 @@ fn create_provider_uses_cloud_when_opted_in_and_local_ai_off() {#[tokio::test]async fn tree_summarizer_ingest_rejects_blank_content() {let (_tmp, cfg) = config_in_tempdir();+ bind_tree_driver(&cfg);let err = tree_summarizer_ingest(&cfg, "team", " ", None, None).await.expect_err("blank content should be rejected");@@ -99,6 +105,7 @@ async fn tree_summarizer_ingest_writes_buffer_and_reports_metadata() {.with_ymd_and_hms(2026, 5, 24, 12, 30, 0).unwrap();let meta = json!({"source": "unit-test"});+ bind_tree_driver(&cfg);let outcome =tree_summarizer_ingest(&cfg, "Team / Notes", "hello world", Some(ts), Some(&meta)).await@@ -127,6 +134,7 @@ async fn tree_summarizer_ingest_writes_buffer_and_reports_metadata() {#[tokio::test]async fn tree_summarizer_status_reports_empty_tree_defaults() {let (_tmp, cfg) = config_in_tempdir();+ bind_tree_driver(&cfg);let outcome = tree_summarizer_status(&cfg, "fresh-ns").await.expect("status on fresh namespace");@@ -142,6 +150,7 @@ async fn tree_summarizer_status_reports_empty_tree_defaults() {#[tokio::test]async fn tree_summarizer_query_errors_when_node_is_missing() {let (_tmp, cfg) = config_in_tempdir();+ bind_tree_driver(&cfg);let err = tree_summarizer_query(&cfg, "fresh-ns", Some("root")).await.expect_err("missing node should error");@@ -156,8 +165,9 @@ async fn tree_summarizer_query_returns_node_and_children() {.unwrap();let root = test_node("team", "root", "root summary", ts, 1);let year = test_node("team", "2026", "year summary", ts, 1);- store::write_node(&cfg, &root).expect("write root");- store::write_node(&cfg, &year).expect("write year");+ engine_store::write_node(&cfg, &root).expect("write root");+ engine_store::write_node(&cfg, &year).expect("write year");+ bind_tree_driver(&cfg);let outcome = tree_summarizer_query(&cfg, "team", None).await@@ -198,8 +208,9 @@ async fn tree_summarizer_status_reports_populated_tree_details() {test_node("team", "2026/05/24/08", "hour one", early, 0),test_node("team", "2026/05/24/17", "hour two", late, 0),] {- store::write_node(&cfg, &node).expect("write test node");+ engine_store::write_node(&cfg, &node).expect("write test node");}+ bind_tree_driver(&cfg);let outcome = tree_summarizer_status(&cfg, "team").await@@ -218,6 +229,7 @@ async fn tree_summarizer_status_reports_populated_tree_details() {async fn tree_summarizer_run_skips_when_buffer_is_empty() {let (_tmp, mut cfg) = config_in_tempdir();cfg.local_ai.runtime_enabled = true;+ bind_tree_driver(&cfg);let outcome = tree_summarizer_run(&cfg, "team").await@@ -232,7 +244,7 @@ async fn tree_summarizer_run_skips_when_buffer_is_empty() {json!({ "skipped": true, "reason": "no buffered data" }));assert!(- !store::buffer_dir(&cfg, "team").exists(),+ !engine_store::buffer_dir(&cfg, "team").exists(),"skip path should not create a buffer directory");}@@ -245,6 +257,7 @@ async fn tree_summarizer_run_skips_cleanly_with_cloud_fallback_and_empty_buffer(let (_tmp, mut cfg) = config_in_tempdir();cfg.local_ai.runtime_enabled = false;cfg.memory_tree.cloud_summarization_opt_in = true;+ bind_tree_driver(&cfg);let outcome = tree_summarizer_run(&cfg, "team").awaitdiff --git a/src/openhuman/memory/tree/tree_runtime/test_support/mod.rs b/src/openhuman/memory/tree/tree_runtime/test_support/mod.rsnew file mode 100644index 0000000000..1d3aeec1fb--- /dev/null+++ b/src/openhuman/memory/tree/tree_runtime/test_support/mod.rs@@ -0,0 +1,306 @@+//! A driver for the tests of this module's RPC handlers and CLI.+//!+//! # Why a driver has to exist here at all (#5560)+//!+//! The five `tree_summarizer_*` handlers used to call+//! `tree_runtime::{engine, store}` and run the markdown time tree in this+//! process, so a test could write nodes and call a handler with nothing in+//! between. They go through the contract's six runtime-tree doors now, which+//! means they resolve a `MemoryProvider` first — and in a unit test with no+//! binding installed, `memory::binding` tries to load the compiled TinyMemory+//! module, which in a test process can *block* rather than fail.+//! [`bind_tree_driver`] is what stops that, and [`EngineBackedTree`] is what it+//! installs.+//!+//! # Why it is backed by the real engine store rather than a fake+//!+//! What these tests assert is end to end: that an ingest leaves a buffer file+//! on disk carrying the content and its metadata, that a written node comes+//! back with its children, that six nodes read as depth five. Against a+//! hand-rolled fake every one of those becomes an assertion about the fake.+//!+//! The calls below are the ones the real `tinycortex` driver makes for each+//! door — same validators, same order, same error classes — so this double+//! differs from production in exactly one way: *where* the engine runs. Here it+//! is this process; in production it is the loaded module's.+//!+//! Naming `tinymemory_core::` from a `test_support/` path is deliberate and is+//! the route the three sibling globs took when they were deleted:+//! `memory::direct_engine_refs` skips these paths, and the crate is served to+//! them by the `[dev-dependencies]` entry.++use std::sync::Arc;++use async_trait::async_trait;+use chrono::{DateTime, Utc};+use serde_json::Value;++use crate::openhuman::config::Config;+use crate::openhuman::memory::api::capabilities::{Capabilities, Capability};+use crate::openhuman::memory::api::chunks::Chunk;+use crate::openhuman::memory::api::error::MemoryError;+use crate::openhuman::memory::api::health::MemoryHealth;+use crate::openhuman::memory::api::provider::types::{+ ExportPage, ExportRecord, ImportOutcome, SourceScope,+};+use crate::openhuman::memory::api::provider::{+ MemoryCore, MemoryPortability, MemoryProvider, MemoryRecall, MemoryTree,+};+use crate::openhuman::memory::api::recall::OwnedRecallOpts;+use crate::openhuman::memory::api::tree::{IngestRequest, QueryResult, TreeNode, TreeStatus};+use crate::openhuman::memory::api::types::{+ MemoryCategory, MemoryEntry, MemoryTaint, NamespaceSummary,+};++/// The engine's runtime-tree store, for assertions that have to look at what+/// was actually written rather than at what a double said it wrote.+pub(crate) use tinymemory_core::tree::tree_runtime::store as engine_store;++/// A driver serving the six runtime-tree doors from the in-process engine.+pub(crate) struct EngineBackedTree {+ inner: tinymemory_api::null::NullMemoryProvider,+ config: Config,+}++impl EngineBackedTree {+ pub(crate) fn new(config: Config) -> Self {+ Self {+ inner: tinymemory_api::null::NullMemoryProvider::new(),+ config,+ }+ }++ /// An engine failure in the contract's error type.+ ///+ /// Validation refusals go out as [`MemoryError::Invalid`] at the call sites+ /// below rather than through here, matching the driver — that is the+ /// variant `ops::driver_error` unwraps to reproduce the handlers'+ /// historical error strings, so getting the class wrong would show up as a+ /// changed message rather than a failed call.+ fn engine_error(context: &str, error: impl std::fmt::Display) -> MemoryError {+ MemoryError::Other(anyhow::anyhow!("{context}: {error}"))+ }+}++#[async_trait]+impl MemoryCore for EngineBackedTree {+ async fn store(+ &self,+ namespace: &str,+ key: &str,+ content: &str,+ category: MemoryCategory,+ session_id: Option<&str>,+ taint: MemoryTaint,+ ) -> Result<(), MemoryError> {+ self.inner+ .store(namespace, key, content, category, session_id, taint)+ .await+ }+ async fn get(&self, namespace: &str, key: &str) -> Result<Option<MemoryEntry>, MemoryError> {+ self.inner.get(namespace, key).await+ }+ async fn forget(&self, namespace: &str, key: &str) -> Result<bool, MemoryError> {+ self.inner.forget(namespace, key).await+ }+ async fn list(+ &self,+ namespace: Option<&str>,+ category: Option<&MemoryCategory>,+ session_id: Option<&str>,+ ) -> Result<Vec<MemoryEntry>, MemoryError> {+ self.inner.list(namespace, category, session_id).await+ }+ async fn namespaces(&self) -> Result<Vec<NamespaceSummary>, MemoryError> {+ self.inner.namespaces().await+ }+}++#[async_trait]+impl MemoryRecall for EngineBackedTree {+ async fn recall(+ &self,+ query: &str,+ limit: usize,+ opts: &OwnedRecallOpts,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<MemoryEntry>, MemoryError> {+ self.inner.recall(query, limit, opts, scope).await+ }+}++#[async_trait]+impl MemoryPortability for EngineBackedTree {+ async fn export_page(+ &self,+ cursor: Option<&str>,+ limit: usize,+ ) -> Result<ExportPage, MemoryError> {+ self.inner.export_page(cursor, limit).await+ }+ async fn import_records(+ &self,+ records: Vec<ExportRecord>,+ ) -> Result<ImportOutcome, MemoryError> {+ self.inner.import_records(records).await+ }+}++#[async_trait]+impl MemoryTree for EngineBackedTree {+ // The family's five **required** members. Nothing under test reaches them,+ // and answering `Unsupported` rather than delegating to null is the honest+ // shape: this double serves the runtime-tree doors and nothing else, so a+ // future test that wandered onto `seal` would get a refusal it can read+ // instead of a silent empty answer it would have to debug.+ async fn append(&self, _request: IngestRequest) -> Result<(), MemoryError> {+ Err(MemoryError::unsupported(Capability::Tree))+ }+ async fn query_source(+ &self,+ _namespace: &str,+ _source_id: &str,+ _limit: usize,+ _scope: Option<&SourceScope>,+ ) -> Result<Vec<Chunk>, MemoryError> {+ Err(MemoryError::unsupported(Capability::Tree))+ }+ async fn drill_down(+ &self,+ _namespace: &str,+ _node_id: &str,+ ) -> Result<QueryResult, MemoryError> {+ Err(MemoryError::unsupported(Capability::Tree))+ }+ async fn seal(&self, _namespace: &str) -> Result<TreeStatus, MemoryError> {+ Err(MemoryError::unsupported(Capability::Tree))+ }+ async fn cascade(&self, _namespace: &str) -> Result<TreeStatus, MemoryError> {+ Err(MemoryError::unsupported(Capability::Tree))+ }++ async fn runtime_buffer_write(+ &self,+ namespace: &str,+ content: &str,+ timestamp: DateTime<Utc>,+ metadata: Option<Value>,+ ) -> Result<String, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ if content.trim().is_empty() {+ return Err(MemoryError::Invalid(+ "content must not be empty".to_string(),+ ));+ }+ let path = engine_store::buffer_write(+ &self.config,+ namespace.trim(),+ content,+ ×tamp,+ metadata.as_ref(),+ )+ .map_err(|error| Self::engine_error("buffer tree content", error))?;+ Ok(path.display().to_string())+ }++ async fn runtime_read_node(+ &self,+ namespace: &str,+ node_id: &str,+ ) -> Result<Option<TreeNode>, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ engine_store::validate_node_id(node_id).map_err(MemoryError::Invalid)?;+ engine_store::read_node(&self.config, namespace.trim(), node_id)+ .map_err(|error| Self::engine_error("read tree node", error))+ }++ async fn runtime_read_children(+ &self,+ namespace: &str,+ parent_id: &str,+ ) -> Result<Vec<TreeNode>, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ engine_store::validate_node_id(parent_id).map_err(MemoryError::Invalid)?;+ engine_store::read_children(&self.config, namespace.trim(), parent_id)+ .map_err(|error| Self::engine_error("read tree children", error))+ }++ async fn runtime_tree_status(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ engine_store::get_tree_status(&self.config, namespace.trim())+ .map_err(|error| Self::engine_error("read tree status", error))+ }++ /// The summariser is resolved through `ops::create_provider` — the resolver+ /// the handler used before the migration — so the tests written around the+ /// local-AI / cloud-opt-in ladder keep asserting against it.+ ///+ /// The real driver resolves through `chat_host::create_chat_model_with_model_id`+ /// instead, which is the one behavioural difference between this double and+ /// production and is documented at `ops::create_provider`.+ async fn runtime_summarize(+ &self,+ namespace: &str,+ timestamp: DateTime<Utc>,+ ) -> Result<Option<TreeNode>, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ let (provider, _model) = super::ops::create_provider(&self.config)+ .map_err(|error| Self::engine_error("create summarizer", error))?;+ tinymemory_core::tree::tree_runtime::engine::run_summarization(+ &self.config,+ provider.as_ref(),+ namespace.trim(),+ timestamp,+ )+ .await+ .map_err(|error| Self::engine_error("run tree summarization", format!("{error:#}")))+ }++ async fn runtime_rebuild(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ engine_store::validate_namespace(namespace).map_err(MemoryError::Invalid)?;+ let (provider, _model) = super::ops::create_provider(&self.config)+ .map_err(|error| Self::engine_error("create summarizer", error))?;+ tinymemory_core::tree::tree_runtime::engine::rebuild_tree(+ &self.config,+ provider.as_ref(),+ namespace.trim(),+ )+ .await+ .map_err(|error| Self::engine_error("rebuild tree", format!("{error:#}")))+ }+}++#[async_trait]+impl MemoryProvider for EngineBackedTree {+ fn driver_id(&self) -> &str {+ "engine-backed-tree"+ }+ fn capabilities(&self) -> Capabilities {+ Capabilities::all()+ }+ async fn health(&self) -> MemoryHealth {+ MemoryHealth::Ready+ }+ fn as_tree(&self) -> Option<&dyn MemoryTree> {+ Some(self)+ }+}++/// Bind [`EngineBackedTree`] as `cfg`'s workspace driver.+///+/// Call this **after** a test has finished shaping its `Config`: the double+/// captures the config it was built with, and several tests flip+/// `local_ai.runtime_enabled` or the cloud opt-in after constructing one.+/// Binding before that would hand the test a driver resolving its summariser+/// from the config it was about to change.+///+/// The binding cache is keyed by workspace + subtree + `[subsystems.memory]`,+/// so a handler's own `binding::for_config` finds exactly what this installed+/// as long as the `[subsystems.memory]` block is untouched.+pub(crate) fn bind_tree_driver(cfg: &Config) {+ crate::openhuman::memory::binding::install_for_test(+ &cfg.workspace_dir,+ &cfg.subsystems.memory,+ Arc::new(EngineBackedTree::new(cfg.clone())) as Arc<dyn MemoryProvider>,+ );+}diff --git a/src/openhuman/modules/memory_part_01.rs b/src/openhuman/modules/memory_part_01.rsindex 36056b228c..d097d0a392 100644--- a/src/openhuman/modules/memory_part_01.rs+++ b/src/openhuman/modules/memory_part_01.rs@@ -151,7 +151,9 @@ use tinymemory_api::provider::{};use tinymemory_api::recall::OwnedRecallOpts;use tinymemory_api::tool_memory::ToolMemoryRule;-use tinymemory_api::tree::{IngestRequest, QueryResult, SummaryForest, TreeLeaf, TreeStatus};+use tinymemory_api::tree::{+ IngestRequest, QueryResult, SummaryForest, TreeLeaf, TreeNode, TreeStatus,+};use tinymemory_api::types::{GraphRelationRecord, MemoryCategory, MemoryEntry, MemoryKvRecord, MemoryTaint,NamespaceDocumentInput, NamespaceMemoryHit, NamespaceRetrievalContext, NamespaceSummary,diff --git a/src/openhuman/modules/memory_part_02.rs b/src/openhuman/modules/memory_part_02.rsindex 5e2498e528..c39a0cafef 100644--- a/src/openhuman/modules/memory_part_02.rs+++ b/src/openhuman/modules/memory_part_02.rs@@ -145,6 +145,103 @@ impl MemoryTree for ModuleMemoryProvider {(per_namespace_cap, total_cap))}++ // ── The runtime-tree and flavour doors ──────────────────────────────────+ //+ // The seven below are named through `tinymemory_bus::names::methods`+ // rather than as string literals, unlike their neighbours above. The+ // failure a literal invites is precisely the one this family is prone to:+ // a member the pinned artifact does not serve answers `Unsupported` at run+ // time, so a mistyped wire name is indistinguishable from a stale pin, and+ // both look like "the module is old". The constants make the typo a+ // compile error and leave `Unsupported` meaning only what it should.+ //+ // Every one of them is **defaulted** on the trait, which is what makes+ // forwarding them mandatory rather than optional: an override that is+ // missing here does not fail to compile, it silently inherits+ // `Err(Unsupported)` and the driver underneath is never asked.++ async fn runtime_buffer_write(+ &self,+ namespace: &str,+ content: &str,+ timestamp: chrono::DateTime<chrono::Utc>,+ metadata: Option<serde_json::Value>,+ ) -> Result<String, MemoryError> {+ module_call!(+ self,+ "runtime_buffer_write",+ methods::RUNTIME_BUFFER_WRITE,+ (namespace, content, timestamp, metadata)+ )+ }++ async fn runtime_read_node(+ &self,+ namespace: &str,+ node_id: &str,+ ) -> Result<Option<TreeNode>, MemoryError> {+ module_call!(+ self,+ "runtime_read_node",+ methods::RUNTIME_READ_NODE,+ (namespace, node_id)+ )+ }++ async fn runtime_read_children(+ &self,+ namespace: &str,+ parent_id: &str,+ ) -> Result<Vec<TreeNode>, MemoryError> {+ module_call!(+ self,+ "runtime_read_children",+ methods::RUNTIME_READ_CHILDREN,+ (namespace, parent_id)+ )+ }++ async fn runtime_tree_status(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ module_call!(+ self,+ "runtime_tree_status",+ methods::RUNTIME_TREE_STATUS,+ (namespace,)+ )+ }++ /// Long-running on [`Self::summarise`]'s terms — the fold is one provider+ /// call per hour group drained, plus the propagation above them — and it+ /// rides the default deadline for the same reason: the module clamps each+ /// fold to the level's own token budget, and a summariser that outruns the+ /// deadline is the failure every caller of this surface already handles.+ async fn runtime_summarize(+ &self,+ namespace: &str,+ timestamp: chrono::DateTime<chrono::Utc>,+ ) -> Result<Option<TreeNode>, MemoryError> {+ module_call!(+ self,+ "runtime_summarize",+ methods::RUNTIME_SUMMARIZE,+ (namespace, timestamp)+ )+ }++ /// As [`Self::runtime_summarize`], over every level of the tree at once.+ async fn runtime_rebuild(&self, namespace: &str) -> Result<TreeStatus, MemoryError> {+ module_call!(+ self,+ "runtime_rebuild",+ methods::RUNTIME_REBUILD,+ (namespace,)+ )+ }++ async fn flavour_profile(&self, scope: &str) -> Result<Option<String>, MemoryError> {+ module_call!(self, "flavour_profile", methods::FLAVOUR_PROFILE, (scope,))+ }}#[async_trait]diff --git a/src/openhuman/modules/memory_tests.rs b/src/openhuman/modules/memory_tests.rsindex c30cfd6e23..420aea6cc0 100644--- a/src/openhuman/modules/memory_tests.rs+++ b/src/openhuman/modules/memory_tests.rs@@ -523,6 +523,171 @@ async fn the_defaulted_members_dispatch_to_the_module_instead_of_refusing() {.await.expect_err("a disabled host cannot succeed"),);++ // The seven the runtime-tree round added (contract 4.0). Six carry the+ // `tree_summarizer_*` RPC surface and the `tree-summarizer` CLI; the+ // seventh is what `memory_flavour` reads. All seven are defaulted upstream,+ // so a missing `module_call!` arm is invisible to the compiler and turns+ // "Build Summary Trees" into `unsupported capability` against an artifact+ // that serves it.+ let at = chrono::Utc::now();+ refused(+ "runtime_buffer_write",+ MemoryTree::runtime_buffer_write(&provider, "ns", "content", at, None)+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "runtime_read_node",+ MemoryTree::runtime_read_node(&provider, "ns", "root")+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "runtime_read_children",+ MemoryTree::runtime_read_children(&provider, "ns", "root")+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "runtime_tree_status",+ MemoryTree::runtime_tree_status(&provider, "ns")+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "runtime_summarize",+ MemoryTree::runtime_summarize(&provider, "ns", at)+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "runtime_rebuild",+ MemoryTree::runtime_rebuild(&provider, "ns")+ .await+ .expect_err("a disabled host cannot succeed"),+ );+ refused(+ "flavour_profile",+ MemoryTree::flavour_profile(&provider, "persona/communication")+ .await+ .expect_err("a disabled host cannot succeed"),+ );+}++/// The runtime-tree and flavour doors, driven against a **real** module.+///+/// The test above proves the `module_call!` arms exist by discriminating+/// `Other` from `Unsupported` against a disabled host; it cannot prove the wire+/// names are right, because a mistyped one fails the same way a disabled host+/// does. This one can: it loads an actual artifact and asserts the answers.+///+/// # What it deliberately does not drive+///+/// `runtime_summarize` and `runtime_rebuild` resolve a chat model on the+/// driver's side and then spend on it. A test that called them would either+/// reach the network or assert against a provider-resolution failure, and+/// neither says anything about the door. The five below are store-shaped and+/// answer from a fresh workspace with no ambiguity: a buffered write reports+/// where it landed, an empty tree has no root and no children, its status is+/// all zeroes, and nothing has been distilled for a persona scope.+///+/// Run it against a locally built module, one test per process:+///+/// ```text+/// TINYMEMORY_TEST_MODULE=/path/to/libtinymemory_module.dylib \+/// cargo test --lib -- --ignored --exact --test-threads=1 \+/// openhuman::modules::memory::tests::the_runtime_tree_doors_round_trip_through_a_real_module+/// ```+#[tokio::test]+#[ignore = "needs a built tinymemory module (TINYMEMORY_TEST_MODULE) and its own process: \+the bus belongs to whichever runtime creates it, so a second module-loading test in the same \+process finds a broker whose tasks are already gone and hangs rather than failing"]+async fn the_runtime_tree_doors_round_trip_through_a_real_module() {+ let module = std::env::var_os("TINYMEMORY_TEST_MODULE")+ .expect("set TINYMEMORY_TEST_MODULE to a built libtinymemory_module cdylib");+ let workspace = tempfile::TempDir::new().expect("tempdir");++ let mut config = Config::default();+ config.workspace_dir = workspace.path().to_path_buf();+ config.modules.enabled = true;+ config.modules.install_dir = Some(+ workspace+ .path()+ .join("modules")+ .to_string_lossy()+ .into_owned(),+ );+ config+ .modules+ .overrides+ .push(crate::openhuman::config::schema::ModuleOverride {+ id: MODULE_ID.to_string(),+ path: module.to_string_lossy().into_owned(),+ });++ let provider = ModuleMemoryProvider::new(Arc::new(config));+ let tree = provider.as_tree().expect("the Tree family");+ let at = chrono::Utc::now();++ let path = tree+ .runtime_buffer_write("team", "standup notes", at, None)+ .await+ .expect("RuntimeBufferWrite must reach the module");+ assert!(+ !path.trim().is_empty(),+ "the buffered write reports where it landed"+ );++ assert!(+ tree.runtime_read_node("team", "root")+ .await+ .expect("RuntimeReadNode must reach the module")+ .is_none(),+ "a buffered write creates no nodes; absence is data, not an error"+ );+ assert!(+ tree.runtime_read_children("team", "root")+ .await+ .expect("RuntimeReadChildren must reach the module")+ .is_empty(),+ "a parent that does not exist has no children"+ );++ let status = tree+ .runtime_tree_status("team")+ .await+ .expect("RuntimeTreeStatus must reach the module");+ assert_eq!(status.namespace, "team");+ assert_eq!(status.total_nodes, 0);+ assert_eq!(status.depth, 0);++ assert!(+ tree.flavour_profile("persona/communication")+ .await+ .expect("FlavourProfile must reach the module")+ .is_none(),+ "nothing has been distilled for this scope yet"+ );++ // The two refusals the doors make before touching the store, so a wrong+ // wire name cannot pass this test by answering plausibly to everything.+ let rejected = tree+ .runtime_buffer_write("../escape", "x", at, None)+ .await+ .expect_err("a traversal namespace is refused");+ assert!(+ matches!(rejected, MemoryError::Invalid(_)),+ "a rejected namespace is a caller mistake, not a backend failure: {rejected:?}"+ );+ let blank = tree+ .runtime_buffer_write("team", " ", at, None)+ .await+ .expect_err("blank content is refused");+ assert!(+ matches!(blank, MemoryError::Invalid(_)),+ "blank content is a caller mistake: {blank:?}"+ );}#[test]diff --git a/tests/memory_tree_summarizer_e2e.rs b/tests/memory_tree_summarizer_e2e.rsindex c48c613ffc..eeb4cb625d 100644--- a/tests/memory_tree_summarizer_e2e.rs+++ b/tests/memory_tree_summarizer_e2e.rs@@ -31,9 +31,14 @@ use chrono::{DateTime, TimeZone, Utc};use tempfile::tempdir;use openhuman_core::openhuman::config::Config;-use openhuman_core::openhuman::memory::tree::tree_runtime::{engine, store};+// The host's `tree_runtime` re-export of these two engine modules is gone+// (#5560): the RPC surface goes through the contract's runtime-tree doors, and+// the fold itself is the driver's. This target still drives the engine+// directly, so it names the engine crate — which is what the sibling+// `memory::tree` globs' tests already do.use tinyinference::model::{ChatModel, ModelRequest, ModelResponse};use tinyinference::Error as TinyAgentsError;+use tinymemory_core::tree::tree_runtime::{engine, store};// ── Env isolation ─────────────────────────────────────────────────────────diff --git a/tests/raw_coverage/memory_raw_coverage_e2e.rs b/tests/raw_coverage/memory_raw_coverage_e2e.rsindex 638a5368fc..99e4f1a15f 100644--- a/tests/raw_coverage/memory_raw_coverage_e2e.rs+++ b/tests/raw_coverage/memory_raw_coverage_e2e.rs@@ -48,7 +48,7 @@ use tinycortex::memory::sync::{SyncOutcome, SyncPipelineKind};use tinymemory_core::tree::summarise::{fallback_summary, SummaryContext, SummaryInput,};-use openhuman_core::openhuman::memory::tree::tree_runtime::store as tree_store;+use tinymemory_core::tree::tree_runtime::store as tree_store;use openhuman_core::openhuman::memory::tree::tree_runtime::{derive_node_ids, estimate_tokens, level_from_node_id, node_id_to_path, NodeLevel, TreeNode,};diff --git a/tests/raw_coverage/memory_threads_raw_coverage_e2e.rs b/tests/raw_coverage/memory_threads_raw_coverage_e2e.rsindex 75fb9809b5..b793a399bb 100644--- a/tests/raw_coverage/memory_threads_raw_coverage_e2e.rs+++ b/tests/raw_coverage/memory_threads_raw_coverage_e2e.rs@@ -130,7 +130,7 @@ use tinymemory_core::tree::summarise::{fallback_summary, SummaryContext, SummaryInput,};use tinymemory_core::tree::tree::bucket_seal::LeafRef;-use openhuman_core::openhuman::memory::tree::tree_runtime::store as tree_runtime_store;+use tinymemory_core::tree::tree_runtime::store as tree_runtime_store;use openhuman_core::openhuman::memory::tree::tree_runtime::{all_tree_summarizer_controller_schemas, all_tree_summarizer_registered_controllers,derive_node_ids, derive_parent_id, estimate_tokens, level_from_node_id, node_id_to_path,diff --git a/tests/raw_coverage/memory_tree_memory_round23_raw_coverage_e2e.rs b/tests/raw_coverage/memory_tree_memory_round23_raw_coverage_e2e.rsindex 5600580159..fea4c0e347 100644--- a/tests/raw_coverage/memory_tree_memory_round23_raw_coverage_e2e.rs+++ b/tests/raw_coverage/memory_tree_memory_round23_raw_coverage_e2e.rs@@ -20,9 +20,13 @@ use openhuman_core::openhuman::inference::embeddings::NoopEmbedding;use tinycortex::memory::ingest::{ExtractionMode, MemoryIngestionConfig, MemoryIngestionRequest};use tinymemory_core::store::{NamespaceDocumentInput, UnifiedMemory};use openhuman_core::openhuman::memory::tree::tree_runtime::{- all_tree_summarizer_registered_controllers, engine, rpc as tree_runtime_rpc,- store as tree_runtime_store,+ all_tree_summarizer_registered_controllers, rpc as tree_runtime_rpc,};+// The host's `tree_runtime` re-export of these two engine modules is gone+// (#5560): the RPC surface goes through the contract's runtime-tree doors now,+// and the fold is the driver's. This target drives the engine directly, so it+// names the engine crate.+use tinymemory_core::tree::tree_runtime::{engine, store as tree_runtime_store};use tinyinference::model::{ChatModel, ModelRequest, ModelResponse};struct EnvVarGuard {diff --git a/tests/raw_coverage/memory_tree_sync_raw_coverage_e2e.rs b/tests/raw_coverage/memory_tree_sync_raw_coverage_e2e.rsindex e861d58e3c..9c24c8f390 100644--- a/tests/raw_coverage/memory_tree_sync_raw_coverage_e2e.rs+++ b/tests/raw_coverage/memory_tree_sync_raw_coverage_e2e.rs@@ -44,9 +44,9 @@ use tinymemory_core::tree::tree::bucket_seal::append_leaf;use tinymemory_core::tree::tree::{append_leaf_deferred, get_or_create_tree, store as tree_store, LabelStrategy, LeafRef,};-use openhuman_core::openhuman::memory::tree::tree_runtime::{- engine, rpc as tree_runtime_rpc, store as runtime_store,-};+use openhuman_core::openhuman::memory::tree::tree_runtime::rpc as tree_runtime_rpc;+// As above: the host re-export is gone, the engine is named directly (#5560).+use tinymemory_core::tree::tree_runtime::{engine, store as runtime_store};use tinyinference::model::{ChatModel, ModelRequest, ModelResponse};struct EnvVarGuard {diff --git a/vendor/tinymemory b/vendor/tinymemoryindex 28d9092783..3da810f0ad 160000--- a/vendor/tinymemory+++ b/vendor/tinymemory@@ -1 +1 @@-Subproject commit 28d9092783a5ccb997b9369e75e14937c37fe01c+Subproject commit 3da810f0ad48b5e2488004679721fc5ebc9419a0