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/desktop/notifications/bus.rs,crates/openhuman-core/sr

Steven Enamakel2148dba6d1da
diff --git a/crates/openhuman-core/src/desktop/notifications/bus.rs b/crates/openhuman-core/src/desktop/notifications/bus.rs
index 086d1a3aae..1eb9b496bd 100644
--- a/crates/openhuman-core/src/desktop/notifications/bus.rs
+++ b/crates/openhuman-core/src/desktop/notifications/bus.rs
@@ -607,3 +607,7 @@ mod bus_tests;
#[cfg(test)]
#[path = "bus_tests_2_tests.rs"]
mod tests;
+
+#[cfg(test)]
+#[path = "bus_tests_3_tests.rs"]
+mod profile_routing_tests;
diff --git a/crates/openhuman-core/src/desktop/notifications/bus_tests_3_tests.rs b/crates/openhuman-core/src/desktop/notifications/bus_tests_3_tests.rs
new file mode 100644
index 0000000000..6949fd970f
--- /dev/null
+++ b/crates/openhuman-core/src/desktop/notifications/bus_tests_3_tests.rs
@@ -0,0 +1,72 @@
+use super::*;
+use crate::core::runtime::{CoreContext, DomainSet};
+use crate::profiles::{ProfileHost, ProfileId, ProfileIdMode, SaasConfig};
+
+#[tokio::test]
+async fn cron_completion_stays_in_each_profile_when_agent_ids_match() {
+ use std::sync::Arc;
+
+ let root = tempfile::tempdir().unwrap();
+ let host = Arc::new(ProfileHost::new(
+ SaasConfig::new(root.path()),
+ CoreContext::for_test(DomainSet::full(), None),
+ ));
+ let suffix = uuid::Uuid::new_v4().simple().to_string();
+ let profile_a = ProfileId::for_user(&format!("profile-a-{suffix}"), ProfileIdMode::Raw).unwrap();
+ let profile_b = ProfileId::for_user(&format!("profile-b-{suffix}"), ProfileIdMode::Raw).unwrap();
+ host.provision(&profile_a).await.unwrap();
+ host.provision(&profile_b).await.unwrap();
+ let state_a = host.open(&profile_a).await.unwrap();
+ let state_b = host.open(&profile_b).await.unwrap();
+ ProfileHost::install(Arc::clone(&host));
+
+ let subscriber = NotificationBridgeSubscriber::new(crate::config::Config::default());
+ for (profile, job_id) in [(&profile_a, "profile-job-a"), (&profile_b, "profile-job-b")] {
+ subscriber
+ .handle(&DomainEvent::CronJobCompleted {
+ job_id: job_id.into(),
+ success: true,
+ output: "done".into(),
+ tenant: Some(crate::core::runtime::Tenant {
+ profile: Some(profile.as_str().to_string()),
+ agent: Some("shared-agent-id".into()),
+ }),
+ })
+ .await;
+ }
+
+ let config_a = host.provisioned_config(&profile_a).await.unwrap();
+ let config_b = host.provisioned_config(&profile_b).await.unwrap();
+ let events_a = CoreContext::scope(
+ state_a.context().for_agent("shared-agent-id"),
+ async {
+ crate::desktop::notifications::store::list_core_notifications(&config_a, true, 10)
+ .unwrap()
+ },
+ )
+ .await;
+ let events_b = CoreContext::scope(
+ state_b.context().for_agent("shared-agent-id"),
+ async {
+ crate::desktop::notifications::store::list_core_notifications(&config_b, true, 10)
+ .unwrap()
+ },
+ )
+ .await;
+
+ assert_eq!(events_a.len(), 1, "profile A owns its completion");
+ assert!(events_a[0].id.starts_with("cron:profile-job-a:"));
+ assert_eq!(events_b.len(), 1, "profile B owns its completion");
+ assert!(events_b[0].id.starts_with("cron:profile-job-b:"));
+
+ let missing_tenant = DomainEvent::CronJobCompleted {
+ job_id: "missing-profile-job".into(),
+ success: true,
+ output: "done".into(),
+ tenant: Some(crate::core::runtime::Tenant {
+ profile: Some(format!("h-{}", "0".repeat(32))),
+ agent: Some("shared-agent-id".into()),
+ }),
+ };
+ assert!(event_dispatch(&missing_tenant).is_none());
+}