The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
style: apply rustfmt formatting across profiles, web_chat, and saas tests
Steven Enamakel129e5534f7ff
diff --git a/crates/openhuman-core/src/core/runtime/saas_tests.rs b/crates/openhuman-core/src/core/runtime/saas_tests.rsindex 6f7998c336..7c3fe4c6ea 100644--- a/crates/openhuman-core/src/core/runtime/saas_tests.rs+++ b/crates/openhuman-core/src/core/runtime/saas_tests.rs@@ -173,7 +173,11 @@ fn cluster_settings_default_and_resolve() {let mut fresh = SaasConfig::new("/srv/oh");let random = fresh.resolve_node_id(None).to_owned();assert!(random.starts_with("node-"), "{random}");- assert_eq!(fresh.resolve_node_id(Some("ignored")), random, "resolved once");+ assert_eq!(+ fresh.resolve_node_id(Some("ignored")),+ random,+ "resolved once"+ );let mut configured = SaasConfig::new("/srv/oh");configured.node_id = Some("node-file".into());assert_eq!(configured.resolve_node_id(Some("node-env")), "node-file");diff --git a/crates/openhuman-core/src/profiles/gateway_tests.rs b/crates/openhuman-core/src/profiles/gateway_tests.rsindex acfc6ff093..e04b9778c1 100644--- a/crates/openhuman-core/src/profiles/gateway_tests.rs+++ b/crates/openhuman-core/src/profiles/gateway_tests.rs@@ -68,11 +68,8 @@ fn a_profile_held_elsewhere_is_a_409_naming_the_holder() {expires_at_ms: 10_000,released: false,};- let refusal = GatewayRefusal::from_open_error(- &id("alice"),- OpenError::HeldElsewhere(record),- 4_000,- );+ let refusal =+ GatewayRefusal::from_open_error(&id("alice"), OpenError::HeldElsewhere(record), 4_000);assert_eq!(refusal.status, 409);assert_eq!(refusal.message, PROFILE_HELD);assert_eq!(diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rsindex 6ca8bfca35..53ab2d87f8 100644--- a/crates/openhuman-core/src/profiles/host.rs+++ b/crates/openhuman-core/src/profiles/host.rs@@ -210,7 +210,11 @@ impl ProfileHost {}let grant = match held {Some(grant) => grant,- None => match self.leases.acquire(id.as_str(), profile_lease::now_ms()).await {+ None => match self+ .leases+ .acquire(id.as_str(), profile_lease::now_ms())+ .await+ {Ok(grant) => grant,Err(LeaseError::Held(record)) => {return Err(format!(@@ -514,9 +518,11 @@ impl ProfileHost {"[profiles] fenced profile={id} node={} ({why}); stopping its turns",self.node);- let stopped =- CoreContext::scope(Arc::clone(state.context()), crate::web_chat::cancel_all_turns())- .await;+ let stopped = CoreContext::scope(+ Arc::clone(state.context()),+ crate::web_chat::cancel_all_turns(),+ )+ .await;log::info!("[profiles] fenced profile={id}: stopped {stopped} thread(s)");}@@ -530,9 +536,7 @@ impl ProfileHost {let idle_limit = Duration::from_secs(self.saas.idle_evict_secs);let idle: Vec<ProfileId> = open.iter()- .filter(|(_, slot)| {- !in_use(slot) && now.duration_since(slot.last_used) >= idle_limit- })+ .filter(|(_, slot)| !in_use(slot) && now.duration_since(slot.last_used) >= idle_limit).map(|(id, _)| id.clone()).collect();idle.into_iter()@@ -633,7 +637,11 @@ fn recover_session_store(id: &ProfileId, context: &Arc<CoreContext>) {}let key = crate::core::runtime::session_key(&crate::core::runtime::Tenant::of(context));let now = chrono::Utc::now().to_rfc3339();- match provider.for_agent(&key).turn_states.mark_all_interrupted(&now) {+ match provider+ .for_agent(&key)+ .turn_states+ .mark_all_interrupted(&now)+ {Ok(0) => {}Ok(turns) => {log::info!("[profiles] profile={id} recovered {turns} interrupted stored turn(s)");diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rsindex 2b3d28f71f..caaf9761d6 100644--- a/crates/openhuman-core/src/profiles/host_tests.rs+++ b/crates/openhuman-core/src/profiles/host_tests.rs@@ -17,7 +17,10 @@ async fn provisioning_creates_the_layout_once() {let host = host(&tmp, 4, 60);let id = profile("alice");assert!(host.provision(&id).await.unwrap());- assert!(!host.provision(&id).await.unwrap(), "second provision is a no-op");+ assert!(+ !host.provision(&id).await.unwrap(),+ "second provision is a no-op"+ );let layout = ProfileLayout::new(tmp.path(), &id);assert!(layout.workspace_dir.is_dir() && layout.sandbox_dir.is_dir());let summary = host.summary(&id).await.unwrap().unwrap();diff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rsindex 0a2508c4a0..96f0609c89 100644--- a/crates/openhuman-core/src/profiles/lease_tests.rs+++ b/crates/openhuman-core/src/profiles/lease_tests.rs@@ -140,7 +140,10 @@ async fn eviction_and_shutdown_release_the_lease() {let busy = a.open(&bob).await.unwrap();a.release_idle_on_shutdown().await;- assert!(a.is_open(&bob), "a profile in use keeps its lease at shutdown");+ assert!(+ a.is_open(&bob),+ "a profile in use keeps its lease at shutdown"+ );drop(busy);a.release_idle_on_shutdown().await;assert!(!a.is_open(&bob));diff --git a/crates/openhuman-core/src/profiles/mod.rs b/crates/openhuman-core/src/profiles/mod.rsindex 565813c013..bfe9a1f032 100644--- a/crates/openhuman-core/src/profiles/mod.rs+++ b/crates/openhuman-core/src/profiles/mod.rs@@ -36,8 +36,8 @@ pub mod tools;pub mod types;pub use host::{current, Profile, ProfileHost};+pub use layout::ProfileLayout;pub use lease::OpenError;pub use registry::ProfileRegistry;-pub use layout::ProfileLayout;pub use schemas::{all_profiles_controller_schemas, all_profiles_registered_controllers};pub use types::{ProfileId, ProfileIdMode, ProfileSummary};diff --git a/crates/openhuman-core/src/profiles/ops.rs b/crates/openhuman-core/src/profiles/ops.rsindex a36c595314..2eb8d2bf81 100644--- a/crates/openhuman-core/src/profiles/ops.rs+++ b/crates/openhuman-core/src/profiles/ops.rs@@ -6,8 +6,7 @@use super::credentials::{self, UserCredentialKind};use super::host::{self, ProfileHost};use super::types::{- CredentialResult, DeprovisionResult, ProfileId, ProfileSummary, ProvisionResult,- ReleaseResult,+ CredentialResult, DeprovisionResult, ProfileId, ProfileSummary, ProvisionResult, ReleaseResult,};use crate::core::Outcome;diff --git a/crates/openhuman-core/src/profiles/ops_tests.rs b/crates/openhuman-core/src/profiles/ops_tests.rsindex 0afd0f82d4..4766bffd29 100644--- a/crates/openhuman-core/src/profiles/ops_tests.rs+++ b/crates/openhuman-core/src/profiles/ops_tests.rs@@ -32,7 +32,8 @@ async fn status_and_deprovision_take_profile_ids_only() {assert!(deprovision_on(&host, "../operator").await.is_err());let id = ProfileId::for_user("alice", crate::profiles::ProfileIdMode::Raw).unwrap();- assert!(status_on(&host, id.as_str()).await+ assert!(status_on(&host, id.as_str())+ .await.unwrap_err().contains("not provisioned"));provision_on(&host, "alice").await.unwrap();diff --git a/crates/openhuman-core/src/profiles/registry.rs b/crates/openhuman-core/src/profiles/registry.rsindex 470b8ca96e..09d210af7a 100644--- a/crates/openhuman-core/src/profiles/registry.rs+++ b/crates/openhuman-core/src/profiles/registry.rs@@ -39,7 +39,10 @@ impl std::fmt::Debug for ProfileRegistry {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {match self {Self::Documents { .. } => f.write_str("ProfileRegistry::Documents"),- Self::Files { root } => f.debug_struct("ProfileRegistry::Files").field("root", root).finish(),+ Self::Files { root } => f+ .debug_struct("ProfileRegistry::Files")+ .field("root", root)+ .finish(),}}}@@ -116,7 +119,8 @@ impl ProfileRegistry {pub async fn create(&self, meta: &ProfileMeta) -> Result<bool, String> {let id = &meta.profile_id;if let Some(docs) = self.docs().await? {- let doc = serde_json::to_value(meta).map_err(|e| format!("encoding profile {id}: {e}"))?;+ let doc =+ serde_json::to_value(meta).map_err(|e| format!("encoding profile {id}: {e}"))?;return match docs.put(REGISTRY_COLLECTION, id.as_str(), doc, Precondition::Absent).awaitdiff --git a/crates/openhuman-core/src/profiles/schemas.rs b/crates/openhuman-core/src/profiles/schemas.rsindex a3b7184dcc..caef204cb7 100644--- a/crates/openhuman-core/src/profiles/schemas.rs+++ b/crates/openhuman-core/src/profiles/schemas.rs@@ -216,13 +216,15 @@ fn handle_status(params: Map<String, Value>) -> ControllerFuture {fn handle_set_credential(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let payload = deserialize_params::<CredentialParams>(params)?;- to_json(super::ops::set_credential(- &payload.profile_id,- payload.kind,- &payload.token,- payload.expires_at.as_deref(),+ to_json(+ super::ops::set_credential(+ &payload.profile_id,+ payload.kind,+ &payload.token,+ payload.expires_at.as_deref(),+ )+ .await?,)- .await?)})}diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rsindex 1bcc8a0e41..3cbca07b5b 100644--- a/crates/openhuman-core/src/web_chat/mod.rs+++ b/crates/openhuman-core/src/web_chat/mod.rs@@ -76,15 +76,15 @@ pub use event_bus::fresh_approval_surface_subscription;pub use ops::drain_queued_turns_for_test;#[cfg(any(test, debug_assertions))]pub use ops::parallel_in_flight_entries_for_test;+#[cfg(test)]+pub(crate) use ops::track_parallel_turn_for_test;pub use ops::{- cancel_all_turns, cancel_chat, cancel_chat_scoped, cancel_should_target, channel_web_cancel, channel_web_chat,- channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,+ cancel_all_turns, cancel_chat, cancel_chat_scoped, cancel_should_target, channel_web_cancel,+ channel_web_chat, channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,in_flight_entries_for_test, invalidate_thread_sessions, run_system_turn_on_thread, start_chat,StartChatError, SESSION_CHECKOUT_FAILURE, SYSTEM_CLIENT_ID,};pub use types::ChatRequestMetadata;-#[cfg(test)]-pub(crate) use ops::track_parallel_turn_for_test;// Public API — schemas / controllerspub use schemas::{diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rsindex 5477e6e4c4..10464d19ec 100644--- a/crates/openhuman-core/src/web_chat/ops.rs+++ b/crates/openhuman-core/src/web_chat/ops.rs@@ -19,8 +19,8 @@ pub(super) use budget_correlation::{};pub use channel_ops::{- cancel_all_turns, cancel_chat, cancel_chat_scoped, channel_web_cancel, channel_web_chat, channel_web_queue_clear,- channel_web_queue_remove, channel_web_queue_status,+ cancel_all_turns, cancel_chat, cancel_chat_scoped, channel_web_cancel, channel_web_chat,+ channel_web_queue_clear, channel_web_queue_remove, channel_web_queue_status,};pub use start_chat::{start_chat, StartChatError};@@ -34,9 +34,9 @@ pub(crate) use state::in_flight;pub use state::parallel_in_flight_entries_for_test;#[cfg(test)]pub(crate) use state::scoped_key;+pub(super) use state::thread_sessions;#[cfg(test)]pub(crate) use state::track_parallel_turn_for_test;-pub(super) use state::thread_sessions;pub use state::{cancel_should_target, in_flight_entries_for_test, invalidate_thread_sessions};pub(crate) use state::{event_session_id_for, key_for};#[cfg(test)]diff --git a/crates/openhuman-rpc/src/server/saas_gateway.rs b/crates/openhuman-rpc/src/server/saas_gateway.rsindex 37f3e0e110..505f714809 100644--- a/crates/openhuman-rpc/src/server/saas_gateway.rs+++ b/crates/openhuman-rpc/src/server/saas_gateway.rs@@ -25,8 +25,7 @@ use std::time::{SystemTime, UNIX_EPOCH};use crate::core_host::core::runtime::CoreContext;use crate::core_host::profiles::gateway::{- resolve_scope, GatewayRefusal, GatewayScope, PROFILE_OWNER_HEADER, USER_HEADER,- USER_SIG_HEADER,+ resolve_scope, GatewayRefusal, GatewayScope, PROFILE_OWNER_HEADER, USER_HEADER, USER_SIG_HEADER,};use axum::extract::Request;use axum::http::{header, StatusCode};diff --git a/crates/openhuman-rpc/src/server/shims.rs b/crates/openhuman-rpc/src/server/shims.rsindex e6544db078..aeb5c1b605 100644--- a/crates/openhuman-rpc/src/server/shims.rs+++ b/crates/openhuman-rpc/src/server/shims.rs@@ -80,7 +80,11 @@ pub async fn run_server_saas(let storage_url = config.resolved_storage_url();log::info!("[rpc:saas] session store: {}",- if storage_url.is_some() { "storage backend" } else { "on-disk" }+ if storage_url.is_some() {+ "storage backend"+ } else {+ "on-disk"+ });crate::session_store::install_for_saas(storage_url).await?;let runtime =diff --git a/tests/saas_mode/cluster.rs b/tests/saas_mode/cluster.rsindex 764edd37dd..e43769de97 100644--- a/tests/saas_mode/cluster.rs+++ b/tests/saas_mode/cluster.rs@@ -134,7 +134,11 @@ fn start_node(node.log_tail());}- assert!(Instant::now() < deadline, "core {} never became healthy", name);+ assert!(+ Instant::now() < deadline,+ "core {} never became healthy",+ name+ );std::thread::sleep(Duration::from_millis(250));}node@@ -240,7 +244,8 @@ fn turn_state(node: &Node, user: &str, thread: &str) -> Option<String> {/// both cores (cluster leases), or `None` (file locks on the shared root).fn one_core_at_a_time(storage_url: Option<&str>) {let d = deployment(true);- let storage_url = storage_url.map(|url| url.replace("{tmp}", &d.tmp.path().display().to_string()));+ let storage_url =+ storage_url.map(|url| url.replace("{tmp}", &d.tmp.path().display().to_string()));let backend = hanging_backend();let one = start_node(&d, "1", storage_url.as_deref(), "", Some(backend));let mut two = start_node(&d, "2", storage_url.as_deref(), "", Some(backend));@@ -256,7 +261,10 @@ fn one_core_at_a_time(storage_url: Option<&str>) {assert_eq!(body["owner"], "core-1");if storage_url.is_some() {assert_eq!(body["endpoint"], one.base.as_str(), "{body}");- assert!(body["retry_after_ms"].as_u64().is_some_and(|ms| ms > 0), "{body}");+ assert!(+ body["retry_after_ms"].as_u64().is_some_and(|ms| ms > 0),+ "{body}"+ );}// An operator release on core 1 hands alice over at once.@@ -267,7 +275,10 @@ fn one_core_at_a_time(storage_url: Option<&str>) {);assert!(body.to_string().contains("\"released\":true"), "{body}");let (status, _, body) = call(&two, "alice", "core.ping", json!({}));- assert_eq!(status, 200, "core 2 hosts alice right after the release: {body}");+ assert_eq!(+ status, 200,+ "core 2 hosts alice right after the release: {body}"+ );let (status, owner, _) = call(&one, "alice", "core.ping", json!({}));assert_eq!((status, owner.as_deref()), (409, Some("core-2")));@@ -281,9 +292,12 @@ fn one_core_at_a_time(storage_url: Option<&str>) {assert!(body.get("result").is_some(), "{body}");start_turn(&two, "alice", "t-kill");// In flight, and far enough that its snapshot is on disk.- wait_until("alice's turn in flight on core 2", &two, Duration::from_secs(90), || {- active(&two, "alice", "t-kill") && turn_state(&two, "alice", "t-kill").is_some()- });+ wait_until(+ "alice's turn in flight on core 2",+ &two,+ Duration::from_secs(90),+ || active(&two, "alice", "t-kill") && turn_state(&two, "alice", "t-kill").is_some(),+ );let live = turn_state(&two, "alice", "t-kill");assert!(matches!(live.as_deref(), Some("started" | "streaming")),@@ -293,9 +307,12 @@ fn one_core_at_a_time(storage_url: Option<&str>) {// Core 1 takes alice over once the lease lapses (at once for a file// lock, which dies with its process), and the turn reads interrupted.- wait_until("core 1 to take alice over", &one, Duration::from_secs(30), || {- call(&one, "alice", "core.ping", json!({})).0 == 200- });+ wait_until(+ "core 1 to take alice over",+ &one,+ Duration::from_secs(30),+ || call(&one, "alice", "core.ping", json!({})).0 == 200,+ );assert_eq!(turn_state(&one, "alice", "t-kill").as_deref(),Some("interrupted"),@@ -335,9 +352,12 @@ fn a_profile_in_use_is_not_evicted_mid_turn() {// Alice's request returns at once; her turn keeps running.start_turn(&node, "alice", "t1");- wait_until("alice's turn in flight", &node, Duration::from_secs(60), || {- active(&node, "alice", "t1")- });+ wait_until(+ "alice's turn in flight",+ &node,+ Duration::from_secs(60),+ || active(&node, "alice", "t1"),+ );// The only slot is busy with a live turn, though no request holds it.let (status, _, body) = call(&node, "bob", "core.ping", json!({}));@@ -353,9 +373,12 @@ fn a_profile_in_use_is_not_evicted_mid_turn() {assert!(body.to_string().contains("\"cancelled\":true"), "{body}");// Once the turn is gone alice is idle, and bob gets the slot.- wait_until("bob to get the slot", &node, Duration::from_secs(30), || {- call(&node, "bob", "core.ping", json!({})).0 == 200- });+ wait_until(+ "bob to get the slot",+ &node,+ Duration::from_secs(30),+ || call(&node, "bob", "core.ping", json!({})).0 == 200,+ );}#[test]@@ -372,9 +395,12 @@ fn two_users_with_the_same_thread_id_stay_apart() {let b = s.spawn(|| start_turn(&node, "bob", "t1"));(a.join().unwrap(), b.join().unwrap())});- wait_until("both turns in flight", &node, Duration::from_secs(60), || {- active(&node, "alice", "t1") && active(&node, "bob", "t1")- });+ wait_until(+ "both turns in flight",+ &node,+ Duration::from_secs(60),+ || active(&node, "alice", "t1") && active(&node, "bob", "t1"),+ );let request_id = |body: &Value| {find_key(body, "request_id").and_then(Value::as_str)@@ -412,7 +438,6 @@ fn two_users_with_the_same_thread_id_stay_apart() {);}-/// The first value under `key` anywhere in `value`.fn find_key<'a>(value: &'a Value, key: &str) -> Option<&'a Value> {match value {