Skip to content

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

chore: files changed crates/openhuman-core/src/cron/client.rs,crates/openhuman-core/src/cron/client_

Steven Enamakel3996dde2d4a0
diff --git a/crates/openhuman-core/src/cron/client.rs b/crates/openhuman-core/src/cron/client.rs
index 55c3a985d1..2a1f89573b 100644
--- a/crates/openhuman-core/src/cron/client.rs
+++ b/crates/openhuman-core/src/cron/client.rs
@@ -20,7 +20,7 @@ use tinyflows_bus::schedule::{
members, CheckOriginRequest, DeliveryConfig, JobOrigin, RunsCloserThanRequest, Schedule,
SessionTarget, StoreBackend, StoreConfig, StoreOperation, StoreRequest, TooFrequent,
};
-use tinyflows_bus::schedule::{CronJob, CronJobPatch};
+use tinyflows_bus::schedule::CronJob;
use super::documents_port::{self, DocScope};
use crate::config::Config;
diff --git a/crates/openhuman-core/src/cron/client_tests.rs b/crates/openhuman-core/src/cron/client_tests.rs
index bf06069b1d..88d896f59e 100644
--- a/crates/openhuman-core/src/cron/client_tests.rs
+++ b/crates/openhuman-core/src/cron/client_tests.rs
@@ -1,134 +1,4 @@
use super::*;
-use chrono::TimeZone;
-
-fn at(hour: u32) -> DateTime<Utc> {
- Utc.with_ymd_and_hms(2030, 1, 1, hour, 0, 0).unwrap()
-}
-
-fn cron(expr: &str) -> Schedule {
- Schedule::Cron {
- expr: expr.into(),
- tz: Some("UTC".into()),
- active_hours: None,
- }
-}
-
-#[tokio::test]
-async fn next_run_comes_from_the_module() {
- let config = Config::default();
- let next = next_run(&config, &cron("0 9 * * *"), at(8)).await.unwrap();
- assert_eq!(next, at(9));
- assert!(next_run(&config, &cron("not a cron"), at(8)).await.is_err());
-}
-
-#[tokio::test]
-async fn schedules_are_validated_and_the_agent_floor_applies() {
- let config = Config::default();
- validate_schedule(&config, &cron("0 9 * * *"), at(8), true)
- .await
- .unwrap();
- let every_minute = Schedule::Every { every_ms: 60_000 };
- validate_schedule(&config, &every_minute, at(8), false)
- .await
- .unwrap();
- assert!(validate_schedule(&config, &every_minute, at(8), true)
- .await
- .is_err());
- let past = Schedule::At { at: at(1) };
- assert!(validate_schedule(&config, &past, at(8), false)
- .await
- .is_err());
-}
-
-#[tokio::test]
-async fn expressions_normalise_and_report_their_cron_form() {
- let config = Config::default();
- assert_eq!(
- normalize_expression(&config, "0 9 * * 1-5").await.unwrap(),
- "0 0 9 * * 2-6"
- );
- assert!(schedule_cron_expression(&config, &cron("0 9 * * *"))
- .await
- .unwrap()
- .is_some());
- assert!(
- schedule_cron_expression(&config, &Schedule::Every { every_ms: 1000 })
- .await
- .unwrap()
- .is_none()
- );
-}
-
-#[tokio::test]
-async fn delays_parse_and_delivery_defaults_follow_the_origin() {
- let config = Config::default();
- assert_eq!(
- parse_human_delay(&config, "2h").await.unwrap(),
- Duration::hours(2)
- );
- assert!(parse_human_delay(&config, "soon").await.is_err());
- assert_eq!(
- default_delivery(&config, None).await.unwrap().mode,
- "proactive"
- );
- let origin = JobOrigin::Web {
- thread_id: "t1".into(),
- agent_id: None,
- };
- assert_eq!(
- default_delivery(&config, Some(&origin)).await.unwrap().mode,
- "origin"
- );
-}
-
-#[tokio::test]
-async fn origin_delivery_without_an_origin_is_refused() {
- let config = Config::default();
- let origin_delivery = default_delivery(
- &config,
- Some(&JobOrigin::Web {
- thread_id: "t1".into(),
- agent_id: None,
- }),
- )
- .await
- .unwrap();
- assert!(
- check_origin_requirements(&config, &SessionTarget::Isolated, &origin_delivery, None)
- .await
- .is_err()
- );
- check_origin_requirements(
- &config,
- &SessionTarget::Isolated,
- &DeliveryConfig::default(),
- None,
- )
- .await
- .unwrap();
-}
-
-#[tokio::test]
-async fn long_output_is_cut_at_the_contract_bound() {
- let config = Config::default();
- let long = "x".repeat(tinyflows_bus::schedule::MAX_CRON_OUTPUT_BYTES * 2);
- let cut = truncate_cron_output(&config, &long).await.unwrap();
- assert!(cut.len() <= tinyflows_bus::schedule::MAX_CRON_OUTPUT_BYTES + 32);
- assert!(cut.ends_with(tinyflows_bus::schedule::TRUNCATED_OUTPUT_MARKER));
-}
-
-#[tokio::test]
-async fn runs_closer_than_reports_the_tightest_pair() {
- let config = Config::default();
- let hit = runs_closer_than(&config, &cron("*/3 * * * *"), at(8), Duration::minutes(5))
- .await
- .unwrap();
- assert!(hit.is_some());
- let none = runs_closer_than(&config, &cron("0 9 * * *"), at(8), Duration::minutes(5))
- .await
- .unwrap();
- assert!(none.is_none());
-}
#[tokio::test]
async fn a_module_error_keeps_its_own_message() {
diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rs
index 0ce7e5f529..aac6408ff3 100644
--- a/crates/openhuman-core/src/cron/ops_tests.rs
+++ b/crates/openhuman-core/src/cron/ops_tests.rs
@@ -343,7 +343,7 @@ async fn cron_run_rejects_duplicate_concurrent_execution() {
// Hold the run claim directly to simulate an in-flight execution without
// spawning a real long-running subprocess (deterministic, no timing dependency).
- let running = try_acquire_run(&job.id).expect("the job is free");
+ let running = crate::cron::scheduler::try_acquire_run(&job.id).expect("the job is free");
let err = cron_run(
&crate::core::runtime::DispatchCtx::ambient(),
&config,
@@ -420,7 +420,7 @@ async fn run_job_now_refuses_a_job_that_is_already_running() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
let job = single_flight_system_job(&config, "ops-run-now-busy");
- let _running = try_acquire_run(&job.id).expect("the job is free");
+ let _running = crate::cron::scheduler::try_acquire_run(&job.id).expect("the job is free");
let err = run_job_now(
&crate::core::runtime::DispatchCtx::ambient(),
&config,
diff --git a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
index 714a36b771..df1285c84f 100644
--- a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
@@ -1,12 +1,5 @@
use super::*;
-#[test]
-fn forbidden_path_argument_skips_flags_and_urls() {
- let policy = SecurityPolicy::default();
- assert!(forbidden_path_argument(&policy, "curl https://example.com").is_none());
- assert!(forbidden_path_argument(&policy, "ls -la").is_none());
-}
-
#[tokio::test]
async fn deliver_if_configured_skips_empty_mode() {
let tmp = TempDir::new().unwrap();
diff --git a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
index 97db2c8176..c7f4996948 100644
--- a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
@@ -569,31 +569,3 @@ async fn deliver_if_configured_skips_non_announce_mode() {
.is_ok());
}
-#[test]
-fn is_env_assignment_true() {
- assert!(is_env_assignment("FOO=bar"));
- assert!(is_env_assignment("_VAR=1"));
-}
-
-#[test]
-fn is_env_assignment_false() {
- assert!(!is_env_assignment("echo"));
- assert!(!is_env_assignment("=bad"));
- assert!(!is_env_assignment("123=nope"));
- assert!(!is_env_assignment(""));
-}
-
-#[test]
-fn strip_wrapping_quotes_removes_quotes() {
- assert_eq!(strip_wrapping_quotes("\"hello\""), "hello");
- assert_eq!(strip_wrapping_quotes("'world'"), "world");
- assert_eq!(strip_wrapping_quotes("noquotes"), "noquotes");
- assert_eq!(strip_wrapping_quotes(""), "");
-}
-
-#[test]
-fn forbidden_path_argument_allows_safe_commands() {
- let policy = SecurityPolicy::default();
- assert!(forbidden_path_argument(&policy, "echo hello").is_none());
- assert!(forbidden_path_argument(&policy, "date").is_none());
-}