Skip to content

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

refactor(tests): use imported DispatchCtx in subagent tenant tests

Steven Enamakeldc6f0a1c3567
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
index 8cbf26c3bd..d61a7a81a2 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs
@@ -61,7 +61,7 @@ impl Worker {
let task_handle = tokio::spawn(std::future::pending::<()>());
let abort = task_handle.abort_handle();
register(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &DispatchCtx::ambient(),
task.clone(),
"researcher".into(),
PARENT.into(),
@@ -228,12 +228,7 @@ async fn saas_dispatch_exposes_only_the_callers_detached_worker_controls() {
})
.await;
CoreContext::scope(pair.alice.clone(), async {
- assert!(resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- )
- .is_ok());
+ assert!(resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok());
})
.await;
for function in ["steer", "cancel"] {
@@ -328,7 +323,7 @@ async fn unscoped_async_spawn_refuses_before_persisting_a_running_session() {
sessions.is_empty(),
"refused spawn must not create durable sessions: {sessions:?}"
);
- assert!(snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty());
+ assert!(snapshot_for_parent(&DispatchCtx::ambient(), PARENT).is_empty());
assert!(
std::fs::read_dir(workspace.path())
.unwrap()
@@ -346,7 +341,7 @@ async fn same_parent_rosters_are_profile_isolated() {
let pair = Pair::new();
for (ctx, own) in [(&pair.alice, &pair.a), (&pair.bob, &pair.b)] {
let tasks = CoreContext::sync_scope(ctx.clone(), || {
- snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT)
+ snapshot_for_parent(&DispatchCtx::ambient(), PARENT)
});
assert_eq!(
tasks.iter().map(|t| t.task_id.as_str()).collect::<Vec<_>>(),
@@ -366,24 +361,16 @@ async fn same_parent_resolution_and_wait_refuse_foreign_workers() {
let pair = Pair::new();
CoreContext::scope(pair.bob.clone(), async {
assert!(matches!(
- task_id_for_session(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.session,
- PARENT
- ),
+ task_id_for_session(&DispatchCtx::ambient(), &pair.a.session, PARENT),
Err(WaitError::NotOwned)
));
assert!(matches!(
- resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- ),
+ resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT),
Err(WaitError::NotOwned)
));
assert!(matches!(
wait(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &DispatchCtx::ambient(),
&pair.a.task,
PARENT,
Duration::ZERO
@@ -392,12 +379,7 @@ async fn same_parent_resolution_and_wait_refuse_foreign_workers() {
Err(WaitError::NotOwned)
));
assert_eq!(
- task_id_for_session(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.b.session,
- PARENT
- )
- .unwrap(),
+ task_id_for_session(&DispatchCtx::ambient(), &pair.b.session, PARENT).unwrap(),
pair.b.task
);
})
@@ -416,7 +398,7 @@ async fn same_parent_agent_steering_refuses_foreign_worker() {
CoreContext::scope(pair.bob.clone(), async {
assert_eq!(
steer(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &DispatchCtx::ambient(),
&pair.a.task,
PARENT,
"foreign".into(),
@@ -427,7 +409,7 @@ async fn same_parent_agent_steering_refuses_foreign_worker() {
);
assert_eq!(pair.a.queue.status().await.steers, 0);
steer(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &DispatchCtx::ambient(),
&pair.b.task,
PARENT,
"own".into(),
@@ -475,12 +457,7 @@ async fn public_cancellation_refuses_another_profiles_task() {
field(&control("cancel", &pair.a.task).await, "cancelled"),
Some(false)
);
- assert!(resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.b.task,
- PARENT
- )
- .is_ok());
+ assert!(resume_ref_for_task(&DispatchCtx::ambient(), &pair.b.task, PARENT).is_ok());
assert_eq!(
field(&control("cancel", &pair.b.task).await, "cancelled"),
Some(true)
@@ -489,12 +466,7 @@ async fn public_cancellation_refuses_another_profiles_task() {
.await;
CoreContext::scope(pair.alice.clone(), async {
assert!(
- resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- )
- .is_ok(),
+ resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok(),
"foreign cancel leaves original worker live"
);
})
@@ -511,18 +483,14 @@ async fn missing_saas_scope_cannot_observe_or_control_workers() {
}
let pair = Pair::new();
assert!(CoreContext::scoped().is_none());
- assert!(snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty());
+ assert!(snapshot_for_parent(&DispatchCtx::ambient(), PARENT).is_empty());
assert!(matches!(
- resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- ),
+ resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT),
Err(WaitError::NotOwned)
));
assert_eq!(
steer(
- &crate::core::runtime::DispatchCtx::ambient(),
+ &DispatchCtx::ambient(),
&pair.a.task,
PARENT,
"unscoped".into(),
@@ -541,24 +509,13 @@ async fn missing_saas_scope_cannot_observe_or_control_workers() {
);
assert_eq!(pair.a.queue.status().await.steers, 0);
CoreContext::sync_scope(pair.alice.clone(), || {
- assert!(resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- )
- .is_ok())
+ assert!(resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT).is_ok())
});
// A scoped kernel context without an admitted profile is not authority.
CoreContext::scope(CoreContext::for_test(DomainSet::full(), None), async {
- assert!(
- snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).is_empty()
- );
+ assert!(snapshot_for_parent(&DispatchCtx::ambient(), PARENT).is_empty());
assert!(matches!(
- resume_ref_for_task(
- &crate::core::runtime::DispatchCtx::ambient(),
- &pair.a.task,
- PARENT
- ),
+ resume_ref_for_task(&DispatchCtx::ambient(), &pair.a.task, PARENT),
Err(WaitError::NotOwned)
));
assert_eq!(
@@ -584,7 +541,7 @@ async fn desktop_public_controls_remain_available_without_parent_scope() {
let directory = tempfile::tempdir().unwrap();
let worker = Worker::register(directory.path());
assert_eq!(
- snapshot_for_parent(&crate::core::runtime::DispatchCtx::ambient(), PARENT).len(),
+ snapshot_for_parent(&DispatchCtx::ambient(), PARENT).len(),
1
);
assert_eq!(