Skip to content

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

style: apply rustfmt formatting to session store and approval tests

Steven Enamakel28056767c89c
diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rs
index 75d2a3922a..24cc424e7c 100644
--- a/crates/openhuman-core/src/agent/session_store/mod.rs
+++ b/crates/openhuman-core/src/agent/session_store/mod.rs
@@ -138,18 +138,14 @@ pub fn transcripts_or_files(
agent_id: &str,
workspace_dir: &std::path::Path,
) -> Arc<dyn tinyagents_session::transcript::TranscriptLocator> {
- transcripts_for(agent_id).unwrap_or_else(|| {
- match current_embedded_agent() {
- Some(embedded) => {
- log::debug!(
- "[session_store] transcripts under the agent's directory agent={embedded}"
- );
- Arc::new(AgentTranscriptFiles::new(workspace_dir, &embedded))
- }
- None => Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(
- workspace_dir,
- )),
+ transcripts_for(agent_id).unwrap_or_else(|| match current_embedded_agent() {
+ Some(embedded) => {
+ log::debug!("[session_store] transcripts under the agent's directory agent={embedded}");
+ Arc::new(AgentTranscriptFiles::new(workspace_dir, &embedded))
}
+ None => Arc::new(tinyagents_session::transcript::FileTranscriptLocator::new(
+ workspace_dir,
+ )),
})
}
diff --git a/crates/openhuman-core/src/agent/session_store/mod_tests.rs b/crates/openhuman-core/src/agent/session_store/mod_tests.rs
index a01a811a7e..da3aeaafff 100644
--- a/crates/openhuman-core/src/agent/session_store/mod_tests.rs
+++ b/crates/openhuman-core/src/agent/session_store/mod_tests.rs
@@ -72,10 +72,7 @@ async fn without_a_store_transcripts_are_workspace_files() {
assert_eq!(found, expected);
}
-fn derived(
- profile: Option<&str>,
- agent: Option<&str>,
-) -> Arc<crate::core::runtime::CoreContext> {
+fn derived(profile: Option<&str>, agent: Option<&str>) -> Arc<crate::core::runtime::CoreContext> {
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
let mut overlay = ContextOverlay::new(
crate::config::Config::default(),
@@ -91,10 +88,7 @@ fn derived(
CoreContext::for_test(DomainSet::full(), None).derive_with(overlay)
}
-async fn under<T>(
- ctx: Arc<crate::core::runtime::CoreContext>,
- f: impl FnOnce() -> T,
-) -> T {
+async fn under<T>(ctx: Arc<crate::core::runtime::CoreContext>, f: impl FnOnce() -> T) -> T {
crate::core::runtime::CoreContext::scope(ctx, async move { f() }).await
}
@@ -141,6 +135,11 @@ async fn two_profiles_default_agents_keep_separate_session_keys_and_stores() {
assert_ne!(alice, bob);
assert_eq!(
alice,
- Some(provider.for_agent("alice~default").transcripts.destination_key())
+ Some(
+ provider
+ .for_agent("alice~default")
+ .transcripts
+ .destination_key()
+ )
);
}
diff --git a/crates/openhuman-core/src/mcp/host_agent_tests.rs b/crates/openhuman-core/src/mcp/host_agent_tests.rs
index 686612e673..86e53cccba 100644
--- a/crates/openhuman-core/src/mcp/host_agent_tests.rs
+++ b/crates/openhuman-core/src/mcp/host_agent_tests.rs
@@ -97,8 +97,7 @@ async fn reading_an_agents_connections_does_not_create_its_host() {
/// own workspace, a profile id, and no agent id.
fn profile_context(config: &Config, profile: &str) -> Arc<CoreContext> {
CoreContext::for_test_with_config(DomainSet::full(), config.clone()).derive_with(
- ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::none())
- .profile(profile),
+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::none()).profile(profile),
)
}
@@ -133,7 +132,11 @@ async fn two_profiles_default_agents_get_their_own_hosts_and_never_the_default()
let ambient_alice =
CoreContext::scope(profile_context(&alice, "alice"), async { try_service() }).await;
- let ambient_bob = CoreContext::scope(profile_context(&bob, "bob"), async { try_service() }).await;
- assert!(Arc::ptr_eq(&ambient_alice.expect("alice's host"), &alice_host));
+ let ambient_bob =
+ CoreContext::scope(profile_context(&bob, "bob"), async { try_service() }).await;
+ assert!(Arc::ptr_eq(
+ &ambient_alice.expect("alice's host"),
+ &alice_host
+ ));
assert!(Arc::ptr_eq(&ambient_bob.expect("bob's host"), &bob_host));
}
diff --git a/crates/openhuman-core/src/security/approval/gate_tenant_tests.rs b/crates/openhuman-core/src/security/approval/gate_tenant_tests.rs
index a6e9c69d94..897e8cc6bd 100644
--- a/crates/openhuman-core/src/security/approval/gate_tenant_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_tenant_tests.rs
@@ -40,7 +40,10 @@ fn profile_route_keys_are_distinct_per_profile_and_from_the_desktop() {
let b = thread_route_key(&tenant(Some("bob"), None), "t-1");
assert_ne!(a, b);
assert_ne!(a, "t-1");
- assert_ne!(a, thread_route_key(&tenant(Some("alice"), Some("alice")), "t-1"));
+ assert_ne!(
+ a,
+ thread_route_key(&tenant(Some("alice"), Some("alice")), "t-1")
+ );
assert!(a.starts_with('\u{1e}'), "a profile key is marked: {a:?}");
}
@@ -88,7 +91,10 @@ async fn two_profiles_default_agents_park_on_one_thread_id_apart() {
let gate = Arc::clone(&gate);
CoreContext::scope(ctx, async move { gate.pending_for_thread("t-test") })
};
- assert_eq!(seen_by(Arc::clone(&alice)).await, Some(alice_request.clone()));
+ assert_eq!(
+ seen_by(Arc::clone(&alice)).await,
+ Some(alice_request.clone())
+ );
assert_eq!(seen_by(Arc::clone(&bob)).await, Some(bob_request.clone()));
// The process's own (unprofiled) route for the thread stays empty.
assert!(gate.pending_for_agent_thread(None, "t-test").is_none());
@@ -97,8 +103,17 @@ async fn two_profiles_default_agents_park_on_one_thread_id_apart() {
gate.decide(&bob_request, ApprovalDecision::Deny).unwrap();
let (alice_outcome, _) = alice_turn.await.unwrap();
let (bob_outcome, _) = bob_turn.await.unwrap();
- assert!(matches!(alice_outcome, GateOutcome::Deny { .. }), "{alice_outcome:?}");
- assert!(matches!(bob_outcome, GateOutcome::Deny { .. }), "{bob_outcome:?}");
- assert!(seen_by(alice).await.is_none(), "a decision clears the route");
+ assert!(
+ matches!(alice_outcome, GateOutcome::Deny { .. }),
+ "{alice_outcome:?}"
+ );
+ assert!(
+ matches!(bob_outcome, GateOutcome::Deny { .. }),
+ "{bob_outcome:?}"
+ );
+ assert!(
+ seen_by(alice).await.is_none(),
+ "a decision clears the route"
+ );
assert!(seen_by(bob).await.is_none());
}
diff --git a/crates/openhuman-core/src/security/approval/gate_tests.rs b/crates/openhuman-core/src/security/approval/gate_tests.rs
index 9ed13415a6..65828447e0 100644
--- a/crates/openhuman-core/src/security/approval/gate_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_tests.rs
@@ -206,9 +206,9 @@ mod core_flow_tests;
mod forced_tests;
#[path = "gate_origin_intercept_tests.rs"]
mod origin_intercept_tests;
+#[path = "gate_tenant_tests.rs"]
+mod tenant_tests;
#[path = "gate_triage_tests.rs"]
mod triage_tests;
#[path = "gate_ttl_and_triage_tests.rs"]
mod ttl_and_triage_tests;
-#[path = "gate_tenant_tests.rs"]
-mod tenant_tests;
diff --git a/crates/openhuman-core/src/skills/write_root_tests.rs b/crates/openhuman-core/src/skills/write_root_tests.rs
index 034f32d171..3f1d312de1 100644
--- a/crates/openhuman-core/src/skills/write_root_tests.rs
+++ b/crates/openhuman-core/src/skills/write_root_tests.rs
@@ -143,8 +143,12 @@ async fn two_profiles_default_agents_keep_their_skills_apart_from_each_other_and
let (alice_ws, home_for_create) = (one.path().to_path_buf(), home_path.clone());
CoreContext::scope(profile_on(one.path(), "alice"), async move {
- create_workflow_inner(Some(&home_for_create), &alice_ws, user_workflow("alice-only"))
- .expect("alice creates a workflow");
+ create_workflow_inner(
+ Some(&home_for_create),
+ &alice_ws,
+ user_workflow("alice-only"),
+ )
+ .expect("alice creates a workflow");
})
.await;
assert!(