Skip to content

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

style: reformat long lines in cost scope tests

Steven Enamakel69499afb1289
diff --git a/crates/openhuman-core/src/platform/cost/scope_tests.rs b/crates/openhuman-core/src/platform/cost/scope_tests.rs
index a896cf8362..1d359bbeca 100644
--- a/crates/openhuman-core/src/platform/cost/scope_tests.rs
+++ b/crates/openhuman-core/src/platform/cost/scope_tests.rs
@@ -70,8 +70,12 @@ async fn ambient_scope_reads_the_turn_and_prefers_the_subagent() {
(
UsageScope::in_ctx(&DispatchCtx::ambient(), Some("openhuman"), None)
.with_definition(Some("orchestrator")),
- UsageScope::in_ctx(&DispatchCtx::ambient(), Some("openhuman"), Some(("researcher", "task-1")))
- .with_definition(Some("orchestrator")),
+ UsageScope::in_ctx(
+ &DispatchCtx::ambient(),
+ Some("openhuman"),
+ Some(("researcher", "task-1")),
+ )
+ .with_definition(Some("orchestrator")),
)
}
.await
@@ -95,7 +99,8 @@ fn outside_any_turn_and_without_a_provider_the_scope_is_empty() {
#[tokio::test]
async fn the_explicit_context_names_the_session_agent_not_the_ambient_one() {
- let root = crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);
+ let root =
+ crate::core::runtime::CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);
let alice = crate::core::runtime::agent_scope::test_agent_context(&root, "alice");
let bob = crate::core::runtime::agent_scope::test_agent_context(&root, "bob");
let alice_ctx = DispatchCtx::new(alice.clone());
diff --git a/crates/openhuman-core/src/security/approval/store_agent.rs b/crates/openhuman-core/src/security/approval/store_agent.rs
index e08b6ff868..cd6e3f49ad 100644
--- a/crates/openhuman-core/src/security/approval/store_agent.rs
+++ b/crates/openhuman-core/src/security/approval/store_agent.rs
@@ -51,3 +51,7 @@ fn acts_for_a_profile(ctx: &DispatchCtx) -> bool {
pub fn pending_agent(config: &Config, request_id: &str) -> Result<Option<Option<String>>> {
super::super::store_documents::current(config)?.pending_agent(request_id)
}
+
+#[cfg(test)]
+#[path = "store_agent_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/security/approval/store_agent_tests.rs b/crates/openhuman-core/src/security/approval/store_agent_tests.rs
new file mode 100644
index 0000000000..7313b0c2e5
--- /dev/null
+++ b/crates/openhuman-core/src/security/approval/store_agent_tests.rs
@@ -0,0 +1,43 @@
+use super::*;
+
+use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
+use crate::tools::toolpacks::ToolGroups;
+
+fn profile_ctx(root: &std::sync::Arc<CoreContext>, profile: &str) -> DispatchCtx {
+ DispatchCtx::new(
+ root.derive_with(
+ ContextOverlay::new(
+ crate::config::Config::default(),
+ DomainSet::kernel(),
+ ToolGroups::none(),
+ )
+ .profile(profile),
+ ),
+ )
+}
+
+#[tokio::test]
+async fn the_explicit_context_decides_whether_the_caller_acts_for_a_profile() {
+ let root = CoreContext::for_test(DomainSet::full(), None);
+ let profile = profile_ctx(&root, "u-alice");
+ let plain = DispatchCtx::new(root.clone());
+
+ // Each answer holds while the task is ambient under the other tenant,
+ // across an await and in a spawned task.
+ let for_profile = tokio::spawn(CoreContext::scope(root.clone(), {
+ let profile = profile.clone();
+ async move {
+ tokio::task::yield_now().await;
+ acts_for_a_profile(&profile)
+ }
+ }));
+ let for_plain = tokio::spawn(CoreContext::scope(
+ profile.core().unwrap().clone(),
+ async move {
+ tokio::task::yield_now().await;
+ acts_for_a_profile(&plain)
+ },
+ ));
+ assert!(for_profile.await.unwrap());
+ assert!(!for_plain.await.unwrap());
+}