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
chore: files changed crates/openhuman-core/src/cron/ops_delivery_tests.rs
Steven Enamakele9d01623bd51
diff --git a/crates/openhuman-core/src/cron/ops_delivery_tests.rs b/crates/openhuman-core/src/cron/ops_delivery_tests.rsindex 9d4a3ca970..f4ead580df 100644--- a/crates/openhuman-core/src/cron/ops_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/ops_delivery_tests.rs@@ -148,3 +148,95 @@ async fn run_job_now_pairs_trigger_and_completion_after_delivery() {let runs = cron::list_runs(&config, &job.id, 10).unwrap();assert_eq!(runs[0].delivery_status, Some(DeliveryStatus::NotRequested));}++#[tokio::test]+async fn completion_events_keep_their_agent_owner_on_repeated_reads() {+ use crate::core::events::DomainEvent;+ use tinybus::EventHandler;++ struct Completions(mpsc::UnboundedSender<DomainEvent>);+ #[async_trait]+ impl EventHandler<DomainEvent> for Completions {+ fn name(&self) -> &str {+ "test::cron::completion_owner_is_event_data"+ }++ async fn handle(&self, event: &DomainEvent) {+ if matches!(event, DomainEvent::CronJobCompleted { job_id, .. } if job_id == "shared-completion-id") {+ let _ = self.0.send(event.clone());+ }+ }+ }++ crate::core::bus::init().await.unwrap();+ let (tx, mut rx) = mpsc::unbounded_channel();+ let _subscription = crate::core::bus::BUS+ .subscribe(Arc::new(Completions(tx)))+ .unwrap();++ let context_for = |agent: &str| {+ crate::core::runtime::CoreContext::for_test(+ crate::core::runtime::DomainSet::full(),+ None,+ )+ .derive_with(+ crate::core::runtime::ContextOverlay::new(+ crate::config::Config::default(),+ crate::core::runtime::DomainSet::full(),+ Default::default(),+ )+ .session_agent(agent),+ )+ };+ let job = cron::CronJob {+ id: "shared-completion-id".into(),+ ..tests::single_flight_system_job(+ &tests::test_config(&TempDir::new().unwrap()),+ "completion-owner-test",+ )+ };++ crate::cron::scheduler::run_delivery::publish_completion(+ &crate::core::runtime::DispatchCtx::new(context_for("completion-owner-a")),+ &job,+ true,+ "done",+ );+ crate::cron::scheduler::run_delivery::publish_completion(+ &crate::core::runtime::DispatchCtx::new(context_for("completion-owner-b")),+ &job,+ true,+ "done",+ );++ let events = tokio::time::timeout(std::time::Duration::from_secs(2), async {+ let mut events = Vec::new();+ while events.len() < 2 {+ events.push(rx.recv().await.expect("completion subscriber remains open"));+ }+ events+ })+ .await+ .expect("both completion events arrive");+ let owners = futures::future::join_all(events.iter().map(|event| {+ event_owner(+ &crate::core::runtime::DispatchCtx::host_default(),+ &crate::config::Config::default(),+ event,+ )+ }))+ .await;++ assert_eq!(owners[0], Ok(Some("completion-owner-a".into())));+ assert_eq!(owners[1], Ok(Some("completion-owner-b".into())));+ assert_eq!(+ event_owner(+ &crate::core::runtime::DispatchCtx::host_default(),+ &crate::config::Config::default(),+ &events[0],+ )+ .await,+ Ok(Some("completion-owner-a".into())),+ "reading an event repeatedly must not consume or change its owner"+ );+}