Skip to content

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

chore: apply rustfmt formatting across the codebase

Steven Enamakel4ceadf3b7515
diff --git a/crates/openhuman-core/src/agent/context/manager_tests.rs b/crates/openhuman-core/src/agent/context/manager_tests.rs
index ac435cb2ab..b29753f3d8 100644
--- a/crates/openhuman-core/src/agent/context/manager_tests.rs
+++ b/crates/openhuman-core/src/agent/context/manager_tests.rs
@@ -68,4 +68,3 @@ fn autocompact_enabled_requires_both_master_and_autocompact_flags() {
no_autocompact.autocompact_enabled = false;
assert!(!manager_with_config(&no_autocompact).autocompact_enabled());
}
-
diff --git a/crates/openhuman-core/src/agent/harness_init/registry_tests.rs b/crates/openhuman-core/src/agent/harness_init/registry_tests.rs
index e71245683d..88db39ce9c 100644
--- a/crates/openhuman-core/src/agent/harness_init/registry_tests.rs
+++ b/crates/openhuman-core/src/agent/harness_init/registry_tests.rs
@@ -4,11 +4,7 @@ use super::*;
fn all_steps_have_stable_ids_and_are_non_required() {
let steps = all_steps();
let ids: Vec<_> = steps.iter().map(|s| s.id).collect();
- let mut expected = vec![
- "python_runtime",
- "kompress",
- "runtime_python_server",
- ];
+ let mut expected = vec!["python_runtime", "kompress", "runtime_python_server"];
// `node_runtime` is a registration-site gate: it is absent (not
// dead-but-listed) when the managed Node runtime is compiled out. `cfg!`
// (not `#[cfg]`) keeps `expected` mutable-and-used in both builds — same
diff --git a/crates/openhuman-core/src/agent/hooks_tests.rs b/crates/openhuman-core/src/agent/hooks_tests.rs
index 8178717812..953841959e 100644
--- a/crates/openhuman-core/src/agent/hooks_tests.rs
+++ b/crates/openhuman-core/src/agent/hooks_tests.rs
@@ -147,7 +147,7 @@ async fn fired_hooks_observe_the_firing_dispatchs_core_context() {
let tenant_ctx = CoreContext::for_test(
crate::core::runtime::DomainSet::full(),
- Some(std::path::PathBuf::from("/tmp/tenant-a"))
+ Some(std::path::PathBuf::from("/tmp/tenant-a")),
);
let (tx, rx) = tokio::sync::oneshot::channel();
let probe: std::sync::Arc<dyn PostTurnHook> = std::sync::Arc::new(ContextProbe {
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs
index 7c81bb9389..5c2c5785d4 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs
@@ -17,9 +17,7 @@ use crate::agent::progress::AgentProgress;
use crate::agent::subagent_host::{
run_subagent_with_parent, SubagentRunOptions, SubagentRunOutcome, SubagentRunStatus,
};
-use crate::threads::store::{
- self as conversations, ConversationMessage, CreateConversationThread,
-};
+use crate::threads::store::{self as conversations, ConversationMessage, CreateConversationThread};
use async_trait::async_trait;
use serde_json::json;
use std::path::PathBuf;
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs
index 7f27f095c7..1ad73428eb 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tool_call_text_tests.rs
@@ -2,7 +2,9 @@ use super::*;
#[test]
fn prose_is_not_a_tool_call() {
- assert!(!looks_like_unexecuted_tool_call("All done, the file is saved."));
+ assert!(!looks_like_unexecuted_tool_call(
+ "All done, the file is saved."
+ ));
assert!(!contains_tool_call_payload("All done."));
assert_eq!(strip_tool_calls_from_response(" plain "), " plain ");
}
@@ -23,10 +25,16 @@ fn stripping_keeps_only_the_prose() {
#[test]
fn an_unclosed_tag_drops_the_tail() {
- assert_eq!(strip_tool_calls_from_response("Keep <tool_call>{\"a\":1"), "Keep");
+ assert_eq!(
+ strip_tool_calls_from_response("Keep <tool_call>{\"a\":1"),
+ "Keep"
+ );
}
#[test]
fn a_pure_payload_strips_to_empty() {
- assert_eq!(strip_tool_calls_from_response("<tool_call>{}</tool_call>"), "");
+ assert_eq!(
+ strip_tool_calls_from_response("<tool_call>{}</tool_call>"),
+ ""
+ );
}
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
index 4b2c6a4e6b..5916cea440 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread.rs
@@ -14,9 +14,7 @@ use std::path::PathBuf;
use serde_json::json;
-use crate::threads::store::{
- self as conversations, ConversationMessage, CreateConversationThread,
-};
+use crate::threads::store::{self as conversations, ConversationMessage, CreateConversationThread};
/// Create a worker sub-thread linked to `parent_thread_id` and seed it with
/// the delegation `prompt` as the opening user message. Returns the new
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 3a92d44f39..8043b13707 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -244,8 +244,8 @@ impl OpenHumanTurnPrelude {
})
}
fn begin_user_effects(&self, request: &SessionTurnRequest) {
- let user_text = crate::agent::turn_origin::current_is_user_authored()
- .then(|| request.input.text());
+ let user_text =
+ crate::agent::turn_origin::current_is_user_authored().then(|| request.input.text());
self.mutable
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
@@ -721,16 +721,19 @@ impl OpenHumanTurnPrelude {
"[session_host] conversation turn committed tool_calls={}",
tool_calls.len()
);
- crate::core::bus::BUS.publish(crate::core::events::DomainEvent::ConversationTurnCommitted {
- thread_id,
- agent_id: Some(self.agent_definition_id.clone()).filter(|id| !id.trim().is_empty()),
- workspace: Some(self.action_dir.display().to_string()),
- channel: Some(self.event_channel.clone()).filter(|channel| !channel.trim().is_empty()),
- user_text,
- assistant_text: receipt.outcome.output.clone().unwrap_or_default(),
- tool_calls,
- workspace_dir: self.workspace_dir.clone(),
- });
+ crate::core::bus::BUS.publish(
+ crate::core::events::DomainEvent::ConversationTurnCommitted {
+ thread_id,
+ agent_id: Some(self.agent_definition_id.clone()).filter(|id| !id.trim().is_empty()),
+ workspace: Some(self.action_dir.display().to_string()),
+ channel: Some(self.event_channel.clone())
+ .filter(|channel| !channel.trim().is_empty()),
+ user_text,
+ assistant_text: receipt.outcome.output.clone().unwrap_or_default(),
+ tool_calls,
+ workspace_dir: self.workspace_dir.clone(),
+ },
+ );
}
fn mirror_transcript_after_commit(&self, receipt: &CommitReceipt<OpenHumanRunContext>) {
@@ -774,7 +777,6 @@ impl OpenHumanTurnPrelude {
}
});
}
-
}
/// Reconcile visible delegate names without reopening a caller's explicit
@@ -1239,10 +1241,8 @@ impl OpenHumanSessionHost {
)
.await;
request.input = user_message_from_text(&enriched);
- let mut preparation = prelude
- .prepare(new_session)
- .await
- .map_err(|error| {
+ let mut preparation =
+ prelude.prepare(new_session).await.map_err(|error| {
tinyagents_runtime::RuntimeError::Driver(error.to_string())
})?;
if overrides.suppress_tools {
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
index 0d9cc32239..c439050712 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_memory_and_hooks_tests.rs
@@ -95,4 +95,3 @@ async fn embedder_tool_hooks_post_use_without_pre_call_falls_back_to_null() {
assert_eq!(post[0].1, serde_json::Value::Null);
assert_eq!(post[0].2, Some(true));
}
-
diff --git a/crates/openhuman-core/src/channels/host/adapters.rs b/crates/openhuman-core/src/channels/host/adapters.rs
index a757c7fa23..b70246b795 100644
--- a/crates/openhuman-core/src/channels/host/adapters.rs
+++ b/crates/openhuman-core/src/channels/host/adapters.rs
@@ -180,9 +180,8 @@ impl ConversationStore for ConversationHistoryStore {
session_key: &str,
limit: usize,
) -> anyhow::Result<Vec<ConversationMessage>> {
- let messages =
- crate::threads::store::get_messages(self.workspace_dir.clone(), session_key)
- .map_err(|e| anyhow::anyhow!(e))?;
+ let messages = crate::threads::store::get_messages(self.workspace_dir.clone(), session_key)
+ .map_err(|e| anyhow::anyhow!(e))?;
let start = messages.len().saturating_sub(limit);
Ok(messages[start..]
.iter()
@@ -217,12 +216,8 @@ impl ConversationStore for ConversationHistoryStore {
sender: message.role,
created_at: now,
};
- crate::threads::store::append_message(
- self.workspace_dir.clone(),
- session_key,
- stored,
- )
- .map_err(|e| anyhow::anyhow!(e))?;
+ crate::threads::store::append_message(self.workspace_dir.clone(), session_key, stored)
+ .map_err(|e| anyhow::anyhow!(e))?;
Ok(())
}
}
diff --git a/crates/openhuman-core/src/channels/tests/prompt.rs b/crates/openhuman-core/src/channels/tests/prompt.rs
index b42e493c9c..16fe198fa0 100644
--- a/crates/openhuman-core/src/channels/tests/prompt.rs
+++ b/crates/openhuman-core/src/channels/tests/prompt.rs
@@ -60,8 +60,14 @@ fn prompt_injects_workspace_files() {
"missing IDENTITY content"
);
// v1 memory files are never inlined; memory v2 injects `context.md`.
- assert!(!prompt.contains("### PROFILE.md"), "PROFILE.md must not be inlined");
- assert!(!prompt.contains("### MEMORY.md"), "MEMORY.md must not be inlined");
+ assert!(
+ !prompt.contains("### PROFILE.md"),
+ "PROFILE.md must not be inlined"
+ );
+ assert!(
+ !prompt.contains("### MEMORY.md"),
+ "MEMORY.md must not be inlined"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index 1132c9a5db..b23fbc3712 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -46,22 +46,22 @@ pub use schema::{
DelegateAgentConfig, DiagramViewerConfig, DictationActivationMode, DictationConfig,
DiscordConfig, DockerRuntimeConfig, EmailConfig, EmbeddingRouteConfig, GitbooksConfig,
HttpHeader, HttpRequestConfig, IMessageConfig, IntegrationToggle, IntegrationsConfig,
- LarkConfig, LegacySearchInputs, LinqConfig, LocalAiConfig,
- MatrixConfig, McpAuthConfig, McpClientConfig, McpClientIdentityConfig, McpServerConfig,
- McpToolExposure, MemoryConfig, ModelRouteConfig, MultimodalConfig,
- MultimodalFileConfig, ObservabilityConfig, OrchestratorModelConfig, PrivacyConfig, PrivacyMode,
- ProxyConfig, ProxyScope, ReliabilityConfig, ResourceLimitsConfig,
- RuntimeConfig, RuntimePoolConfig, RuntimePoolLangConfig, SandboxBackend, SandboxConfig,
- SchedulerConfig, SchedulerGateConfig, SchedulerGateMode, SearchConfig, SearchEngineCredentials,
- SearchPresentation, SearchProviderSettings, SearchRoute, SearxngConfig, SecretsConfig,
- SecurityConfig, ShellConfig, SlackConfig, StreamMode, SttEngine, TeamModelConfig, TelegramConfig,
- TokenjuiceConfig, UpdateConfig, UpdateRestartStrategy, VoiceActivationMode, VoiceServerConfig,
- WebSearchConfig, WebhookConfig, YuanbaoConfig, DEFAULT_MODEL, LEGACY_TIER_MODELS,
- MANAGED_MULTIMODAL_MODELS, MANAGED_SEARCH_PROVIDERS,
- MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT, MODEL_MEDIA_UNDERSTANDING,
- MODEL_VIDEO_GENERATION_AGENT, SEARCH_ENGINE_BRAVE, SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA,
- SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL, SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY,
- SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
+ LarkConfig, LegacySearchInputs, LinqConfig, LocalAiConfig, MatrixConfig, McpAuthConfig,
+ McpClientConfig, McpClientIdentityConfig, McpServerConfig, McpToolExposure, MemoryConfig,
+ ModelRouteConfig, MultimodalConfig, MultimodalFileConfig, ObservabilityConfig,
+ OrchestratorModelConfig, PrivacyConfig, PrivacyMode, ProxyConfig, ProxyScope,
+ ReliabilityConfig, ResourceLimitsConfig, RuntimeConfig, RuntimePoolConfig,
+ RuntimePoolLangConfig, SandboxBackend, SandboxConfig, SchedulerConfig, SchedulerGateConfig,
+ SchedulerGateMode, SearchConfig, SearchEngineCredentials, SearchPresentation,
+ SearchProviderSettings, SearchRoute, SearxngConfig, SecretsConfig, SecurityConfig, ShellConfig,
+ SlackConfig, StreamMode, SttEngine, TeamModelConfig, TelegramConfig, TokenjuiceConfig,
+ UpdateConfig, UpdateRestartStrategy, VoiceActivationMode, VoiceServerConfig, WebSearchConfig,
+ WebhookConfig, YuanbaoConfig, DEFAULT_MODEL, LEGACY_TIER_MODELS, MANAGED_MULTIMODAL_MODELS,
+ MANAGED_SEARCH_PROVIDERS, MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT,
+ MODEL_MEDIA_UNDERSTANDING, MODEL_VIDEO_GENERATION_AGENT, SEARCH_ENGINE_BRAVE,
+ SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA, SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL,
+ SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY, SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER,
+ SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
};
// Kept as a separate re-export (issue #4117) so the large alphabetized group
// above stays byte-identical and rustfmt-stable.
diff --git a/crates/openhuman-core/src/config/ops/mod.rs b/crates/openhuman-core/src/config/ops/mod.rs
index fef028d7d7..a4744df5b9 100644
--- a/crates/openhuman-core/src/config/ops/mod.rs
+++ b/crates/openhuman-core/src/config/ops/mod.rs
@@ -14,10 +14,10 @@ mod ui;
pub use agent::redact_home;
pub use agent::{
add_auto_approve_tool, apply_agent_paths_settings, apply_agent_settings,
- apply_autonomy_settings, ensure_agent_dirs, ensure_usable_cwd, expand_tilde,
- get_agent_paths, get_agent_settings, get_autonomy_settings,
- load_and_apply_agent_paths_settings, load_and_apply_agent_settings,
- load_and_apply_autonomy_settings, AgentPathsPatch, AgentSettingsPatch, AutonomySettingsPatch,
+ apply_autonomy_settings, ensure_agent_dirs, ensure_usable_cwd, expand_tilde, get_agent_paths,
+ get_agent_settings, get_autonomy_settings, load_and_apply_agent_paths_settings,
+ load_and_apply_agent_settings, load_and_apply_autonomy_settings, AgentPathsPatch,
+ AgentSettingsPatch, AutonomySettingsPatch,
};
pub use loader::{
diff --git a/crates/openhuman-core/src/config/schema/agent.rs b/crates/openhuman-core/src/config/schema/agent.rs
index e2eb4d288e..0b9774e675 100644
--- a/crates/openhuman-core/src/config/schema/agent.rs
+++ b/crates/openhuman-core/src/config/schema/agent.rs
@@ -482,4 +482,3 @@ impl Default for AgentConfig {
}
}
}
-
diff --git a/crates/openhuman-core/src/config/schema/load/dirs.rs b/crates/openhuman-core/src/config/schema/load/dirs.rs
index 7cbe2cf372..b0a8e57c33 100644
--- a/crates/openhuman-core/src/config/schema/load/dirs.rs
+++ b/crates/openhuman-core/src/config/schema/load/dirs.rs
@@ -33,7 +33,6 @@ pub const PROJECTS_DIR_ENV_VAR: &str = "OPENHUMAN_PROJECTS_DIR";
/// Environment override for the agent action sandbox directory.
pub const ACTION_DIR_ENV_VAR: &str = "OPENHUMAN_ACTION_DIR";
-
fn default_root_dir_name() -> &'static str {
if crate::config::app_env::is_staging_app_env(
crate::config::app_env::app_env_from_env().as_deref(),
diff --git a/crates/openhuman-core/src/config/schema/memory.rs b/crates/openhuman-core/src/config/schema/memory.rs
index 7e88520973..aa1cc78479 100644
--- a/crates/openhuman-core/src/config/schema/memory.rs
+++ b/crates/openhuman-core/src/config/schema/memory.rs
@@ -272,8 +272,8 @@ where
pub(crate) fn decode_sources_lenient(raw: Vec<serde_json::Value>) -> Vec<MemorySourceConfig> {
raw.into_iter()
.enumerate()
- .filter_map(|(index, value)| {
- match serde_json::from_value::<MemorySourceConfig>(value) {
+ .filter_map(
+ |(index, value)| match serde_json::from_value::<MemorySourceConfig>(value) {
Ok(entry) => Some(entry),
Err(error) => {
tracing::warn!(
@@ -283,8 +283,8 @@ pub(crate) fn decode_sources_lenient(raw: Vec<serde_json::Value>) -> Vec<MemoryS
);
None
}
- }
- })
+ },
+ )
.collect()
}
diff --git a/crates/openhuman-core/src/config/schema/memory_tests.rs b/crates/openhuman-core/src/config/schema/memory_tests.rs
index 93b519aeca..af3173c182 100644
--- a/crates/openhuman-core/src/config/schema/memory_tests.rs
+++ b/crates/openhuman-core/src/config/schema/memory_tests.rs
@@ -8,8 +8,14 @@ fn defaults_select_tinyhumans_with_ingest_and_context_on() {
assert!(config.engines.is_empty());
assert!(config.sources.is_empty());
assert!(config.conversations.enabled);
- assert_eq!(config.conversations.batch_turns, DEFAULT_CONVERSATION_BATCH_TURNS);
- assert_eq!(config.conversations.idle_secs, DEFAULT_CONVERSATION_IDLE_SECS);
+ assert_eq!(
+ config.conversations.batch_turns,
+ DEFAULT_CONVERSATION_BATCH_TURNS
+ );
+ assert_eq!(
+ config.conversations.idle_secs,
+ DEFAULT_CONVERSATION_IDLE_SECS
+ );
assert!(config.context.enabled);
assert_eq!(config.context.interval_mins, DEFAULT_CONTEXT_INTERVAL_MINS);
assert_eq!(config.context.budget_tokens, DEFAULT_CONTEXT_BUDGET_TOKENS);
@@ -108,7 +114,10 @@ fn endpoint_for_ignores_blank_and_missing_endpoints() {
endpoint: Some(" https://c.example ".into()),
},
);
- assert_eq!(config.endpoint_for("cortexdb").as_deref(), Some("https://c.example"));
+ assert_eq!(
+ config.endpoint_for("cortexdb").as_deref(),
+ Some("https://c.example")
+ );
}
#[test]
@@ -120,19 +129,46 @@ fn source_kind_round_trips_its_wire_names() {
json!(kind.as_str())
);
}
- assert_eq!(MemorySourceKind::parse(" FOLDER "), Some(MemorySourceKind::Folder));
+ assert_eq!(
+ MemorySourceKind::parse(" FOLDER "),
+ Some(MemorySourceKind::Folder)
+ );
assert_eq!(MemorySourceKind::parse("twitter_query"), None);
}
#[test]
fn migrates_every_mappable_legacy_kind() {
let cases = [
- (json!({"id":"a","kind":"folder","path":"/p"}), MemorySourceKind::Folder, "/p"),
- (json!({"id":"b","kind":"file","path":"/f.md"}), MemorySourceKind::File, "/f.md"),
- (json!({"id":"c","kind":"web_page","url":"https://w"}), MemorySourceKind::Link, "https://w"),
- (json!({"id":"d","kind":"github_repo","url":"o/r"}), MemorySourceKind::Github, "o/r"),
- (json!({"id":"e","kind":"rss_feed","url":"https://f"}), MemorySourceKind::Rss, "https://f"),
- (json!({"id":"f","kind":"composio","toolkit":"gmail"}), MemorySourceKind::Composio, "gmail"),
+ (
+ json!({"id":"a","kind":"folder","path":"/p"}),
+ MemorySourceKind::Folder,
+ "/p",
+ ),
+ (
+ json!({"id":"b","kind":"file","path":"/f.md"}),
+ MemorySourceKind::File,
+ "/f.md",
+ ),
+ (
+ json!({"id":"c","kind":"web_page","url":"https://w"}),
+ MemorySourceKind::Link,
+ "https://w",
+ ),
+ (
+ json!({"id":"d","kind":"github_repo","url":"o/r"}),
+ MemorySourceKind::Github,
+ "o/r",
+ ),
+ (
+ json!({"id":"e","kind":"rss_feed","url":"https://f"}),
+ MemorySourceKind::Rss,
+ "https://f",
+ ),
+ (
+ json!({"id":"f","kind":"composio","toolkit":"gmail"}),
+ MemorySourceKind::Composio,
+ "gmail",
+ ),
];
for (legacy, kind, target) in cases {
let migrated = migrate_legacy_source(&legacy).expect("mappable kind migrates");
diff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rs
index 99ee0c2935..2424490a83 100644
--- a/crates/openhuman-core/src/config/schema/mod.rs
+++ b/crates/openhuman-core/src/config/schema/mod.rs
@@ -72,7 +72,8 @@ mod update;
mod web_chat_config;
pub use agent::{
- AgentConfig, DelegateAgentConfig, OrchestratorModelConfig, RequiredOutputContract, TeamModelConfig, ToolSearchConfig,
+ AgentConfig, DelegateAgentConfig, OrchestratorModelConfig, RequiredOutputContract,
+ TeamModelConfig, ToolSearchConfig,
};
pub use autonomy::AutonomyConfig;
pub use capability_providers::{CapabilityProviderConfig, CapabilityProviderTrustState};
@@ -89,6 +90,10 @@ pub use dashboard::{DashboardConfig, DiagramViewerConfig, EventStreamConfig, Mod
pub use dictation::{DictationActivationMode, DictationConfig};
pub use identity_cost::{CostConfig, ModelPricing};
pub use local_ai::{LocalAiConfig, LocalAiUsage};
+pub use memory::{
+ migrate_legacy_source, MemoryConfig, MemoryContextConfig, MemoryConversationsConfig,
+ MemoryEngineSettings, MemorySourceConfig, MemorySourceKind, MEMORY_CORTEXDB_KEY_NAME,
+};
pub use modules::{ModuleOverride, ModulesConfig};
pub use node::NodeConfig;
pub use observability::{AgentTracingBackend, AgentTracingConfig, ObservabilityConfig};
@@ -104,10 +109,6 @@ pub use runtime::{
};
pub use runtime_pool::{RuntimePoolConfig, RuntimePoolLangConfig};
pub use runtime_python::RuntimePythonConfig;
-pub use memory::{
- migrate_legacy_source, MemoryConfig, MemoryContextConfig, MemoryConversationsConfig,
- MemoryEngineSettings, MemorySourceConfig, MemorySourceKind, MEMORY_CORTEXDB_KEY_NAME,
-};
pub use scheduler_gate::{PauseReason, Policy, SchedulerGateConfig, SchedulerGateMode};
pub use task_sources::TaskSourcesConfig;
pub use tokenjuice::TokenjuiceConfig;
diff --git a/crates/openhuman-core/src/config/schema/types.rs b/crates/openhuman-core/src/config/schema/types.rs
index 17943ff4c1..119292d68f 100644
--- a/crates/openhuman-core/src/config/schema/types.rs
+++ b/crates/openhuman-core/src/config/schema/types.rs
@@ -12,9 +12,8 @@ mod resolvers;
pub use config::{Config, CustomEmbeddingsConfig, ModelRegistryEntry};
pub use model_ids::{
is_legacy_tier_model, legacy_tier_role, DEFAULT_MODEL, LEGACY_TIER_MODELS,
- MANAGED_MULTIMODAL_MODELS,
- MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT, MODEL_MEDIA_UNDERSTANDING,
- MODEL_VIDEO_GENERATION_AGENT, WORKLOAD_ROLES,
+ MANAGED_MULTIMODAL_MODELS, MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT,
+ MODEL_MEDIA_UNDERSTANDING, MODEL_VIDEO_GENERATION_AGENT, WORKLOAD_ROLES,
};
pub use output_language::{normalize_output_language, output_language_directive};
diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rs
index 6705b02ef2..6b4ef6b4bc 100644
--- a/crates/openhuman-core/src/config/schema/types/config.rs
+++ b/crates/openhuman-core/src/config/schema/types/config.rs
@@ -473,7 +473,6 @@ pub struct Config {
#[serde(default)]
pub model_registry: Vec<ModelRegistryEntry>,
-
}
/// Shared default so `#[serde(default)]` and `Config::default()` stay in sync.
diff --git a/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs b/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
index 66ee089fee..2a72294e51 100644
--- a/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
+++ b/crates/openhuman-core/src/config/schema/types_model_pin_tests.rs
@@ -197,7 +197,10 @@ learning_reflection = true
"#,
)
.expect("config with retired learning keys must still load");
- assert_eq!(config.workload_local_model("memory").as_deref(), Some("summary-local"));
+ assert_eq!(
+ config.workload_local_model("memory").as_deref(),
+ Some("summary-local")
+ );
assert_eq!(config.workload_local_model("learning"), None);
assert!(config.local_ai.usage.embeddings);
}
diff --git a/crates/openhuman-core/src/config/schemas/controllers/agent.rs b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
index e135499767..6a8fee84cf 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/agent.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
@@ -7,8 +7,8 @@ use crate::core::all::ControllerFuture;
use super::super::helpers::{
deserialize_params, to_json, AgentSettingsUpdate, AutonomySettingsUpdate,
- BrowserSettingsUpdate, ComputerSettingsUpdate, PrivacyModeUpdate,
- SandboxSettingsUpdate, SetBrowserAllowAllParams,
+ BrowserSettingsUpdate, ComputerSettingsUpdate, PrivacyModeUpdate, SandboxSettingsUpdate,
+ SetBrowserAllowAllParams,
};
pub(crate) fn handle_get_autonomy_settings(_params: Map<String, Value>) -> ControllerFuture {
diff --git a/crates/openhuman-core/src/config/schemas/controllers/registry.rs b/crates/openhuman-core/src/config/schemas/controllers/registry.rs
index 57b909ecd4..3355079932 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/registry.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/registry.rs
@@ -5,11 +5,10 @@ use crate::core::ControllerSchema;
use super::super::schema_defs::schemas;
use super::agent::{
- handle_get_agent_settings, handle_get_autonomy_settings,
- handle_get_privacy_mode, handle_get_sandbox_settings, handle_set_browser_allow_all,
- handle_set_privacy_mode, handle_update_agent_settings, handle_update_autonomy_settings,
- handle_update_browser_settings, handle_update_computer_settings,
- handle_update_sandbox_settings,
+ handle_get_agent_settings, handle_get_autonomy_settings, handle_get_privacy_mode,
+ handle_get_sandbox_settings, handle_set_browser_allow_all, handle_set_privacy_mode,
+ handle_update_agent_settings, handle_update_autonomy_settings, handle_update_browser_settings,
+ handle_update_computer_settings, handle_update_sandbox_settings,
};
use super::inference::{
handle_get_client_config, handle_get_config, handle_get_runtime_flags, handle_resolve_api_url,
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index a68112943a..000f97823c 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -1080,9 +1080,7 @@ pub fn schema_for_rpc_method(method: &str) -> Option<ControllerSchema> {
let found = view
.iter()
.chain(internal_registry().iter())
- .find(|g| {
- g.controller.rpc_method_name() == method && group_allowed(g.group)
- })
+ .find(|g| g.controller.rpc_method_name() == method && group_allowed(g.group))
.map(|g| g.controller.schema.clone());
found
}
diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rs
index bf9ce34544..f3c6e83588 100644
--- a/crates/openhuman-core/src/core/all_tests.rs
+++ b/crates/openhuman-core/src/core/all_tests.rs
@@ -197,10 +197,7 @@ fn all_controller_schemas_matches_registered_count() {
// Take one registry snapshot: extensions may register concurrently between
// two public lookups, so comparing separate snapshots is racy.
let view = registry_view();
- let visible: Vec<_> = view
- .iter()
- .filter(|g| group_allowed(g.group))
- .collect();
+ let visible: Vec<_> = view.iter().filter(|g| group_allowed(g.group)).collect();
let schemas = visible.iter().map(|g| &g.controller.schema).count();
let controllers = visible.len();
assert_eq!(schemas, controllers);
diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rs
index 5a5539d66d..19fbd10c50 100644
--- a/crates/openhuman-core/src/core/cli.rs
+++ b/crates/openhuman-core/src/core/cli.rs
@@ -675,9 +675,7 @@ fn print_general_help(grouped: &BTreeMap<String, Vec<ControllerSchema>>) {
println!(" openhuman [OPTIONS] (show this help)");
println!(" openhuman run [--host <addr>] [--port <u16>] [--jsonrpc-only] [--verbose]");
println!(" openhuman call --method <name> [--params '<json>' | --params-stdin]");
- println!(
- " openhuman mcp [-v|--verbose] (stdio MCP server)"
- );
+ println!(" openhuman mcp [-v|--verbose] (stdio MCP server)");
println!(" openhuman-tui [--thread <id>|--new] (terminal UI; separate executable)");
println!(" openhuman skills <subcommand> [options] (skill development runtime)");
println!(" openhuman agent <subcommand> [options] (inspect agent definitions & prompts)");
diff --git a/crates/openhuman-core/src/core/cli_tests.rs b/crates/openhuman-core/src/core/cli_tests.rs
index 37a3fd2549..ced61fd74d 100644
--- a/crates/openhuman-core/src/core/cli_tests.rs
+++ b/crates/openhuman-core/src/core/cli_tests.rs
@@ -335,4 +335,3 @@ fn default_build_leaves_the_generic_namespace_path_unchanged() {
"`memory_diff` was removed and must not be listed"
);
}
-
diff --git a/crates/openhuman-core/src/core/envelope.rs b/crates/openhuman-core/src/core/envelope.rs
index 2c52c55beb..368784b9e6 100644
--- a/crates/openhuman-core/src/core/envelope.rs
+++ b/crates/openhuman-core/src/core/envelope.rs
@@ -73,7 +73,9 @@ pub(crate) fn request_id() -> String {
}
/// Named counts for an envelope's `meta.counts`.
-pub(crate) fn counts(entries: impl IntoIterator<Item = (&'static str, usize)>) -> BTreeMap<String, usize> {
+pub(crate) fn counts(
+ entries: impl IntoIterator<Item = (&'static str, usize)>,
+) -> BTreeMap<String, usize> {
entries
.into_iter()
.map(|(key, value)| (key.to_string(), value))
diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rs
index 008772c370..aee3a915a3 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -284,7 +284,6 @@ pub enum DomainEvent {
/// A memory recall query completed.
MemoryRecalled { query: String, hit_count: usize },
-
// ── Channels ────────────────────────────────────────────────────────
/// An inbound channel message from the transport layer, ready for processing.
///
@@ -957,8 +956,6 @@ pub enum DomainEvent {
reason: String,
},
-
-
// ── Notification ────────────────────────────────────────────────────
/// An integration notification was ingested from an embedded webview.
NotificationIngested {
@@ -997,7 +994,6 @@ pub enum DomainEvent {
payload_b64: String,
},
-
// ── MCP Clients ─────────────────────────────────────────────────────
/// A new MCP server was installed from the Smithery registry.
McpServerInstalled {
diff --git a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs b/crates/openhuman-core/src/core/runtime/subscribers_tests.rs
index 3b3c3cfee0..29c771dffa 100644
--- a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/subscribers_tests.rs
@@ -1,6 +1,4 @@
-use super::{
- group_first_time_when_bus_ready, DomainSubscriberPlan,
-};
+use super::{group_first_time_when_bus_ready, DomainSubscriberPlan};
use crate::config::test_env::EnvVarGuard;
// ---- domain-subscriber gating (#4796 DoD item 3) ----------------------------
diff --git a/crates/openhuman-core/src/cron/mod.rs b/crates/openhuman-core/src/cron/mod.rs
index 2e1d3dfe10..2a823f603a 100644
--- a/crates/openhuman-core/src/cron/mod.rs
+++ b/crates/openhuman-core/src/cron/mod.rs
@@ -13,8 +13,8 @@ pub mod bus;
pub mod ops;
mod schemas;
pub mod seed;
-pub mod system_jobs;
mod store;
+pub mod system_jobs;
pub mod tools;
pub mod scheduler;
diff --git a/crates/openhuman-core/src/cron/scheduler_gate/gate.rs b/crates/openhuman-core/src/cron/scheduler_gate/gate.rs
index adeb89c379..a458391700 100644
--- a/crates/openhuman-core/src/cron/scheduler_gate/gate.rs
+++ b/crates/openhuman-core/src/cron/scheduler_gate/gate.rs
@@ -13,9 +13,9 @@ use std::sync::{Arc, OnceLock};
use parking_lot::RwLock;
use tokio::sync::{Notify, Semaphore};
-use crate::config::SchedulerGateConfig;
use super::signals::SignalEnv;
use super::throttle::{GateCore, SharedCore, LLM_SLOTS};
+use crate::config::SchedulerGateConfig;
pub use super::decide::Signals;
pub use super::throttle::LlmPermit;
diff --git a/crates/openhuman-core/src/cron/scheduler_gate/throttle_tests.rs b/crates/openhuman-core/src/cron/scheduler_gate/throttle_tests.rs
index 5a851221e4..10d4a53555 100644
--- a/crates/openhuman-core/src/cron/scheduler_gate/throttle_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_gate/throttle_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use std::sync::atomic::{AtomicBool, Ordering};
use crate::config::schema::SchedulerGateMode;
+use std::sync::atomic::{AtomicBool, Ordering};
fn calm() -> Signals {
Signals {
diff --git a/crates/openhuman-core/src/cron/system_jobs.rs b/crates/openhuman-core/src/cron/system_jobs.rs
index 78cbd48f05..b9130c4eba 100644
--- a/crates/openhuman-core/src/cron/system_jobs.rs
+++ b/crates/openhuman-core/src/cron/system_jobs.rs
@@ -17,7 +17,9 @@ use anyhow::Result;
use crate::config::Config;
use crate::memory::bus::{CONTEXT_REFRESH_JOB, SOURCES_SYNC_JOB};
-use super::{add_flow_schedule_job, list_jobs, update_job, CronJob, CronJobPatch, JobType, Schedule};
+use super::{
+ add_flow_schedule_job, list_jobs, update_job, CronJob, CronJobPatch, JobType, Schedule,
+};
/// Command prefix that marks a `flow` row as a system job.
pub const SYSTEM_COMMAND_PREFIX: &str = "system:";
diff --git a/crates/openhuman-core/src/cron/system_jobs_tests.rs b/crates/openhuman-core/src/cron/system_jobs_tests.rs
index 19019ab58d..7a4cfefb27 100644
--- a/crates/openhuman-core/src/cron/system_jobs_tests.rs
+++ b/crates/openhuman-core/src/cron/system_jobs_tests.rs
@@ -117,9 +117,15 @@ fn ensure_memory_jobs_seeds_both_jobs_and_follows_the_context_interval() {
// Re-running changes nothing; a new interval reschedules only the refresh.
ensure_memory_jobs(&config).unwrap();
- assert_eq!(system_rows(&config, CONTEXT_REFRESH_JOB)[0].id, refresh[0].id);
+ assert_eq!(
+ system_rows(&config, CONTEXT_REFRESH_JOB)[0].id,
+ refresh[0].id
+ );
config.memory.context.interval_mins = 120;
ensure_memory_jobs(&config).unwrap();
- assert_eq!(system_rows(&config, CONTEXT_REFRESH_JOB)[0].schedule, every(120));
+ assert_eq!(
+ system_rows(&config, CONTEXT_REFRESH_JOB)[0].schedule,
+ every(120)
+ );
assert_eq!(system_rows(&config, SOURCES_SYNC_JOB)[0].id, sync[0].id);
}
diff --git a/crates/openhuman-core/src/desktop/provider_surfaces/ops.rs b/crates/openhuman-core/src/desktop/provider_surfaces/ops.rs
index 4bf661a356..2dede5f018 100644
--- a/crates/openhuman-core/src/desktop/provider_surfaces/ops.rs
+++ b/crates/openhuman-core/src/desktop/provider_surfaces/ops.rs
@@ -3,8 +3,8 @@
//! This initial cut keeps state in-memory so the RPC contract and UI wiring
//! can land before the SQLite-backed store arrives.
-use crate::core::Outcome;
use crate::core::envelope::{ApiEnvelope, EmptyRequest};
+use crate::core::Outcome;
use serde::Serialize;
use std::collections::BTreeMap;
diff --git a/crates/openhuman-core/src/desktop/provider_surfaces/schemas.rs b/crates/openhuman-core/src/desktop/provider_surfaces/schemas.rs
index a379e1f20d..50031458f4 100644
--- a/crates/openhuman-core/src/desktop/provider_surfaces/schemas.rs
+++ b/crates/openhuman-core/src/desktop/provider_surfaces/schemas.rs
@@ -7,8 +7,8 @@ use serde::de::DeserializeOwned;
use serde_json::{Map, Value};
use crate::core::all::RegisteredController;
-use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use crate::core::envelope::EmptyRequest;
+use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use super::ops;
use super::types::ProviderEvent;
diff --git a/crates/openhuman-core/src/inference/embedding_host/schemas.rs b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
index 377f49fe72..b5a6feabf3 100644
--- a/crates/openhuman-core/src/inference/embedding_host/schemas.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
@@ -55,7 +55,10 @@ pub fn schemas(function: &str) -> ControllerSchema {
function: "get_settings",
description: "Get current embedding settings and provider catalog.",
inputs: vec![],
- outputs: vec![json_output("settings", "Embedding settings and provider catalog.")],
+ outputs: vec![json_output(
+ "settings",
+ "Embedding settings and provider catalog.",
+ )],
},
"update_settings" => ControllerSchema {
namespace: "embeddings",
@@ -65,7 +68,10 @@ pub fn schemas(function: &str) -> ControllerSchema {
optional_string("provider", "Embedding provider slug."),
optional_string("model", "Model identifier."),
optional_u64("dimensions", "Output vector dimensions."),
- optional_string("custom_endpoint", "Custom endpoint URL (for custom provider)."),
+ optional_string(
+ "custom_endpoint",
+ "Custom endpoint URL (for custom provider).",
+ ),
optional_u64("rate_limit_per_min", "Rate limit in requests per minute."),
],
outputs: vec![json_output("result", "Updated settings.")],
@@ -75,7 +81,10 @@ pub fn schemas(function: &str) -> ControllerSchema {
function: "set_api_key",
description: "Store an API key for an embedding provider.",
inputs: vec![
- required_string("provider", "Provider slug (e.g. voyage, openai, cohere, custom)."),
+ required_string(
+ "provider",
+ "Provider slug (e.g. voyage, openai, cohere, custom).",
+ ),
required_string("api_key", "The API key to store."),
],
outputs: vec![json_output("result", "Storage confirmation.")],
@@ -84,9 +93,7 @@ pub fn schemas(function: &str) -> ControllerSchema {
namespace: "embeddings",
function: "clear_api_key",
description: "Remove the stored API key for an embedding provider.",
- inputs: vec![
- required_string("provider", "Provider slug."),
- ],
+ inputs: vec![required_string("provider", "Provider slug.")],
outputs: vec![json_output("result", "Removal confirmation.")],
},
"embed" => ControllerSchema {
diff --git a/crates/openhuman-core/src/memory/bus.rs b/crates/openhuman-core/src/memory/bus.rs
index bd9549c398..eaa1c29512 100644
--- a/crates/openhuman-core/src/memory/bus.rs
+++ b/crates/openhuman-core/src/memory/bus.rs
@@ -86,7 +86,9 @@ impl EventHandler<DomainEvent> for ConversationIngestSubscriber {
};
match crate::config::rpc::load_config_for_workspace_with_timeout(workspace_dir).await {
Ok(config) => super::conversations::record_turn(&config, turn).await,
- Err(error) => tracing::debug!(error = %error, "[memory:bus] config unavailable; turn dropped"),
+ Err(error) => {
+ tracing::debug!(error = %error, "[memory:bus] config unavailable; turn dropped")
+ }
}
}
}
@@ -135,7 +137,10 @@ pub async fn run_system_job(config: &crate::config::Config, job: &str) {
}
SOURCES_SYNC_JOB => {
let started = super::sources::sync_due(config, Utc::now());
- tracing::debug!(started = started.len(), "[memory:bus] due source syncs started");
+ tracing::debug!(
+ started = started.len(),
+ "[memory:bus] due source syncs started"
+ );
}
_ => {}
}
diff --git a/crates/openhuman-core/src/memory/bus_tests.rs b/crates/openhuman-core/src/memory/bus_tests.rs
index ffc14b2799..2c02f3030e 100644
--- a/crates/openhuman-core/src/memory/bus_tests.rs
+++ b/crates/openhuman-core/src/memory/bus_tests.rs
@@ -87,13 +87,16 @@ async fn run_system_job_starts_due_source_syncs() {
let folder = tmp.path().join("notes");
std::fs::create_dir_all(&folder).unwrap();
std::fs::write(folder.join("a.md"), "# Notes\n\nthe due source says hello").unwrap();
- config.memory.sources.push(crate::config::schema::MemorySourceConfig {
- id: "src-due".into(),
- kind: crate::config::schema::MemorySourceKind::Folder,
- target: folder.display().to_string(),
- label: "Notes".into(),
- schedule_mins: Some(15),
- });
+ config
+ .memory
+ .sources
+ .push(crate::config::schema::MemorySourceConfig {
+ id: "src-due".into(),
+ kind: crate::config::schema::MemorySourceKind::Folder,
+ target: folder.display().to_string(),
+ label: "Notes".into(),
+ schedule_mins: Some(15),
+ });
run_system_job(&config, SOURCES_SYNC_JOB).await;
// The sync runs in the background; wait for its recorded state.
for _ in 0..200 {
@@ -129,7 +132,9 @@ async fn system_jobs_subscriber_only_reacts_to_memory_jobs() {
let path = crate::memory::context::context_path(&config.workspace_dir);
CoreContext::scope(ctx, async {
subscriber
- .handle(&DomainEvent::CronSystemJobDue { job: "other".into() })
+ .handle(&DomainEvent::CronSystemJobDue {
+ job: "other".into(),
+ })
.await;
assert!(!path.exists(), "a foreign job does nothing");
subscriber
@@ -138,7 +143,9 @@ async fn system_jobs_subscriber_only_reacts_to_memory_jobs() {
})
.await;
assert!(path.exists(), "the refresh job ran");
- subscriber.handle(&turn_event(std::path::Path::new("/x"), "t")).await;
+ subscriber
+ .handle(&turn_event(std::path::Path::new("/x"), "t"))
+ .await;
})
.await;
}
@@ -148,7 +155,10 @@ async fn ingest_subscriber_stores_a_committed_turn_with_names_and_ids_only() {
let tmp = tempfile::tempdir().unwrap();
let mut config = config_in(&tmp);
config.memory.conversations.batch_turns = 1;
- config.save().await.expect("config saved beside the workspace");
+ config
+ .save()
+ .await
+ .expect("config saved beside the workspace");
let engine = bind_reference(&config);
ConversationIngestSubscriber
diff --git a/crates/openhuman-core/src/memory/conversations/buffer.rs b/crates/openhuman-core/src/memory/conversations/buffer.rs
index 18c8861769..230ebded29 100644
--- a/crates/openhuman-core/src/memory/conversations/buffer.rs
+++ b/crates/openhuman-core/src/memory/conversations/buffer.rs
@@ -9,7 +9,9 @@
use std::collections::HashMap;
use chrono::{DateTime, Duration, Utc};
-use tinymemory::{MemoryMeta, Role, SourceKind, SourceRef, StoreItem, ToolCallRef, Turn, TurnRange};
+use tinymemory::{
+ MemoryMeta, Role, SourceKind, SourceRef, StoreItem, ToolCallRef, Turn, TurnRange,
+};
/// One committed exchange: the user's message and the assistant's reply.
#[derive(Debug, Clone, PartialEq)]
@@ -66,7 +68,11 @@ impl Batch {
#[must_use]
pub fn into_item(self) -> StoreItem {
let last = self.last();
- let agent_id = self.turns.iter().rev().find_map(|turn| turn.agent_id.clone());
+ let agent_id = self
+ .turns
+ .iter()
+ .rev()
+ .find_map(|turn| turn.agent_id.clone());
let workspace = self
.turns
.iter()
diff --git a/crates/openhuman-core/src/memory/conversations/buffer_tests.rs b/crates/openhuman-core/src/memory/conversations/buffer_tests.rs
index 622220fa92..5c97408e14 100644
--- a/crates/openhuman-core/src/memory/conversations/buffer_tests.rs
+++ b/crates/openhuman-core/src/memory/conversations/buffer_tests.rs
@@ -43,7 +43,9 @@ fn threads_are_batched_independently() {
let mut buffer = ConversationBuffer::default();
assert!(buffer.push(turn("a", "1", "1", 0), 0, 2).is_none());
assert!(buffer.push(turn("b", "1", "1", 0), 0, 2).is_none());
- let full = buffer.push(turn("a", "2", "2", 1), 1, 2).expect("a is full");
+ let full = buffer
+ .push(turn("a", "2", "2", 1), 1, 2)
+ .expect("a is full");
assert_eq!(full.thread_id, "a");
assert_eq!(buffer.pending("a"), 0);
assert_eq!(buffer.pending("b"), 1);
@@ -124,7 +126,13 @@ fn into_item_carries_meta_and_keeps_tool_call_names_and_ids_only() {
assert_eq!(meta.thread_id.as_deref(), Some("thread-9"));
assert_eq!(meta.agent_id.as_deref(), Some("orchestrator"));
assert_eq!(meta.workspace.as_deref(), Some("/work"));
- assert_eq!(meta.turns, Some(TurnRange { first: 10, last: 11 }));
+ assert_eq!(
+ meta.turns,
+ Some(TurnRange {
+ first: 10,
+ last: 11
+ })
+ );
assert_eq!(meta.source.kind, SourceKind::Conversation);
assert_eq!(meta.source.id.as_deref(), Some("thread-9"));
assert_eq!(meta.tags, vec!["channel:web".to_string()]);
@@ -140,7 +148,10 @@ fn into_item_carries_meta_and_keeps_tool_call_names_and_ids_only() {
assert!(turns[0].tool_calls.is_empty());
// The serialised item has no place for arguments.
let json = serde_json::to_string(&turns[1].tool_calls).unwrap();
- assert!(!json.contains("arguments") && !json.contains("args"), "{json}");
+ assert!(
+ !json.contains("arguments") && !json.contains("args"),
+ "{json}"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/memory/conversations/mod.rs b/crates/openhuman-core/src/memory/conversations/mod.rs
index 055098b62e..6bbf5edebd 100644
--- a/crates/openhuman-core/src/memory/conversations/mod.rs
+++ b/crates/openhuman-core/src/memory/conversations/mod.rs
@@ -62,7 +62,9 @@ struct ThreadCounter {
}
fn state_path(workspace_dir: &Path) -> PathBuf {
- workspace_dir.join("memory").join("conversations_state.json")
+ workspace_dir
+ .join("memory")
+ .join("conversations_state.json")
}
fn read_state(workspace_dir: &Path) -> ConversationsState {
@@ -92,7 +94,9 @@ fn write_state(workspace_dir: &Path, state: &ConversationsState) {
/// Claims the next turn index of `thread_id`.
fn next_turn_index(workspace_dir: &Path, thread_id: &str, now: DateTime<Utc>) -> u32 {
- let _guard = STATE_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let _guard = STATE_LOCK
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
let mut state = read_state(workspace_dir);
let counter = state
.threads
@@ -121,7 +125,9 @@ fn next_turn_index(workspace_dir: &Path, thread_id: &str, now: DateTime<Utc>) ->
}
fn remember_stored(workspace_dir: &Path, batch: &Batch, stored_at: DateTime<Utc>) {
- let _guard = STATE_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let _guard = STATE_LOCK
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
let mut state = read_state(workspace_dir);
state.recent.insert(
0,
@@ -156,7 +162,9 @@ pub async fn record_turn(config: &Config, turn: CommittedTurn) {
}
let index = next_turn_index(&config.workspace_dir, &turn.thread_id, turn.at);
let ready = {
- let mut buffers = BUFFERS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let mut buffers = BUFFERS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
buffers
.entry(config.workspace_dir.clone())
.or_default()
@@ -170,7 +178,9 @@ pub async fn record_turn(config: &Config, turn: CommittedTurn) {
/// Stores every thread idle for `idle_secs` at `now`.
pub async fn flush_idle(config: &Config, now: DateTime<Utc>) -> usize {
let ready = {
- let mut buffers = BUFFERS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let mut buffers = BUFFERS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
buffers
.get_mut(&config.workspace_dir)
.map(|buffer| buffer.take_idle(now, config.memory.conversations.idle_secs))
@@ -187,7 +197,9 @@ pub async fn flush_idle(config: &Config, now: DateTime<Utc>) -> usize {
/// off, so nothing buffered is silently lost).
pub async fn flush_all(config: &Config) -> usize {
let ready = {
- let mut buffers = BUFFERS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ let mut buffers = BUFFERS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
buffers
.get_mut(&config.workspace_dir)
.map(ConversationBuffer::take_all)
@@ -247,7 +259,10 @@ pub async fn forget_channel(config: &Config, channel: &str) -> MemoryResult<usiz
.engine
.forget(tinymemory::ForgetTarget::Filter(filter))
.await?;
- tracing::debug!(forgotten = report.forgotten, "[memory:conversations] channel forgotten");
+ tracing::debug!(
+ forgotten = report.forgotten,
+ "[memory:conversations] channel forgotten"
+ );
Ok(report.forgotten)
}
diff --git a/crates/openhuman-core/src/memory/conversations/mod_tests.rs b/crates/openhuman-core/src/memory/conversations/mod_tests.rs
index 1d2f5aa88b..2d1b7df646 100644
--- a/crates/openhuman-core/src/memory/conversations/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/conversations/mod_tests.rs
@@ -19,7 +19,9 @@ fn turn(thread: &str, text: &str, at: DateTime<Utc>) -> CommittedTurn {
}
}
-async fn conversations_in(engine: &tinymemory::conformance::ReferenceEngine) -> Vec<tinymemory::Hit> {
+async fn conversations_in(
+ engine: &tinymemory::conformance::ReferenceEngine,
+) -> Vec<tinymemory::Hit> {
stored(
engine,
MetaFilter {
@@ -76,14 +78,23 @@ async fn idle_threads_are_flushed_without_waiting_on_a_clock() {
let started = Utc::now();
record_turn(&config, turn("t-idle", "hello", started)).await;
- assert_eq!(flush_idle(&config, started + Duration::seconds(119)).await, 0);
+ assert_eq!(
+ flush_idle(&config, started + Duration::seconds(119)).await,
+ 0
+ );
assert!(conversations_in(&engine).await.is_empty());
assert_eq!(pending_turns(&config.workspace_dir, "t-idle"), 1);
- assert_eq!(flush_idle(&config, started + Duration::seconds(120)).await, 1);
+ assert_eq!(
+ flush_idle(&config, started + Duration::seconds(120)).await,
+ 1
+ );
assert_eq!(conversations_in(&engine).await.len(), 1);
assert_eq!(pending_turns(&config.workspace_dir, "t-idle"), 0);
- assert_eq!(flush_idle(&config, started + Duration::seconds(500)).await, 0);
+ assert_eq!(
+ flush_idle(&config, started + Duration::seconds(500)).await,
+ 0
+ );
}
#[tokio::test]
@@ -198,7 +209,10 @@ fn thread_counters_are_pruned_oldest_first() {
let after = read_state(ws);
assert_eq!(after.threads.len(), THREAD_COUNTER_LIMIT);
assert!(after.threads.contains_key("fresh"));
- assert!(!after.threads.contains_key("old-0000"), "the oldest went first");
+ assert!(
+ !after.threads.contains_key("old-0000"),
+ "the oldest went first"
+ );
}
#[test]
@@ -229,7 +243,9 @@ async fn forget_channel_removes_only_that_channels_conversations() {
let tmp_off = tempfile::tempdir().unwrap();
assert_eq!(
- forget_channel(&config_in(&tmp_off), "telegram").await.unwrap(),
+ forget_channel(&config_in(&tmp_off), "telegram")
+ .await
+ .unwrap(),
0,
"memory off forgets nothing and is not an error"
);
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index f4e99f6bda..e10fa51fc3 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -135,7 +135,11 @@ pub fn resolve(config: &Config) -> Binding {
"" => off(None, None, "no memory engine selected"),
other => {
tracing::warn!(engine = %other, "[memory:engine] unknown engine id in config");
- off(None, None, "the configured memory engine is not available in this build")
+ off(
+ None,
+ None,
+ "the configured memory engine is not available in this build",
+ )
}
}
}
@@ -161,7 +165,11 @@ fn resolve_tinyhumans(config: &Config) -> Binding {
Ok(url) => url,
Err(error) => {
tracing::debug!(error = %error, "[memory:engine] no backend origin for tinyhumans");
- return off(Some(TINYHUMANS_ENGINE), None, "no TinyHumans backend is available");
+ return off(
+ Some(TINYHUMANS_ENGINE),
+ None,
+ "no TinyHumans backend is available",
+ );
}
},
};
@@ -172,7 +180,10 @@ fn resolve_tinyhumans(config: &Config) -> Binding {
"sign in to use TinyHumans memory",
);
}
- let fingerprint = format!("{TINYHUMANS_ENGINE}|{endpoint}|{}", config.config_path.display());
+ let fingerprint = format!(
+ "{TINYHUMANS_ENGINE}|{endpoint}|{}",
+ config.config_path.display()
+ );
let source: Arc<dyn BearerSource> = Arc::new(HostBearer {
config: Arc::new(config.clone()),
});
@@ -257,7 +268,11 @@ fn build_cached(
/// A short, non-reversible identity of a key for the cache fingerprint.
fn key_digest(key: &str) -> String {
let digest = Sha256::digest(key.as_bytes());
- digest.iter().take(8).map(|byte| format!("{byte:02x}")).collect()
+ digest
+ .iter()
+ .take(8)
+ .map(|byte| format!("{byte:02x}"))
+ .collect()
}
/// Drops every cached engine, so the next [`resolve`] rebuilds.
diff --git a/crates/openhuman-core/src/memory/engine_tests.rs b/crates/openhuman-core/src/memory/engine_tests.rs
index 222f9d85c7..f5bd0d5c96 100644
--- a/crates/openhuman-core/src/memory/engine_tests.rs
+++ b/crates/openhuman-core/src/memory/engine_tests.rs
@@ -53,7 +53,10 @@ fn tinyhumans_with_the_host_credential_binds_and_caches() {
assert_eq!(first.id, TINYHUMANS_ENGINE);
assert_eq!(first.endpoint, "https://memory.example.test");
let second = resolve(&config).engine().expect("bound again");
- assert!(Arc::ptr_eq(&first.engine, &second.engine), "cached engine reused");
+ assert!(
+ Arc::ptr_eq(&first.engine, &second.engine),
+ "cached engine reused"
+ );
}
#[test]
@@ -77,7 +80,10 @@ fn cortexdb_is_off_until_a_key_is_stored_and_rebuilds_on_a_new_key() {
assert!(!has_key(&config, CORTEXDB_ENGINE));
store_cortexdb_key(&config, " cdb-key-one ").unwrap();
- assert_eq!(read_cortexdb_key(&config).unwrap().as_deref(), Some("cdb-key-one"));
+ assert_eq!(
+ read_cortexdb_key(&config).unwrap().as_deref(),
+ Some("cdb-key-one")
+ );
assert!(has_key(&config, CORTEXDB_ENGINE));
let first = resolve(&config).engine().expect("bound");
assert_eq!(first.id, CORTEXDB_ENGINE);
diff --git a/crates/openhuman-core/src/memory/exit.rs b/crates/openhuman-core/src/memory/exit.rs
index cb7941ac1d..cf44f14ca0 100644
--- a/crates/openhuman-core/src/memory/exit.rs
+++ b/crates/openhuman-core/src/memory/exit.rs
@@ -29,9 +29,7 @@ pub async fn run_within(config: &Config, budget: Duration) -> Option<usize> {
Some(flushed)
}
Err(_) => {
- log::warn!(
- "[memory:exit] conversation flush exceeded {budget:?}; dropping the rest"
- );
+ log::warn!("[memory:exit] conversation flush exceeded {budget:?}; dropping the rest");
None
}
}
diff --git a/crates/openhuman-core/src/memory/exit_tests.rs b/crates/openhuman-core/src/memory/exit_tests.rs
index 1aacf3cc66..6e0e0dc349 100644
--- a/crates/openhuman-core/src/memory/exit_tests.rs
+++ b/crates/openhuman-core/src/memory/exit_tests.rs
@@ -27,10 +27,16 @@ async fn stores_buffered_turns_on_exit() {
let engine = bind_reference(&config);
conversations::record_turn(&config, turn("t-exit")).await;
- assert_eq!(conversations::pending_turns(&config.workspace_dir, "t-exit"), 1);
+ assert_eq!(
+ conversations::pending_turns(&config.workspace_dir, "t-exit"),
+ 1
+ );
assert_eq!(run(&config).await, Some(1));
- assert_eq!(conversations::pending_turns(&config.workspace_dir, "t-exit"), 0);
+ assert_eq!(
+ conversations::pending_turns(&config.workspace_dir, "t-exit"),
+ 0
+ );
let items = stored(
&engine,
MetaFilter {
@@ -46,5 +52,8 @@ async fn stores_buffered_turns_on_exit() {
async fn nothing_buffered_flushes_nothing() {
let tmp = tempfile::tempdir().expect("tempdir");
let config = config_in(&tmp);
- assert_eq!(run_within(&config, Duration::from_millis(500)).await, Some(0));
+ assert_eq!(
+ run_within(&config, Duration::from_millis(500)).await,
+ Some(0)
+ );
}
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index 72dd15a638..69eb4f4531 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -220,12 +220,18 @@ async fn run(workspace_dir: &Path, bound: &BoundEngine, mut file: ImportFile) {
let _ = reader.await;
match failure {
Some(error) => {
- tracing::warn!(imported = file.state.imported, "[memory:import] import stopped");
+ tracing::warn!(
+ imported = file.state.imported,
+ "[memory:import] import stopped"
+ );
file.state.phase = ImportPhase::Error;
file.state.error = Some(error);
}
None => {
- tracing::info!(imported = file.state.imported, "[memory:import] import finished");
+ tracing::info!(
+ imported = file.state.imported,
+ "[memory:import] import finished"
+ );
file.state.phase = ImportPhase::Done;
file.state.error = None;
}
diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rs
index 46843dfea7..475ee90912 100644
--- a/crates/openhuman-core/src/memory/import_tests.rs
+++ b/crates/openhuman-core/src/memory/import_tests.rs
@@ -36,7 +36,10 @@ fn legacy_workspace(workspace_dir: &Path) {
memory_doc(&conn, "d1", "notes", "Plan", "Ship memory v2 on Friday");
memory_doc(&conn, "d2", "notes", "Ideas", "Try oolong tea");
memory_doc(&conn, "d3", "learning:style", "Style", "Keep answers terse");
- for (n, (role, text)) in [("user", "hi there"), ("assistant", "hello")].iter().enumerate() {
+ for (n, (role, text)) in [("user", "hi there"), ("assistant", "hello")]
+ .iter()
+ .enumerate()
+ {
conn.execute(
"INSERT INTO episodic_log (session_id, timestamp, role, content) VALUES ('s1', ?1, ?2, ?3)",
params![1_700_000_000.0 + n as f64, role, text],
@@ -117,7 +120,10 @@ async fn start_needs_memory_on_and_a_legacy_store() {
for _ in 0..2 {
// The claim is released, so asking again gives the same answer rather
// than a stale "already running" status.
- assert_eq!(start(&empty, true).await.unwrap_err().code(), INVALID_REQUEST);
+ assert_eq!(
+ start(&empty, true).await.unwrap_err().code(),
+ INVALID_REQUEST
+ );
}
}
@@ -177,7 +183,9 @@ async fn an_interrupted_import_resumes_from_its_checkpoint() {
let items = stored(&engine, MetaFilter::default()).await;
assert_eq!(items.len(), 4, "d1 is not sent again");
assert!(
- !items.iter().any(|item| item.text.contains("Ship memory v2")),
+ !items
+ .iter()
+ .any(|item| item.text.contains("Ship memory v2")),
"the checkpointed document was skipped"
);
}
diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rs
index 7256bab9d8..bd8cd7696b 100644
--- a/crates/openhuman-core/src/memory/ops.rs
+++ b/crates/openhuman-core/src/memory/ops.rs
@@ -49,7 +49,9 @@ pub async fn engine_get(config: &Config) -> EngineView {
let health = bound.engine.health().await;
let (status, reason) = match health {
tinymemory::EngineHealth::Ok => (EngineStatus::Ok, None),
- tinymemory::EngineHealth::Degraded(reason) => (EngineStatus::Degraded, Some(reason)),
+ tinymemory::EngineHealth::Degraded(reason) => {
+ (EngineStatus::Degraded, Some(reason))
+ }
tinymemory::EngineHealth::Down(reason) => (EngineStatus::Down, Some(reason)),
};
tracing::debug!(engine = %bound.id, ?status, "[memory:ops] engine_get");
@@ -233,8 +235,18 @@ fn merge_meta(meta: &mut MemoryMeta, host: MemoryMeta) {
)*};
}
take!(
- workspace, folder, file_path, language, repo, commit, url, thread_id, turns, agent_id,
- tool_call, observed_at
+ workspace,
+ folder,
+ file_path,
+ language,
+ repo,
+ commit,
+ url,
+ thread_id,
+ turns,
+ agent_id,
+ tool_call,
+ observed_at
);
meta.source = host.source;
for tag in host.tags {
@@ -252,9 +264,7 @@ pub async fn learn(
) -> MemoryResult<LearnView> {
let item = learning_item(params, host_meta)?;
let receipt = store_item(config, item).await?;
- Ok(LearnView {
- id: receipt.id.0,
- })
+ Ok(LearnView { id: receipt.id.0 })
}
/// Scrubs `item` and stores it on the bound engine.
diff --git a/crates/openhuman-core/src/memory/ops_tests.rs b/crates/openhuman-core/src/memory/ops_tests.rs
index 98d745c816..840b5331ca 100644
--- a/crates/openhuman-core/src/memory/ops_tests.rs
+++ b/crates/openhuman-core/src/memory/ops_tests.rs
@@ -44,12 +44,19 @@ async fn every_engine_operation_reports_memory_off_without_an_engine() {
.unwrap_err();
assert_eq!(fetch_error.code(), MEMORY_OFF);
- let learn_error = learn(&config, learn_params("a fact"), None).await.unwrap_err();
- assert_eq!(learn_error.code(), MEMORY_OFF);
-
- let forget_error = forget(&config, ForgetParams { ids: vec!["a".into()] })
+ let learn_error = learn(&config, learn_params("a fact"), None)
.await
.unwrap_err();
+ assert_eq!(learn_error.code(), MEMORY_OFF);
+
+ let forget_error = forget(
+ &config,
+ ForgetParams {
+ ids: vec!["a".into()],
+ },
+ )
+ .await
+ .unwrap_err();
assert_eq!(forget_error.code(), MEMORY_OFF);
let list_error = items_list(&config, ItemsListParams::default())
@@ -74,9 +81,13 @@ async fn learn_recall_fetch_list_and_forget_round_trip() {
let config = config_in(&tmp);
let engine = bind_reference(&config);
- let learned = learn(&config, learn_params("The user prefers dark roast coffee"), None)
- .await
- .unwrap();
+ let learned = learn(
+ &config,
+ learn_params("The user prefers dark roast coffee"),
+ None,
+ )
+ .await
+ .unwrap();
assert!(!learned.id.is_empty());
let answer = recall(
@@ -108,7 +119,9 @@ async fn learn_recall_fetch_list_and_forget_round_trip() {
.unwrap();
assert_eq!(page.hits.len(), 1);
- let listed = items_list(&config, ItemsListParams::default()).await.unwrap();
+ let listed = items_list(&config, ItemsListParams::default())
+ .await
+ .unwrap();
assert_eq!(listed.items.len(), 1);
assert_eq!(listed.items[0].id.0, learned.id);
@@ -135,9 +148,14 @@ async fn forget_needs_an_id() {
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
bind_reference(&config);
- let error = forget(&config, ForgetParams { ids: vec![" ".into()] })
- .await
- .unwrap_err();
+ let error = forget(
+ &config,
+ ForgetParams {
+ ids: vec![" ".into()],
+ },
+ )
+ .await
+ .unwrap_err();
assert_eq!(error.code(), INVALID_REQUEST);
}
@@ -176,7 +194,11 @@ fn host_meta_wins_over_caller_meta() {
let meta = item.meta();
assert_eq!(meta.thread_id.as_deref(), Some("t-real"));
assert_eq!(meta.agent_id.as_deref(), Some("orchestrator"));
- assert_eq!(meta.repo.as_deref(), Some("owner/repo"), "caller fields kept");
+ assert_eq!(
+ meta.repo.as_deref(),
+ Some("owner/repo"),
+ "caller fields kept"
+ );
assert_eq!(meta.source.kind, SourceKind::Agent);
assert_eq!(meta.tags, vec!["mine".to_string(), "host".to_string()]);
assert!(meta.observed_at.is_some());
@@ -223,7 +245,9 @@ async fn stores_are_scrubbed_of_secrets() {
.unwrap();
let items = stored(&engine, MetaFilter::default()).await;
assert_eq!(items.len(), 1);
- assert!(!items[0].text.contains("abcdefghijklmnopqrstuvwxyz0123456789"));
+ assert!(!items[0]
+ .text
+ .contains("abcdefghijklmnopqrstuvwxyz0123456789"));
}
#[test]
diff --git a/crates/openhuman-core/src/memory/schemas/defs.rs b/crates/openhuman-core/src/memory/schemas/defs.rs
index c67c6fe640..a4273bf071 100644
--- a/crates/openhuman-core/src/memory/schemas/defs.rs
+++ b/crates/openhuman-core/src/memory/schemas/defs.rs
@@ -61,11 +61,19 @@ fn limit() -> FieldSchema {
}
fn filter() -> FieldSchema {
- opt("filter", TypeSchema::Json, "MetaFilter: metadata fields, kinds, sources, tags_any, observed_after/before.")
+ opt(
+ "filter",
+ TypeSchema::Json,
+ "MetaFilter: metadata fields, kinds, sources, tags_any, observed_after/before.",
+ )
}
fn cursor() -> FieldSchema {
- opt("cursor", TypeSchema::String, "Engine cursor from a previous page.")
+ opt(
+ "cursor",
+ TypeSchema::String,
+ "Engine cursor from a previous page.",
+ )
}
/// The schema of `function`; an unknown function gets the namespace's
diff --git a/crates/openhuman-core/src/memory/schemas_tests.rs b/crates/openhuman-core/src/memory/schemas_tests.rs
index cdc48004b3..3bceaafc8b 100644
--- a/crates/openhuman-core/src/memory/schemas_tests.rs
+++ b/crates/openhuman-core/src/memory/schemas_tests.rs
@@ -1,8 +1,8 @@
use super::*;
+use crate::config::Config;
use crate::core::runtime::context::CoreContext;
use crate::core::runtime::DomainSet;
use crate::memory::test_fixtures::{bind_reference, config_in};
-use crate::config::Config;
use serde_json::{json, Map, Value};
/// Every method of the spec's RPC table (`docs/specs/memory-v2.md`), exactly.
@@ -166,21 +166,31 @@ async fn read_handlers_answer_over_a_bound_engine() {
let config = config_in(&tmp);
bind_reference(&config);
- let learned = call(&config, "learn", json!({"text": "Likes oolong", "kind": "preference"}))
- .await
- .unwrap();
+ let learned = call(
+ &config,
+ "learn",
+ json!({"text": "Likes oolong", "kind": "preference"}),
+ )
+ .await
+ .unwrap();
let learned = learned.get("result").unwrap_or(&learned).clone();
let id = learned["id"].as_str().expect("id").to_string();
- let listed = call(&config, "items_list", json!({"limit": 5})).await.unwrap();
+ let listed = call(&config, "items_list", json!({"limit": 5}))
+ .await
+ .unwrap();
let listed = listed.get("result").unwrap_or(&listed);
assert_eq!(listed["items"].as_array().unwrap().len(), 1);
- let recalled = call(&config, "recall", json!({"question": "oolong"})).await.unwrap();
+ let recalled = call(&config, "recall", json!({"question": "oolong"}))
+ .await
+ .unwrap();
let recalled = recalled.get("result").unwrap_or(&recalled);
assert!(!recalled["citations"].as_array().unwrap().is_empty());
- let fetched = call(&config, "fetch", json!({"query": "oolong"})).await.unwrap();
+ let fetched = call(&config, "fetch", json!({"query": "oolong"}))
+ .await
+ .unwrap();
let fetched = fetched.get("result").unwrap_or(&fetched);
assert_eq!(fetched["hits"].as_array().unwrap().len(), 1);
@@ -241,7 +251,11 @@ async fn settings_handlers_validate_persist_and_report() {
let got = call(&config, "context_get", json!({})).await.unwrap();
assert!(got.get("result").unwrap_or(&got).get("markdown").is_some());
let convo = call(&config, "conversations_get", json!({})).await.unwrap();
- assert!(convo.get("result").unwrap_or(&convo).get("recent").is_some());
+ assert!(convo
+ .get("result")
+ .unwrap_or(&convo)
+ .get("recent")
+ .is_some());
}
#[tokio::test]
@@ -269,7 +283,10 @@ async fn engine_set_persists_the_selection_and_rejects_unknown_engines() {
assert_eq!(view["endpoint"], "https://cortex.example.test");
let saved = std::fs::read_to_string(&config.config_path).unwrap();
assert!(saved.contains("cortexdb"), "{saved}");
- assert!(!saved.contains("cdb-test-key"), "the key never lands in config");
+ assert!(
+ !saved.contains("cdb-test-key"),
+ "the key never lands in config"
+ );
}
#[tokio::test]
@@ -293,9 +310,13 @@ async fn source_handlers_add_remove_and_sync() {
let saved = std::fs::read_to_string(&config.config_path).unwrap();
assert!(saved.contains("Docs"), "{saved}");
- let bad_kind = call(&config, "sources_add", json!({"kind": "twitter", "target": "x"}))
- .await
- .unwrap_err();
+ let bad_kind = call(
+ &config,
+ "sources_add",
+ json!({"kind": "twitter", "target": "x"}),
+ )
+ .await
+ .unwrap_err();
assert!(bad_kind.contains("INVALID_REQUEST"));
let none = call(&config, "sources_list", json!({})).await.unwrap();
@@ -308,7 +329,9 @@ async fn source_handlers_add_remove_and_sync() {
let unknown_sync = {
bind_reference(&config);
- call(&config, "sources_sync", json!({"id": "src-missing"})).await.unwrap_err()
+ call(&config, "sources_sync", json!({"id": "src-missing"}))
+ .await
+ .unwrap_err()
};
assert!(unknown_sync.contains("INVALID_REQUEST"));
}
@@ -321,7 +344,10 @@ async fn import_handlers_report_scan_and_refuse_without_consent() {
assert_eq!(scan.get("result").unwrap_or(&scan)["found"], false);
let status = call(&config, "import_status", json!({})).await.unwrap();
- assert_eq!(status.get("result").unwrap_or(&status)["state"]["phase"], "idle");
+ assert_eq!(
+ status.get("result").unwrap_or(&status)["state"]["phase"],
+ "idle"
+ );
let refused = call(&config, "import_start", json!({"consent": false}))
.await
diff --git a/crates/openhuman-core/src/memory/sources/composio.rs b/crates/openhuman-core/src/memory/sources/composio.rs
index 944f047ab2..aaccdd2336 100644
--- a/crates/openhuman-core/src/memory/sources/composio.rs
+++ b/crates/openhuman-core/src/memory/sources/composio.rs
@@ -15,7 +15,9 @@ use tinymemory::{DocumentBody, MemoryMeta, SourceKind, SourceRef, StoreItem};
use crate::config::schema::MemorySourceConfig;
use crate::config::Config;
-use crate::integrations::composio::ops::{active_connection_ids, run_sync_pass, SYNC_PASS_MAX_ITEMS};
+use crate::integrations::composio::ops::{
+ active_connection_ids, run_sync_pass, SYNC_PASS_MAX_ITEMS,
+};
use crate::memory::engine::BoundEngine;
use crate::memory::error::{MemoryError, MemoryResult};
@@ -121,7 +123,6 @@ pub async fn sync_toolkit(
Ok(stored)
}
-
/// The memory source id a Composio sync of `toolkit` files its items under:
/// the configured `composio` source for the toolkit when there is one, else
/// `composio:<toolkit>`.
diff --git a/crates/openhuman-core/src/memory/sources/composio_tests.rs b/crates/openhuman-core/src/memory/sources/composio_tests.rs
index b498ae8ab1..8df8a06529 100644
--- a/crates/openhuman-core/src/memory/sources/composio_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/composio_tests.rs
@@ -21,7 +21,13 @@ fn record_item_builds_a_tagged_document() {
rec.tags = vec!["inbox".into(), " ".into(), "gmail".into(), "inbox".into()];
let item = record_item("GMail", "conn-7", "src-g", &rec).expect("an item");
- let StoreItem::Document { title, body, mime, meta } = item else {
+ let StoreItem::Document {
+ title,
+ body,
+ mime,
+ meta,
+ } = item
+ else {
panic!("expected a document");
};
assert_eq!(title.as_deref(), Some("Quarterly plan"));
@@ -32,10 +38,17 @@ fn record_item_builds_a_tagged_document() {
assert_eq!(meta.source.id.as_deref(), Some("src-g"));
assert_eq!(
meta.tags,
- vec!["gmail".to_string(), "connection:conn-7".to_string(), "inbox".to_string()],
+ vec![
+ "gmail".to_string(),
+ "connection:conn-7".to_string(),
+ "inbox".to_string()
+ ],
"toolkit and connection first, blanks and duplicates dropped"
);
- assert_eq!(meta.observed_at.map(|t| t.timestamp_millis()), Some(1_700_000_000_000));
+ assert_eq!(
+ meta.observed_at.map(|t| t.timestamp_millis()),
+ Some(1_700_000_000_000)
+ );
}
#[test]
@@ -89,7 +102,12 @@ async fn store_records_with_nothing_to_store_is_zero() {
let config = config_in(&tmp);
bind_reference(&config);
let bound = crate::memory::engine::resolve(&config).engine().unwrap();
- assert_eq!(store_records(&bound, "notion", "c", "s", &[]).await.unwrap(), 0);
+ assert_eq!(
+ store_records(&bound, "notion", "c", "s", &[])
+ .await
+ .unwrap(),
+ 0
+ );
}
#[test]
@@ -97,20 +115,26 @@ fn source_id_for_toolkit_prefers_the_configured_source() {
let tmp = tempfile::tempdir().unwrap();
let mut config = config_in(&tmp);
assert_eq!(source_id_for_toolkit(&config, "Gmail"), "composio:gmail");
- config.memory.sources.push(crate::config::schema::MemorySourceConfig {
- id: "src-gmail".into(),
- kind: MemorySourceKind::Composio,
- target: "gmail".into(),
- label: "Gmail".into(),
- schedule_mins: None,
- });
- config.memory.sources.push(crate::config::schema::MemorySourceConfig {
- id: "src-folder".into(),
- kind: MemorySourceKind::Folder,
- target: "notion".into(),
- label: "Folder named like a toolkit".into(),
- schedule_mins: None,
- });
+ config
+ .memory
+ .sources
+ .push(crate::config::schema::MemorySourceConfig {
+ id: "src-gmail".into(),
+ kind: MemorySourceKind::Composio,
+ target: "gmail".into(),
+ label: "Gmail".into(),
+ schedule_mins: None,
+ });
+ config
+ .memory
+ .sources
+ .push(crate::config::schema::MemorySourceConfig {
+ id: "src-folder".into(),
+ kind: MemorySourceKind::Folder,
+ target: "notion".into(),
+ label: "Folder named like a toolkit".into(),
+ schedule_mins: None,
+ });
assert_eq!(source_id_for_toolkit(&config, "GMAIL"), "src-gmail");
assert_eq!(source_id_for_toolkit(&config, "notion"), "composio:notion");
}
@@ -121,12 +145,24 @@ async fn forget_connection_removes_only_that_connections_items() {
let config = config_in(&tmp);
let engine = bind_reference(&config);
let bound = crate::memory::engine::resolve(&config).engine().unwrap();
- store_records(&bound, "gmail", "conn-a", "src", &[record("1", "A", "from a")])
- .await
- .unwrap();
- store_records(&bound, "gmail", "conn-b", "src", &[record("2", "B", "from b")])
- .await
- .unwrap();
+ store_records(
+ &bound,
+ "gmail",
+ "conn-a",
+ "src",
+ &[record("1", "A", "from a")],
+ )
+ .await
+ .unwrap();
+ store_records(
+ &bound,
+ "gmail",
+ "conn-b",
+ "src",
+ &[record("2", "B", "from b")],
+ )
+ .await
+ .unwrap();
assert_eq!(forget_connection(&config, "conn-a").await.unwrap(), 1);
let left = stored(&engine, MetaFilter::default()).await;
assert_eq!(left.len(), 1);
diff --git a/crates/openhuman-core/src/memory/sources/mod.rs b/crates/openhuman-core/src/memory/sources/mod.rs
index 42bffc4590..fb9348aa47 100644
--- a/crates/openhuman-core/src/memory/sources/mod.rs
+++ b/crates/openhuman-core/src/memory/sources/mod.rs
@@ -103,7 +103,10 @@ fn http_url(target: &str) -> MemoryResult<String> {
/// Builds a new source from `memory_sources_add` params and appends it to
/// `config`; the caller persists `config`.
-pub fn apply_add(config: &mut Config, params: &SourcesAddParams) -> MemoryResult<MemorySourceConfig> {
+pub fn apply_add(
+ config: &mut Config,
+ params: &SourcesAddParams,
+) -> MemoryResult<MemorySourceConfig> {
let kind = MemorySourceKind::parse(&params.kind).ok_or_else(|| {
MemoryError::invalid(format!(
"unknown source kind `{}` (folder, file, link, github, rss, composio)",
@@ -173,14 +176,19 @@ pub async fn forget_items(config: &Config, id: &str) -> MemoryResult<usize> {
/// Whether `source` is due for a scheduled sync at `now`.
#[must_use]
-pub fn is_due(source: &MemorySourceConfig, last: Option<&state::SourceState>, now: DateTime<Utc>) -> bool {
+pub fn is_due(
+ source: &MemorySourceConfig,
+ last: Option<&state::SourceState>,
+ now: DateTime<Utc>,
+) -> bool {
let Some(mins) = source.schedule_mins else {
return false;
};
match last {
Some(state) if state.status == SourceStatus::Syncing => false,
Some(state) => state.last_sync_at.is_none_or(|at| {
- now.signed_duration_since(at) >= chrono::Duration::minutes(i64::from(mins.max(MIN_SCHEDULE_MINS)))
+ now.signed_duration_since(at)
+ >= chrono::Duration::minutes(i64::from(mins.max(MIN_SCHEDULE_MINS)))
}),
None => true,
}
diff --git a/crates/openhuman-core/src/memory/sources/mod_tests.rs b/crates/openhuman-core/src/memory/sources/mod_tests.rs
index 2909169f26..56b78932ed 100644
--- a/crates/openhuman-core/src/memory/sources/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/mod_tests.rs
@@ -96,7 +96,10 @@ fn add_list_and_remove_round_trip_through_config() {
assert_eq!(added.schedule_mins, Some(60));
let unlabeled = apply_add(&mut config, &add_params("github", "owner/repo")).unwrap();
- assert_eq!(unlabeled.label, "https://github.com/owner/repo", "label defaults to the target");
+ assert_eq!(
+ unlabeled.label, "https://github.com/owner/repo",
+ "label defaults to the target"
+ );
let listed = list(&config);
assert_eq!(listed.len(), 2);
@@ -120,7 +123,9 @@ fn add_validates_kind_schedule_and_target() {
let tmp = tempfile::tempdir().unwrap();
let mut config = config_in(&tmp);
assert_eq!(
- apply_add(&mut config, &add_params("twitter", "x")).unwrap_err().code(),
+ apply_add(&mut config, &add_params("twitter", "x"))
+ .unwrap_err()
+ .code(),
INVALID_REQUEST
);
assert_eq!(
@@ -136,10 +141,15 @@ fn add_validates_kind_schedule_and_target() {
INVALID_REQUEST
);
assert_eq!(
- apply_add(&mut config, &add_params("link", "nope")).unwrap_err().code(),
+ apply_add(&mut config, &add_params("link", "nope"))
+ .unwrap_err()
+ .code(),
INVALID_REQUEST
);
- assert!(config.memory.sources.is_empty(), "a refused add changes nothing");
+ assert!(
+ config.memory.sources.is_empty(),
+ "a refused add changes nothing"
+ );
// A Composio source needs no reader.
apply_add(&mut config, &add_params("composio", "Gmail")).unwrap();
assert_eq!(config.memory.sources[0].target, "gmail");
@@ -166,7 +176,10 @@ fn view_overlays_the_sync_state() {
fn is_due_follows_schedule_and_status() {
let now = Utc::now();
let scheduled = source("s", Some(60));
- assert!(!is_due(&source("manual", None), None, now), "on demand only");
+ assert!(
+ !is_due(&source("manual", None), None, now),
+ "on demand only"
+ );
assert!(is_due(&scheduled, None, now), "never synced");
let synced = |ago_mins: i64, status| state::SourceState {
@@ -174,10 +187,25 @@ fn is_due_follows_schedule_and_status() {
status,
..state::SourceState::default()
};
- assert!(!is_due(&scheduled, Some(&synced(59, SourceStatus::Idle)), now));
- assert!(is_due(&scheduled, Some(&synced(60, SourceStatus::Idle)), now));
- assert!(is_due(&scheduled, Some(&synced(500, SourceStatus::Error)), now), "errors retry");
- assert!(!is_due(&scheduled, Some(&synced(500, SourceStatus::Syncing)), now));
+ assert!(!is_due(
+ &scheduled,
+ Some(&synced(59, SourceStatus::Idle)),
+ now
+ ));
+ assert!(is_due(
+ &scheduled,
+ Some(&synced(60, SourceStatus::Idle)),
+ now
+ ));
+ assert!(
+ is_due(&scheduled, Some(&synced(500, SourceStatus::Error)), now),
+ "errors retry"
+ );
+ assert!(!is_due(
+ &scheduled,
+ Some(&synced(500, SourceStatus::Syncing)),
+ now
+ ));
let no_last_sync = state::SourceState::default();
assert!(is_due(&scheduled, Some(&no_last_sync), now));
}
diff --git a/crates/openhuman-core/src/memory/sources/state.rs b/crates/openhuman-core/src/memory/sources/state.rs
index 56fbfc3836..b17e2cd6cd 100644
--- a/crates/openhuman-core/src/memory/sources/state.rs
+++ b/crates/openhuman-core/src/memory/sources/state.rs
@@ -67,7 +67,9 @@ pub fn load(workspace_dir: &Path) -> BTreeMap<String, SourceState> {
/// Applies `change` to `id`'s state and persists it.
pub fn update(workspace_dir: &Path, id: &str, change: impl FnOnce(&mut SourceState)) {
- 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_all(workspace_dir);
change(all.entry(id.to_string()).or_default());
write_all(workspace_dir, &all);
@@ -75,7 +77,9 @@ pub fn update(workspace_dir: &Path, id: &str, change: impl FnOnce(&mut SourceSta
/// Drops `id`'s state.
pub fn remove(workspace_dir: &Path, id: &str) {
- 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_all(workspace_dir);
if all.remove(id).is_some() {
write_all(workspace_dir, &all);
@@ -85,7 +89,9 @@ pub fn remove(workspace_dir: &Path, id: &str) {
/// Marks every `syncing` source idle: called once at startup, when no sync
/// can be running yet.
pub fn reset_interrupted(workspace_dir: &Path) {
- 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_all(workspace_dir);
let mut changed = false;
for state in all.values_mut() {
diff --git a/crates/openhuman-core/src/memory/sources/sync.rs b/crates/openhuman-core/src/memory/sources/sync.rs
index 1754aebbb7..f4198bbf9c 100644
--- a/crates/openhuman-core/src/memory/sources/sync.rs
+++ b/crates/openhuman-core/src/memory/sources/sync.rs
@@ -42,7 +42,9 @@ pub(super) fn reader_entry(source: &MemorySourceConfig) -> MemoryResult<Option<M
};
let mut entry = MemorySourceEntry::new(source.id.clone(), kind, source.label.clone());
match source.kind {
- MemorySourceKind::Folder | MemorySourceKind::File => entry.path = Some(source.target.clone()),
+ MemorySourceKind::Folder | MemorySourceKind::File => {
+ entry.path = Some(source.target.clone())
+ }
_ => entry.url = Some(source.target.clone()),
}
apply_kind_defaults(&mut entry);
@@ -59,9 +61,14 @@ pub async fn sync_one(config: &Config, source: &MemorySourceConfig) -> MemoryRes
return super::composio::sync_toolkit(config, &bound, source).await;
};
let reader = reader_for_request(&entry.kind);
- let collected = collect_items(reader.as_ref(), &entry, &config.action_dir, &NativeConverter)
- .await
- .map_err(|error| MemoryError::Engine(format!("reading the source failed: {error}")))?;
+ let collected = collect_items(
+ reader.as_ref(),
+ &entry,
+ &config.action_dir,
+ &NativeConverter,
+ )
+ .await
+ .map_err(|error| MemoryError::Engine(format!("reading the source failed: {error}")))?;
if !collected.skipped.is_empty() {
tracing::debug!(
id = %source.id,
@@ -181,7 +188,9 @@ pub fn sync_due(config: &Config, now: DateTime<Utc>) -> Vec<String> {
for id in due {
match start_sync(config, Some(&id)) {
Ok(ids) => started.extend(ids),
- Err(error) => tracing::debug!(id = %id, code = error.code(), "[memory:sources] due sync not started"),
+ Err(error) => {
+ tracing::debug!(id = %id, code = error.code(), "[memory:sources] due sync not started")
+ }
}
}
started
diff --git a/crates/openhuman-core/src/memory/sources/sync_tests.rs b/crates/openhuman-core/src/memory/sources/sync_tests.rs
index a2fbbc814d..68675a651c 100644
--- a/crates/openhuman-core/src/memory/sources/sync_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/sync_tests.rs
@@ -49,9 +49,13 @@ fn reader_entry_maps_every_kind() {
label: "L".into(),
schedule_mins: None,
};
- let folder = reader_entry(&mk(MemorySourceKind::Folder, "/p")).unwrap().unwrap();
+ let folder = reader_entry(&mk(MemorySourceKind::Folder, "/p"))
+ .unwrap()
+ .unwrap();
assert_eq!(folder.path.as_deref(), Some("/p"));
- let file = reader_entry(&mk(MemorySourceKind::File, "/p/a.md")).unwrap().unwrap();
+ let file = reader_entry(&mk(MemorySourceKind::File, "/p/a.md"))
+ .unwrap()
+ .unwrap();
assert_eq!(file.path.as_deref(), Some("/p/a.md"));
for (kind, target) in [
(MemorySourceKind::Link, "https://example.com/"),
@@ -61,7 +65,9 @@ fn reader_entry_maps_every_kind() {
let entry = reader_entry(&mk(kind, target)).unwrap().unwrap();
assert_eq!(entry.url.as_deref(), Some(target));
}
- assert!(reader_entry(&mk(MemorySourceKind::Composio, "gmail")).unwrap().is_none());
+ assert!(reader_entry(&mk(MemorySourceKind::Composio, "gmail"))
+ .unwrap()
+ .is_none());
}
#[tokio::test]
@@ -91,12 +97,16 @@ async fn sync_one_reports_memory_off_and_unreadable_sources() {
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
let dir = notes(&config, 1);
- let off = sync_one(&config, &folder_source("s", &dir, None)).await.unwrap_err();
+ let off = sync_one(&config, &folder_source("s", &dir, None))
+ .await
+ .unwrap_err();
assert_eq!(off.code(), crate::memory::error::MEMORY_OFF);
bind_reference(&config);
let missing = config.action_dir.join("does-not-exist");
- assert!(sync_one(&config, &folder_source("s", &missing, None)).await.is_err());
+ assert!(sync_one(&config, &folder_source("s", &missing, None))
+ .await
+ .is_err());
}
#[tokio::test]
@@ -105,7 +115,10 @@ async fn start_sync_walks_syncing_then_idle_and_records_items() {
let mut config = config_in(&tmp);
bind_reference(&config);
let dir = notes(&config, 2);
- config.memory.sources.push(folder_source("src-ok", &dir, None));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-ok", &dir, None));
let started = start_sync(&config, Some("src-ok")).unwrap();
assert_eq!(started, vec!["src-ok".to_string()]);
@@ -127,7 +140,10 @@ async fn a_failing_sync_lands_in_error_with_the_message() {
let mut config = config_in(&tmp);
bind_reference(&config);
let missing = config.action_dir.join("vanished");
- config.memory.sources.push(folder_source("src-bad", &missing, None));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-bad", &missing, None));
start_sync(&config, None).unwrap();
let done = wait_for_idle(&config, "src-bad").await;
@@ -149,7 +165,10 @@ fn start_sync_refuses_unknown_ids_and_memory_off() {
start_sync(&config, Some("src-nope")).unwrap_err().code(),
INVALID_REQUEST
);
- assert!(start_sync(&config, None).unwrap().is_empty(), "no sources, nothing started");
+ assert!(
+ start_sync(&config, None).unwrap().is_empty(),
+ "no sources, nothing started"
+ );
}
#[tokio::test]
@@ -158,7 +177,10 @@ async fn a_source_already_syncing_is_not_started_twice() {
let mut config = config_in(&tmp);
bind_reference(&config);
let dir = notes(&config, 1);
- config.memory.sources.push(folder_source("src-once", &dir, None));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-once", &dir, None));
let key = (config.workspace_dir.clone(), "src-once".to_string());
RUNNING.lock().unwrap().insert(key.clone());
assert!(start_sync(&config, Some("src-once")).unwrap().is_empty());
@@ -173,9 +195,18 @@ async fn sync_due_starts_only_scheduled_sources_that_are_due() {
let mut config = config_in(&tmp);
bind_reference(&config);
let dir = notes(&config, 1);
- config.memory.sources.push(folder_source("src-sched", &dir, Some(15)));
- config.memory.sources.push(folder_source("src-manual", &dir, None));
- config.memory.sources.push(folder_source("src-fresh", &dir, Some(15)));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-sched", &dir, Some(15)));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-manual", &dir, None));
+ config
+ .memory
+ .sources
+ .push(folder_source("src-fresh", &dir, Some(15)));
let now = Utc::now();
state::update(&config.workspace_dir, "src-fresh", |s| {
s.last_sync_at = Some(now);
@@ -198,7 +229,10 @@ async fn sync_due_starts_only_scheduled_sources_that_are_due() {
fn sync_due_with_memory_off_starts_nothing() {
let tmp = tempfile::tempdir().unwrap();
let mut config = config_in(&tmp);
- config.memory.sources.push(folder_source("s", tmp.path(), Some(15)));
+ config
+ .memory
+ .sources
+ .push(folder_source("s", tmp.path(), Some(15)));
assert!(sync_due(&config, Utc::now()).is_empty());
}
@@ -221,7 +255,9 @@ async fn store_all_skips_a_bad_item_but_fails_when_nothing_stored() {
tinymemory::MemoryMeta::default(),
);
assert_eq!(
- store_all(&bound, vec![bad.clone(), good], "src").await.unwrap(),
+ store_all(&bound, vec![bad.clone(), good], "src")
+ .await
+ .unwrap(),
1
);
assert!(store_all(&bound, vec![bad], "src").await.is_err());
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index 0a7e58c729..a1cfcbfe75 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use std::collections::HashSet;
use crate::memory::test_fixtures::{bind_reference, config_in, stored};
+use std::collections::HashSet;
use std::path::{Path, PathBuf};
use tinymemory::{ItemKind, MetaFilter};
@@ -38,16 +38,28 @@ fn schema_and_permissions_follow_the_action() {
assert!(!tool.description().is_empty());
let schema = tool.parameters_schema();
assert_eq!(schema["required"][0], "action");
- assert_eq!(schema["properties"]["action"]["enum"].as_array().unwrap().len(), 4);
+ assert_eq!(
+ schema["properties"]["action"]["enum"]
+ .as_array()
+ .unwrap()
+ .len(),
+ 4
+ );
assert_eq!(tool.permission_level(), PermissionLevel::Write);
for read in ["recall", "fetch"] {
let args = json!({ "action": read });
- assert_eq!(tool.permission_level_with_args(&args), PermissionLevel::ReadOnly);
+ assert_eq!(
+ tool.permission_level_with_args(&args),
+ PermissionLevel::ReadOnly
+ );
assert!(tool.is_concurrency_safe(&args));
}
for write in ["learn", "forget"] {
let args = json!({ "action": write });
- assert_eq!(tool.permission_level_with_args(&args), PermissionLevel::Write);
+ assert_eq!(
+ tool.permission_level_with_args(&args),
+ PermissionLevel::Write
+ );
assert!(!tool.is_concurrency_safe(&args));
}
assert_eq!(
@@ -197,7 +209,12 @@ async fn recall_without_a_thread_records_no_citations() {
thread_id: None,
..facts()
};
- run_action(&config, &json!({"action": "learn", "text": "fact one"}), &no_thread).await;
+ run_action(
+ &config,
+ &json!({"action": "learn", "text": "fact one"}),
+ &no_thread,
+ )
+ .await;
let result = run_action(
&config,
&json!({"action": "recall", "question": "fact one"}),
@@ -247,10 +264,16 @@ fn turn_citations_are_capped_and_deduplicated() {
let drained = take_turn_citations(thread);
assert_eq!(drained.len(), MAX_TURN_CITATIONS);
assert_eq!(
- drained.iter().map(|c| c.id.clone()).collect::<HashSet<_>>().len(),
+ drained
+ .iter()
+ .map(|c| c.id.clone())
+ .collect::<HashSet<_>>()
+ .len(),
MAX_TURN_CITATIONS
);
- assert!(drained[0].snippet.chars().count() <= crate::memory::types::TURN_CITATION_SNIPPET_CHARS);
+ assert!(
+ drained[0].snippet.chars().count() <= crate::memory::types::TURN_CITATION_SNIPPET_CHARS
+ );
assert_eq!(drained[0].key, "learning");
}
diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rs
index d9822d1718..fde6fc9233 100644
--- a/crates/openhuman-core/src/memory/types.rs
+++ b/crates/openhuman-core/src/memory/types.rs
@@ -466,7 +466,11 @@ impl From<&Citation> for TurnCitation {
.observed_at
.map(|at| at.to_rfc3339())
.unwrap_or_default(),
- snippet: citation.snippet.chars().take(TURN_CITATION_SNIPPET_CHARS).collect(),
+ snippet: citation
+ .snippet
+ .chars()
+ .take(TURN_CITATION_SNIPPET_CHARS)
+ .collect(),
}
}
}
diff --git a/crates/openhuman-core/src/modules/registry.rs b/crates/openhuman-core/src/modules/registry.rs
index a435308dba..653dc4032e 100644
--- a/crates/openhuman-core/src/modules/registry.rs
+++ b/crates/openhuman-core/src/modules/registry.rs
@@ -37,8 +37,8 @@ mod tests;
mod records_computer;
mod records_docs_wallet;
mod records_extra;
-mod records_mcp_connectors;
mod records_juice;
+mod records_mcp_connectors;
mod records_runtime;
mod records_search;
mod records_voice;
@@ -47,8 +47,8 @@ use crate::modules::types::ModuleRecord;
use records_computer::TINYCOMPUTER;
use records_docs_wallet::{TINYDOCS, TINYWALLET};
use records_extra::{TINYBOX, TINYCHANNELS, TINYHOSTS};
-use records_mcp_connectors::{TINYCONNECTORS, TINYMCP};
use records_juice::TINYJUICE;
+use records_mcp_connectors::{TINYCONNECTORS, TINYMCP};
use records_runtime::{TINYRUNTIME, TINYRUNTIME_NODEJS, TINYRUNTIME_PYTHON};
use records_search::TINYSEARCH;
use records_voice::TINYVOICE;
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 24d3590f86..e72897a5b5 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
@@ -495,7 +495,11 @@ 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_conversations_set"),
+ (
+ "memory.conversations",
+ "conversations",
+ "memory_conversations_set",
+ ),
("memory.documents", "documents", "memory_sources_add"),
("memory.context", "context", "memory_context_refresh"),
] {
@@ -511,7 +515,10 @@ fn memory_v2_capabilities_cite_live_surface_and_rpcs() {
cap.how_to
);
}
- assert!(lookup("memory.import").expect("import").how_to.contains("memory_import_start"));
+ assert!(lookup("memory.import")
+ .expect("import")
+ .how_to
+ .contains("memory_import_start"));
}
/// The v1 memory surface is gone; no catalog entry may advertise it.
@@ -535,7 +542,13 @@ fn v1_memory_capabilities_are_not_advertised() {
}
for c in all_capabilities() {
let text = format!("{} {} {}", c.name, c.description, c.how_to);
- for dead in ["memory_tree", "MEMORY.md", "PROFILE.md", "memory_goals", "TinyCortex"] {
+ for dead in [
+ "memory_tree",
+ "MEMORY.md",
+ "PROFILE.md",
+ "memory_goals",
+ "TinyCortex",
+ ] {
assert!(!text.contains(dead), "`{}` still mentions `{dead}`", c.id);
}
}
diff --git a/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs b/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs
index 1a01808c3a..66d5c6717d 100644
--- a/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs
+++ b/crates/openhuman-core/src/platform/doctor/core/memory_agent_checks.rs
@@ -20,9 +20,10 @@ pub(super) fn check_memory_engine(memory: &MemoryEngineCheck, items: &mut Vec<Di
let reason = memory.reason.as_deref().unwrap_or("no reason given");
items.push(match memory.status.as_str() {
"ok" => DiagnosticItem::ok(cat, format!("memory engine '{engine}' is serving")),
- "degraded" => {
- DiagnosticItem::warn(cat, format!("memory engine '{engine}' is degraded: {reason}"))
- }
+ "degraded" => DiagnosticItem::warn(
+ cat,
+ format!("memory engine '{engine}' is degraded: {reason}"),
+ ),
"off" => DiagnosticItem::warn(cat, format!("memory is off: {reason}")),
_ => DiagnosticItem::error(cat, format!("memory engine '{engine}' is down: {reason}")),
});
diff --git a/crates/openhuman-core/src/platform/doctor/core_tests.rs b/crates/openhuman-core/src/platform/doctor/core_tests.rs
index 46d227c419..5740871f7f 100644
--- a/crates/openhuman-core/src/platform/doctor/core_tests.rs
+++ b/crates/openhuman-core/src/platform/doctor/core_tests.rs
@@ -74,4 +74,3 @@ fn model_matches_rejects_different_base_models() {
assert!(!model_matches("bge-m3:latest", "nomic-embed-text"));
assert!(!model_matches("bge-m3:latest", "bge-m3:v1.0"));
}
-
diff --git a/crates/openhuman-core/src/threads/ops.rs b/crates/openhuman-core/src/threads/ops.rs
index 03b5b8ffc3..48613425b8 100644
--- a/crates/openhuman-core/src/threads/ops.rs
+++ b/crates/openhuman-core/src/threads/ops.rs
@@ -35,17 +35,15 @@ pub use usage::{token_usage, SubagentUsageDto, ThreadTokenUsageRequest, ThreadTo
// Test-only re-exports so `use super::*;` in the split-out test modules below
// keeps resolving the shared helpers that now live in `support`.
#[cfg(test)]
-use crate::threads::store::{
- ConversationMessage, ConversationThread, CreateConversationThread,
-};
+use crate::threads::store::{ConversationMessage, ConversationThread, CreateConversationThread};
+#[cfg(test)]
+use crate::threads::THREAD_TITLE_LOG_PREFIX;
#[cfg(test)]
use crate::threads::{
AppendConversationMessageRequest, ConversationMessageRecord, DeleteConversationThreadRequest,
EmptyRequest, GenerateConversationThreadTitleRequest,
};
#[cfg(test)]
-use crate::threads::THREAD_TITLE_LOG_PREFIX;
-#[cfg(test)]
use support::{message_to_record, record_to_message, run_to_completion, thread_to_summary};
#[cfg(test)]
use tinyagents_harness::title::{is_auto_generated_thread_title, title_from_user_message};
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index 3e02f3c17b..3d01ec66ba 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -8,6 +8,7 @@ use super::support::{
use crate::core::Outcome;
use crate::threads::store as conversations;
use crate::threads::store::{ConversationMessagePatch, CrossThreadHit};
+use crate::threads::ThreadsError;
use crate::threads::{
ApiEnvelope, AppendConversationMessageRequest, ConversationMessageRecord,
ConversationMessagesRequest, ConversationMessagesResponse, ConversationThreadSummary,
@@ -16,7 +17,6 @@ use crate::threads::{
UpdateConversationMessageRequest, UpdateConversationThreadLabelsRequest,
UpdateConversationThreadTitleRequest, UpsertConversationThreadRequest,
};
-use crate::threads::ThreadsError;
use crate::web_chat as web_channel;
use std::path::PathBuf;
use tinyagents_session::turn_state;
diff --git a/crates/openhuman-core/src/threads/ops/support.rs b/crates/openhuman-core/src/threads/ops/support.rs
index 416c489103..8e1149c168 100644
--- a/crates/openhuman-core/src/threads/ops/support.rs
+++ b/crates/openhuman-core/src/threads/ops/support.rs
@@ -6,8 +6,8 @@ use crate::config::Config;
use crate::core::runtime::context::CoreContext;
use crate::threads::store as conversations;
use crate::threads::store::{ConversationMessage, ConversationThread};
-use crate::threads::{ConversationMessageRecord, ConversationThreadSummary};
use crate::threads::THREAD_TITLE_LOG_PREFIX;
+use crate::threads::{ConversationMessageRecord, ConversationThreadSummary};
use std::path::PathBuf;
use tinyagents_harness::title::{title_from_user_message, title_log_fingerprint};
diff --git a/crates/openhuman-core/src/threads/ops/title_generation.rs b/crates/openhuman-core/src/threads/ops/title_generation.rs
index 40380a1f40..bd307d2ae8 100644
--- a/crates/openhuman-core/src/threads/ops/title_generation.rs
+++ b/crates/openhuman-core/src/threads/ops/title_generation.rs
@@ -6,11 +6,11 @@ use crate::config::Config;
use crate::core::Outcome;
use crate::inference::provider;
use crate::threads::store as conversations;
+use crate::threads::ThreadsError;
+use crate::threads::THREAD_TITLE_LOG_PREFIX;
use crate::threads::{
ApiEnvelope, ConversationThreadSummary, GenerateConversationThreadTitleRequest,
};
-use crate::threads::ThreadsError;
-use crate::threads::THREAD_TITLE_LOG_PREFIX;
use tinyagents_harness::title::{
build_title_request, is_auto_generated_thread_title, sanitize_generated_title,
title_log_fingerprint,
diff --git a/crates/openhuman-core/src/threads/ops/turn_state_ops.rs b/crates/openhuman-core/src/threads/ops/turn_state_ops.rs
index 4e91d9498f..421dbefe61 100644
--- a/crates/openhuman-core/src/threads/ops/turn_state_ops.rs
+++ b/crates/openhuman-core/src/threads/ops/turn_state_ops.rs
@@ -2,11 +2,11 @@
use super::support::{counts, envelope, workspace_dir};
use crate::core::Outcome;
-use crate::threads::{ApiEnvelope, EmptyRequest};
use crate::threads::turn_state::{
ClearTurnStateRequest, ClearTurnStateResponse, GetTurnStateForRequestRequest,
GetTurnStateRequest, GetTurnStateResponse, ListTurnStatesResponse,
};
+use crate::threads::{ApiEnvelope, EmptyRequest};
use tinyagents_session::turn_state;
/// Returns the persisted in-flight turn snapshot for a thread, if any.
diff --git a/crates/openhuman-core/src/threads/schemas/handlers.rs b/crates/openhuman-core/src/threads/schemas/handlers.rs
index aa20704d3c..c6a46a9432 100644
--- a/crates/openhuman-core/src/threads/schemas/handlers.rs
+++ b/crates/openhuman-core/src/threads/schemas/handlers.rs
@@ -4,15 +4,15 @@ use serde::de::DeserializeOwned;
use serde_json::{Map, Value};
use crate::core::all::ControllerFuture;
+use crate::threads::turn_state::{
+ ClearTurnStateRequest, GetTurnStateForRequestRequest, GetTurnStateRequest,
+};
use crate::threads::{
AppendConversationMessageRequest, ConversationMessagesRequest, CreateConversationThreadRequest,
DeleteConversationThreadRequest, EmptyRequest, GenerateConversationThreadTitleRequest,
UpdateConversationMessageRequest, UpdateConversationThreadLabelsRequest,
UpdateConversationThreadTitleRequest, UpsertConversationThreadRequest,
};
-use crate::threads::turn_state::{
- ClearTurnStateRequest, GetTurnStateForRequestRequest, GetTurnStateRequest,
-};
use super::super::ops;
diff --git a/crates/openhuman-core/src/threads/store/blocking.rs b/crates/openhuman-core/src/threads/store/blocking.rs
index 4100242890..1c9d967371 100644
--- a/crates/openhuman-core/src/threads/store/blocking.rs
+++ b/crates/openhuman-core/src/threads/store/blocking.rs
@@ -51,7 +51,7 @@
use std::path::PathBuf;
-use crate::threads::store as store;
+use crate::threads::store;
use super::{
ConversationMessage, ConversationMessagePatch, ConversationPurgeStats, ConversationStore,
diff --git a/crates/openhuman-core/src/threads/store/bus_tests.rs b/crates/openhuman-core/src/threads/store/bus_tests.rs
index 52d29fed71..60e45f4b5f 100644
--- a/crates/openhuman-core/src/threads/store/bus_tests.rs
+++ b/crates/openhuman-core/src/threads/store/bus_tests.rs
@@ -61,14 +61,12 @@ async fn persists_inbound_and_processed_turns_into_workspace_thread() {
})
.await;
- let threads =
- crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
+ let threads = crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
assert_eq!(threads.len(), 1);
assert_eq!(threads[0].id, "channel:slack_alice_general_thread:thread-1");
- let messages =
- crate::threads::store::get_messages(temp.path().to_path_buf(), &threads[0].id)
- .expect("messages");
+ let messages = crate::threads::store::get_messages(temp.path().to_path_buf(), &threads[0].id)
+ .expect("messages");
assert_eq!(messages.len(), 2);
assert_eq!(messages[0].id, "user:m1");
assert_eq!(messages[0].sender, "user");
@@ -114,8 +112,7 @@ async fn telegram_thread_ts_does_not_split_persisted_thread() {
})
.await;
- let threads =
- crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
+ let threads = crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
assert_eq!(threads.len(), 1);
assert_eq!(threads[0].id, "channel:telegram_alice_chat-1");
}
@@ -196,11 +193,9 @@ async fn received_matching_workspace_is_persisted() {
})
.await;
- let messages = crate::threads::store::get_messages(
- temp.path().to_path_buf(),
- "channel:slack_bob_dev",
- )
- .expect("messages");
+ let messages =
+ crate::threads::store::get_messages(temp.path().to_path_buf(), "channel:slack_bob_dev")
+ .expect("messages");
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].id, "user:m1");
}
@@ -227,8 +222,7 @@ async fn received_stale_workspace_is_dropped() {
.await;
// No thread should have been created in temp (the subscriber's workspace).
- let threads =
- crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
+ let threads = crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
assert!(
threads.is_empty(),
"stale-workspace event must not create a thread"
@@ -435,8 +429,7 @@ async fn multiple_stale_workspaces_all_dropped() {
.await;
}
- let threads =
- crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
+ let threads = crate::threads::store::list_threads(temp.path().to_path_buf()).expect("threads");
assert!(
threads.is_empty(),
"no events from wrong workspaces should create a thread"
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index bc95e176d7..b855fb9fae 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -19,7 +19,6 @@ use tinytools_std::filesystem::{
};
use tinytools_std::network::{CurlTool, PushoverTool};
-
/// Create the default tool registry
pub fn default_tools(security: Arc<SecurityPolicy>) -> Vec<Box<dyn Tool>> {
default_tools_with_runtime(security, Arc::new(NativeRuntime::new()))
diff --git a/crates/openhuman-core/src/tools/ops_tests_capability_gating_tests.rs b/crates/openhuman-core/src/tools/ops_tests_capability_gating_tests.rs
index 9cfa9589cd..87b355e911 100644
--- a/crates/openhuman-core/src/tools/ops_tests_capability_gating_tests.rs
+++ b/crates/openhuman-core/src/tools/ops_tests_capability_gating_tests.rs
@@ -260,7 +260,13 @@ fn memory_tool_is_absent_while_memory_is_off() {
"the memory tool must not be registered with memory off; got: {names:?}"
);
// The v1 memory surface is gone, not merely hidden.
- for removed in ["memory_store", "memory_recall", "memory_forget", "goals", "tool_stats"] {
+ for removed in [
+ "memory_store",
+ "memory_recall",
+ "memory_forget",
+ "goals",
+ "tool_stats",
+ ] {
assert!(
!names.iter().any(|n| n == removed),
"v1 tool `{removed}` must no longer be registered"
diff --git a/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs b/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
index 66e6518200..c50582583c 100644
--- a/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
+++ b/crates/openhuman-core/src/tools/ops_tests_domain_family_tests.rs
@@ -280,10 +280,7 @@ fn knowledge_default_off_tools_are_filtered_when_not_opted_in() {
fn knowledge_default_off_tools_retained_when_opted_in() {
let tmp = TempDir::new().unwrap();
let mut tools = expansion_tools_for(&tmp);
- filter_tools_by_user_preference(
- &mut tools,
- &["workflow_manage".to_string()],
- );
+ filter_tools_by_user_preference(&mut tools, &["workflow_manage".to_string()]);
let names = tool_names(&tools);
let off_tools = knowledge_default_off();
for on in &off_tools {
diff --git a/crates/openhuman-core/src/tools/schemas/apify.rs b/crates/openhuman-core/src/tools/schemas/apify.rs
index e512e6c869..a8d487517a 100644
--- a/crates/openhuman-core/src/tools/schemas/apify.rs
+++ b/crates/openhuman-core/src/tools/schemas/apify.rs
@@ -21,17 +21,11 @@ pub(super) fn handle_apify_linkedin_scrape(params: Map<String, Value>) -> Contro
"Apify scrape unavailable — no backend session token. Sign in first.".to_string()
})?;
- let data = super::linkedin::scrape_linkedin_profile(
- &client,
- &profile_url,
- )
- .await
- .map_err(|e| format!("Apify LinkedIn scrape failed: {e:#}"))?;
+ let data = super::linkedin::scrape_linkedin_profile(&client, &profile_url)
+ .await
+ .map_err(|e| format!("Apify LinkedIn scrape failed: {e:#}"))?;
- let markdown = super::linkedin::render_profile_markdown(
- &profile_url,
- &data,
- );
+ let markdown = super::linkedin::render_profile_markdown(&profile_url, &data);
let payload = json!({ "data": data, "markdown": markdown });
let log = vec![format!(