The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/modules/README.md
Steven Enamakel298407b206e7
diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.mdnew file mode 100644index 0000000000..46564cf24f--- /dev/null+++ b/crates/openhuman-core/src/modules/README.md@@ -0,0 +1,123 @@+# modules++The native loadable-module host. A module is a first-party `cdylib` — `tinydocs`,+`tinywallet`, `tinymemory`, `tinyjuice`, `tinyvoice`, `tinyruntime` (++`tinyruntime-nodejs` / `tinyruntime-python`), `tinymcp`, `tinyconnectors` — that+speaks the tinybus module ABI. It is downloaded from a pinned GitHub release,+verified against a digest compiled into [`registry.rs`](registry.rs), admitted+through tinybus's ABI/manifest gates, and attached to a private in-process+broker as an ordinary bus peer. The core then calls it like any other service.+See [`mod.rs`](mod.rs)'s own `//!` for the full "what this buys, what it costs"+argument; this file is the navigation layer over it.++Feature-gated as `modules`, and unusually load-bearing for a feature: it is ON+in both the contributor default set and the shipped product set, because the+memory subsystem's module-backed driver is not optional at test time (see the+Cargo.toml comment beside `modules = ["tinybus/modules"]`). `documents`,+`web3`, and `voice` each turn a per-module host half on inside this directory+(`documents.rs`, `wallet.rs`, `voice.rs`) but do not gate the directory itself.++## Layout++| Path | Purpose |+| --- | --- |+| `mod.rs` | Crate-level rustdoc for the whole loading model; re-exports |+| `registry.rs` (+ `registry_part_01.rs`, `registry_part_02.rs`) | The compiled-in table: every `ModuleRecord`, its per-platform digests, and `find`/`ALL` |+| `platform.rs` | Which published artifact (`ubuntu-24.04-x86_64`, `macos-15-arm64`, ...) belongs to this host, newest-compatible first |+| `types.rs` | `LoadPolicy`, `ModuleRecord`, `ModuleSource`, `ModuleState`, `ModuleStatus`, `PlatformAsset` |+| `host.rs` | The module broker: a dedicated process-lifetime tokio runtime, its `ModuleHost`, and the host's own `Connection` for calling into loaded modules |+| `resolution.rs` | One resolution slot per module id, replacing a single global lock so unrelated modules never queue behind each other |+| `ops.rs` | `ensure_loaded` / `ensure_loaded_within` / `state_of` / `LoadError`; the release cache under `install_dir`; failure caching |+| `boot.rs` | What loads at startup: search-path artifacts, then every `LoadPolicy::Eager` record — deliberately not every registry entry |+| `schemas.rs` | The `modules` RPC namespace (`list`, `status`, `load`) |+| `documents.rs` | Host half of `tinydocs` (feature `documents`): the three document operations |+| `wallet.rs` | Host half of `tinywallet` (feature `web3`): confidential and split transaction-signing flows |+| `voice.rs` | Host half of `tinyvoice` (feature `voice`): the voice primitives |+| `memory.rs` (+ `memory_part_01..04.rs`) | `ModuleMemoryProvider`, forwarding `MemoryProvider` calls to the loaded `tinymemory` module via `tinymemory-api` |+| `memory_host.rs` | Host-owned callbacks served *to* the TinyMemory module (embedding, chat compute, event publishing, Composio); sole survivor of the `host_impls` pair after the in-process engine left (openhuman#6161) |+| `runtime.rs` | Host half of `tinyruntime`: resolving a language runtime (via `tinyruntime-nodejs`/`-python`) and running code on it |+| `connectors.rs` | Reaching `tinyconnectors`; egress policy, route selection, and webhook delivery stay in this crate even though scope enforcement moved into the module |+| `tokenjuice_host.rs` | Host-owned ML callback served to the `tinyjuice` module |+| `*_tests.rs` | Focused tests beside each file above |++## Loading pipeline++1. `registry::find(id)` looks up the compiled-in `ModuleRecord`.+2. `resolution::table().claim(id)` gives the caller `Run`, `Wait`, or `Done` —+ the first caller for a module resolves it as a process-lifetime task;+ everyone else waits on a watch channel (`ops.rs`).+3. Resolution order is cheapest first: already serving on the host's broker,+ a developer's `modules.overrides` (or a `*_TEST_MODULE` env var), the+ module search path (`OPENHUMAN_MODULE_PATH`, then platform data dirs), then+ the release cache.+4. `platform::host_candidates()` picks the ordered list of artifact keys this+ host can run; `ops::load_cached` tries each until one is admitted.+5. The release cache downloads (if `modules.allow_download`), verifies the+ archive's SHA-256 against the digest pinned in `registry.rs`, extracts, and+ `dlopen`s — all off the module runtime's worker thread so a cold download+ never stalls another task.+6. tinybus's ABI descriptor, manifest, and digest gates decide whether the+ artifact is *admitted*; a faulted or refused module is cached as+ `LoadError::Failed` and never retried in this process — restart is the only+ recovery, because tinybus never unloads a library.++`boot::load_declared_modules` runs steps 3–6 at startup only for search-path+artifacts and `LoadPolicy::Eager` records (currently `tinymemory`, when the+memory driver actually selected the module-backed binding). Everything else is+`LoadPolicy::Lazy` and resolves on first `ensure_loaded` call — deliberately+not eager, so a user who never touches a feature never pays its download.++## Contract crates++Each loadable module has a small `*-bus` contract crate for interface names,+method constants, request/response types, and its contract version:++| Contract | Feature or role |+| --- | --- |+| `tinydocs-bus` | `documents` |+| `tinyvoice-bus` | `voice` |+| `tinyjuice-bus` | inference kernel |+| `tinyruntime-bus` | runtime clients |+| `tinywallet-bus` | `web3` |+| `tinymcp-bus` | `mcp` |+| `tinychannels-bus` | channel vocabulary |+| `tinymemory-api` | memory (selectively re-exported as `crate::memory::api`, not copied or widened) |++Rules: never redeclare a contract type in OpenHuman; call members through+contract constants, not string literals; contract crates stay synchronous and+free of I/O and runtime dependencies; shared wire behavior belongs in the+contract, runtime/config/security policy stays in this host.++## Security and operational invariants++A loaded module shares this process's address space, privileges, and crash+domain — it is first-party code that happens to ship separately, not a+sandbox boundary. From `AGENTS.md`, do not weaken these:++- Only the compiled registry (`registry.rs`) may select which artifacts can+ load. There is no RPC method to name an arbitrary path.+- Pin release checksums verbatim from the release's own `checksum.toml`. Never+ compute a replacement digest from a local build — that would make the check+ agree with whatever was served instead of with what the release published.+- Keep the ABI, manifest, dependency, and digest admission checks intact.+- Never unload or repeatedly retry a faulted module in the same process; a+ refused or crashed module is terminal until restart.+- Untrusted code belongs in a separate process, not in a module.+- Never enable the `modules` feature directly on the unconditional `tinybus`+ dependency; forward it from OpenHuman's own `modules` feature+ (`modules = ["tinybus/modules"]`), so a `--no-default-features` build without+ `modules` does not pull in tinybus's loader.+- Initialize recursive submodules before building:+ `git submodule update --init --recursive vendor/`.++## Used by++- `crate::runtime::client` — the ungated facade over+ [`crate::modules::runtime`] for resolving/calling `tinyruntime`.+- `memory::binding` — binds `ModuleMemoryProvider` when the memory driver+ selects the module-backed class.+- `core::all::all_registered_controllers` — wires the `modules` RPC namespace+ (`crate::modules::all_registered_controllers()`).+- `config::schema::modules::ModulesConfig` — `enabled`, `allow_download`,+ `install_dir`, and `overrides` control only whether the compiled-in modules+ in this directory load, never what is loadable.