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
chore(memory): reformat long lines and reorder imports for consistency
Steven Enamakel38656e182450
diff --git a/crates/openhuman-core/src/memory/binding.rs b/crates/openhuman-core/src/memory/binding.rsindex e5a00fc242..a2ad22e2cb 100644--- a/crates/openhuman-core/src/memory/binding.rs+++ b/crates/openhuman-core/src/memory/binding.rs@@ -526,7 +526,8 @@ pub(crate) fn bind_provider_for_test(/// dedicated memory is a different store, so it must be a different binding./// The subtree is `"memory"` for every ordinary caller.pub(super) type BindingCacheKey = (PathBuf, String, MemorySubsystemConfig);-pub(super) static BINDINGS: OnceLock<RwLock<HashMap<BindingCacheKey, Arc<MemoryBinding>>>> = OnceLock::new();+pub(super) static BINDINGS: OnceLock<RwLock<HashMap<BindingCacheKey, Arc<MemoryBinding>>>> =+ OnceLock::new();/// Every binding this process has built so far, for the exit path.///diff --git a/crates/openhuman-core/src/memory/binding_admission_tests.rs b/crates/openhuman-core/src/memory/binding_admission_tests.rsindex 5510338f01..af651f934c 100644--- a/crates/openhuman-core/src/memory/binding_admission_tests.rs+++ b/crates/openhuman-core/src/memory/binding_admission_tests.rs@@ -147,7 +147,11 @@ fn admit_refuses_the_hosted_engine_when_memory_remote_is_off() {..Default::default()};let refusal = admit(&cfg).expect_err("no hosted engine without memory-remote");- assert!(refusal.reason.contains("not built in"), "{}", refusal.reason);+ assert!(+ refusal.reason.contains("not built in"),+ "{}",+ refusal.reason+ );}#[cfg(feature = "memory-remote")]@@ -171,7 +175,11 @@ fn admit_refuses_a_trusted_external_id_the_factory_does_not_know() {"{}",refusal.reason);- assert!(!refusal.reason.contains("trust_state"), "{}", refusal.reason);+ assert!(+ !refusal.reason.contains("trust_state"),+ "{}",+ refusal.reason+ );}#[cfg(feature = "memory-remote")]diff --git a/crates/openhuman-core/src/memory/binding_remote.rs b/crates/openhuman-core/src/memory/binding_remote.rsindex c2a5112844..d51fff861c 100644--- a/crates/openhuman-core/src/memory/binding_remote.rs+++ b/crates/openhuman-core/src/memory/binding_remote.rs@@ -185,9 +185,7 @@ mod imp {use std::path::{Path, PathBuf};use std::sync::Arc;- use tinymemory::factory::{- build_provider, BearerSource, EngineConfig, EngineCredential,- };+ use tinymemory::factory::{build_provider, BearerSource, EngineConfig, EngineCredential};use super::{keyring_user_id, scrub, EngineTarget, HOSTED_ENGINE_ID};use crate::memory::api::provider::MemoryProvider;@@ -219,13 +217,17 @@ mod imp {let config =crate::config::ops::load_config_for_workspace_with_timeout(&self.workspace_dir).await- .map_err(|e| anyhow::anyhow!("{NO_SESSION_MESSAGE} (config unavailable: {e})"))?;+ .map_err(|e| {+ anyhow::anyhow!("{NO_SESSION_MESSAGE} (config unavailable: {e})")+ })?;match crate::security::credentials::session_support::backend_bearer_secret(&config) {Ok(Some(token)) if !token.trim().is_empty() => Ok(token),Ok(_) => Err(anyhow::anyhow!(NO_SESSION_MESSAGE)),Err(e) => {log::debug!("[memory:remote] bearer lookup failed: {e}");- Err(anyhow::anyhow!("{NO_SESSION_MESSAGE} (credential lookup failed)"))+ Err(anyhow::anyhow!(+ "{NO_SESSION_MESSAGE} (credential lookup failed)"+ ))}}}@@ -293,8 +295,12 @@ mod imp {if let Some(key) = target.api_key.as_deref() {secrets.push(key);}- build_provider(id, &config, credential)- .map_err(|e| format!("engine '{id}' could not be built: {}", scrub(&e.to_string(), &secrets)))+ build_provider(id, &config, credential).map_err(|e| {+ format!(+ "engine '{id}' could not be built: {}",+ scrub(&e.to_string(), &secrets)+ )+ })}}diff --git a/crates/openhuman-core/src/memory/binding_remote_tests.rs b/crates/openhuman-core/src/memory/binding_remote_tests.rsindex 031e4be203..479a0694f7 100644--- a/crates/openhuman-core/src/memory/binding_remote_tests.rs+++ b/crates/openhuman-core/src/memory/binding_remote_tests.rs@@ -2,7 +2,10 @@ use super::*;#[test]fn credential_ref_names_the_engine_specific_keychain_entry() {- assert_eq!(credential_ref_for("supermemory"), "keychain:memory-supermemory");+ assert_eq!(+ credential_ref_for("supermemory"),+ "keychain:memory-supermemory"+ );let parsed = crate::security::credentials::credential_ref::CredentialRef::parse(&credential_ref_for("mem0"),)@@ -28,7 +31,10 @@ fn scrub_removes_every_secret_and_ignores_blank_ones() {"failed to reach https://leak.example with key sk-123",&["https://leak.example", "sk-123", "", " "],);- assert!(!scrubbed.contains("leak.example") && !scrubbed.contains("sk-123"), "{scrubbed}");+ assert!(+ !scrubbed.contains("leak.example") && !scrubbed.contains("sk-123"),+ "{scrubbed}"+ );}#[test]@@ -45,7 +51,10 @@ fn engine_target_from_entry_copies_endpoint_deployment_and_ref() {assert_eq!(target.id, "mem0");assert_eq!(target.endpoint.as_deref(), Some("https://e.example"));assert_eq!(target.deployment.as_deref(), Some("cloud"));- assert_eq!(target.credential_ref.as_deref(), Some("keychain:memory-mem0"));+ assert_eq!(+ target.credential_ref.as_deref(),+ Some("keychain:memory-mem0")+ );assert!(target.api_key.is_none());assert!(EngineTarget::from_entry("mem0", None).endpoint.is_none());}@@ -55,15 +64,26 @@ fn api_url_override_is_read_from_the_workspace_config() {let dir = tempfile::tempdir().unwrap();let workspace = dir.path().join("workspace");std::fs::create_dir_all(&workspace).unwrap();- assert_eq!(configured_api_url(&workspace), None, "no config, no override");- std::fs::write(dir.path().join("config.toml"), "api_url = \" https://staging.example \"\n")- .unwrap();+ assert_eq!(+ configured_api_url(&workspace),+ None,+ "no config, no override"+ );+ std::fs::write(+ dir.path().join("config.toml"),+ "api_url = \" https://staging.example \"\n",+ )+ .unwrap();assert_eq!(configured_api_url(&workspace).as_deref(),Some("https://staging.example"));std::fs::write(dir.path().join("config.toml"), "api_url = \"\"\n").unwrap();- assert_eq!(configured_api_url(&workspace), None, "blank means no override");+ assert_eq!(+ configured_api_url(&workspace),+ None,+ "blank means no override"+ );}#[cfg(feature = "memory-remote")]diff --git a/crates/openhuman-core/src/memory/ops/engine.rs b/crates/openhuman-core/src/memory/ops/engine.rsindex 6f467640b8..a8e06eb72e 100644--- a/crates/openhuman-core/src/memory/ops/engine.rs+++ b/crates/openhuman-core/src/memory/ops/engine.rs@@ -17,8 +17,7 @@ use serde::{Deserialize, Serialize};use crate::config::schema::{Config, MemoryDriverConfig};use crate::memory::binding::{self, MODULE_ID};use crate::memory::binding_remote::{- credential_ref_for, is_remote_engine, keyring_user_id, CREDENTIAL_NAME_PREFIX,- HOSTED_ENGINE_ID,+ credential_ref_for, is_remote_engine, keyring_user_id, CREDENTIAL_NAME_PREFIX, HOSTED_ENGINE_ID,};use crate::rpc::RpcOutcome;@@ -200,9 +199,13 @@ pub fn classify_engine_error(error: &anyhow::Error) -> String {// The hosted backend's 402 carries a `[USER_INSUFFICIENT_CREDITS]`// message prefix (`tinymemory_remote::hosted`).MemoryError::BudgetExceeded(message)- if message.trim_start().starts_with("[USER_INSUFFICIENT_CREDITS]") =>+ if message+ .trim_start()+ .starts_with("[USER_INSUFFICIENT_CREDITS]") =>{- return format!("{INSUFFICIENT_CREDITS_PREFIX} the memory engine is out of credits");+ return format!(+ "{INSUFFICIENT_CREDITS_PREFIX} the memory engine is out of credits"+ );}MemoryError::Unauthorized(_) => {return format!("{SESSION_EXPIRED_PREFIX} the memory engine rejected the session");@@ -310,7 +313,8 @@ pub(super) fn build_target_provider(api_key: prepared.api_key.clone(),credential_ref: prepared.takes_key.then(|| credential_ref_for(&prepared.id)),};- build_engine(&config.workspace_dir, &config.api_url, &target).map_err(|e| classify_engine_message(&e))+ build_engine(&config.workspace_dir, &config.api_url, &target)+ .map_err(|e| classify_engine_message(&e))}#[cfg(not(feature = "memory-remote"))]@@ -377,9 +381,7 @@ pub(super) async fn commit_engine(class: Some("external".to_string()),transport: Some("http".to_string()),endpoint: prepared.endpoint.clone(),- credential_ref: prepared- .takes_key- .then(|| credential_ref_for(&prepared.id)),+ credential_ref: prepared.takes_key.then(|| credential_ref_for(&prepared.id)),// The user chose this engine in the UI: that is the trust grant.trust_state: "trusted".to_string(),deployment: prepared.deployment.clone(),@@ -419,7 +421,9 @@ pub(super) fn state_for(config: &Config) -> Result<EngineState, String> {} else {entry.and_then(|e| e.credential_ref.as_deref())- .and_then(|r| crate::security::credentials::credential_ref::CredentialRef::parse(r).ok())+ .and_then(|r| {+ crate::security::credentials::credential_ref::CredentialRef::parse(r).ok()+ }).is_some_and(|r| r.resolve(&keyring_user_id(&config.workspace_dir)).is_ok())};Ok(EngineState {@@ -457,7 +461,9 @@ pub async fn memory_engine_get() -> Result<RpcOutcome<EngineState>, String> {}/// `memory.engine_set`.-pub async fn memory_engine_set(params: EngineTargetParams) -> Result<RpcOutcome<EngineState>, String> {+pub async fn memory_engine_set(+ params: EngineTargetParams,+) -> Result<RpcOutcome<EngineState>, String> {let config = load_config().await?;let prepared = prepare_target(params)?;log::debug!(diff --git a/crates/openhuman-core/src/memory/ops/engine_migrate.rs b/crates/openhuman-core/src/memory/ops/engine_migrate.rsindex 41e09eb131..47de866a65 100644--- a/crates/openhuman-core/src/memory/ops/engine_migrate.rs+++ b/crates/openhuman-core/src/memory/ops/engine_migrate.rs@@ -142,7 +142,9 @@ async fn run_copy(}/// `memory.engine_migrate`.-pub async fn memory_engine_migrate(params: MigrateParams) -> Result<RpcOutcome<MigrateStarted>, String> {+pub async fn memory_engine_migrate(+ params: MigrateParams,+) -> Result<RpcOutcome<MigrateStarted>, String> {let config: Config = crate::config::rpc::load_config_with_timeout().await?;let prepared = prepare_target(params.to)?;diff --git a/crates/openhuman-core/src/memory/ops/engine_migrate_tests.rs b/crates/openhuman-core/src/memory/ops/engine_migrate_tests.rsindex 708c74acef..9c9b0e6fc1 100644--- a/crates/openhuman-core/src/memory/ops/engine_migrate_tests.rs+++ b/crates/openhuman-core/src/memory/ops/engine_migrate_tests.rs@@ -4,7 +4,9 @@ use super::*;static JOBS_LOCK: Mutex<()> = Mutex::new(());fn lock() -> std::sync::MutexGuard<'static, ()> {- JOBS_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner)+ JOBS_LOCK+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner)}fn clear() {diff --git a/crates/openhuman-core/src/memory/ops/engine_tests.rs b/crates/openhuman-core/src/memory/ops/engine_tests.rsindex ac08e5ab62..f4d9f3f99a 100644--- a/crates/openhuman-core/src/memory/ops/engine_tests.rs+++ b/crates/openhuman-core/src/memory/ops/engine_tests.rs@@ -37,7 +37,14 @@ fn the_module_advertises_every_capability_family() {#[test]fn every_remote_engine_is_listed_with_at_least_the_mandatory_families() {let engines = available_engines();- for id in ["tinyhumans", "supermemory", "mem0", "cognee", "cortex", "agentmemory"] {+ for id in [+ "tinyhumans",+ "supermemory",+ "mem0",+ "cognee",+ "cortex",+ "agentmemory",+ ] {let engine = engines.iter().find(|e| e.id == id)@@ -59,7 +66,10 @@ fn every_remote_engine_is_listed_with_at_least_the_mandatory_families() {#[test]fn prepare_rejects_empty_null_and_unknown_engines() {for bad in ["", " ", "null", "not-an-engine"] {- assert!(prepare_target(target(bad)).is_err(), "{bad:?} must be rejected");+ assert!(+ prepare_target(target(bad)).is_err(),+ "{bad:?} must be rejected"+ );}}@@ -79,11 +89,15 @@ fn prepare_folds_the_legacy_alias_and_ignores_module_options() {fn prepare_validates_endpoint_and_deployment() {let mut bad_endpoint = target("supermemory");bad_endpoint.endpoint = Some("ftp://nope".into());- assert!(prepare_target(bad_endpoint).unwrap_err().contains("http(s)"));+ assert!(prepare_target(bad_endpoint)+ .unwrap_err()+ .contains("http(s)"));let mut bad_deployment = target("mem0");bad_deployment.deployment = Some("moon".into());- assert!(prepare_target(bad_deployment).unwrap_err().contains("deployment"));+ assert!(prepare_target(bad_deployment)+ .unwrap_err()+ .contains("deployment"));let mut good = target("mem0");good.endpoint = Some(" https://api.mem0.ai ".into());@@ -104,10 +118,16 @@ fn the_hosted_engine_drops_a_caller_supplied_endpoint_and_key() {params.api_key = Some("tiny_live_pasted".into());params.deployment = Some("cloud".into());let prepared = prepare_target(params).unwrap();- assert!(prepared.endpoint.is_none(), "an endpoint could redirect the session bearer");+ assert!(+ prepared.endpoint.is_none(),+ "an endpoint could redirect the session bearer"+ );assert!(prepared.api_key.is_none());assert!(prepared.deployment.is_none());- assert!(!prepared.takes_key, "the hosted entry carries no credential_ref");+ assert!(+ !prepared.takes_key,+ "the hosted entry carries no credential_ref"+ );}#[test]@@ -122,7 +142,10 @@ fn a_402_from_the_hosted_backend_becomes_insufficient_credits() {fn a_budget_error_without_the_credits_code_is_left_alone() {let error = anyhow::Error::new(MemoryError::BudgetExceeded("token budget".into()));let message = classify_engine_error(&error);- assert!(!message.starts_with(INSUFFICIENT_CREDITS_PREFIX), "{message}");+ assert!(+ !message.starts_with(INSUFFICIENT_CREDITS_PREFIX),+ "{message}"+ );}#[test]@@ -149,12 +172,14 @@ fn backend_unavailable_and_prefixed_messages_pass_through() {fn a_bearer_source_failure_surfaces_as_session_expired() {// The hosted adapter wraps a failing `BearerSource` in `Unauthorized`; the// message the bearer reports keeps the prefix so string paths agree too.+ assert!(classify_engine_message(+ "SESSION_EXPIRED: no TinyHumans session (credential lookup failed)"+ )+ .starts_with(SESSION_EXPIRED_PREFIX));assert!(- classify_engine_message("SESSION_EXPIRED: no TinyHumans session (credential lookup failed)")+ classify_engine_message("unauthorized: SESSION_EXPIRED: no TinyHumans session").starts_with(SESSION_EXPIRED_PREFIX));- assert!(classify_engine_message("unauthorized: SESSION_EXPIRED: no TinyHumans session")- .starts_with(SESSION_EXPIRED_PREFIX));}#[test]@@ -169,7 +194,12 @@ fn state_and_list_serialise_to_the_bare_wire_shapes_the_ui_reads() {last_error: None,}).unwrap();- let mut keys: Vec<&str> = state.as_object().unwrap().keys().map(String::as_str).collect();+ let mut keys: Vec<&str> = state+ .as_object()+ .unwrap()+ .keys()+ .map(String::as_str)+ .collect();keys.sort_unstable();assert_eq!(keys,@@ -201,6 +231,9 @@ fn state_and_list_serialise_to_the_bare_wire_shapes_the_ui_reads() {"hosted","capabilities",] {- assert!(engine.get(key).is_some(), "engine descriptor lacks {key}: {engine}");+ assert!(+ engine.get(key).is_some(),+ "engine descriptor lacks {key}: {engine}"+ );}}diff --git a/crates/openhuman-core/src/memory/ops/mod.rs b/crates/openhuman-core/src/memory/ops/mod.rsindex 1fb1346d43..e77ac15432 100644--- a/crates/openhuman-core/src/memory/ops/mod.rs+++ b/crates/openhuman-core/src/memory/ops/mod.rs@@ -54,12 +54,6 @@ pub use documents::{DeleteDocParams, IngestDocParams, NamespaceOnlyParams, NamespaceSummariesResponse,PutDocParams, PutDocResult, QueryNamespaceParams, RecallNamespaceParams,};-pub use files::{ai_list_memory_files, ai_read_memory_file, ai_write_memory_file};-pub use kv_graph::{- graph_query, graph_upsert, kv_delete, kv_get, kv_list_namespace, kv_set, GraphQueryParams,- GraphUpsertParams, KvGetDeleteParams, KvSetParams,-};-pub use learn::{memory_learn_all, LearnAllParams, LearnAllResult, NamespaceLearnResult};pub use engine::{memory_engine_get, memory_engine_set, memory_engines_list, EngineState, EngineTargetParams,EnginesList,@@ -67,6 +61,12 @@ pub use engine::{pub use engine_migrate::{memory_engine_migrate, memory_engine_migrate_status, MigrateParams, MigrateStatusParams,};+pub use files::{ai_list_memory_files, ai_read_memory_file, ai_write_memory_file};+pub use kv_graph::{+ graph_query, graph_upsert, kv_delete, kv_get, kv_list_namespace, kv_set, GraphQueryParams,+ GraphUpsertParams, KvGetDeleteParams, KvSetParams,+};+pub use learn::{memory_learn_all, LearnAllParams, LearnAllResult, NamespaceLearnResult};pub use provider::{memory_provider_status, memory_subsystem_status};pub use sync::{memory_ingestion_status, memory_scheduler_override, memory_sync_all, memory_sync_channel,diff --git a/crates/openhuman-core/src/memory/schemas/engine.rs b/crates/openhuman-core/src/memory/schemas/engine.rsindex a8a85b0aff..048a519c9e 100644--- a/crates/openhuman-core/src/memory/schemas/engine.rs+++ b/crates/openhuman-core/src/memory/schemas/engine.rs@@ -8,9 +8,7 @@ use serde_json::{Map, Value};use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::{ControllerSchema, FieldSchema, TypeSchema};-use crate::memory::rpc::{- self, EngineTargetParams, MigrateParams, MigrateStatusParams,-};+use crate::memory::rpc::{self, EngineTargetParams, MigrateParams, MigrateStatusParams};use super::{parse_params, to_json};@@ -91,13 +89,48 @@ fn target_inputs() -> Vec<FieldSchema> {fn state_outputs() -> Vec<FieldSchema> {vec![- field("driver", TypeSchema::String, "Bound engine id (null after a fallback).", true),- field("endpoint", opt_string(), "Endpoint in use, when the engine has one.", false),- field("deployment", opt_string(), "Deployment in use, when the engine has several.", false),- field("has_credential", TypeSchema::Bool, "Whether a credential is available. The credential itself is never returned.", true),- field("class", TypeSchema::String, "How the engine is bound: module | external | null.", true),- field("fell_back_from", opt_string(), "The engine that was asked for and refused, when this is a fallback.", false),- field("last_error", opt_string(), "Why the fallback happened; null when clean.", false),+ field(+ "driver",+ TypeSchema::String,+ "Bound engine id (null after a fallback).",+ true,+ ),+ field(+ "endpoint",+ opt_string(),+ "Endpoint in use, when the engine has one.",+ false,+ ),+ field(+ "deployment",+ opt_string(),+ "Deployment in use, when the engine has several.",+ false,+ ),+ field(+ "has_credential",+ TypeSchema::Bool,+ "Whether a credential is available. The credential itself is never returned.",+ true,+ ),+ field(+ "class",+ TypeSchema::String,+ "How the engine is bound: module | external | null.",+ true,+ ),+ field(+ "fell_back_from",+ opt_string(),+ "The engine that was asked for and refused, when this is a fallback.",+ false,+ ),+ field(+ "last_error",+ opt_string(),+ "Why the fallback happened; null when clean.",+ false,+ ),]}