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
fix(cron): prevent duplicate job execution on scheduler restart
Steven Enamakel8a97d7e5c114
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rsindex e7447a6705..8eb8541455 100644--- a/crates/openhuman-core/src/cron/scheduler.rs+++ b/crates/openhuman-core/src/cron/scheduler.rs@@ -116,9 +116,6 @@ pub(crate) async fn tick_live_agents(dispatcher: &mut JobDispatcher) {return;}};- if !agent_jobs_may_exist(&config) {- return;- }let jobs = match due_jobs(&config, Utc::now()) {Ok(jobs) => jobs,Err(error) => {@@ -150,16 +147,6 @@ pub async fn run_live_agent_pass(max_concurrent: usize) {dispatcher.drain().await;}-/// Whether an agent can have jobs to poll: with a storage backend its jobs-/// live in the backend under its scope (`crate::storage`), so there is always-/// something to ask; without one, only once its own store exists, or the-/// `jobs.db` tinyflows used to write there (which the first call imports).-pub(crate) fn agent_jobs_may_exist(config: &Config) -> bool {- crate::storage::installed().is_some()- || crate::cron::store::db_path(config).exists()- || crate::cron::store::legacy_db_path(config).exists()-}-/// Single poll cycle of the scheduler loop, extracted so tests can drive/// it without owning `tokio::time::interval`.///diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rsindex dbed91b5b9..a91c6e3e61 100644--- a/crates/openhuman-core/src/cron/scheduler_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs@@ -336,23 +336,3 @@ async fn a_pipeline_reports_its_last_stage_rather_than_pipefail() {);}-#[tokio::test]-async fn without_a_backend_an_agent_needs_its_own_job_store_or_a_legacy_jobs_db() {- // The lib test binary installs no storage backend into the process slot.- if crate::storage::installed().is_some() {- return;- }- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp).await;- let db = crate::cron::store::db_path(&config);- let _ = std::fs::remove_file(&db);- assert!(!agent_jobs_may_exist(&config));- std::fs::create_dir_all(db.parent().unwrap()).unwrap();- std::fs::write(&db, b"").unwrap();- assert!(agent_jobs_may_exist(&config));- // The `jobs.db` tinyflows wrote counts too: the first call imports it.- std::fs::remove_file(&db).unwrap();- assert!(!agent_jobs_may_exist(&config));- std::fs::write(crate::cron::store::legacy_db_path(&config), b"").unwrap();- assert!(agent_jobs_may_exist(&config));-}diff --git a/crates/openhuman-core/src/cron/store.rs b/crates/openhuman-core/src/cron/store.rsindex f38bf60044..67bd36e223 100644--- a/crates/openhuman-core/src/cron/store.rs+++ b/crates/openhuman-core/src/cron/store.rs@@ -1,12 +1,9 @@//! Cron persistence: a thin host binding of `tinyflows_drivers::schedule::CronDocuments`.//!//! Jobs, run history and per-job policy live on the storage ports, in the-//! acting agent's scope of the installed backend ([`crate::storage`]) or, when-//! the host configured none, in a SQLite document store of their own-//! (`<workspace>/cron/schedule.db`, an embedded agent's under-//! `agents/<id>/cron/`). tinyflows no longer has a SQLite store of its own: the-//! `jobs.db` it wrote is imported once, read-only, on first use-//! ([`crate::storage::import`]).+//! acting agent's scope of the storage backend ([`crate::storage`]). tinyflows no+//! longer has a SQLite store of its own: the `jobs.db` it wrote is imported+//! once, read-only, when the backend is installed ([`crate::storage::import`]).//!//! This module only turns the host [`Config`] into the store's limits//! (run-history cap, due-job batch size), so callers keep passing `&Config`.