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
refactor(memory): finish the preference migration, and stop naming the engine for its re-exports\n\nTwo more engine references shed per file the ratchet tracks, and its\nstale-entry check drove both deletions.\n\nThe host preferences module has existed since the guard rewrite and its own\ndocs say the engine copy was never the engine's — but three session call\nsites (two in turn/context.rs, one in turn/core.rs) still called\n`tinymemory_core::preferences`. They now use session-handle twins\n(`load_general_preferences_on`, `recall_situational_preferences_on`) added\nbeside the guard-shaped originals: the agent session binds its memory once\nand threads the `Arc<dyn Memory>` through the turn, and resolving a guard\nambiently there could disagree with the handle the session actually writes\nthrough. `Memory` is the contract trait (`tinymemory_core::traits` is a\nre-export of `tinymemory_api`), and `recall_relevant_by_vector` is a\ncontract-trait method, so both twins are engine-neutral.\n\nOne deliberate behaviour alignment: the general loader uses the host\nmodule's blank-skip rule — the budget is spent only on kept values — where\nthe engine's `take(limit)`-first order let a single blank newest entry\nstarve the prompt block of a real preference one row behind it. The host\nmodule documents that rule as the fix; the migrated callers now get it too.\n\nThe `memory::*` alias surface stops naming the engine for the trait and its\nvalue types: `tinymemory_core::traits` re-exports the contract's items, so\nthe alias now names `api::traits::Memory` and `api::types::*` directly.\nSame items, proven by the compiler; one fewer compile-time reason the crate\nstays in the build (#5560).\n\nRatchet: −2 files (turn/context.rs, turn/core.rs — fully off the engine);\nturn_tests' namespace constant repointed with them.\n\n
Shanu9a554e294a65
diff --git a/src/openhuman/agent/harness/session/turn/context.rs b/src/openhuman/agent/harness/session/turn/context.rsindex 9ff70199f1..9281bb440b 100644--- a/src/openhuman/agent/harness/session/turn/context.rs+++ b/src/openhuman/agent/harness/session/turn/context.rs@@ -165,9 +165,9 @@ impl Agent {// via per-turn recall (Lane B). The legacy `user_profile` pinned namespace// is no longer read here; explicit prefs now live in `user_pref_general`.if !self.learning_enabled && self.explicit_preferences_enabled {- let general = tinymemory_core::preferences::load_general_preferences(+ let general = crate::openhuman::memory::preferences::load_general_preferences_on(&self.memory,- tinymemory_core::preferences::STANDING_PREFS_LIMIT,+ crate::openhuman::memory::preferences::STANDING_PREFS_LIMIT,).await;tracing::debug!(@@ -210,9 +210,9 @@ impl Agent {// injected as ground truth. A high-confidence inferred facet should be// *proposed* to the user (and pinned via `save_preference` on// confirmation), not silently treated as a standing preference.- let general = tinymemory_core::preferences::load_general_preferences(+ let general = crate::openhuman::memory::preferences::load_general_preferences_on(&self.memory,- tinymemory_core::preferences::STANDING_PREFS_LIMIT,+ crate::openhuman::memory::preferences::STANDING_PREFS_LIMIT,).await;diff --git a/src/openhuman/agent/harness/session/turn/core.rs b/src/openhuman/agent/harness/session/turn/core.rsindex b49e0b03f1..dfdaf99cdf 100644--- a/src/openhuman/agent/harness/session/turn/core.rs+++ b/src/openhuman/agent/harness/session/turn/core.rs@@ -484,11 +484,12 @@ impl Agent {// cost). An unrelated message clears the similarity gate to nothing, so// no block is injected.{- let situational = tinymemory_core::preferences::recall_situational_preferences(- &self.memory,- user_message,- )- .await;+ let situational =+ crate::openhuman::memory::preferences::recall_situational_preferences_on(+ &self.memory,+ user_message,+ )+ .await;if !situational.is_empty() {log::info!("[pref_recall] situational block injected: {} item(s)",diff --git a/src/openhuman/agent/harness/session/turn_tests.rs b/src/openhuman/agent/harness/session/turn_tests.rsindex 3acf1d2610..f03f900415 100644--- a/src/openhuman/agent/harness/session/turn_tests.rs+++ b/src/openhuman/agent/harness/session/turn_tests.rs@@ -2184,7 +2184,7 @@ async fn fetch_learned_context_returns_general_prefs_when_explicit_flag_on_learn// writes them). The explicit path now reads `user_pref_general`, not the// legacy `user_profile` pinned namespace.mem.store(- tinymemory_core::preferences::USER_PREF_GENERAL_NAMESPACE,+ crate::openhuman::memory::preferences::USER_PREF_GENERAL_NAMESPACE,"package_manager","Use pnpm for package management.",crate::openhuman::memory::MemoryCategory::Core,@@ -2193,7 +2193,7 @@ async fn fetch_learned_context_returns_general_prefs_when_explicit_flag_on_learn.await.unwrap();mem.store(- tinymemory_core::preferences::USER_PREF_GENERAL_NAMESPACE,+ crate::openhuman::memory::preferences::USER_PREF_GENERAL_NAMESPACE,"verbosity","Keep replies terse.",crate::openhuman::memory::MemoryCategory::Core,@@ -2278,7 +2278,7 @@ async fn fetch_learned_context_loads_general_prefs_when_learning_enabled() {let tmp = tempfile::TempDir::new().unwrap();let mem = make_real_memory(tmp.path());mem.store(- tinymemory_core::preferences::USER_PREF_GENERAL_NAMESPACE,+ crate::openhuman::memory::preferences::USER_PREF_GENERAL_NAMESPACE,"tone","Be concise and direct.",crate::openhuman::memory::MemoryCategory::Core,diff --git a/src/openhuman/memory/api.rs b/src/openhuman/memory/api.rsindex a74c465df8..d60afdd34c 100644--- a/src/openhuman/memory/api.rs+++ b/src/openhuman/memory/api.rs@@ -74,8 +74,8 @@//! move in the same change that removed the duplicate.pub use tinymemory_api::{- capabilities, chunks, error, goals, health, provider, recall, tool_memory, tree, types, wire,- CONTRACT_VERSION,+ capabilities, chunks, error, goals, health, provider, recall, tool_memory, traits, tree, types,+ wire, CONTRACT_VERSION,};/// The inbound half of the seam: the only two `tinymemory_api::host` types thatdiff --git a/src/openhuman/memory/direct_engine_refs_tests.rs b/src/openhuman/memory/direct_engine_refs_tests.rsindex 84566c84f6..13e0cbda76 100644--- a/src/openhuman/memory/direct_engine_refs_tests.rs+++ b/src/openhuman/memory/direct_engine_refs_tests.rs@@ -353,16 +353,6 @@ const ALLOWED: &[(&str, Verdict, &str)] = &[Verdict::NeedsWiderSeam,"holds or boots the in-process engine handle (global::init); driver construction belongs to memory::binding and the seam has no door onto the live client",),- (- "src/openhuman/agent/harness/session/turn/context.rs",- Verdict::NeedsWiderSeam,- "preferences namespace and loaders are engine-owned (preferences::STANDING_PREFS_LIMIT, preferences::load_general_preferences); no capability family covers them",- ),- (- "src/openhuman/agent/harness/session/turn/core.rs",- Verdict::NeedsWiderSeam,- "preferences namespace and loaders are engine-owned (preferences::recall_situational_preferences); no capability family covers them",- ),("src/openhuman/agent/harness/subagent_runner/ops/runner.rs",Verdict::NeedsWiderSeam,diff --git a/src/openhuman/memory/mod.rs b/src/openhuman/memory/mod.rsindex 9129da4ec1..7ad3303c33 100644--- a/src/openhuman/memory/mod.rs+++ b/src/openhuman/memory/mod.rs@@ -131,8 +131,12 @@ pub use tinymemory_core::ingestion::{// are simply ours now. See `rpc_models`'s module docs.pub mod rpc_models;pub use rpc_models::*;-pub use tinymemory_core::traits::{- Memory, MemoryCategory, MemoryEntry, MemoryTaint, NamespaceSummary, RecallOpts,+// Named at the contract, where they are defined — `tinymemory_core::traits`+// is itself a re-export of these (#18 §A1), so this changes no item, only+// which crate the alias holds in the build (#5560).+pub use crate::openhuman::memory::api::traits::Memory;+pub use crate::openhuman::memory::api::types::{+ MemoryCategory, MemoryEntry, MemoryTaint, NamespaceSummary, RecallOpts,};// Types that external tests and consumers historically imported fromdiff --git a/src/openhuman/memory/preferences/mod.rs b/src/openhuman/memory/preferences/mod.rsindex 74d6ffb935..5a8ace0f7d 100644--- a/src/openhuman/memory/preferences/mod.rs+++ b/src/openhuman/memory/preferences/mod.rs@@ -129,6 +129,65 @@ pub async fn load_general_preferences(memory: &MemoryGuard, limit: usize) -> Vecout}+/// [`load_general_preferences`] for a caller holding the session's own+/// storage handle rather than a guard.+///+/// The agent session binds its memory once at build time and threads the+/// `Arc<dyn Memory>` through the turn; resolving a guard ambiently there+/// would re-derive the workspace and could disagree with the handle the+/// session actually writes through. Same rule as the guard variant,+/// including the blank-skip: the budget is spent only on kept values, so a+/// blank newest entry cannot starve the prompt block of a real preference+/// one row behind it.+pub async fn load_general_preferences_on(+ memory: &std::sync::Arc<dyn crate::openhuman::memory::Memory>,+ limit: usize,+) -> Vec<String> {+ let entries = memory+ .list(Some(USER_PREF_GENERAL_NAMESPACE), None, None)+ .await+ .unwrap_or_default();+ let mut out = Vec::new();+ for entry in entries {+ if out.len() >= limit {+ break;+ }+ if let Ok(Some(full)) = memory.get(USER_PREF_GENERAL_NAMESPACE, &entry.key).await {+ let value = full.content.trim();+ if !value.is_empty() {+ out.push(value.to_string());+ }+ }+ }+ out+}++/// [`recall_situational_preferences`] for the session's own storage handle.+///+/// `recall_relevant_by_vector` is a contract-trait method, so this stays+/// engine-neutral; a backend without vectors answers empty, which is the+/// documented degradation for Lane B — an absent block, never a failed turn.+pub async fn recall_situational_preferences_on(+ memory: &std::sync::Arc<dyn crate::openhuman::memory::Memory>,+ query: &str,+) -> Vec<String> {+ if query.trim().is_empty() {+ return Vec::new();+ }+ memory+ .recall_relevant_by_vector(+ USER_PREF_SITUATIONAL_NAMESPACE,+ query,+ SITUATIONAL_RECALL_LIMIT,+ SITUATIONAL_MIN_SIMILARITY,+ )+ .await+ .unwrap_or_default()+ .into_iter()+ .map(|(_topic, value)| value)+ .collect()+}+/// Recall situational preferences semantically relevant to `query` (Lane B).////// Returns only preferences whose vector similarity to the message clears