Skip to content

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

test(sessions): cover agent key isolation across operator and profile scopes

Steven Enamakelbfef1af4b64c
diff --git a/crates/openhuman-core/src/storage/sessions/tenant_router_tests.rs b/crates/openhuman-core/src/storage/sessions/tenant_router_tests.rs
index 1679e73f0d..43e6f473e5 100644
--- a/crates/openhuman-core/src/storage/sessions/tenant_router_tests.rs
+++ b/crates/openhuman-core/src/storage/sessions/tenant_router_tests.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::storage::test_support::memory_backend;
+use tinyagents_harness::store::Store;
fn stores() -> TenantSessionStores {
TenantSessionStores::new(memory_backend(), false).expect("bridge")
@@ -53,3 +54,34 @@ fn one_provider_serves_every_agent_of_a_tenant() {
let (other, _) = router.route("u~two");
assert!(!Arc::ptr_eq(&first, &other));
}
+
+#[tokio::test]
+async fn the_same_agent_key_is_isolated_between_operator_and_profile_scopes() {
+ let router = stores();
+ let operator = router.for_agent("asha");
+ let profile_key = crate::core::runtime::session_key(&crate::core::runtime::Tenant {
+ profile: Some("alice".into()),
+ agent: Some("asha".into()),
+ });
+ let profile = router.for_agent(&profile_key);
+
+ operator
+ .kv
+ .put("scope-test", "owner", serde_json::json!("operator"))
+ .await
+ .unwrap();
+ profile
+ .kv
+ .put("scope-test", "owner", serde_json::json!("alice"))
+ .await
+ .unwrap();
+
+ assert_eq!(
+ operator.kv.get("scope-test", "owner").await.unwrap(),
+ Some(serde_json::json!("operator"))
+ );
+ assert_eq!(
+ profile.kv.get("scope-test", "owner").await.unwrap(),
+ Some(serde_json::json!("alice"))
+ );
+}