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
chore: files changed crates/openhuman-core/src/cron/system_jobs.rs,crates/openhuman-core/src/cron/sy
Steven Enamakela0973d580ea6
diff --git a/crates/openhuman-core/src/cron/system_jobs.rs b/crates/openhuman-core/src/cron/system_jobs.rsindex b9130c4eba..f5181cea45 100644--- a/crates/openhuman-core/src/cron/system_jobs.rs+++ b/crates/openhuman-core/src/cron/system_jobs.rs@@ -7,18 +7,22 @@//! instead of a flow tick, and the owning domain runs it. Cron stays agnostic//! of what the job does; the rows show up in the routines list like any other.//!-//! Memory owns two (`memory::bus`): `memory_context_refresh`, every-//! `[memory.context] interval_mins`, and `memory_sources_sync`, every-//! [`SOURCES_SYNC_INTERVAL_MINS`]. [`ensure_memory_jobs`] is idempotent: it-//! creates a missing row and reschedules one whose interval drifted.+//! Memory owns two (`memory::bus`): `memory_background`, every+//! [`BACKGROUND_INTERVAL_MINS`] (the queued belief builds and deferred+//! ingests), and `memory_sources_sync`, every [`SOURCES_SYNC_INTERVAL_MINS`].+//! [`ensure_memory_jobs`] is idempotent: it creates a missing row, reschedules+//! one whose interval drifted, and removes the retired+//! `memory_context_refresh` row.use anyhow::Result;use crate::config::Config;-use crate::memory::bus::{CONTEXT_REFRESH_JOB, SOURCES_SYNC_JOB};+use crate::memory::bus::{RETIRED_CONTEXT_REFRESH_JOB, SOURCES_SYNC_JOB};+use crate::memory::lifecycle::jobs::{BACKGROUND_INTERVAL_MINS, BACKGROUND_JOB};use super::{- add_flow_schedule_job, list_jobs, update_job, CronJob, CronJobPatch, JobType, Schedule,+ add_flow_schedule_job, list_jobs, remove_job, update_job, CronJob, CronJobPatch, JobType,+ Schedule,};/// Command prefix that marks a `flow` row as a system job.@@ -79,14 +83,18 @@ pub fn ensure_system_job(config: &Config, name: &str, schedule: Schedule) -> Res}}-/// Seeds (or reschedules) memory's system jobs for `config`.+/// Seeds (or reschedules) memory's system jobs for `config`, and removes+/// the ones memory retired.pub fn ensure_memory_jobs(config: &Config) -> Result<()> {- ensure_system_job(- config,- CONTEXT_REFRESH_JOB,- every(config.memory.context.interval_mins),- )?;+ let background_mins = u32::try_from(BACKGROUND_INTERVAL_MINS).unwrap_or(u32::MAX);+ ensure_system_job(config, BACKGROUND_JOB, every(background_mins))?;ensure_system_job(config, SOURCES_SYNC_JOB, every(SOURCES_SYNC_INTERVAL_MINS))?;+ for job in list_jobs(config)? {+ if system_job_name(&job) == Some(RETIRED_CONTEXT_REFRESH_JOB) {+ tracing::info!(id = %job.id, "[cron:system] removing the retired context refresh job");+ remove_job(config, &job.id)?;+ }+ }Ok(())}diff --git a/crates/openhuman-core/src/cron/system_jobs_tests.rs b/crates/openhuman-core/src/cron/system_jobs_tests.rsindex 7a4cfefb27..05c60db6bf 100644--- a/crates/openhuman-core/src/cron/system_jobs_tests.rs+++ b/crates/openhuman-core/src/cron/system_jobs_tests.rs@@ -102,30 +102,26 @@ fn ensure_system_job_restores_a_cleared_name() {}#[test]-fn ensure_memory_jobs_seeds_both_jobs_and_follows_the_context_interval() {+fn ensure_memory_jobs_seeds_both_jobs_and_retires_the_context_refresh() {let tmp = TempDir::new().unwrap();- let mut config = test_config(&tmp);- config.memory.context.interval_mins = 60;+ let config = test_config(&tmp);+ let retired = ensure_system_job(&config, RETIRED_CONTEXT_REFRESH_JOB, every(360)).unwrap();ensure_memory_jobs(&config).unwrap();- let refresh = system_rows(&config, CONTEXT_REFRESH_JOB);+ let background = system_rows(&config, BACKGROUND_JOB);let sync = system_rows(&config, SOURCES_SYNC_JOB);- assert_eq!(refresh.len(), 1);+ assert_eq!(background.len(), 1);assert_eq!(sync.len(), 1);- assert_eq!(refresh[0].schedule, every(60));+ assert_eq!(background[0].schedule, every(BACKGROUND_INTERVAL_MINS as u32));assert_eq!(sync[0].schedule, every(SOURCES_SYNC_INTERVAL_MINS));-- // Re-running changes nothing; a new interval reschedules only the refresh.- ensure_memory_jobs(&config).unwrap();- assert_eq!(- system_rows(&config, CONTEXT_REFRESH_JOB)[0].id,- refresh[0].id+ assert!(+ system_rows(&config, RETIRED_CONTEXT_REFRESH_JOB).is_empty(),+ "the retired row {} is removed",+ retired.id);- config.memory.context.interval_mins = 120;++ // Re-running changes nothing.ensure_memory_jobs(&config).unwrap();- assert_eq!(- system_rows(&config, CONTEXT_REFRESH_JOB)[0].schedule,- every(120)- );+ assert_eq!(system_rows(&config, BACKGROUND_JOB)[0].id, background[0].id);assert_eq!(system_rows(&config, SOURCES_SYNC_JOB)[0].id, sync[0].id);}