Skip to content

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

test(storage): cover owner resolution for scoped jobs

Steven Enamakel6fa9ba074bc0
diff --git a/scripts/ci/saas-ambient-baseline.json b/scripts/ci/saas-ambient-baseline.json
index f3669beb60..39b8024753 100644
--- a/scripts/ci/saas-ambient-baseline.json
+++ b/scripts/ci/saas-ambient-baseline.json
@@ -601,13 +601,6 @@
"text": "tokio::task::spawn_blocking(move || load_app_session_profile(&config_for_profile))",
"occurrence": 1
},
- {
- "rule": "bare-spawn",
- "path": "crates/openhuman-core/src/flows/bus/trigger.rs",
- "line": 202,
- "text": "tokio::spawn(async move {",
- "occurrence": 1
- },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/flows/ops/run.rs",
@@ -783,13 +776,6 @@
"text": "tokio::spawn(async move {",
"occurrence": 1
},
- {
- "rule": "bare-spawn",
- "path": "crates/openhuman-core/src/integrations/task_sources/bus.rs",
- "line": 91,
- "text": "tokio::spawn(async move {",
- "occurrence": 1
- },
{
"rule": "bare-spawn",
"path": "crates/openhuman-core/src/integrations/test_support_backend.rs",
diff --git a/tests/storage_scope_e2e.rs b/tests/storage_scope_e2e.rs
index a2219a0e4f..20b064995e 100644
--- a/tests/storage_scope_e2e.rs
+++ b/tests/storage_scope_e2e.rs
@@ -17,7 +17,7 @@ use openhuman_core::core::runtime::{
ContextOverlay, CoreBuilder, CoreContext, DomainSet, ServiceSet,
};
use openhuman_core::cron::{self, Schedule};
-use openhuman_core::storage::agents::for_each_scope;
+use openhuman_core::storage::agents::{find_owner, for_each_scope, within_agent};
use openhuman_core::HostKind;
fn job_names(config: &Config) -> Vec<String> {
@@ -72,6 +72,17 @@ async fn background_work_visits_every_agent_scope() {
"{live:?}"
);
+ // An event naming only the job resolves to its owner, and handling it
+ // there sees the job.
+ let job_id = within_agent(Some("agent-e2e"), async {
+ cron::list_jobs(&config).unwrap()[0].id.clone()
+ })
+ .await;
+ let owner = find_owner("e2e", || async { cron::get_job(&config, &job_id).is_ok() }).await;
+ assert_eq!(owner, Some(Some("agent-e2e".to_string())));
+ let missing = find_owner("e2e", || async { cron::get_job(&config, "nope").is_ok() }).await;
+ assert_eq!(missing, None);
+
// … and, once the agent is gone, through the id the backend recorded.
drop(agent);
let recorded = for_each_scope("e2e", || async { job_names(&config) }).await;