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
fix(user_agents): keep saas operator and user planes disjoint
Steven Enamakelf9a269dd773d
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 720027a12c..f764f1a218 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -90,7 +90,10 @@ fn group_allowed(group: DomainGroup) -> bool {/// SaaS user, the method is on the user surface (`user_agents::surface`).fn visible(g: &GroupedController) -> bool {group_allowed(g.group)- && crate::user_agents::surface::method_visible(&g.controller.rpc_method_name())+ && crate::user_agents::surface::method_visible(+ &g.controller.rpc_method_name(),+ g.group == DomainGroup::Operator,+ )}/// The global static registry of all controllers, initialized once on first access.diff --git a/crates/openhuman-core/src/core/runtime/saas.rs b/crates/openhuman-core/src/core/runtime/saas.rsindex 4eec2f38dd..0c91a13d65 100644--- a/crates/openhuman-core/src/core/runtime/saas.rs+++ b/crates/openhuman-core/src/core/runtime/saas.rs@@ -139,11 +139,14 @@ impl ServiceSet {}impl DomainSet {- /// The domain families a SaaS core serves: the operator plane. No user- /// family yet; each opens as its per-user isolation lands.+ /// The domain families a SaaS core registers: the operator plane and the+ /// user families whose per-user isolation has landed. User agents derive+ /// their contexts from these; `user_agents::surface` keeps the operator+ /// scope on its own plane and each user on the user allowlist.pub fn saas() -> Self {Self {operator: true,+ threads: true,..Self::none()}}diff --git a/crates/openhuman-core/src/core/runtime/saas_tests.rs b/crates/openhuman-core/src/core/runtime/saas_tests.rsindex 27b2818c63..aba413be44 100644--- a/crates/openhuman-core/src/core/runtime/saas_tests.rs+++ b/crates/openhuman-core/src/core/runtime/saas_tests.rs@@ -86,9 +86,10 @@ fn the_saas_presets_are_closed() {DomainSet::saas(),DomainSet {operator: true,+ threads: true,..DomainSet::none()},- "only the operator plane until user families are isolated"+ "the operator plane plus the user families isolated so far");let services = ServiceSet::saas();assert!(services.rpc_http);diff --git a/crates/openhuman-core/src/user_agents/surface.rs b/crates/openhuman-core/src/user_agents/surface.rsindex 8fa2a939d2..d1255d3575 100644--- a/crates/openhuman-core/src/user_agents/surface.rs+++ b/crates/openhuman-core/src/user_agents/surface.rs@@ -39,8 +39,9 @@ pub const USER_METHODS: &[&str] = &["openhuman.threads_todos_get",];-/// Whether `method` may be dispatched or listed in the current scope.-pub fn method_visible(method: &str) -> bool {+/// Whether `method` (of an operator-plane controller or not) may be+/// dispatched or listed in the current scope.+pub fn method_visible(method: &str, operator_plane: bool) -> bool {visible_in(is_saas(),CoreContext::current()@@ -48,13 +49,23 @@ pub fn method_visible(method: &str) -> bool {.and_then(CoreContext::session_agent).is_some(),method,+ operator_plane,)}-/// [`method_visible`] as a pure function of the mode and whether the scope is-/// a user's.-pub fn visible_in(saas: bool, user_scope: bool, method: &str) -> bool {- !(saas && user_scope) || USER_METHODS.contains(&method)+/// [`method_visible`] as a pure function of the mode and the scope.+///+/// In SaaS the two planes never overlap: the operator scope reaches only the+/// operator plane, and a user's scope only [`USER_METHODS`]. The SaaS+/// `DomainSet` registers the user families on the runtime so user contexts+/// can derive them; this keeps the operator from serving them on its own+/// workspace.+pub fn visible_in(saas: bool, user_scope: bool, method: &str, operator_plane: bool) -> bool {+ match (saas, user_scope) {+ (false, _) => true,+ (true, false) => operator_plane,+ (true, true) => !operator_plane && USER_METHODS.contains(&method),+ }}/// Thread ids a user may choose for themselves. Ids are only unique per agent,diff --git a/crates/openhuman-core/src/user_agents/surface_tests.rs b/crates/openhuman-core/src/user_agents/surface_tests.rsindex c2db376556..45c7c9197f 100644--- a/crates/openhuman-core/src/user_agents/surface_tests.rs+++ b/crates/openhuman-core/src/user_agents/surface_tests.rs@@ -1,13 +1,21 @@use super::*;#[test]-fn only_a_saas_user_scope_is_narrowed() {+fn single_user_processes_are_not_narrowed() {let unlisted = "openhuman.config_update_autonomy_settings";- assert!(visible_in(false, false, unlisted), "single-user core");- assert!(visible_in(false, true, unlisted), "embedded agent");- assert!(visible_in(true, false, unlisted), "operator plane");- assert!(!visible_in(true, true, unlisted), "SaaS user");- assert!(visible_in(true, true, "openhuman.threads_list"));+ assert!(visible_in(false, false, unlisted, false), "single-user core");+ assert!(visible_in(false, true, unlisted, false), "embedded agent");+}++#[test]+fn the_saas_planes_never_overlap() {+ let provision = "openhuman.user_agents_provision";+ let threads = "openhuman.threads_list";+ assert!(visible_in(true, false, provision, true), "operator reaches its plane");+ assert!(!visible_in(true, false, threads, false), "operator never serves user methods");+ assert!(visible_in(true, true, threads, false), "user reaches the allowlist");+ assert!(!visible_in(true, true, provision, true), "user never reaches the operator plane");+ assert!(!visible_in(true, true, "openhuman.config_get_config", false));}#[test]@@ -17,7 +25,7 @@ fn turn_starting_thread_methods_stay_closed_for_now() {"openhuman.threads_edit_message","openhuman.threads_regenerate",] {- assert!(!visible_in(true, true, method), "{method}");+ assert!(!visible_in(true, true, method, false), "{method}");}}