Skip to content

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

docs(readme): document core runtime and storage modules

Steven Enamakel5adec6d7dba8
diff --git a/crates/openhuman-core/src/core/runtime/README.md b/crates/openhuman-core/src/core/runtime/README.md
index fdde15f0cc..d9af8f12f1 100644
--- a/crates/openhuman-core/src/core/runtime/README.md
+++ b/crates/openhuman-core/src/core/runtime/README.md
@@ -181,7 +181,7 @@ plane, and a user's scope only the reviewed `USER_METHODS`.
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:
+Three 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
@@ -192,6 +192,21 @@ Two guards keep SaaS work from falling back to process-wide state:
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.
+ `CoreContext::propagate` follows the same rule in SaaS.
+- **The tenant key.** `runtime/tenant.rs`: a context derived with
+ `ContextOverlay::profile(id)` serves that SaaS profile, and
+ `current_tenant()` reads `Tenant { profile, agent }` from the task's own
+ scope only (`CoreContext::scoped`), failing closed with `NoTenant`
+ rather than falling back to the operator. Per-tenant state keys on it:
+ `tenant_key(&tenant, id)` (injective; the bare id on the desktop) for
+ in-process tables keyed by caller-chosen thread or session ids,
+ `session_key(&tenant)` for the host session store, and
+ `storage::scope_for_profile` for the storage backend. A profile gets
+ fresh state slots, `current_slot` hands an unscoped SaaS task a throwaway
+ slot, and `CoreContext::tenant_in_use()` reports whether turns still run
+ on a profile, so a host never evicts it mid-turn. The ratchet's
+ `ambient-context` rule baselines the `CoreContext::current()` and
+ `.session_agent()` reads that remain outside `core/runtime/`.
`DomainSet` lives in `runtime/domain_set.rs` and `DomainGroup` in
`core/domain_group.rs`. Both are re-exported from their old paths.
diff --git a/crates/openhuman-core/src/storage/README.md b/crates/openhuman-core/src/storage/README.md
index 14e34a43d4..f4187640ef 100644
--- a/crates/openhuman-core/src/storage/README.md
+++ b/crates/openhuman-core/src/storage/README.md
@@ -32,9 +32,12 @@ on `storage-mongodb`.
- `driver_is_shared(driver)` / `installed_is_shared()`: whether other
processes may write the same backend (MongoDB). Boot-time recovery, such
as the orphaned-run sweep, is skipped on a shared backend.
-- `current_scope()` / `current_scoped()`: the acting agent's scope (`local`
- on a single-user host; an error in SaaS mode with no acting agent) and the
- installed backend under it.
+- `scope_for_profile(profile_id)`: the scope a SaaS profile's records live
+ under (`profile:<id>`, hashed when that is not a valid scope).
+- `current_scope()` / `current_scoped()`: the tenant's scope — its profile's
+ when it serves one, else the acting agent's, else `local` on a single-user
+ host; an error in SaaS mode without a profile — and the installed backend
+ under it.
- `block_on(future)`: runs a storage future from synchronous store code on
one shared runtime thread.
- `documents::Repo` and `documents::compare_and_swap`: the base the domain