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
test(core): cover explicit-context ownership without task scope
Steven Enamakel89229307e0ad
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rsindex 90dfe78db6..aeb30e745b 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tenant_tests.rs@@ -148,3 +148,40 @@ fn an_unknown_session_is_dropped_in_saas() {assert_eq!(drains.len(), 1);assert!(drains[0].owner.is_none());}++/// The busy marks follow the explicit context: with no scope anywhere, one+/// profile's in-flight turn defers only its own thread, and a Stop clears only+/// its own marks.+#[tokio::test]+async fn busy_marks_are_keyed_by_the_explicit_context() {+ use super::busy_guard::{clear_busy_for_thread, is_busy, TurnBusy};+ let _guard = crate::config::TEST_ENV_LOCK.lock().await;+ let (ws_a, ws_b) = (TestWorkspace::new(), TestWorkspace::new());+ let alice = DispatchCtx::new(profile(&unique("b-alice"), ws_a.path()));+ let bob = DispatchCtx::new(profile(&unique("b-bob"), ws_b.path()));+ let session = unique("busy-session");+ let thread = unique("busy-thread");+ note_session_thread(&alice, &session, &thread);+ note_session_thread(&bob, &session, &thread);++ let held = TurnBusy::start(&alice, &session);+ // Across an await and on a spawned task, nothing leans on a task scope.+ tokio::task::yield_now().await;+ let (a, b) = tokio::spawn({+ let (alice, bob, thread) = (alice.clone(), bob.clone(), thread.clone());+ async move { (is_busy(&alice, &thread), is_busy(&bob, &thread)) }+ })+ .await+ .expect("probe ran");+ assert!(a, "alice's turn is in flight on her thread");+ assert!(!b, "bob's thread of the same id is idle");++ assert_eq!(clear_busy_for_thread(&bob, &thread), 0);+ assert!(+ is_busy(&alice, &thread),+ "bob's Stop cleared nothing of hers"+ );+ assert_eq!(clear_busy_for_thread(&alice, &thread), 1);+ assert!(!is_busy(&alice, &thread));+ drop(held);+}diff --git a/crates/openhuman-core/src/cron/completion_owner_tests.rs b/crates/openhuman-core/src/cron/completion_owner_tests.rsindex 11fa9ca7eb..25744fe531 100644--- a/crates/openhuman-core/src/cron/completion_owner_tests.rs+++ b/crates/openhuman-core/src/cron/completion_owner_tests.rs@@ -33,3 +33,28 @@ fn a_job_completed_without_an_agent_is_not_noted() {);assert_eq!(take("completion-owner-local"), None);}++#[tokio::test]+async fn the_explicit_context_names_the_owner_with_no_task_scope() {+ let agent = CoreContext::for_test(DomainSet::full(), None).derive_with(+ ContextOverlay::new(+ crate::config::Config::default(),+ DomainSet::full(),+ Default::default(),+ )+ .session_agent("explicit-owner-agent"),+ );+ // Not inside `CoreContext::scope`: the explicit value alone decides, even+ // across an await and on a spawned task.+ let ctx = crate::core::runtime::DispatchCtx::new(agent);+ tokio::spawn(async move {+ tokio::task::yield_now().await;+ note(&ctx, "explicit-owner-job");+ })+ .await+ .expect("note task ran");+ assert_eq!(+ take("explicit-owner-job").as_deref(),+ Some("explicit-owner-agent")+ );+}