Skip to content

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

feat(plan_review): resolve parked reviews by socket profile

Steven Enamakel6d9b21150f84
diff --git a/crates/openhuman-core/src/plan_review/gate.rs b/crates/openhuman-core/src/plan_review/gate.rs
index 6196c7073c..e7f5133733 100644
--- a/crates/openhuman-core/src/plan_review/gate.rs
+++ b/crates/openhuman-core/src/plan_review/gate.rs
@@ -195,6 +195,23 @@ impl PlanReviewGate {
self.parked.lock().get(&(scope, request_id)).cloned()
}
+ /// The parked review a socket subscribed under its own profile should
+ /// replay. SaaS sockets carry that profile in their authenticated client
+ /// state; a missing id fails closed. Single-host sockets retain the host's
+ /// ambient tenant and ignore the optional profile hint.
+ pub fn parked_review_for_socket(
+ &self,
+ socket_profile_id: Option<&str>,
+ thread_id: &str,
+ ) -> Option<ParkedReview> {
+ let tenant = socket_tenant(
+ socket_profile_id,
+ crate::core::runtime::DispatchCtx::ambient().tenant(),
+ crate::core::runtime::is_saas(),
+ )?;
+ self.parked_review_for_thread(&tenant, thread_id)
+ }
+
/// Resolve a parked review by `request_id`. Returns `true` when a waiter was
/// woken; `false` when the id is unknown (already decided / expired).
pub fn decide(
@@ -240,6 +257,22 @@ impl PlanReviewGate {
}
}
+fn socket_tenant(
+ profile_id: Option<&str>,
+ ambient: Result<Tenant, crate::core::runtime::tenant::NoTenant>,
+ saas: bool,
+) -> Option<Tenant> {
+ if saas {
+ let profile = profile_id.filter(|profile| !profile.trim().is_empty())?;
+ Some(Tenant {
+ profile: Some(profile.to_owned()),
+ agent: None,
+ })
+ } else {
+ ambient.ok()
+ }
+}
+
/// Removes a parked review's registry entries on drop — covers both the normal
/// return and cancellation of the parked future.
struct ParkGuard<'a> {