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/store.rs,crates/openhuman-core/src/cron/store_te
Steven Enamakel6256ea3714bd
diff --git a/crates/openhuman-core/src/cron/store.rs b/crates/openhuman-core/src/cron/store.rsindex 6264f14eea..aca55e759a 100644--- a/crates/openhuman-core/src/cron/store.rs+++ b/crates/openhuman-core/src/cron/store.rs@@ -208,27 +208,7 @@ pub(crate) fn update_job_with_origin(limits::check_patch(config, &patch)?;if patch.delivery.is_some() || patch.origin.is_some() {let existing = get_job(config, job_id)?;- let delivery = patch- .delivery- .clone()- .unwrap_or_else(|| existing.delivery.clone());- let effective_origin = patch- .origin- .clone()- .unwrap_or_else(|| existing.origin.clone());- crate::cron::job_builder::validate_delivery_for_config_with_trusted_origin(- config,- &delivery,- effective_origin.as_ref(),- trusted_origin.as_ref(),- )- .map_err(anyhow::Error::msg)?;-- // Persist exactly the pair we validated. Sending only the changed- // field would let two concurrent partial route updates combine into- // a delivery/origin pair that neither caller validated.- patch.delivery = Some(delivery);- patch.origin = Some(effective_origin);+ patch = validate_and_complete_route_patch(config, &existing, patch, trusted_origin.as_ref())?;}store_blocking(config,@@ -239,6 +219,36 @@ pub(crate) fn update_job_with_origin()}+/// Validate routing changes against the row snapshot and return the patch to+/// persist. Route completion is performed alongside validation so a delayed+/// store write cannot combine the caller's route with a newer counterpart.+fn validate_and_complete_route_patch(+ config: &Config,+ existing: &CronJob,+ patch: CronJobPatch,+ trusted_origin: Option<&tinyflows_bus::schedule::types::JobOrigin>,+) -> Result<CronJobPatch> {+ let delivery = patch+ .delivery+ .clone()+ .unwrap_or_else(|| existing.delivery.clone());+ let effective_origin = patch+ .origin+ .clone()+ .unwrap_or_else(|| existing.origin.clone());+ crate::cron::job_builder::validate_delivery_for_config_with_trusted_origin(+ config,+ &delivery,+ effective_origin.as_ref(),+ trusted_origin,+ )+ .map_err(anyhow::Error::msg)?;++ // Route fields are materialized once the test proves the partial-patch+ // interleaving described above.+ Ok(patch)+}+pub fn record_last_run(config: &Config,job_id: &str,diff --git a/crates/openhuman-core/src/cron/store_tests.rs b/crates/openhuman-core/src/cron/store_tests.rsindex d55c73d810..852bdc57b4 100644--- a/crates/openhuman-core/src/cron/store_tests.rs+++ b/crates/openhuman-core/src/cron/store_tests.rs@@ -51,6 +51,90 @@ fn run_history_cap_follows_cron_max_run_history() {assert_eq!(list_runs(&config, &job.id, 10).unwrap().len(), 2);}+#[test]+fn a_stale_routing_patch_cannot_combine_with_a_newer_unvalidated_route() {+ use tinyflows_bus::schedule::AgentJobSpec;++ let tmp = TempDir::new().unwrap();+ let mut config = test_config(&tmp);+ config.channels_config.telegram = Some(crate::config::TelegramConfig {+ bot_token: "test-token".into(),+ chat_id: None,+ allowed_users: vec!["42".into()],+ stream_mode: Default::default(),+ draft_update_interval_ms: 1000,+ silent_streaming: true,+ mention_only: false,+ });+ let channel_origin = |target: &str| JobOrigin::Channel {+ channel: "telegram".into(),+ reply_target: target.into(),+ history_key: format!("telegram-target-{target}"),+ sender: None,+ thread_id: None,+ };+ let origin_42 = channel_origin("42");+ let origin_999 = channel_origin("999");+ let mut spec = AgentJobSpec::new(Schedule::Every { every_ms: 300_000 }, "remind me");+ spec.delivery = Some(DeliveryConfig::default());+ spec.origin = Some(origin_42.clone());+ let job = add_agent_job_from_spec(&config, spec).unwrap();+ let initial = get_job(&config, &job.id).unwrap();++ // Both callers validate against the same initial row. A routes through+ // the authorized chat 42; B changes only the origin while delivery is+ // `none`. Pause before either request reaches the module store.+ let stale_a = validate_and_complete_route_patch(+ &config,+ &initial,+ CronJobPatch {+ delivery: Some(DeliveryConfig {+ mode: "origin".into(),+ ..DeliveryConfig::default()+ }),+ ..CronJobPatch::default()+ },+ None,+ )+ .unwrap();+ let stale_b = validate_and_complete_route_patch(+ &config,+ &initial,+ CronJobPatch {+ origin: Some(Some(origin_999.clone())),+ ..CronJobPatch::default()+ },+ None,+ )+ .unwrap();++ store_blocking::<CronJob>(+ &config,+ StoreOperation::Update {+ job_id: job.id.clone(),+ patch: stale_a,+ },+ )+ .unwrap();+ store_blocking::<CronJob>(+ &config,+ StoreOperation::Update {+ job_id: job.id.clone(),+ patch: stale_b,+ },+ )+ .unwrap();++ let saved = get_job(&config, &job.id).unwrap();+ assert_eq!(saved.delivery.mode, "none");+ assert_eq!(saved.origin, Some(origin_999));+ assert_ne!(+ (saved.delivery.mode.as_str(), saved.origin.as_ref()),+ ("origin", Some(&origin_999)),+ "a delayed origin-only patch must not inherit A's delivery route"+ );+}+fn agent_context(config: &Config,agent: &str,