Skip to content

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

docs(storage): document storage engine ownership rules

Steven Enamakel3babcc9ac6e5
diff --git a/AGENTS.md b/AGENTS.md
index 6d69449ab3..861ae55cab 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -518,6 +518,31 @@ checked by `scripts/ci/check-feature-forwarding.mjs`. The same gate checks the
library chain: a core gate must be forwarded by `openhuman-embed`, then
`openhuman-tinyhumans`, then `openhuman-rpc`, then the `openhuman-cli` and
`openhuman-tui` hosts (each to `openhuman-rpc/<gate>`), or be listed in
+
+## Storage engine ownership
+
+tinystoragedrivers (`vendor/tinystoragedrivers`) is the only crate family that may
+depend on a storage engine. Engines (rusqlite, mongodb, aws-sdk-s3, lapin,
+object_store, sqlx, redb, sled, rocksdb, fs2, and their transitive deps) are
+reachable only from the following composition roots, which are the only
+packages listed in the ALLOWLIST in `scripts/ci/check-storage-owner.mjs`:
+
+ openhuman core storage domain (installs and owns the backend)
+ openhuman-app keyring secrets via rusqlite
+ openhuman-cli keyring secrets via rusqlite
+ openhuman-tui keyring secrets via rusqlite
+ openhuman-rpc keyring secrets via rusqlite
+ tinychannels iMessage chat.db reader (read-only SQLite)
+ tinybox-cli bin target, bundles engine
+ tinyjuice bin target, bundles engine
+
+Every other first-party crate must reach tinystoragedrivers only through
+`tinystoragedrivers-types`, `tinystoragedrivers-api`, `tinystoragedrivers-bus`
+or `tinystoragedrivers-busproxy`. The gate `node scripts/ci/check-storage-owner.mjs`
+walks the normal+build dependency closure of `--all-features` from every
+non-root first-party package and fails if it reaches an engine crate.
+Run in `pnpm rust:layout`.
+
`CHAIN_GATES_NOT_FORWARDED` / `CHAIN_LOCAL_GATES` with a reason. Test both enabled and disabled
builds after changing a gate. Use `scripts/assert-shed.sh` or
`scripts/dep-sim.py` before claiming a dependency reduction.
diff --git a/docs/gitbooks/en/developing/architecture/storage.md b/docs/gitbooks/en/developing/architecture/storage.md
index 9131bf1ddf..f9a1c26bf9 100644
--- a/docs/gitbooks/en/developing/architecture/storage.md
+++ b/docs/gitbooks/en/developing/architecture/storage.md
@@ -7,7 +7,7 @@ icon: database
# Storage
-OpenHuman keeps durable state on the ports of [`tinystoragedrivers`](https://github.com/tinyhumansai/tinystoragedrivers), vendored at `vendor/tinystoragedrivers` (v1.0.0). The host and every module declare it by git tag, and the root and app `[patch."https://github.com/tinyhumansai/tinystoragedrivers"]` tables redirect each of them onto that one checkout, so the build holds one copy. The vendored commit must stay semver-compatible with the tag modules declare; `scripts/ci/check-storage-owner.mjs` fails when any `tinystoragedrivers*` package resolves outside `vendor/tinystoragedrivers/`. One URL picks the backend for the whole process. The host adapter is `crates/openhuman-core/src/storage/`. It resolves the URL, opens the backend, holds it in a process slot and decides which scope a call runs in. The ports, the drivers and their conformance suites belong to `tinystoragedrivers`, and the typed records stay with the domain that owns them.
+OpenHuman keeps durable state on the ports of [`tinystoragedrivers`](https://github.com/tinyhumansai/tinystoragedrivers), vendored at `vendor/tinystoragedrivers`. The submodule ships a curated surface — types, API traits, bus contracts and the memory engine — plus separate engine crates enabled by feature flag. The root and app `[patch."https://github.com/tinyhumansai/tinystoragedrivers"]` tables redirect every declaration onto the one submodule checkout, so the build holds one copy. The vendored commit must stay semver-compatible with the tag modules declare; `scripts/ci/check-storage-owner.mjs` enforces two rules: (1) every `tinystoragedrivers*` package in the resolved graph is a path under `vendor/tinystoragedrivers/`, and (2) no non-root first-party crate reaches an engine crate (`rusqlite`, `mongodb`, `bson`, `aws-sdk-s3`, `aws-smithy-*`, `lapin`, `amq-protocol`, `object_store`, `sqlx`, `redb`, `sled`, `rocksdb`, `fs2`) through any normal or build dependency. The reasoned allowlist covers composition roots only (`openhuman`, `openhuman-app`, `openhuman-cli`, `openhuman-tui`, `openhuman-rpc`, `tinychannels`, `tinybox-cli`, `tinyjuice`). One URL picks the backend for the whole process. The host adapter is `crates/openhuman-core/src/storage/`. It resolves the URL, opens the backend, holds it in a process slot and decides which scope a call runs in. The ports, the drivers and their conformance suites belong to `tinystoragedrivers`, and the typed records stay with the domain that owns them.
With no URL configured, which is the desktop default, the host opens `sqlite:<workspace>/storage` and installs it. The URL decides where the whole process keeps its state, and there is no second layout: older installs' per-domain databases, transcripts and turn-state files are imported once, read-only, when the backend is installed. The files that remain outside the ports are listed under "What is not on the ports yet" below.