Skip to content

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

chore: 姫路城 is a Japanese castle.

Steven Enamakel391747ec4073
diff --git a/crates/openhuman-core/src/cron/limits_tests.rs b/crates/openhuman-core/src/cron/limits_tests.rs
index bf8f58960f..31176fd4ba 100644
--- a/crates/openhuman-core/src/cron/limits_tests.rs
+++ b/crates/openhuman-core/src/cron/limits_tests.rs
@@ -152,3 +152,15 @@ fn stored_rows_that_break_the_limits_are_refused_at_run() {
let ok = create_agent_job(&config, input(600_000, None), origin()).unwrap();
limits::check_run(&config, &ok).unwrap();
}
+
+#[tokio::test]
+async fn run_now_refuses_a_stored_job_that_breaks_the_limits() {
+ let tmp = TempDir::new().unwrap();
+ let mut config = limited(&tmp);
+ config.cron.agent_jobs_only = false;
+ let shell = add_shell_job(&config, None, Schedule::Every { every_ms: 600_000 }, "echo").unwrap();
+ config.cron.agent_jobs_only = true;
+ assert!(crate::cron::ops::run_job_now(&config, &shell.id).await.is_err());
+ assert!(crate::cron::ops::cron_run(&config, &shell.id).await.is_err());
+ assert!(crate::cron::runs::list(&config, &shell.id).is_empty());
+}
diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rs
index 21aa2d620e..69334d918c 100644
--- a/crates/openhuman-core/src/profiles/host_tests.rs
+++ b/crates/openhuman-core/src/profiles/host_tests.rs
@@ -354,3 +354,33 @@ async fn a_profile_with_a_live_turn_is_not_evicted() {
assert!(!host.is_open(&a), "evicted once the turn ended");
host.open(&b).await.unwrap();
}
+
+#[tokio::test]
+async fn the_operators_cron_limits_bind_every_profile_whatever_its_config_says() {
+ let tmp = tempfile::tempdir().unwrap();
+ let mut saas = SaasConfig::new(tmp.path());
+ saas.cron.agent_jobs_only = true;
+ saas.cron.min_interval_secs = 900;
+ saas.cron.max_active_jobs = 3;
+ let host = ProfileHost::new(saas, CoreContext::for_test(DomainSet::full(), None));
+ let id = profile("alice");
+ host.provision(&id).await.unwrap();
+ // The user's own file tries to switch the mode off.
+ let layout = ProfileLayout::new(tmp.path(), &id);
+ std::fs::write(
+ &layout.config_path,
+ "[cron]\nagent_jobs_only = false\nmin_interval_secs = 1\nmax_active_jobs = 999\n",
+ )
+ .unwrap();
+ let forced = host.provisioned_config(&id).await.unwrap();
+ let opened = host.open(&id).await.unwrap();
+ let loaded = CoreContext::scope(Arc::clone(opened.context()), async {
+ crate::config::ops::load_current_or_init().await.unwrap()
+ })
+ .await;
+ for config in [&forced, &opened.config, &loaded] {
+ assert!(config.cron.agent_jobs_only);
+ assert_eq!(config.cron.min_interval_secs, 900);
+ assert_eq!(config.cron.max_active_jobs, 3);
+ }
+}