Skip to content

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

refactor(channels): clean up imports and test structure

Steven Enamakel274e09d49310
diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rs
index a8c54f2ed3..da1798d008 100644
--- a/crates/openhuman-core/src/channels/bus/delivery.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery.rs
@@ -2,17 +2,17 @@
use crate::backend::{BackendApiError, BackendClient};
use crate::modules::channel_runtime::ChannelRuntimeLease;
use crate::security::credentials::session_support::{
- BackendCredential, get_session_token, is_local_session_token,
+ get_session_token, is_local_session_token, BackendCredential,
};
+use serde_json::json;
#[cfg(test)]
use serde_json::Value;
-use serde_json::json;
use tinybus::module::ModuleCallError;
use tinychannels_bus::module_progressive::{
ChannelOutputEvent, ProgressiveCommand, ProgressiveEvent, ProgressiveResult,
ProgressiveTransportRequest, ProgressiveTransportResult,
};
-use tinychannels_bus::{ChannelBackendRequest, ChannelBackendResult, methods};
+use tinychannels_bus::{methods, ChannelBackendRequest, ChannelBackendResult};
/// Transport refusals are typed facts; recovery and retry budgets belong to the module.
pub(super) fn map_backend_error(error: anyhow::Error) -> ProgressiveTransportResult {
diff --git a/crates/openhuman-core/src/channels/bus/delivery_tests.rs b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
index f50da2e333..9e8d49c9fa 100644
--- a/crates/openhuman-core/src/channels/bus/delivery_tests.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
@@ -16,14 +16,12 @@ async fn transport_captures_no_local_or_missing_hosted_credential() {
let _env_lock = crate::config::TEST_ENV_LOCK.lock().await;
let workspace = tempfile::tempdir().expect("temporary workspace");
let _workspace_env = EnvVarGuard::workspace_unlocked(workspace.path());
- assert!(
- ManagedTransport::capture(
- &crate::config::Config::default(),
- "telegram".into(),
- tokio_util::sync::CancellationToken::new()
- )
- .is_err()
- );
+ assert!(ManagedTransport::capture(
+ &crate::config::Config::default(),
+ "telegram".into(),
+ tokio_util::sync::CancellationToken::new()
+ )
+ .is_err());
}
#[test]
diff --git a/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs b/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
index bffce5fba7..f71f9a2de1 100644
--- a/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
+++ b/crates/openhuman-core/src/channels/bus_inbound_thread_id_tests_tests.rs
@@ -15,12 +15,10 @@ fn channel_message_body_adds_deterministic_idempotency_key() {
assert_eq!(left["text"], "hello");
assert_eq!(left["threadId"], "topic-1");
assert_eq!(left["idempotencyKey"], right["idempotencyKey"]);
- assert!(
- left["idempotencyKey"]
- .as_str()
- .expect("idempotency key")
- .starts_with("legacy-send:telegram:")
- );
+ assert!(left["idempotencyKey"]
+ .as_str()
+ .expect("idempotency key")
+ .starts_with("legacy-send:telegram:"));
}
#[test]
diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rs
index 6753bcd625..efc293cb22 100644
--- a/crates/openhuman-core/src/channels/context_tests.rs
+++ b/crates/openhuman-core/src/channels/context_tests.rs
@@ -90,11 +90,12 @@ fn timeout_and_history_keys_respect_channel_rules() {
#[tokio::test]
async fn overflow_detection_covers_edge_cases() {
let ctx = runtime_context();
- assert!(
- is_context_window_overflow_error(&ctx, &anyhow::anyhow!("Maximum context length exceeded"))
- .await
- .unwrap()
- );
+ assert!(is_context_window_overflow_error(
+ &ctx,
+ &anyhow::anyhow!("Maximum context length exceeded")
+ )
+ .await
+ .unwrap());
assert!(
!is_context_window_overflow_error(&ctx, &anyhow::anyhow!("network timeout"))
.await
diff --git a/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
index c82b4be6b4..2613426d6f 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/callback_tests.rs
@@ -1,9 +1,9 @@
use super::*;
use super::{ProgressiveChannelTransport, ProgressiveOutputObserver};
-use crate::channels::Channel;
use crate::channels::context::ChannelRuntimeContext;
use crate::channels::runtime::dispatch::RuntimeChannelMessage;
+use crate::channels::Channel;
use std::collections::HashMap;
use std::sync::{Arc, Mutex, OnceLock, Weak};
use tinychannels_bus::channel::{
@@ -176,16 +176,14 @@ fn callback_for_channels(
let context_slot: Arc<OnceLock<Weak<ChannelRuntimeContext>>> = Arc::new(OnceLock::new());
assert!(context_slot.set(Arc::downgrade(&context)).is_ok());
let progressive_slot = Arc::new(OnceLock::new());
- assert!(
- progressive_slot
- .set(Arc::new(
- progressive_channels
- .into_iter()
- .map(|(name, adapter)| (name, Arc::downgrade(&adapter)))
- .collect()
- ))
- .is_ok()
- );
+ assert!(progressive_slot
+ .set(Arc::new(
+ progressive_channels
+ .into_iter()
+ .map(|(name, adapter)| (name, Arc::downgrade(&adapter)))
+ .collect()
+ ))
+ .is_ok());
let (dispatch, _receiver) = tokio::sync::mpsc::channel::<RuntimeChannelMessage>(1);
let mut callback = ChannelHostCallbacks::new(
&crate::core::runtime::DispatchCtx::host_default(),
@@ -531,16 +529,14 @@ async fn native_progressive_callbacks_stop_after_channel_session_cancellation()
);
callback.cancellation.cancel();
- assert!(
- callback
- .dispatch_controller_backend(output_event_request(
- Some("telegram:bot-b"),
- Some("chat-42"),
- Some("turn-15"),
- ))
- .await
- .is_err()
- );
+ assert!(callback
+ .dispatch_controller_backend(output_event_request(
+ Some("telegram:bot-b"),
+ Some("chat-42"),
+ Some("turn-15"),
+ ))
+ .await
+ .is_err());
assert!(observer.seen.lock().await.is_empty());
}
@@ -569,16 +565,14 @@ async fn native_progressive_callbacks_fail_closed_after_transport_owner_drops()
drop(context);
drop(adapter);
- assert!(
- callback
- .dispatch_controller_backend(output_event_request(
- Some("telegram:bot-b"),
- Some("chat-42"),
- Some("turn-16"),
- ))
- .await
- .is_err()
- );
+ assert!(callback
+ .dispatch_controller_backend(output_event_request(
+ Some("telegram:bot-b"),
+ Some("chat-42"),
+ Some("turn-16"),
+ ))
+ .await
+ .is_err());
}
#[path = "callback_inbound_tests.rs"]
diff --git a/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs b/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
index f88127c926..ed81ed333d 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/delivery_import.rs
@@ -18,11 +18,11 @@
use std::collections::BTreeMap;
use std::path::Path;
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use sha2::Digest;
use tinychannels_bus::module_delivery::{
- DELIVERY_PENDING_CAPACITY, DELIVERY_RECORD_BYTES, DELIVERY_RESULT_CAPACITY,
- DELIVERY_RESULT_TTL_SECONDS, DeliveryQueueEntry, DeliveryTerminalResult,
+ DeliveryQueueEntry, DeliveryTerminalResult, DELIVERY_PENDING_CAPACITY, DELIVERY_RECORD_BYTES,
+ DELIVERY_RESULT_CAPACITY, DELIVERY_RESULT_TTL_SECONDS,
};
use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition};
diff --git a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
index 271b99d4bb..040e6521f0 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
@@ -39,7 +39,7 @@ fn module_callback_error_does_not_expose_provider_details() {
#[test]
fn receipt_scope_requires_exact_channel_and_full_conversation_identity() {
- use tinychannels_bus::channel::{MessageReceipt, types::ConversationKind};
+ use tinychannels_bus::channel::{types::ConversationKind, MessageReceipt};
use tinychannels_bus::{ChannelRef, ConversationRef};
let channel = ChannelRef {
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
index 5389f2d905..0073b73aed 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs
@@ -3,7 +3,7 @@
use super::super::dispatch::run_message_dispatch_loop;
use super::module_providers::ModuleChannelRuntime;
-use super::turn_parts::{PromptToolDescs, build_channel_turn_parts, runtime_context};
+use super::turn_parts::{build_channel_turn_parts, runtime_context, PromptToolDescs};
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
diff --git a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
index c3e3a3f32b..640d76af9a 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/turn_parts.rs
@@ -6,7 +6,7 @@
//! the caller's own config and policy, so a relayed turn never runs with the
//! operator's tools or workspace.
-use super::chat_workload::{ChatWorkloadResolution, resolve_chat_workload};
+use super::chat_workload::{resolve_chat_workload, ChatWorkloadResolution};
use super::prompt::format_access_context;
use crate::agent::host_runtime;
use crate::channels::context::ChannelRuntimeContext;
diff --git a/crates/openhuman-core/src/channels/runtime/startup_tests.rs b/crates/openhuman-core/src/channels/runtime/startup_tests.rs
index 691e9fd8da..e8af9daf17 100644
--- a/crates/openhuman-core/src/channels/runtime/startup_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup_tests.rs
@@ -7,7 +7,7 @@
//! (cloud) path is preserved for users who haven't picked a local /
//! BYOK model, and the override path activates for those who have.
-use super::{ChatWorkloadResolution, RelayInboundMessageHandler, resolve_chat_workload};
+use super::{resolve_chat_workload, ChatWorkloadResolution, RelayInboundMessageHandler};
use crate::config::Config;
use tinychannels::relay::RelayInboundHandler;