The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(plan_review): resolve socket replay tenant in the gate
Steven Enamakeld88e604bb90b
diff --git a/crates/openhuman-core/src/plan_review/gate_tests.rs b/crates/openhuman-core/src/plan_review/gate_tests.rsindex efcb4d72e8..ca947d1a10 100644--- a/crates/openhuman-core/src/plan_review/gate_tests.rs+++ b/crates/openhuman-core/src/plan_review/gate_tests.rs@@ -254,3 +254,30 @@ async fn parked_reviews_are_isolated_by_tenant() {));assert_eq!(parked.await, PlanReviewResolution::Approve);}++#[test]+fn socket_replay_tenant_uses_the_sockets_profile_in_saas() {+ let ambient = Tenant {+ profile: Some("ambient-profile".into()),+ agent: None,+ };+ let replay_tenant = socket_tenant(Some("socket-profile"), Ok(ambient), true)+ .expect("socket profile must identify its review scope");+ assert_eq!(replay_tenant.profile.as_deref(), Some("socket-profile"));+}++#[test]+fn socket_replay_tenant_fails_closed_without_a_saas_profile() {+ assert!(socket_tenant(None, Ok(Tenant::default()), true).is_none());+}++#[test]+fn non_saas_socket_replay_keeps_the_host_tenant() {+ let ambient = Tenant {+ profile: Some("host-profile".into()),+ agent: None,+ };+ let replay_tenant = socket_tenant(Some("untrusted-socket-hint"), Ok(ambient.clone()), false)+ .expect("host tenant remains available");+ assert_eq!(replay_tenant, ambient);+}diff --git a/crates/openhuman-rpc/src/server/socketio.rs b/crates/openhuman-rpc/src/server/socketio.rsindex a9bbd61ce5..1c7767ac30 100644--- a/crates/openhuman-rpc/src/server/socketio.rs+++ b/crates/openhuman-rpc/src/server/socketio.rs@@ -1190,43 +1190,9 @@ fn replay_parked_approval(socket: &SocketRef, thread_id: &str) {/// just joined that thread's room. Mirrors [`replay_parked_approval`] — a/// plan review is a live, in-memory park (no SQLite row), but it reaches the/// UI the same fire-and-forget way, so the same reconciliation applies.-fn socket_replay_tenant(- profile_id: Option<&str>,- ambient: Result<- crate::core_host::core::runtime::tenant::Tenant,- crate::core_host::core::runtime::tenant::NoTenant,- >,- saas: bool,-) -> Result<- crate::core_host::core::runtime::tenant::Tenant,- crate::core_host::core::runtime::tenant::NoTenant,-> {- if saas {- match profile_id.filter(|profile| !profile.trim().is_empty()) {- Some(profile) => {- Ok(crate::core_host::core::runtime::tenant::Tenant {- profile: Some(profile.to_owned()),- agent: None,- })- }- None => Err(crate::core_host::core::runtime::tenant::NoTenant),- }- } else {- ambient- }-}-fn replay_parked_plan_review(socket: &SocketRef, thread_id: &str, profile_id: Option<&str>) {- let ambient = crate::core_host::core::runtime::DispatchCtx::ambient().tenant();- let Ok(tenant) = socket_replay_tenant(- profile_id,- ambient,- crate::core_host::core::runtime::is_saas(),- ) else {- return;- };let Some(row) = crate::core_host::agent::plan_review::gate::global()- .parked_review_for_thread(&tenant, thread_id)+ .parked_review_for_socket(profile_id, thread_id)else {return;};diff --git a/crates/openhuman-rpc/src/server/socketio_tests.rs b/crates/openhuman-rpc/src/server/socketio_tests.rsindex 52ee1d3451..36e0707fb4 100644--- a/crates/openhuman-rpc/src/server/socketio_tests.rs+++ b/crates/openhuman-rpc/src/server/socketio_tests.rs@@ -1,33 +1,17 @@use super::{channel_connection_update_payload, event_alias, origin_is_allowed_with_extra,- publish_companion_state_changed, socket_replay_tenant, subscribe_companion_state_changed,+ publish_companion_state_changed, subscribe_companion_state_changed, ThreadSubscribePayload,};#[test]-fn plan_review_replay_uses_the_joining_sockets_profile() {- let ambient = crate::core_host::core::runtime::tenant::Tenant {- profile: Some("ambient-profile".into()),- agent: None,- };- let actual = socket_replay_tenant(Some("socket-profile"), Ok(ambient), true).unwrap();- assert_eq!(actual.profile.as_deref(), Some("socket-profile"));-}--#[test]-fn plan_review_replay_fails_closed_without_a_saas_socket_profile() {- let ambient = crate::core_host::core::runtime::tenant::Tenant::default();- assert!(socket_replay_tenant(None, Ok(ambient), true).is_err());-}--#[test]-fn plan_review_replay_keeps_the_host_tenant_outside_saas() {- let ambient = crate::core_host::core::runtime::tenant::Tenant {- profile: Some("host-profile".into()),- agent: None,- };- let actual = socket_replay_tenant(Some("ignored-client-profile"), Ok(ambient.clone()), false)- .unwrap();- assert_eq!(actual, ambient);+fn thread_subscribe_carries_the_sockets_profile_for_review_replay() {+ let payload: ThreadSubscribePayload = serde_json::from_value(serde_json::json!({+ "thread_id": "thread-1",+ "profile_id": "socket-profile",+ }))+ .expect("thread subscribe payload");+ assert_eq!(payload.thread_id, "thread-1");+ assert_eq!(payload.profile_id.as_deref(), Some("socket-profile"));}#[test]