Skip to content

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

refactor(storage): use owner-specific prefix functions for storage grants

Steven Enamakelc42783105b1b
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas.rs b/crates/openhuman-core/src/modules/storage_grant_schemas.rs
index 660424b943..49d088dc09 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas.rs
@@ -135,8 +135,12 @@ pub(super) fn grant_for(module_id: &str) -> Option<StorageGrant> {
secret_prefixes.extend(items.secrets);
Some(StorageGrant {
collections: items.collections,
- stream_prefixes: items.streams,
- blob_prefixes: items.blobs,
+ // v2 owner bus crates expose their collection declarations, but not
+ // every non-document name. Keep those capabilities explicit at the
+ // host boundary until the owner contracts publish them. Connectors
+ // already has a pure storage-needs contract, so consume it directly.
+ stream_prefixes: stream_prefixes(row.owner),
+ blob_prefixes: blob_prefixes(row.owner),
secret_prefixes,
writable: true,
queues: queues.as_ref().map(|grant| Arc::clone(&grant.manifest)),
@@ -144,6 +148,24 @@ pub(super) fn grant_for(module_id: &str) -> Option<StorageGrant> {
})
}
+fn stream_prefixes(owner: &str) -> Vec<String> {
+ match owner {
+ "mcp" => vec![tinymcp_bus::storage::AUDIT_STREAM.to_owned()],
+ "connectors" => tinyconnectors_bus::storage::storage_needs().stream_prefixes,
+ // TinyWallet's module still reads and appends this released ledger
+ // stream while its bus contract currently declares collections only.
+ "wallet" => vec!["wallet.payments".to_owned()],
+ _ => Vec::new(),
+ }
+}
+
+fn blob_prefixes(owner: &str) -> Vec<String> {
+ match owner {
+ "juice" => vec![format!("{}/", tinyjuice_bus::storage::CCR_PREFIX)],
+ _ => Vec::new(),
+ }
+}
+
pub(super) mod tinychannels {
pub(crate) const MODULE_ID: &str = "tinychannels";
}
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
index ffdc2538f1..b8eba88071 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
@@ -109,12 +109,55 @@ fn tinyjuice_reaches_only_its_blob_prefix() {
&grant,
Object::Blobs,
"Get",
- json!({"key": "juice/ccr/abc"})
+ json!({"key": "tinyjuice_ccr/abc"})
));
assert!(!allowed(
&grant,
Object::Blobs,
"Get",
- json!({"key": "other/abc"})
+ json!({"key": "juice/ccr/abc"})
+ ));
+}
+
+#[test]
+fn non_document_grants_match_the_owner_contracts_without_broad_prefixes() {
+ let connectors = declared("tinyconnectors").unwrap();
+ assert!(allowed(
+ &connectors,
+ Object::Streams,
+ "Append",
+ json!({"stream": "connectors.triggers/2026-10-21"})
+ ));
+ assert!(allowed(
+ &connectors,
+ Object::Streams,
+ "Append",
+ json!({"stream": "triggers/2026-10-21"})
+ ));
+ assert_eq!(
+ authorize(
+ &connectors,
+ Object::Streams,
+ "Append",
+ &json!({"stream": "other/2026-10-21"})
+ ),
+ Err(Denied::Target)
+ );
+
+ let wallet = declared("tinywallet").unwrap();
+ assert!(allowed(
+ &wallet,
+ Object::Streams,
+ "Append",
+ json!({"stream": "wallet.payments"})
));
+ assert_eq!(
+ authorize(
+ &wallet,
+ Object::Streams,
+ "Append",
+ &json!({"stream": "other.payments"})
+ ),
+ Err(Denied::Target)
+ );
}