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 user agent gateway code
Steven Enamakel861bd0a27075
diff --git a/crates/openhuman-core/src/user_agents/credentials_tests.rs b/crates/openhuman-core/src/user_agents/credentials_tests.rsindex 1e446914ea..54086994ea 100644--- a/crates/openhuman-core/src/user_agents/credentials_tests.rs+++ b/crates/openhuman-core/src/user_agents/credentials_tests.rs@@ -1,5 +1,7 @@use super::*;-use crate::security::credentials::session_support::{resolve_backend_credential, BackendCredential};+use crate::security::credentials::session_support::{+ resolve_backend_credential, BackendCredential,+};use crate::user_agents::layout::{agent_config, UserAgentLayout};use crate::user_agents::UserAgentId;diff --git a/crates/openhuman-core/src/user_agents/gateway.rs b/crates/openhuman-core/src/user_agents/gateway.rsindex 3ba8bd1c0d..bc62c49e12 100644--- a/crates/openhuman-core/src/user_agents/gateway.rs+++ b/crates/openhuman-core/src/user_agents/gateway.rs@@ -107,13 +107,11 @@ pub fn resolve_scope(let Some(user_id) = user_id else {return Ok(GatewayScope::Operator);};- let host = host::host()- .ok_or_else(|| GatewayRefusal::new(503, "this core serves no users"))?;+ let host = host::host().ok_or_else(|| GatewayRefusal::new(503, "this core serves no users"))?;let agent = UserAgentId::for_user(user_id).map_err(|e| GatewayRefusal::new(400, e))?;if host.saas().require_user_signature {- let signature = signature.ok_or_else(|| {- GatewayRefusal::new(401, format!("missing {USER_SIG_HEADER}"))- })?;+ let signature = signature+ .ok_or_else(|| GatewayRefusal::new(401, format!("missing {USER_SIG_HEADER}")))?;verify(secret, user_id, signature, now).map_err(|e| {log::warn!("[user_agents][gateway] refused agent={agent}: {e}");GatewayRefusal::new(401, e)diff --git a/crates/openhuman-core/src/user_agents/gateway_tests.rs b/crates/openhuman-core/src/user_agents/gateway_tests.rsindex 6fb9e09453..aeb3730288 100644--- a/crates/openhuman-core/src/user_agents/gateway_tests.rs+++ b/crates/openhuman-core/src/user_agents/gateway_tests.rs@@ -14,8 +14,14 @@ fn a_fresh_signature_verifies() {#[test]fn a_signature_is_bound_to_the_user_the_secret_and_the_window() {let header = sign(SECRET, "alice", 1_000);- assert!(verify(SECRET, "bob", &header, 1_000).is_err(), "another user");- assert!(verify("other-secret", "alice", &header, 1_000).is_err(), "another secret");+ assert!(+ verify(SECRET, "bob", &header, 1_000).is_err(),+ "another user"+ );+ assert!(+ verify("other-secret", "alice", &header, 1_000).is_err(),+ "another secret"+ );let stale = verify(SECRET, "alice", &header, 1_000 + SIGNATURE_WINDOW_SECS + 1);assert!(stale.unwrap_err().contains("window"));}@@ -23,7 +29,10 @@ fn a_signature_is_bound_to_the_user_the_secret_and_the_window() {#[test]fn malformed_signatures_are_refused() {for header in ["", "v1=00", "t=1000", "t=abc,v1=00", "t=1000,v1=zz"] {- assert!(verify(SECRET, "alice", header, 1_000).is_err(), "{header:?}");+ assert!(+ verify(SECRET, "alice", header, 1_000).is_err(),+ "{header:?}"+ );}}@@ -33,7 +42,9 @@ fn a_tampered_tag_is_refused() {let mut tampered = header.clone();let last = tampered.pop().unwrap();tampered.push(if last == '0' { '1' } else { '0' });- assert!(verify(SECRET, "alice", &tampered, 1_000).unwrap_err().contains("does not match"));+ assert!(verify(SECRET, "alice", &tampered, 1_000)+ .unwrap_err()+ .contains("does not match"));}#[test]diff --git a/crates/openhuman-core/src/user_agents/ops.rs b/crates/openhuman-core/src/user_agents/ops.rsindex 407779d249..cc91288838 100644--- a/crates/openhuman-core/src/user_agents/ops.rs+++ b/crates/openhuman-core/src/user_agents/ops.rs@@ -3,8 +3,8 @@//! Gateway user ids are taken here and turned into agent ids at once; they//! are never logged, stored or returned.-use super::host::{self, AgentHost};use super::credentials::{self, UserCredentialKind};+use super::host::{self, AgentHost};use super::types::{CredentialResult, DeprovisionResult, ProvisionResult, UserAgentId, UserAgentSummary,};diff --git a/crates/openhuman-core/src/user_agents/ops_tests.rs b/crates/openhuman-core/src/user_agents/ops_tests.rsindex d62f1ac87e..ecee49b279 100644--- a/crates/openhuman-core/src/user_agents/ops_tests.rs+++ b/crates/openhuman-core/src/user_agents/ops_tests.rs@@ -47,11 +47,15 @@ fn credentials_are_set_and_cleared_per_agent_and_never_echoed() {let host = host(&tmp);let alice = UserAgentId::for_user("alice").unwrap();let bob = UserAgentId::for_user("bob").unwrap();- assert!(- set_credential_on(&host, alice.as_str(), UserCredentialKind::Session, "t", None)- .unwrap_err()- .contains("not provisioned")- );+ assert!(set_credential_on(+ &host,+ alice.as_str(),+ UserCredentialKind::Session,+ "t",+ None+ )+ .unwrap_err()+ .contains("not provisioned"));provision_on(&host, "alice").unwrap();provision_on(&host, "bob").unwrap();diff --git a/crates/openhuman-rpc/src/server/saas_gateway.rs b/crates/openhuman-rpc/src/server/saas_gateway.rsindex e46b503780..a2002a69be 100644--- a/crates/openhuman-rpc/src/server/saas_gateway.rs+++ b/crates/openhuman-rpc/src/server/saas_gateway.rs@@ -46,11 +46,7 @@ pub(crate) fn is_closed_in_saas(path: &str) -> bool {fn refuse(status: u16, message: &str) -> Response {let status = StatusCode::from_u16(status).unwrap_or(StatusCode::FORBIDDEN);- (- status,- axum::Json(serde_json::json!({ "error": message })),- )- .into_response()+ (status, axum::Json(serde_json::json!({ "error": message }))).into_response()}fn header_str<'a>(req: &'a Request, name: &str) -> Option<&'a str> {@@ -64,11 +60,7 @@ fn bearer(req: &Request) -> Option<&str> {}/// The SaaS request layer; `operator` is the runtime's own context.-pub(crate) async fn saas_gateway(- operator: Arc<CoreContext>,- req: Request,- next: Next,-) -> Response {+pub(crate) async fn saas_gateway(operator: Arc<CoreContext>, req: Request, next: Next) -> Response {let path = req.uri().path();if is_closed_in_saas(path) {log::debug!("[rpc:saas] {path} is not served in SaaS mode");diff --git a/tests/saas_mode_e2e.rs b/tests/saas_mode_e2e.rsindex 8b82d2d9f1..62c4d2207d 100644--- a/tests/saas_mode_e2e.rs+++ b/tests/saas_mode_e2e.rs@@ -337,7 +337,10 @@ fn gateway_requests_run_under_the_named_users_agent() {"openhuman.user_agents_status",json!({ "agent_id": alice.as_str() }),);- assert!(body.to_string().contains("\"has_credential\":true"), "{body}");+ assert!(+ body.to_string().contains("\"has_credential\":true"),+ "{body}"+ );// A signed request for alice runs under her agent.let (status, body) = user_rpc(&client, &base, BEARER, "alice", None, "core.ping");@@ -353,15 +356,27 @@ fn gateway_requests_run_under_the_named_users_agent() {None,"openhuman.user_agents_list",);- assert!(body.get("error").is_some(), "operator methods are not a user's: {body}");+ assert!(+ body.get("error").is_some(),+ "operator methods are not a user's: {body}"+ );// Refusals: bad bearer first, then signatures, then provisioning.let (status, body) = user_rpc(&client, &base, "wrong-bearer", "alice", None, "core.ping");assert_eq!(status, 401, "{body}");let (status, body) = user_rpc(&client, &base, "wrong-bearer", "bob", None, "core.ping");- assert_eq!(status, 401, "an unauthenticated caller cannot probe users: {body}");- let (status, body) =- user_rpc(&client, &base, BEARER, "alice", Some("t=1,v1=00"), "core.ping");+ assert_eq!(+ status, 401,+ "an unauthenticated caller cannot probe users: {body}"+ );+ let (status, body) = user_rpc(+ &client,+ &base,+ BEARER,+ "alice",+ Some("t=1,v1=00"),+ "core.ping",+ );assert_eq!(status, 401, "{body}");let forged = openhuman_core::user_agents::gateway::sign(BEARER, "alice", now());let (status, body) = user_rpc(&client, &base, BEARER, "bob", Some(&forged), "core.ping");