Skip to content

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

fix: satisfy strict Rust checks on main

Steven Enamakelb150e4cdf616
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
index 8c50abd733..969f39acde 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs
@@ -31,9 +31,9 @@ impl OpenHumanTurnPrelude {
.is_empty();
#[cfg(not(feature = "mcp"))]
let has_configured_mcp_tools = false;
- if !definition
+ if definition
.as_ref()
- .is_some_and(|definition| !definition.subagents.is_empty())
+ .is_none_or(|definition| definition.subagents.is_empty())
&& !has_recorded_tool_snapshot
&& !has_configured_mcp_tools
{
diff --git a/crates/openhuman-core/src/channels/controllers/backend.rs b/crates/openhuman-core/src/channels/controllers/backend.rs
index c5e83b9256..3a2ac66f05 100644
--- a/crates/openhuman-core/src/channels/controllers/backend.rs
+++ b/crates/openhuman-core/src/channels/controllers/backend.rs
@@ -1,6 +1,8 @@
//! TinyChannels backend implementation for OpenHuman controller operations.
-use serde_json::{json, Value};
+use serde_json::Value;
+#[cfg(test)]
+use serde_json::json;
use crate::config::{ChannelsConfig, Config};
use crate::core::Outcome;
diff --git a/crates/openhuman-core/src/channels/providers/relay/channel.rs b/crates/openhuman-core/src/channels/providers/relay/channel.rs
index d1524107ee..d68e94dd44 100644
--- a/crates/openhuman-core/src/channels/providers/relay/channel.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/channel.rs
@@ -11,7 +11,7 @@ use async_trait::async_trait;
use serde_json::json;
use crate::channels::traits::{Channel, ChannelMessage, SendMessage};
-use crate::web_chat::{WebChannelEvent, publish_web_channel_event};
+use crate::web_chat::{publish_web_channel_event, WebChannelEvent};
/// The event name a relayed reply is published under.
pub const CHANNEL_OUTBOUND_EVENT: &str = "channel_outbound";
diff --git a/crates/openhuman-core/src/channels/providers/relay/mod.rs b/crates/openhuman-core/src/channels/providers/relay/mod.rs
index d2c9ebde8c..725be88e74 100644
--- a/crates/openhuman-core/src/channels/providers/relay/mod.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/mod.rs
@@ -26,10 +26,10 @@ mod params;
mod schemas;
mod store;
-pub use channel::{CHANNEL_OUTBOUND_EVENT, RelayChannel};
+pub use channel::{RelayChannel, CHANNEL_OUTBOUND_EVENT};
pub use ops::channel_relay_inbound;
pub use params::{
- DEFAULT_RELAY_CLIENT_ID, MAX_CHANNEL_LEN, MAX_ID_LEN, MAX_SENDER_NAME_CHARS, MAX_TEXT_BYTES,
- RESERVED_CHANNELS, RelayInboundParams, validate_channel, validate_id,
+ validate_channel, validate_id, RelayInboundParams, DEFAULT_RELAY_CLIENT_ID, MAX_CHANNEL_LEN,
+ MAX_ID_LEN, MAX_SENDER_NAME_CHARS, MAX_TEXT_BYTES, RESERVED_CHANNELS,
};
pub use schemas::{all_relay_controller_schemas, all_relay_registered_controllers};
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index d4b38fb90b..094d7345e4 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -3,15 +3,15 @@
use std::collections::HashMap;
use std::sync::Arc;
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use super::channel::RelayChannel;
use super::params::RelayInboundParams;
use super::store::{self, Recorded};
use crate::channels::context::MAX_CHANNEL_HISTORY;
use crate::channels::runtime::{
- PromptToolDescs, build_channel_turn_parts, prepare_runtime_limits,
- process_channel_runtime_message, runtime_context,
+ build_channel_turn_parts, prepare_runtime_limits, process_channel_runtime_message,
+ runtime_context, PromptToolDescs,
};
use crate::config::Config;
use crate::core::Outcome;
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
index a54b7367ab..b84087bf32 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
@@ -1,6 +1,6 @@
use super::super::channel::CHANNEL_OUTBOUND_EVENT;
use super::*;
-use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, mock_agent_run_turn};
+use crate::agent::bus::{mock_agent_run_turn, AgentTurnRequest, AgentTurnResponse};
use crate::agent::turn_origin::AgentTurnOrigin;
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
use std::sync::Mutex;
diff --git a/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs b/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
index 8f0be869cb..c696065b47 100644
--- a/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/schemas_tests.rs
@@ -24,11 +24,9 @@ fn the_controller_is_channel_relay_inbound() {
#[test]
fn the_controller_is_registered() {
- assert!(
- crate::core::all::all_registered_controllers()
- .iter()
- .any(|c| c.rpc_method_name() == "openhuman.channel_relay_inbound")
- );
+ assert!(crate::core::all::all_registered_controllers()
+ .iter()
+ .any(|c| c.rpc_method_name() == "openhuman.channel_relay_inbound"));
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/channels/runtime/mod.rs b/crates/openhuman-core/src/channels/runtime/mod.rs
index 330e5566cd..87b8ee69b1 100644
--- a/crates/openhuman-core/src/channels/runtime/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/mod.rs
@@ -12,9 +12,9 @@ pub use startup::start_channels;
pub(crate) use startup::start_channels_with_session;
// The hosted-channel relay (`channels::providers::relay`) runs one message
// through the same pipeline, with a context built from the caller's config.
-pub(crate) use dispatch::{
- process_channel_message, process_channel_runtime_message, RuntimeChannelMessage,
-};
+#[cfg(test)]
+pub(crate) use dispatch::process_channel_message;
+pub(crate) use dispatch::{process_channel_runtime_message, RuntimeChannelMessage};
pub(crate) use startup::{build_channel_turn_parts, runtime_context, PromptToolDescs};
#[cfg(any(test, debug_assertions))]
diff --git a/crates/openhuman-core/src/channels/runtime/startup/delivery_store.rs b/crates/openhuman-core/src/channels/runtime/startup/delivery_store.rs
index 711b92ad61..c75227af2d 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/delivery_store.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/delivery_store.rs
@@ -171,7 +171,7 @@ impl ChannelDeliveryStore {
"delivery fingerprint is invalid"
);
anyhow::ensure!(
- serde_json::to_vec(&result).map_or(false, |bytes| bytes.len() <= DELIVERY_RECORD_BYTES),
+ serde_json::to_vec(&result).is_ok_and(|bytes| bytes.len() <= DELIVERY_RECORD_BYTES),
"delivery result exceeds its record limit"
);
let (_guard, mut state) = self.locked_state().await?;
@@ -240,7 +240,7 @@ fn validate_entry(entry: &DeliveryQueueEntry) -> anyhow::Result<()> {
"delivery id does not match intent key"
);
anyhow::ensure!(
- serde_json::to_vec(entry).map_or(false, |bytes| bytes.len() <= DELIVERY_RECORD_BYTES),
+ serde_json::to_vec(entry).is_ok_and(|bytes| bytes.len() <= DELIVERY_RECORD_BYTES),
"delivery record exceeds its limit"
);
Ok(())
diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
index 232589796c..3614092ec8 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs
@@ -365,7 +365,7 @@ impl Channel for ModuleChannel {
}
fn capabilities(&self) -> tinychannels_bus::ChannelCapabilities {
- self.interaction.capabilities.clone()
+ self.interaction.capabilities
}
fn supports_reactions(&self) -> bool {
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rs
index 85268ffb41..9d9d946050 100644
--- a/crates/openhuman-core/src/core/runtime/services.rs
+++ b/crates/openhuman-core/src/core/runtime/services.rs
@@ -297,9 +297,7 @@ pub fn spawn_channels_service() -> Option<tokio::task::JoinHandle<()>> {
|channel_session| async move {
let config = match crate::config::Config::load_or_init().await {
Ok(c) => c,
- Err(e) => {
- return Err(e.into());
- }
+ Err(e) => return Err(e),
};
if !crate::channels::has_listener_configuration(&config) {
log::debug!(
diff --git a/crates/openhuman-core/src/mcp/server/http.rs b/crates/openhuman-core/src/mcp/server/http.rs
index 125b283668..ac745f36da 100644
--- a/crates/openhuman-core/src/mcp/server/http.rs
+++ b/crates/openhuman-core/src/mcp/server/http.rs
@@ -171,10 +171,7 @@ async fn http_session_request(
} else {
None
};
- let internal_session_id = match session.as_ref() {
- Some(session) => Some(session.id().to_owned()),
- None => None,
- };
+ let internal_session_id = session.as_ref().map(|session| session.id().to_owned());
let request = ServerHttpSessionRequest {
method: method.clone(),
requested_session_id: requested_session_id.clone(),
diff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
index 31bdc3a25f..013c199543 100644
--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
@@ -338,7 +338,7 @@ async fn run_subagent_tool(params: &Map<String, Value>) -> Result<Value, ToolCal
let config = load_config_and_init_registry().await?;
let mut agent =
- OpenHumanSessionHost::from_config_for_agent(&config, &agent_id).map_err(|err| {
+ OpenHumanSessionHost::from_config_for_agent(&config, agent_id).map_err(|err| {
ToolCallError::InvalidParams(format!("failed to build agent `{agent_id}`: {err}"))
})?;
agent.set_event_context(
@@ -370,7 +370,7 @@ async fn run_subagent_tool(params: &Map<String, Value>) -> Result<Value, ToolCal
// `handle_json_value` dispatch above it) keeps a small stack frame.
let response = Box::pin(subagent_depth::scope(
child_depth,
- crate::agent::turn_origin::with_origin(origin, agent.run_single(&prompt)),
+ crate::agent::turn_origin::with_origin(origin, agent.run_single(prompt)),
))
.await
.map_err(|err| ToolCallError::Internal(format!("subagent `{agent_id}` failed: {err}")))?;
diff --git a/crates/openhuman-core/src/modules/tinybox_tests.rs b/crates/openhuman-core/src/modules/tinybox_tests.rs
index fe5acb28c4..cb6a5c430f 100644
--- a/crates/openhuman-core/src/modules/tinybox_tests.rs
+++ b/crates/openhuman-core/src/modules/tinybox_tests.rs
@@ -2,7 +2,7 @@
use std::sync::{Arc, Mutex};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinybus::broker::Broker;
use tinybus::service::Interface;
use tinybus::transport::memory::MemoryBus;
@@ -557,8 +557,8 @@ async fn no_workspace_docker_refusal_is_not_retried_as_an_ordinary_call() {
}
#[tokio::test]
-async fn docker_controls_use_typed_calls_with_validated_contract_capability()
--> Result<(), Box<dyn std::error::Error>> {
+async fn docker_controls_use_typed_calls_with_validated_contract_capability(
+) -> Result<(), Box<dyn std::error::Error>> {
let (_service, client, calls) = mock_client().await;
let status = call_docker_status_with_client(
&client,