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 core crates

Steven Enamakel09eaf64dbce7
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
index f2bf77f9ab..b3b28261f7 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/delegate_graph.rs
@@ -10,9 +10,9 @@
//! Use it for non-trivial sub-tasks that benefit from a self-review/revision
//! loop; use `spawn_subagent` for a single focused hand-off.
-use crate::core::runtime::DispatchCtx;
use crate::agent::harness::host_definition::AgentDefinitionRegistry;
use crate::agent::orchestration::delegation::run_subagent_delegation_with_parent_context;
+use crate::core::runtime::DispatchCtx;
use async_trait::async_trait;
use serde_json::json;
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
index e591893a5a..d5b3e8520c 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest.rs
@@ -77,13 +77,16 @@ impl OpenHumanTurnPrelude {
if let Some(config) = &self.runtime_config {
return Some(config.clone());
}
- crate::config::rpc::load_config_for_workspace_with_timeout(&DispatchCtx::ambient(), &self.workspace_dir)
- .await
- .map(Arc::new)
- .map_err(|error| {
- log::debug!("[session_host:memory] no config for memory: {error}");
- })
- .ok()
+ crate::config::rpc::load_config_for_workspace_with_timeout(
+ &DispatchCtx::ambient(),
+ &self.workspace_dir,
+ )
+ .await
+ .map(Arc::new)
+ .map_err(|error| {
+ log::debug!("[session_host:memory] no config for memory: {error}");
+ })
+ .ok()
}
/// Takes completed memory and queues a user-authored turn's log and recall.
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
index efd59bf732..8f8495a5c3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs
@@ -414,7 +414,9 @@ impl OpenHumanSecurityGate {
let policy = self.effective_policy();
#[cfg(feature = "modules")]
let desktop_approval_disabled = match self.resolve_tool(&call.tool_name) {
- Some(tool) => crate::desktop::control::approvals_disabled_for(&DispatchCtx::ambient(), tool).await,
+ Some(tool) => {
+ crate::desktop::control::approvals_disabled_for(&DispatchCtx::ambient(), tool).await
+ }
None => false,
};
#[cfg(not(feature = "modules"))]
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs
index 70c19c17c7..126fee2219 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/approval.rs
@@ -84,7 +84,13 @@ impl ApprovalSecurityMiddleware {
.flat_map(|set| set.iter())
.find(|tool| tool.name() == name)
{
- Some(tool) => crate::desktop::control::approvals_disabled_for(&DispatchCtx::ambient(), tool.as_ref()).await,
+ Some(tool) => {
+ crate::desktop::control::approvals_disabled_for(
+ &DispatchCtx::ambient(),
+ tool.as_ref(),
+ )
+ .await
+ }
None => false,
};
#[cfg(not(feature = "modules"))]
@@ -137,7 +143,12 @@ impl ApprovalResolver<crate::agent::tinyagents::host::OpenHumanRunContext>
let summary = summarize_action(&call.name, &call.arguments);
let redacted = redact_args(&call.arguments);
let (outcome, request_id) = gate
- .intercept_audited(&ctx.data.approval, approval_name.as_ref(), &summary, redacted)
+ .intercept_audited(
+ &ctx.data.approval,
+ approval_name.as_ref(),
+ &summary,
+ redacted,
+ )
.await;
match outcome {
GateOutcome::Deny { reason } => {
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs
index f7ed0cff40..b5dcae0d50 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs
@@ -333,7 +333,13 @@ impl ToolMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
// level), mirroring the engine order in `agent_tool_exec`.
#[cfg(feature = "modules")]
let desktop_approval_disabled = match self.resolve_tool(&call.name) {
- Some(tool) => crate::desktop::control::approvals_disabled_for(&crate::core::runtime::DispatchCtx::ambient(), tool.as_ref()).await,
+ Some(tool) => {
+ crate::desktop::control::approvals_disabled_for(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ tool.as_ref(),
+ )
+ .await
+ }
None => false,
};
#[cfg(not(feature = "modules"))]
diff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
index c498733179..2b044cd4c8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
@@ -116,7 +116,8 @@ impl HarnessPayloadSummarizer<OpenHumanRunContext> for SubagentPayloadSummarizer
Ok(Box::new(move |request: GenerateRequest| {
Box::pin(async move {
- let config_loaded = crate::config::ops::load_current_or_init(&DispatchCtx::ambient()).await;
+ let config_loaded =
+ crate::config::ops::load_current_or_init(&DispatchCtx::ambient()).await;
let (source, model) = subagent_host::resolve_subagent_source(
&definition.model,
&definition.id,
diff --git a/crates/openhuman-core/src/agent/tools/todo.rs b/crates/openhuman-core/src/agent/tools/todo.rs
index dd85893fab..ba715e7eb5 100644
--- a/crates/openhuman-core/src/agent/tools/todo.rs
+++ b/crates/openhuman-core/src/agent/tools/todo.rs
@@ -17,9 +17,9 @@
//! (see [`current_scope`] / [`legacy_session_key`]) so an in-flight list isn't
//! dropped by the rekey.
-use crate::core::runtime::DispatchCtx;
use crate::agent::harness::fork_context::ParentExecutionContext;
use crate::agent::todos::ops::{self, TodoScope};
+use crate::core::runtime::DispatchCtx;
use async_trait::async_trait;
use std::path::PathBuf;
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/channels/runtime/session_tests.rs b/crates/openhuman-core/src/channels/runtime/session_tests.rs
index ca2f5ab118..2e5625f43d 100644
--- a/crates/openhuman-core/src/channels/runtime/session_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/session_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
diff --git a/crates/openhuman-core/src/config/ops/agent.rs b/crates/openhuman-core/src/config/ops/agent.rs
index 040a8c157e..ad78a57085 100644
--- a/crates/openhuman-core/src/config/ops/agent.rs
+++ b/crates/openhuman-core/src/config/ops/agent.rs
@@ -149,7 +149,8 @@ pub async fn apply_autonomy_settings(
}
/// Loads the configuration, applies autonomy settings updates, and saves it.
-pub async fn load_and_apply_autonomy_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_autonomy_settings(
+ ctx: &DispatchCtx,
update: AutonomySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -157,7 +158,9 @@ pub async fn load_and_apply_autonomy_settings(ctx: &DispatchCtx,
}
/// Returns the current `[autonomy]` settings block as JSON (no secrets).
-pub async fn get_autonomy_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_autonomy_settings(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let value = serde_json::to_value(&config.autonomy).map_err(|e| e.to_string())?;
Ok(Outcome::single_log(value, "autonomy settings read"))
@@ -265,7 +268,8 @@ pub async fn apply_agent_settings(
}
/// Loads the configuration, applies agent settings updates, and saves it.
-pub async fn load_and_apply_agent_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_agent_settings(
+ ctx: &DispatchCtx,
update: AgentSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -275,7 +279,7 @@ pub async fn load_and_apply_agent_settings(ctx: &DispatchCtx,
/// Returns the agent execution settings (currently the action timeout) plus the
/// runtime-effective value and whether the `OPENHUMAN_TOOL_TIMEOUT_SECS` env var
/// is overriding the configured value, so the UI can explain a no-op control.
-pub async fn get_agent_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_agent_settings(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
crate::tools::timeout::set_tool_timeout_secs(config.agent.agent_timeout_secs);
let value = serde_json::json!({
@@ -651,7 +655,8 @@ pub async fn apply_agent_paths_settings(
}
/// Loads the configuration, applies agent-paths updates, and saves it.
-pub async fn load_and_apply_agent_paths_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_agent_paths_settings(
+ ctx: &DispatchCtx,
update: AgentPathsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -667,7 +672,7 @@ fn paths_equal(a: &Path, b: &Path) -> bool {
/// Reports the agent's filesystem roots so the UI can render them live
/// instead of hard-coding strings that drift away from `Config`.
-pub async fn get_agent_paths(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_agent_paths(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
Ok(Outcome::new(
agent_paths_payload(&config),
diff --git a/crates/openhuman-core/src/config/ops/computer.rs b/crates/openhuman-core/src/config/ops/computer.rs
index 65ad8f4351..0a10486ed8 100644
--- a/crates/openhuman-core/src/config/ops/computer.rs
+++ b/crates/openhuman-core/src/config/ops/computer.rs
@@ -1,8 +1,8 @@
//! TinyComputer model settings: the decision model and the planner and
//! rescue models the module runs a task with.
-use crate::core::runtime::DispatchCtx;
use crate::config::{ComputerConfig, Config, DecisionModel};
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use super::loader::{load_config_with_timeout, snapshot_config_json};
@@ -94,7 +94,8 @@ pub async fn apply_computer_settings(
}
/// Load the configuration, update `[computer]`, and save it.
-pub async fn load_and_apply_computer_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_computer_settings(
+ ctx: &DispatchCtx,
update: ComputerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rs
index 0ead1000e1..aa4dd07f10 100644
--- a/crates/openhuman-core/src/config/ops/loader/load.rs
+++ b/crates/openhuman-core/src/config/ops/loader/load.rs
@@ -86,10 +86,8 @@ pub async fn load_config_in(ctx: &crate::core::runtime::DispatchCtx) -> Result<C
/// The context-aware counterpart of [`Config::load_or_init`] for code that
/// runs inside a turn: [`load_config_with_timeout`] with the context's
/// inference route applied.
-pub async fn load_current_or_init(ctx: &DispatchCtx, ) -> anyhow::Result<Config> {
- let mut config = ctx.load_config()
- .await
- .map_err(anyhow::Error::msg)?;
+pub async fn load_current_or_init(ctx: &DispatchCtx) -> anyhow::Result<Config> {
+ let mut config = ctx.load_config().await.map_err(anyhow::Error::msg)?;
if let Some(route) = config.ephemeral_route.clone() {
tracing::trace!(
agent = crate::core::runtime::agent_scope::current_agent_id()
@@ -120,7 +118,8 @@ pub async fn load_current_or_init(ctx: &DispatchCtx, ) -> anyhow::Result<Config>
/// exists there is nothing workspace-specific to read, so this falls back to
/// the process-global load with `workspace_dir` re-anchored — the previous
/// behaviour, and still correct for a single-workspace host.
-pub async fn load_config_for_workspace_with_timeout(ctx: &DispatchCtx,
+pub async fn load_config_for_workspace_with_timeout(
+ ctx: &DispatchCtx,
workspace_dir: &Path,
) -> Result<Config, String> {
let candidate = [
diff --git a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
index 2e51aab226..1d28ee3b7d 100644
--- a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
+++ b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs
@@ -148,7 +148,7 @@ pub(crate) async fn reset_local_data_for_paths(
/// callers where in-process removal is acceptable (POSIX file semantics
/// tolerate unlinking open files; on Windows the CLI invocation runs
/// without the core attached, so no handle is in the way).
-pub async fn reset_local_data(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn reset_local_data(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let current_openhuman_dir = config_openhuman_dir(&config);
let default_openhuman_dir = default_openhuman_dir();
@@ -165,7 +165,7 @@ pub async fn reset_local_data(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json:
/// after which the Tauri shell removes them while no process holds open
/// handles. See OPENHUMAN-TAURI-AF for the Windows file-locking failure
/// that motivated the split.
-pub async fn get_data_paths(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_data_paths(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let current_openhuman_dir = config_openhuman_dir(&config);
let default_openhuman_dir = default_openhuman_dir();
diff --git a/crates/openhuman-core/src/config/ops/loader/snapshot.rs b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
index aa2d1535f6..9d93e5a544 100644
--- a/crates/openhuman-core/src/config/ops/loader/snapshot.rs
+++ b/crates/openhuman-core/src/config/ops/loader/snapshot.rs
@@ -136,7 +136,9 @@ pub fn client_config_json(config: &Config) -> serde_json::Value {
}
/// Loads config and returns the client-facing AI config slice.
-pub async fn load_and_get_client_config_snapshot(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn load_and_get_client_config_snapshot(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let snapshot = client_config_json(&config);
Ok(Outcome::new(
@@ -158,13 +160,17 @@ pub async fn get_config_snapshot(config: &Config) -> Result<Outcome<serde_json::
}
/// Loads the configuration from disk and returns a snapshot.
-pub async fn load_and_get_config_snapshot(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn load_and_get_config_snapshot(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
get_config_snapshot(&config).await
}
/// Reads dashboard settings exposed to the desktop UI.
-pub async fn get_dashboard_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_dashboard_settings(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let request_id = uuid::Uuid::new_v4().to_string();
tracing::debug!(
target: "openhuman_core::config",
diff --git a/crates/openhuman-core/src/config/ops/loader_current_tests.rs b/crates/openhuman-core/src/config/ops/loader_current_tests.rs
index 363fd99dd2..bbdc88ba83 100644
--- a/crates/openhuman-core/src/config/ops/loader_current_tests.rs
+++ b/crates/openhuman-core/src/config/ops/loader_current_tests.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::schema::{EphemeralRoute, EPHEMERAL_ROUTE_SLUG};
+use crate::core::runtime::DispatchCtx;
use crate::core::runtime::{context::CoreContext, DomainSet};
fn context_with(config: Config) -> std::sync::Arc<CoreContext> {
@@ -22,9 +22,12 @@ async fn a_context_route_follows_every_load_of_the_context_config() {
headers: Vec::new(),
});
- let loaded = CoreContext::scope(context_with(config), load_current_or_init(&DispatchCtx::process_default()))
- .await
- .expect("context config loads");
+ let loaded = CoreContext::scope(
+ context_with(config),
+ load_current_or_init(&DispatchCtx::process_default()),
+ )
+ .await
+ .expect("context config loads");
let pinned = format!("{EPHEMERAL_ROUTE_SLUG}:ctx-model");
assert_eq!(loaded.chat_provider.as_deref(), Some(pinned.as_str()));
@@ -41,9 +44,12 @@ async fn a_context_route_follows_every_load_of_the_context_config() {
#[tokio::test]
async fn a_context_without_a_route_loads_unchanged_providers() {
- let loaded = CoreContext::scope(context_with(base_config()), load_current_or_init(&DispatchCtx::process_default()))
- .await
- .expect("context config loads");
+ let loaded = CoreContext::scope(
+ context_with(base_config()),
+ load_current_or_init(&DispatchCtx::process_default()),
+ )
+ .await
+ .expect("context config loads");
assert!(loaded.ephemeral_route.is_none());
assert!(loaded
diff --git a/crates/openhuman-core/src/config/ops/loader_explicit_ctx_tests.rs b/crates/openhuman-core/src/config/ops/loader_explicit_ctx_tests.rs
index aa46f20997..45d2109cb8 100644
--- a/crates/openhuman-core/src/config/ops/loader_explicit_ctx_tests.rs
+++ b/crates/openhuman-core/src/config/ops/loader_explicit_ctx_tests.rs
@@ -58,3 +58,29 @@ async fn the_ambient_loader_reads_the_scoped_context() {
.expect("loads");
assert_eq!(loaded.default_model.as_deref(), Some("ambient-model"));
}
+
+/// An op that takes its context (not just the handler) reads that context's
+/// config: two tenants snapshotting at once, interleaved at await points, each
+/// get their own, and the task's scope does not leak in.
+#[tokio::test(flavor = "current_thread")]
+async fn a_config_op_snapshots_the_context_it_is_handed() {
+ let a = DispatchCtx::new(tenant("snapshot-tenant-a"));
+ let b = DispatchCtx::new(tenant("snapshot-tenant-b"));
+ let intruder = tenant("snapshot-scoped-intruder");
+ let snapshot = |ctx: DispatchCtx| async move {
+ tokio::task::yield_now().await;
+ let out = load_and_get_config_snapshot(&ctx).await.expect("snapshot");
+ out.value.to_string()
+ };
+ let (sa, sb) =
+ CoreContext::scope(intruder, async { tokio::join!(snapshot(a), snapshot(b)) }).await;
+ assert!(
+ sa.contains("snapshot-tenant-a") && !sa.contains("snapshot-tenant-b"),
+ "{sa}"
+ );
+ assert!(
+ sb.contains("snapshot-tenant-b") && !sb.contains("snapshot-tenant-a"),
+ "{sb}"
+ );
+ assert!(!sa.contains("scoped-intruder") && !sb.contains("scoped-intruder"));
+}
diff --git a/crates/openhuman-core/src/config/ops/model.rs b/crates/openhuman-core/src/config/ops/model.rs
index b06dec546c..120ada96c6 100644
--- a/crates/openhuman-core/src/config/ops/model.rs
+++ b/crates/openhuman-core/src/config/ops/model.rs
@@ -1,7 +1,7 @@
//! Model/provider config operations: AI providers, memory, runtime, local AI, Composio.
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use super::loader::{load_config_with_timeout, snapshot_config_json};
@@ -440,7 +440,8 @@ pub async fn apply_model_settings(
}
/// Loads the configuration, applies model settings updates, and saves it.
-pub async fn load_and_apply_model_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_model_settings(
+ ctx: &DispatchCtx,
update: ModelSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -485,7 +486,8 @@ pub async fn apply_memory_settings(
}
/// Loads the configuration, applies memory settings updates, and saves it.
-pub async fn load_and_apply_memory_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_memory_settings(
+ ctx: &DispatchCtx,
update: MemorySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -543,7 +545,8 @@ pub async fn apply_runtime_settings(
}
/// Loads the configuration, applies runtime settings updates, and saves it.
-pub async fn load_and_apply_runtime_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_runtime_settings(
+ ctx: &DispatchCtx,
update: RuntimeSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -620,7 +623,8 @@ pub async fn apply_local_ai_settings(
}
/// Loads the configuration, applies local-AI settings updates, and saves it.
-pub async fn load_and_apply_local_ai_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_local_ai_settings(
+ ctx: &DispatchCtx,
update: LocalAiSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -658,7 +662,8 @@ pub async fn apply_composio_trigger_settings(
}
/// Loads the configuration, applies composio trigger settings, and saves it.
-pub async fn load_and_apply_composio_trigger_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_composio_trigger_settings(
+ ctx: &DispatchCtx,
update: ComposioTriggerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -666,7 +671,9 @@ pub async fn load_and_apply_composio_trigger_settings(ctx: &DispatchCtx,
}
/// Reads the current composio trigger-triage settings.
-pub async fn get_composio_trigger_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_composio_trigger_settings(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let result = serde_json::json!({
"triage_disabled": config.composio.triage_disabled,
@@ -688,7 +695,9 @@ pub(crate) fn resolve_backend_api_url(config: &Config) -> Option<String> {
/// Resolves the effective backend API URL from configuration or defaults;
/// `api_url` is `null` when the core has no hosted backend.
-pub async fn load_and_resolve_api_url(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn load_and_resolve_api_url(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let resolved = resolve_backend_api_url(&config);
Ok(Outcome::new(
diff --git a/crates/openhuman-core/src/config/ops/privacy.rs b/crates/openhuman-core/src/config/ops/privacy.rs
index 8aa413c52c..e1abe9eb2a 100644
--- a/crates/openhuman-core/src/config/ops/privacy.rs
+++ b/crates/openhuman-core/src/config/ops/privacy.rs
@@ -5,8 +5,8 @@
//! live `SecurityPolicy` so the inference chokepoint enforces the change
//! immediately, without a core restart.
-use crate::core::runtime::DispatchCtx;
use crate::config::{Config, PrivacyMode};
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use super::loader::load_config_with_timeout;
@@ -42,7 +42,7 @@ fn privacy_mode_value(mode: PrivacyMode) -> serde_json::Value {
}
/// Returns the current `[privacy]` mode as `{ "mode": "<snake_case>" }`.
-pub async fn get_privacy_mode(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_privacy_mode(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
log::debug!(
"[privacy][rpc] get_privacy_mode -> {:?}",
@@ -96,7 +96,8 @@ pub async fn apply_privacy_settings(
}
/// Loads the configuration, applies the privacy-mode update, and saves it.
-pub async fn load_and_apply_privacy_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_privacy_settings(
+ ctx: &DispatchCtx,
update: PrivacySettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/config/ops/sandbox.rs b/crates/openhuman-core/src/config/ops/sandbox.rs
index 6c6bb4ed7d..758fa9a772 100644
--- a/crates/openhuman-core/src/config/ops/sandbox.rs
+++ b/crates/openhuman-core/src/config/ops/sandbox.rs
@@ -1,7 +1,7 @@
//! Sandbox / Docker runtime config operations.
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use super::loader::{load_config_with_timeout, snapshot_config_json};
@@ -17,7 +17,7 @@ pub struct SandboxSettingsPatch {
pub env_passthrough: Option<Vec<String>>,
}
-pub async fn get_sandbox_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_sandbox_settings(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let sandbox = &config.sandbox;
let docker = &config.runtime.docker;
@@ -121,7 +121,8 @@ pub async fn apply_sandbox_settings(
))
}
-pub async fn load_and_apply_sandbox_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_sandbox_settings(
+ ctx: &DispatchCtx,
update: SandboxSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/config/ops/search.rs b/crates/openhuman-core/src/config/ops/search.rs
index d87008449f..df3ff4e416 100644
--- a/crates/openhuman-core/src/config/ops/search.rs
+++ b/crates/openhuman-core/src/config/ops/search.rs
@@ -310,7 +310,8 @@ pub async fn apply_search_settings(
))
}
-pub async fn load_and_apply_search_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_search_settings(
+ ctx: &DispatchCtx,
update: SearchSettingsPatch,
) -> Result<Outcome<Value>, String> {
let mut config = ctx.load_config().await?;
@@ -391,7 +392,7 @@ pub(crate) fn search_settings_json_with(config: &Config, managed_available: bool
}
/// Read the current search settings. Keys are reported only as booleans.
-pub async fn get_search_settings(ctx: &DispatchCtx, ) -> Result<Outcome<Value>, String> {
+pub async fn get_search_settings(ctx: &DispatchCtx) -> Result<Outcome<Value>, String> {
let config = ctx.load_config().await?;
Ok(Outcome::new(
search_settings_json(&config),
diff --git a/crates/openhuman-core/src/config/ops/ui.rs b/crates/openhuman-core/src/config/ops/ui.rs
index c98c6ba147..3fd9dfd0ae 100644
--- a/crates/openhuman-core/src/config/ops/ui.rs
+++ b/crates/openhuman-core/src/config/ops/ui.rs
@@ -163,7 +163,8 @@ fn normalize_browser_backend(raw: &str) -> Result<String, String> {
}
/// Loads the configuration, applies browser settings updates, and saves it.
-pub async fn load_and_apply_browser_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_browser_settings(
+ ctx: &DispatchCtx,
update: BrowserSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -230,7 +231,8 @@ pub async fn apply_user_timezone(
}
/// Loads the configuration, sets the user's time zone, and saves it.
-pub async fn load_and_apply_user_timezone(ctx: &DispatchCtx,
+pub async fn load_and_apply_user_timezone(
+ ctx: &DispatchCtx,
timezone: Option<String>,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -247,7 +249,8 @@ pub fn user_timezone_json(config: &Config) -> serde_json::Value {
}
/// Loads the configuration, applies analytics settings updates, and saves it.
-pub async fn load_and_apply_analytics_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_analytics_settings(
+ ctx: &DispatchCtx,
update: AnalyticsSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -255,7 +258,8 @@ pub async fn load_and_apply_analytics_settings(ctx: &DispatchCtx,
}
/// Resolves a workspace onboarding flag, creating or checking its existence.
-pub async fn workspace_onboarding_flag_resolve(ctx: &DispatchCtx,
+pub async fn workspace_onboarding_flag_resolve(
+ ctx: &DispatchCtx,
flag_name: Option<String>,
default_name: &str,
) -> Result<Outcome<bool>, String> {
@@ -295,7 +299,8 @@ pub fn workspace_onboarding_flag_exists(
}
/// Creates or removes an onboarding flag file in the workspace.
-pub async fn workspace_onboarding_flag_set(ctx: &DispatchCtx,
+pub async fn workspace_onboarding_flag_set(
+ ctx: &DispatchCtx,
flag_name: Option<String>,
default_name: &str,
value: bool,
@@ -332,7 +337,7 @@ pub async fn workspace_onboarding_flag_set(ctx: &DispatchCtx,
}
/// Returns whether the onboarding process has been marked as completed.
-pub async fn get_onboarding_completed(ctx: &DispatchCtx, ) -> Result<Outcome<bool>, String> {
+pub async fn get_onboarding_completed(ctx: &DispatchCtx) -> Result<Outcome<bool>, String> {
let config = ctx.load_config().await?;
Ok(Outcome::single_log(
config.onboarding_completed,
@@ -344,7 +349,10 @@ pub async fn get_onboarding_completed(ctx: &DispatchCtx, ) -> Result<Outcome<boo
///
/// On a false→true transition, seeds the recurring morning-briefing
/// cron job via [`crate::cron::seed::seed_proactive_agents`].
-pub async fn set_onboarding_completed(ctx: &DispatchCtx, value: bool) -> Result<Outcome<bool>, String> {
+pub async fn set_onboarding_completed(
+ ctx: &DispatchCtx,
+ value: bool,
+) -> Result<Outcome<bool>, String> {
tracing::debug!(value, "[onboarding] set_onboarding_completed called");
let mut config = ctx.load_config().await?;
let was_completed = config.onboarding_completed;
@@ -377,7 +385,9 @@ pub async fn set_onboarding_completed(ctx: &DispatchCtx, value: bool) -> Result<
}
/// Returns the current dictation settings as a JSON object.
-pub async fn get_dictation_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_dictation_settings(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let result = json!({
"enabled": config.dictation.enabled,
@@ -394,7 +404,8 @@ pub async fn get_dictation_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde
}
/// Loads configuration, applies dictation settings updates, and saves it.
-pub async fn load_and_apply_dictation_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_dictation_settings(
+ ctx: &DispatchCtx,
update: DictationSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
@@ -440,7 +451,9 @@ pub async fn load_and_apply_dictation_settings(ctx: &DispatchCtx,
}
/// Returns the current voice server settings as a JSON object.
-pub async fn get_voice_server_settings(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn get_voice_server_settings(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
let result = json!({
"auto_start": config.voice_server.auto_start,
@@ -461,7 +474,8 @@ pub async fn get_voice_server_settings(ctx: &DispatchCtx, ) -> Result<Outcome<se
}
/// Loads configuration, applies voice server settings updates, and saves it.
-pub async fn load_and_apply_voice_server_settings(ctx: &DispatchCtx,
+pub async fn load_and_apply_voice_server_settings(
+ ctx: &DispatchCtx,
update: VoiceServerSettingsPatch,
) -> Result<Outcome<serde_json::Value>, String> {
let mut config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/config/ops_voice_and_autonomy_tests.rs b/crates/openhuman-core/src/config/ops_voice_and_autonomy_tests.rs
index 407505a191..96fd032818 100644
--- a/crates/openhuman-core/src/config/ops_voice_and_autonomy_tests.rs
+++ b/crates/openhuman-core/src/config/ops_voice_and_autonomy_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
#[tokio::test]
async fn get_config_snapshot_wraps_snapshot_in_rpc_outcome() {
@@ -30,7 +30,9 @@ async fn load_and_apply_dictation_settings_rejects_invalid_activation_mode() {
streaming: None,
streaming_interval_ms: None,
};
- let err = load_and_apply_dictation_settings(&DispatchCtx::process_default(), patch).await.unwrap_err();
+ let err = load_and_apply_dictation_settings(&DispatchCtx::process_default(), patch)
+ .await
+ .unwrap_err();
assert!(err.contains("invalid activation_mode"));
unsafe {
std::env::remove_var("OPENHUMAN_WORKSPACE");
@@ -82,7 +84,9 @@ async fn load_and_apply_dictation_settings_accepts_valid_modes() {
streaming_interval_ms: Some(500),
};
assert!(
- load_and_apply_dictation_settings(&DispatchCtx::process_default(), patch).await.is_ok(),
+ load_and_apply_dictation_settings(&DispatchCtx::process_default(), patch)
+ .await
+ .is_ok(),
"mode `{mode}` should be accepted"
);
}
@@ -174,7 +178,9 @@ async fn get_dictation_settings_reads_from_loaded_config() {
unsafe {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
- let outcome = get_dictation_settings(&DispatchCtx::process_default()).await.expect("ok");
+ let outcome = get_dictation_settings(&DispatchCtx::process_default())
+ .await
+ .expect("ok");
assert!(outcome.value.get("enabled").is_some());
assert!(outcome.value.get("hotkey").is_some());
assert!(outcome.value.get("streaming_interval_ms").is_some());
@@ -190,7 +196,9 @@ async fn get_voice_server_settings_reads_from_loaded_config() {
unsafe {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
- let outcome = get_voice_server_settings(&DispatchCtx::process_default()).await.expect("ok");
+ let outcome = get_voice_server_settings(&DispatchCtx::process_default())
+ .await
+ .expect("ok");
assert!(outcome.value.get("auto_start").is_some());
assert!(outcome.value.get("custom_dictionary").is_some());
unsafe {
@@ -205,7 +213,9 @@ async fn get_onboarding_completed_reads_from_loaded_config() {
unsafe {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
- let outcome = get_onboarding_completed(&DispatchCtx::process_default()).await.expect("ok");
+ let outcome = get_onboarding_completed(&DispatchCtx::process_default())
+ .await
+ .expect("ok");
// Default value — either true or false is fine; we just verify the call path.
let _ = outcome.value;
unsafe {
@@ -220,7 +230,9 @@ async fn load_and_resolve_api_url_returns_api_url_in_response() {
unsafe {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
- let outcome = load_and_resolve_api_url(&DispatchCtx::process_default()).await.expect("ok");
+ let outcome = load_and_resolve_api_url(&DispatchCtx::process_default())
+ .await
+ .expect("ok");
assert!(outcome.value.get("api_url").is_some());
unsafe {
std::env::remove_var("OPENHUMAN_WORKSPACE");
@@ -246,15 +258,20 @@ async fn workspace_onboarding_flag_resolve_rejects_invalid_and_defaults() {
unsafe {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
- let err = workspace_onboarding_flag_resolve(&DispatchCtx::process_default(), Some("a/b".into()), "done")
- .await
- .unwrap_err();
+ let err = workspace_onboarding_flag_resolve(
+ &DispatchCtx::process_default(),
+ Some("a/b".into()),
+ "done",
+ )
+ .await
+ .unwrap_err();
assert!(err.contains("Invalid onboarding flag"));
// Happy path: default name on a fresh workspace → file doesn't exist.
- let outcome = workspace_onboarding_flag_resolve(&DispatchCtx::process_default(), None, "onboarding.done")
- .await
- .expect("ok");
+ let outcome =
+ workspace_onboarding_flag_resolve(&DispatchCtx::process_default(), None, "onboarding.done")
+ .await
+ .expect("ok");
let _ = outcome.value;
unsafe {
std::env::remove_var("OPENHUMAN_WORKSPACE");
@@ -269,9 +286,14 @@ async fn workspace_onboarding_flag_set_rejects_invalid_names() {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
for bad in ["", " ", "a/b", "a\\b", ".."] {
- let err = workspace_onboarding_flag_set(&DispatchCtx::process_default(), Some(bad.into()), "default", true)
- .await
- .unwrap_err();
+ let err = workspace_onboarding_flag_set(
+ &DispatchCtx::process_default(),
+ Some(bad.into()),
+ "default",
+ true,
+ )
+ .await
+ .unwrap_err();
assert!(err.contains("Invalid onboarding flag"), "name {bad}: {err}");
}
unsafe {
@@ -287,14 +309,24 @@ async fn workspace_onboarding_flag_set_round_trip() {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
// Create flag
- let created = workspace_onboarding_flag_set(&DispatchCtx::process_default(), Some("onboarding.done".into()), "default", true)
- .await
- .expect("create");
+ let created = workspace_onboarding_flag_set(
+ &DispatchCtx::process_default(),
+ Some("onboarding.done".into()),
+ "default",
+ true,
+ )
+ .await
+ .expect("create");
assert!(created.value);
// Remove flag
- let removed = workspace_onboarding_flag_set(&DispatchCtx::process_default(), Some("onboarding.done".into()), "default", false)
- .await
- .expect("remove");
+ let removed = workspace_onboarding_flag_set(
+ &DispatchCtx::process_default(),
+ Some("onboarding.done".into()),
+ "default",
+ false,
+ )
+ .await
+ .expect("remove");
assert!(!removed.value);
unsafe {
std::env::remove_var("OPENHUMAN_WORKSPACE");
diff --git a/crates/openhuman-core/src/config/schemas/controllers/inference.rs b/crates/openhuman-core/src/config/schemas/controllers/inference.rs
index c85d5396ea..8e911e9250 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/inference.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/inference.rs
@@ -11,10 +11,7 @@ use super::super::helpers::{
RuntimeSettingsUpdate,
};
-pub(super) fn handle_get_config(
- ctx: DispatchCtx,
- _params: Map<String, Value>,
-) -> ControllerFuture {
+pub(super) fn handle_get_config(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move { to_json(config_rpc::load_and_get_config_snapshot(&ctx).await?) })
}
diff --git a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
index a598799a89..a692ffcbc0 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
@@ -19,7 +19,8 @@ pub(super) fn handle_workspace_onboarding_flag_exists(
Box::pin(async move {
let payload = deserialize_params::<WorkspaceOnboardingFlagParams>(params)?;
to_json(
- config_rpc::workspace_onboarding_flag_resolve(&ctx,
+ config_rpc::workspace_onboarding_flag_resolve(
+ &ctx,
payload.flag_name,
DEFAULT_ONBOARDING_FLAG_NAME,
)
@@ -35,7 +36,8 @@ pub(super) fn handle_workspace_onboarding_flag_set(
Box::pin(async move {
let payload = deserialize_params::<WorkspaceOnboardingFlagSetParams>(params)?;
to_json(
- config_rpc::workspace_onboarding_flag_set(&ctx,
+ config_rpc::workspace_onboarding_flag_set(
+ &ctx,
payload.flag_name,
DEFAULT_ONBOARDING_FLAG_NAME,
payload.value,
@@ -144,7 +146,8 @@ pub(crate) fn handle_get_data_paths(
/// the explicit id the core would fall back to the pre-login `users/local` dir
/// and leave the real user's data behind. Absent/blank → marker-based
/// resolution (the default used by the agent tool and diagnostics).
-async fn resolve_data_paths(ctx: &DispatchCtx,
+async fn resolve_data_paths(
+ ctx: &DispatchCtx,
params: Map<String, Value>,
) -> Result<crate::core::Outcome<Value>, String> {
let user_id = params
diff --git a/crates/openhuman-core/src/config/schemas_tests.rs b/crates/openhuman-core/src/config/schemas_tests.rs
index 46a3f2cc8d..2309a48a6d 100644
--- a/crates/openhuman-core/src/config/schemas_tests.rs
+++ b/crates/openhuman-core/src/config/schemas_tests.rs
@@ -298,7 +298,8 @@ async fn handle_get_autonomy_settings_returns_current_value() {
std::env::set_var("OPENHUMAN_WORKSPACE", tmp.path());
}
// Seed a known value before reading.
- let _ = crate::config::ops::load_and_apply_autonomy_settings(&DispatchCtx::process_default(),
+ let _ = crate::config::ops::load_and_apply_autonomy_settings(
+ &DispatchCtx::process_default(),
crate::config::ops::AutonomySettingsPatch {
max_actions_per_hour: Some(123),
..Default::default()
diff --git a/crates/openhuman-core/src/config/workspace/ops_tests.rs b/crates/openhuman-core/src/config/workspace/ops_tests.rs
index 98fb0923cb..e017c3c905 100644
--- a/crates/openhuman-core/src/config/workspace/ops_tests.rs
+++ b/crates/openhuman-core/src/config/workspace/ops_tests.rs
@@ -1,7 +1,7 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::test_env::EnvVarGuard;
use crate::config::TEST_ENV_LOCK as ENV_LOCK;
+use crate::core::runtime::DispatchCtx;
use tempfile::tempdir;
// ── ensure_workspace_file ──────────────────────────────────────
@@ -118,10 +118,14 @@ async fn init_workspace_reports_existing_entries_on_second_call_without_force()
let _env = EnvVarGuard::workspace_unlocked(tmp.path());
// First call populates the workspace.
- init_workspace(&DispatchCtx::process_default(), false).await.expect("first init ok");
+ init_workspace(&DispatchCtx::process_default(), false)
+ .await
+ .expect("first init ok");
// Second call without force should report everything as existing
// and nothing as created / overwritten.
- let value = init_workspace(&DispatchCtx::process_default(), false).await.expect("second init ok");
+ let value = init_workspace(&DispatchCtx::process_default(), false)
+ .await
+ .expect("second init ok");
let created = value["result"]["files"]["created"].as_array().unwrap();
let overwritten = value["result"]["files"]["overwritten"].as_array().unwrap();
@@ -151,7 +155,9 @@ async fn init_workspace_with_force_overwrites_existing_bootstrap_files() {
let tmp = tempdir().unwrap();
let _env = EnvVarGuard::workspace_unlocked(tmp.path());
- let first = init_workspace(&DispatchCtx::process_default(), false).await.expect("initial init");
+ let first = init_workspace(&DispatchCtx::process_default(), false)
+ .await
+ .expect("initial init");
// The config loader may place the workspace at a subpath of the
// env override (e.g. `{tmp}/workspace`), so discover the real
// location from the first result rather than assuming it is
@@ -164,7 +170,9 @@ async fn init_workspace_with_force_overwrites_existing_bootstrap_files() {
let soul = workspace_dir.join("SOUL.md");
std::fs::write(&soul, "corrupted").unwrap();
- let value = init_workspace(&DispatchCtx::process_default(), true).await.expect("forced init");
+ let value = init_workspace(&DispatchCtx::process_default(), true)
+ .await
+ .expect("forced init");
let overwritten: Vec<&str> = value["result"]["files"]["overwritten"]
.as_array()
diff --git a/crates/openhuman-core/src/core/invoke.rs b/crates/openhuman-core/src/core/invoke.rs
index 84243d46c5..1d77eb47d8 100644
--- a/crates/openhuman-core/src/core/invoke.rs
+++ b/crates/openhuman-core/src/core/invoke.rs
@@ -97,8 +97,9 @@ async fn invoke_scoped(
params: Value,
) -> Result<Value, String> {
let core = ctx.core().cloned();
- let call: std::pin::Pin<Box<dyn std::future::Future<Output = Result<Value, String>> + Send + '_>> =
- Box::pin(invoke_method_inner(ctx, state, method, params));
+ let call: std::pin::Pin<
+ Box<dyn std::future::Future<Output = Result<Value, String>> + Send + '_>,
+ > = Box::pin(invoke_method_inner(ctx, state, method, params));
match core {
Some(core) => CoreContext::scope(core, call).await,
None => call.await,
diff --git a/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs b/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
index 248612a111..536a3af490 100644
--- a/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
+++ b/crates/openhuman-core/src/desktop/app_state/ops/snapshot.rs
@@ -8,7 +8,6 @@
//! shell's `openhuman_tinyhumans::session` cache — so this snapshot never talks to the
//! backend.
-use crate::core::runtime::DispatchCtx;
use super::runtime_snapshot::{
build_runtime_snapshot, degraded_runtime_snapshot, RUNTIME_SNAPSHOT_TIMEOUT,
};
@@ -19,6 +18,7 @@ use super::state_file::{
use super::types::{AppStateSnapshot, StoredAppState, StoredAppStatePatch};
use super::LOG_PREFIX;
use crate::config::rpc as config_rpc;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::security::credentials::session_support::{
load_app_session_profile, session_state_from_profile,
@@ -39,7 +39,7 @@ pub(super) fn sanitize_snapshot_user(user: Option<Value>) -> Option<Value> {
}
}
-pub async fn snapshot(ctx: &DispatchCtx, ) -> Result<Outcome<AppStateSnapshot>, String> {
+pub async fn snapshot(ctx: &DispatchCtx) -> Result<Outcome<AppStateSnapshot>, String> {
let req_id = SNAPSHOT_REQ_COUNTER.fetch_add(1, Ordering::Relaxed);
let t_total = Instant::now();
@@ -141,7 +141,8 @@ pub async fn snapshot(ctx: &DispatchCtx, ) -> Result<Outcome<AppStateSnapshot>,
))
}
-pub async fn update_local_state(ctx: &DispatchCtx,
+pub async fn update_local_state(
+ ctx: &DispatchCtx,
patch: StoredAppStatePatch,
) -> Result<Outcome<StoredAppState>, String> {
let config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/desktop/app_state/schemas.rs b/crates/openhuman-core/src/desktop/app_state/schemas.rs
index c80a79d92d..1eaba75a62 100644
--- a/crates/openhuman-core/src/desktop/app_state/schemas.rs
+++ b/crates/openhuman-core/src/desktop/app_state/schemas.rs
@@ -105,11 +105,14 @@ fn handle_update_local_state(ctx: DispatchCtx, params: Map<String, Value>) -> Co
Box::pin(async move {
let payload: UpdateLocalStateParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- crate::desktop::app_state::update_local_state(&ctx, StoredAppStatePatch {
- encryption_key: payload.encryption_key,
- onboarding_tasks: payload.onboarding_tasks,
- keyring_consent: payload.keyring_consent,
- })
+ crate::desktop::app_state::update_local_state(
+ &ctx,
+ StoredAppStatePatch {
+ encryption_key: payload.encryption_key,
+ onboarding_tasks: payload.onboarding_tasks,
+ keyring_consent: payload.keyring_consent,
+ },
+ )
.await?
.into_cli_compatible_json()
})
diff --git a/crates/openhuman-core/src/desktop/notifications/rpc.rs b/crates/openhuman-core/src/desktop/notifications/rpc.rs
index e2c97a67b6..2468f4b99f 100644
--- a/crates/openhuman-core/src/desktop/notifications/rpc.rs
+++ b/crates/openhuman-core/src/desktop/notifications/rpc.rs
@@ -295,7 +295,10 @@ pub async fn handle_list(ctx: &DispatchCtx, params: Map<String, Value>) -> Resul
// ─────────────────────────────────────────────────────────────────────────────
/// Mark a single notification as read.
-pub async fn handle_mark_read(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_mark_read(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let id = params
@@ -314,7 +317,10 @@ pub async fn handle_mark_read(ctx: &DispatchCtx, params: Map<String, Value>) ->
}
/// Read notification routing settings for a provider.
-pub async fn handle_settings_get(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_settings_get(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let provider = params
.get("provider")
@@ -327,7 +333,10 @@ pub async fn handle_settings_get(ctx: &DispatchCtx, params: Map<String, Value>)
}
/// Upsert notification routing settings for a provider.
-pub async fn handle_settings_set(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_settings_set(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let req: NotificationSettingsUpsertRequest = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("[notification_intel] invalid settings_set params: {e}"))?;
@@ -348,7 +357,10 @@ pub async fn handle_settings_set(ctx: &DispatchCtx, params: Map<String, Value>)
// ─────────────────────────────────────────────────────────────────────────────
/// Mark a single notification as dismissed.
-pub async fn handle_dismiss(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_dismiss(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let id = params
.get("id")
@@ -368,7 +380,10 @@ pub async fn handle_dismiss(ctx: &DispatchCtx, params: Map<String, Value>) -> Re
// ─────────────────────────────────────────────────────────────────────────────
/// Mark a single notification as acted upon.
-pub async fn handle_mark_acted(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_mark_acted(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let id = params
.get("id")
@@ -397,7 +412,10 @@ pub async fn handle_mark_acted(ctx: &DispatchCtx, params: Map<String, Value>) ->
/// closed / disconnected — these are otherwise lost because the live channel
/// is broadcast-only. Optional params: `only_unread` (bool, default true),
/// `limit` (u64, default 100).
-pub async fn handle_core_list(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_core_list(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let only_unread = params
@@ -421,7 +439,10 @@ pub async fn handle_core_list(ctx: &DispatchCtx, params: Map<String, Value>) ->
/// Mark a persisted core notification as read so it isn't re-surfaced on the
/// next sync-down.
-pub async fn handle_core_mark_read(ctx: &DispatchCtx, params: Map<String, Value>) -> Result<Value, String> {
+pub async fn handle_core_mark_read(
+ ctx: &DispatchCtx,
+ params: Map<String, Value>,
+) -> Result<Value, String> {
let config = ctx.load_config().await?;
let id = params
.get("id")
diff --git a/crates/openhuman-core/src/flows/ops/builder.rs b/crates/openhuman-core/src/flows/ops/builder.rs
index df9606ea71..7c3acde563 100644
--- a/crates/openhuman-core/src/flows/ops/builder.rs
+++ b/crates/openhuman-core/src/flows/ops/builder.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
/// Runs the `workflow_builder` agent for one authoring turn and returns its
/// proposal, invoking it as a first-class backend agent (exactly like the Flow
@@ -16,7 +16,8 @@ use super::*;
/// Persistence stays with the agent's tools: `propose`/`revise` never persist;
/// `save_workflow` (only reachable in `build` mode with a real `flow_id`)
/// writes onto an existing flow. This op never enables or runs a flow.
-pub async fn flows_build(ctx: &DispatchCtx,
+pub async fn flows_build(
+ ctx: &DispatchCtx,
config: &Config,
req: crate::flows::agents::workflow_builder::builder_prompt::BuilderRequest,
stream: Option<FlowStreamTarget>,
@@ -30,7 +31,8 @@ pub async fn flows_build(ctx: &DispatchCtx,
/// This is intentionally crate-private: product surfaces use [`flows_build`]'s
/// normal builder belt. Host integrations that add their own persistence
/// boundary can hide tools that would bypass that boundary.
-pub(crate) async fn flows_build_with_extra_hidden_tools(ctx: &DispatchCtx,
+pub(crate) async fn flows_build_with_extra_hidden_tools(
+ ctx: &DispatchCtx,
config: &Config,
req: crate::flows::agents::workflow_builder::builder_prompt::BuilderRequest,
stream: Option<FlowStreamTarget>,
diff --git a/crates/openhuman-core/src/flows/ops/discovery.rs b/crates/openhuman-core/src/flows/ops/discovery.rs
index fd5546cd96..15a1bb6a06 100644
--- a/crates/openhuman-core/src/flows/ops/discovery.rs
+++ b/crates/openhuman-core/src/flows/ops/discovery.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
// ─────────────────────────────────────────────────────────────────────────────
// Flow Scout — workflow discovery + suggestion lifecycle
@@ -36,7 +36,8 @@ const FLOW_DISCOVER_PROMPT: &str = "Discover the most useful automations you cou
/// (`PermissionLevel::None`) — so this never persists, enables, or runs a flow.
/// Turning a suggestion into a real flow is the user's separate "Build this"
/// action, which routes to `workflow_builder`.
-pub async fn flows_discover(ctx: &DispatchCtx,
+pub async fn flows_discover(
+ ctx: &DispatchCtx,
config: &Config,
stream: Option<FlowStreamTarget>,
) -> Result<Outcome<Vec<FlowSuggestion>>, String> {
diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rs
index 377689dec1..cdcbcbb7ef 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
// ─────────────────────────────────────────────────────────────────────────────
// Copilot / scout streaming (Phase B) — bridge a builder/scout turn's live
@@ -91,7 +91,8 @@ pub(super) fn attach_flow_progress_bridge(
/// path, so segmentation/reaction match a normal turn), a failure publishes a
/// `chat_error`. Broadcast as `"system"` so any viewer of the thread receives
/// it (frontend keys by `thread_id`).
-pub(super) async fn finalize_flow_stream(ctx: &DispatchCtx,
+pub(super) async fn finalize_flow_stream(
+ ctx: &DispatchCtx,
target: &FlowStreamTarget,
result: &Result<String, String>,
prompt: &str,
diff --git a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
index fef54331c2..c69b242e18 100644
--- a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use crate::{
config::Config,
flows::{
@@ -64,10 +64,15 @@ fn repair_backend_failure_returns_no_proposal_before_starting_the_builder() {
failing_node_ids: vec!["fetch".to_string()],
};
- let outcome =
- flows_build_with_extra_hidden_tools(&DispatchCtx::process_default(), &Config::default(), req.clone(), None, &[])
- .await
- .expect("backend failure should short-circuit before the builder starts");
+ let outcome = flows_build_with_extra_hidden_tools(
+ &DispatchCtx::process_default(),
+ &Config::default(),
+ req.clone(),
+ None,
+ &[],
+ )
+ .await
+ .expect("backend failure should short-circuit before the builder starts");
assert_eq!(outcome.value["proposal"], Value::Null);
assert_eq!(outcome.value["error"], Value::Null);
@@ -83,9 +88,15 @@ fn repair_backend_failure_returns_no_proposal_before_starting_the_builder() {
};
let mut events = crate::web_chat::subscribe_web_channel_events();
- flows_build_with_extra_hidden_tools(&DispatchCtx::process_default(), &Config::default(), req, Some(stream), &[])
- .await
- .expect("streamed backend failure should short-circuit before the builder starts");
+ flows_build_with_extra_hidden_tools(
+ &DispatchCtx::process_default(),
+ &Config::default(),
+ req,
+ Some(stream),
+ &[],
+ )
+ .await
+ .expect("streamed backend failure should short-circuit before the builder starts");
let done = loop {
match events.try_recv() {
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
index d87c11ca0d..ac052d3f04 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/code.rs
@@ -71,9 +71,14 @@ impl CodeRunner for OpenHumanCode {
let action = json!({ "language": format!("{language:?}"), "source": source });
let summary = crate::security::approval::summarize_action("flows_code", &action);
let redacted = crate::security::approval::redact_args(&action);
- let (gate_outcome, audit_id) =
- gate_call_for_tier(&self.approval, tier_decision, "flows_code", &summary, redacted)
- .await;
+ let (gate_outcome, audit_id) = gate_call_for_tier(
+ &self.approval,
+ tier_decision,
+ "flows_code",
+ &summary,
+ redacted,
+ )
+ .await;
if let crate::security::approval::GateOutcome::Deny { reason } = gate_outcome {
return Err(EngineError::Capability(reason));
}
diff --git a/crates/openhuman-core/src/hooks/host.rs b/crates/openhuman-core/src/hooks/host.rs
index b60207f97b..54a7f2d1dc 100644
--- a/crates/openhuman-core/src/hooks/host.rs
+++ b/crates/openhuman-core/src/hooks/host.rs
@@ -47,7 +47,8 @@ pub fn engine() -> &'static HookEngine {
/// with, which froze the home directory at first use. Discovery resolves the
/// user layer against the home directory **now**, as it did before the engine
/// moved upstream, so a reload after `HOME` changes reads the right file.
-pub async fn reload(ctx: &DispatchCtx,
+pub async fn reload(
+ ctx: &DispatchCtx,
project_dir: Option<std::path::PathBuf>,
workspace_dir: Option<std::path::PathBuf>,
) -> Arc<HookConfig> {
diff --git a/crates/openhuman-core/src/hooks/ops.rs b/crates/openhuman-core/src/hooks/ops.rs
index 7008185a9c..19b6e530fe 100644
--- a/crates/openhuman-core/src/hooks/ops.rs
+++ b/crates/openhuman-core/src/hooks/ops.rs
@@ -43,7 +43,8 @@ pub async fn init(ctx: &DispatchCtx, config: &crate::config::schema::Config) {
super::host::engine()
.set_default_timeout(Duration::from_secs(settings.default_timeout_secs))
.await;
- let loaded = super::host::reload(&ctx,
+ let loaded = super::host::reload(
+ &ctx,
Some(config.action_dir.clone()),
Some(config.workspace_dir.clone()),
)
diff --git a/crates/openhuman-core/src/hooks/prompt_eval.rs b/crates/openhuman-core/src/hooks/prompt_eval.rs
index caf0d20033..74affd20d0 100644
--- a/crates/openhuman-core/src/hooks/prompt_eval.rs
+++ b/crates/openhuman-core/src/hooks/prompt_eval.rs
@@ -11,16 +11,21 @@
//! keeps the override scoped to this evaluation: nothing persists, and a
//! concurrent turn on the real config is unaffected.
-use crate::core::runtime::DispatchCtx;
use crate::config::schema::Config;
+use crate::core::runtime::DispatchCtx;
/// Ask the model to judge a hook condition, returning its raw answer.
///
/// Errors are strings rather than `anyhow` because every caller folds them into
/// the fail-open / fail-closed decision, where the only thing that matters is
/// the message.
-pub async fn evaluate(ctx: &DispatchCtx, instruction: &str, model: Option<&str>) -> Result<String, String> {
- let mut config = ctx.load_config()
+pub async fn evaluate(
+ ctx: &DispatchCtx,
+ instruction: &str,
+ model: Option<&str>,
+) -> Result<String, String> {
+ let mut config = ctx
+ .load_config()
.await
.map_err(|error| format!("loading config for prompt hook: {error}"))?;
if let Some(model) = model {
diff --git a/crates/openhuman-core/src/hooks/shell.rs b/crates/openhuman-core/src/hooks/shell.rs
index be58a0e44a..7fd8761a31 100644
--- a/crates/openhuman-core/src/hooks/shell.rs
+++ b/crates/openhuman-core/src/hooks/shell.rs
@@ -27,7 +27,7 @@ fn slot() -> &'static RwLock<Option<ShellInvocation>> {
/// Ask TinyBox which shell it selects and remember it for [`command`].
///
/// A failure is logged and leaves any earlier selection in place.
-pub(super) async fn resolve(ctx: &DispatchCtx, ) {
+pub(super) async fn resolve(ctx: &DispatchCtx) {
#[cfg(feature = "modules")]
{
let config = match ctx.load_config().await {
diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
index 99bb34e691..839cdafe0b 100644
--- a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
@@ -1,8 +1,8 @@
//! Embedding settings: reading the current configuration and applying an
//! update, including the save-time verification of a custom endpoint.
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::security::credentials::AuthService;
@@ -193,7 +193,8 @@ pub async fn get_settings(config: &Config) -> Result<Outcome<serde_json::Value>,
/// Updates embedding provider/model/dimensions. Nothing persisted depends on
/// the embedding signature any more (memory v2 engines embed server-side), so a
/// change applies directly.
-pub async fn update_settings(ctx: &DispatchCtx,
+pub async fn update_settings(
+ ctx: &DispatchCtx,
provider: Option<String>,
model: Option<String>,
dimensions: Option<usize>,
diff --git a/crates/openhuman-core/src/inference/embedding_host/schemas.rs b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
index ce0acb620a..3f597a2ee2 100644
--- a/crates/openhuman-core/src/inference/embedding_host/schemas.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/schemas.rs
@@ -182,7 +182,8 @@ fn handle_update_settings(ctx: DispatchCtx, params: Map<String, Value>) -> Contr
Box::pin(async move {
let p = deserialize_params::<UpdateSettingsParams>(params)?;
to_json(
- super::rpc::update_settings(&ctx,
+ super::rpc::update_settings(
+ &ctx,
p.provider,
p.model,
p.dimensions,
diff --git a/crates/openhuman-core/src/inference/ops.rs b/crates/openhuman-core/src/inference/ops.rs
index 2c7688ca0a..7a5b5d01c3 100644
--- a/crates/openhuman-core/src/inference/ops.rs
+++ b/crates/openhuman-core/src/inference/ops.rs
@@ -1,8 +1,8 @@
//! JSON-RPC controller surface for inference operations.
-use crate::core::runtime::DispatchCtx;
use crate::config::rpc as config_rpc;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::inference::host_runtime as local_runtime;
use crate::inference::provider as providers;
@@ -251,7 +251,7 @@ pub async fn inference_analyze_sentiment(
result
}
-pub async fn inference_get_client_config(ctx: &DispatchCtx, ) -> Result<Outcome<Value>, String> {
+pub async fn inference_get_client_config(ctx: &DispatchCtx) -> Result<Outcome<Value>, String> {
debug!("{LOG_PREFIX} get_client_config:start");
let result = config_rpc::load_and_get_client_config_snapshot(&ctx).await;
match &result {
@@ -261,7 +261,8 @@ pub async fn inference_get_client_config(ctx: &DispatchCtx, ) -> Result<Outcome<
result
}
-pub async fn inference_update_model_settings(ctx: &DispatchCtx,
+pub async fn inference_update_model_settings(
+ ctx: &DispatchCtx,
update: config_rpc::ModelSettingsPatch,
) -> Result<Outcome<Value>, String> {
debug!("{LOG_PREFIX} update_model_settings:start");
@@ -273,7 +274,8 @@ pub async fn inference_update_model_settings(ctx: &DispatchCtx,
result
}
-pub async fn inference_update_local_settings(ctx: &DispatchCtx,
+pub async fn inference_update_local_settings(
+ ctx: &DispatchCtx,
update: config_rpc::LocalAiSettingsPatch,
) -> Result<Outcome<Value>, String> {
debug!("{LOG_PREFIX} update_local_settings:start");
diff --git a/crates/openhuman-core/src/inference/ops_tests.rs b/crates/openhuman-core/src/inference/ops_tests.rs
index ae3594211e..75d1f0acdf 100644
--- a/crates/openhuman-core/src/inference/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/ops_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use crate::security::credentials::openai_oauth::{OPENAI_OAUTH_PROFILE_NAME, OPENAI_PROVIDER_KEY};
use crate::security::credentials::profiles::{AuthProfile, AuthProfilesStore, TokenSet};
use axum::{routing::post, Json, Router};
diff --git a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
index 839e5a29a1..127e93b7e1 100644
--- a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
@@ -118,7 +118,9 @@ pub(super) fn handle_inference_get_client_config(
ctx: DispatchCtx,
_params: Map<String, Value>,
) -> ControllerFuture {
- Box::pin(async move { to_json(crate::inference::rpc::inference_get_client_config(&ctx).await?) })
+ Box::pin(
+ async move { to_json(crate::inference::rpc::inference_get_client_config(&ctx).await?) },
+ )
}
pub(super) fn handle_inference_update_model_settings(
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index 6bd2537f8e..60210974d0 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -440,7 +440,8 @@ pub(crate) mod module_stub;
mod repl_module_tests;
/// Run a typed query inside TinyJuice; cached originals stay inside the module.
-pub async fn query(ctx: &DispatchCtx,
+pub async fn query(
+ ctx: &DispatchCtx,
request: tinyjuice_bus::wire::QueryRequest,
) -> Result<tinyjuice_bus::wire::QueryResponse, String> {
let config = ctx.load_config().await?;
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rs
index 2189b31c39..aa0a3a39d4 100644
--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs
+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs
@@ -240,7 +240,8 @@ impl Tool for ComposioActionTool {
}
async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {
- let (config, outcome) = Box::pin(self.execute_unredacted(&DispatchCtx::ambient(), args, None)).await;
+ let (config, outcome) =
+ Box::pin(self.execute_unredacted(&DispatchCtx::ambient(), args, None)).await;
super::tools::redact_composio_outcome(&config, outcome)
}
async fn execute_with_context(
@@ -249,8 +250,12 @@ impl Tool for ComposioActionTool {
_options: ToolCallOptions,
context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
- let (config, outcome) =
- Box::pin(self.execute_unredacted(&DispatchCtx::ambient(), args, sandbox_mode_for_tool(context))).await;
+ let (config, outcome) = Box::pin(self.execute_unredacted(
+ &DispatchCtx::ambient(),
+ args,
+ sandbox_mode_for_tool(context),
+ ))
+ .await;
super::tools::redact_composio_outcome(&config, outcome)
}
}
@@ -261,7 +266,8 @@ impl ComposioActionTool {
/// credential that dispatched — for both a spawn-time config and a
/// deferred instance with none.
async fn execute_unredacted(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
args: Value,
sandbox_mode: Option<SandboxMode>,
) -> (Box<Config>, anyhow::Result<ToolResult>) {
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs b/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs
index fa9718c3d8..e3bce41545 100644
--- a/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/action_tool_tests.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::test_env::EnvVarGuard;
+use crate::core::runtime::DispatchCtx;
/// Build a minimal `Arc<Config>` with `composio.mode = "backend"`
/// (the default). The sandbox gate runs *before* any HTTP call or
@@ -496,8 +496,12 @@ fn deferred_instance_returns_live_config_for_redaction() {
);
// Boxed exactly like `Tool::execute` does.
- let (live_config, outcome) =
- Box::pin(t.execute_unredacted(&DispatchCtx::process_default(), serde_json::json!({}), None)).await;
+ let (live_config, outcome) = Box::pin(t.execute_unredacted(
+ &DispatchCtx::process_default(),
+ serde_json::json!({}),
+ None,
+ ))
+ .await;
let first = outcome.expect("contract-gate surface is Ok(error result)");
assert!(
first.is_error && error_text(&first).contains("Input JSON schema"),
diff --git a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
index a268b13c42..e576fdc3f3 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs
@@ -90,7 +90,9 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {
// The cache refresh runs for every toolkit; only the profile fetch is gated on a native provider.
let toolkit = toolkit.clone();
let connection_id = connection_id.clone();
- tokio::spawn(async move { on_connection_created(&DispatchCtx::ambient(), toolkit, connection_id).await });
+ tokio::spawn(async move {
+ on_connection_created(&DispatchCtx::ambient(), toolkit, connection_id).await
+ });
}
}
diff --git a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
index 83de45bc56..9c36586417 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
@@ -1,7 +1,7 @@
//! Direct mode (BYO API key) ops.
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use super::super::{
@@ -72,7 +72,8 @@ pub async fn composio_get_mode(config: &Config) -> OpResult<Outcome<serde_json::
/// (optionally) flip `config.composio.mode` over to `"direct"`.
///
/// **Logging redacts the key** — only its length and presence are recorded.
-pub async fn composio_set_api_key(ctx: &DispatchCtx,
+pub async fn composio_set_api_key(
+ ctx: &DispatchCtx,
config: &Config,
api_key: &str,
activate_direct: bool,
@@ -93,7 +94,8 @@ pub async fn composio_set_api_key(ctx: &DispatchCtx,
.map_err(|e| format!("[composio-direct] store_composio_api_key failed: {e}"))?;
let mode_log = if activate_direct {
- let mut cfg_mut = ctx.load_config()
+ let mut cfg_mut = ctx
+ .load_config()
.await
.map_err(|e| format!("[composio-direct] reload config failed: {e}"))?;
cfg_mut.composio.mode = crate::config::schema::COMPOSIO_MODE_DIRECT.into();
@@ -132,13 +134,17 @@ pub async fn composio_set_api_key(ctx: &DispatchCtx,
/// Clear the stored direct-mode API key and reset
/// `config.composio.mode` back to `"backend"`.
-pub async fn composio_clear_api_key(ctx: &DispatchCtx, config: &Config) -> OpResult<Outcome<serde_json::Value>> {
+pub async fn composio_clear_api_key(
+ ctx: &DispatchCtx,
+ config: &Config,
+) -> OpResult<Outcome<serde_json::Value>> {
tracing::debug!("[composio-direct] clear_api_key");
crate::security::credentials::clear_composio_api_key(config)
.await
.map_err(|e| format!("[composio-direct] clear_composio_api_key failed: {e}"))?;
- let mut cfg_mut = ctx.load_config()
+ let mut cfg_mut = ctx
+ .load_config()
.await
.map_err(|e| format!("[composio-direct] reload config failed: {e}"))?;
cfg_mut.composio.mode = crate::config::schema::COMPOSIO_MODE_BACKEND.into();
diff --git a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
index f111c8de4e..a47205e25a 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
#[tokio::test]
async fn composio_set_api_key_rejects_invalid_direct_key_before_persisting() {
@@ -24,9 +24,14 @@ async fn composio_set_api_key_rejects_invalid_direct_key_before_persisting() {
let config = direct_mode_no_key_config(&tmp);
let _auth_guard = DirectAuthFailureGuard::new("ck_invalid_direct");
- let err = composio_set_api_key(&DispatchCtx::process_default(), &config, "ck_invalid_direct", false)
- .await
- .expect_err("invalid direct-mode key must be rejected before persistence");
+ let err = composio_set_api_key(
+ &DispatchCtx::process_default(),
+ &config,
+ "ck_invalid_direct",
+ false,
+ )
+ .await
+ .expect_err("invalid direct-mode key must be rejected before persistence");
assert!(
err.contains("Invalid Composio API key"),
"unexpected error: {err}"
@@ -80,9 +85,14 @@ async fn composio_set_api_key_validates_candidate_key_even_when_stored_key_exist
.expect("seed old stored composio key");
let _new_key_guard = DirectAuthFailureGuard::new("ck_new_invalid");
- let err = composio_set_api_key(&DispatchCtx::process_default(), &config, "ck_new_invalid", false)
- .await
- .expect_err("candidate invalid key must be rejected even if old stored key is valid");
+ let err = composio_set_api_key(
+ &DispatchCtx::process_default(),
+ &config,
+ "ck_new_invalid",
+ false,
+ )
+ .await
+ .expect_err("candidate invalid key must be rejected even if old stored key is valid");
assert!(
err.contains("Invalid Composio API key"),
"unexpected error: {err}"
diff --git a/crates/openhuman-core/src/integrations/task_sources/bus.rs b/crates/openhuman-core/src/integrations/task_sources/bus.rs
index 94d5eca429..94003e11ea 100644
--- a/crates/openhuman-core/src/integrations/task_sources/bus.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/bus.rs
@@ -63,7 +63,12 @@ impl EventHandler<DomainEvent> for TaskSourcesConnectionSubscriber {
/// loaded inside it — so an agent whose own config disables task sources is
/// skipped even when the process config enables them, and the other way
/// round.
-async fn fire_in_scope(ctx: &DispatchCtx, provider: ProviderSlug, toolkit: &str, connection_id: &str) {
+async fn fire_in_scope(
+ ctx: &DispatchCtx,
+ provider: ProviderSlug,
+ toolkit: &str,
+ connection_id: &str,
+) {
let config = match ctx.load_config().await {
Ok(config) => config,
Err(e) => {
diff --git a/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs b/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
index d181fb1364..e08d7b89e1 100644
--- a/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use crate::integrations::task_sources::types::{FilterSpec, SourceTarget};
use serde_json::json;
@@ -91,5 +91,11 @@ async fn a_connection_event_is_handled_per_scope() {
connection_id: "conn-1".to_string(),
})
.await;
- fire_in_scope(&DispatchCtx::process_default(), ProviderSlug::Github, "github", "conn-1").await;
+ fire_in_scope(
+ &DispatchCtx::process_default(),
+ ProviderSlug::Github,
+ "github",
+ "conn-1",
+ )
+ .await;
}
diff --git a/crates/openhuman-core/src/integrations/task_sources/periodic.rs b/crates/openhuman-core/src/integrations/task_sources/periodic.rs
index abe88885ee..a98457475a 100644
--- a/crates/openhuman-core/src/integrations/task_sources/periodic.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/periodic.rs
@@ -103,7 +103,8 @@ async fn run_loop() {
for (agent, result) in
crate::storage::agents::for_each_live_scope("task_sources", || async {
run_one_tick(&DispatchCtx::ambient()).await
- }).await
+ })
+ .await
{
if let Err(e) = result {
tracing::warn!(error = %e, agent = agent.as_deref().unwrap_or("local"), "[task_sources:periodic] tick failed (continuing)");
@@ -114,8 +115,9 @@ async fn run_loop() {
/// Run a single scheduler tick. `pub(crate)` so tests can drive ticks
/// without the real `interval`.
-pub(crate) async fn run_one_tick(ctx: &DispatchCtx, ) -> Result<(), String> {
- let config = ctx.load_config()
+pub(crate) async fn run_one_tick(ctx: &DispatchCtx) -> Result<(), String> {
+ let config = ctx
+ .load_config()
.await
.map_err(|e| format!("load_config: {e}"))?;
diff --git a/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs b/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs
index f2a7260d7e..0b1c6917e7 100644
--- a/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/periodic_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use crate::integrations::task_sources::types::{
provider_can_fetch, FilterSpec, ProviderSlug, SourceTarget,
};
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 2b3cb2970f..50846925e9 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -34,7 +34,7 @@ fn finish<T: Serialize>(result: MemoryResult<T>) -> Result<Value, String> {
to_json(result.map_err(String::from)?)
}
-async fn load(ctx: &DispatchCtx, ) -> Result<Config, String> {
+async fn load(ctx: &DispatchCtx) -> Result<Config, String> {
ctx.load_config().await
}
diff --git a/crates/openhuman-core/src/modules/wallet_host.rs b/crates/openhuman-core/src/modules/wallet_host.rs
index e54fd2b4f7..daf9f43c85 100644
--- a/crates/openhuman-core/src/modules/wallet_host.rs
+++ b/crates/openhuman-core/src/modules/wallet_host.rs
@@ -693,10 +693,8 @@ impl WalletHost {
&self,
request: AuthorizeX402PaymentRequest,
) -> tinybus::Result<HostResponse> {
- let owner_matches = x402_request_owner_matches(
- &request,
- crate::agent::turn_origin::current().as_ref(),
- );
+ let owner_matches =
+ x402_request_owner_matches(&request, crate::agent::turn_origin::current().as_ref());
let approved = if owner_matches {
if let Some(gate) = crate::security::approval::ApprovalGate::try_global() {
matches!(
diff --git a/crates/openhuman-core/src/platform/socket/ops.rs b/crates/openhuman-core/src/platform/socket/ops.rs
index e3a75eccd4..f78e426294 100644
--- a/crates/openhuman-core/src/platform/socket/ops.rs
+++ b/crates/openhuman-core/src/platform/socket/ops.rs
@@ -50,7 +50,10 @@ async fn connect_with_session_using(
Ok(manager.get_state())
}
-pub async fn connect_with_session(ctx: &DispatchCtx, manager: &SocketManager) -> Result<SocketState, String> {
+pub async fn connect_with_session(
+ ctx: &DispatchCtx,
+ manager: &SocketManager,
+) -> Result<SocketState, String> {
log::info!("[socket:rpc] connect_with_session — resolving credentials");
let config = std::sync::Arc::new(ctx.load_config().await?);
let api_url = crate::backend::require_base_url(&config.api_url)?;
diff --git a/crates/openhuman-core/src/platform/update/ops.rs b/crates/openhuman-core/src/platform/update/ops.rs
index efc4fd25d9..0e908979ec 100644
--- a/crates/openhuman-core/src/platform/update/ops.rs
+++ b/crates/openhuman-core/src/platform/update/ops.rs
@@ -10,14 +10,17 @@ use crate::core::Outcome;
use crate::platform::update;
use crate::platform::update::types::{UpdateApplyResult, UpdateInfo, UpdateRunResult, VersionInfo};
-async fn load_update_policy(ctx: &DispatchCtx, ) -> Result<UpdateConfig, String> {
+async fn load_update_policy(ctx: &DispatchCtx) -> Result<UpdateConfig, String> {
ctx.load_config()
.await
.map(|cfg| cfg.update)
.map_err(|err| format!("failed to load config for update policy: {err}"))
}
-async fn enforce_update_mutation_policy(ctx: &DispatchCtx, method: &str) -> Result<UpdateConfig, String> {
+async fn enforce_update_mutation_policy(
+ ctx: &DispatchCtx,
+ method: &str,
+) -> Result<UpdateConfig, String> {
let policy = load_update_policy(&ctx).await.map_err(|err| {
let message = format!(
"{method} blocked: {err}; failing closed because update policy could not be loaded"
@@ -178,7 +181,7 @@ pub async fn update_version() -> Outcome<Value> {
/// update was applied the function publishes a restart request before
/// returning, so the caller will see `restart_requested: true` and the
/// core process will exit shortly afterwards.
-pub async fn update_run(ctx: &DispatchCtx, ) -> Outcome<Value> {
+pub async fn update_run(ctx: &DispatchCtx) -> Outcome<Value> {
log::info!("[update:rpc] update_run invoked");
let policy = match enforce_update_mutation_policy(&ctx, "openhuman.update_run").await {
Ok(policy) => policy,
@@ -342,7 +345,8 @@ fn validate_asset_name(name: &str) -> Result<(), String> {
/// - `asset_name` (string, required): must be a safe filename starting with `openhuman-core-`.
/// - `staging_dir` (string, optional): ignored — always uses the default staging directory
/// for security (next to the running executable or Resources/).
-pub async fn update_apply(ctx: &DispatchCtx,
+pub async fn update_apply(
+ ctx: &DispatchCtx,
download_url: String,
asset_name: String,
_staging_dir: Option<String>,
diff --git a/crates/openhuman-core/src/platform/update/ops_tests.rs b/crates/openhuman-core/src/platform/update/ops_tests.rs
index 72c335744a..68ec931cb9 100644
--- a/crates/openhuman-core/src/platform/update/ops_tests.rs
+++ b/crates/openhuman-core/src/platform/update/ops_tests.rs
@@ -10,9 +10,9 @@
//! - `build_run_result_from_staged_update` sets `restart_requested = false`
//! under the `Supervisor` strategy.
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::UpdateRestartStrategy;
+use crate::core::runtime::DispatchCtx;
use crate::platform::update::types::{UpdateApplyResult, UpdateInfo};
// ── update_version ────────────────────────────────────────────────────────────
diff --git a/crates/openhuman-core/src/platform/update/ops_tests_2_tests.rs b/crates/openhuman-core/src/platform/update/ops_tests_2_tests.rs
index 4cf0be231a..08d74884b9 100644
--- a/crates/openhuman-core/src/platform/update/ops_tests_2_tests.rs
+++ b/crates/openhuman-core/src/platform/update/ops_tests_2_tests.rs
@@ -1,7 +1,7 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::test_env::EnvVarGuard;
use crate::config::TEST_ENV_LOCK;
+use crate::core::runtime::DispatchCtx;
use tempfile::TempDir;
async fn write_update_policy(tmp: &TempDir, update: UpdateConfig) {
@@ -102,7 +102,8 @@ fn validate_asset_name_rejects_unprefixed_asset() {
#[tokio::test]
async fn update_apply_rejects_non_github_url_before_network_call() {
let _guard = TEST_ENV_LOCK.lock().await;
- let outcome = update_apply(&DispatchCtx::process_default(),
+ let outcome = update_apply(
+ &DispatchCtx::process_default(),
"https://evil.example.com/asset".to_string(),
"openhuman-core-x86_64.tar.gz".to_string(),
None,
@@ -118,7 +119,8 @@ async fn update_apply_rejects_non_github_url_before_network_call() {
#[tokio::test]
async fn update_apply_rejects_unsafe_asset_name() {
let _guard = TEST_ENV_LOCK.lock().await;
- let outcome = update_apply(&DispatchCtx::process_default(),
+ let outcome = update_apply(
+ &DispatchCtx::process_default(),
"https://github.com/owner/repo/releases/download/v1/x".to_string(),
"../etc/passwd".to_string(),
None,
@@ -145,7 +147,8 @@ async fn update_apply_rejects_when_rpc_mutations_disabled() {
)
.await;
- let outcome = update_apply(&DispatchCtx::process_default(),
+ let outcome = update_apply(
+ &DispatchCtx::process_default(),
"https://github.com/owner/repo/releases/download/v1/x".to_string(),
"openhuman-core-x86_64.tar.gz".to_string(),
None,
diff --git a/crates/openhuman-core/src/platform/update/schemas.rs b/crates/openhuman-core/src/platform/update/schemas.rs
index fdf9f3d23a..9ce6bce89b 100644
--- a/crates/openhuman-core/src/platform/update/schemas.rs
+++ b/crates/openhuman-core/src/platform/update/schemas.rs
@@ -152,7 +152,8 @@ fn handle_apply(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
.map(|s| s.to_string());
to_json(
- crate::platform::update::rpc::update_apply(&ctx, download_url, asset_name, staging_dir).await,
+ crate::platform::update::rpc::update_apply(&ctx, download_url, asset_name, staging_dir)
+ .await,
)
})
}
diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rs
index 098eb6683d..87066881e5 100644
--- a/crates/openhuman-core/src/profiles/host_tests.rs
+++ b/crates/openhuman-core/src/profiles/host_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
fn host(tmp: &tempfile::TempDir, max_open: usize, idle_secs: u64) -> ProfileHost {
let mut saas = SaasConfig::new(tmp.path());
@@ -396,7 +396,9 @@ async fn the_operators_cron_limits_bind_every_profile_whatever_its_config_says()
let forced = host.provisioned_config(&id).await.unwrap();
let opened = host.open(&id).await.unwrap();
let loaded = CoreContext::scope(Arc::clone(opened.context()), async {
- crate::config::ops::load_current_or_init(&DispatchCtx::process_default()).await.unwrap()
+ crate::config::ops::load_current_or_init(&DispatchCtx::process_default())
+ .await
+ .unwrap()
})
.await;
for config in [&forced, &opened.config, &loaded] {
diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rs
index 80ade801dc..33cb747e0a 100644
--- a/crates/openhuman-core/src/sandbox/ops.rs
+++ b/crates/openhuman-core/src/sandbox/ops.rs
@@ -1,13 +1,13 @@
//! Sandbox backend operations — policy resolution, backend creation, and
//! routed execution.
-use crate::core::runtime::DispatchCtx;
use super::docker;
use super::types::{
ElevatedOp, SandboxBackendHandle, SandboxBackendKind, SandboxExecRequest, SandboxExecResult,
SandboxPolicy, SandboxStatus, ELEVATED_TOOLS,
};
use crate::config::{RuntimeConfig, SandboxBackend, SandboxConfig};
+use crate::core::runtime::DispatchCtx;
use std::collections::HashMap;
use std::ffi::OsString;
use std::path::Path;
@@ -46,7 +46,10 @@ pub fn sandbox_off_value(value: Option<&str>) -> bool {
/// Whether a command tool must use the sandbox execution path. An explicit
/// backend in the active config is an operator requirement even when the
/// agent definition uses the usual `SandboxMode::None` default.
-pub async fn command_requires_sandbox(ctx: &DispatchCtx, sandbox_mode: Option<SandboxMode>) -> Result<bool, String> {
+pub async fn command_requires_sandbox(
+ ctx: &DispatchCtx,
+ sandbox_mode: Option<SandboxMode>,
+) -> Result<bool, String> {
if crate::core::runtime::is_saas() {
// Every SaaS command must enter the per-user container path, including
// language tools whose agent definition does not request a sandbox.
@@ -74,14 +77,16 @@ pub async fn command_requires_sandbox(ctx: &DispatchCtx, sandbox_mode: Option<Sa
/// Resolve the policy for a command tool before building its command line.
/// SaaS always uses the user's container; other hosts apply the operator's
/// backend selection while retaining an agent-level sandbox requirement.
-pub(crate) async fn resolve_command_policy(ctx: &DispatchCtx,
+pub(crate) async fn resolve_command_policy(
+ ctx: &DispatchCtx,
action_dir: &Path,
state_dir: &Path,
) -> Result<SandboxPolicy, String> {
if crate::core::runtime::is_saas() {
return crate::profiles::tools::sandbox_policy(action_dir, state_dir);
}
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|error| format!("Cannot read sandbox configuration: {error}"))?;
let mut policy = resolve_sandbox_policy(
@@ -223,7 +228,10 @@ pub(crate) fn local_status_for_jail(
}
}
-pub async fn create_sandbox_backend(ctx: &DispatchCtx, policy: &SandboxPolicy) -> SandboxBackendHandle {
+pub async fn create_sandbox_backend(
+ ctx: &DispatchCtx,
+ policy: &SandboxPolicy,
+) -> SandboxBackendHandle {
if policy.backend != SandboxBackendKind::Docker {
return create_sandbox_backend_with_config(policy, &crate::config::Config::default())
.await
@@ -286,7 +294,8 @@ fn docker_error_handle() -> SandboxBackendHandle {
///
/// Returns the sandboxed execution result. The caller (typically the
/// shell tool) is responsible for converting this into a `ToolResult`.
-pub async fn execute_in_sandbox(ctx: &DispatchCtx,
+pub async fn execute_in_sandbox(
+ ctx: &DispatchCtx,
policy: &SandboxPolicy,
command: &str,
working_dir: &Path,
@@ -299,7 +308,8 @@ pub async fn execute_in_sandbox(ctx: &DispatchCtx,
/// [`execute_in_sandbox`] that feeds `meter` with the command's output as it
/// streams (the native backends; Docker reports elapsed time only), for the
/// shell tool's progress line.
-pub(crate) async fn execute_in_sandbox_metered(ctx: &DispatchCtx,
+pub(crate) async fn execute_in_sandbox_metered(
+ ctx: &DispatchCtx,
policy: &SandboxPolicy,
command: &str,
working_dir: &Path,
@@ -318,7 +328,8 @@ pub(crate) async fn execute_in_sandbox_metered(ctx: &DispatchCtx,
let explicitly_requested = if crate::core::runtime::is_saas() || sandbox_disabled_by_host() {
false
} else {
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|e| anyhow::anyhow!("Cannot read sandbox configuration: {e}"))?;
module_config = Some(config.clone());
@@ -350,11 +361,9 @@ pub(crate) async fn execute_in_sandbox_metered(ctx: &DispatchCtx,
crate::config::ensure_usable_cwd(working_dir)?;
let config = match module_config {
Some(config) => config,
- None => ctx.load_config()
- .await
- .map_err(|error| {
- anyhow::anyhow!("Cannot read module configuration: {error}")
- })?,
+ None => ctx.load_config().await.map_err(|error| {
+ anyhow::anyhow!("Cannot read module configuration: {error}")
+ })?,
};
execute_unsandboxed(
&config,
@@ -371,11 +380,9 @@ pub(crate) async fn execute_in_sandbox_metered(ctx: &DispatchCtx,
crate::config::ensure_usable_cwd(working_dir)?;
let config = match module_config {
Some(config) => config,
- None => ctx.load_config()
- .await
- .map_err(|error| {
- anyhow::anyhow!("Cannot read module configuration: {error}")
- })?,
+ None => ctx.load_config().await.map_err(|error| {
+ anyhow::anyhow!("Cannot read module configuration: {error}")
+ })?,
};
let policy = super::local_grants::with_resolved_grants(&config, policy).await?;
super::native_jail::execute(
@@ -400,11 +407,9 @@ pub(crate) async fn execute_in_sandbox_metered(ctx: &DispatchCtx,
};
let config = match module_config {
Some(config) => config,
- None => ctx.load_config()
- .await
- .map_err(|error| {
- anyhow::anyhow!("Cannot read module configuration: {error}")
- })?,
+ None => ctx.load_config().await.map_err(|error| {
+ anyhow::anyhow!("Cannot read module configuration: {error}")
+ })?,
};
docker::docker_exec(&config, policy, &request).await
}
diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rs
index 4d3895bdca..6fc9410542 100644
--- a/crates/openhuman-core/src/sandbox/ops_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::RuntimeConfig;
+use crate::core::runtime::DispatchCtx;
#[test]
fn resolve_sandbox_policy_none_mode() {
@@ -207,7 +207,8 @@ async fn execute_in_sandbox_none_backend() {
&RuntimeConfig::default(),
false,
);
- let result = execute_in_sandbox(&DispatchCtx::process_default(),
+ let result = execute_in_sandbox(
+ &DispatchCtx::process_default(),
&policy,
"echo sandbox-test",
Path::new("/tmp"),
@@ -282,7 +283,8 @@ async fn execute_in_sandbox_none_backend_runs_on_every_os() {
&RuntimeConfig::default(),
false,
);
- let result = execute_in_sandbox(&DispatchCtx::process_default(),
+ let result = execute_in_sandbox(
+ &DispatchCtx::process_default(),
&policy,
"echo sandbox-test",
tempdir.path(),
@@ -356,9 +358,11 @@ async fn sandbox_off_component_forces_the_unsandboxed_fallback_and_no_module_loa
crate::core::runtime::context::CoreContext::scope(ctx, async {
assert!(sandbox_component_off());
assert!(sandbox_disabled_by_host());
- assert!(!command_requires_sandbox(&dispatch, Some(SandboxMode::Sandboxed))
- .await
- .unwrap());
+ assert!(
+ !command_requires_sandbox(&dispatch, Some(SandboxMode::Sandboxed))
+ .await
+ .unwrap()
+ );
})
.await;
}
diff --git a/crates/openhuman-core/src/search/tools.rs b/crates/openhuman-core/src/search/tools.rs
index 959f115c8e..51a4da7740 100644
--- a/crates/openhuman-core/src/search/tools.rs
+++ b/crates/openhuman-core/src/search/tools.rs
@@ -120,7 +120,8 @@ impl TinySearchTool {
async fn live_config(&self, ctx: &DispatchCtx) -> anyhow::Result<Config> {
match &self.config {
Some(config) => Ok(config.as_ref().clone()),
- None => ctx.load_config()
+ None => ctx
+ .load_config()
.await
.map_err(|error| anyhow::anyhow!(error)),
}
diff --git a/crates/openhuman-core/src/security/approval/rpc.rs b/crates/openhuman-core/src/security/approval/rpc.rs
index 2c716e2e02..2cadf1ed4c 100644
--- a/crates/openhuman-core/src/security/approval/rpc.rs
+++ b/crates/openhuman-core/src/security/approval/rpc.rs
@@ -202,7 +202,8 @@ pub async fn approval_preauthorize_flow(
/// Apply a decision to a pending row. Errors when the request id is
/// unknown / already decided / belongs to a different session. With
/// `agent_id`, also errors when the request belongs to another agent.
-pub async fn approval_decide(ctx: &DispatchCtx,
+pub async fn approval_decide(
+ ctx: &DispatchCtx,
request_id: &str,
decision: ApprovalDecision,
agent_id: Option<&str>,
diff --git a/crates/openhuman-core/src/security/credentials/bus.rs b/crates/openhuman-core/src/security/credentials/bus.rs
index 31a208be6c..e2f16cfd20 100644
--- a/crates/openhuman-core/src/security/credentials/bus.rs
+++ b/crates/openhuman-core/src/security/credentials/bus.rs
@@ -23,8 +23,8 @@
//! `OPENHUMAN-TAURI-1T` (5,414 Sentry events from one user's
//! cron-driven LLM calls after session expiry).
-use crate::core::runtime::DispatchCtx;
use crate::core::events::DomainEvent;
+use crate::core::runtime::DispatchCtx;
use crate::cron::scheduler_gate;
use async_trait::async_trait;
use tinybus::EventHandler;
@@ -56,8 +56,12 @@ impl EventHandler<DomainEvent> for SessionExpiredSubscriber {
}
async fn handle(&self, event: &DomainEvent) {
- self.handle_with(&DispatchCtx::ambient(), crate::core::runtime::is_saas(), event)
- .await;
+ self.handle_with(
+ &DispatchCtx::ambient(),
+ crate::core::runtime::is_saas(),
+ event,
+ )
+ .await;
}
}
@@ -130,7 +134,9 @@ impl SessionExpiredSubscriber {
// loaded config; if the config can't load (rare — disk issue),
// we've at least pinned the scheduler gate so background work
// can't make things worse.
- if let Err(err) = crate::security::credentials::rpc::clear_session(&ctx, &config).await {
+ if let Err(err) =
+ crate::security::credentials::rpc::clear_session(&ctx, &config).await
+ {
tracing::warn!(
source = %source,
error = %err,
diff --git a/crates/openhuman-core/src/security/credentials/bus_tests.rs b/crates/openhuman-core/src/security/credentials/bus_tests.rs
index 6f2379b3d7..2d52581be0 100644
--- a/crates/openhuman-core/src/security/credentials/bus_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/bus_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
#[test]
fn name_is_stable() {
@@ -38,7 +38,8 @@ async fn session_expired_in_saas_returns_before_any_teardown() {
// in SaaS it must return at once, leaving the gate untouched.
tokio::time::timeout(
std::time::Duration::from_secs(1),
- s.handle_with(&DispatchCtx::process_default(),
+ s.handle_with(
+ &DispatchCtx::process_default(),
true,
&DomainEvent::SessionExpired {
source: "test".into(),
diff --git a/crates/openhuman-core/src/security/credentials/ops/boot_env.rs b/crates/openhuman-core/src/security/credentials/ops/boot_env.rs
index ae275bb18d..2a41c84344 100644
--- a/crates/openhuman-core/src/security/credentials/ops/boot_env.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/boot_env.rs
@@ -11,8 +11,8 @@
//! a fresh install and is otherwise ignored, so rotating it means clearing the
//! stored one first (`openhuman-core auth clear_credential`).
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::security::credentials::api_key;
use crate::security::credentials::session_support::{get_session_token, CredentialKind};
diff --git a/crates/openhuman-core/src/security/credentials/ops/boot_env_tests.rs b/crates/openhuman-core/src/security/credentials/ops/boot_env_tests.rs
index de3bb081ed..fcdbdd4194 100644
--- a/crates/openhuman-core/src/security/credentials/ops/boot_env_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/boot_env_tests.rs
@@ -1,7 +1,7 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::test_env::EnvVarGuard;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use tempfile::TempDir;
fn config_in(tmp: &TempDir) -> Config {
diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rs
index 85df58c7ee..acbca00bc7 100644
--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs
@@ -181,7 +181,8 @@ fn resolve(request: SetCredentialRequest) -> Result<Resolved, String> {
/// no purge, no service restart). A **different user** than the one stored is
/// signed out first so `active_user.toml` never points at one user while
/// another's profile exists.
-pub async fn set_credential(ctx: &DispatchCtx,
+pub async fn set_credential(
+ ctx: &DispatchCtx,
config: &Config,
request: SetCredentialRequest,
) -> Result<Outcome<AuthStateResponse>, String> {
@@ -377,7 +378,8 @@ pub async fn set_credential(ctx: &DispatchCtx,
/// Remove the stored credential of `kind` — or every credential when `None`.
/// A session (or local) removal runs the sign-out teardown; an API-key removal
/// only closes the scheduler gate when no other credential remains.
-pub async fn clear_credential(ctx: &DispatchCtx,
+pub async fn clear_credential(
+ ctx: &DispatchCtx,
config: &Config,
kind: Option<CredentialKind>,
) -> Result<Outcome<Value>, String> {
@@ -506,7 +508,10 @@ pub async fn clear_credential(ctx: &DispatchCtx,
/// teardown, user-dir deactivation, service stop, rebind to the signed-out
/// workspace, and Sentry / identity clear. Callers hold
/// [`CREDENTIAL_MUTATION_LOCK`].
-async fn clear_session_credential(ctx: &DispatchCtx, config: &Config) -> Result<Outcome<bool>, String> {
+async fn clear_session_credential(
+ ctx: &DispatchCtx,
+ config: &Config,
+) -> Result<Outcome<bool>, String> {
let mut logs = Vec::new();
crate::cron::scheduler_gate::set_signed_out(true);
#[cfg(feature = "web3")]
@@ -573,13 +578,15 @@ async fn clear_session_credential(ctx: &DispatchCtx, config: &Config) -> Result<
/// Historical entry point: install a session (or local) credential from a
/// bare token. Same as [`set_credential`] with the kind classified by shape.
-pub async fn store_session(ctx: &DispatchCtx,
+pub async fn store_session(
+ ctx: &DispatchCtx,
config: &Config,
token: &str,
user_id: Option<String>,
user: Option<Value>,
) -> Result<Outcome<AuthStateResponse>, String> {
- set_credential(&ctx,
+ set_credential(
+ &ctx,
config,
SetCredentialRequest {
token: token.to_string(),
diff --git a/crates/openhuman-core/src/security/credentials/ops/user_scope.rs b/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
index 58d4b622b5..78466c78e6 100644
--- a/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/user_scope.rs
@@ -7,11 +7,11 @@
//! installed or removed. They know nothing about *how* the credential was
//! obtained — that is the host's business.
-use crate::core::runtime::DispatchCtx;
use crate::config::{
default_root_openhuman_dir, pre_login_user_dir, read_active_user_id, user_openhuman_dir,
write_active_user_id, Config,
};
+use crate::core::runtime::DispatchCtx;
use crate::threads::store as conversations;
use super::gated_services::is_embedder_host;
@@ -110,10 +110,11 @@ pub(super) fn deactivate_user_scope() -> Result<(), String> {
/// The config that reflects the current `active_user.toml` — reloaded after an
/// activation so credentials, keys and workspaces land in the user-scoped
/// location — or `fallback` when the reload fails.
-pub(super) async fn reload_config_or(ctx: &DispatchCtx, _fallback: &Config) -> Result<Config, String> {
- ctx.load_config()
- .await
- .map_err(|error| error.to_string())
+pub(super) async fn reload_config_or(
+ ctx: &DispatchCtx,
+ _fallback: &Config,
+) -> Result<Config, String> {
+ ctx.load_config().await.map_err(|error| error.to_string())
}
/// Point every process-global store at `config`'s workspace after a
diff --git a/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
index 88859358e4..cdbd8d7cc8 100644
--- a/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
use crate::security::credentials::api_key;
#[tokio::test]
@@ -20,7 +20,8 @@ async fn same_token_refresh_preserves_issuing_backend_and_refuses_rebinding() {
true,
)
.unwrap();
- let state = set_credential(&DispatchCtx::process_default(),
+ let state = set_credential(
+ &DispatchCtx::process_default(),
&config,
SetCredentialRequest {
token: "synthetic-session".into(),
@@ -35,7 +36,8 @@ async fn same_token_refresh_preserves_issuing_backend_and_refuses_rebinding() {
state.issuing_backend.as_deref(),
Some("https://issuer.example")
);
- let error = set_credential(&DispatchCtx::process_default(),
+ let error = set_credential(
+ &DispatchCtx::process_default(),
&config,
SetCredentialRequest {
token: "synthetic-session".into(),
@@ -97,9 +99,13 @@ async fn decrypt_secret_round_trips_noise_through_migrate_path() {
async fn set_credential_rejects_empty_or_whitespace_token() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let err = store_session(&DispatchCtx::process_default(), &config, "", None, None).await.unwrap_err();
+ let err = store_session(&DispatchCtx::process_default(), &config, "", None, None)
+ .await
+ .unwrap_err();
assert!(err.contains("token is required"));
- let err = store_session(&DispatchCtx::process_default(), &config, " ", None, None).await.unwrap_err();
+ let err = store_session(&DispatchCtx::process_default(), &config, " ", None, None)
+ .await
+ .unwrap_err();
assert!(err.contains("token is required"));
}
@@ -107,7 +113,8 @@ async fn set_credential_rejects_empty_or_whitespace_token() {
async fn set_credential_rejects_unknown_kind() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let err = set_credential(&DispatchCtx::process_default(),
+ let err = set_credential(
+ &DispatchCtx::process_default(),
&config,
SetCredentialRequest {
token: "x".into(),
@@ -151,7 +158,8 @@ async fn set_credential_requires_a_user_id_for_a_session() {
.await
.unwrap_err();
assert!(err.contains("userId required"), "{err}");
- let err = store_session(&DispatchCtx::process_default(),
+ let err = store_session(
+ &DispatchCtx::process_default(),
&config,
"opaque-token",
None,
@@ -176,7 +184,8 @@ async fn set_credential_installs_a_session_without_touching_the_backend() {
let exp = chrono::Utc::now() + chrono::Duration::hours(1);
let token = jwt_with_payload(json!({ "sub": "user-42", "exp": exp.timestamp() }));
- let result = store_session(&DispatchCtx::process_default(),
+ let result = store_session(
+ &DispatchCtx::process_default(),
&config,
&token,
None,
@@ -230,10 +239,16 @@ async fn set_credential_derives_the_user_id_from_the_jwt_subject() {
assert_eq!(state.user_id.as_deref(), Some("from-claims"));
// Explicit userId wins over the claim; the user payload's id wins over
// the claim too.
- let state = store_session(&DispatchCtx::process_default(), &config, &token, Some("explicit".into()), None)
- .await
- .unwrap()
- .value;
+ let state = store_session(
+ &DispatchCtx::process_default(),
+ &config,
+ &token,
+ Some("explicit".into()),
+ None,
+ )
+ .await
+ .unwrap()
+ .value;
assert_eq!(state.user_id.as_deref(), Some("explicit"));
}
@@ -248,7 +263,8 @@ async fn set_credential_with_the_same_token_and_user_is_a_cheap_refresh() {
"sub": "user-7",
"exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
}));
- let first = store_session(&DispatchCtx::process_default(),
+ let first = store_session(
+ &DispatchCtx::process_default(),
&config,
&token,
None,
@@ -260,7 +276,8 @@ async fn set_credential_with_the_same_token_and_user_is_a_cheap_refresh() {
// The host's `/auth/me` answer arrives: same token, same user.
let user_config = crate::config::load_config_with_timeout().await.unwrap();
- let second = store_session(&DispatchCtx::process_default(),
+ let second = store_session(
+ &DispatchCtx::process_default(),
&user_config,
&token,
None,
@@ -288,7 +305,8 @@ async fn set_credential_for_a_different_user_signs_the_previous_one_out_first()
let _home = EnvVarGuard::set("HOME", tmp.path());
let config = test_config(&tmp);
let exp = (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp();
- store_session(&DispatchCtx::process_default(),
+ store_session(
+ &DispatchCtx::process_default(),
&config,
&jwt_with_payload(json!({ "sub": "alice", "exp": exp })),
None,
@@ -297,7 +315,8 @@ async fn set_credential_for_a_different_user_signs_the_previous_one_out_first()
.await
.unwrap();
let alice_config = crate::config::load_config_with_timeout().await.unwrap();
- let result = store_session(&DispatchCtx::process_default(),
+ let result = store_session(
+ &DispatchCtx::process_default(),
&alice_config,
&jwt_with_payload(json!({ "sub": "bob", "exp": exp })),
None,
@@ -328,7 +347,8 @@ async fn set_credential_for_a_different_user_signs_the_previous_one_out_first()
async fn set_and_clear_api_key_credential() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let state = set_credential(&DispatchCtx::process_default(),
+ let state = set_credential(
+ &DispatchCtx::process_default(),
&config,
SetCredentialRequest {
token: "sk-live".into(),
@@ -343,10 +363,14 @@ async fn set_and_clear_api_key_credential() {
assert_eq!(state.credential.as_deref(), Some("api-key"));
assert!(state.user_id.is_none());
- let cleared = clear_credential(&DispatchCtx::process_default(), &config, Some(session_support::CredentialKind::ApiKey))
- .await
- .unwrap()
- .value;
+ let cleared = clear_credential(
+ &DispatchCtx::process_default(),
+ &config,
+ Some(session_support::CredentialKind::ApiKey),
+ )
+ .await
+ .unwrap()
+ .value;
assert_eq!(cleared["removedApiKey"], true);
assert_eq!(cleared["removedSession"], false);
assert!(
@@ -372,14 +396,21 @@ async fn clearing_the_session_preserves_a_coexisting_api_key() {
// Install the session first: this activates the user-scoped directory.
let exp = chrono::Utc::now() + chrono::Duration::hours(1);
let token = jwt_with_payload(json!({ "sub": "user-42", "exp": exp.timestamp() }));
- store_session(&DispatchCtx::process_default(), &config, &token, None, Some(json!({ "id": "user-42" })))
- .await
- .unwrap();
+ store_session(
+ &DispatchCtx::process_default(),
+ &config,
+ &token,
+ None,
+ Some(json!({ "id": "user-42" })),
+ )
+ .await
+ .unwrap();
// Store the API key against the now-active user-scoped config, exactly
// as the dispatcher would for a follow-up `auth.set_credential` call.
let user_scoped = crate::config::load_config_with_timeout().await.unwrap();
- set_credential(&DispatchCtx::process_default(),
+ set_credential(
+ &DispatchCtx::process_default(),
&user_scoped,
SetCredentialRequest {
token: "sk-live".into(),
@@ -395,10 +426,14 @@ async fn clearing_the_session_preserves_a_coexisting_api_key() {
);
// Sign the session out only — the API key must not be cleared.
- let cleared = clear_credential(&DispatchCtx::process_default(), &user_scoped, Some(session_support::CredentialKind::Session))
- .await
- .unwrap()
- .value;
+ let cleared = clear_credential(
+ &DispatchCtx::process_default(),
+ &user_scoped,
+ Some(session_support::CredentialKind::Session),
+ )
+ .await
+ .unwrap()
+ .value;
assert_eq!(cleared["removedSession"], true);
assert_eq!(cleared["removedApiKey"], false);
@@ -449,7 +484,8 @@ async fn clearing_the_session_preserves_the_active_key_over_a_stale_destination_
// Key A already sits at the real pre-login/signed-out scope — e.g. left
// over from an earlier api-key-only run before any session existed.
let pre_login = crate::config::load_config_with_timeout().await.unwrap();
- set_credential(&DispatchCtx::process_default(),
+ set_credential(
+ &DispatchCtx::process_default(),
&pre_login,
SetCredentialRequest {
token: "sk-stale-a".into(),
@@ -468,13 +504,20 @@ async fn clearing_the_session_preserves_the_active_key_over_a_stale_destination_
// from the pre-login one key A lives beside.
let exp = chrono::Utc::now() + chrono::Duration::hours(1);
let token = jwt_with_payload(json!({ "sub": "user-99", "exp": exp.timestamp() }));
- store_session(&DispatchCtx::process_default(), &pre_login, &token, None, Some(json!({ "id": "user-99" })))
- .await
- .unwrap();
+ store_session(
+ &DispatchCtx::process_default(),
+ &pre_login,
+ &token,
+ None,
+ Some(json!({ "id": "user-99" })),
+ )
+ .await
+ .unwrap();
// Key B is the one actually active while the session is up.
let user_scoped = crate::config::load_config_with_timeout().await.unwrap();
- set_credential(&DispatchCtx::process_default(),
+ set_credential(
+ &DispatchCtx::process_default(),
&user_scoped,
SetCredentialRequest {
token: "sk-live-b".into(),
@@ -491,9 +534,13 @@ async fn clearing_the_session_preserves_the_active_key_over_a_stale_destination_
// A session-only clear must preserve key B as the effective credential,
// not let the stale key A at the destination win by default.
- clear_credential(&DispatchCtx::process_default(), &user_scoped, Some(session_support::CredentialKind::Session))
- .await
- .unwrap();
+ clear_credential(
+ &DispatchCtx::process_default(),
+ &user_scoped,
+ Some(session_support::CredentialKind::Session),
+ )
+ .await
+ .unwrap();
let signed_out = crate::config::load_config_with_timeout().await.unwrap();
assert_eq!(
@@ -520,12 +567,19 @@ async fn clearing_without_a_kind_removes_a_user_scoped_api_key_at_its_source() {
let exp = chrono::Utc::now() + chrono::Duration::hours(1);
let token = jwt_with_payload(json!({ "sub": "user-77", "exp": exp.timestamp() }));
- store_session(&DispatchCtx::process_default(), &config, &token, None, Some(json!({ "id": "user-77" })))
- .await
- .unwrap();
+ store_session(
+ &DispatchCtx::process_default(),
+ &config,
+ &token,
+ None,
+ Some(json!({ "id": "user-77" })),
+ )
+ .await
+ .unwrap();
let user_scoped = crate::config::load_config_with_timeout().await.unwrap();
- set_credential(&DispatchCtx::process_default(),
+ set_credential(
+ &DispatchCtx::process_default(),
&user_scoped,
SetCredentialRequest {
token: "sk-live".into(),
@@ -537,7 +591,10 @@ async fn clearing_without_a_kind_removes_a_user_scoped_api_key_at_its_source() {
.unwrap();
assert!(api_key::has_api_key(&user_scoped));
- let cleared = clear_credential(&DispatchCtx::process_default(), &user_scoped, None).await.unwrap().value;
+ let cleared = clear_credential(&DispatchCtx::process_default(), &user_scoped, None)
+ .await
+ .unwrap()
+ .value;
assert_eq!(cleared["removed"], true);
assert_eq!(cleared["removedSession"], true);
assert_eq!(
@@ -569,7 +626,8 @@ async fn clear_credential_without_a_kind_removes_everything() {
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set("HOME", tmp.path());
let config = test_config(&tmp);
- set_credential(&DispatchCtx::process_default(),
+ set_credential(
+ &DispatchCtx::process_default(),
&config,
SetCredentialRequest {
token: "sk-live".into(),
@@ -579,7 +637,10 @@ async fn clear_credential_without_a_kind_removes_everything() {
)
.await
.unwrap();
- let cleared = clear_credential(&DispatchCtx::process_default(), &config, None).await.unwrap().value;
+ let cleared = clear_credential(&DispatchCtx::process_default(), &config, None)
+ .await
+ .unwrap()
+ .value;
assert_eq!(cleared["removed"], true);
assert_eq!(cleared["removedApiKey"], true);
assert!(
@@ -604,9 +665,15 @@ async fn store_session_local_token_rejects_missing_user_payload() {
let _home = EnvVarGuard::set("HOME", tmp.path());
let config = test_config(&tmp);
let local_token = "header.payload.local";
- let err = store_session(&DispatchCtx::process_default(), &config, local_token, None, None)
- .await
- .unwrap_err();
+ let err = store_session(
+ &DispatchCtx::process_default(),
+ &config,
+ local_token,
+ None,
+ None,
+ )
+ .await
+ .unwrap_err();
assert!(
err.contains("local session requires a user payload"),
"expected 'local session requires a user payload', got: {err}"
@@ -631,7 +698,8 @@ async fn store_session_local_token_succeeds_without_network_and_forces_local_use
"email": "[email protected]"
});
// Pass a different user_id to verify it is overridden.
- let result = store_session(&DispatchCtx::process_default(),
+ let result = store_session(
+ &DispatchCtx::process_default(),
&config,
local_token,
Some("should-be-overridden".to_string()),
diff --git a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
index 0e94351f21..f58061dd03 100644
--- a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
// ── clear_session ──────────────────────────────────────────────
@@ -15,7 +15,9 @@ async fn clear_session_on_empty_store_reports_removed_false() {
let tmp = TempDir::new().unwrap();
let _home = EnvVarGuard::set("HOME", tmp.path());
let config = test_config(&tmp);
- let result = clear_session(&DispatchCtx::process_default(), &config).await.unwrap();
+ let result = clear_session(&DispatchCtx::process_default(), &config)
+ .await
+ .unwrap();
assert_eq!(result.value["removed"], false);
}
@@ -399,7 +401,9 @@ async fn clear_session_on_one_account_does_not_affect_another() {
.unwrap();
// Clearing the session for account A must not wipe account B's credentials.
- clear_session(&DispatchCtx::process_default(), &config_a).await.unwrap();
+ clear_session(&DispatchCtx::process_default(), &config_a)
+ .await
+ .unwrap();
let listed_b = list_provider_credentials(&config_b, None)
.await
diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rs
index 5a52ca0985..0ef5e1f199 100644
--- a/crates/openhuman-core/src/security/credentials/session_support.rs
+++ b/crates/openhuman-core/src/security/credentials/session_support.rs
@@ -1,7 +1,7 @@
//! Session/auth helpers used by RPC and [`crate::core_server::helpers`].
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use super::profiles::{AuthProfile, AuthProfileKind, TokenSet};
use super::responses::{AuthProfileSummary, AuthStateResponse};
@@ -66,7 +66,7 @@ pub fn is_local_session_token(token: &str) -> bool {
/// credential. A backend-only route may report a missing session or 401 while
/// this credential remains valid; those errors must not broadcast sign-out.
/// A failed lookup leaves the ordinary session-expiry path in place.
-pub async fn current_session_is_local(ctx: &DispatchCtx, ) -> bool {
+pub async fn current_session_is_local(ctx: &DispatchCtx) -> bool {
let Ok(config) = ctx.load_config().await else {
return false;
};
diff --git a/crates/openhuman-core/src/security/devices/bus.rs b/crates/openhuman-core/src/security/devices/bus.rs
index ac93119215..0283cd2ace 100644
--- a/crates/openhuman-core/src/security/devices/bus.rs
+++ b/crates/openhuman-core/src/security/devices/bus.rs
@@ -95,7 +95,9 @@ impl EventHandler<DomainEvent> for DeviceTunnelSubscriber {
.unwrap_or_else(std::sync::PoisonError::into_inner)
.get(channel_id.as_str())
.cloned();
- match super::owner::owner_of(&DispatchCtx::ambient(), channel_id, pending.as_ref()).await {
+ match super::owner::owner_of(&DispatchCtx::ambient(), channel_id, pending.as_ref())
+ .await
+ {
Ok(owner) => {
let handled = crate::storage::agents::within_agent(
owner.as_deref(),
diff --git a/crates/openhuman-core/src/security/devices/owner.rs b/crates/openhuman-core/src/security/devices/owner.rs
index 61693bafff..6209272052 100644
--- a/crates/openhuman-core/src/security/devices/owner.rs
+++ b/crates/openhuman-core/src/security/devices/owner.rs
@@ -64,7 +64,8 @@ pub(super) type OwnerLookupFailed = crate::storage::agents::LookupFailed;
/// paired device. The configuration is loaded inside the scope: in SaaS mode
/// loading it needs an acting agent, which the tunnel task does not have.
async fn has_live_device(ctx: &DispatchCtx, channel_id: &str) -> Result<bool, String> {
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|error| format!("load config: {error}"))?;
super::store::get_device(&config, channel_id)
@@ -75,7 +76,8 @@ async fn has_live_device(ctx: &DispatchCtx, channel_id: &str) -> Result<bool, St
/// Whether the current scope holds `channel_id` as a revoked device (a missing
/// row is not revoked).
async fn is_revoked(ctx: &DispatchCtx, channel_id: &str) -> Result<bool, String> {
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|error| format!("load config: {error}"))?;
super::store::get_device(&config, channel_id)
@@ -95,7 +97,8 @@ async fn is_revoked(ctx: &DispatchCtx, channel_id: &str) -> Result<bool, String>
///
/// [`OwnerLookupFailed`] when no scope has the device and at least one
/// scope's lookup failed.
-pub(super) async fn owner_of(ctx: &DispatchCtx,
+pub(super) async fn owner_of(
+ ctx: &DispatchCtx,
channel_id: &str,
pending: Option<&PairingSession>,
) -> Result<Option<String>, OwnerLookupFailed> {
@@ -109,9 +112,11 @@ pub(super) async fn owner_of(ctx: &DispatchCtx,
if !has_active_cipher(channel_id) {
return Ok(session.agent.clone());
}
- let revoked =
- crate::storage::agents::within_agent(session.agent.as_deref(), is_revoked(&ctx, channel_id))
- .await;
+ let revoked = crate::storage::agents::within_agent(
+ session.agent.as_deref(),
+ is_revoked(&ctx, channel_id),
+ )
+ .await;
return match revoked {
Some(Ok(false)) => Ok(session.agent.clone()),
Some(Ok(true)) => Err(OwnerLookupFailed {
@@ -129,8 +134,11 @@ pub(super) async fn owner_of(ctx: &DispatchCtx,
};
}
if let Some(owner) = cached(channel_id) {
- match crate::storage::agents::within_agent(owner.as_deref(), has_live_device(&ctx, channel_id))
- .await
+ match crate::storage::agents::within_agent(
+ owner.as_deref(),
+ has_live_device(&ctx, channel_id),
+ )
+ .await
{
Some(Ok(true)) => return Ok(owner),
Some(Err(error)) => {
@@ -142,9 +150,10 @@ pub(super) async fn owner_of(ctx: &DispatchCtx,
Some(Ok(false)) | None => forget(channel_id),
}
}
- let lookups =
- crate::storage::agents::for_each_scope("device owner", || has_live_device(&ctx, channel_id))
- .await;
+ let lookups = crate::storage::agents::for_each_scope("device owner", || {
+ has_live_device(&ctx, channel_id)
+ })
+ .await;
let owner = decide(lookups)?;
if let Some(owner) = &owner {
log::debug!(
diff --git a/crates/openhuman-core/src/security/devices/owner_tests.rs b/crates/openhuman-core/src/security/devices/owner_tests.rs
index 6f0c1a9aa7..12ab1f4ffa 100644
--- a/crates/openhuman-core/src/security/devices/owner_tests.rs
+++ b/crates/openhuman-core/src/security/devices/owner_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
fn session(agent: Option<&str>) -> PairingSession {
PairingSession {
@@ -16,14 +16,26 @@ fn session(agent: Option<&str>) -> PairingSession {
async fn a_pending_pairing_names_its_agent() {
let pending = session(Some("agent-7"));
assert_eq!(
- owner_of(&DispatchCtx::process_default(), "owner-test-pending", Some(&pending))
- .await
- .unwrap()
- .as_deref(),
+ owner_of(
+ &DispatchCtx::process_default(),
+ "owner-test-pending",
+ Some(&pending)
+ )
+ .await
+ .unwrap()
+ .as_deref(),
Some("agent-7")
);
let local = session(None);
- assert_eq!(owner_of(&DispatchCtx::process_default(), "owner-test-pending", Some(&local)).await, Ok(None));
+ assert_eq!(
+ owner_of(
+ &DispatchCtx::process_default(),
+ "owner-test-pending",
+ Some(&local)
+ )
+ .await,
+ Ok(None)
+ );
}
/// A remembered owner is re-checked in its scope: once that scope no longer
@@ -37,8 +49,11 @@ async fn a_remembered_owner_that_lost_the_device_is_forgotten() {
scoped_config(tmp.path()),
);
remember("owner-test-stale", None);
- let owner =
- crate::core::runtime::CoreContext::scope(context, owner_of(&DispatchCtx::process_default(), "owner-test-stale", None)).await;
+ let owner = crate::core::runtime::CoreContext::scope(
+ context,
+ owner_of(&DispatchCtx::process_default(), "owner-test-stale", None),
+ )
+ .await;
assert_eq!(owner, Ok(None));
assert_eq!(cached("owner-test-stale"), None, "the stale entry is gone");
}
@@ -54,9 +69,11 @@ async fn a_revoked_device_is_not_its_agents_any_more() {
crate::core::runtime::DomainSet::full(),
config,
);
- let owner =
- crate::core::runtime::CoreContext::scope(context, owner_of(&DispatchCtx::process_default(), "owner-test-revoked", None))
- .await;
+ let owner = crate::core::runtime::CoreContext::scope(
+ context,
+ owner_of(&DispatchCtx::process_default(), "owner-test-revoked", None),
+ )
+ .await;
assert_eq!(owner, Ok(None));
assert_eq!(
cached("owner-test-revoked"),
@@ -90,8 +107,11 @@ async fn a_device_found_in_the_local_scope_belongs_to_local_and_is_remembered()
crate::core::runtime::DomainSet::full(),
config,
);
- let owner =
- crate::core::runtime::CoreContext::scope(context, owner_of(&DispatchCtx::process_default(), "owner-test-found", None)).await;
+ let owner = crate::core::runtime::CoreContext::scope(
+ context,
+ owner_of(&DispatchCtx::process_default(), "owner-test-found", None),
+ )
+ .await;
assert_eq!(owner, Ok(None));
assert_eq!(cached("owner-test-found"), Some(None));
}
@@ -103,9 +123,11 @@ async fn a_channel_no_scope_knows_is_local_and_not_remembered() {
crate::core::runtime::DomainSet::full(),
scoped_config(tmp.path()),
);
- let owner =
- crate::core::runtime::CoreContext::scope(context, owner_of(&DispatchCtx::process_default(), "owner-test-missing", None))
- .await;
+ let owner = crate::core::runtime::CoreContext::scope(
+ context,
+ owner_of(&DispatchCtx::process_default(), "owner-test-missing", None),
+ )
+ .await;
assert_eq!(owner, Ok(None));
assert_eq!(cached("owner-test-missing"), None);
}
@@ -153,9 +175,11 @@ async fn a_revoked_device_with_a_live_cipher_is_dropped() {
super::super::crypto::TunnelCipher::new(&[7u8; 32]),
)),
);
- let owner =
- crate::core::runtime::CoreContext::scope(context, owner_of(&DispatchCtx::process_default(), "owner-test-cipher", None))
- .await;
+ let owner = crate::core::runtime::CoreContext::scope(
+ context,
+ owner_of(&DispatchCtx::process_default(), "owner-test-cipher", None),
+ )
+ .await;
super::super::rpc::ACTIVE_CIPHERS
.lock()
.unwrap()
@@ -178,7 +202,12 @@ async fn a_leftover_pairing_session_does_not_outlive_a_revocation() {
let pending = session(None);
// Before the handshake the session names the agent.
assert_eq!(
- owner_of(&DispatchCtx::process_default(), "owner-test-leftover", Some(&pending)).await,
+ owner_of(
+ &DispatchCtx::process_default(),
+ "owner-test-leftover",
+ Some(&pending)
+ )
+ .await,
Ok(None)
);
super::super::rpc::ACTIVE_CIPHERS.lock().unwrap().insert(
@@ -190,7 +219,11 @@ async fn a_leftover_pairing_session_does_not_outlive_a_revocation() {
// Cipher live, row not persisted yet: still the session's agent.
let racing = crate::core::runtime::CoreContext::scope(
std::sync::Arc::clone(&context),
- owner_of(&DispatchCtx::process_default(), "owner-test-leftover", Some(&pending)),
+ owner_of(
+ &DispatchCtx::process_default(),
+ "owner-test-leftover",
+ Some(&pending),
+ ),
)
.await;
assert_eq!(racing, Ok(None));
@@ -200,7 +233,11 @@ async fn a_leftover_pairing_session_does_not_outlive_a_revocation() {
super::super::store::revoke_device(&config, "owner-test-leftover").unwrap();
let owner = crate::core::runtime::CoreContext::scope(
context,
- owner_of(&DispatchCtx::process_default(), "owner-test-leftover", Some(&pending)),
+ owner_of(
+ &DispatchCtx::process_default(),
+ "owner-test-leftover",
+ Some(&pending),
+ ),
)
.await;
super::super::rpc::ACTIVE_CIPHERS
diff --git a/crates/openhuman-core/src/security/keyring_consent/ops.rs b/crates/openhuman-core/src/security/keyring_consent/ops.rs
index 2570592406..6f440b5940 100644
--- a/crates/openhuman-core/src/security/keyring_consent/ops.rs
+++ b/crates/openhuman-core/src/security/keyring_consent/ops.rs
@@ -19,7 +19,10 @@ pub async fn keyring_status() -> Result<Outcome<KeyringStatus>, String> {
Ok(Outcome::single_log(status, "keyring status fetched"))
}
-pub async fn keyring_consent_decide(ctx: &DispatchCtx, mode: String) -> Result<Outcome<ConsentPreference>, String> {
+pub async fn keyring_consent_decide(
+ ctx: &DispatchCtx,
+ mode: String,
+) -> Result<Outcome<ConsentPreference>, String> {
if mode != "local_encrypted" && mode != "declined" {
return Err(format!(
"invalid mode '{mode}': expected 'local_encrypted' or 'declined'"
diff --git a/crates/openhuman-core/src/security/keyring_consent/ops_tests.rs b/crates/openhuman-core/src/security/keyring_consent/ops_tests.rs
index 7822932353..1909520afc 100644
--- a/crates/openhuman-core/src/security/keyring_consent/ops_tests.rs
+++ b/crates/openhuman-core/src/security/keyring_consent/ops_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
#[tokio::test]
async fn keyring_status_returns_ok() {
@@ -11,7 +11,8 @@ async fn keyring_status_returns_ok() {
#[tokio::test]
async fn keyring_consent_decide_rejects_invalid_mode() {
- let result = keyring_consent_decide(&DispatchCtx::process_default(), "invalid".to_string()).await;
+ let result =
+ keyring_consent_decide(&DispatchCtx::process_default(), "invalid".to_string()).await;
assert!(result.is_err());
assert!(result.unwrap_err().contains("invalid mode"));
}
diff --git a/crates/openhuman-core/src/security/ops.rs b/crates/openhuman-core/src/security/ops.rs
index 2662b5dd81..7ba43d8d88 100644
--- a/crates/openhuman-core/src/security/ops.rs
+++ b/crates/openhuman-core/src/security/ops.rs
@@ -25,7 +25,9 @@ pub fn security_policy_info_for_config(config: &Config) -> Outcome<serde_json::V
Outcome::single_log(payload, "security_policy_info computed from active config")
}
-pub async fn load_and_get_security_policy_info(ctx: &DispatchCtx, ) -> Result<Outcome<serde_json::Value>, String> {
+pub async fn load_and_get_security_policy_info(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<serde_json::Value>, String> {
let config = ctx.load_config().await?;
Ok(security_policy_info_for_config(&config))
}
diff --git a/crates/openhuman-core/src/security/ops_tests.rs b/crates/openhuman-core/src/security/ops_tests.rs
index 4442fae42d..eac287db3c 100644
--- a/crates/openhuman-core/src/security/ops_tests.rs
+++ b/crates/openhuman-core/src/security/ops_tests.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::test_env::EnvVarGuard;
+use crate::core::runtime::DispatchCtx;
#[test]
fn security_policy_info_returns_all_documented_fields() {
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index 73eae612a2..fddb731d47 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -1,11 +1,11 @@
//! Create, read, update, and delete operations for conversation threads and
//! their messages.
-use crate::core::runtime::DispatchCtx;
use super::support::{
counts, envelope, message_to_record, record_to_message, run_to_completion, thread_to_summary,
workspace_dir,
};
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::threads::store as conversations;
use crate::threads::store::{ConversationMessagePatch, CrossThreadHit};
@@ -152,11 +152,13 @@ pub async fn transcript_search(
}
/// Appends a message to a conversation thread.
-pub async fn message_append(ctx: &DispatchCtx,
+pub async fn message_append(
+ ctx: &DispatchCtx,
request: AppendConversationMessageRequest,
) -> Result<Outcome<ApiEnvelope<ConversationMessageRecord>>, ThreadsError> {
let origin = crate::core::runtime::CoreContext::current_turn_origin();
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|error| ThreadsError::Message(format!("load config: {error}")))?;
let persistence_dir = workspace_dir().await.map_err(ThreadsError::Message)?;
@@ -405,10 +407,12 @@ pub async fn delete_after(
/// [`run_to_completion`] task, so a caller that disconnects mid-delete cannot
/// leave the thread gone from the store with its sessions, sub-agents and turn
/// snapshot still live.
-pub async fn thread_delete(ctx: &DispatchCtx,
+pub async fn thread_delete(
+ ctx: &DispatchCtx,
request: DeleteConversationThreadRequest,
) -> Result<Outcome<ApiEnvelope<DeleteConversationThreadResponse>>, String> {
- let config = ctx.load_config()
+ let config = ctx
+ .load_config()
.await
.map_err(|e| format!("load config: {e}"))?;
run_to_completion("thread_delete", thread_delete_inner(config, request)).await
diff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rs
index ac9c976f6a..4f8af4126f 100644
--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs
+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs
@@ -1,5 +1,5 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
+use crate::core::runtime::DispatchCtx;
// NOTE: the title_log_fingerprint / collapse_whitespace copies were removed
// here (plan.md §2.1) — threads/title.rs (the owning module) already covers
@@ -186,17 +186,20 @@ async fn message_append_returns_typed_not_found_for_stale_thread() {
let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());
let thread_id = "thread-missing";
- let err = message_append(&DispatchCtx::process_default(), AppendConversationMessageRequest {
- thread_id: thread_id.to_string(),
- message: ConversationMessageRecord {
- id: "msg-1".to_string(),
- content: "hello".to_string(),
- message_type: "text".to_string(),
- extra_metadata: Value::Null,
- sender: "user".to_string(),
- created_at: "2026-01-01T00:00:00Z".to_string(),
+ let err = message_append(
+ &DispatchCtx::process_default(),
+ AppendConversationMessageRequest {
+ thread_id: thread_id.to_string(),
+ message: ConversationMessageRecord {
+ id: "msg-1".to_string(),
+ content: "hello".to_string(),
+ message_type: "text".to_string(),
+ extra_metadata: Value::Null,
+ sender: "user".to_string(),
+ created_at: "2026-01-01T00:00:00Z".to_string(),
+ },
},
- })
+ )
.await
.expect_err("missing thread must return a typed not-found error");
@@ -362,10 +365,13 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {
.await;
assert_eq!(bg::pending_for(&dir, thread_id).len(), 1);
- thread_delete(&DispatchCtx::process_default(), DeleteConversationThreadRequest {
- thread_id: thread_id.to_string(),
- deleted_at: "2026-01-01T00:02:00Z".into(),
- })
+ thread_delete(
+ &DispatchCtx::process_default(),
+ DeleteConversationThreadRequest {
+ thread_id: thread_id.to_string(),
+ deleted_at: "2026-01-01T00:02:00Z".into(),
+ },
+ )
.await
.expect("delete thread");
@@ -492,10 +498,13 @@ async fn thread_delete_forgets_its_conversation_memory_or_queues_it() {
.expect("load config")
.workspace_dir;
- thread_delete(&DispatchCtx::process_default(), DeleteConversationThreadRequest {
- thread_id: thread_id.to_string(),
- deleted_at: "2026-01-01T00:02:00Z".into(),
- })
+ thread_delete(
+ &DispatchCtx::process_default(),
+ DeleteConversationThreadRequest {
+ thread_id: thread_id.to_string(),
+ deleted_at: "2026-01-01T00:02:00Z".into(),
+ },
+ )
.await
.expect("delete thread");
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index 38ab792c93..f3aa27bfa5 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -241,7 +241,8 @@ impl EventHandler<DomainEvent> for ConversationPersistenceSubscriber {
);
return;
}
- if let Err(error) = persist_channel_turn(&DispatchCtx::ambient(),
+ if let Err(error) = persist_channel_turn(
+ &DispatchCtx::ambient(),
&my_workspace,
ChannelTurnDescriptor {
channel,
@@ -299,7 +300,8 @@ impl EventHandler<DomainEvent> for ConversationPersistenceSubscriber {
);
return;
}
- if let Err(error) = persist_channel_turn(&DispatchCtx::ambient(),
+ if let Err(error) = persist_channel_turn(
+ &DispatchCtx::ambient(),
&my_workspace,
ChannelTurnDescriptor {
channel,
@@ -348,7 +350,8 @@ struct ChannelTurnDescriptor<'a> {
source: &'a str,
}
-async fn persist_channel_turn(ctx: &DispatchCtx,
+async fn persist_channel_turn(
+ ctx: &DispatchCtx,
workspace_dir: &Path,
descriptor: ChannelTurnDescriptor<'_>,
) -> Result<(), String> {
diff --git a/crates/openhuman-core/src/tools/impl/network/host.rs b/crates/openhuman-core/src/tools/impl/network/host.rs
index 60d1f050d4..c7ed7ce6e2 100644
--- a/crates/openhuman-core/src/tools/impl/network/host.rs
+++ b/crates/openhuman-core/src/tools/impl/network/host.rs
@@ -65,13 +65,7 @@ pub fn http_request_tool(
max_response_size: usize,
timeout_secs: u64,
) -> HttpRequestTool {
- http_request_tool_for(
- gate,
- None,
- allowed_domains,
- max_response_size,
- timeout_secs,
- )
+ http_request_tool_for(gate, None, allowed_domains, max_response_size, timeout_secs)
}
/// [`http_request_tool`] whose x402 quotes are owned by `chat`.
@@ -291,7 +285,8 @@ mod x402 {
.ok_or_else(|| {
"402 response is missing a valid PAYMENT-REQUIRED header".to_string()
})?;
- let config = crate::core::runtime::DispatchCtx::ambient().load_config()
+ let config = crate::core::runtime::DispatchCtx::ambient()
+ .load_config()
.await
.map_err(|error| format!("x402 payment failed: {error}"))?;
declined_when_wallet_off(&config)?;
diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
index 510a19f52e..c946ebdd5d 100644
--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs
+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs
@@ -83,7 +83,8 @@ impl ImageInspector for ModuleImageInspector<'_> {
let config = match self.config {
Some(config) => config,
None => {
- loaded = DispatchCtx::ambient().load_config()
+ loaded = DispatchCtx::ambient()
+ .load_config()
.await
.map_err(|error| format!("config unavailable: {error}"))?;
&loaded
@@ -408,8 +409,14 @@ impl PresentationTool {
.map(|n| n.to_string_lossy().into_owned())
.unwrap_or_default();
let reason = format!("failed to write generated deck ({filename}): {err}");
- let _ =
- fail_artifact(&self.workspace_dir, &self.files_dir, &meta.id, &reason, chat).await;
+ let _ = fail_artifact(
+ &self.workspace_dir,
+ &self.files_dir,
+ &meta.id,
+ &reason,
+ chat,
+ )
+ .await;
tracing::warn!(
target: "presentation",
err = %err,
@@ -421,7 +428,8 @@ impl PresentationTool {
}
let size_bytes = bytes.len() as u64;
- let updated = match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes, chat).await {
+ let updated = match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes, chat).await
+ {
Ok(updated) => updated,
Err(err) => {
let reason = format!("failed to finalize artifact: {err}");
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 6857d689cd..d4090d3fdd 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -1,10 +1,10 @@
-use crate::core::runtime::DispatchCtx;
use super::shell_description::{command_param_description, shell_description};
#[cfg(feature = "modules")]
use super::shell_support::container_environment;
use super::shell_support::{command_failure, exec_result, python_utf8_env, tool_timeout_message};
use crate::agent::host_runtime::RuntimeAdapter;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::security::{AuditLogger, CommandExecutionLog, SecurityPolicy};
use async_trait::async_trait;
use serde_json::json;
@@ -264,7 +264,8 @@ impl Tool for ShellTool {
}
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
- self.execute_in_context(&DispatchCtx::ambient(), args, None).await
+ self.execute_in_context(&DispatchCtx::ambient(), args, None)
+ .await
}
async fn execute_with_context(
@@ -273,13 +274,15 @@ impl Tool for ShellTool {
_options: ToolCallOptions,
context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
- self.execute_in_context(&DispatchCtx::ambient(), args, context).await
+ self.execute_in_context(&DispatchCtx::ambient(), args, context)
+ .await
}
}
impl ShellTool {
async fn execute_in_context(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
args: serde_json::Value,
context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
@@ -298,7 +301,9 @@ impl ShellTool {
let (allowed, result) = crate::sandbox::shell_progress::with_shell_progress(
context,
crate::sandbox::shell_progress::HEARTBEAT_INTERVAL,
- |meter| self.run_with_security_in_context(&ctx, command, requested_timeout, context, meter),
+ |meter| {
+ self.run_with_security_in_context(&ctx, command, requested_timeout, context, meter)
+ },
)
.await;
let duration_ms = u64::try_from(start.elapsed().as_millis()).unwrap_or(u64::MAX);
@@ -326,7 +331,8 @@ impl ShellTool {
/// checks (rate limits, path guards, approval gate routing) apply
/// identically to workflow-triggered commands.
pub(crate) async fn run_with_security(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
command: &str,
requested_timeout: Option<u64>,
) -> (bool, ToolResult) {
@@ -335,7 +341,8 @@ impl ShellTool {
}
async fn run_with_security_in_context(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
command: &str,
requested_timeout: Option<u64>,
context: Option<&dyn ToolRunContext>,
@@ -423,7 +430,8 @@ impl ShellTool {
// A sandboxed agent or an explicit operator backend uses the sandbox
// execution path. Security checks above still apply.
- let sandbox_required = match crate::sandbox::command_requires_sandbox(&ctx,
+ let sandbox_required = match crate::sandbox::command_requires_sandbox(
+ &ctx,
crate::agent::tinyagents::host::run_context::sandbox_mode_for_tool(context),
)
.await
@@ -624,7 +632,8 @@ impl ShellTool {
/// Execute a command through the sandbox backend. Called when the
/// agent's `SandboxMode` is `Sandboxed`.
async fn run_sandboxed(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
command: &str,
requested_timeout: Option<u64>,
action_dir: &Path,
@@ -644,7 +653,8 @@ impl ShellTool {
/// Execute a command under a resolved sandbox `policy`.
async fn run_in_policy(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
policy: crate::sandbox::SandboxPolicy,
command: &str,
requested_timeout: Option<u64>,
@@ -681,8 +691,8 @@ impl ShellTool {
"[shell] starting sandboxed command"
);
- let result = sandbox::ops::execute_in_sandbox_metered(&ctx,
- &policy, command, action_dir, extra_env, effective, meter,
+ let result = sandbox::ops::execute_in_sandbox_metered(
+ &ctx, &policy, command, action_dir, extra_env, effective, meter,
)
.await;
(true, exec_result(result, effective))
diff --git a/crates/openhuman-core/src/tools/schemas/web_search.rs b/crates/openhuman-core/src/tools/schemas/web_search.rs
index 196844cf2c..b3a7c20f4e 100644
--- a/crates/openhuman-core/src/tools/schemas/web_search.rs
+++ b/crates/openhuman-core/src/tools/schemas/web_search.rs
@@ -29,7 +29,8 @@ fn optional_text(params: &Map<String, Value>, key: &str) -> Option<String> {
}
/// Run one role tool and shape the response for RPC callers.
-async fn run_role_tool(ctx: &DispatchCtx,
+async fn run_role_tool(
+ ctx: &DispatchCtx,
tool: &'static str,
arguments: Value,
method: &str,
@@ -154,7 +155,13 @@ fn search_arguments(params: &Map<String, Value>, provider: Option<&str>) -> Resu
pub(super) fn handle_web_search(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let arguments = search_arguments(&params, None)?;
- run_role_tool(&ctx, tinysearch_bus::tools::WEB_SEARCH, arguments, "web_search").await
+ run_role_tool(
+ &ctx,
+ tinysearch_bus::tools::WEB_SEARCH,
+ arguments,
+ "web_search",
+ )
+ .await
})
}
@@ -164,7 +171,8 @@ pub(super) fn handle_searxng_search(
) -> ControllerFuture {
Box::pin(async move {
let arguments = search_arguments(&params, Some("searxng"))?;
- run_role_tool(&ctx,
+ run_role_tool(
+ &ctx,
tinysearch_bus::tools::WEB_SEARCH,
arguments,
"searxng_search",
@@ -190,7 +198,13 @@ pub(super) fn handle_web_answer(ctx: DispatchCtx, params: Map<String, Value>) ->
query_len = query.chars().count(),
"[rpc][tools.web_answer] request"
);
- run_role_tool(&ctx, tinysearch_bus::tools::WEB_ANSWER, arguments, "web_answer").await
+ run_role_tool(
+ &ctx,
+ tinysearch_bus::tools::WEB_ANSWER,
+ arguments,
+ "web_answer",
+ )
+ .await
})
}
@@ -211,7 +225,8 @@ pub(super) fn handle_web_contents(
arguments["provider"] = json!(provider);
}
tracing::debug!(urls = urls.len(), "[rpc][tools.web_contents] request");
- run_role_tool(&ctx,
+ run_role_tool(
+ &ctx,
tinysearch_bus::tools::WEB_CONTENTS,
arguments,
"web_contents",
diff --git a/crates/openhuman-core/src/web3/module_tools.rs b/crates/openhuman-core/src/web3/module_tools.rs
index c8404a7c09..362cdbb189 100644
--- a/crates/openhuman-core/src/web3/module_tools.rs
+++ b/crates/openhuman-core/src/web3/module_tools.rs
@@ -46,7 +46,8 @@ impl Tool for Web3ModuleTool {
context: Option<&dyn tinytools::ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let approval = crate::agent::tinyagents::host::run_context::approval_for_tool(context);
- self.run(&DispatchCtx::ambient(), args, approval.chat.as_ref()).await
+ self.run(&DispatchCtx::ambient(), args, approval.chat.as_ref())
+ .await
}
async fn execute_with_options(
@@ -61,7 +62,8 @@ impl Tool for Web3ModuleTool {
impl Web3ModuleTool {
/// Runs the tool for a turn whose approval context is `chat`.
pub(crate) async fn run(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
args: Value,
chat: Option<&crate::security::approval::ApprovalChatContext>,
) -> anyhow::Result<ToolResult> {
diff --git a/crates/openhuman-core/src/web3/wallet/execution.rs b/crates/openhuman-core/src/web3/wallet/execution.rs
index fa628d85ad..0b8fe6eff4 100644
--- a/crates/openhuman-core/src/web3/wallet/execution.rs
+++ b/crates/openhuman-core/src/web3/wallet/execution.rs
@@ -2,8 +2,8 @@
//! This host supplies configuration, custody, transport and approvals; wallet
//! algorithms and user-scoped service state remain in the compiled module.
-use crate::core::runtime::DispatchCtx;
use crate::config::rpc as config_rpc;
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::modules::{wallet as wallet_module, wallet_service};
use tinywallet_bus::names::methods;
@@ -20,7 +20,9 @@ use tinywallet_bus::wire::{EvmNetwork, WalletNetworkDefaults};
use super::ops::WalletChain;
/// Default row for every supported network, with the host's endpoints.
-pub async fn network_defaults(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<WalletNetworkDefaults>>, String> {
+pub async fn network_defaults(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<Vec<WalletNetworkDefaults>>, String> {
let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
@@ -39,7 +41,7 @@ pub async fn network_defaults(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<WalletN
}
/// Every asset the wallet catalogues.
-pub async fn supported_assets(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<SupportedAsset>>, String> {
+pub async fn supported_assets(ctx: &DispatchCtx) -> Result<Outcome<Vec<SupportedAsset>>, String> {
let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
@@ -58,7 +60,7 @@ pub async fn supported_assets(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<Support
}
/// Which chains have an account and a provider.
-pub async fn chain_status(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<ChainStatus>>, String> {
+pub async fn chain_status(ctx: &DispatchCtx) -> Result<Outcome<Vec<ChainStatus>>, String> {
let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
@@ -77,7 +79,7 @@ pub async fn chain_status(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<ChainStatus
}
/// Live native balances.
-pub async fn balances(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<BalanceInfo>>, String> {
+pub async fn balances(ctx: &DispatchCtx) -> Result<Outcome<Vec<BalanceInfo>>, String> {
let config = ctx.load_config().await?;
let result = wallet_service::with_native_wallet(&config, |service| async {
wallet_module::call(
@@ -96,7 +98,8 @@ pub async fn balances(ctx: &DispatchCtx, ) -> Result<Outcome<Vec<BalanceInfo>>,
}
/// Validate a transfer and store a quote for it.
-pub async fn prepare_transfer(ctx: &DispatchCtx,
+pub async fn prepare_transfer(
+ ctx: &DispatchCtx,
params: PrepareTransferParams,
owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<PreparedTransaction>, String> {
@@ -111,7 +114,8 @@ pub async fn prepare_transfer(ctx: &DispatchCtx,
}
/// Confirm and execute a prepared transfer.
-pub async fn execute_prepared(ctx: &DispatchCtx,
+pub async fn execute_prepared(
+ ctx: &DispatchCtx,
params: ExecutePreparedParams,
owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<ExecutionResult>, String> {
@@ -126,7 +130,8 @@ pub async fn execute_prepared(ctx: &DispatchCtx,
}
/// Check the on-chain lifecycle state of a broadcast transaction.
-pub async fn tx_status(ctx: &DispatchCtx,
+pub async fn tx_status(
+ ctx: &DispatchCtx,
chain: WalletChain,
evm_network: Option<EvmNetwork>,
hash: &str,
@@ -154,7 +159,8 @@ pub async fn tx_status(ctx: &DispatchCtx,
}
/// Fetch the receipt of a broadcast transaction.
-pub async fn tx_receipt(ctx: &DispatchCtx,
+pub async fn tx_receipt(
+ ctx: &DispatchCtx,
chain: WalletChain,
evm_network: Option<EvmNetwork>,
hash: &str,
@@ -182,7 +188,8 @@ pub async fn tx_receipt(ctx: &DispatchCtx,
}
/// Look up the raw transaction payload by hash.
-pub async fn lookup_tx(ctx: &DispatchCtx,
+pub async fn lookup_tx(
+ ctx: &DispatchCtx,
chain: WalletChain,
evm_network: Option<EvmNetwork>,
hash: &str,
@@ -210,7 +217,11 @@ pub async fn lookup_tx(ctx: &DispatchCtx,
}
/// Encode ERC-20 transfer calldata in the loaded wallet module.
-pub async fn encode_erc20_transfer(ctx: &DispatchCtx, to_address: &str, amount_raw: &str) -> Result<String, String> {
+pub async fn encode_erc20_transfer(
+ ctx: &DispatchCtx,
+ to_address: &str,
+ amount_raw: &str,
+) -> Result<String, String> {
let config = ctx.load_config().await?;
wallet_module::encode_erc20_transfer(&config, to_address, amount_raw)
.await
diff --git a/crates/openhuman-core/src/web3/wallet/ops.rs b/crates/openhuman-core/src/web3/wallet/ops.rs
index cf06c00370..07a11871d6 100644
--- a/crates/openhuman-core/src/web3/wallet/ops.rs
+++ b/crates/openhuman-core/src/web3/wallet/ops.rs
@@ -38,7 +38,8 @@ fn supported_word_counts() -> String {
}
/// Generate recovery material through the attested wallet module.
-pub async fn generate_recovery_phrase(ctx: &DispatchCtx,
+pub async fn generate_recovery_phrase(
+ ctx: &DispatchCtx,
word_count: u8,
) -> Result<Outcome<GeneratedRecoveryPhrase>, String> {
tinywallet_bus::validate_mnemonic_word_count(word_count).map_err(|error| error.to_string())?;
@@ -60,7 +61,8 @@ pub async fn generate_recovery_phrase(ctx: &DispatchCtx,
/// The returned BIP-39 seed is used only for OpenHuman's existing generic
/// storage-key KDF; mnemonic parsing and all chain derivation remain in the
/// confidential module operation.
-pub async fn derive_recovery_material(ctx: &DispatchCtx,
+pub async fn derive_recovery_material(
+ ctx: &DispatchCtx,
mnemonic: String,
) -> Result<Outcome<WalletRecoveryMaterial>, String> {
let word_count = mnemonic.split_whitespace().count();
@@ -115,7 +117,8 @@ pub async fn derive_recovery_material(ctx: &DispatchCtx,
}
/// Check whether a phrase is valid BIP-39 input without deriving account data.
-pub async fn validate_recovery_phrase(ctx: &DispatchCtx,
+pub async fn validate_recovery_phrase(
+ ctx: &DispatchCtx,
mnemonic: String,
) -> Result<Outcome<RecoveryPhraseValidation>, String> {
use crate::modules::wallet::WalletCallError;
@@ -201,7 +204,7 @@ fn validate_setup(params: &WalletSetupParams) -> Result<Vec<WalletAccount>, Stri
Ok(normalized)
}
-pub async fn status(ctx: &DispatchCtx, ) -> Result<Outcome<WalletStatus>, String> {
+pub async fn status(ctx: &DispatchCtx) -> Result<Outcome<WalletStatus>, String> {
let config = ctx.load_config().await?;
let _guard = WALLET_STATE_FILE_LOCK.lock();
let status = to_status(&config, load_stored_wallet_state_unlocked(&config)?);
@@ -219,7 +222,10 @@ pub async fn status(ctx: &DispatchCtx, ) -> Result<Outcome<WalletStatus>, String
))
}
-pub async fn setup(ctx: &DispatchCtx, params: WalletSetupParams) -> Result<Outcome<WalletStatus>, String> {
+pub async fn setup(
+ ctx: &DispatchCtx,
+ params: WalletSetupParams,
+) -> Result<Outcome<WalletStatus>, String> {
let config = ctx.load_config().await?;
let accounts = validate_setup(&params)?;
let encrypted_mnemonic = params
@@ -271,7 +277,9 @@ pub async fn setup(ctx: &DispatchCtx, params: WalletSetupParams) -> Result<Outco
/// This is a read-only operation — it never writes to disk or the keychain.
/// The plaintext phrase is returned only in the RPC response and must be kept
/// in transient React state on the frontend; it must never be logged or persisted.
-pub async fn reveal_recovery_phrase(ctx: &DispatchCtx, ) -> Result<Outcome<RevealRecoveryPhraseResult>, String> {
+pub async fn reveal_recovery_phrase(
+ ctx: &DispatchCtx,
+) -> Result<Outcome<RevealRecoveryPhraseResult>, String> {
debug!("{LOG_PREFIX} reveal_recovery_phrase ENTRY");
let config = ctx.load_config().await.map_err(|e| {
@@ -349,7 +357,10 @@ pub async fn reveal_recovery_phrase(ctx: &DispatchCtx, ) -> Result<Outcome<Revea
))
}
-pub(crate) async fn secret_material(ctx: &DispatchCtx, chain: WalletChain) -> Result<WalletSecretMaterial, String> {
+pub(crate) async fn secret_material(
+ ctx: &DispatchCtx,
+ chain: WalletChain,
+) -> Result<WalletSecretMaterial, String> {
debug!(
"{LOG_PREFIX} secret_material loading config chain={}",
chain.as_str()
diff --git a/crates/openhuman-core/src/web3/wallet/ops_tests.rs b/crates/openhuman-core/src/web3/wallet/ops_tests.rs
index ebf711046d..bab4e62071 100644
--- a/crates/openhuman-core/src/web3/wallet/ops_tests.rs
+++ b/crates/openhuman-core/src/web3/wallet/ops_tests.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
use super::*;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
fn sample_account(chain: WalletChain) -> WalletAccount {
WalletAccount {
@@ -249,9 +249,10 @@ async fn reveal_recovery_phrase_returns_error_when_no_wallet() {
async fn reveal_recovery_phrase_returns_phrase_for_existing_wallet() {
let temp = tempfile::tempdir().expect("temp dir");
let _wallet_lock = crate::web3::wallet::test_support::TEST_LOCK.lock().await;
- let _workspace_guard = crate::web3::wallet::test_support::setup_wallet_in(&DispatchCtx::process_default(), &temp)
- .await
- .expect("setup wallet");
+ let _workspace_guard =
+ crate::web3::wallet::test_support::setup_wallet_in(&DispatchCtx::process_default(), &temp)
+ .await
+ .expect("setup wallet");
let result = reveal_recovery_phrase(&DispatchCtx::process_default())
.await
.expect("reveal should succeed");
diff --git a/crates/openhuman-core/src/web3/wallet/schemas.rs b/crates/openhuman-core/src/web3/wallet/schemas.rs
index 03cc789f38..e4ce906679 100644
--- a/crates/openhuman-core/src/web3/wallet/schemas.rs
+++ b/crates/openhuman-core/src/web3/wallet/schemas.rs
@@ -440,14 +440,17 @@ fn handle_setup(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutur
Box::pin(async move {
let payload: SetupWalletParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
- crate::web3::wallet::setup(&ctx, WalletSetupParams {
- consent_granted: payload.consent_granted,
- source: payload.source,
- mnemonic_word_count: payload.mnemonic_word_count,
- encrypted_mnemonic: Some(payload.encrypted_mnemonic),
- accounts: payload.accounts,
- force: payload.force,
- })
+ crate::web3::wallet::setup(
+ &ctx,
+ WalletSetupParams {
+ consent_granted: payload.consent_granted,
+ source: payload.source,
+ mnemonic_word_count: payload.mnemonic_word_count,
+ encrypted_mnemonic: Some(payload.encrypted_mnemonic),
+ accounts: payload.accounts,
+ force: payload.force,
+ },
+ )
.await?
.into_cli_compatible_json()
})
@@ -472,8 +475,10 @@ fn handle_encode_erc20_transfer(ctx: DispatchCtx, params: Map<String, Value>) ->
if parsed.chain != WalletChain::Evm {
return Err("encode_erc20_transfer only supports the evm chain".to_string());
}
- serde_json::to_value(encode_erc20_transfer(&ctx, &parsed.to_address, &parsed.amount_raw).await?)
- .map_err(|e| format!("failed to encode ERC20 transfer output: {e}"))
+ serde_json::to_value(
+ encode_erc20_transfer(&ctx, &parsed.to_address, &parsed.amount_raw).await?,
+ )
+ .map_err(|e| format!("failed to encode ERC20 transfer output: {e}"))
})
}
diff --git a/crates/openhuman-core/src/web3/wallet/test_support.rs b/crates/openhuman-core/src/web3/wallet/test_support.rs
index c36f1f52e8..7dd39da136 100644
--- a/crates/openhuman-core/src/web3/wallet/test_support.rs
+++ b/crates/openhuman-core/src/web3/wallet/test_support.rs
@@ -116,7 +116,10 @@ pub(crate) async fn set_workspace_env_for_test(temp: &TempDir) -> EnvVarGuard {
EnvVarGuard::workspace_async(temp.path()).await
}
-pub(crate) async fn setup_wallet_in(ctx: &DispatchCtx, temp: &TempDir) -> Result<EnvVarGuard, String> {
+pub(crate) async fn setup_wallet_in(
+ ctx: &DispatchCtx,
+ temp: &TempDir,
+) -> Result<EnvVarGuard, String> {
// Wallet state lookups rely on OPENHUMAN_WORKSPACE for the duration of
// each test. Return a guard so the tempdir path does not leak into later
// parallel tests after this test's TempDir has been dropped.
@@ -125,23 +128,26 @@ pub(crate) async fn setup_wallet_in(ctx: &DispatchCtx, temp: &TempDir) -> Result
let encrypted = crate::security::encryption::rpc::encrypt_secret(&config, TEST_MNEMONIC)
.await?
.value;
- setup(&ctx, WalletSetupParams {
- consent_granted: true,
- source: WalletSetupSource::Imported,
- mnemonic_word_count: 12,
- encrypted_mnemonic: Some(encrypted),
- accounts: [
- WalletChain::Evm,
- WalletChain::Btc,
- WalletChain::Solana,
- WalletChain::Tron,
- ]
- .into_iter()
- .map(sample_account)
- .collect(),
- // Test helper: force=true allows re-setup in tests that already have a wallet.
- force: true,
- })
+ setup(
+ &ctx,
+ WalletSetupParams {
+ consent_granted: true,
+ source: WalletSetupSource::Imported,
+ mnemonic_word_count: 12,
+ encrypted_mnemonic: Some(encrypted),
+ accounts: [
+ WalletChain::Evm,
+ WalletChain::Btc,
+ WalletChain::Solana,
+ WalletChain::Tron,
+ ]
+ .into_iter()
+ .map(sample_account)
+ .collect(),
+ // Test helper: force=true allows re-setup in tests that already have a wallet.
+ force: true,
+ },
+ )
.await?;
Ok(workspace_guard)
}
diff --git a/crates/openhuman-core/src/web3/wallet/tools.rs b/crates/openhuman-core/src/web3/wallet/tools.rs
index 9e1388a73e..48f6689c20 100644
--- a/crates/openhuman-core/src/web3/wallet/tools.rs
+++ b/crates/openhuman-core/src/web3/wallet/tools.rs
@@ -67,14 +67,16 @@ impl Tool for WalletModuleTool {
context: Option<&dyn tinytools::ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let approval = crate::agent::tinyagents::host::run_context::approval_for_tool(context);
- self.run(&DispatchCtx::ambient(), args, approval.chat.as_ref()).await
+ self.run(&DispatchCtx::ambient(), args, approval.chat.as_ref())
+ .await
}
}
impl WalletModuleTool {
/// Runs the tool for a turn whose approval context is `chat`.
pub(crate) async fn run(
- &self, ctx: &DispatchCtx,
+ &self,
+ ctx: &DispatchCtx,
args: Value,
chat: Option<&crate::security::approval::ApprovalChatContext>,
) -> anyhow::Result<ToolResult> {
@@ -106,11 +108,17 @@ impl WalletModuleTool {
};
let result = match self.name() {
"wallet_tx_status" => outcome_value(
- crate::web3::wallet::tx_status(&ctx, query.chain, query.evm_network, &query.hash)
- .await,
+ crate::web3::wallet::tx_status(
+ &ctx,
+ query.chain,
+ query.evm_network,
+ &query.hash,
+ )
+ .await,
),
"wallet_tx_receipt" => outcome_value(
- crate::web3::wallet::tx_receipt(&ctx,
+ crate::web3::wallet::tx_receipt(
+ &ctx,
query.chain,
query.evm_network,
&query.hash,
@@ -118,8 +126,13 @@ impl WalletModuleTool {
.await,
),
_ => outcome_value(
- crate::web3::wallet::lookup_tx(&ctx, query.chain, query.evm_network, &query.hash)
- .await,
+ crate::web3::wallet::lookup_tx(
+ &ctx,
+ query.chain,
+ query.evm_network,
+ &query.hash,
+ )
+ .await,
),
};
result
diff --git a/crates/openhuman-embed/tests/agent_lifecycle.rs b/crates/openhuman-embed/tests/agent_lifecycle.rs
index e880249753..f22513a710 100644
--- a/crates/openhuman-embed/tests/agent_lifecycle.rs
+++ b/crates/openhuman-embed/tests/agent_lifecycle.rs
@@ -144,7 +144,8 @@ fn removing_an_agent_releases_everything_it_held() {
"a removal barrier is a benign decision miss, not a lost registration"
);
for owner in [None, Some("closing")] {
- assert!(openhuman_core::security::approval::rpc::approval_decide(&openhuman_core::core::runtime::DispatchCtx::process_default(),
+ assert!(openhuman_core::security::approval::rpc::approval_decide(
+ &openhuman_core::core::runtime::DispatchCtx::process_default(),
&closing_request.request_id,
openhuman_embed::ApprovalDecision::ApproveOnce,
owner,
diff --git a/tests/in_process/config_auth_app_state_connectivity_e2e.rs b/tests/in_process/config_auth_app_state_connectivity_e2e.rs
index e1064aff4a..0911d49675 100644
--- a/tests/in_process/config_auth_app_state_connectivity_e2e.rs
+++ b/tests/in_process/config_auth_app_state_connectivity_e2e.rs
@@ -1,10 +1,10 @@
//! Focused JSON-RPC E2E coverage for config, auth/credentials, app_state,
//! and connectivity controller surfaces.
-use openhuman_core::core::runtime::DispatchCtx;
use crate::env_guard::{env_lock, env_lock_async, EnvVarGuard};
use crate::rpc_auth::ensure_rpc_auth;
use crate::rpc_harness::{ok, payload, rpc, schema};
+use openhuman_core::core::runtime::DispatchCtx;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use std::sync::{
@@ -1097,11 +1097,13 @@ async fn config_default_path_loader_ignores_workspace_override_and_projects_dir_
let root = home.join(".openhuman");
let user_dir = root.join("users").join("default-loader-user");
let workspace_override = tmp.path().join("workspace-override");
- let _guards = [EnvVarGuard::set_to_path("HOME", &home),
+ let _guards = [
+ EnvVarGuard::set_to_path("HOME", &home),
EnvVarGuard::unset(APP_ENV_VAR),
EnvVarGuard::unset(VITE_APP_ENV_VAR),
EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", &workspace_override),
- EnvVarGuard::set("OPENHUMAN_MODEL", " default-loader-model ")];
+ EnvVarGuard::set("OPENHUMAN_MODEL", " default-loader-model "),
+ ];
let missing = Config::load_from_default_paths()
.await
@@ -2676,17 +2678,25 @@ async fn config_auto_approve_public_helper_persists_once_and_is_idempotent() {
let _lock = env_lock_async().await;
let tmp = tempdir().expect("tempdir");
let home = tmp.path().join("home");
- let _guards = [EnvVarGuard::set_to_path("HOME", &home),
+ let _guards = [
+ EnvVarGuard::set_to_path("HOME", &home),
EnvVarGuard::unset("OPENHUMAN_WORKSPACE"),
EnvVarGuard::unset(APP_ENV_VAR),
- EnvVarGuard::unset(VITE_APP_ENV_VAR)];
+ EnvVarGuard::unset(VITE_APP_ENV_VAR),
+ ];
- openhuman_core::config::add_auto_approve_tool(&DispatchCtx::process_default(), "tool.config.round10")
- .await
- .expect("add auto approve tool");
- openhuman_core::config::add_auto_approve_tool(&DispatchCtx::process_default(), "tool.config.round10")
- .await
- .expect("idempotent auto approve tool");
+ openhuman_core::config::add_auto_approve_tool(
+ &DispatchCtx::process_default(),
+ "tool.config.round10",
+ )
+ .await
+ .expect("add auto approve tool");
+ openhuman_core::config::add_auto_approve_tool(
+ &DispatchCtx::process_default(),
+ "tool.config.round10",
+ )
+ .await
+ .expect("idempotent auto approve tool");
let loaded = Config::load_or_init()
.await