Skip to content

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

Merge remote-tracking branch 'upstream/main' into saas-phase4a

Steven Enamakela735c1c8fb16
diff --cc crates/openhuman-core/src/core/all.rs
index f764f1a218,5252cd3ffc..34ebda32e9
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@@ -83,19 -83,9 +83,19 @@@ fn active_domain_set() -> Option<crate:
/// (full, no filter) so pre-boot unit tests and non-context callers see every
/// domain, exactly as before #4796.
fn group_allowed(group: DomainGroup) -> bool {
- active_domain_set().is_none_or(|s| s.allows(group))
+ active_domain_set().map_or(group != DomainGroup::Operator, |s| s.allows(group))
}
+/// Whether `g` is live in the ambient scope: its family is enabled and, for a
+/// 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(),
+ g.group == DomainGroup::Operator,
+ )
+}
+
/// The global static registry of all controllers, initialized once on first access.
static REGISTRY: OnceLock<Vec<GroupedController>> = OnceLock::new();
diff --cc tests/saas_mode_e2e.rs
index 89d3256fd7,6646a68230..06e45bc10c
--- a/tests/saas_mode_e2e.rs
+++ b/tests/saas_mode_e2e.rs
@@@ -422,90 -424,38 +436,126 @@@ fn gateway_requests_run_under_the_named
drop(server);
}
+fn provision(client: &reqwest::blocking::Client, base: &str, user: &str) -> String {
+ let (_, body) = rpc_with(
+ client,
+ base,
+ Some(BEARER),
+ "openhuman.user_agents_provision",
+ json!({ "user_id": user }),
+ );
+ assert!(body.get("result").is_some(), "provision {user}: {body}");
+ openhuman_core::user_agents::UserAgentId::for_user(user)
+ .unwrap()
+ .to_string()
+}
+
+fn thread_ids(body: &Value) -> Vec<String> {
+ let text = body.to_string();
+ let mut ids = Vec::new();
+ for part in text.split("\"id\":\"").skip(1) {
+ if let Some(end) = part.find('"') {
+ ids.push(part[..end].to_string());
+ }
+ }
+ ids
+}
+
+#[test]
+fn each_user_sees_only_their_own_threads() {
+ let d = deployment(true);
+ let (server, base, client) = start(&d);
+ let alice = provision(&client, &base, "alice");
+ let bob = provision(&client, &base, "bob");
+ let call = |user: &str, method: &str, params: Value| {
+ user_rpc_with(&client, &base, BEARER, user, None, method, params)
+ };
+
+ let (status, body) = call("alice", "openhuman.threads_create_new", json!({}));
+ assert_eq!(status, 200, "{body}");
+ assert!(body.get("result").is_some(), "{body}");
+
+ // The same caller-chosen id in two users' scopes is two threads.
+ for user in ["alice", "bob"] {
+ let (_, body) = call(
+ user,
+ "openhuman.threads_upsert",
+ json!({ "id": "shared-id", "title": format!("{user}'s"), "created_at": "2026-10-07T00:00:00Z" }),
+ );
+ assert!(body.get("result").is_some(), "{user} upsert: {body}");
+ }
+
+ let (_, alice_list) = call("alice", "openhuman.threads_list", json!({}));
+ let (_, bob_list) = call("bob", "openhuman.threads_list", json!({}));
+ let alice_ids = thread_ids(&alice_list);
+ let bob_ids = thread_ids(&bob_list);
+ assert_eq!(alice_ids.len(), 2, "alice: {alice_list}");
+ assert_eq!(bob_ids, vec!["shared-id".to_string()], "bob: {bob_list}");
+ assert!(bob_list.to_string().contains("bob's"), "{bob_list}");
+ assert!(!bob_list.to_string().contains("alice's"), "{bob_list}");
+
+ // Each user's threads live in their own workspace.
+ for (agent, owner) in [(&alice, "alice"), (&bob, "bob")] {
+ let threads = d.root.join("agents").join(agent).join("workspace");
+ assert!(threads.is_dir(), "{owner}'s workspace");
+ }
+ // Boot migrations leave an empty index in the operator workspace; no user
+ // thread may ever reach it.
+ let operator_index = d
+ .root
+ .join("operator/workspace/memory/conversations/threads.jsonl");
+ let operator_threads = std::fs::read_to_string(&operator_index).unwrap_or_default();
+ assert!(
+ !operator_threads.contains("shared-id") && operator_threads.trim().is_empty(),
+ "no user thread lands in the operator workspace: {operator_threads}"
+ );
+
+ // Reserved and path-like ids are refused; turn-starting methods are closed.
+ for id in ["channel:telegram/1", "../escape"] {
+ let (_, body) = call(
+ "alice",
+ "openhuman.threads_upsert",
+ json!({ "id": id, "title": "x", "created_at": "2026-10-07T00:00:00Z" }),
+ );
+ assert!(body.get("error").is_some(), "{id}: {body}");
+ }
+ let (_, body) = call("alice", "openhuman.threads_regenerate", json!({}));
+ assert!(body.get("error").is_some(), "{body}");
+ drop(server);
+}
++
+ #[test]
+ fn a_duplicate_or_unreadable_user_header_is_refused() {
+ use openhuman_core::user_agents::gateway::USER_HEADER;
+ let d = deployment(true);
+ let (server, base, client) = start(&d);
+ let body =
+ json!({ "jsonrpc": "2.0", "id": 1, "method": "openhuman.user_agents_list", "params": {} });
+
+ // Two user headers: refused, never run as the operator.
+ let status = client
+ .post(format!("{base}/rpc"))
+ .bearer_auth(BEARER)
+ .header(USER_HEADER, "alice")
+ .header(USER_HEADER, "bob")
+ .json(&body)
+ .send()
+ .unwrap()
+ .status()
+ .as_u16();
+ assert_eq!(status, 400);
+
+ // A header value that is valid HTTP but not text: refused too.
+ let unreadable = reqwest::header::HeaderValue::from_bytes(b"alice\xff").unwrap();
+ let status = client
+ .post(format!("{base}/rpc"))
+ .bearer_auth(BEARER)
+ .header(USER_HEADER, unreadable)
+ .json(&body)
+ .send()
+ .unwrap()
+ .status()
+ .as_u16();
+ assert_eq!(status, 400);
+ drop(server);
+ }