Skip to content

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

docs: add README files for core modules

Steven Enamakel94c78df53e71
diff --git a/crates/openhuman-core/src/skills/webhooks/README.md b/crates/openhuman-core/src/skills/webhooks/README.md
index 8e1e294dde..44585209a4 100644
--- a/crates/openhuman-core/src/skills/webhooks/README.md
+++ b/crates/openhuman-core/src/skills/webhooks/README.md
@@ -2,7 +2,7 @@
Client-side webhook **tunnel routing** for OpenHuman. The backend provisions and hosts the actual tunnels (ngrok / cloudflare / etc.) and forwards incoming HTTP requests to the app over Socket.IO; this module maps each backend tunnel UUID to its owning target (a skill, the built-in echo responder, or the agent triage pipeline), dispatches incoming requests, builds responses, captures debug logs, and exposes both local routing RPCs and thin proxies to the backend's tunnel-management API.
-`webhooks` is nested under `skills/` for historical reasons but is **not** gated by the `skills` Cargo feature — it has always-compiled callers in `crates/openhuman-core/src/core/` and stays outside the `skills` feature gate (see `crates/openhuman-core/src/skills/mod.rs`).
+`webhooks` is nested under `skills/` for historical reasons but is **not** gated by the `skills` Cargo feature: it has always-compiled callers in `crates/openhuman-core/src/core/` and stays outside the `skills` feature gate (see `crates/openhuman-core/src/skills/mod.rs`).
## Responsibilities
@@ -19,10 +19,10 @@ Client-side webhook **tunnel routing** for OpenHuman. The backend provisions and
| --- | --- |
| `crates/openhuman-core/src/skills/webhooks/mod.rs` | Export-only: module docstring, `pub mod` decls, re-exports of `WebhookRouter`, types, and the `all_webhooks_*` controller pair. |
| `crates/openhuman-core/src/skills/webhooks/types.rs` | Serde domain types: `WebhookRequest`, `WebhookResponseData`, `TunnelRegistration`, `WebhookActivityEntry`, `WebhookDebugLogEntry`, debug result wrappers, `WebhookDebugEvent`. |
-| `crates/openhuman-core/src/skills/webhooks/router.rs` | `WebhookRouter` — route map + ownership rules, disk persistence (generation-counter, spawn_blocking offload), bounded debug log ring (`MAX_DEBUG_LOG_ENTRIES = 250`), debug-event broadcast channel. |
+| `crates/openhuman-core/src/skills/webhooks/router.rs` | `WebhookRouter`: route map + ownership rules, disk persistence (generation-counter, spawn_blocking offload), bounded debug log ring (`MAX_DEBUG_LOG_ENTRIES = 250`), debug-event broadcast channel. |
| `crates/openhuman-core/src/skills/webhooks/ops.rs` | RPC handler logic returning `RpcOutcome<T>`: local routing ops (`list_registrations`, `list_logs`, `clear_logs`, `register_echo`, `unregister_echo`, `register_agent`, `trigger_agent`), `build_echo_response`, and backend-proxied tunnel CRUD (`list/create/get/update/delete_tunnel`, `get_bandwidth`). |
| `crates/openhuman-core/src/skills/webhooks/schemas.rs` | Controller schemas + `handle_*` fns + `all_controller_schemas` / `all_registered_controllers`; deserializes params, delegates to `ops.rs`. |
-| `crates/openhuman-core/src/skills/webhooks/bus.rs` | `WebhookRequestSubscriber` (`EventHandler`) — the incoming-request routing flow; helpers `decode_webhook_body`, `run_agent_trigger`, `build_agent_response`. |
+| `crates/openhuman-core/src/skills/webhooks/bus.rs` | `WebhookRequestSubscriber` (`EventHandler`): the incoming-request routing flow; helpers `decode_webhook_body`, `run_agent_trigger`, `build_agent_response`. |
| `crates/openhuman-core/src/skills/webhooks/{webhooks_tests,bus_tests,ops_tests,router_tests,schemas_tests,types_tests}.rs` | Test suites, each pulled into its sibling source file via `#[cfg(test)] #[path = "..."] mod tests;` (no inline test modules). |
## Public surface
@@ -63,10 +63,10 @@ None. This domain owns no `tools.rs` agent tools.
## Events
-Subscriber (in `bus.rs`): **`WebhookRequestSubscriber`** — `name() = "webhook::request_handler"`, `domains() = ["webhook"]`. Registered in `register_domain_subscribers()` (`crates/openhuman-core/src/core/jsonrpc.rs`, called from `bootstrap_core_runtime()`), gated on the `Skills` domain group being enabled (`plan.skills`) and installed at most once per process; `channels/runtime/startup/start_channels.rs` deliberately does not register it, to avoid double-registration when both startup paths run in the same process.
+Subscriber (in `bus.rs`): **`WebhookRequestSubscriber`**: `name() = "webhook::request_handler"`, `domains() = ["webhook"]`. Registered in `register_domain_subscribers()` (`crates/openhuman-core/src/core/jsonrpc.rs`, called from `bootstrap_core_runtime()`), gated on the `Skills` domain group being enabled (`plan.skills`) and installed at most once per process; `channels/runtime/startup/start_channels.rs` deliberately does not register it, to avoid double-registration when both startup paths run in the same process.
-- **Subscribes**: `DomainEvent::WebhookIncomingRequest` (published by the socket transport in `socket/event_handlers.rs`).
-- **Publishes**: `DomainEvent::WebhookRegistered` / `WebhookUnregistered` (from the router on registration changes — `WebhookUnregistered`, the `registration_changed` debug event and the route re-persist all fire **only when a registration was actually removed**; unregistering an absent tunnel is a silent no-op that returns `Ok(false)`, see #6091), `DomainEvent::WebhookReceived` (when routed to a target), `DomainEvent::WebhookProcessed` (always, with status/elapsed/error).
+- Subscribes: `DomainEvent::WebhookIncomingRequest` (published by the socket transport in `socket/event_handlers.rs`).
+- Publishes: `DomainEvent::WebhookRegistered` / `WebhookUnregistered` (from the router on registration changes: `WebhookUnregistered`, the `registration_changed` debug event and the route re-persist all fire **only when a registration was actually removed**; unregistering an absent tunnel is a silent no-op that returns `Ok(false)`, see #6091), `DomainEvent::WebhookReceived` (when routed to a target), `DomainEvent::WebhookProcessed` (always, with status/elapsed/error).
Routing outcomes by `target_kind`: `echo` → `build_echo_response` (200); `agent` → decode body, spawn triage, return `202 Accepted` (spawned task emits the real response later, with 60s timeout → 504); `skill` / unknown → `501` (direct skill dispatch not available); no registration → `404`. Responses are emitted over the socket as `webhook:response`.
@@ -74,35 +74,35 @@ The router also runs a separate `tokio::sync::broadcast` channel of `WebhookDebu
## Persistence
-`WebhookRouter` serializes its registrations to a JSON file (`PersistedRoutes`) at the optional `persist_path` passed to `new()`, and reloads them from that file when constructed. Writes are best-effort and fire-and-forget: offloaded to `spawn_blocking` inside a tokio runtime (inline otherwise), guarded by a monotonic generation counter so stale writes under rapid churn are dropped. Debug logs are **not** persisted — they live only in an in-memory `VecDeque` capped at 250 entries.
+`WebhookRouter` serializes its registrations to a JSON file (`PersistedRoutes`) at the optional `persist_path` passed to `new()`, and reloads them from that file when constructed. Writes are best-effort and fire-and-forget: offloaded to `spawn_blocking` inside a tokio runtime (inline otherwise), guarded by a monotonic generation counter so stale writes under rapid churn are dropped. Debug logs are **not** persisted: they live only in an in-memory `VecDeque` capped at 250 entries.
Note that nothing in the production startup path currently constructs a `WebhookRouter` or calls `SocketManager::set_webhook_router`; the only caller is `tests/raw_coverage/webhooks_ingress_e2e.rs`. Until a router is attached, the local RPCs return empty results (see above) and the subscriber answers every incoming request with `404`.
## Dependencies
-- `crate::core::bus::BUS` and `crate::core::events::DomainEvent` — publishing and subscribing; the `EventHandler` trait comes from `tinybus`.
-- `crate::core::all` — `ControllerFuture`, `RegisteredController` for controller registration.
-- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` — RPC schema types.
-- `crate::core::observability::report_error` — error reporting for body-decode / agent-trigger failures.
-- `crate::platform::socket::global_socket_manager` — obtain the `WebhookRouter` (stored on the socket manager) and `emit` responses over the socket.
-- `crate::agent::triage` — `TriggerEnvelope`, `run_triage`, `apply_decision`, `TriageOutcome` for agent-tunnel routing and `trigger_agent`.
-- `crate::config::{Config, rpc::load_config_with_timeout}` — config for backend-proxy RPCs.
-- `crate::api::{BackendOAuthClient, config::effective_backend_api_url, jwt::get_session_token}` — authenticated backend tunnel CRUD/bandwidth calls.
-- `crate::rpc::RpcOutcome` — handler return contract.
+- `crate::core::bus::BUS` and `crate::core::events::DomainEvent`: publishing and subscribing; the `EventHandler` trait comes from `tinybus`.
+- `crate::core::all`: `ControllerFuture`, `RegisteredController` for controller registration.
+- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`: RPC schema types.
+- `crate::core::observability::report_error`: error reporting for body-decode / agent-trigger failures.
+- `crate::platform::socket::global_socket_manager`: obtain the `WebhookRouter` (stored on the socket manager) and `emit` responses over the socket.
+- `crate::agent::triage`: `TriggerEnvelope`, `run_triage`, `apply_decision`, `TriageOutcome` for agent-tunnel routing and `trigger_agent`.
+- `crate::config::{Config, rpc::load_config_with_timeout}`: config for backend-proxy RPCs.
+- `crate::api::{BackendOAuthClient, config::effective_backend_api_url, jwt::get_session_token}`: authenticated backend tunnel CRUD/bandwidth calls.
+- `crate::rpc::RpcOutcome`: handler return contract.
## Used by
-- `crates/openhuman-core/src/core/all.rs` — registers the controllers/schemas into the RPC registry.
-- `crates/openhuman-core/src/platform/socket/manager.rs` — stores the `WebhookRouter` (`set_webhook_router` / `webhook_router`) on the socket manager; ops/bus retrieve it from there.
-- `crates/openhuman-core/src/platform/socket/event_handlers.rs` — publishes `WebhookIncomingRequest` from the socket and reads the shared router slot.
-- `crates/openhuman-core/src/core/jsonrpc.rs` — registers `WebhookRequestSubscriber` in `register_domain_subscribers()` and provides the RPC transport surface.
-- `crates/openhuman-core/src/core/events.rs` — defines the `Webhook*` `DomainEvent` variants this module uses.
+- `crates/openhuman-core/src/core/all.rs`: registers the controllers/schemas into the RPC registry.
+- `crates/openhuman-core/src/platform/socket/manager.rs`: stores the `WebhookRouter` (`set_webhook_router` / `webhook_router`) on the socket manager; ops/bus retrieve it from there.
+- `crates/openhuman-core/src/platform/socket/event_handlers.rs`: publishes `WebhookIncomingRequest` from the socket and reads the shared router slot.
+- `crates/openhuman-core/src/core/jsonrpc.rs`: registers `WebhookRequestSubscriber` in `register_domain_subscribers()` and provides the RPC transport surface.
+- `crates/openhuman-core/src/core/events.rs`: defines the `Webhook*` `DomainEvent` variants this module uses.
## Notes / gotchas
-- **Direct skill dispatch is not implemented**: a `skill`-kind tunnel returns `501`. Real handling exists only for `echo` and `agent` kinds (the QuickJS skill runtime was removed; see `gitbooks/developing/architecture.md`).
+- Direct skill dispatch is not implemented: a `skill`-kind tunnel returns `501`. Real handling exists only for `echo` and `agent` kinds (the QuickJS skill runtime was removed; see `gitbooks/developing/architecture.md`).
- `route()` deliberately resolves only `target_kind == "skill"` registrations; echo/agent registrations are matched via `registration()` in the bus, not `route()`.
-- Agent tunnels respond `202` immediately and complete asynchronously — the spawned task emits the final `webhook:response` itself to avoid blocking the broadcast dispatch task during LLM calls.
+- Agent tunnels respond `202` immediately and complete asynchronously: the spawned task emits the final `webhook:response` itself to avoid blocking the broadcast dispatch task during LLM calls.
- `register_agent` stores `agent_id` for observability and rebind validation only; per the docstring the triage evaluator selects the target agent dynamically regardless of the pinned value.
- Persistence is fire-and-forget and may not flush before process exit; a lost write only replays the most recent registration change on next startup.
- `decode_webhook_body` returns `{}` for empty bodies and wraps non-JSON-but-valid-UTF-8 bodies under a `"raw"` key; invalid base64 is a hard error (→ 400).
diff --git a/crates/openhuman-core/src/test_support/README.md b/crates/openhuman-core/src/test_support/README.md
index 53174d97cd..91065c9f0c 100644
--- a/crates/openhuman-core/src/test_support/README.md
+++ b/crates/openhuman-core/src/test_support/README.md
@@ -1,6 +1,6 @@
# test_support
-Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E2E specs drive the in-process core between tests without restarting the process. `openhuman.test_reset` returns the running core to a fresh-install baseline; the `test_support.*` introspection RPCs let specs verify that a UI action actually flowed through to disk and to live Rust state (workspace tree, files, the `IN_FLIGHT` chat map, wallet prepared quotes). Everything here is gated behind the `/rpc` bearer token (only written in debug builds) and, for the destructive reset, an explicit `OPENHUMAN_E2E_MODE` env flag — so it is effectively unreachable in release.
+Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E2E specs drive the in-process core between tests without restarting the process. `openhuman.test_reset` returns the running core to a fresh-install baseline; the `test_support.*` introspection RPCs let specs verify that a UI action actually flowed through to disk and to live Rust state (workspace tree, files, the `IN_FLIGHT` chat map, wallet prepared quotes). Everything here is gated behind the `/rpc` bearer token (only written in debug builds) and, for the destructive reset, an explicit `OPENHUMAN_E2E_MODE` env flag: so it is effectively unreachable in release.
## Responsibilities
@@ -15,7 +15,7 @@ Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E
| File | Role |
| --- | --- |
| `crates/openhuman-core/src/test_support/mod.rs` | Export-only module: declares `introspect`, `rpc`, `schemas`; re-exports `all_test_support_controller_schemas` / `all_test_support_registered_controllers`. |
-| `crates/openhuman-core/src/test_support/rpc.rs` | `openhuman.test_reset` implementation — `reset()` wipes cron, memory tree, config fields, and active user; returns a `ResetSummary`. Includes the `OPENHUMAN_E2E_MODE` guard. |
+| `crates/openhuman-core/src/test_support/rpc.rs` | `openhuman.test_reset` implementation: `reset()` wipes cron, memory tree, config fields, and active user; returns a `ResetSummary`. Includes the `OPENHUMAN_E2E_MODE` guard. |
| `crates/openhuman-core/src/test_support/rpc_tests.rs` | Tests for the `OPENHUMAN_E2E_MODE` guard (`reset` rejects when unset; `1`/`true`/`yes` accepted) and for `wipe_memory_tree` removing content dirs. |
| `crates/openhuman-core/src/test_support/introspect.rs` | Read-only introspection RPCs: `workspace_root`, `list_workspace_files`, `read_workspace_file`, `in_flight_chats`, `wallet_prepared_quotes`, plus the `resolve_workspace_relative` path guard and the iterative `walk_dir`. |
| `crates/openhuman-core/src/test_support/introspect_tests.rs` | Tests for `resolve_workspace_relative` only: `..` traversal (missing and existing targets), leading `/` and `./` handling, and (unix) a symlink pointing out of the workspace. The RPC functions themselves have no unit tests here; E2E specs exercise them. |
@@ -24,8 +24,8 @@ Test-support domain: wipe-and-reset plus read-only introspection RPCs that let E
## Public surface
From `mod.rs`:
-- `all_test_support_controller_schemas()` — `Vec<ControllerSchema>` for the six controllers.
-- `all_test_support_registered_controllers()` — `Vec<RegisteredController>` (schema + handler pairs).
+- `all_test_support_controller_schemas()`: `Vec<ControllerSchema>` for the six controllers.
+- `all_test_support_registered_controllers()`: `Vec<RegisteredController>` (schema + handler pairs).
From `rpc` / `introspect` (used by handlers, also `pub`):
- `rpc::reset() -> RpcOutcome<ResetSummary>`, `rpc::reset_json()` (raw JSON envelope convenience; currently `#[allow(dead_code)]`, no caller).
@@ -49,33 +49,33 @@ Note the `reset` controller uses namespace `test` (method `openhuman.test_reset`
## Persistence
-This module owns no state of its own — it mutates/reads state owned by other domains:
-- **Wipes**: cron jobs (`cron::clear_all_jobs`), memory tree rows/content dirs/sync state (`memory::read_rpc::wipe_all_rpc`), config fields (`onboarding_completed`, `chat_onboarding_completed`, `api_key`), and `active_user.toml` (`config::clear_active_user` under `default_root_openhuman_dir`).
-- **Reads**: workspace files under `Config::workspace_dir`, the in-process `IN_FLIGHT` chat map, and the in-memory wallet prepared-quote store.
+This module owns no state of its own: it mutates/reads state owned by other domains:
+- Wipes: cron jobs (`cron::clear_all_jobs`), memory tree rows/content dirs/sync state (`memory::read_rpc::wipe_all_rpc`), config fields (`onboarding_completed`, `chat_onboarding_completed`, `api_key`), and `active_user.toml` (`config::clear_active_user` under `default_root_openhuman_dir`).
+- Reads: workspace files under `Config::workspace_dir`, the in-process `IN_FLIGHT` chat map, and the in-memory wallet prepared-quote store.
## Dependencies
-- `crate::config` — `Config::load_or_init`/`save`, `workspace_dir`, `clear_active_user`, `default_root_openhuman_dir`; config is the source of truth for the workspace root and the fields reset wipes.
-- `crate::cron` — `clear_all_jobs` to wipe scheduled jobs during reset.
-- `crate::memory::read_rpc` — `wipe_all_rpc` to clear memory-tree rows, content dirs, and sync state.
-- `crate::web_chat` — `in_flight_entries_for_test` to snapshot the live `IN_FLIGHT` chat map.
-- `crate::web3::wallet` — `prepared_quotes_for_test` and `PreparedTransaction` to snapshot prepared quotes.
-- `crate::core::all` — `ControllerFuture`, `RegisteredController` for handler wiring.
-- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` — controller schema types.
-- `crate::rpc::RpcOutcome` — standard RPC result envelope; `crate::rpc` is the `openhuman-rpc` crate re-exported by `pub use openhuman_rpc as rpc;` in `crates/openhuman-core/src/lib.rs`.
+- `crate::config`: `Config::load_or_init`/`save`, `workspace_dir`, `clear_active_user`, `default_root_openhuman_dir`; config is the source of truth for the workspace root and the fields reset wipes.
+- `crate::cron`: `clear_all_jobs` to wipe scheduled jobs during reset.
+- `crate::memory::read_rpc`: `wipe_all_rpc` to clear memory-tree rows, content dirs, and sync state.
+- `crate::web_chat`: `in_flight_entries_for_test` to snapshot the live `IN_FLIGHT` chat map.
+- `crate::web3::wallet`: `prepared_quotes_for_test` and `PreparedTransaction` to snapshot prepared quotes.
+- `crate::core::all`: `ControllerFuture`, `RegisteredController` for handler wiring.
+- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`: controller schema types.
+- `crate::rpc::RpcOutcome`: standard RPC result envelope; `crate::rpc` is the `openhuman-rpc` crate re-exported by `pub use openhuman_rpc as rpc;` in `crates/openhuman-core/src/lib.rs`.
## Used by
-- `crates/openhuman-core/src/core/all.rs` — pushes `all_test_support_registered_controllers()` into the global registry under `DomainGroup::Platform`, behind the same `#[cfg(feature = "e2e-test-support")]`. Method names come from the registry's `openhuman.{namespace}_{function}` rule. `all_test_support_controller_schemas()` has no consumer outside this module.
-- `crates/openhuman-core/src/lib.rs` — declares `pub mod test_support;` behind `#[cfg(feature = "e2e-test-support")]`. The feature is off in the contributor default set (`default = [...]` in `crates/openhuman-core/Cargo.toml`) and absent from `scripts/ci/product-features.txt`, so neither a bare `cargo check` nor the shipped app compiles this module. It is turned on by the E2E build (`app/scripts/e2e-build.sh`, forwarded through `crates/openhuman-app/Cargo.toml`'s `e2e-test-support` feature) and by a dedicated CI Lite lane (`.github/workflows/ci-lite.yml`) that `cargo check`s it and runs the `test_support::introspect::` tests with `--no-default-features --features e2e-test-support`.
+- `crates/openhuman-core/src/core/all.rs`: pushes `all_test_support_registered_controllers()` into the global registry under `DomainGroup::Platform`, behind the same `#[cfg(feature = "e2e-test-support")]`. Method names come from the registry's `openhuman.{namespace}_{function}` rule. `all_test_support_controller_schemas()` has no consumer outside this module.
+- `crates/openhuman-core/src/lib.rs`: declares `pub mod test_support;` behind `#[cfg(feature = "e2e-test-support")]`. The feature is off in the contributor default set (`default = [...]` in `crates/openhuman-core/Cargo.toml`) and absent from `scripts/ci/product-features.txt`, so neither a bare `cargo check` nor the shipped app compiles this module. It is turned on by the E2E build (`app/scripts/e2e-build.sh`, forwarded through `crates/openhuman-app/Cargo.toml`'s `e2e-test-support` feature) and by a dedicated CI Lite lane (`.github/workflows/ci-lite.yml`) that `cargo check`s it and runs the `test_support::introspect::` tests with `--no-default-features --features e2e-test-support`.
- Consumed at runtime by E2E specs (WDIO) calling `openhuman.test_reset` and `openhuman.test_support_*` over JSON-RPC.
## Notes / gotchas
-- **Double gating**: `reset` is fail-closed behind both the `/rpc` bearer token and `OPENHUMAN_E2E_MODE`; introspection RPCs rely on the bearer token alone. The token file specs read is written by `crates/openhuman-app/src/core_process.rs` under `#[cfg(debug_assertions)]` only.
-- **In-process reset**: the core process is not restarted; specs reload the webview afterward so the renderer also starts blank.
-- **Add new persistent state to `reset`**: per the module docstring, any new domain that survives `test_reset` is a leak that lets specs interfere — extend `rpc::reset` when adding persistent state.
-- **Path-jail ordering**: `resolve_workspace_relative` rejects `..` (and root/prefix components) lexically before touching the filesystem; the `canonicalize` + `starts_with` check underneath only catches symlink escapes and used to fail open for non-existent targets (openhuman#6085). It canonicalizes the root first (macOS `/var`→`/private/var`); `walk_dir` uses `symlink_metadata` and skips symlinks so listings can't follow links out of the workspace.
-- **CI runs only the `introspect` tests**: the CI Lite lane filters to `test_support::introspect::` because `rpc_tests.rs`'s `wipe_memory_tree` test fails under `--no-default-features` (the memory driver there does not serve `Maintenance`, so `wipe_all_rpc` errors). Run `cargo test -p openhuman --features e2e-test-support --lib -- test_support::` locally to cover both files.
-- **`read_workspace_file` byte accounting**: `returned_bytes` is the raw byte count before lossy UTF-8 conversion (which substitutes U+FFFD and can change length) so specs can assert byte-accurate truncation.
+- Double gating: `reset` is fail-closed behind both the `/rpc` bearer token and `OPENHUMAN_E2E_MODE`; introspection RPCs rely on the bearer token alone. The token file specs read is written by `crates/openhuman-app/src/core_process.rs` under `#[cfg(debug_assertions)]` only.
+- In-process reset: the core process is not restarted; specs reload the webview afterward so the renderer also starts blank.
+- Add new persistent state to `reset`: per the module docstring, any new domain that survives `test_reset` is a leak that lets specs interfere: extend `rpc::reset` when adding persistent state.
+- Path-jail ordering: `resolve_workspace_relative` rejects `..` (and root/prefix components) lexically before touching the filesystem; the `canonicalize` + `starts_with` check underneath only catches symlink escapes and used to fail open for non-existent targets (openhuman#6085). It canonicalizes the root first (macOS `/var`→`/private/var`); `walk_dir` uses `symlink_metadata` and skips symlinks so listings can't follow links out of the workspace.
+- CI runs only the `introspect` tests: the CI Lite lane filters to `test_support::introspect::` because `rpc_tests.rs`'s `wipe_memory_tree` test fails under `--no-default-features` (the memory driver there does not serve `Maintenance`, so `wipe_all_rpc` errors). Run `cargo test -p openhuman --features e2e-test-support --lib -- test_support::` locally to cover both files.
+- `read_workspace_file` byte accounting: `returned_bytes` is the raw byte count before lossy UTF-8 conversion (which substitutes U+FFFD and can change length) so specs can assert byte-accurate truncation.
- **`list_workspace_files` schema omits `entries`** for brevity, but the runtime payload includes them; `max_depth` defaults to 2, clamped to 6; entry cap is 2000.
diff --git a/crates/openhuman-core/src/tools/README.md b/crates/openhuman-core/src/tools/README.md
index 19fa42b374..5b12a7d5f7 100644
--- a/crates/openhuman-core/src/tools/README.md
+++ b/crates/openhuman-core/src/tools/README.md
@@ -5,7 +5,7 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
## Responsibilities
- Use the [`tinytools::Tool`] async trait and its supporting value types (`ToolResult`, `ToolSpec`, `PermissionLevel`, `ToolScope`, `ToolCategory`, `ToolCallOptions`, `ToolExposure`) directly from `tinytools`.
-- Assemble the registry the agent loop runs against — `default_tools[_with_runtime]` (minimal: shell + file read/write) and `all_tools[_with_runtime]` (full, config-gated set).
+- Assemble the registry the agent loop runs against: `default_tools[_with_runtime]` (minimal: shell + file read/write) and `all_tools[_with_runtime]` (full, config-gated set).
- Gate registration on config flags / env (`browser.enabled`, `node.enabled`, `runtime_python.enabled`, `learning.*`, `integrations.*`, `search.engine`, `gitbooks.enabled`, MCP registry presence, `OPENHUMAN_LSP_ENABLED`).
- Own the cross-cutting built-in tool impls under `impl/` (filesystem, browser, generic system, generic network, meta, and the `documents`-gated document/presentation tools).
- Provide the pre-execution [`ToolPolicy`] middleware (allow/deny gate) and the default allow-all policy.
@@ -13,7 +13,7 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
- Synthesize per-subagent orchestrator tools at agent-build time (`orchestrator_tools`).
- Wrap runtime-generated capability tools (`generated`).
- Filter the registry by user tool-toggle preferences (`user_filter`).
-- Own tool-call lifecycle state and failure classification (`status`), on-demand schema disclosure (`toolpacks`), the process-wide tool execution timeout (`timeout`), the read-only cross-surface discovery registry (`registry`), and per-session tool-boundary policy (`agent_policy`) — each documented in its own sibling README.
+- Own tool-call lifecycle state and failure classification (`status`), on-demand schema disclosure (`toolpacks`), the process-wide tool execution timeout (`timeout`), the read-only cross-surface discovery registry (`registry`), and per-session tool-boundary policy (`agent_policy`): each documented in its own sibling README.
- Expose a JSON-RPC `tools` controller allowlist (`openhuman.tools_*` on the wire) for Tauri-driven flows (onboarding-style orchestration in the renderer).
- Browser-allowlist derivation: narrow the browser host list from the unified fetch allowlist (`browser_allowed_domains`, strips `"*"`).
@@ -36,14 +36,14 @@ The agent tool layer. Defines the core [`Tool`] trait every agent-callable capab
| [`crates/openhuman-core/src/tools/timeout/`](timeout/README.md) | Process-wide tool execution timeout (`OPENHUMAN_TOOL_TIMEOUT_SECS` → config → `120`s default); scripting tools (`shell`/`node_exec`/`npm_exec`/`python_exec`) return `ToolTimeout::Unbounded` unless given an explicit `timeout_secs`. |
| [`crates/openhuman-core/src/tools/registry/`](registry/README.md) | Unified read-only discovery registry across MCP stdio, JSON-RPC controller, and connected MCP client tools, plus policy/tool-visibility diagnostics. |
| [`crates/openhuman-core/src/tools/agent_policy/`](agent_policy/README.md) | Per-session tool boundary: classifies every tool against a channel's permission ceiling into allow/require-approval/deny/hide, and renders the prompt-visible boundary section. |
-| [`crates/openhuman-core/src/tools/impl/mod.rs`](impl/README.md) | Aggregates the built-in tool families; glob re-exports `browser`, `filesystem`, `network`, `system` and the two `documents`-gated tools. `meta` is declared `pub` but not glob re-exported — reach it as `implementations::meta`. |
+| [`crates/openhuman-core/src/tools/impl/mod.rs`](impl/README.md) | Aggregates the built-in tool families; glob re-exports `browser`, `filesystem`, `network`, `system` and the two `documents`-gated tools. `meta` is declared `pub` but not glob re-exported: reach it as `implementations::meta`. |
| `crates/openhuman-core/src/tools/impl/filesystem/` | Tools `file_read`, `file_write`, `edit`, `apply_patch`, `grep`, `glob`, `list`, `read_diff`, `csv_export`, `git_operations`, `run_linter`, `run_tests`, `update_memory_md`. Helper modules (not tools): `git_operations_config`/`git_operations_render`, and `write_sink` (the injectable filesystem-write seam tests use to provoke OS refusals). |
| `crates/openhuman-core/src/tools/impl/browser/` | Deferred `browser` (TinyBrowser bus actions and Jev tasks), deferred `browser_open` (simple TinyBrowser entry point), and direct `image_info`. |
| `crates/openhuman-core/src/tools/impl/system/` | Tools `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`. Helper module (not a tool): `command_output`, the shared exit-code/stdout/stderr formatter for the shell family. |
| `crates/openhuman-core/src/tools/impl/network/` | Tools `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` (`mcp`-feature gated), `gmail_unsubscribe`. Helper module: `url_guard` (host allowlist matching, private-address rejection, `validate_url`). |
| `crates/openhuman-core/src/tools/impl/meta/` | Tools *about* the tool surface itself: `deferred` (the host's half of `ToolExposure::Deferred`; the harness's intrinsic `tool_search` bridge is the lookup half) and `collapse` (multi-action schema/permission merging helpers). |
-| `crates/openhuman-core/src/tools/impl/document/` (`documents` feature) | `DocumentTool` (`generate_document`) — structured document generation/editing engine. |
-| `crates/openhuman-core/src/tools/impl/presentation/` (`documents` feature) | `PresentationTool` (`generate_presentation`) — structured slide-deck generation engine. |
+| `crates/openhuman-core/src/tools/impl/document/` (`documents` feature) | `DocumentTool` (`generate_document`): structured document generation/editing engine. |
+| `crates/openhuman-core/src/tools/impl/presentation/` (`documents` feature) | `PresentationTool` (`generate_presentation`): structured slide-deck generation engine. |
| `crates/openhuman-core/src/search/` | Search engine registry and search-owned agent tools such as `web_search`. |
| `*_tests.rs` / `#[cfg(test)] mod tests` | Co-located/sibling unit tests across the module. |
@@ -76,13 +76,13 @@ Handlers load config via `config::rpc::load_config_with_timeout`, build the back
This module **owns** the cross-cutting built-in tools (the only ones that belong here per the repo's tool-ownership rule):
-- **Filesystem**: `file_read`, `file_write`, `edit`, `apply_patch`, `grep`, `glob`, `list`, `read_diff`, `csv_export`, `git_operations`, `run_linter`, `run_tests`, `update_memory_md`.
-- **System/process**: `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`.
-- **Browser**: `browser`, `browser_open`, `image_info`.
-- **Generic network**: `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, MCP bridge (`mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool`), `gmail_unsubscribe`.
-- **Meta**: `deferred` (which tools leave the wire for the harness's `tool_search` bridge) and the `collapse` multi-action helpers used by other tools' schema merging.
+- Filesystem: `file_read`, `file_write`, `edit`, `apply_patch`, `grep`, `glob`, `list`, `read_diff`, `csv_export`, `git_operations`, `run_linter`, `run_tests`, `update_memory_md`.
+- System/process: `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`.
+- Browser: `browser`, `browser_open`, `image_info`.
+- Generic network: `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, MCP bridge (`mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool`), `gmail_unsubscribe`.
+- Meta: `deferred` (which tools leave the wire for the harness's `tool_search` bridge) and the `collapse` multi-action helpers used by other tools' schema merging.
- **Documents** (`documents` feature): `generate_document` (`DocumentTool`), `generate_presentation` (`PresentationTool`).
-- **Search**: `web_search` and provider-specific search families are registered by `crate::search`; `search.engine = "disabled"` suppresses this surface entirely.
+- Search: `web_search` and provider-specific search families are registered by `crate::search`; `search.engine = "disabled"` suppresses this surface entirely.
Domain-owned tools (memory, cron, wallet, composio, integrations, skills, voice::audio_toolkit, agent sub-dispatch like `spawn_subagent`/`spawn_async_subagent`/`delegate`/`todo`/`plan_exit`/`run_skill`) are **registered** in `all_tools` but implemented in their respective domains and only re-exported through this module.
@@ -96,40 +96,40 @@ None. No `store.rs`; the module holds no persisted state. Tools that persist (me
## Dependencies
-- `crate::agent` — `host_runtime` (`RuntimeAdapter`/`NativeRuntime`), `tool_policy::GeneratedToolRuntimeContext`, harness definitions (`AgentDefinition`, `SubagentEntry`) for orchestrator tool synthesis, and the agent-owned dispatch tools re-exported here.
-- `crate::config` — `Config`, `BrowserConfig`, `HttpRequestConfig`, `DelegateAgentConfig`; drives all registration gating and `config::rpc::load_config_with_timeout` in RPC handlers.
-- `crate::search` — active search engine registry and search-owned tool implementations.
-- `crate::security` — `SecurityPolicy` (host/path/command gating threaded into nearly every tool) + `AuditLogger`.
-- `crate::memory` — `memory::ops::guard::active_memory_guard` (read by `tool_stats`) and the memory-owned tool sets re-exported here; the registry takes no `Memory` handle itself.
-- `crate::integrations` — `build_client` backend HTTP client + the integration tool structs (apify, brave, parallel, stock, twilio, tinyfish, google_places, querit, seltz, searxng).
-- `crate::integrations::composio` — `all_composio_agent_tools`, mode-aware client (`create_composio_client`) for `openhuman.tools_composio_execute`.
-- `crate::runtime::javascript` / `crate::runtime::python` — `NodeBootstrap` shared by shell/node_exec/npm_exec (behind `runtime-node`), `PythonBootstrap` for `python_exec`.
-- `crate::mcp::config_servers` (`McpServerRegistry` behind the `mcp_*` bridge tools and the gitbooks MCP source) and `crate::mcp::registry` (tool re-exports; `connections` for the discovery registry) — `mcp` feature.
-- `tinytools` (vendored via `vendor/tinyagents/`) — the `Tool` trait itself and its vocabulary, imported directly by each consumer.
-- `crate::skills` — skill-run spawning and skill-owned tools (`skills` feature).
-- `crate::agent::learning` — LinkedIn enrichment scrape/render for the Apify RPC handler.
-- `crate::web3::wallet`, `crate::cron`, `crate::voice::audio_toolkit` — domain-owned tools re-exported and registered (behind their respective features).
-- `crate::inference::provider` — `ProviderRuntimeOptions` handed to `DelegateTool`.
-- `crate::security::approval`, `crate::agent::context`, `crate::security::credentials`, `crate::platform::update`, `crate::util` — supporting types used by individual tools.
-- `core::all` — `ControllerSchema`, `FieldSchema`, `TypeSchema`, `RegisteredController`, `ControllerFuture` for the RPC controller surface.
+- `crate::agent`: `host_runtime` (`RuntimeAdapter`/`NativeRuntime`), `tool_policy::GeneratedToolRuntimeContext`, harness definitions (`AgentDefinition`, `SubagentEntry`) for orchestrator tool synthesis, and the agent-owned dispatch tools re-exported here.
+- `crate::config`: `Config`, `BrowserConfig`, `HttpRequestConfig`, `DelegateAgentConfig`; drives all registration gating and `config::rpc::load_config_with_timeout` in RPC handlers.
+- `crate::search`: active search engine registry and search-owned tool implementations.
+- `crate::security`: `SecurityPolicy` (host/path/command gating threaded into nearly every tool) + `AuditLogger`.
+- `crate::memory`: `memory::ops::guard::active_memory_guard` (read by `tool_stats`) and the memory-owned tool sets re-exported here; the registry takes no `Memory` handle itself.
+- `crate::integrations`: `build_client` backend HTTP client + the integration tool structs (apify, brave, parallel, stock, twilio, tinyfish, google_places, querit, seltz, searxng).
+- `crate::integrations::composio`: `all_composio_agent_tools`, mode-aware client (`create_composio_client`) for `openhuman.tools_composio_execute`.
+- `crate::runtime::javascript` / `crate::runtime::python`: `NodeBootstrap` shared by shell/node_exec/npm_exec (behind `runtime-node`), `PythonBootstrap` for `python_exec`.
+- `crate::mcp::config_servers` (`McpServerRegistry` behind the `mcp_*` bridge tools and the gitbooks MCP source) and `crate::mcp::registry` (tool re-exports; `connections` for the discovery registry): `mcp` feature.
+- `tinytools` (vendored via `vendor/tinyagents/`): the `Tool` trait itself and its vocabulary, imported directly by each consumer.
+- `crate::skills`: skill-run spawning and skill-owned tools (`skills` feature).
+- `crate::agent::learning`: LinkedIn enrichment scrape/render for the Apify RPC handler.
+- `crate::web3::wallet`, `crate::cron`, `crate::voice::audio_toolkit`: domain-owned tools re-exported and registered (behind their respective features).
+- `crate::inference::provider`: `ProviderRuntimeOptions` handed to `DelegateTool`.
+- `crate::security::approval`, `crate::agent::context`, `crate::security::credentials`, `crate::platform::update`, `crate::util`: supporting types used by individual tools.
+- `core::all`: `ControllerSchema`, `FieldSchema`, `TypeSchema`, `RegisteredController`, `ControllerFuture` for the RPC controller surface.
## Used by
-- `crates/openhuman-core/src/core/all.rs` — registers the `tools` RPC controllers + schemas.
-- `crate::agent` host layers (`agent/session_host/builder/`, `agent/subagent_host/`, `agent/tools/*`) and the `crate::agent::tinyagents` seam (`CanonicalSharedToolAdapter`, `ToolPolicyMiddleware`) — primary consumers; build the registry and execute/police tools on the TinyAgents path.
-- `crate::channels::runtime::dispatch::routing` — calls `orchestrator_tools::collect_orchestrator_tools` to build per-subagent orchestrator tool sets.
-- `crate::tools::agent_policy`, `crate::security::approval` — read tool metadata (category, external-effect) for policy/approval decisions.
+- `crates/openhuman-core/src/core/all.rs`: registers the `tools` RPC controllers + schemas.
+- `crate::agent` host layers (`agent/session_host/builder/`, `agent/subagent_host/`, `agent/tools/*`) and the `crate::agent::tinyagents` seam (`CanonicalSharedToolAdapter`, `ToolPolicyMiddleware`): primary consumers; build the registry and execute/police tools on the TinyAgents path.
+- `crate::channels::runtime::dispatch::routing`: calls `orchestrator_tools::collect_orchestrator_tools` to build per-subagent orchestrator tool sets.
+- `crate::tools::agent_policy`, `crate::security::approval`: read tool metadata (category, external-effect) for policy/approval decisions.
- `crate::tools::registry` (reads `all_tools_controller_schemas`) and `crate::mcp::server` (reuses `SEARXNG_MAX_RESULTS` / `normalize_categories` for its stdio tool specs).
-- `openhuman-embed` — re-exports `toolpacks::{ToolGroups, GroupMode}` as its tool-visibility control.
+- `openhuman-embed`: re-exports `toolpacks::{ToolGroups, GroupMode}` as its tool-visibility control.
## Notes / gotchas
-- **Ownership rule**: only genuinely cross-cutting tool families (filesystem, browser, generic system/network, meta, and the `documents`-gated document/presentation tools) belong in `impl/`. New domain tools go in the owning domain's `tools.rs` and are re-exported via `mod.rs` — do not add them under `impl/`.
-- **One unified `ToolResult`**: every tool imports it from `tinytools`, so every tool uses the same type.
-- **Browser allowlist is fail-safe**: the browser shares `http_request.allowed_domains` but `browser_allowed_domains` strips the `"*"` wildcard — unifying can only narrow browser reach. Allow-all stays behind `OPENHUMAN_BROWSER_ALLOW_ALL`.
-- **Node tools are co-gated**: `shell`, `node_exec`, and `npm_exec` share one memoised `NodeBootstrap`; with `node.enabled = false` (or the `runtime-node` feature off), node/npm tools are not registered and shell skips PATH injection.
-- **`external_effect_with_args`** is the hook the harness checks at the gate-decision point (not the arg-less variant) — override it for per-call gating (e.g. composio `execute` vs `list`).
-- **`PermissionLevel` ordering is load-bearing**: the runtime compares `<` to reject tools above a channel's max; `permission_level()` should return the *minimum* level across a multi-action tool, with `permission_level_with_args` doing the per-call check.
-- **`is_concurrency_safe` is still advisory in practice**: it is mapped to `ToolRuntime.idempotent` in `agent/tinyagents/tools.rs`, and tinyagents only runs a multi-call batch concurrently when no tool-wrap middleware is registered. OpenHuman's approval and scope gates are `wrap_tool` middlewares, so its turns take the serial path.
-- **RPC surface is intentionally tiny** (6 methods) — anything not in `schemas.rs`/`schemas/` is agent-only.
-- **Search engine is a single selector**: `search.engine` (`disabled`/`managed`/`parallel`/`brave`/`querit`/`exa`/`tavily`; a BYO engine without a key falls back to `managed`) chooses which `web_search`-family tools register; legacy `seltz`/`searxng` blocks are parsed but no longer auto-register agent tools (they remain reachable via their RPC handlers).
+- Ownership rule: only genuinely cross-cutting tool families (filesystem, browser, generic system/network, meta, and the `documents`-gated document/presentation tools) belong in `impl/`. New domain tools go in the owning domain's `tools.rs` and are re-exported via `mod.rs`: do not add them under `impl/`.
+- One unified `ToolResult`: every tool imports it from `tinytools`, so every tool uses the same type.
+- Browser allowlist is fail-safe: the browser shares `http_request.allowed_domains` but `browser_allowed_domains` strips the `"*"` wildcard: unifying can only narrow browser reach. Allow-all stays behind `OPENHUMAN_BROWSER_ALLOW_ALL`.
+- Node tools are co-gated: `shell`, `node_exec`, and `npm_exec` share one memoised `NodeBootstrap`; with `node.enabled = false` (or the `runtime-node` feature off), node/npm tools are not registered and shell skips PATH injection.
+- **`external_effect_with_args`** is the hook the harness checks at the gate-decision point (not the arg-less variant): override it for per-call gating (e.g. composio `execute` vs `list`).
+- `PermissionLevel` ordering is load-bearing: the runtime compares `<` to reject tools above a channel's max; `permission_level()` should return the *minimum* level across a multi-action tool, with `permission_level_with_args` doing the per-call check.
+- `is_concurrency_safe` is still advisory in practice: it is mapped to `ToolRuntime.idempotent` in `agent/tinyagents/tools.rs`, and tinyagents only runs a multi-call batch concurrently when no tool-wrap middleware is registered. OpenHuman's approval and scope gates are `wrap_tool` middlewares, so its turns take the serial path.
+- **RPC surface is intentionally tiny** (6 methods): anything not in `schemas.rs`/`schemas/` is agent-only.
+- Search engine is a single selector: `search.engine` (`disabled`/`managed`/`parallel`/`brave`/`querit`/`exa`/`tavily`; a BYO engine without a key falls back to `managed`) chooses which `web_search`-family tools register; legacy `seltz`/`searxng` blocks are parsed but no longer auto-register agent tools (they remain reachable via their RPC handlers).
diff --git a/crates/openhuman-core/src/tools/agent_policy/README.md b/crates/openhuman-core/src/tools/agent_policy/README.md
index 09e2608b2a..160d139557 100644
--- a/crates/openhuman-core/src/tools/agent_policy/README.md
+++ b/crates/openhuman-core/src/tools/agent_policy/README.md
@@ -19,7 +19,7 @@ Not to be confused with `crate::agent::tool_policy` (the generic `ToolPolicy` pr
| --- | --- |
| `crates/openhuman-core/src/tools/agent_policy/mod.rs` | Export-only: module docstring + `mod` decls + `pub use` re-exports of the engine, prompt renderer, and types. |
| `crates/openhuman-core/src/tools/agent_policy/types.rs` | Serde-free domain types: `TaskRiskLevel`, `TaskProfile`, `ToolPolicyAction`, `ToolPolicyDecision`, `ToolCapability`, `ToolPolicySession` (with query helpers). Holds the private `NO_TOOLS_ALLOWED_SENTINEL`. |
-| `crates/openhuman-core/src/tools/agent_policy/engine.rs` | `ToolPolicyEngine::build_session` / `build_session_from_refs` — the classification logic; private `permission_for_channel` / `parse_permission_level` helpers. |
+| `crates/openhuman-core/src/tools/agent_policy/engine.rs` | `ToolPolicyEngine::build_session` / `build_session_from_refs`: the classification logic; private `permission_for_channel` / `parse_permission_level` helpers. |
| `crates/openhuman-core/src/tools/agent_policy/engine_tests.rs` | Engine tests, attached via `#[path]` from `engine.rs`. |
| `crates/openhuman-core/src/tools/agent_policy/prompt.rs` | `render_tool_policy_boundary` + `TOOL_POLICY_BOUNDARY_HEADING`; private UTF-8-safe `truncate_utf8`. |
| `crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs` | Prompt-rendering tests, attached via `#[path]` from `prompt.rs`. |
@@ -29,38 +29,38 @@ Not to be confused with `crate::agent::tool_policy` (the generic `ToolPolicy` pr
Re-exported from `mod.rs`:
- `ToolPolicyEngine::build_session(agent_id, channel, entrypoint, channel_permissions: &HashMap<String,String>, tools: &[Box<dyn Tool>], visible_tool_names: &HashSet<String>) -> ToolPolicySession`.
-- `ToolPolicyEngine::build_session_from_refs(..., tools: &[&dyn Tool], ...)` — same classification over borrowed tools so the harness can classify its durable registry and its synthesized delegate tools together; `build_session` delegates to it.
-- `render_tool_policy_boundary(session: &ToolPolicySession, max_bytes: usize) -> Option<String>` — `None` when the session has no restrictions; otherwise a truncated prompt section.
+- `ToolPolicyEngine::build_session_from_refs(..., tools: &[&dyn Tool], ...)`: same classification over borrowed tools so the harness can classify its durable registry and its synthesized delegate tools together; `build_session` delegates to it.
+- `render_tool_policy_boundary(session: &ToolPolicySession, max_bytes: usize) -> Option<String>`: `None` when the session has no restrictions; otherwise a truncated prompt section.
- Types: `TaskProfile`, `TaskRiskLevel`, `ToolCapability`, `ToolPolicyAction`, `ToolPolicyDecision`, `ToolPolicySession`.
`ToolPolicySession` helpers: `is_allowed(name)`, `has_restrictions()`, `restricted_tool_count()`, `visible_tool_names_for_prompt()`, `decision_for(name)` (defaults to `Deny`).
`ToolPolicyDecision` has two predicates that answer different questions:
-- `is_denied()` — true for anything other than `Allow`, including `HideFromPrompt`. Right for a direct tool call by name.
-- `blocks_execution()` — true for `Deny` / `RequireApproval`, or when `required_permission` exceeds `allowed_permission`. `HideFromPrompt` alone does not block, so withheld packed tools stay reachable through `use_skill`. The permission re-check exists because the classifier tests hidden-ness before the ceiling, so a hidden tool over the ceiling is recorded as `HideFromPrompt` only.
+- `is_denied()`: true for anything other than `Allow`, including `HideFromPrompt`. Right for a direct tool call by name.
+- `blocks_execution()`: true for `Deny` / `RequireApproval`, or when `required_permission` exceeds `allowed_permission`. `HideFromPrompt` alone does not block, so withheld packed tools stay reachable through `use_skill`. The permission re-check exists because the classifier tests hidden-ness before the ceiling, so a hidden tool over the ceiling is recorded as `HideFromPrompt` only.
## Dependencies
-- `crate::tools` — `PermissionLevel` (ordered, parsed and compared) and the `Tool` trait (`name()`, `permission_level()`). The only in-crate dependency.
+- `crate::tools`: `PermissionLevel` (ordered, parsed and compared) and the `Tool` trait (`name()`, `permission_level()`). The only in-crate dependency.
- `log` for `[tool-policy]` diagnostics; every call sets `target: "openhuman::tools::agent_policy"` explicitly (the lib crate is named `openhuman`).
## Used by
-- `crates/openhuman-core/src/agent/session_host/builder/builder_build.rs` — builds two snapshots with `build_session_from_refs`: the session's `tool_policy_session` (with the role visibility filter) and a `channel_policy_session` without it, used to derive the sub-agent tool ceiling.
-- `crates/openhuman-core/src/agent/session_host/builder/mod.rs` — `visible_tool_specs_for_policy` filters prompt-visible specs with `decision_for(name).blocks_execution()`.
-- `crates/openhuman-core/src/agent/session_host/runtime/accessors.rs` — `rebuild_tool_policy_session` re-runs `build_session_from_refs` after `hide_tools`.
-- `crates/openhuman-core/src/agent/session_host/turn/context.rs` — calls `render_tool_policy_boundary(&session, 2048)` and appends the block to the end of the system prompt.
-- `crates/openhuman-core/src/agent/session_host/types.rs` — carries `tool_policy_session` on the session.
-- `crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs` — `ToolPolicyMiddleware` is the runtime enforcement point: `is_denied()` for direct calls, `blocks_execution()` for the `use_skill` route. The snapshot reaches it through `ToolPolicyEnforcement` in `agent/tinyagents/turn_policy.rs`.
-- `crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs` — `SecurityGate::with_tool_policy` accepts an `Arc<ToolPolicySession>` and maps its actions to gate verdicts.
-- `crates/openhuman-core/src/config/schema/agent.rs` — the `channel_permissions` field docs describe the engine's fallback semantics.
+- `crates/openhuman-core/src/agent/session_host/builder/builder_build.rs`: builds two snapshots with `build_session_from_refs`: the session's `tool_policy_session` (with the role visibility filter) and a `channel_policy_session` without it, used to derive the sub-agent tool ceiling.
+- `crates/openhuman-core/src/agent/session_host/builder/mod.rs`: `visible_tool_specs_for_policy` filters prompt-visible specs with `decision_for(name).blocks_execution()`.
+- `crates/openhuman-core/src/agent/session_host/runtime/accessors.rs`: `rebuild_tool_policy_session` re-runs `build_session_from_refs` after `hide_tools`.
+- `crates/openhuman-core/src/agent/session_host/turn/context.rs`: calls `render_tool_policy_boundary(&session, 2048)` and appends the block to the end of the system prompt.
+- `crates/openhuman-core/src/agent/session_host/types.rs`: carries `tool_policy_session` on the session.
+- `crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs`: `ToolPolicyMiddleware` is the runtime enforcement point: `is_denied()` for direct calls, `blocks_execution()` for the `use_skill` route. The snapshot reaches it through `ToolPolicyEnforcement` in `agent/tinyagents/turn_policy.rs`.
+- `crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs`: `SecurityGate::with_tool_policy` accepts an `Arc<ToolPolicySession>` and maps its actions to gate verdicts.
+- `crates/openhuman-core/src/config/schema/agent.rs`: the `channel_permissions` field docs describe the engine's fallback semantics.
## Notes / gotchas
-- **Legacy escape hatch**: an empty `channel_permissions` map yields `PermissionLevel::Dangerous` (fully unrestricted). `AgentConfig::migrate_channel_permissions_if_legacy` seeds the map on first boot, so this branch is only hit before that migration. Once *any* entry exists, channels missing from the map (or with an unparseable value) fall back to `PermissionLevel::ReadOnly`.
+- Legacy escape hatch: an empty `channel_permissions` map yields `PermissionLevel::Dangerous` (fully unrestricted). `AgentConfig::migrate_channel_permissions_if_legacy` seeds the map on first boot, so this branch is only hit before that migration. Once *any* entry exists, channels missing from the map (or with an unparseable value) fall back to `PermissionLevel::ReadOnly`.
- **Permission parsing** (`parse_permission_level`) is lenient: trims, lowercases, strips `-`/`_`, and accepts aliases (`read`/`readonly`, `exec`/`execute`, `danger`/`dangerous`). Unrecognized tokens fall back to read-only.
-- **Two independent restriction axes**: a tool can be `Deny`ed (exceeds the permission ceiling → `blocked_tool_names`) or `HideFromPrompt` (not in the non-empty `visible_tool_names` set → `hidden_tool_names`). Hidden is tested first, so a tool that is both hidden and over the ceiling lands only in `hidden_tool_names`; `blocks_execution()` carries the ceiling check for that case.
+- Two independent restriction axes: a tool can be `Deny`ed (exceeds the permission ceiling → `blocked_tool_names`) or `HideFromPrompt` (not in the non-empty `visible_tool_names` set → `hidden_tool_names`). Hidden is tested first, so a tool that is both hidden and over the ceiling lands only in `hidden_tool_names`; `blocks_execution()` carries the ceiling check for that case.
- An empty `visible_tool_names` set means "all visible", not "none visible".
- `ToolPolicyAction::RequireApproval` is handled (routed to `blocked_tool_names`) but the engine never produces it.
- `visible_tool_names_for_prompt()` inserts `NO_TOOLS_ALLOWED_SENTINEL` when restrictions exist but nothing is allowed, so callers can distinguish an empty-but-restricted surface from an unrestricted one.
diff --git a/crates/openhuman-core/src/tools/impl/README.md b/crates/openhuman-core/src/tools/impl/README.md
index 091320369c..cda5bb46f3 100644
--- a/crates/openhuman-core/src/tools/impl/README.md
+++ b/crates/openhuman-core/src/tools/impl/README.md
@@ -35,7 +35,7 @@ tested but no production assembly site constructs it today.
| `network/` | `HttpRequestTool`, `WebFetchTool`, `CurlTool`, `GitbooksSearchTool`, `GitbooksGetPageTool`, `GmailUnsubscribeTool`, and under the `mcp` Cargo feature `McpListServersTool`, `McpListToolsTool`, `McpCallTool`; `url_guard.rs` is the shared SSRF/allowlist validator, not a tool | `http_request`, `web_fetch`, `curl`, `gmail_unsubscribe` always registered; `gitbooks_*` need `gitbooks.enabled` and, when the active profile sets an `mcp_allowlist`, an entry named `gitbooks`; `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` register only when the static `[[mcp_client.servers]]` registry (after the profile allowlist) is non-empty |
| `document/` (feature `documents`) | `DocumentTool` (`generate_document`) | always registered when compiled. Builds `.docx` bytes via the pure-Rust `engine` module (`docx-rs`, no subprocess) inside `spawn_blocking` + `tokio::time::timeout`; allocates the artifact with `agent::artifacts::create_artifact` (kind `Document`), persists `args.json` next to it for the failed-card Retry path, then `finalize_artifact` or `fail_artifact` |
| `presentation/` (feature `documents`) | `PresentationTool` (`generate_presentation`) | always registered when compiled. Same shape as `document/` with `ppt-rs` producing `.pptx` and kind `Presentation` |
-| `meta/` | `deferred` (`strip_deferred_from_visible`, `deferred_tool_names`, the `TOOL_SEARCH_NAME` belt opt-in constant); `collapse` helpers (`resolve`, `merge_action_schemas`, `args_without_action`, `strictest_permission`, `any_external_effect`, `unknown_action_message`, `CollapsedAction`) | not registered: `deferred` is the host's half of `ToolExposure::Deferred` — the session builder (`agent/session_host/builder/builder_build.rs`) uses it to split a belt into the advertised set and the still-registered deferred set, and the tinyagents harness advertises its intrinsic `tool_search` / `tool_call` bridge over the latter (ranked per `agent/tinyagents/discovery`). The `collapse` helpers are used by `cron/tools/collapsed.rs` and `memory/tools/collapsed.rs` to merge a multi-action tool's per-action schemas and permissions into one entry |
+| `meta/` | `deferred` (`strip_deferred_from_visible`, `deferred_tool_names`, the `TOOL_SEARCH_NAME` belt opt-in constant); `collapse` helpers (`resolve`, `merge_action_schemas`, `args_without_action`, `strictest_permission`, `any_external_effect`, `unknown_action_message`, `CollapsedAction`) | not registered: `deferred` is the host's half of `ToolExposure::Deferred`: the session builder (`agent/session_host/builder/builder_build.rs`) uses it to split a belt into the advertised set and the still-registered deferred set, and the tinyagents harness advertises its intrinsic `tool_search` / `tool_call` bridge over the latter (ranked per `agent/tinyagents/discovery`). The `collapse` helpers are used by `cron/tools/collapsed.rs` and `memory/tools/collapsed.rs` to merge a multi-action tool's per-action schemas and permissions into one entry |
## Notes
diff --git a/crates/openhuman-core/src/tools/registry/README.md b/crates/openhuman-core/src/tools/registry/README.md
index 64d4f81f52..502be1f691 100644
--- a/crates/openhuman-core/src/tools/registry/README.md
+++ b/crates/openhuman-core/src/tools/registry/README.md
@@ -1,6 +1,6 @@
# tool_registry
-Unified **read-only** tool registry for OpenHuman. It builds a single discovery view across every tool surface the agent can call — MCP stdio server tools, JSON-RPC controller-backed tools, and tools from currently-connected MCP client servers — and exposes them with stable ids, normalized JSON Schemas, transport/route metadata, tags, and health. It also produces redacted policy/tool-visibility diagnostics (autonomy posture, MCP allowlists, MCP write-audit health, recent policy denials, capability-provider summaries) and tracks an in-memory ring buffer of recent agent-tool policy denials. Nothing here executes tools; it only enumerates and describes them.
+Unified **read-only** tool registry for OpenHuman. It builds a single discovery view across every tool surface the agent can call: MCP stdio server tools, JSON-RPC controller-backed tools, and tools from currently-connected MCP client servers, and exposes them with stable ids, normalized JSON Schemas, transport/route metadata, tags, and health. It also produces redacted policy/tool-visibility diagnostics (autonomy posture, MCP allowlists, MCP write-audit health, recent policy denials, capability-provider summaries) and tracks an in-memory ring buffer of recent agent-tool policy denials. Nothing here executes tools; it only enumerates and describes them.
## Responsibilities
@@ -29,7 +29,7 @@ Unified **read-only** tool registry for OpenHuman. It builds a single discovery
- From `providers`: `CapabilityProviderMetadata`, `CapabilityProviderRegistry`, `CapabilityProviderRegistryError`, `capability_provider_by_id`, `capability_provider_diagnostics`, `capability_provider_registry`, `is_capability_provider_trusted_enabled`, `list_capability_providers`, `normalize_capability_provider_id`.
- From `schemas`: `all_tool_registry_controller_schemas`, `all_tool_registry_registered_controllers`.
- From `types`: `ToolRegistryEntry`, `ToolRegistryList`, `ToolRegistryTransport`, `ToolRegistryHealth`, `ToolPolicyDiagnostics`, `ToolPolicyPosture`, `McpAllowlistDiagnostics`, `McpServerAllowlistSummary`, `McpWriteAuditHealth`, `RecentPolicyDenial`, `CapabilityProviderDiagnostics`.
-- `denials` is `pub mod` — consumers call `tools::registry::denials::record(...)` directly.
+- `denials` is `pub mod`: consumers call `tools::registry::denials::record(...)` directly.
## RPC / controllers
@@ -49,28 +49,28 @@ No owned persistence. `diagnostics()` reads the MCP write-audit log through `cra
## Dependencies
-- `crate::core::all` — `rpc_method_name()` for controller route metadata and `all_controller_schemas()` for the `security.` / `approval.` policy-surface scan. Registry *entries* for controllers come from `crate::tools::all_tools_controller_schemas()`, not the whole controller set.
-- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` and `core::all::{ControllerFuture, RegisteredController}` — schema model and controller registration contract.
-- `crate::config` (`Config`, `config::schema::CapabilityProviderTrustState`) — autonomy posture, MCP client allowlists, capability-provider config.
-- `crate::mcp::server` (`McpToolSpec`, `tool_specs()`) — MCP stdio tool source for registry entries.
-- `crate::mcp::registry::connections` (`all_connected_tools()` / `all_connected_tools_for_config()`, defined inside `mcp/registry/mod.rs`; empty-returning stubs in `mcp/registry/stub.rs` when the `mcp` feature is disabled) — live MCP client server tools, fetched via `block_in_place` only on the multi-thread runtime.
-- `crate::mcp::audit` (`list_writes`, `McpWriteListQuery`; stubbed under `mcp/audit/stub.rs` without the `mcp` feature) — write-audit health.
-- `crate::rpc::RpcOutcome` — RPC result envelope.
+- `crate::core::all`: `rpc_method_name()` for controller route metadata and `all_controller_schemas()` for the `security.` / `approval.` policy-surface scan. Registry *entries* for controllers come from `crate::tools::all_tools_controller_schemas()`, not the whole controller set.
+- `crate::core::{ControllerSchema, FieldSchema, TypeSchema}` and `core::all::{ControllerFuture, RegisteredController}`: schema model and controller registration contract.
+- `crate::config` (`Config`, `config::schema::CapabilityProviderTrustState`): autonomy posture, MCP client allowlists, capability-provider config.
+- `crate::mcp::server` (`McpToolSpec`, `tool_specs()`): MCP stdio tool source for registry entries.
+- `crate::mcp::registry::connections` (`all_connected_tools()` / `all_connected_tools_for_config()`, defined inside `mcp/registry/mod.rs`; empty-returning stubs in `mcp/registry/stub.rs` when the `mcp` feature is disabled): live MCP client server tools, fetched via `block_in_place` only on the multi-thread runtime.
+- `crate::mcp::audit` (`list_writes`, `McpWriteListQuery`; stubbed under `mcp/audit/stub.rs` without the `mcp` feature): write-audit health.
+- `crate::rpc::RpcOutcome`: RPC result envelope.
## Used by
-- `crates/openhuman-core/src/core/all.rs` — registers controllers/schemas and routes the `tool_registry` namespace.
-- `crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs` — calls `tools::registry::denials::record(...)` when a tool call is denied or requires approval.
-- `crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs` — the `intelligence.tool_registry` capability entry points users at `openhuman.tool_registry_list` / `openhuman.tool_registry_get`.
-- `tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs` and siblings — exercise `denials`, `ops::diagnostics_for_config`, and the provider registry directly.
+- `crates/openhuman-core/src/core/all.rs`: registers controllers/schemas and routes the `tool_registry` namespace.
+- `crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs`: calls `tools::registry::denials::record(...)` when a tool call is denied or requires approval.
+- `crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs`: the `intelligence.tool_registry` capability entry points users at `openhuman.tool_registry_list` / `openhuman.tool_registry_get`.
+- `tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs` and siblings: exercise `denials`, `ops::diagnostics_for_config`, and the provider registry directly.
## Notes / gotchas
-- **Read-only by design** — the registry never executes tools; routes are descriptive metadata only.
-- **Duplicate `tool_id` is first-write-wins**: ordered MCP-stdio → controller → MCP-client; duplicates (e.g. external servers reusing well-known names) are logged and skipped, not overwritten. MCP-client ids are `mcp-client::<server_id>::<tool>` and route to `openhuman.mcp_clients_tool_call`.
-- **MCP client enumeration is best-effort**: on a single-thread tokio runtime (e.g. unit tests) or with no runtime, connected-client tools silently fall back to empty, since `block_in_place` panics outside the multi-thread runtime.
-- **`registry_entries()` vs `registry_entries_for_config()`**: the ambient form resolves the MCP host through the process default, which stops answering once a second workspace is open in the process (test binaries). Callers holding a `Config` should use the `_for_config` variant.
-- `looks_write_capable` is a **heuristic** over tool-id keywords (add/create/delete/send/write/…), surfaced as `possible_write_surfaces` for review — not an authoritative permission check.
+- **Read-only by design**: the registry never executes tools; routes are descriptive metadata only.
+- Duplicate `tool_id` is first-write-wins: ordered MCP-stdio → controller → MCP-client; duplicates (e.g. external servers reusing well-known names) are logged and skipped, not overwritten. MCP-client ids are `mcp-client::<server_id>::<tool>` and route to `openhuman.mcp_clients_tool_call`.
+- MCP client enumeration is best-effort: on a single-thread tokio runtime (e.g. unit tests) or with no runtime, connected-client tools silently fall back to empty, since `block_in_place` panics outside the multi-thread runtime.
+- `registry_entries()` vs `registry_entries_for_config()`: the ambient form resolves the MCP host through the process default, which stops answering once a second workspace is open in the process (test binaries). Callers holding a `Config` should use the `_for_config` variant.
+- `looks_write_capable` is a **heuristic** over tool-id keywords (add/create/delete/send/write/…), surfaced as `possible_write_surfaces` for review: not an authoritative permission check.
- `policy_surfaces` includes a fixed seed list plus any controller whose method starts with `security.` / `approval.`.
- Denial reasons containing any of `Bearer `, `sk-`, `ghp_`, `-----BEGIN` are replaced wholesale with `[redacted: sensitive content]`, then truncated to 240 chars; entries are bounded to 50, and blank tool names are dropped.
- Capability-provider ids are slugged to lowercase alphanumerics with `-`/`_`/`.` separators (max 96 chars); invalid or post-normalization-duplicate ids return `CapabilityProviderRegistryError`.