Skip to content

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

chore: files changed crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs

Steven Enamakel2a7c451096ae
diff --git a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
index b27d0c7a83..c57f09fc4a 100644
--- a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
@@ -351,3 +351,78 @@ fn only_one_scheduler_loop_holds_the_slot() {
let again = SchedulerSlot::acquire(LOOP_SCOPE);
assert!(again.is_some());
}
+
+/// Upgrade regression: a job whose retry budget and single-flight setting lived
+/// in the old `cron_job_policies` side table keeps firing after the upgrade,
+/// with that policy now on the job itself.
+#[tokio::test]
+async fn an_upgraded_job_with_a_side_table_policy_keeps_firing_with_it() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
+ let legacy = crate::cron::store::legacy_db_path(&config);
+ std::fs::create_dir_all(legacy.parent().unwrap()).unwrap();
+ std::fs::copy(
+ std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("src/storage/import/fixtures/tinyflows/workspace/cron/jobs.db"),
+ &legacy,
+ )
+ .unwrap();
+ let shell_id = "a0ebbb67-f060-4467-92f7-78d6272be94e";
+ {
+ let conn = crate::storage::rusqlite::Connection::open(&legacy).unwrap();
+ conn.execute_batch(
+ "CREATE TABLE IF NOT EXISTS cron_job_policies (
+ job_id TEXT PRIMARY KEY, retries INTEGER, single_flight INTEGER NOT NULL DEFAULT 0)",
+ )
+ .unwrap();
+ conn.execute(
+ "INSERT INTO cron_job_policies (job_id, retries, single_flight) VALUES (?1, 0, 1)",
+ [shell_id],
+ )
+ .unwrap();
+ }
+
+ force_due(&config, shell_id);
+ let job = cron::get_job(&config, shell_id).unwrap();
+ assert_eq!(job.policy.retries, Some(0));
+ assert!(job.policy.single_flight);
+
+ let mut dispatcher = JobDispatcher::new(&config, &security(&config));
+ dispatcher.dispatch(vec![job]).await.unwrap();
+ dispatcher.drain().await;
+
+ let after = cron::get_job(&config, shell_id).unwrap();
+ assert_eq!(after.last_status.as_deref(), Some("ok"), "the upgraded job ran");
+ assert!(after.policy.single_flight, "its policy survived the run");
+}
+
+/// A `flow` schedule row fires through the runtime's trigger sink: the run is
+/// recorded without any `FlowScheduleTick` event in between, and an unknown
+/// flow is a no-op rather than a failure.
+#[tokio::test]
+async fn a_flow_schedule_job_fires_through_the_trigger_sink() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
+ let job = cron::add_flow_schedule_job(
+ &config,
+ "flow-missing-for-sink",
+ Schedule::Every {
+ every_ms: 3_600_000,
+ },
+ )
+ .unwrap();
+ force_due(&config, &job.id);
+ let job = cron::get_job(&config, &job.id).unwrap();
+
+ let mut dispatcher = JobDispatcher::new(&config, &security(&config));
+ dispatcher.dispatch(vec![job.clone()]).await.unwrap();
+ dispatcher.drain().await;
+
+ let stored = cron::get_job(&config, &job.id).unwrap();
+ assert_eq!(stored.last_status.as_deref(), Some("ok"));
+ assert!(stored
+ .last_output
+ .unwrap_or_default()
+ .contains("flow schedule tick emitted for flow flow-missing-for-sink"));
+ assert!(stored.next_run > Utc::now(), "the recurrence moved on");
+}