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
feat(modules): add storage grant and import modules for tiny services
Steven Enamakele29c4d38c676
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rsindex 3cb2b9c1dd..224a8297f5 100644--- a/crates/openhuman-core/src/modules/mod.rs+++ b/crates/openhuman-core/src/modules/mod.rs@@ -280,7 +280,7 @@ pub async fn import_legacy_connectors(import_once(ctx,"connectors",- storage_grant_tinyconnectors::MODULE_ID,+ storage_grant_schemas::tinyconnectors::MODULE_ID,state_dir,storage_import_tinyconnectors::import_legacy(ctx, state_dir),)@@ -302,7 +302,7 @@ pub async fn import_legacy_x402(return import_once(ctx,"x402",- storage_grant_tinywallet::MODULE_ID,+ storage_grant_schemas::tinywallet::MODULE_ID,workspace_dir,storage_import_tinywallet::import_legacy(ctx, workspace_dir),)@@ -325,7 +325,7 @@ pub async fn import_legacy_tinybox(import_once(ctx,"tinybox",- storage_grant_tinybox::MODULE_ID,+ storage_grant_schemas::tinybox::MODULE_ID,workspace_dir,storage_import_tinybox::import_legacy(ctx, workspace_dir),)@@ -344,7 +344,7 @@ pub(crate) fn expiring_blob_module_scopes() -> Vec<crate::storage::Scope> {#[cfg(feature = "modules")]{- [storage_grant_tinyjuice::MODULE_ID]+ [storage_grant_schemas::tinyjuice::MODULE_ID].into_iter().filter_map(|id| storage_host::current_module_scope(ctx, id).ok()).collect()@@ -363,7 +363,7 @@ pub(crate) fn expiring_blob_module_scopes_for(profile: &str,base: &crate::storage::Scope,) -> Vec<crate::storage::Scope> {- [storage_grant_tinyjuice::MODULE_ID]+ [storage_grant_schemas::tinyjuice::MODULE_ID].into_iter().filter_map(|id| storage_host::module_scope(Some(profile), base, id).ok()).collect()@@ -399,7 +399,7 @@ pub async fn import_legacy_tinyjuice(import_once(ctx,"tinyjuice",- storage_grant_tinyjuice::MODULE_ID,+ storage_grant_schemas::tinyjuice::MODULE_ID,root,storage_import_tinyjuice::import_legacy(ctx, root, ttl),)diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas.rs b/crates/openhuman-core/src/modules/storage_grant_schemas.rsnew file mode 100644index 0000000000..2cebd1e554--- /dev/null+++ b/crates/openhuman-core/src/modules/storage_grant_schemas.rs@@ -0,0 +1,116 @@+//! The storage grants of the loadable modules, generated from their schemas.+//!+//! A module reaches storage only through `ai.tinyhumans.tinystorage.Storage`+//! (`storage_host`) and its authority is a [`StorageGrant`]. Each module owner+//! declares what it stores in `storage_schema()` (collections with their+//! indexes, streams, blob and secret prefixes, each with a scope class); the+//! host composes those into the registry ([`crate::storage::schema`]) and this+//! file turns the **module-scoped** items of the module's owner into the grant.+//! The hand-written per-module tables this replaces could drift from what the+//! module actually declares; a generated grant cannot.+//!+//! Secrets are the one thing a schema cannot name for tinymcp (a secret cannot+//! be renamed by a migration step and sits outside the owner prefix), so the+//! row lists those beside the schema.+//!+//! The `mod <module>` blocks hold the registry id and the v1 names the host's+//! one-time legacy-file importers (`storage_import_*`) still write: the+//! importers write the module's v1 shapes and the owner's steps carry them+//! forward (`ensure_migrated` in `storage_host`).++use super::storage_grants::StorageGrant;+use crate::storage::schema::module_items;++/// One module's row: its registry id, the schema owner that declares its+/// storage, and secret prefixes the schema cannot name.+struct Row {+ module: &'static str,+ owner: &'static str,+ secrets: &'static [&'static str],+}++const ROWS: [Row; 6] = [+ Row {+ module: tinychannels::MODULE_ID,+ owner: "channels",+ secrets: &[],+ },+ Row {+ module: tinymcp::MODULE_ID,+ owner: "mcp",+ secrets: &["mcp_client_env/", "mcp_cache_fingerprint_key"],+ },+ Row {+ module: tinyconnectors::MODULE_ID,+ owner: "connectors",+ secrets: &[],+ },+ Row {+ module: tinywallet::MODULE_ID,+ owner: "wallet",+ secrets: &[],+ },+ Row {+ module: tinybox::MODULE_ID,+ owner: "box",+ secrets: &[],+ },+ Row {+ module: tinyjuice::MODULE_ID,+ owner: "juice",+ secrets: &[],+ },+];++/// The grant generated for `module_id`, or `None` for a module with no row.+pub(super) fn grant_for(module_id: &str) -> Option<StorageGrant> {+ let row = ROWS.iter().find(|row| row.module == module_id)?;+ let items = module_items(row.owner);+ let mut secret_prefixes: Vec<String> = row.secrets.iter().map(|s| (*s).to_owned()).collect();+ secret_prefixes.extend(items.secrets);+ Some(StorageGrant {+ collections: items.collections,+ stream_prefixes: items.streams,+ blob_prefixes: items.blobs,+ secret_prefixes,+ writable: true,+ })+}++pub(super) mod tinychannels {+ pub(crate) const MODULE_ID: &str = "tinychannels";+}++pub(super) mod tinymcp {+ pub(crate) const MODULE_ID: &str = "tinymcp";+}++pub(super) mod tinyconnectors {+ pub(crate) const MODULE_ID: &str = "tinyconnectors";+ /// The v1 preference collection the importer writes.+ pub(crate) const PREFS_COLLECTION: &str = "composio-user-scopes";+ /// The v1 trigger-archive stream prefix the importer writes.+ pub(crate) const TRIGGER_STREAM_PREFIX: &str = "triggers/";+}++pub(super) mod tinywallet {+ pub(crate) const MODULE_ID: &str = "tinywallet";+ /// The v1 payments stream the importer writes.+ pub(crate) const PAYMENTS_STREAM: &str = "x402.payments";+}++pub(super) mod tinybox {+ pub(crate) const MODULE_ID: &str = "tinybox";+ /// The v1 jail-index collection the importer writes.+ pub(crate) const JAIL_INDEX_COLLECTION: &str = "tinybox_jail_index";+}++pub(super) mod tinyjuice {+ pub(crate) const MODULE_ID: &str = "tinyjuice";+ /// The v1 CCR blob prefix the importer writes.+ pub(crate) const CCR_BLOB_PREFIX: &str = "tinyjuice_ccr/";+}++#[cfg(test)]+#[path = "storage_grant_schemas_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinybox.rs b/crates/openhuman-core/src/modules/storage_grant_tinybox.rsdeleted file mode 100644index c0f29546dd..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinybox.rs+++ /dev/null@@ -1,44 +0,0 @@-//! What the `tinybox` module may touch through the storage bus.-//!-//! The names are the module's own (`tinybox_drivers` in-//! tinyhumansai/tinybox, v0.1.29), restated here because a host never links a-//! module's implementation library: a grant is a reviewable build-time-//! decision, like the registry's digests. When the module's declaration-//! changes, this table changes in the same re-pin; the test in-//! `storage_grant_tinybox_tests.rs` pins the shape.-//!-//! * `tinybox_boxes`: one document per box record, keyed by box id;-//! * `tinybox_jail_index`: one document per jail registry, the same JSON the-//! registry used to keep in `index.json`.-//!-//! No streams, blobs or secrets: box contents live on the box's own disk.--use tinystoragedrivers::CollectionSpec;--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinybox";--/// Box records, one document per box.-pub(super) const BOX_COLLECTION: &str = "tinybox_boxes";-/// Jail registry indexes, one document per registry.-pub(super) const JAIL_INDEX_COLLECTION: &str = "tinybox_jail_index";--/// The grant the host serves the `tinybox` module under.-pub(super) fn grant() -> StorageGrant {- StorageGrant {- collections: vec![- CollectionSpec::new(BOX_COLLECTION),- CollectionSpec::new(JAIL_INDEX_COLLECTION),- ],- stream_prefixes: Vec::new(),- blob_prefixes: Vec::new(),- secret_prefixes: Vec::new(),- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinybox_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rsdeleted file mode 100644index 3112be684f..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinybox_tests.rs+++ /dev/null@@ -1,74 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinybox_and_validates() {- let declared = declared(MODULE_ID).expect("tinybox declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.secret_prefixes.is_empty());-}--#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn box_records_and_the_jail_index_are_reachable() {- for name in ["tinybox_boxes", "tinybox_jail_index"] {- assert!(- allowed(- Object::Documents,- "Put",- json!({"collection": name, "id": "x"})- ),- "{name}"- );- }- assert_eq!(grant().collections.len(), 2);- for other in [- "tinybox_host_import",- "tinybox_boxes_x",- "approvals",- "_secrets",- ] {- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Get",- &json!({"collection": other, "id": "x"})- ),- Err(Denied::Target),- "{other}"- );- }-}--#[test]-fn streams_blobs_and_secrets_are_not_granted() {- assert_eq!(- authorize(&grant(), Object::Streams, "Append", &json!({"stream": "s"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinychannels.rs b/crates/openhuman-core/src/modules/storage_grant_tinychannels.rsdeleted file mode 100644index cf205d5e2e..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinychannels.rs+++ /dev/null@@ -1,76 +0,0 @@-//! What the `tinychannels` module may touch through the storage bus.-//!-//! The collections are the module's own declaration (`tinychannels::storage`-//! and `tinychannels::remote::session_store` in tinyhumansai/tinychannels,-//! contract v21), restated here because a host never links a module's-//! implementation library: a grant is a reviewable build-time decision, like-//! the registry's digests. When the module's declaration changes, this table-//! changes in the same re-pin; the test in `storage_grant_tinychannels_tests.rs`-//! pins the shape.-//!-//! * delivery queue: pending, failed and terminal-result records behind-//! required deliveries (replacing the `Save/LoadPendingDelivery` callbacks);-//! * remote control: chat to thread bindings, in-flight flags and the legacy-//! import marker (replacing the remote-session JSON map);-//! * WhatsApp Web: the linked-device session, so pairing survives a restart.-//!-//! No streams, blobs or secrets: the module keeps none there. The iMessage-//! `chat.db` reader is an external read-only database, not storage.--use tinystoragedrivers::CollectionSpec;--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinychannels";--/// Delivery entries awaiting a terminal outcome.-const DELIVERY_PENDING: &str = "channels_delivery_pending";-/// Permanently failed delivery entries.-const DELIVERY_FAILED: &str = "channels_delivery_failed";-/// Idempotent terminal delivery results.-const DELIVERY_RESULTS: &str = "channels_delivery_results";-/// Chat to host-thread bindings.-const REMOTE_BINDINGS: &str = "channel_remote_bindings";-/// Chats with a turn in flight.-const REMOTE_BUSY: &str = "channel_remote_busy";-/// The one-time legacy import marker of the remote-session files.-const REMOTE_META: &str = "channel_remote_meta";-/// The WhatsApp Web session backend's collections.-const WHATSAPP: [&str; 8] = [- "whatsapp_device",- "whatsapp_identity",- "whatsapp_session",- "whatsapp_prekey",- "whatsapp_signed_prekey",- "whatsapp_sender_key",- "whatsapp_sync_key",- "whatsapp_lid_mapping",-];--/// The grant the host serves the `tinychannels` module under.-pub(super) fn grant() -> StorageGrant {- let collections = [- DELIVERY_PENDING,- DELIVERY_FAILED,- DELIVERY_RESULTS,- REMOTE_BINDINGS,- REMOTE_BUSY,- REMOTE_META,- ]- .into_iter()- .chain(WHATSAPP)- .map(CollectionSpec::new)- .collect();- StorageGrant {- collections,- stream_prefixes: Vec::new(),- blob_prefixes: Vec::new(),- secret_prefixes: Vec::new(),- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinychannels_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinychannels_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinychannels_tests.rsdeleted file mode 100644index e0856eb42a..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinychannels_tests.rs+++ /dev/null@@ -1,91 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinychannels_and_validates() {- let declared = declared(MODULE_ID).expect("tinychannels declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.stream_prefixes.is_empty());- assert!(declared.blob_prefixes.is_empty());- assert!(declared.secret_prefixes.is_empty());-}--#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn delivery_remote_and_whatsapp_collections_are_all_granted() {- let names: Vec<String> = grant().collections.iter().map(|s| s.name.clone()).collect();- assert_eq!(names.len(), 14);- for name in &names {- assert!(- allowed(- Object::Documents,- "Put",- json!({"collection": name, "id": "x"})- ),- "{name}"- );- }- for expected in [- "channels_delivery_pending",- "channels_delivery_failed",- "channels_delivery_results",- "channel_remote_bindings",- "whatsapp_session",- "whatsapp_prekey",- ] {- assert!(names.iter().any(|n| n == expected), "{expected}");- }-}--#[test]-fn other_collections_and_the_host_import_marker_are_refused() {- for other in [- "approvals",- "mcp_servers",- "channels_host_import",- "_secrets",- ] {- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Get",- &json!({"collection": other, "id": "x"})- ),- Err(Denied::Target),- "{other}"- );- }-}--#[test]-fn streams_blobs_and_secrets_are_not_granted() {- assert_eq!(- authorize(&grant(), Object::Streams, "Append", &json!({"stream": "s"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors.rsdeleted file mode 100644index 67c238f7b0..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinyconnectors.rs+++ /dev/null@@ -1,42 +0,0 @@-//! What the `tinyconnectors` module may touch through the storage bus.-//!-//! The names are the module's own declaration (`tinyconnectors::state::-//! STORAGE_NEEDS` in tinyhumansai/tinyconnectors, v0.18.0), restated here-//! because a host never links a module's implementation library: a grant is a-//! reviewable build-time decision, like the registry's digests. When the-//! module's declaration changes, this table changes in the same re-pin; the-//! test in `storage_grant_tinyconnectors_tests.rs` pins the shape.-//!-//! * `composio-user-scopes`: one document per toolkit holding the user's scope-//! preference (`{ "value": ... }`);-//! * `triggers/`: the trigger archive, one stream per UTC day-//! (`triggers/<YYYY-MM-DD>`).-//!-//! No blobs or secrets: the module keeps none there.--use tinystoragedrivers::CollectionSpec;--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinyconnectors";--/// Per-toolkit scope preferences, one document each.-pub(super) const PREFS_COLLECTION: &str = "composio-user-scopes";-/// Prefix of every day's trigger-archive stream.-pub(super) const TRIGGER_STREAM_PREFIX: &str = "triggers/";--/// The grant the host serves the `tinyconnectors` module under.-pub(super) fn grant() -> StorageGrant {- StorageGrant {- collections: vec![CollectionSpec::new(PREFS_COLLECTION)],- stream_prefixes: vec![TRIGGER_STREAM_PREFIX.into()],- blob_prefixes: Vec::new(),- secret_prefixes: Vec::new(),- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinyconnectors_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rsdeleted file mode 100644index 9b2fc9a391..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinyconnectors_tests.rs+++ /dev/null@@ -1,86 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinyconnectors_and_validates() {- let declared = declared(MODULE_ID).expect("tinyconnectors declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.secret_prefixes.is_empty());-}--#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn only_its_own_collection_and_trigger_streams_are_reachable() {- assert_eq!(grant().collections.len(), 1);- assert!(allowed(- Object::Documents,- "Put",- json!({"collection": "composio-user-scopes", "id": "gmail"})- ));- for day in ["triggers/2026-10-13", "triggers/x"] {- assert!(- allowed(Object::Streams, "Append", json!({"stream": day})),- "{day}"- );- assert!(- allowed(Object::Streams, "Len", json!({"stream": day})),- "{day}"- );- }- for other in ["trigger", "mcp_audit", "x402.payments", "_secrets"] {- assert_eq!(- authorize(- &grant(),- Object::Streams,- "Append",- &json!({"stream": other})- ),- Err(Denied::Target),- "{other}"- );- }- for other in [- "composio-user-scopes-x",- "tinyconnectors_host_import",- "approvals",- ] {- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Get",- &json!({"collection": other, "id": "x"})- ),- Err(Denied::Target),- "{other}"- );- }-}--#[test]-fn blobs_and_secrets_are_not_granted() {- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_grant_tinyjuice.rsdeleted file mode 100644index ef112877c9..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinyjuice.rs+++ /dev/null@@ -1,37 +0,0 @@-//! What the `tinyjuice` module may touch through the storage bus.-//!-//! The prefix is the CCR durable tier's own (`tinyjuice_drivers::CCR_PREFIX` in-//! tinyhumansai/tinyjuice, v0.10.0), restated here because a host never links-//! a module's implementation library: a grant is a reviewable build-time-//! decision, like the registry's digests. When the module's declaration-//! changes, this table changes in the same re-pin; the test in-//! `storage_grant_tinyjuice_tests.rs` pins the shape.-//!-//! * `tinyjuice_ccr/<token>`: one expiring blob per compressed original, the-//! content the model can ask to recover. The lifetime is the configured CCR-//! TTL, set by the module on each write.-//!-//! No collections, streams or secrets.--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinyjuice";--/// Prefix of every CCR blob key.-pub(super) const CCR_BLOB_PREFIX: &str = "tinyjuice_ccr/";--/// The grant the host serves the `tinyjuice` module under.-pub(super) fn grant() -> StorageGrant {- StorageGrant {- collections: Vec::new(),- stream_prefixes: Vec::new(),- blob_prefixes: vec![CCR_BLOB_PREFIX.into()],- secret_prefixes: Vec::new(),- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinyjuice_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rsdeleted file mode 100644index 632aa08ce4..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinyjuice_tests.rs+++ /dev/null@@ -1,74 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinyjuice_and_validates() {- let declared = declared(MODULE_ID).expect("tinyjuice declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.secret_prefixes.is_empty());-}--#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn only_ccr_blobs_are_reachable() {- for selector in ["Get", "Head", "Delete"] {- assert!(- allowed(- Object::Blobs,- selector,- json!({"key": "tinyjuice_ccr/0123456789abcdef0123456789abcdef"})- ),- "{selector}"- );- }- for other in [- "tinyjuice_ccr",- "tinyjuice_ccr_x/a",- "ccr/a",- "../tinyjuice_ccr/a",- ] {- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": other})),- Err(Denied::Target),- "{other}"- );- }-}--#[test]-fn documents_streams_and_secrets_are_not_granted() {- assert!(grant().collections.is_empty());- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Get",- &json!({"collection": "tinyjuice_host_import", "id": "x"})- ),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Streams, "Append", &json!({"stream": "s"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinymcp.rs b/crates/openhuman-core/src/modules/storage_grant_tinymcp.rsdeleted file mode 100644index 41a1e8e798..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinymcp.rs+++ /dev/null@@ -1,60 +0,0 @@-//! What the `tinymcp` module may touch through the storage bus.-//!-//! The collections, indexes, stream and secret names are the module's own-//! declaration (`tinymcp::storage::grant()` and `collection_specs()` in-//! tinyhumansai/tinymcp, docs/specs/storage-ports.md), restated here because a-//! host never links a module's implementation library: a grant is a reviewable-//! build-time decision, like the registry's digests. When the module's-//! declaration changes, this table changes in the same re-pin; the test in-//! `storage_grant_tinymcp_tests.rs` pins the shape.--use tinystoragedrivers::{CollectionSpec, IndexSpec};--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinymcp";--/// Installed servers, one document each.-const SERVERS: &str = "mcp_servers";-/// Claims on qualified names, so installing one service twice is one install.-const SERVER_NAMES: &str = "mcp_server_names";-/// Upstream browse responses, with a timestamp.-const REGISTRY_CACHE: &str = "mcp_registry_cache";-/// Each server's last advertised tool list.-const TOOL_CACHE: &str = "mcp_tool_cache";-/// The local copy of an upstream catalog, one document per server.-const REGISTRY_INDEX: &str = "mcp_registry_index";-/// Where each catalog's sync stands.-const REGISTRY_INDEX_STATE: &str = "mcp_registry_index_state";--/// The append-only stream of tool-write audit records.-const AUDIT_STREAM: &str = "mcp_audit";-/// Prefix of the secret holding one server's environment and OAuth values.-const ENV_SECRET_PREFIX: &str = "mcp_client_env/";-/// The secret holding the key the tool-cache fingerprints are keyed with.-const CACHE_KEY_SECRET: &str = "mcp_cache_fingerprint_key";--/// The grant the host serves the `tinymcp` module under.-pub(super) fn grant() -> StorageGrant {- StorageGrant {- collections: vec![- CollectionSpec::new(SERVERS)- .index(IndexSpec::new("qualified_name", ["qualified_name"]))- .index(IndexSpec::new("installed_at", ["installed_at"])),- CollectionSpec::new(SERVER_NAMES),- CollectionSpec::new(REGISTRY_CACHE).index(IndexSpec::new("cache_key", ["cache_key"])),- CollectionSpec::new(TOOL_CACHE),- CollectionSpec::new(REGISTRY_INDEX).index(IndexSpec::new("source", ["source"])),- CollectionSpec::new(REGISTRY_INDEX_STATE),- ],- stream_prefixes: vec![AUDIT_STREAM.into()],- blob_prefixes: Vec::new(),- secret_prefixes: vec![ENV_SECRET_PREFIX.into(), CACHE_KEY_SECRET.into()],- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinymcp_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinymcp_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinymcp_tests.rsdeleted file mode 100644index 2920d3918d..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinymcp_tests.rs+++ /dev/null@@ -1,104 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinymcp_and_validates() {- let declared = declared(MODULE_ID).expect("tinymcp declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.blob_prefixes.is_empty());-}--#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn tinymcp_reaches_exactly_its_own_collections() {- for name in grant().collections.iter().map(|spec| spec.name.clone()) {- assert!(- allowed(- Object::Documents,- "Get",- json!({"collection": name, "id": "x"})- ),- "{name}"- );- }- for other in ["approvals", "mcp_servers_extra", "_secrets", "mcp_audit"] {- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Put",- &json!({"collection": other})- ),- Err(Denied::Target),- "{other}"- );- }-}--#[test]-fn the_catalog_index_is_declared_for_the_modules_own_search_filters() {- let grant = grant();- let spec = |name: &str| {- grant- .collections- .iter()- .find(|spec| spec.name == name)- .unwrap()- };- assert_eq!(spec("mcp_servers").indexes.len(), 2);- assert_eq!(spec("mcp_registry_index").indexes.len(), 1);- assert!(spec("mcp_server_names").indexes.is_empty());-}--#[test]-fn the_audit_stream_and_env_secrets_are_granted_and_nothing_else() {- assert!(allowed(- Object::Streams,- "Append",- json!({"stream": "mcp_audit", "payload": {}})- ));- assert_eq!(- authorize(- &grant(),- Object::Streams,- "Append",- &json!({"stream": "other"})- ),- Err(Denied::Target)- );- for name in ["mcp_client_env/srv-1", "mcp_cache_fingerprint_key"] {- assert!(- allowed(Object::Secrets, "Get", json!({"name": name})),- "{name}"- );- }- assert_eq!(- authorize(- &grant(),- Object::Secrets,- "Get",- &json!({"name": "wallet/seed"})- ),- Err(Denied::Target)- );- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": "any"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_grant_tinywallet.rs b/crates/openhuman-core/src/modules/storage_grant_tinywallet.rsdeleted file mode 100644index ba68971165..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinywallet.rs+++ /dev/null@@ -1,46 +0,0 @@-//! What the `tinywallet` module may touch through the storage bus.-//!-//! The names are the x402 ledger's own (`tinywallet_x402::ledger::persist` in-//! tinyhumansai/tinywallet, v0.22.0), restated here because a host never links-//! a module's implementation library: a grant is a reviewable build-time-//! decision, like the registry's digests. When the module's declaration-//! changes, this table changes in the same re-pin; the test in-//! `storage_grant_tinywallet_tests.rs` pins the shape.-//!-//! * `x402.payments`: the append-only payments stream. A payment that changes-//! status is appended again with the same id; readers fold to the latest.-//! * `x402_budget`: one document, `holds`, with every outstanding budget hold.-//! Reservations are compare-and-swap on it, so two processes sharing a-//! backend cannot both spend the same budget. A hold expires after 15-//! minutes unless the module renews it (every 5), so a process that dies-//! mid-payment never locks budget forever.-//!-//! No blobs or secrets: the signing keys stay with the host's keyring and-//! reach the module only through its confidential calls.--use tinystoragedrivers::CollectionSpec;--use super::storage_grants::StorageGrant;--/// The registry id the grant is declared under.-pub(super) const MODULE_ID: &str = "tinywallet";--/// The payments stream.-pub(super) const PAYMENTS_STREAM: &str = "x402.payments";-/// The collection holding the budget-hold document.-pub(super) const BUDGET_COLLECTION: &str = "x402_budget";--/// The grant the host serves the `tinywallet` module under.-pub(super) fn grant() -> StorageGrant {- StorageGrant {- collections: vec![CollectionSpec::new(BUDGET_COLLECTION)],- stream_prefixes: vec![PAYMENTS_STREAM.into()],- blob_prefixes: Vec::new(),- secret_prefixes: Vec::new(),- writable: true,- }-}--#[cfg(test)]-#[path = "storage_grant_tinywallet_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rs b/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rsdeleted file mode 100644index 541acc4e25..0000000000--- a/crates/openhuman-core/src/modules/storage_grant_tinywallet_tests.rs+++ /dev/null@@ -1,91 +0,0 @@-use super::*;-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};-use serde_json::json;--fn allowed(object: Object, selector: &str, request: serde_json::Value) -> bool {- matches!(- authorize(&grant(), object, selector, &request),- Ok(Plan::Forward { .. })- )-}--#[test]-fn the_grant_is_declared_for_tinywallet_and_validates() {- let declared = declared(MODULE_ID).expect("tinywallet declares storage");- assert_eq!(declared, grant());- declared.validate().expect("a valid grant");- assert!(declared.writable);- assert!(declared.secret_prefixes.is_empty());-}--#[cfg(feature = "web3")]-#[test]-fn the_declared_module_id_is_a_registry_module() {- assert!(crate::modules::registry::ALL- .iter()- .any(|record| record.id == MODULE_ID));-}--#[test]-fn the_payments_stream_and_the_budget_hold_document_are_reachable() {- assert!(allowed(- Object::Streams,- "Append",- json!({"stream": "x402.payments"})- ));- assert!(allowed(- Object::Streams,- "ReadWindow",- json!({"stream": "x402.payments"})- ));- // The hold is compare-and-swap on one document: puts with a precondition- // are forwarded like any other write.- assert!(allowed(- Object::Documents,- "Put",- json!({"collection": "x402_budget", "id": "holds"})- ));- assert!(allowed(- Object::Documents,- "Get",- json!({"collection": "x402_budget", "id": "holds"})- ));-}--#[test]-fn nothing_else_is_reachable() {- for other in [- "x402_budget_extra",- "tinywallet_host_import",- "approvals",- "_secrets",- ] {- assert_eq!(- authorize(- &grant(),- Object::Documents,- "Get",- &json!({"collection": other, "id": "x"})- ),- Err(Denied::Target),- "{other}"- );- }- assert_eq!(- authorize(- &grant(),- Object::Streams,- "Append",- &json!({"stream": "mcp_audit"})- ),- Err(Denied::Target)- );- assert_eq!(- authorize(&grant(), Object::Blobs, "Get", &json!({"key": "k"})),- Err(Denied::Object)- );- assert_eq!(- authorize(&grant(), Object::Secrets, "Get", &json!({"name": "n"})),- Err(Denied::Object)- );-}diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rsindex 1983436302..966b80beda 100644--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs@@ -25,7 +25,7 @@ use anyhow::{Context, Result};use serde_json::{json, Value};use tinystoragedrivers::{CollectionSpec, ScopedStorage};-use super::storage_grant_tinybox::{JAIL_INDEX_COLLECTION, MODULE_ID};+use super::storage_grant_schemas::tinybox::{JAIL_INDEX_COLLECTION, MODULE_ID};use super::storage_import_support as support;use crate::core::runtime::DispatchCtx;diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rsindex f2238fd863..4013dc420b 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs@@ -26,7 +26,7 @@ use anyhow::{anyhow, Context, Result};use serde_json::{json, Value};use tinystoragedrivers::{CollectionSpec, ScopedStorage};-use super::storage_grant_tinyconnectors::{MODULE_ID, PREFS_COLLECTION, TRIGGER_STREAM_PREFIX};+use super::storage_grant_schemas::tinyconnectors::{MODULE_ID, PREFS_COLLECTION, TRIGGER_STREAM_PREFIX};use super::storage_import_support as support;use crate::core::runtime::DispatchCtx;diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rsindex 75edd9c104..b99f4ee5e4 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs@@ -27,7 +27,7 @@ use anyhow::{anyhow, Context, Result};use serde_json::json;use tinystoragedrivers::{Capability, ScopedStorage};-use super::storage_grant_tinyjuice::{CCR_BLOB_PREFIX, MODULE_ID};+use super::storage_grant_schemas::tinyjuice::{CCR_BLOB_PREFIX, MODULE_ID};use super::storage_import_support as support;use crate::core::runtime::DispatchCtx;diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rsindex faf4e585d4..bd7548c40b 100644--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs@@ -26,7 +26,7 @@ use anyhow::{anyhow, Context, Result};use serde_json::json;use tinystoragedrivers::ScopedStorage;-use super::storage_grant_tinywallet::{MODULE_ID, PAYMENTS_STREAM};+use super::storage_grant_schemas::tinywallet::{MODULE_ID, PAYMENTS_STREAM};use super::storage_import_support as support;use crate::core::runtime::DispatchCtx;