Skip to content

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

docs(runtime): document saas operator plane and user_agents domain

Steven Enamakel23dd28f54cb0
diff --git a/crates/openhuman-core/src/core/runtime/README.md b/crates/openhuman-core/src/core/runtime/README.md
index afcfe8dd48..6b12a7c999 100644
--- a/crates/openhuman-core/src/core/runtime/README.md
+++ b/crates/openhuman-core/src/core/runtime/README.md
@@ -166,9 +166,28 @@ through `runtime/saas.rs`:
it never resolves `~/.openhuman` or an `active_user.toml`. The gateway
bearer is the RPC token.
-The SaaS presets are closed. `DomainSet::saas()` enables no domain family, so
-a SaaS core answers only its built-ins (`core.*`, `/health`, `/schema`) until
-each family's per-user isolation lands.
+The SaaS presets are closed. `DomainSet::saas()` enables only the operator
+plane (`DomainGroup::Operator`, the `user_agents.*` controllers), so a SaaS
+core answers its built-ins (`core.*`, `/health`, `/schema`) and provisioning,
+and nothing a user could reach, until each family's per-user isolation lands.
+`saas::build` installs the process's `user_agents::AgentHost`. Each open user
+agent runs under a context derived from the operator's, with its own forced
+config and `session_agent` (see `user_agents/README.md`).
+
+Two guards keep SaaS work from falling back to process-wide state:
+
+- **Config redirect.** In SaaS, `Config::load_or_init()` returns the config the
+ current context carries and fails outside any context
+ (`config/schema/load/saas_scope.rs`). It never resolves
+ `OPENHUMAN_WORKSPACE`, `active_user.toml` or `~/.openhuman`.
+- **Scoped spawns.** `runtime/spawn.rs`'s `spawn_scoped` /
+ `spawn_blocking_scoped` carry the caller's `CoreContext` and memory identity
+ into the spawned task. `scripts/ci/check-saas-ambient.mjs` (`pnpm
+ saas:ambient`) ratchets the bare spawns, direct `load_or_init` calls,
+ environment writes and `home_dir()` lookups that remain.
+
+`DomainSet` lives in `runtime/domain_set.rs` and `DomainGroup` in
+`core/domain_group.rs`. Both are re-exported from their old paths.
## Shared tokio tuning constants
diff --git a/crates/openhuman-core/src/user_agents/README.md b/crates/openhuman-core/src/user_agents/README.md
new file mode 100644
index 0000000000..e52b9021dd
--- /dev/null
+++ b/crates/openhuman-core/src/user_agents/README.md
@@ -0,0 +1,34 @@
+# user_agents
+
+In SaaS mode (`core::runtime::Mode::Saas`), each user is served as one agent.
+This domain maps a gateway user to that agent, lays out the agent's private
+state, forces the config it runs with, and keeps the open agents of the
+process. A single-user core never serves it: its controllers belong to
+`DomainGroup::Operator`, which only `DomainSet::saas()` enables.
+
+## Files
+
+| File | Purpose |
+| --- | --- |
+| `types.rs` | `UserAgentId` (`u-` + 32 hex chars of `sha256(user_id)`), its metadata, and the operator-plane result types |
+| `layout.rs` | `<root>/agents/<id>/{agent.toml, config.toml, workspace/, sandbox/}`, archived agents, and `agent_config`: the forced paths, memory binding and autonomy policy |
+| `host.rs` | `AgentHost`: provisioning, lazy open, LRU and idle eviction (never of an agent in use), each agent's derived `CoreContext`, `current()` |
+| `ops.rs` | `provision` / `deprovision` / `list` / `status`, returning `Outcome<T>` |
+| `schemas.rs` | The `user_agents.*` controllers |
+
+## Rules
+
+- **Gateway user ids never leave `ops.rs`.** They are hashed into an agent id
+ immediately and are never logged, stored or returned.
+- **An agent's config is forced, not configured.**
+ - Every path sits under the agent's directory.
+ - Memory is bound to the agent (`[memory] agent_id`, `root = user:<id>`).
+ That binding wins over definition pins and team roots.
+ - The autonomy policy is on and supervised, with no auto-approval, no tool
+ installation and no trusted roots.
+- **The isolation boundary is the agent's `CoreContext`.** It carries the forced
+ config and `session_agent = <id>`, and has no domain family or tool group of
+ its own yet. Work for a user runs under it, which is what the config loader,
+ the session store and the per-thread caches key on.
+- **Deprovisioning archives.** The agent's directory moves to
+ `<root>/deprovisioned/<id>-<unix-secs>/`. Nothing is deleted.