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(security): reformat owner device module
Steven Enamakel35a48fbaa18e
diff --git a/crates/openhuman-core/src/security/devices/owner.rs b/crates/openhuman-core/src/security/devices/owner.rsindex 559753e9b7..ed5f8952eb 100644--- a/crates/openhuman-core/src/security/devices/owner.rs+++ b/crates/openhuman-core/src/security/devices/owner.rs@@ -20,8 +20,7 @@ use super::types::PairingSession;/// Channels whose owner this process has resolved: `Some(agent)`, or `None`/// for `local`.-static OWNERS: LazyLock<Mutex<HashMap<String, Option<String>>>> =- LazyLock::new(Default::default);+static OWNERS: LazyLock<Mutex<HashMap<String, Option<String>>>> = LazyLock::new(Default::default);/// Records that `channel_id` belongs to `agent` (`None` = `local`).pub(super) fn remember(channel_id: &str, agent: Option<String>) {@@ -41,10 +40,7 @@ fn cached(channel_id: &str) -> Option<Option<String>> {/// The agent `channel_id` belongs to, resolved as described above. A channel/// no scope knows yet (a handshake still in flight) is `local`.-pub(super) async fn owner_of(- channel_id: &str,- pending: Option<&PairingSession>,-) -> Option<String> {+pub(super) async fn owner_of(channel_id: &str, pending: Option<&PairingSession>) -> Option<String> {if let Some(session) = pending {return session.agent.clone();}diff --git a/crates/openhuman-core/src/security/devices/owner_tests.rs b/crates/openhuman-core/src/security/devices/owner_tests.rsnew file mode 100644index 0000000000..c756f226f1--- /dev/null+++ b/crates/openhuman-core/src/security/devices/owner_tests.rs@@ -0,0 +1,44 @@+use super::*;++fn session(agent: Option<&str>) -> PairingSession {+ PairingSession {+ channel_id: "owner-test".to_string(),+ pairing_token: "token".to_string(),+ core_pubkey: "pk".to_string(),+ rpc_url: None,+ expires_at: "2099-01-01T00:00:00Z".to_string(),+ agent: agent.map(str::to_string),+ }+}++#[tokio::test]+async fn a_pending_pairing_names_its_agent() {+ let pending = session(Some("agent-7"));+ assert_eq!(+ owner_of("owner-test-pending", Some(&pending))+ .await+ .as_deref(),+ Some("agent-7")+ );+ let local = session(None);+ assert_eq!(owner_of("owner-test-pending", Some(&local)).await, None);+}++#[tokio::test]+async fn a_remembered_owner_is_used_without_a_lookup() {+ remember("owner-test-cached", Some("agent-9".to_string()));+ assert_eq!(+ owner_of("owner-test-cached", None).await.as_deref(),+ Some("agent-9")+ );+ remember("owner-test-local", None);+ assert_eq!(owner_of("owner-test-local", None).await, None);+}++#[test]+fn the_agent_is_not_sent_over_the_wire_when_absent() {+ let json = serde_json::to_value(session(None)).unwrap();+ assert!(json.get("agent").is_none());+ let json = serde_json::to_value(session(Some("a"))).unwrap();+ assert_eq!(json["agent"], "a");+}