Skip to content

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

docs: document saas mode and profile lease consumers

Steven Enamakel6505dab196db
diff --git a/crates/openhuman-core/src/storage/README.md b/crates/openhuman-core/src/storage/README.md
index a79df0e40e..d5897dd45a 100644
--- a/crates/openhuman-core/src/storage/README.md
+++ b/crates/openhuman-core/src/storage/README.md
@@ -94,6 +94,12 @@ reference model.
## Consumers
+- The SaaS profile host (`profiles::lease`, `profiles::registry`): one
+ lease per profile (`DocumentLeases` over the installed backend, else
+ `LocalLeases` under `<root>/users`) and the profile registry, collection
+ `profiles` in the same `cluster` scope. A lease taken over unclean runs
+ the profile's workspace recovery; a lost one fences the profile. See
+ `profiles/README.md`.
- The session store: `openhuman_rpc::session_store::install_for_host` opens
the configured backend before boot and installs `DriverSessionStores`
over it. See that module's README.
diff --git a/crates/openhuman-rpc/src/server/README.md b/crates/openhuman-rpc/src/server/README.md
index 4752c459c0..13e4439cd2 100644
--- a/crates/openhuman-rpc/src/server/README.md
+++ b/crates/openhuman-rpc/src/server/README.md
@@ -113,6 +113,44 @@ outermost to innermost:
The bearer is the per-launch RPC token the core owns
(`openhuman::core::auth`); [`auth.rs`](auth.rs) is only the route policy over it.
+### SaaS mode
+
+`run_server_saas` (`--mode saas --saas-config <file>`) boots the operator's
+config instead of a builder. Before boot it installs the session store for
+the operator's storage URL (`OPENHUMAN_STORAGE_URL`, else `storage_url`)
+through `session_store::install_for_saas`: the on-disk store with no URL,
+else `DriverSessionStores` over that backend with `recover_on_open(false)`,
+because a profile's turns are recovered when its lease is taken over, not
+when its stores open. On shutdown it releases the leases of idle profiles.
+
+In place of the single-context layer, [`saas_gateway.rs`](saas_gateway.rs)
+picks each request's context (the decision is
+`openhuman::profiles::gateway`):
+
+- routes a SaaS core never serves (`/v1`, `/events/*`, `/ws/*`,
+ `/socket.io`, `/dev/connect`, `/oauth/*`) answer `404`, and so does
+ `/events` without a user;
+- no `X-OpenHuman-User`: the operator plane;
+- with one: the bearer first (`401`), then a duplicate or unreadable header
+ (`400`), the signature (`401`), and the user's profile, which is opened
+ and leased: `403` when it is not provisioned, `503` when every slot is
+ busy or storage fails.
+
+A profile another core hosts answers **`409 Conflict`**:
+
+```text
+X-OpenHuman-Profile-Owner: <owner node id>
+
+{"error": "profile_held", "owner": "<node id>",
+ "endpoint": "<owner's advertise_url, or null>", "retry_after_ms": <ms>}
+```
+
+`endpoint` is where the owner can be reached (null for a node that
+advertises none) and `retry_after_ms` how long its lease lasts unless it is
+renewed. A gateway routes the user to the owner, or retries after that
+long; a dead owner's lease lapses within `lease_ttl_secs`. The refusal comes
+after the bearer check, so an unauthenticated caller learns nothing.
+
### A failed call
`rpc_handler` decodes the controller's `StructuredRpcError` (if any), then