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
feat(cron): add per-job execution limits
Steven Enamakela7649d1b7e0a
diff --git a/crates/openhuman-core/src/cron/limits.rs b/crates/openhuman-core/src/cron/limits.rsindex abf9b27f18..fc60190284 100644--- a/crates/openhuman-core/src/cron/limits.rs+++ b/crates/openhuman-core/src/cron/limits.rs@@ -14,8 +14,7 @@ use chrono::{Duration, Utc};use crate::config::Config;use crate::cron::{- delivery_mode, list_jobs, runs_closer_than, CronJob, CronJobPatch, DeliveryConfig, JobType,- Schedule,+ delivery_mode, list_jobs, CronJob, CronJobPatch, DeliveryConfig, JobType, Schedule,};/// Whether `config` restricts cron to agent jobs.@@ -32,7 +31,13 @@ fn check_type(job_type: &JobType) -> Result<()> {fn check_schedule(config: &Config, schedule: &Schedule) -> Result<()> {let min = Duration::seconds(i64::try_from(config.cron.min_interval_secs).unwrap_or(i64::MAX));- if let Some(too_frequent) = runs_closer_than(schedule, Utc::now(), min) {+ // The cadence walk runs in the module (`RunsCloserThan`); a module that+ // cannot answer fails the check closed rather than waving a job through.+ let schedule = schedule.clone();+ let too_frequent = crate::cron::client::blocking(config, move |config| async move {+ crate::cron::client::runs_closer_than(&config, &schedule, Utc::now(), min).await+ })?;+ if let Some(too_frequent) = too_frequent {bail!("recurring cron jobs must run at least {}s apart, but this schedule {too_frequent}",config.cron.min_interval_secsdiff --git a/crates/openhuman-core/src/cron/mod.rs b/crates/openhuman-core/src/cron/mod.rsindex 195171ecda..07c1116254 100644--- a/crates/openhuman-core/src/cron/mod.rs+++ b/crates/openhuman-core/src/cron/mod.rs@@ -37,9 +37,6 @@ pub use ops as rpc;#[cfg(test)]pub use ops::update_cron_job;pub use ops::{add_once, add_once_at, pause_job, resume_job};-// Pure scheduling logic (schedule model, next-run computation) lives in-// `tinyflows-schedule`; the host keeps the scheduler runtime, store, config-// and RPC, and re-exports the upstream names so `cron::Schedule` etc. hold.pub use schemas::{all_controller_schemas as all_cron_controller_schemas,all_registered_controllers as all_cron_registered_controllers, schemas as cron_schemas,diff --git a/crates/openhuman-core/src/cron/ops.rs b/crates/openhuman-core/src/cron/ops.rsindex 43609f861d..1690600a05 100644--- a/crates/openhuman-core/src/cron/ops.rs+++ b/crates/openhuman-core/src/cron/ops.rs@@ -9,10 +9,9 @@ use {tinyflows_bus::schedule::types::CronRun, tinyflows_bus::schedule::types::Schedule,};-/// Claim `job_id` as running. `None` when a run (scheduled or Run Now) already-/// holds it; the claim is released when the guard drops, including on panic or+/// Claim `job_id` as running. `None` when a Run Now of it already holds it; the claim is released when the guard drops, including on panic or/// future cancellation, so an aborted task can never lock a job id.-pub(crate) fn try_acquire_run(job_id: &str) -> Option<tinyflows_schedule::runtime::RunClaim> {+pub(crate) fn try_acquire_run(job_id: &str) -> Option<crate::cron::scheduler::RunGuard> {crate::cron::scheduler::try_acquire_run(job_id)}@@ -31,7 +30,10 @@ pub(crate) fn load_job_for_run(config: &Config, job_id: &str) -> Result<CronJob>}pub fn add_once(config: &Config, delay: &str, command: &str) -> Result<CronJob> {- let duration = tinyflows_schedule::validation::parse_human_delay(delay)?;+ let delay = delay.to_string();+ let duration = crate::cron::client::blocking(config, move |config| async move {+ crate::cron::client::parse_human_delay(&config, &delay).await+ })?;let at = chrono::Utc::now() + duration;add_once_at(config, at, command)}