Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-core/src/agent/session_host/runtime_session.rs,crates/openhuma

Steven Enamakelafbba634e53c
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index e2cc510179..e1b7de0eba 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1152,7 +1152,8 @@ impl OpenHumanSessionHost {
.unwrap_or_else(|poisoned| poisoned.into_inner())
.active_turn_overrides,
);
- let current_input = view.history.last().filter(|last| **last == request.input);
+ let current_input =
+ view.history.last().filter(|last| **last == request.input);
let (enriched, memory_turn) = futures::join!(
prelude.enrich_request(
&original_user_message,
diff --git a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
index 44aa9c6fb1..828a7e9fdc 100644
--- a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer.rs
@@ -17,7 +17,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use tinyagents_harness::error::Result;
-use tinyagents_harness::summarization::{SummaryRecord, SummaryRequest, Summarizer};
+use tinyagents_harness::summarization::{Summarizer, SummaryRecord, SummaryRequest};
use tinyinference_llm::message::{ContentBlock, Message};
use tinymemory_api::{Role, Turn};
@@ -59,7 +59,10 @@ impl MemoryRecallSummarizer {
let (record, pack) = futures::join!(summary, recall);
let mut record = record?;
if let Some(pack) = pack {
- append(&mut record.summary, &format!("\n\n{RECALLED_HEADING}\n\n{}", pack.markdown.trim()));
+ append(
+ &mut record.summary,
+ &format!("\n\n{RECALLED_HEADING}\n\n{}", pack.markdown.trim()),
+ );
tracing::debug!(
thread_id = %self.turn.thread_id,
tokens = pack.tokens,
diff --git a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer_tests.rs b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer_tests.rs
index 0ed39563fa..62a8c5a397 100644
--- a/crates/openhuman-core/src/agent/tinyagents/memory_summarizer_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/memory_summarizer_tests.rs
@@ -99,7 +99,13 @@ async fn without_recall_the_summarizer_is_unchanged_and_its_failure_is_its_own()
let mut quiet = (*turn).clone();
quiet.identity.recall = false;
let off = MemoryRecallSummarizer::wrap(Box::new(ConcatSummarizer), Some(Arc::new(quiet)));
- assert!(!off.summarize(&dropped()).await.unwrap().summary.text().contains(RECALLED_HEADING));
+ assert!(!off
+ .summarize(&dropped())
+ .await
+ .unwrap()
+ .summary
+ .text()
+ .contains(RECALLED_HEADING));
let failing = MemoryRecallSummarizer::wrap(Box::new(Failing), Some(turn));
assert!(failing.summarize(&dropped()).await.is_err());
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
index ed3a1a30d0..98bd7443c6 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/memory_pack_tests.rs
@@ -33,7 +33,10 @@ fn pack() -> TurnPack {
#[tokio::test]
async fn the_pack_rides_every_request_of_the_turn() {
let mut ctx = context(Some(pack()));
- let history = vec![Message::system("You are helpful."), Message::user("How far is it?")];
+ let history = vec![
+ Message::system("You are helpful."),
+ Message::user("How far is it?"),
+ ];
for _ in 0..2 {
let mut request = ModelRequest::new(history.clone());
@@ -45,7 +48,11 @@ async fn the_pack_rides_every_request_of_the_turn() {
let tail = request.messages.last().unwrap().text();
assert!(tail.starts_with(OPEN_TAG), "{tail}");
assert!(tail.contains("metric units"));
- assert_eq!(&request.messages[..2], &history[..], "the transcript is untouched");
+ assert_eq!(
+ &request.messages[..2],
+ &history[..],
+ "the transcript is untouched"
+ );
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rs
index 1ae706040c..8492283f3d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs
@@ -26,10 +26,10 @@ mod embeddings;
mod harness_assembly;
mod harness_context_ladder;
pub(crate) mod harness_tool_registration;
-mod memory_summarizer;
pub mod host;
pub(crate) mod hosted_error;
pub(crate) mod journal;
+mod memory_summarizer;
pub(crate) mod middleware;
pub(crate) mod model;
pub(crate) mod observability;
diff --git a/crates/openhuman-core/src/config/schema/memory_tests.rs b/crates/openhuman-core/src/config/schema/memory_tests.rs
index a397ed8f47..4aa5d4d76f 100644
--- a/crates/openhuman-core/src/config/schema/memory_tests.rs
+++ b/crates/openhuman-core/src/config/schema/memory_tests.rs
@@ -10,7 +10,10 @@ fn defaults_select_tinyhumans_with_logging_and_recall_on() {
assert!(config.conversations.enabled);
assert!(config.recall.enabled);
assert_eq!(config.recall.budget_tokens, DEFAULT_RECALL_BUDGET_TOKENS);
- assert_eq!(config.recall.pre_turn_timeout_ms, DEFAULT_PRE_TURN_TIMEOUT_MS);
+ assert_eq!(
+ config.recall.pre_turn_timeout_ms,
+ DEFAULT_PRE_TURN_TIMEOUT_MS
+ );
assert_eq!(config.recall.build_delay_secs, DEFAULT_BUILD_DELAY_SECS);
assert_eq!(config.agent_id, None);
assert_eq!(config.root, None);
@@ -58,7 +61,10 @@ schedule_mins = 15
assert_eq!(config.recall.budget_tokens, 500);
assert_eq!(config.recall.team_limit, 0);
assert!(config.recall.enabled, "unset fields keep their default");
- assert_eq!(config.agents["researcher"].agent_id.as_deref(), Some("desk"));
+ assert_eq!(
+ config.agents["researcher"].agent_id.as_deref(),
+ Some("desk")
+ );
assert_eq!(config.agents["researcher"].recall, Some(false));
assert_eq!(config.sources.len(), 1);
assert_eq!(config.sources[0].kind, MemorySourceKind::Folder);
diff --git a/crates/openhuman-core/src/cron/system_jobs_tests.rs b/crates/openhuman-core/src/cron/system_jobs_tests.rs
index 05c60db6bf..3d969f6919 100644
--- a/crates/openhuman-core/src/cron/system_jobs_tests.rs
+++ b/crates/openhuman-core/src/cron/system_jobs_tests.rs
@@ -112,7 +112,10 @@ fn ensure_memory_jobs_seeds_both_jobs_and_retires_the_context_refresh() {
let sync = system_rows(&config, SOURCES_SYNC_JOB);
assert_eq!(background.len(), 1);
assert_eq!(sync.len(), 1);
- assert_eq!(background[0].schedule, every(BACKGROUND_INTERVAL_MINS as u32));
+ assert_eq!(
+ background[0].schedule,
+ every(BACKGROUND_INTERVAL_MINS as u32)
+ );
assert_eq!(sync[0].schedule, every(SOURCES_SYNC_INTERVAL_MINS));
assert!(
system_rows(&config, RETIRED_CONTEXT_REFRESH_JOB).is_empty(),
diff --git a/crates/openhuman-core/src/flows/memory_tools.rs b/crates/openhuman-core/src/flows/memory_tools.rs
index eddbace4d0..382a57001a 100644
--- a/crates/openhuman-core/src/flows/memory_tools.rs
+++ b/crates/openhuman-core/src/flows/memory_tools.rs
@@ -26,7 +26,9 @@ use std::sync::Arc;
use async_trait::async_trait;
use serde_json::json;
-use tinymemory_api::{Citation, ForgetTarget, LearningKind, MemoryMeta, MetaFilter, SourceKind, SourceRef};
+use tinymemory_api::{
+ Citation, ForgetTarget, LearningKind, MemoryMeta, MetaFilter, SourceKind, SourceRef,
+};
use tinytools::{PermissionLevel, Tool, ToolResult};
use crate::agent::turn_origin::{self, AgentTurnOrigin, TrustedAutomationSource};
diff --git a/crates/openhuman-core/src/memory/backfill.rs b/crates/openhuman-core/src/memory/backfill.rs
index 569be8c96e..851dd78b3e 100644
--- a/crates/openhuman-core/src/memory/backfill.rs
+++ b/crates/openhuman-core/src/memory/backfill.rs
@@ -213,32 +213,35 @@ pub fn turn_items(
return Vec::new();
};
let base = u32::try_from(index.saturating_mul(2)).unwrap_or(u32::MAX - 1);
- [(Role::User, &turn.user, base), (Role::Assistant, &turn.assistant, base + 1)]
- .into_iter()
- .filter(|(_, text, _)| !text.trim().is_empty())
- .map(|(role, text, at_index)| StoreItem::Conversation {
- meta: MemoryMeta {
- namespace: node.clone(),
- thread_id: Some(thread_id.to_string()),
- turns: Some(TurnRange {
- first: at_index,
- last: at_index,
- }),
- agent_id: Some(identity.agent_id.clone()),
- source: SourceRef {
- kind: SourceKind::Conversation,
- id: Some(thread_id.to_string()),
- },
- observed_at: Some(turn.at),
- tags: vec![BACKFILL_TAG.to_string()],
- ..MemoryMeta::default()
+ [
+ (Role::User, &turn.user, base),
+ (Role::Assistant, &turn.assistant, base + 1),
+ ]
+ .into_iter()
+ .filter(|(_, text, _)| !text.trim().is_empty())
+ .map(|(role, text, at_index)| StoreItem::Conversation {
+ meta: MemoryMeta {
+ namespace: node.clone(),
+ thread_id: Some(thread_id.to_string()),
+ turns: Some(TurnRange {
+ first: at_index,
+ last: at_index,
+ }),
+ agent_id: Some(identity.agent_id.clone()),
+ source: SourceRef {
+ kind: SourceKind::Conversation,
+ id: Some(thread_id.to_string()),
},
- turns: vec![Turn {
- at: Some(turn.at),
- ..Turn::new(role, text.as_str())
- }],
- })
- .collect()
+ observed_at: Some(turn.at),
+ tags: vec![BACKFILL_TAG.to_string()],
+ ..MemoryMeta::default()
+ },
+ turns: vec![Turn {
+ at: Some(turn.at),
+ ..Turn::new(role, text.as_str())
+ }],
+ })
+ .collect()
}
/// The first turn of `thread_id` the lifecycle logged (not a backfill), as a
@@ -424,8 +427,10 @@ async fn run(
}
}
let end = group.last().map_or(0, |last| last + 1);
- file.stored
- .insert(plan.thread_id.clone(), u32::try_from(end).unwrap_or(u32::MAX));
+ file.stored.insert(
+ plan.thread_id.clone(),
+ u32::try_from(end).unwrap_or(u32::MAX),
+ );
file.state.turns_stored += group.len() as u64;
file.state.items_stored += count;
write_file(workspace_dir, &file);
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rs
index 21047b1f68..563113e10a 100644
--- a/crates/openhuman-core/src/memory/brain.rs
+++ b/crates/openhuman-core/src/memory/brain.rs
@@ -11,9 +11,7 @@
//! the identity in scope (the default root outside an agent).
use serde::{Deserialize, Serialize};
-use tinymemory_api::{
- ExploreRequest, Facet, Hit, Namespace, StoreItem, WriteOptions,
-};
+use tinymemory_api::{ExploreRequest, Facet, Hit, Namespace, StoreItem, WriteOptions};
use tinymemory_integrations::documents::{NativeConverter, RawDocument};
use tinymemory_tools::{Brain, BrainSource, MemoryLayout};
@@ -61,7 +59,11 @@ pub fn brain_source(kind: MemorySourceKind, target: &str, item: &StoreItem) -> B
/// `item` placed in `layout`'s brain under `source`: the source's node, and
/// no agent id (the brain belongs to every agent).
-pub fn file_into(layout: &MemoryLayout, source: &BrainSource, mut item: StoreItem) -> MemoryResult<StoreItem> {
+pub fn file_into(
+ layout: &MemoryLayout,
+ source: &BrainSource,
+ mut item: StoreItem,
+) -> MemoryResult<StoreItem> {
let meta = item.meta_mut();
meta.namespace = layout.brain(source)?;
meta.agent_id = None;
@@ -230,17 +232,14 @@ pub async fn ingest(config: &Config, params: BrainIngestParams) -> MemoryResult<
meta.file_path = Some(path.display().to_string());
tinymemory_integrations::brain::brain_document(&NativeConverter, &raw, source, meta)
.await
- .map_err(|error| MemoryError::invalid(format!("cannot convert the file: {error}")))?
+ .map_err(|error| {
+ MemoryError::invalid(format!("cannot convert the file: {error}"))
+ })?
}
- (None, Some(text)) => tinymemory_tools::BrainDocument::new(
- source.unwrap_or(BrainSource::Markdown),
- text,
- ),
- _ => {
- return Err(MemoryError::invalid(
- "pass exactly one of `path` or `text`",
- ))
+ (None, Some(text)) => {
+ tinymemory_tools::BrainDocument::new(source.unwrap_or(BrainSource::Markdown), text)
}
+ _ => return Err(MemoryError::invalid("pass exactly one of `path` or `text`")),
};
if let Some(title) = params.title.filter(|title| !title.trim().is_empty()) {
document = document.titled(title);
diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rs
index 58234da6e6..2feb4cd42a 100644
--- a/crates/openhuman-core/src/memory/brain_tests.rs
+++ b/crates/openhuman-core/src/memory/brain_tests.rs
@@ -19,21 +19,44 @@ fn document(mime: Option<&str>, path: Option<&str>) -> StoreItem {
#[test]
fn synced_items_are_filed_by_what_they_read() {
let plain = document(None, Some("notes/a.md"));
- assert_eq!(brain_source(MemorySourceKind::Github, "o/r", &plain), BrainSource::Github);
- assert_eq!(brain_source(MemorySourceKind::Link, "https://x", &plain), BrainSource::Web);
- assert_eq!(brain_source(MemorySourceKind::Rss, "https://x/feed", &plain), BrainSource::Web);
- assert_eq!(brain_source(MemorySourceKind::Composio, "Notion", &plain), BrainSource::Notion);
+ assert_eq!(
+ brain_source(MemorySourceKind::Github, "o/r", &plain),
+ BrainSource::Github
+ );
+ assert_eq!(
+ brain_source(MemorySourceKind::Link, "https://x", &plain),
+ BrainSource::Web
+ );
+ assert_eq!(
+ brain_source(MemorySourceKind::Rss, "https://x/feed", &plain),
+ BrainSource::Web
+ );
+ assert_eq!(
+ brain_source(MemorySourceKind::Composio, "Notion", &plain),
+ BrainSource::Notion
+ );
assert_eq!(
brain_source(MemorySourceKind::Composio, "gmail", &plain),
BrainSource::Other("gmail".into())
);
- assert_eq!(brain_source(MemorySourceKind::Folder, "/n", &plain), BrainSource::Markdown);
assert_eq!(
- brain_source(MemorySourceKind::File, "/n", &document(None, Some("deck/Q3.PDF"))),
+ brain_source(MemorySourceKind::Folder, "/n", &plain),
+ BrainSource::Markdown
+ );
+ assert_eq!(
+ brain_source(
+ MemorySourceKind::File,
+ "/n",
+ &document(None, Some("deck/Q3.PDF"))
+ ),
BrainSource::Pdf
);
assert_eq!(
- brain_source(MemorySourceKind::Folder, "/n", &document(Some("text/html"), None)),
+ brain_source(
+ MemorySourceKind::Folder,
+ "/n",
+ &document(Some("text/html"), None)
+ ),
BrainSource::Web
);
}
@@ -110,7 +133,12 @@ async fn text_is_ingested_searched_counted_and_forgotten_per_source() {
.await
.unwrap();
assert_eq!(gone.forgotten, 1);
- assert_eq!(stored(&engine, MetaFilter::kinds([ItemKind::Document])).await.len(), 1);
+ assert_eq!(
+ stored(&engine, MetaFilter::kinds([ItemKind::Document]))
+ .await
+ .len(),
+ 1
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/memory/channels.rs b/crates/openhuman-core/src/memory/channels.rs
index 1eea482ca8..a31dad6231 100644
--- a/crates/openhuman-core/src/memory/channels.rs
+++ b/crates/openhuman-core/src/memory/channels.rs
@@ -55,9 +55,15 @@ pub fn record(workspace_dir: &Path, channel: &str, thread_id: &str) {
if channel.is_empty() || thread_id.trim().is_empty() {
return;
}
- let _guard = LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let _guard = LOCK
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
let mut all = read(workspace_dir);
- if all.entry(channel).or_default().insert(thread_id.to_string()) {
+ if all
+ .entry(channel)
+ .or_default()
+ .insert(thread_id.to_string())
+ {
write(workspace_dir, &all);
}
}
@@ -85,10 +91,16 @@ pub async fn forget_channel(config: &Config, channel: &str) -> MemoryResult<usiz
thread_id: Some(thread_id),
..MetaFilter::kinds([ItemKind::Conversation])
};
- forgotten += bound.engine.forget(ForgetTarget::Filter(filter)).await?.forgotten;
+ forgotten += bound
+ .engine
+ .forget(ForgetTarget::Filter(filter))
+ .await?
+ .forgotten;
}
{
- let _guard = LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let _guard = LOCK
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
let mut all = read(&config.workspace_dir);
if all.remove(&key(channel)).is_some() {
write(&config.workspace_dir, &all);
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index 144a800259..686ade9258 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -22,7 +22,7 @@ use std::sync::{Arc, LazyLock, RwLock};
use async_trait::async_trait;
use sha2::{Digest, Sha256};
-use tinymemory_api::{MemoryEngine};
+use tinymemory_api::MemoryEngine;
use tinymemory_integrations::{BearerSource, EngineCredential, EngineSettings};
use crate::config::schema::MEMORY_CORTEXDB_KEY_NAME;
diff --git a/crates/openhuman-core/src/memory/engine_tests.rs b/crates/openhuman-core/src/memory/engine_tests.rs
index 5c4321c47c..07d09e73db 100644
--- a/crates/openhuman-core/src/memory/engine_tests.rs
+++ b/crates/openhuman-core/src/memory/engine_tests.rs
@@ -87,7 +87,10 @@ fn cortexdb_is_off_until_a_key_is_stored_and_rebuilds_on_a_new_key() {
assert!(has_key(&config, CORTEXDB_ENGINE));
let first = resolve(&config).engine().expect("bound");
assert_eq!(first.id, CORTEXDB_ENGINE);
- assert_eq!(first.endpoint, tinymemory_integrations::cortex::CORTEX_API_ENDPOINT);
+ assert_eq!(
+ first.endpoint,
+ tinymemory_integrations::cortex::CORTEX_API_ENDPOINT
+ );
store_cortexdb_key(&config, "cdb-key-two").unwrap();
let second = resolve(&config).engine().expect("rebound");
diff --git a/crates/openhuman-core/src/memory/guard.rs b/crates/openhuman-core/src/memory/guard.rs
index 85245719a1..935332b805 100644
--- a/crates/openhuman-core/src/memory/guard.rs
+++ b/crates/openhuman-core/src/memory/guard.rs
@@ -35,10 +35,15 @@ impl ScrubbingEngine {
#[must_use]
pub fn scrub(item: StoreItem) -> StoreItem {
let kind = item.kind();
- let scrubbed =
- tinymemory_integrations::safety::scrub_item_with(item, crate::security::scrub::host_policy());
+ let scrubbed = tinymemory_integrations::safety::scrub_item_with(
+ item,
+ crate::security::scrub::host_policy(),
+ );
if scrubbed.report.changed() {
- tracing::debug!(kind = kind.as_str(), "[memory:guard] item scrubbed before store");
+ tracing::debug!(
+ kind = kind.as_str(),
+ "[memory:guard] item scrubbed before store"
+ );
}
scrubbed.value
}
diff --git a/crates/openhuman-core/src/memory/guard_tests.rs b/crates/openhuman-core/src/memory/guard_tests.rs
index c0e36918da..331b41cac3 100644
--- a/crates/openhuman-core/src/memory/guard_tests.rs
+++ b/crates/openhuman-core/src/memory/guard_tests.rs
@@ -24,7 +24,8 @@ async fn texts(engine: &ReferenceEngine) -> Vec<String> {
async fn every_write_path_is_scrubbed() {
let reference = Arc::new(ReferenceEngine::new());
let guarded = ScrubbingEngine::wrap(reference.clone());
- let item = |text: &str| StoreItem::document(format!("{text} key={SECRET}"), MemoryMeta::default());
+ let item =
+ |text: &str| StoreItem::document(format!("{text} key={SECRET}"), MemoryMeta::default());
guarded.store(item("one")).await.unwrap();
guarded
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index 2316163fd5..a6f7b1f5cb 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -15,8 +15,8 @@ use std::path::{Path, PathBuf};
use std::sync::{LazyLock, Mutex};
use serde::{Deserialize, Serialize};
-use tinymemory_integrations::import::{Checkpoint, ImportedItem, LegacyWorkspace};
use tinymemory_api::ItemKind;
+use tinymemory_integrations::import::{Checkpoint, ImportedItem, LegacyWorkspace};
use crate::config::Config;
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks.rs b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
index 80fc9fca2c..7e35324740 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
@@ -295,7 +295,12 @@ pub fn logged_reply(text: &str, calls: &[ToolCallSummary]) -> String {
let lines: Vec<String> = calls
.iter()
.filter_map(|call| {
- let result = call.result.as_deref()?.split_whitespace().collect::<Vec<_>>().join(" ");
+ let result = call
+ .result
+ .as_deref()?
+ .split_whitespace()
+ .collect::<Vec<_>>()
+ .join(" ");
(!result.is_empty()).then(|| {
let result: String = result.chars().take(MAX_TOOL_LINE_CHARS).collect();
format!("- {} → {result}", call.name)
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
index 8802d09a64..6630a6bbb0 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
@@ -1,6 +1,8 @@
use super::*;
-use tinymemory_api::{ItemKind, LearningKind, MemoryEngine, MemoryMeta, MetaFilter, Role, StoreItem};
+use tinymemory_api::{
+ ItemKind, LearningKind, MemoryEngine, MemoryMeta, MetaFilter, Role, StoreItem,
+};
use crate::memory::scope::MemoryIdentity;
use crate::memory::test_fixtures::{bind_reference, config_in, stored};
@@ -111,8 +113,17 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {
config.memory.recall.enabled = false;
let quiet = MemoryIdentity::agent("a").resolve(&config);
- assert!(pre_turn(&config, &quiet, input("t", 0, "when do deploys happen?")).await.is_none());
- assert_eq!(stored(&engine, MetaFilter::kinds([ItemKind::Conversation])).await.len(), 1);
+ assert!(
+ pre_turn(&config, &quiet, input("t", 0, "when do deploys happen?"))
+ .await
+ .is_none()
+ );
+ assert_eq!(
+ stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))
+ .await
+ .len(),
+ 1
+ );
config.memory.recall.enabled = true;
config.memory.conversations.enabled = false;
@@ -120,14 +131,18 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {
let pack = pre_turn(&config, &reader, input("t", 2, "when do deploys happen?")).await;
assert!(pack.expect("a pack").markdown.contains("Fridays"));
assert_eq!(
- stored(&engine, MetaFilter::kinds([ItemKind::Conversation])).await.len(),
+ stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))
+ .await
+ .len(),
1,
"nothing new was logged"
);
config.memory.recall.enabled = false;
let none = MemoryIdentity::agent("a").resolve(&config);
- assert!(pre_turn(&config, &none, input("t", 4, "hi")).await.is_none());
+ assert!(pre_turn(&config, &none, input("t", 4, "hi"))
+ .await
+ .is_none());
}
#[tokio::test]
@@ -135,7 +150,9 @@ async fn pre_turn_without_an_engine_runs_the_turn_without_a_pack() {
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
let identity = MemoryIdentity::agent("a").resolve(&config);
- assert!(pre_turn(&config, &identity, input("t", 0, "hello")).await.is_none());
+ assert!(pre_turn(&config, &identity, input("t", 0, "hello"))
+ .await
+ .is_none());
post_turn(&config, &identity, reply("t", 1, "hi")).await;
}
@@ -160,11 +177,20 @@ async fn post_turn_logs_the_reply_and_queues_belief_builds() {
assert!(turns[0].text.contains("read_file → outline.md"));
assert_eq!(turns[0].meta.agent_id.as_deref(), Some("writer"));
let pending = jobs::snapshot(&config).await.pending;
- assert_eq!(pending.len(), 1, "turn index 1 is the 2nd turn: a build is due");
+ assert_eq!(
+ pending.len(),
+ 1,
+ "turn index 1 is the 2nd turn: a build is due"
+ );
config.memory.conversations.enabled = false;
post_turn(&config, &identity, reply("t", 3, "Again.")).await;
- assert_eq!(stored(&engine, MetaFilter::kinds([ItemKind::Conversation])).await.len(), 1);
+ assert_eq!(
+ stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))
+ .await
+ .len(),
+ 1
+ );
}
#[tokio::test]
@@ -173,7 +199,12 @@ async fn compaction_recalls_from_the_dropped_turns() {
let config = config_in(&tmp);
bind_reference(&config);
let identity = MemoryIdentity::agent("a").resolve(&config);
- let _ = pre_turn(&config, &identity, input("t", 0, "the project codename is Heron")).await;
+ let _ = pre_turn(
+ &config,
+ &identity,
+ input("t", 0, "the project codename is Heron"),
+ )
+ .await;
post_turn(&config, &identity, reply("t", 1, "Noted: Heron.")).await;
let dropped = vec![
@@ -182,5 +213,7 @@ async fn compaction_recalls_from_the_dropped_turns() {
];
let pack = compaction(&config, &identity, "t", dropped).await;
assert!(pack.expect("a pack").markdown.contains("Heron"));
- assert!(compaction(&config, &identity, "t", Vec::new()).await.is_none());
+ assert!(compaction(&config, &identity, "t", Vec::new())
+ .await
+ .is_none());
}
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
index 89e0ae41e9..f37efa2b0c 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
@@ -192,11 +192,14 @@ pub async fn run(config: &Config, selection: Selection) -> MemoryResult<Vec<JobR
let cutoff = Utc::now()
- Duration::seconds(i64::try_from(config.memory.recall.build_delay_secs).unwrap_or(0));
let (take, keep): (Vec<QueuedJob>, Vec<QueuedJob>) =
- queue.pending.drain(..).partition(|queued| match &selection {
- Selection::Due => queued.queued_at <= cutoff,
- Selection::All => true,
- Selection::One(id) => &queued.id == id,
- });
+ queue
+ .pending
+ .drain(..)
+ .partition(|queued| match &selection {
+ Selection::Due => queued.queued_at <= cutoff,
+ Selection::All => true,
+ Selection::One(id) => &queued.id == id,
+ });
if let Selection::One(id) = &selection {
if take.is_empty() {
queue.pending = keep;
@@ -236,7 +239,10 @@ pub async fn run(config: &Config, selection: Selection) -> MemoryResult<Vec<JobR
if let JobOutcome::Skipped { reason } = &report.outcome {
record.reason = Some(reason.clone());
}
- record.built = report.consolidation.as_ref().and_then(|receipt| receipt.built);
+ record.built = report
+ .consolidation
+ .as_ref()
+ .and_then(|receipt| receipt.built);
record.stored = report.stored.len();
for follow_up in report.follow_ups {
let id = job_id(&queued.root, &follow_up);
@@ -292,7 +298,10 @@ pub async fn run_due(config: &Config) {
if let crate::cron::scheduler_gate::Policy::Paused { reason } =
crate::cron::scheduler_gate::current_policy()
{
- tracing::debug!(?reason, "[memory:jobs] background paused; queue left for later");
+ tracing::debug!(
+ ?reason,
+ "[memory:jobs] background paused; queue left for later"
+ );
return;
}
match run(config, Selection::Due).await {
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
index 7371ae7cd5..3292545baa 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
@@ -15,7 +15,12 @@ fn build(agent: &str) -> BackgroundJob {
async fn duplicates_merge_and_the_queue_survives_a_reload() {
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
- enqueue(&config, &Namespace::ROOT, vec![build("a"), build("a"), build("b")]).await;
+ enqueue(
+ &config,
+ &Namespace::ROOT,
+ vec![build("a"), build("a"), build("b")],
+ )
+ .await;
enqueue(&config, &Namespace::ROOT, vec![build("a")]).await;
let team: Namespace = "team:acme".parse().unwrap();
enqueue(&config, &team, vec![build("a")]).await;
@@ -40,7 +45,10 @@ async fn due_jobs_wait_for_the_build_delay() {
config.memory.recall.build_delay_secs = 0;
let runs = run(&config, Selection::Due).await.unwrap();
assert_eq!(runs.len(), 1);
- assert_eq!(runs[0].outcome, "done", "the reference engine consolidates on demand");
+ assert_eq!(
+ runs[0].outcome, "done",
+ "the reference engine consolidates on demand"
+ );
let queue = snapshot(&config).await;
assert!(queue.pending.is_empty());
assert_eq!(queue.history.len(), 1);
@@ -62,7 +70,11 @@ async fn one_job_runs_by_id_and_an_unknown_id_is_refused() {
run(&config, Selection::One("nope".into())).await,
Err(MemoryError::InvalidRequest(_))
));
- assert_eq!(snapshot(&config).await.pending.len(), 1, "a refused run keeps the queue");
+ assert_eq!(
+ snapshot(&config).await.pending.len(),
+ 1,
+ "a refused run keeps the queue"
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/memory/lifecycle/mod.rs b/crates/openhuman-core/src/memory/lifecycle/mod.rs
index 4ab1602104..b2ca9f1d3d 100644
--- a/crates/openhuman-core/src/memory/lifecycle/mod.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/mod.rs
@@ -93,13 +93,12 @@ pub fn named_agent_memory(
if let Some(agent_id) = agent_id.map(str::trim).filter(|id| !id.is_empty()) {
identity.agent_id = agent_id.to_string();
}
- let memory = agent_memory(config, &identity)
- .map_err(|error| match error {
- MemoryError::InvalidRequest(message) => {
- MemoryError::invalid(format!("agent `{}`: {message}", identity.agent_id))
- }
- other => other,
- })?;
+ let memory = agent_memory(config, &identity).map_err(|error| match error {
+ MemoryError::InvalidRequest(message) => {
+ MemoryError::invalid(format!("agent `{}`: {message}", identity.agent_id))
+ }
+ other => other,
+ })?;
Ok((memory, identity))
}
diff --git a/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs b/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
index c1aa6e171f..93d6fbeee5 100644
--- a/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
@@ -7,7 +7,11 @@ use crate::memory::test_fixtures::{bind_reference, config_in};
fn the_policy_mirrors_the_recall_config() {
let mut recall = MemoryRecallConfig::default();
let default = policy(&recall);
- assert_eq!(default, RecallPolicy::default(), "the defaults agree with TinyMemory's");
+ assert_eq!(
+ default,
+ RecallPolicy::default(),
+ "the defaults agree with TinyMemory's"
+ );
recall.build_beliefs_every = 0;
recall.team_limit = 0;
@@ -15,11 +19,19 @@ fn the_policy_mirrors_the_recall_config() {
let tuned = policy(&recall);
assert_eq!(tuned.build_beliefs_every, None);
assert_eq!(tuned.team_limit, 0);
- assert_eq!(tuned.budget_tokens, 1, "a zero budget is clamped, never refused");
+ assert_eq!(
+ tuned.budget_tokens, 1,
+ "a zero budget is clamped, never refused"
+ );
let quiet = log_only(default.clone());
assert_eq!(
- (quiet.learnings_limit, quiet.brain_limit, quiet.history_limit, quiet.team_limit),
+ (
+ quiet.learnings_limit,
+ quiet.brain_limit,
+ quiet.history_limit,
+ quiet.team_limit
+ ),
(0, 0, 0, 0)
);
assert_eq!(quiet.budget_tokens, default.budget_tokens);
diff --git a/crates/openhuman-core/src/memory/lifecycle/views.rs b/crates/openhuman-core/src/memory/lifecycle/views.rs
index 4d66ef8510..48f4747b67 100644
--- a/crates/openhuman-core/src/memory/lifecycle/views.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/views.rs
@@ -100,9 +100,17 @@ pub fn apply_policy_set(config: &mut Config, params: &PolicySetParams) -> Memory
recall.budget_tokens = value;
}
for (name, value, slot) in [
- ("learnings_limit", params.learnings_limit, &mut recall.learnings_limit),
+ (
+ "learnings_limit",
+ params.learnings_limit,
+ &mut recall.learnings_limit,
+ ),
("brain_limit", params.brain_limit, &mut recall.brain_limit),
- ("history_limit", params.history_limit, &mut recall.history_limit),
+ (
+ "history_limit",
+ params.history_limit,
+ &mut recall.history_limit,
+ ),
("team_limit", params.team_limit, &mut recall.team_limit),
] {
if let Some(value) = within(name, value, 0, 50)? {
@@ -112,7 +120,12 @@ pub fn apply_policy_set(config: &mut Config, params: &PolicySetParams) -> Memory
if let Some(value) = within("build_beliefs_every", params.build_beliefs_every, 0, 1000)? {
recall.build_beliefs_every = value;
}
- if let Some(value) = within("pre_turn_timeout_ms", params.pre_turn_timeout_ms, 100, 30_000)? {
+ if let Some(value) = within(
+ "pre_turn_timeout_ms",
+ params.pre_turn_timeout_ms,
+ 100,
+ 30_000,
+ )? {
recall.pre_turn_timeout_ms = value;
}
tracing::info!("[memory:policy] recall policy updated");
@@ -148,7 +161,10 @@ pub struct PackPreviewView {
/// `memory_pack_preview`: the pack a turn (with a query) or a session start
/// (without one) would be given. Reads only; nothing is logged.
-pub async fn pack_preview(config: &Config, params: PackPreviewParams) -> MemoryResult<PackPreviewView> {
+pub async fn pack_preview(
+ config: &Config,
+ params: PackPreviewParams,
+) -> MemoryResult<PackPreviewView> {
let (memory, identity) = super::named_agent_memory(config, params.agent_id.as_deref())?;
let query = params.query.filter(|query| !query.trim().is_empty());
let (mode, pack) = match query {
diff --git a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
index 5c0686c1b3..cb36915927 100644
--- a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
@@ -100,11 +100,19 @@ async fn the_preview_reads_without_logging_and_agents_are_listed() {
assert_eq!(turn.agent_id, "writer");
assert!(turn.pack.markdown.contains("1st"));
- let session = pack_preview(&config, PackPreviewParams::default()).await.unwrap();
+ let session = pack_preview(&config, PackPreviewParams::default())
+ .await
+ .unwrap();
assert_eq!(session.mode, "session");
let agents = agents_list(&config).await.unwrap();
- assert_eq!(agents.agents, [AgentCount { agent_id: "writer".into(), turns: 1 }]);
+ assert_eq!(
+ agents.agents,
+ [AgentCount {
+ agent_id: "writer".into(),
+ turns: 1
+ }]
+ );
}
#[tokio::test]
@@ -113,7 +121,18 @@ async fn jobs_run_needs_an_engine_and_names_an_unknown_job() {
let config = config_in(&tmp);
assert!(jobs_run(&config, JobsRunParams::default()).await.is_err());
bind_reference(&config);
- assert!(jobs_run(&config, JobsRunParams::default()).await.unwrap().runs.is_empty());
- assert!(jobs_run(&config, JobsRunParams { id: Some("x".into()) }).await.is_err());
+ assert!(jobs_run(&config, JobsRunParams::default())
+ .await
+ .unwrap()
+ .runs
+ .is_empty());
+ assert!(jobs_run(
+ &config,
+ JobsRunParams {
+ id: Some("x".into())
+ }
+ )
+ .await
+ .is_err());
assert!(jobs_list(&config).await.pending.is_empty());
}
diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rs
index 7912993f25..dc0fa88649 100644
--- a/crates/openhuman-core/src/memory/ops.rs
+++ b/crates/openhuman-core/src/memory/ops.rs
@@ -7,7 +7,10 @@
//! scrubbed of secrets and PII by the bound engine itself ([`super::guard`]).
use chrono::Utc;
-use tinymemory_api::{FetchRequest, ForgetTarget, ItemId, LearningKind, ListRequest, MemoryMeta, RecallRequest, StoreItem, StoreReceipt};
+use tinymemory_api::{
+ FetchRequest, ForgetTarget, ItemId, LearningKind, ListRequest, MemoryMeta, RecallRequest,
+ StoreItem, StoreReceipt,
+};
use crate::config::Config;
diff --git a/crates/openhuman-core/src/memory/schemas_tests.rs b/crates/openhuman-core/src/memory/schemas_tests.rs
index 1e336f5489..7ebd3b282f 100644
--- a/crates/openhuman-core/src/memory/schemas_tests.rs
+++ b/crates/openhuman-core/src/memory/schemas_tests.rs
@@ -104,7 +104,10 @@ fn required_inputs_match_the_spec() {
assert_eq!(required("import_start"), ["consent"]);
assert_eq!(optional("pack_preview"), ["query", "thread_id", "agent_id"]);
assert_eq!(required("brain_search"), ["query"]);
- assert_eq!(optional("brain_ingest"), ["path", "text", "source", "title"]);
+ assert_eq!(
+ optional("brain_ingest"),
+ ["path", "text", "source", "title"]
+ );
assert_eq!(required("brain_forget"), ["source"]);
assert_eq!(optional("jobs_run"), ["id"]);
assert!(required("policy_set").is_empty());
@@ -274,15 +277,25 @@ async fn lifecycle_handlers_answer_over_a_bound_engine() {
let sources = sources.get("result").unwrap_or(&sources);
assert_eq!(sources["sources"][0]["source"], "notion");
- let preview = call(&config, "pack_preview", json!({"query": "when are standups?"}))
- .await
- .unwrap();
+ let preview = call(
+ &config,
+ "pack_preview",
+ json!({"query": "when are standups?"}),
+ )
+ .await
+ .unwrap();
let preview = preview.get("result").unwrap_or(&preview);
assert_eq!(preview["mode"], "turn");
- assert!(preview["pack"]["markdown"].as_str().unwrap().contains("9:30"));
+ assert!(preview["pack"]["markdown"]
+ .as_str()
+ .unwrap()
+ .contains("9:30"));
let ran = call(&config, "jobs_run", json!({})).await.unwrap();
- assert_eq!(ran.get("result").unwrap_or(&ran)["runs"][0]["outcome"], "done");
+ assert_eq!(
+ ran.get("result").unwrap_or(&ran)["runs"][0]["outcome"],
+ "done"
+ );
let agents = call(&config, "agents_list", json!({})).await.unwrap();
assert!(agents.get("result").unwrap_or(&agents)["agents"].is_array());
diff --git a/crates/openhuman-core/src/memory/scope.rs b/crates/openhuman-core/src/memory/scope.rs
index 89b3d805ba..81f03a751c 100644
--- a/crates/openhuman-core/src/memory/scope.rs
+++ b/crates/openhuman-core/src/memory/scope.rs
@@ -156,8 +156,13 @@ fn team_root(team: &str) -> Namespace {
///
/// Why it is not one.
pub fn validate_root(root: &str) -> Result<(), String> {
- let root: Namespace = root.trim().parse().map_err(|error: tinymemory_api::Error| error.to_string())?;
- MemoryLayout::new(root).map(|_| ()).map_err(|error| error.to_string())
+ let root: Namespace = root
+ .trim()
+ .parse()
+ .map_err(|error: tinymemory_api::Error| error.to_string())?;
+ MemoryLayout::new(root)
+ .map(|_| ())
+ .map_err(|error| error.to_string())
}
/// A configured root; an invalid one is logged and ignored.
diff --git a/crates/openhuman-core/src/memory/scope_tests.rs b/crates/openhuman-core/src/memory/scope_tests.rs
index 27bd47e720..f1a45da6e4 100644
--- a/crates/openhuman-core/src/memory/scope_tests.rs
+++ b/crates/openhuman-core/src/memory/scope_tests.rs
@@ -16,7 +16,10 @@ fn by_default_an_agent_is_its_definition_under_the_default_root() {
let nobody = MemoryIdentity::root().resolve(&config);
assert_eq!(nobody.agent_id, DEFAULT_AGENT_ID);
- assert_eq!(MemoryIdentity::agent(" ").resolve(&config).agent_id, DEFAULT_AGENT_ID);
+ assert_eq!(
+ MemoryIdentity::agent(" ").resolve(&config).agent_id,
+ DEFAULT_AGENT_ID
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/memory/sources/composio.rs b/crates/openhuman-core/src/memory/sources/composio.rs
index 5a0651a450..caa8c05b94 100644
--- a/crates/openhuman-core/src/memory/sources/composio.rs
+++ b/crates/openhuman-core/src/memory/sources/composio.rs
@@ -86,7 +86,11 @@ pub async fn store_records(
config,
bound,
items,
- (crate::config::schema::MemorySourceKind::Composio, toolkit, source_id),
+ (
+ crate::config::schema::MemorySourceKind::Composio,
+ toolkit,
+ source_id,
+ ),
layout,
)
.await
diff --git a/crates/openhuman-core/src/memory/sources/composio_tests.rs b/crates/openhuman-core/src/memory/sources/composio_tests.rs
index ea1b23f4b8..94b630e8e2 100644
--- a/crates/openhuman-core/src/memory/sources/composio_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/composio_tests.rs
@@ -1,8 +1,8 @@
use super::*;
-use tinymemory_tools::MemoryLayout;
use crate::config::schema::MemorySourceKind;
use crate::memory::test_fixtures::{bind_reference, config_in, stored};
use tinymemory_api::{ItemKind, MetaFilter};
+use tinymemory_tools::MemoryLayout;
fn record(id: &str, title: &str, content: &str) -> ConnectorRecord {
ConnectorRecord {
@@ -104,10 +104,17 @@ async fn store_records_stores_the_non_empty_ones() {
.iter()
.all(|d| d.meta.source.kind == SourceKind::Composio));
assert!(
- docs.iter().all(|d| d.meta.namespace.to_string() == "source:notion"),
+ docs.iter()
+ .all(|d| d.meta.namespace.to_string() == "source:notion"),
"filed under the toolkit's brain source"
);
- assert_eq!(crate::memory::lifecycle::jobs::snapshot(&config).await.pending.len(), 1);
+ assert_eq!(
+ crate::memory::lifecycle::jobs::snapshot(&config)
+ .await
+ .pending
+ .len(),
+ 1
+ );
}
#[tokio::test]
@@ -117,9 +124,17 @@ async fn store_records_with_nothing_to_store_is_zero() {
bind_reference(&config);
let bound = crate::memory::engine::resolve(&config).engine().unwrap();
assert_eq!(
- store_records(&config, &bound, "notion", "c", "s", &MemoryLayout::default(), &[])
- .await
- .unwrap(),
+ store_records(
+ &config,
+ &bound,
+ "notion",
+ "c",
+ "s",
+ &MemoryLayout::default(),
+ &[]
+ )
+ .await
+ .unwrap(),
0
);
}
diff --git a/crates/openhuman-core/src/memory/sources/mod.rs b/crates/openhuman-core/src/memory/sources/mod.rs
index a08e4a3990..cff09b3e2a 100644
--- a/crates/openhuman-core/src/memory/sources/mod.rs
+++ b/crates/openhuman-core/src/memory/sources/mod.rs
@@ -207,9 +207,20 @@ pub fn is_due(
/// The layout source `source` files into: its own `namespace` (a layout
/// root such as `team:acme`) when set, else the configured root.
#[must_use]
-pub fn layout_of_source(config: &Config, source: &MemorySourceConfig) -> tinymemory_tools::MemoryLayout {
- let default = || crate::memory::scope::MemoryIdentity::root().resolve(config).layout;
- let Some(raw) = source.namespace.as_deref().filter(|raw| !raw.trim().is_empty()) else {
+pub fn layout_of_source(
+ config: &Config,
+ source: &MemorySourceConfig,
+) -> tinymemory_tools::MemoryLayout {
+ let default = || {
+ crate::memory::scope::MemoryIdentity::root()
+ .resolve(config)
+ .layout
+ };
+ let Some(raw) = source
+ .namespace
+ .as_deref()
+ .filter(|raw| !raw.trim().is_empty())
+ else {
return default();
};
raw.parse::<tinymemory_api::Namespace>()
@@ -231,7 +242,11 @@ pub fn layout_of(config: &Config, source_id: &str) -> tinymemory_tools::MemoryLa
.iter()
.find(|source| source.id == source_id)
.map_or_else(
- || crate::memory::scope::MemoryIdentity::root().resolve(config).layout,
+ || {
+ crate::memory::scope::MemoryIdentity::root()
+ .resolve(config)
+ .layout
+ },
|source| layout_of_source(config, source),
)
}
diff --git a/crates/openhuman-core/src/memory/sources/mod_tests.rs b/crates/openhuman-core/src/memory/sources/mod_tests.rs
index 2f5005a91d..6de7006935 100644
--- a/crates/openhuman-core/src/memory/sources/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/mod_tests.rs
@@ -270,7 +270,10 @@ fn a_source_can_store_at_an_agent_node() {
params.namespace = Some("team:acme".into());
let added = apply_add(&mut config, &params).unwrap();
assert_eq!(added.namespace.as_deref(), Some("team:acme"));
- assert_eq!(layout_of(&config, &added.id).root().to_string(), "team:acme");
+ assert_eq!(
+ layout_of(&config, &added.id).root().to_string(),
+ "team:acme"
+ );
assert!(layout_of(&config, "unknown").root().is_root());
let mut bad = add_params("link", "https://example.com/b");
diff --git a/crates/openhuman-core/src/memory/sources/sync_tests.rs b/crates/openhuman-core/src/memory/sources/sync_tests.rs
index 92ed24de4e..df3349cae4 100644
--- a/crates/openhuman-core/src/memory/sources/sync_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/sync_tests.rs
@@ -268,17 +268,15 @@ async fn store_all_skips_a_bad_item_but_fails_when_nothing_stored() {
.unwrap(),
1
);
- assert!(
- store_all(
- &config,
- &bound,
- vec![bad],
- (MemorySourceKind::Folder, "/n", "src"),
- &tinymemory_tools::MemoryLayout::default()
- )
- .await
- .is_err()
- );
+ assert!(store_all(
+ &config,
+ &bound,
+ vec![bad],
+ (MemorySourceKind::Folder, "/n", "src"),
+ &tinymemory_tools::MemoryLayout::default()
+ )
+ .await
+ .is_err());
assert_eq!(
store_all(
&config,
@@ -287,8 +285,8 @@ async fn store_all_skips_a_bad_item_but_fails_when_nothing_stored() {
(MemorySourceKind::Folder, "/n", "src"),
&tinymemory_tools::MemoryLayout::default()
)
- .await
- .unwrap(),
+ .await
+ .unwrap(),
0
);
}
diff --git a/crates/openhuman-core/src/memory/test_fixtures.rs b/crates/openhuman-core/src/memory/test_fixtures.rs
index 5d3bb3a62f..09826aa94d 100644
--- a/crates/openhuman-core/src/memory/test_fixtures.rs
+++ b/crates/openhuman-core/src/memory/test_fixtures.rs
@@ -30,7 +30,10 @@ pub(crate) fn bind_reference(config: &Config) -> Arc<ReferenceEngine> {
}
/// Every item `engine` holds that matches `filter`.
-pub(crate) async fn stored(engine: &ReferenceEngine, filter: MetaFilter) -> Vec<tinymemory_api::Hit> {
+pub(crate) async fn stored(
+ engine: &ReferenceEngine,
+ filter: MetaFilter,
+) -> Vec<tinymemory_api::Hit> {
engine
.list(ListRequest {
filter,
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index 867fe093c2..f560f9f340 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -333,7 +333,10 @@ fn gather_falls_back_to_the_action_dir() {
assert!(gathered.thread_id.is_none());
assert!(gathered.tool_call_id.is_none());
let meta = gathered.learn_meta();
- assert!(meta.namespace.is_root(), "no agent in scope: the default root");
+ assert!(
+ meta.namespace.is_root(),
+ "no agent in scope: the default root"
+ );
assert_eq!(meta.source.kind, SourceKind::Agent);
assert_eq!(meta.tool_call.unwrap().name, MEMORY_TOOL_NAME);
}
@@ -370,7 +373,10 @@ async fn learnings_are_shared_under_a_root_and_a_team_root_is_kept_apart() {
.map(|hit| (hit.meta.namespace.to_string(), hit.meta.agent_id.clone()))
.unwrap()
};
- assert_eq!(at("deploy day"), ("root".into(), Some("orchestrator".into())));
+ assert_eq!(
+ at("deploy day"),
+ ("root".into(), Some("orchestrator".into()))
+ );
assert_eq!(at("arxiv"), ("root".into(), Some("researcher".into())));
assert_eq!(
at("british english"),
@@ -410,7 +416,11 @@ async fn learnings_are_shared_under_a_root_and_a_team_root_is_kept_apart() {
&member(),
)
.await;
- assert!(forgot.text().contains("\"forgotten\":0"), "{}", forgot.text());
+ assert!(
+ forgot.text().contains("\"forgotten\":0"),
+ "{}",
+ forgot.text()
+ );
assert!(stored(&engine, MetaFilter::default())
.await
.iter()
diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rs
index e8a532783c..7c8432c846 100644
--- a/crates/openhuman-core/src/memory/types.rs
+++ b/crates/openhuman-core/src/memory/types.rs
@@ -8,7 +8,9 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
-pub use tinymemory_api::{Citation, EngineDescriptor, FetchMode, Hit, ItemKind, LearningKind, MemoryMeta, MetaFilter};
+pub use tinymemory_api::{
+ Citation, EngineDescriptor, FetchMode, Hit, ItemKind, LearningKind, MemoryMeta, MetaFilter,
+};
use crate::config::schema::MemorySourceKind;
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
index 2406e2f67f..e35b8c259a 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
@@ -495,11 +495,7 @@ fn memory_v2_capabilities_cite_live_surface_and_rpcs() {
("memory.engine", "engine", "memory_engine_set"),
("memory.ask", "ask", "memory_recall"),
("memory.learnings", "learnings", "memory_learn"),
- (
- "memory.conversations",
- "conversations",
- "memory_policy_set",
- ),
+ ("memory.conversations", "conversations", "memory_policy_set"),
("memory.documents", "brain", "memory_brain_ingest"),
("memory.turn_pack", "settings", "memory_pack_preview"),
] {
diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rs
index b6ad15d81a..aaa859e67e 100644
--- a/crates/openhuman-embed/src/agent/build.rs
+++ b/crates/openhuman-embed/src/agent/build.rs
@@ -79,7 +79,9 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn
if let Some(binding) = parts.memory {
let agent_id = binding.agent_id().trim();
if agent_id.is_empty() {
- return Err(AgentError::Invalid("a memory binding needs an agent id".into()));
+ return Err(AgentError::Invalid(
+ "a memory binding needs an agent id".into(),
+ ));
}
if let Some(root) = binding.root_namespace() {
openhuman_core::memory::scope::validate_root(root)
diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rs
index 31c543cbe6..1e81eb4080 100644
--- a/crates/openhuman-embed/tests/runtime_agents.rs
+++ b/crates/openhuman-embed/tests/runtime_agents.rs
@@ -529,7 +529,10 @@ fn one_runtime_hosts_independently_configured_agents() {
.memory(MemoryBinding::new("employee-7").root("team:acme")),
)
.expect("a bound agent instantiates");
- assert_eq!(bound.config().memory.agent_id.as_deref(), Some("employee-7"));
+ assert_eq!(
+ bound.config().memory.agent_id.as_deref(),
+ Some("employee-7")
+ );
assert_eq!(bound.config().memory.root.as_deref(), Some("team:acme"));
assert_eq!(beta.config().memory.agent_id, None);
let err = runtime
diff --git a/tests/memory_cortexdb_live.rs b/tests/memory_cortexdb_live.rs
index c5d166bdbc..3965f16c63 100644
--- a/tests/memory_cortexdb_live.rs
+++ b/tests/memory_cortexdb_live.rs
@@ -507,9 +507,7 @@ async fn run(cortex_url: String, cortex_key: String) {
);
let agents = stack.ok("openhuman.memory_agents_list", json!({})).await;
assert!(
- agents["agents"]
- .as_array()
- .is_some_and(|a| !a.is_empty()),
+ agents["agents"].as_array().is_some_and(|a| !a.is_empty()),
"the answering agent is listed: {agents}"
);
@@ -549,7 +547,9 @@ async fn run(cortex_url: String, cortex_key: String) {
"the pack carries the learning: {preview}"
);
- stack.chat(&thread_b, "Where do we hold launch events?").await;
+ stack
+ .chat(&thread_b, "Where do we hold launch events?")
+ .await;
let deadline = Instant::now() + PATIENCE;
loop {
let injected = stack.mock_bodies().await.into_iter().any(|(url, body)| {
@@ -571,9 +571,9 @@ async fn run(cortex_url: String, cortex_key: String) {
// ---- background: the queued belief builds run on demand -------------------
let jobs = stack.ok("openhuman.memory_jobs_run", json!({})).await;
assert!(
- jobs["runs"].as_array().is_some_and(|runs| runs
- .iter()
- .all(|run| run["outcome"] != json!("failed"))),
+ jobs["runs"]
+ .as_array()
+ .is_some_and(|runs| runs.iter().all(|run| run["outcome"] != json!("failed"))),
"belief builds run on CortexDB: {jobs}"
);
diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rs
index f79b091763..29003d8ba1 100644
--- a/tests/memory_v2_e2e.rs
+++ b/tests/memory_v2_e2e.rs
@@ -133,8 +133,14 @@ impl MockBackend {
.iter()
.map(|row| {
(
- row.get("url").and_then(Value::as_str).unwrap_or_default().to_string(),
- row.get("body").and_then(Value::as_str).unwrap_or_default().to_string(),
+ row.get("url")
+ .and_then(Value::as_str)
+ .unwrap_or_default()
+ .to_string(),
+ row.get("body")
+ .and_then(Value::as_str)
+ .unwrap_or_default()
+ .to_string(),
)
})
.collect()
@@ -407,7 +413,10 @@ async fn memory_is_off_when_signed_out() {
json!({ "consent": true }),
),
("openhuman.memory_sources_sync", json!({})),
- ("openhuman.memory_pack_preview", json!({ "query": "anything" })),
+ (
+ "openhuman.memory_pack_preview",
+ json!({ "query": "anything" }),
+ ),
("openhuman.memory_agents_list", json!({})),
("openhuman.memory_brain_sources", json!({})),
("openhuman.memory_brain_ingest", json!({ "text": "a doc" })),
@@ -1201,7 +1210,11 @@ async fn brain_pack_preview_and_jobs_round_trip() {
);
let sources = f.ok("openhuman.memory_brain_sources", json!({})).await;
- assert_eq!(sources["sources"][0]["source"], json!("notion"), "{sources}");
+ assert_eq!(
+ sources["sources"][0]["source"],
+ json!("notion"),
+ "{sources}"
+ );
let found = f
.ok(
"openhuman.memory_brain_search",
@@ -1234,12 +1247,16 @@ async fn brain_pack_preview_and_jobs_round_trip() {
assert_eq!(after["pending"], json!([]));
assert_eq!(after["history"][0]["outcome"], json!("scheduled"));
assert_eq!(
- f.code("openhuman.memory_jobs_run", json!({ "id": "nope" })).await,
+ f.code("openhuman.memory_jobs_run", json!({ "id": "nope" }))
+ .await,
"INVALID_REQUEST"
);
let gone = f
- .ok("openhuman.memory_brain_forget", json!({ "source": "notion" }))
+ .ok(
+ "openhuman.memory_brain_forget",
+ json!({ "source": "notion" }),
+ )
.await;
assert_eq!(gone["forgotten"], json!(1), "{gone}");
let agents = f.ok("openhuman.memory_agents_list", json!({})).await;
@@ -1295,11 +1312,15 @@ async fn a_chat_turn_carries_its_pack_and_is_logged() {
assert_eq!(accepted["accepted"], json!(true), "{accepted}");
// Pre-turn: the model request carries the pack, recalled for the turn.
- wait_for_request(&f, "an inference request carrying the memory pack", |url, body| {
- url.contains("chat/completions")
- && body.contains("memory-context")
- && body.contains("launch events in Lisbon")
- })
+ wait_for_request(
+ &f,
+ "an inference request carrying the memory pack",
+ |url, body| {
+ url.contains("chat/completions")
+ && body.contains("memory-context")
+ && body.contains("launch events in Lisbon")
+ },
+ )
.await;
// Pre-turn logs the user's message, post-turn the reply, each as one turn
// of the thread under the answering agent's node.
@@ -1323,7 +1344,11 @@ async fn a_chat_turn_carries_its_pack_and_is_logged() {
.request_rows()
.await
.into_iter()
- .filter(|row| row["url"].as_str().is_some_and(|url| url.starts_with("/memory/")))
+ .filter(|row| {
+ row["url"]
+ .as_str()
+ .is_some_and(|url| url.starts_with("/memory/"))
+ })
.collect();
assert!(!memory_calls.is_empty());
for row in &memory_calls {
@@ -1342,7 +1367,9 @@ async fn a_chat_turn_carries_its_pack_and_is_logged() {
)
.await;
assert!(
- transcript.to_string().contains("Where should the launch event be held?"),
+ transcript
+ .to_string()
+ .contains("Where should the launch event be held?"),
"the turn was committed: {transcript}"
);
assert!(