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(cron): add coverage for bus host, client, documents port, and scheduler
Steven Enamakel0d84f73c09ad
diff --git a/crates/openhuman-core/src/cron/bus_host_tests.rs b/crates/openhuman-core/src/cron/bus_host_tests.rsindex 860d253422..88950357d7 100644--- a/crates/openhuman-core/src/cron/bus_host_tests.rs+++ b/crates/openhuman-core/src/cron/bus_host_tests.rs@@ -54,10 +54,11 @@ fn shell_job(config: &Config, command: &str) -> CronJob {.unwrap()}-/// Runs jobs whose command starts with `bus-host-test:` itself and hands every+/// Runs jobs whose command starts with its own `prefix` itself and hands every/// other job to the handler it replaced, so tests running in parallel keep/// their real shell/flow behaviour.struct Marker {+ prefix: &'static str,inner: Arc<dyn JobKindHandler>,calls: Arc<AtomicUsize>,permanent: bool,@@ -66,7 +67,7 @@ struct Marker {#[async_trait]impl JobKindHandler for Marker {async fn run(&self, cx: &JobRunContext, job: &CronJob, run_id: &str) -> JobOutcome {- if !job.command.starts_with("bus-host-test:") {+ if !job.command.starts_with(self.prefix) {return self.inner.run(cx, job, run_id).await;}self.calls.fetch_add(1, Ordering::SeqCst);@@ -88,12 +89,13 @@ async fn execute_runs_the_registered_handler_and_reports_a_retryable_failure() {let _registration = register_kind(JobType::Shell,Arc::new(Marker {+ prefix: "bus-host-test:retryable:",inner: kind_handler(&JobType::Shell).unwrap(),calls: Arc::clone(&calls),permanent: false,}),);- let job = shell_job(&config, "bus-host-test:retryable");+ let job = shell_job(&config, "bus-host-test:retryable:");let attempt: Attempt = proxy.call(callbacks::EXECUTE, (&job, "run-a")).await@@ -112,12 +114,13 @@ async fn a_permanent_handler_outcome_stops_the_retry_loop() {let _registration = register_kind(JobType::Shell,Arc::new(Marker {+ prefix: "bus-host-test:permanent:",inner: kind_handler(&JobType::Shell).unwrap(),calls: Arc::new(AtomicUsize::new(0)),permanent: true,}),);- let job = shell_job(&config, "bus-host-test:permanent");+ let job = shell_job(&config, "bus-host-test:permanent:");let attempt: Attempt = proxy.call(callbacks::EXECUTE, (&job, "run-b")).await@@ -135,12 +138,13 @@ async fn an_agent_only_scheduler_refuses_shell_jobs_before_running_anything() {let _registration = register_kind(JobType::Shell,Arc::new(Marker {+ prefix: "bus-host-test:refused:",inner: kind_handler(&JobType::Shell).unwrap(),calls: Arc::clone(&calls),permanent: false,}),);- let job = shell_job(&config, "bus-host-test:refused");+ let job = shell_job(&config, "bus-host-test:refused:");let attempt: Attempt = proxy.call(callbacks::EXECUTE, (&job, "run-c")).awaitdiff --git a/crates/openhuman-core/src/cron/client_tests.rs b/crates/openhuman-core/src/cron/client_tests.rsindex cb515438af..2273ab085a 100644--- a/crates/openhuman-core/src/cron/client_tests.rs+++ b/crates/openhuman-core/src/cron/client_tests.rs@@ -8,7 +8,7 @@ fn at(hour: u32) -> DateTime<Utc> {fn cron(expr: &str) -> Schedule {Schedule::Cron {expr: expr.into(),- tz: None,+ tz: Some("UTC".into()),active_hours: None,}}diff --git a/crates/openhuman-core/src/cron/documents_port_tests.rs b/crates/openhuman-core/src/cron/documents_port_tests.rsindex be1f0ca367..52acdee532 100644--- a/crates/openhuman-core/src/cron/documents_port_tests.rs+++ b/crates/openhuman-core/src/cron/documents_port_tests.rs@@ -36,7 +36,8 @@ async fn the_port_serves_the_contracts_document_interface_and_reports_capabiliti#[tokio::test]async fn a_second_absent_write_comes_back_as_a_conflict_kind() {let (proxy, _) = port().await;- let put = json!({"op":"put","collection":"cron_jobs","id":"dup","doc":{"a":1},"precondition":"absent"});+ let absent = serde_json::to_value(tinystoragedrivers::Precondition::Absent).unwrap();+ let put = json!({"op":"put","collection":"cron_jobs","id":"dup","doc":{"a":1},"precondition":absent});// The collection must exist first; the module declares it, the port relays.let ensured = ask(&proxy,@@ -53,13 +54,14 @@ async fn a_second_absent_write_comes_back_as_a_conflict_kind() {#[tokio::test]async fn a_collection_outside_the_schedule_port_is_refused() {let (proxy, _) = port().await;+ let none = serde_json::to_value(tinystoragedrivers::Precondition::None).unwrap();for request in [json!({"op":"get","collection":"memory_items","id":"x"}),json!({"op":"count","collection":"flows","filter":{}}),json!({"op":"ensure","spec":{"name":"secrets"}}),json!({"op":"atomic_batch","ops":[- {"op":"put","collection":"cron_jobs","id":"ok","doc":{},"precondition":"none"},- {"op":"delete","collection":"approvals","id":"x","precondition":"none"}+ {"op":"put","collection":"cron_jobs","id":"ok","doc":{},"precondition":none},+ {"op":"delete","collection":"approvals","id":"x","precondition":none}]}),] {let reply = ask(&proxy, request.clone()).await;diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rsindex a9a723e9ef..dbefb02266 100644--- a/crates/openhuman-core/src/cron/scheduler_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs@@ -261,7 +261,7 @@ async fn security_policy_block_halts_without_spending_the_retry_budget() {attempt_count(&counter));assert!(- elapsed < std::time::Duration::from_millis(config.reliability.provider_backoff_ms),+ elapsed < std::time::Duration::from_millis(config.reliability.provider_backoff_ms) * 2,"the loop slept for {elapsed:?} on a deterministic policy refusal. A security block is \permanent across the backoff curve and must return on the first attempt; retrying it \only delays the user's error by the full retry budget (here about 4 s)."