Skip to content

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

feat(storage): add per-module storage grant implementations

Steven Enamakel570b27b5b819
diff --git a/crates/openhuman-core/src/modules/storage_grant_tinybox.rs b/crates/openhuman-core/src/modules/storage_grant_tinybox.rs
new file mode 100644
index 0000000000..c0f29546dd
--- /dev/null
+++ b/crates/openhuman-core/src/modules/storage_grant_tinybox.rs
@@ -0,0 +1,44 @@
+//! 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_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors.rs
new file mode 100644
index 0000000000..67c238f7b0
--- /dev/null
+++ b/crates/openhuman-core/src/modules/storage_grant_tinyconnectors.rs
@@ -0,0 +1,42 @@
+//! 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_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_grant_tinyjuice.rs
new file mode 100644
index 0000000000..ef112877c9
--- /dev/null
+++ b/crates/openhuman-core/src/modules/storage_grant_tinyjuice.rs
@@ -0,0 +1,37 @@
+//! 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_tinywallet.rs b/crates/openhuman-core/src/modules/storage_grant_tinywallet.rs
new file mode 100644
index 0000000000..ba68971165
--- /dev/null
+++ b/crates/openhuman-core/src/modules/storage_grant_tinywallet.rs
@@ -0,0 +1,46 @@
+//! 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_grants.rs b/crates/openhuman-core/src/modules/storage_grants.rs
index b24cea0a28..7ca7a8add6 100644
--- a/crates/openhuman-core/src/modules/storage_grants.rs
+++ b/crates/openhuman-core/src/modules/storage_grants.rs
@@ -184,7 +184,10 @@ type Declaration = (&'static str, fn() -> StorageGrant);
/// decision, like the registry's digests) and then calls
/// `ai.tinyhumans.tinystorage.Storage`; a module with no row has no storage at
/// all. `tinymcp` (v0.18.0 and later) reaches its servers, audit log and
-/// environment secrets through this table.
+/// environment secrets through this table; so do `tinyconnectors` (v0.18.0:
+/// scope preferences and trigger archive), `tinywallet` (v0.22.0: x402 ledger and
+/// budget hold), `tinybox` (v0.1.29: box records, jail index) and `tinyjuice`
+/// (v0.10.0: CCR blobs).
#[must_use]
pub fn declared(module_id: &str) -> Option<StorageGrant> {
let table: &[Declaration] = &[
@@ -196,6 +199,22 @@ pub fn declared(module_id: &str) -> Option<StorageGrant> {
super::storage_grant_tinymcp::MODULE_ID,
super::storage_grant_tinymcp::grant,
),
+ (
+ super::storage_grant_tinyconnectors::MODULE_ID,
+ super::storage_grant_tinyconnectors::grant,
+ ),
+ (
+ super::storage_grant_tinywallet::MODULE_ID,
+ super::storage_grant_tinywallet::grant,
+ ),
+ (
+ super::storage_grant_tinybox::MODULE_ID,
+ super::storage_grant_tinybox::grant,
+ ),
+ (
+ super::storage_grant_tinyjuice::MODULE_ID,
+ super::storage_grant_tinyjuice::grant,
+ ),
];
table
.iter()