Skip to content

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

refactor(cron): make update_cron_job test-only and sync

Steven Enamakelf09e913e267c
diff --git a/crates/openhuman-core/src/cron/mod.rs b/crates/openhuman-core/src/cron/mod.rs
index aff93a72f0..130b7dc20f 100644
--- a/crates/openhuman-core/src/cron/mod.rs
+++ b/crates/openhuman-core/src/cron/mod.rs
@@ -27,7 +27,9 @@ pub mod tools;
pub mod scheduler;
pub use ops as rpc;
-pub use ops::{add_once, add_once_at, parse_human_delay, pause_job, resume_job, update_cron_job};
+pub use ops::{add_once, add_once_at, parse_human_delay, pause_job, resume_job};
+#[cfg(test)]
+pub use ops::update_cron_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.
diff --git a/crates/openhuman-core/src/cron/ops.rs b/crates/openhuman-core/src/cron/ops.rs
index 9eddeb795f..6c1dd1501c 100644
--- a/crates/openhuman-core/src/cron/ops.rs
+++ b/crates/openhuman-core/src/cron/ops.rs
@@ -84,7 +84,8 @@ pub fn resume_job(config: &Config, id: &str) -> Result<CronJob> {
/// `expression` and `tz` are merged with the existing [`Schedule::Cron`] fields; the
/// existing `active_hours` is always preserved as-is. To set or clear `active_hours`
/// directly, use the RPC path (`cron.update` with a full [`CronJobPatch`]).
-pub async fn update_cron_job(
+#[cfg(test)]
+pub fn update_cron_job(
config: &Config,
id: &str,
expression: Option<String>,
@@ -123,9 +124,9 @@ pub async fn update_cron_job(
&config.workspace_dir,
&config.action_dir,
);
- crate::cron::scheduler::shell_job::authorize_shell_command(config, &security, cmd)
- .await
- .map_err(anyhow::Error::msg)?;
+ if !security.is_command_allowed(cmd) {
+ anyhow::bail!("Command blocked by security policy: {cmd}");
+ }
}
let patch = CronJobPatch {
@@ -189,7 +190,6 @@ pub async fn cron_update(
);
crate::cron::scheduler::shell_job::authorize_shell_command(config, &security, command)
.await?;
- }
}
let updated = cron::update_job(config, job_id.trim(), patch).map_err(|e| e.to_string())?;