Skip to content

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

test(cron): cover per-scope scheduler slot and updated callback signatures

Steven Enamakel95294df4f5a9
diff --git a/crates/openhuman-core/src/cron/bus_host_tests.rs b/crates/openhuman-core/src/cron/bus_host_tests.rs
index 1183cc1670..4818f0ea88 100644
--- a/crates/openhuman-core/src/cron/bus_host_tests.rs
+++ b/crates/openhuman-core/src/cron/bus_host_tests.rs
@@ -208,6 +208,7 @@ async fn deliver_answers_with_the_delivery_status_string() {
success: true,
output: "result".into(),
retryable: true,
+ raw_detail: None,
};
let status: String = proxy
.call(callbacks::SEND, (&job, "run-f", &attempt))
@@ -612,10 +613,11 @@ async fn captured_deleted_flow_job_publishes_trigger_and_completion_identity() {
.call(callbacks::SEND, (&job, &run_id, &attempt))
.await
.unwrap();
+ let success = attempt.success;
let projection = DeliveryProjection {
job: job.clone(),
run_id: run_id.clone(),
- success: attempt.success,
+ success,
delivery_status: DeliveryStatus::parse(&delivery_status),
attempt,
};
@@ -641,7 +643,7 @@ async fn captured_deleted_flow_job_publishes_trigger_and_completion_identity() {
},
Seen::Completed {
job_id: job.id,
- success: attempt.success,
+ success,
},
]
);
diff --git a/crates/openhuman-core/src/cron/bus_host_trusted_system_tests.rs b/crates/openhuman-core/src/cron/bus_host_trusted_system_tests.rs
index 4d0d5ee4f7..32e8e81b5d 100644
--- a/crates/openhuman-core/src/cron/bus_host_trusted_system_tests.rs
+++ b/crates/openhuman-core/src/cron/bus_host_trusted_system_tests.rs
@@ -107,7 +107,7 @@ async fn schedule_trigger_runs_trusted_memory_job_child() {
let attempt: Attempt = proxy
.call(
callbacks::SCHEDULE_TRIGGER,
- (&job.command, "run-memory-agent-only"),
+ (&job, "run-memory-agent-only"),
)
.await
.unwrap();
diff --git a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
index 51ce3e207f..1ed4e2ae2c 100644
--- a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
@@ -188,15 +188,45 @@ async fn a_system_job_without_a_handler_is_still_ok_on_dispatch() {
assert!(output.contains("dispatched"), "{output}");
}
-#[test]
-fn only_one_scheduler_loop_holds_the_slot() {
- let first = LoopSlot::acquire().expect("the slot is free");
- assert!(is_running());
- assert!(LoopSlot::acquire().is_none(), "a second loop is refused");
- drop(first);
- assert!(!is_running());
- let again = LoopSlot::acquire();
- assert!(again.is_some());
+#[tokio::test]
+async fn module_scheduler_slot_is_per_store_scope_and_refuses_a_duplicate() {
+ let first_tmp = TempDir::new().unwrap();
+ let first_config = test_config(&first_tmp).await;
+ let mut first = JobDispatcher::new(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &first_config,
+ &security(&first_config),
+ );
+ assert_eq!(first.tick(&first_config).await.unwrap(), 0);
+
+ let mut duplicate = JobDispatcher::new(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &first_config,
+ &security(&first_config),
+ );
+ let error = duplicate
+ .tick(&first_config)
+ .await
+ .expect_err("the same document scope has one module scheduler");
+ assert!(
+ error.to_string().contains("scheduler already owns this scope"),
+ "unexpected duplicate-scope refusal: {error}"
+ );
+
+ let second_tmp = TempDir::new().unwrap();
+ let second_config = test_config(&second_tmp).await;
+ let mut second = JobDispatcher::new(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &second_config,
+ &security(&second_config),
+ );
+ assert_eq!(
+ second.tick(&second_config).await.unwrap(),
+ 0,
+ "a different document/workspace scope owns an independent module slot"
+ );
+ first.drain().await;
+ second.drain().await;
}
/// Upgrade regression: a job whose retry budget and single-flight setting lived