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,crates/openhuman-core/src/
Steven Enamakela15fc568aefe
diff --git a/crates/openhuman-core/src/cron/ops_delivery_tests.rs b/crates/openhuman-core/src/cron/ops_delivery_tests.rsindex 2ec8c1387e..21091be66b 100644--- a/crates/openhuman-core/src/cron/ops_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/ops_delivery_tests.rs@@ -87,3 +87,58 @@ async fn run_job_now_keeps_best_effort_failure_successful_and_records_failed_delassert_eq!(runs[0].status, "ok");assert_eq!(runs[0].delivery_status, Some(DeliveryStatus::Failed));}++#[tokio::test]+async fn run_job_now_pairs_trigger_and_completion_after_delivery() {+ use crate::core::events::DomainEvent;+ use tinybus::EventHandler;++ struct Events(String, mpsc::UnboundedSender<&'static str>);+ #[async_trait]+ impl EventHandler<DomainEvent> for Events {+ fn name(&self) -> &str { "test::cron::run_now_event_pair" }+ async fn handle(&self, event: &DomainEvent) {+ let (job_id, label) = match event {+ DomainEvent::CronJobTriggered { job_id, .. } => (job_id, "triggered"),+ DomainEvent::CronJobCompleted { job_id, .. } => (job_id, "completed"),+ _ => return,+ };+ if job_id == &self.0 { let _ = self.1.send(label); }+ }+ }++ crate::core::bus::init().await.unwrap();+ let tmp = TempDir::new().unwrap();+ let config = tests::test_config(&tmp);+ let name = "ops-run-now-event-pair";+ let _handler = crate::cron::system_job_handlers::register(+ name,+ Arc::new(|_| Box::pin(async { Ok(()) })),+ );+ let job = tests::single_flight_system_job(&config, name);+ let (tx, mut rx) = mpsc::unbounded_channel();+ let _subscription = crate::core::bus::BUS+ .subscribe(Arc::new(Events(job.id.clone(), tx)))+ .unwrap();++ let (success, _) = run_job_now(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job.id,+ )+ .await+ .unwrap();+ assert!(success);+ let pair = tokio::time::timeout(std::time::Duration::from_secs(2), async {+ let mut seen = Vec::new();+ loop {+ let event = rx.recv().await.expect("cron event subscriber remains open");+ seen.push(event);+ if event == "completed" { break; }+ }+ seen+ }).await.expect("Run Now completion event arrives");+ assert_eq!(pair, vec!["triggered", "completed"]);+ let runs = cron::list_runs(&config, &job.id, 10).unwrap();+ assert_eq!(runs[0].delivery_status, Some(DeliveryStatus::NotRequested));+}diff --git a/crates/openhuman-core/src/cron/tools/run_tests.rs b/crates/openhuman-core/src/cron/tools/run_tests.rsindex 93b80ab71a..efa23ad593 100644--- a/crates/openhuman-core/src/cron/tools/run_tests.rs+++ b/crates/openhuman-core/src/cron/tools/run_tests.rs@@ -77,6 +77,62 @@ async fn errors_for_missing_job() {assert!(result.output().contains("not found"));}+#[tokio::test]+async fn cron_run_tool_pairs_start_and_completion_without_requesting_delivery() {+ use crate::core::events::DomainEvent;+ use tinybus::EventHandler;+ use tokio::sync::mpsc;++ struct Events(String, mpsc::UnboundedSender<&'static str>);+ #[async_trait::async_trait]+ impl EventHandler<DomainEvent> for Events {+ fn name(&self) -> &str { "test::cron::run_tool_event_pair" }+ async fn handle(&self, event: &DomainEvent) {+ let (job_id, label) = match event {+ DomainEvent::CronJobTriggered { job_id, .. } => (job_id, "triggered"),+ DomainEvent::CronJobCompleted { job_id, .. } => (job_id, "completed"),+ _ => return,+ };+ if job_id == &self.0 { let _ = self.1.send(label); }+ }+ }++ crate::core::bus::init().await.unwrap();+ let tmp = TempDir::new().unwrap();+ let cfg = test_config(&tmp).await;+ let job = crate::cron::system_jobs::ensure_system_job(+ &cfg,+ "cron-run-tool-event-pair",+ tinyflows_bus::schedule::types::Schedule::Every { every_ms: 3_600_000 },+ ).unwrap();+ let _handler = crate::cron::system_job_handlers::register(+ "cron-run-tool-event-pair",+ Arc::new(|_| Box::pin(async { Ok(()) })),+ );+ let (tx, mut rx) = mpsc::unbounded_channel();+ let _subscription = crate::core::bus::BUS+ .subscribe(Arc::new(Events(job.id.clone(), tx)))+ .unwrap();++ let result = CronRunTool::new(cfg.clone())+ .execute(json!({ "job_id": job.id }))+ .await+ .unwrap();+ assert!(!result.is_error, "{}", result.output());+ let pair = tokio::time::timeout(std::time::Duration::from_secs(2), async {+ let mut seen = Vec::new();+ loop {+ let event = rx.recv().await.expect("cron event subscriber remains open");+ seen.push(event);+ if event == "completed" { break; }+ }+ seen+ }).await.expect("cron_run completion event arrives");+ assert_eq!(pair, vec!["triggered", "completed"]);+ let runs = cron::list_runs(&cfg, &job.id, 10).unwrap();+ assert_eq!(runs[0].delivery_status, Some(cron::DeliveryStatus::NotRequested));+}+// ── GHSA-f46p-6vf9-64mm: approval gate must fire for cron_run ────#[test]