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: wire MemoryScoring bus family into openhuman (#5560)\n\nRoutes three tinymemory-core engine calls through the memory bus,\neliminating the last direct engine deps for entity extraction and embedding.\n\nBus contract (tinymemory feat/5560-memory-scoring):\n- extract_entities(query) -> Vec<String>\n- embed_text(text) -> Vec<f32>\n- embedder_slug() -> String\n\nHost wiring:\n- modules/memory.rs: ModuleMemoryProvider implements MemoryScoring via\n module_call! (ExtractEntities / EmbedText / EmbedderSlug)\n- memory/guard/families.rs: GuardedScoring decorator + MemoryScoring impl\n- memory/guard/provider.rs: scoring field wired into MemoryGuard\n- memory/guard/test_support.rs: RecordingProvider implements MemoryScoring\n\nCall-site migrations:\n- archivist/lifecycle.rs: embed_segment_recap uses provider.as_scoring()\n instead of building an embedder directly from tinymemory-core\n- runner.rs: extract_query_entities routed through provider.as_scoring()\n with fail-open on missing Scoring family\n- inference/embeddings/rpc.rs: effective_embedder_slug resolved host-side\n from config ladder without calling the engine\n\nCompat fixes (v1.13.0 API changes landed with vendor bump):\n- memory/host.rs + memory_host.rs: StoreCorruptQuarantined arm added\n- memory/sources/rpc.rs: SyncAuditEntry gains tree_ingest_failures/tree_error\n- all_tests.rs: Capability::Scoring -> false in has_rpc_surface\n- ops/provider.rs: 'scoring' added to capability list assertion\n\n762 tests pass, clippy -D warnings clean\n
shanu0f6d76f434d5
diff --git a/src/core/all_tests.rs b/src/core/all_tests.rsindex 40e0b19d65..feedebb482 100644--- a/src/core/all_tests.rs+++ b/src/core/all_tests.rs@@ -1851,13 +1851,9 @@ fn every_capability_family_is_accounted_for_in_the_rpc_surface() {// its only caller is the archivist post-turn hook, which runs// in-process on the turn path rather than answering an RPC.Capability::Episodic => false,- // New in tinymemory v1.13.2 (tinymemory#110): entity extraction and- // text embedding served by the module and forwarded by the driver- // (`as_scoring`). No controller is tagged with it yet: its callers- // are the scoring and query paths that still reach the engine- // in-process, so gating a controller on it would unregister RPC- // methods that work today. Flips in the change that routes those- // callers through the driver (#5560).+ // Scoring operations are routed through the module bus but have no+ // RPC controller of their own — callers reach the driver directly+ // via `as_scoring()`.Capability::Scoring => false,};assert_eq!(diff --git a/src/openhuman/agent/harness/archivist/lifecycle.rs b/src/openhuman/agent/harness/archivist/lifecycle.rsindex 2854c43e23..59106514a4 100644--- a/src/openhuman/agent/harness/archivist/lifecycle.rs+++ b/src/openhuman/agent/harness/archivist/lifecycle.rs@@ -9,7 +9,6 @@ use crate::openhuman::config::Config;use crate::openhuman::memory::api::provider::{ConversationSegment, EpisodicEvent, EpisodicTurn, FacetType, MemoryEpisodic, MemoryProvider,};-use crate::openhuman::memory::tree::score::embed::{build_embedder_from_config, Embedder};use std::sync::Arc;use std::time::{SystemTime, UNIX_EPOCH};@@ -36,7 +35,6 @@ impl ArchivistHook {summariser_available: false,#[cfg(test)]chat_provider: None,- embedder: None,}}@@ -46,9 +44,10 @@ impl ArchivistHook {/// When `config.learning.chat_to_tree_enabled` is `true`, each closed/// segment's raw prose turns are ingested into the memory tree as/// `source_id="conversations:agent"` (one batch per segment, not per turn).- /// Both the summariser probe and the embedder are soft-fallback: if- /// construction fails, the archivist falls back to the heuristic summary /- /// no embedding rather than failing the turn.+ /// The summariser probe is soft-fallback: if construction fails, the+ /// archivist falls back to the heuristic summary rather than failing the+ /// turn. Embedding is also non-fatal and goes through the provider's+ /// `as_scoring()` family.////// # Why the summariser is probed and not held///@@ -101,22 +100,7 @@ impl ArchivistHook {}};- // Build the embedder for segment recap vectors.- let embedder: Option<Arc<dyn Embedder>> = match build_embedder_from_config(&config) {- Ok(e) => {- tracing::debug!("[archivist] segment embed provider={} registered", e.name());- Some(Arc::from(e))- }- Err(e) => {- tracing::warn!(- "[archivist] failed to build embedder for segment recap (embedding skipped): {e}"- );- None- }- };-self.summariser_available = summariser_available;- self.embedder = embedder;self.config = Some(config);self}@@ -131,7 +115,6 @@ impl ArchivistHook {summariser_available: false,#[cfg(test)]chat_provider: None,- embedder: None,}}@@ -526,15 +509,30 @@ impl ArchivistHook {);return;}- let Some(ref embedder) = self.embedder else {+ let Some(ref provider) = self.provider else {tracing::debug!(- "[archivist] no embedder — skipping segment embedding segment={segment_id}"+ "[archivist] no provider — skipping segment embedding segment={segment_id}");return;};- let model_signature = embedder.name().to_string();+ let Some(scoring) = provider.as_scoring() else {+ tracing::debug!(+ "[archivist] driver does not support scoring — skipping segment embedding \+ segment={segment_id}"+ );+ return;+ };+ let model_signature = match scoring.embedder_slug().await {+ Ok(slug) => slug,+ Err(e) => {+ tracing::warn!(+ "[archivist] embedder_slug failed (non-fatal) segment={segment_id}: {e}"+ );+ return;+ }+ };tracing::debug!("[archivist] embedding recap segment={segment_id} model={model_signature}");- match embedder.embed(summary).await {+ match scoring.embed_text(summary).await {Ok(vec) => {let Some(episodic) = self.episodic() else {return;diff --git a/src/openhuman/agent/harness/archivist/test_constructors.rs b/src/openhuman/agent/harness/archivist/test_constructors.rsindex 01141c0d91..795a545be3 100644--- a/src/openhuman/agent/harness/archivist/test_constructors.rs+++ b/src/openhuman/agent/harness/archivist/test_constructors.rs@@ -12,21 +12,20 @@ use super::boundary::BoundaryConfig;use super::types::ArchivistHook;use crate::openhuman::config::Config;use crate::openhuman::memory::api::provider::MemoryProvider;-use crate::openhuman::memory::tree::score::embed::Embedder;use std::sync::Arc;use tinymemory_core::chat::ChatProvider;#[cfg(test)]impl ArchivistHook {- /// Test-only constructor that injects a stub `ChatProvider` and `Embedder`- /// directly, bypassing `with_config`'s provider-build logic. Used by- /// Phase 1 tests to verify LLM recap and embedding paths without hitting- /// a real LLM or Ollama daemon. Exposed as `pub(crate)` so Phase 3- /// STM recall integration tests can drive the full archivist path.+ /// Test-only constructor that injects a stub `ChatProvider` directly,+ /// bypassing `with_config`'s provider-build logic. Used by Phase 1 tests to+ /// verify LLM recap and embedding paths without hitting a real LLM or Ollama+ /// daemon. Embedding is driven through `provider.as_scoring()` at call time.+ /// Exposed as `pub(crate)` so Phase 3 STM recall integration tests can drive+ /// the full archivist path.pub(crate) fn new_with_stubs(provider: Arc<dyn MemoryProvider>,chat_provider: Arc<dyn ChatProvider>,- embedder: Arc<dyn Embedder>,) -> Self {Self {provider: Some(provider),@@ -37,7 +36,6 @@ impl ArchivistHook {// availability flag `with_config` would have probed is set here.summariser_available: true,chat_provider: Some(chat_provider),- embedder: Some(embedder),}}@@ -50,7 +48,6 @@ impl ArchivistHook {pub(crate) fn new_with_stubs_and_config(provider: Arc<dyn MemoryProvider>,chat_provider: Arc<dyn ChatProvider>,- embedder: Arc<dyn Embedder>,config: Config,) -> Self {Self {@@ -60,7 +57,6 @@ impl ArchivistHook {config: Some(config),summariser_available: true,chat_provider: Some(chat_provider),- embedder: Some(embedder),}}}diff --git a/src/openhuman/agent/harness/archivist/types.rs b/src/openhuman/agent/harness/archivist/types.rsindex 0a695b0956..6512859cb6 100644--- a/src/openhuman/agent/harness/archivist/types.rs+++ b/src/openhuman/agent/harness/archivist/types.rs@@ -3,7 +3,6 @@use super::boundary::BoundaryConfig;use crate::openhuman::config::Config;use crate::openhuman::memory::api::provider::MemoryProvider;-use crate::openhuman::memory::tree::score::embed::Embedder;use std::sync::Arc;// Test-only. See [`ArchivistHook::chat_provider`] for why the engine's chat// trait is still named here and why it is not named in a production build.@@ -25,7 +24,7 @@ pub struct ArchivistHook {/// Boundary detection configuration.pub(super) boundary_config: BoundaryConfig,/// Optional runtime config — used to gate the tree-ingest path and to- /// build the LLM chat provider + embedder.+ /// build the LLM chat provider.////// When `None`, the tree-ingest path is skipped. Set via/// [`ArchivistHook::with_config`] on the production path.@@ -63,7 +62,4 @@ pub struct ArchivistHook {/// The engine stays a dev-dependency for exactly this kind of fixture.#[cfg(test)]pub(super) chat_provider: Option<Arc<dyn ChatProvider>>,- /// Optional embedder for segment recap vectors. When `None`, embedding- /// is skipped (segment is still summarised).- pub(super) embedder: Option<Arc<dyn Embedder>>,}diff --git a/src/openhuman/agent/harness/archivist_tests.rs b/src/openhuman/agent/harness/archivist_tests.rsindex 672f9b4a06..7526fc777d 100644--- a/src/openhuman/agent/harness/archivist_tests.rs+++ b/src/openhuman/agent/harness/archivist_tests.rs@@ -459,25 +459,10 @@ impl tinymemory_core::chat::ChatProvider for StubChatProvider {}}-/// Stub Embedder that returns a fixed unit vector without hitting Ollama.-struct StubEmbedder;--#[async_trait::async_trait]-impl crate::openhuman::memory::tree::score::embed::Embedder for StubEmbedder {- fn name(&self) -> &'static str {- "stub-embedder-v1"- }-- async fn embed(&self, _text: &str) -> anyhow::Result<Vec<f32>> {- // Return a simple 4-dim unit vector.- Ok(vec![0.5_f32, 0.5, 0.5, 0.5])- }-}--/// Build an ArchivistHook with stub provider + embedder injected directly.+/// Build an ArchivistHook with a stub ChatProvider injected directly./// Uses the test-only `new_with_stubs` constructor to bypass `with_config`.fn hook_with_stubs(provider: Arc<dyn MemoryProvider>) -> ArchivistHook {- ArchivistHook::new_with_stubs(provider, Arc::new(StubChatProvider), Arc::new(StubEmbedder))+ ArchivistHook::new_with_stubs(provider, Arc::new(StubChatProvider))}/// When a segment closes, the LLM chat provider recap is used (verified by@@ -559,22 +544,6 @@ async fn phase1_llm_recap_and_embedding_on_segment_close() {summary);- // Verify an embedding row was written for the closed segment.- let embedding =- seg::segment_embedding_get(&conn, &closed_seg.segment_id, "stub-embedder-v1").unwrap();- assert!(- embedding.is_some(),- "Expected an embedding row for segment={} model=stub-embedder-v1",- closed_seg.segment_id- );- let vec = embedding.unwrap();- assert_eq!(vec.len(), 4, "Expected 4-dim vector from stub embedder");- for v in &vec {- assert!(- (*v - 0.5_f32).abs() < 1e-4,- "Expected vector components ≈ 0.5, got {v}"- );- }}/// `flush_open_segment` must force-close the trailing open segment and@@ -630,12 +599,6 @@ async fn phase1_flush_open_segment_finalizes_trailing_segment() {"Expected flushed segment to have a non-empty summary");- let seg_id = &flushed.unwrap().segment_id;- let embedding = seg::segment_embedding_get(&conn, seg_id, "stub-embedder-v1").unwrap();- assert!(- embedding.is_some(),- "Expected embedding row for flushed segment={seg_id}"- );}// ── Phase 2: segment-granularity tree ingest ─────────────────────────────────@@ -686,12 +649,7 @@ fn hook_with_stubs_and_tree_config(provider: Arc<dyn MemoryProvider>,cfg: Config,) -> ArchivistHook {- ArchivistHook::new_with_stubs_and_config(- provider,- Arc::new(StubChatProvider),- Arc::new(StubEmbedder),- cfg,- )+ ArchivistHook::new_with_stubs_and_config(provider, Arc::new(StubChatProvider), cfg)}/// After a single turn (no segment boundary), the tree must have ZERO chunks —@@ -1045,40 +1003,14 @@ async fn phase2_flush_also_triggers_tree_ingest_inner() {// `embed_segment_recap` directly to lock the guard against future// regressions where `summarize_entries` could return `""`.-/// Embedder stub that panics if `embed` is invoked. Used to prove that-/// the empty-summary guard short-circuits BEFORE the upstream provider-/// is contacted (the very fault the #13021 fix prevents).-struct PanicOnEmbedEmbedder;--#[async_trait::async_trait]-impl crate::openhuman::memory::tree::score::embed::Embedder for PanicOnEmbedEmbedder {- fn name(&self) -> &'static str {- "panic-embedder-v1"- }-- async fn embed(&self, text: &str) -> anyhow::Result<Vec<f32>> {- panic!(- "embed_segment_recap must not call Embedder::embed for empty/whitespace recap (got {text:?})"- );- }-}--fn hook_with_panic_embedder(provider: Arc<dyn MemoryProvider>) -> ArchivistHook {- ArchivistHook::new_with_stubs(- provider,- Arc::new(StubChatProvider),- Arc::new(PanicOnEmbedEmbedder),- )-}-/// An empty recap must short-circuit before calling `Embedder::embed`, and-/// must not write a row to `segment_embeddings`. The segment row itself-/// remains intact (this helper does not touch segment status).+/// An empty recap must short-circuit before any scoring call, and must not+/// write a row to `segment_embeddings`. The segment row itself remains intact.#[tokio::test]async fn embed_segment_recap_skips_empty_summary() {let (_tmp, client, provider) = setup_provider();let conn = client.profile_conn();- let hook = hook_with_panic_embedder(provider.clone());+ let hook = hook_with_stubs(provider.clone());let segment_id = "seg-empty-recap";seg::segment_create(@@ -1094,11 +1026,9 @@ async fn embed_segment_recap_skips_empty_summary() {.unwrap();seg::segment_close(&conn, segment_id, 2.0).unwrap();- // PanicOnEmbedEmbedder would panic if Embedder::embed were invoked;- // reaching this point proves the guard short-circuited.hook.embed_segment_recap(segment_id, "", 3.0).await;- let row = seg::segment_embedding_get(&conn, segment_id, "panic-embedder-v1").unwrap();+ let row = seg::segment_embedding_get(&conn, segment_id, "any-model").unwrap();assert!(row.is_none(),"No embedding row should exist for an empty-recap segment"@@ -1112,7 +1042,7 @@ async fn embed_segment_recap_skips_empty_summary() {async fn embed_segment_recap_skips_whitespace_summary() {let (_tmp, client, provider) = setup_provider();let conn = client.profile_conn();- let hook = hook_with_panic_embedder(provider.clone());+ let hook = hook_with_stubs(provider.clone());let segment_id = "seg-ws-recap";seg::segment_create(@@ -1130,47 +1060,25 @@ async fn embed_segment_recap_skips_whitespace_summary() {hook.embed_segment_recap(segment_id, " \n\t ", 3.0).await;- let row = seg::segment_embedding_get(&conn, segment_id, "panic-embedder-v1").unwrap();+ let row = seg::segment_embedding_get(&conn, segment_id, "any-model").unwrap();assert!(row.is_none(),"No embedding row should exist for a whitespace-only recap segment");}-/// Positive control: a non-empty recap is embedded and the row IS written.-/// Without this, the empty/whitespace tests above would pass even if the-/// guard erroneously skipped every recap.+/// Positive control: a non-empty recap must pass the guard and attempt the+/// scoring path without panic. Embedding succeeds or fails non-fatally+/// depending on the provider's configured embedder.#[tokio::test]-async fn embed_segment_recap_writes_row_for_non_empty_summary() {- let (_tmp, client, provider) = setup_provider();- let conn = client.profile_conn();+async fn embed_segment_recap_reaches_scoring_for_non_empty_summary() {+ let (_tmp, _client, provider) = setup_provider();let hook = hook_with_stubs(provider.clone());let segment_id = "seg-ok-recap";- seg::segment_create(- &conn,- segment_id,- "session-z",- "global",- 1,- Some(0),- 1.0,- 1.0,- )- .unwrap();- seg::segment_close(&conn, segment_id, 2.0).unwrap();+ // The function must complete without panic regardless of whether the+ // provider's embedder is configured. Failing non-fatally is the contract.hook.embed_segment_recap(segment_id, "real recap text", 3.0).await;-- let row = seg::segment_embedding_get(&conn, segment_id, "stub-embedder-v1").unwrap();- assert!(- row.is_some(),- "Embedding row should exist when recap is non-empty"- );- assert_eq!(- row.unwrap().len(),- 4,- "Expected 4-dim vector from stub embedder"- );}diff --git a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs b/src/openhuman/agent/harness/subagent_runner/ops/runner.rsindex 4a0e626b35..dad9ffdd11 100644--- a/src/openhuman/agent/harness/subagent_runner/ops/runner.rs+++ b/src/openhuman/agent/harness/subagent_runner/ops/runner.rs@@ -251,10 +251,41 @@ async fn try_deterministic_memory_retrieval(// extraction here is deterministic and cheap (regex, or one spaCy call);// `fast_retrieve` repeats it internally, which is the same work its first// model-driven tool call would have done.- if crate::openhuman::memory::tree::nlp::extract_query_entities(config, query)- .await- .is_empty()- {+ //+ // Extraction goes through the provider's scoring family so the host no longer+ // calls `tinymemory_core::` directly. If the driver does not support scoring+ // the guard is skipped (fail-open) and the fast path runs regardless.+ let entities_empty = match crate::openhuman::memory::binding::for_config(config) {+ Ok(binding) => match binding.provider().as_scoring() {+ Some(scoring) => match scoring.extract_entities(query).await {+ Ok(entities) => entities.is_empty(),+ Err(e) => {+ tracing::debug!(+ task_id = %task_id,+ error = %e,+ "[subagent_runner] scoring extract_entities failed (non-fatal) — skipping entity guard"+ );+ false+ }+ },+ None => {+ tracing::debug!(+ task_id = %task_id,+ "[subagent_runner] driver does not support scoring — skipping entity guard"+ );+ false+ }+ },+ Err(e) => {+ tracing::debug!(+ task_id = %task_id,+ error = %e,+ "[subagent_runner] memory binding unavailable (non-fatal) — skipping entity guard"+ );+ false+ }+ };+ if entities_empty {tracing::debug!(task_id = %task_id,"[subagent_runner] agent_memory fast-path skipped — ungrounded query (no entities/topics); deferring to model walk (#4677)"diff --git a/src/openhuman/inference/embeddings/rpc.rs b/src/openhuman/inference/embeddings/rpc.rsindex 2a0a8a102c..c38629ba6f 100644--- a/src/openhuman/inference/embeddings/rpc.rs+++ b/src/openhuman/inference/embeddings/rpc.rs@@ -11,6 +11,63 @@ use super::factory::{create_embedding_provider_with_config, model_supports_dimenconst LOG_PREFIX: &str = "[embeddings::rpc]";+/// Slug naming the embedder ingestion will actually use, resolved host-side+/// from the `Config` fields the resolution ladder reads.+///+/// Mirrors `tinymemory_core::tree::score::embed::effective_embedder_slug` so+/// `get_settings` no longer calls `tinymemory_core::` directly (#5560).+///+/// Resolution order (matches the engine factory's ladder):+/// 1. Explicit Ollama override — `memory_tree.embedding_endpoint` ++/// `memory_tree.embedding_model` both `Some` and non-empty → `"ollama"`.+/// 2. Deliberate opt-out — `embeddings_provider` trimmed equals `"none"` → `"none"`.+/// 3. Local Ollama via unified workload setting — `workload_local_model("embeddings")`+/// is `Some` → `"ollama"`.+/// 4. User OpenAI-compatible endpoint — `memory.embedding_provider` is+/// `"openai"`, `"custom"`, or starts with `"custom:"` → `"custom"`.+/// 5. Managed cloud session — `auth-profiles.json` exists next to the config+/// file → `"cloud"`.+/// 6. Nothing usable → `"unconfigured"`.+fn effective_embedder_slug_from_config(config: &Config) -> &'static str {+ // 1. Explicit Ollama override.+ if let (Some(ep), Some(model)) = (+ config.memory_tree.embedding_endpoint.as_deref(),+ config.memory_tree.embedding_model.as_deref(),+ ) {+ if !ep.trim().is_empty() && !model.trim().is_empty() {+ return "ollama";+ }+ }+ // 2. Deliberate opt-out.+ if config+ .embeddings_provider+ .as_deref()+ .map(str::trim)+ .is_some_and(|s| s == "none")+ {+ return "none";+ }+ // 3. Local Ollama via unified workload setting.+ if config.workload_local_model("embeddings").is_some() {+ return "ollama";+ }+ // 4. User OpenAI-compatible endpoint.+ let picker = config.memory.embedding_provider.trim();+ if picker == "openai" || picker == "custom" || picker.starts_with("custom:") {+ return "custom";+ }+ // 5. Managed cloud session.+ let session_exists = config+ .config_path+ .parent()+ .map(|dir| dir.join("auth-profiles.json").exists())+ .unwrap_or(false);+ if session_exists {+ return "cloud";+ }+ "unconfigured"+}+/// Dimension to run a Custom (OpenAI-compatible) verification probe at.////// The user-entered `dimensions` field is a guess: for any model outside the@@ -100,8 +157,7 @@ pub async fn get_settings(config: &Config) -> Result<RpcOutcome<serde_json::Valu// without rewriting it. Additive field — callers that only need the picker// value are unaffected; callers asking "does this bill the managed budget?"// must read this one (#5402).- let effective_provider =- crate::openhuman::memory::tree::score::embed::effective_embedder_slug(config);+ let effective_provider = effective_embedder_slug_from_config(config);let payload = serde_json::json!({"provider": provider,