Skip to content

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

refactor(core): adjust module and storage imports

Steven Enamakel010e0b787f8b
diff --git a/crates/openhuman-core/src/inbound/settings.rs b/crates/openhuman-core/src/inbound/settings.rs
index 5727daaf7f..a28aedbc14 100644
--- a/crates/openhuman-core/src/inbound/settings.rs
+++ b/crates/openhuman-core/src/inbound/settings.rs
@@ -16,8 +16,8 @@ use tinyeventqueues_bus::{Lane, PipelineConfig};
use tinystoragedrivers::QueueConfig;
use crate::config::Config;
-use crate::modules::storage_queue_manifest::QueueManifest;
use crate::modules::storage_grant_schemas::QueueGrant;
+use crate::modules::storage_queue_manifest::QueueManifest;
/// The `[components]` switch that owns the inbound event queues.
pub const COMPONENT: &str = "eventqueues";
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rs
index 3e33235899..73a38b7fe6 100644
--- a/crates/openhuman-core/src/modules/mod.rs
+++ b/crates/openhuman-core/src/modules/mod.rs
@@ -98,8 +98,6 @@ pub(crate) mod storage_grant_schemas;
#[cfg(feature = "modules")]
pub mod storage_grants;
#[cfg(feature = "modules")]
-pub(crate) mod storage_queue_manifest;
-#[cfg(feature = "modules")]
pub(crate) mod storage_host;
#[cfg(feature = "modules")]
mod storage_host_linked;
@@ -119,6 +117,8 @@ mod storage_import_tinyjuice_savings;
mod storage_import_tinymcp;
#[cfg(all(feature = "modules", feature = "web3"))]
mod storage_import_tinywallet;
+#[cfg(feature = "modules")]
+pub(crate) mod storage_queue_manifest;
pub mod tinybox;
pub(crate) mod tinyflows;
#[cfg(feature = "modules")]
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 b8eba88071..da50a9bae1 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::modules::storage_grants::{Denied, Object, Plan, authorize, declared};
+use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};
use serde_json::json;
fn allowed(
diff --git a/crates/openhuman-core/src/modules/storage_host.rs b/crates/openhuman-core/src/modules/storage_host.rs
index 157a1990cd..47e99e56e1 100644
--- a/crates/openhuman-core/src/modules/storage_host.rs
+++ b/crates/openhuman-core/src/modules/storage_host.rs
@@ -45,15 +45,15 @@ use std::sync::Arc;
use async_trait::async_trait;
use serde_json::Value;
use tinybus::BusName;
-use tinystoragedrivers::BlobReader;
use tinystoragedrivers::secrets::{DocumentSecrets, KeyProvider};
+use tinystoragedrivers::BlobReader;
use tinystoragedrivers_bus::{
BlobKeyRequest, BlobStreamHead, PutBlobStreamRequest, StorageFailure, StorageKind,
};
use tinystoragedrivers_busproxy::{Admission, HostFailure, StorageServer};
use self::endpoint::HostEndpoint;
-use super::storage_grants::{Object, Plan, StorageGrant, authorize, declared, filter_reply};
+use super::storage_grants::{authorize, declared, filter_reply, Object, Plan, StorageGrant};
use crate::storage::{Scope, StorageBackend, StorageError};
/// The largest blob a module may send by `PutStream`. The body is bounded per
diff --git a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
index 1aa954c273..b14b761a44 100644
--- a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
@@ -115,9 +115,9 @@ async fn a_module_write_under_a_stale_lease_is_fenced_by_the_host() {
#[tokio::test]
async fn the_bus_hands_the_host_the_brokers_sender_and_nothing_else() {
- use tinybus::Connection;
use tinybus::broker::Broker;
use tinybus::transport::memory::MemoryBus;
+ use tinybus::Connection;
let bus = MemoryBus::new();
Broker::new().spawn(bus.clone());
@@ -180,12 +180,10 @@ async fn the_bus_hands_the_host_the_brokers_sender_and_nothing_else() {
// A forged scope is a refused request, not a different scope.
let mut forged = get("notes", "a");
forged["scope"] = json!("local");
- assert!(
- documents(&module)
- .call::<Value>("Get", forged)
- .await
- .is_err()
- );
+ assert!(documents(&module)
+ .call::<Value>("Get", forged)
+ .await
+ .is_err());
// Secrets are on a confidential route: an ordinary call never reaches the host.
let secrets = module
@@ -195,18 +193,15 @@ async fn the_bus_hands_the_host_the_brokers_sender_and_nothing_else() {
STORAGE_INTERFACE,
)
.unwrap();
- assert!(
- secrets
- .call::<Value>("Get", json!({"name": "token.a"}))
- .await
- .is_err()
- );
- assert!(
- rig.trail
- .0
- .lock()
- .unwrap()
- .iter()
- .all(|record| record.object != "Secrets")
- );
+ assert!(secrets
+ .call::<Value>("Get", json!({"name": "token.a"}))
+ .await
+ .is_err());
+ assert!(rig
+ .trail
+ .0
+ .lock()
+ .unwrap()
+ .iter()
+ .all(|record| record.object != "Secrets"));
}
diff --git a/crates/openhuman-core/src/modules/storage_host_cdylib_stream_tests.rs b/crates/openhuman-core/src/modules/storage_host_cdylib_stream_tests.rs
index f2823cd8e5..2b7dc40865 100644
--- a/crates/openhuman-core/src/modules/storage_host_cdylib_stream_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_cdylib_stream_tests.rs
@@ -61,16 +61,12 @@ async fn a_blob_over_the_bus_frame_round_trips_through_a_peer_bound_stream() {
"{missing}"
);
let trail = rig.trail.0.lock().unwrap().clone();
- assert!(
- trail
- .iter()
- .any(|r| r.op == "PutStream" && r.outcome == "ok" && r.module == "tinyjuice")
- );
- assert!(
- trail
- .iter()
- .any(|r| r.op == "GetStream" && r.outcome == "ok" && r.module == "tinyjuice")
- );
+ assert!(trail
+ .iter()
+ .any(|r| r.op == "PutStream" && r.outcome == "ok" && r.module == "tinyjuice"));
+ assert!(trail
+ .iter()
+ .any(|r| r.op == "GetStream" && r.outcome == "ok" && r.module == "tinyjuice"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -81,14 +77,12 @@ async fn a_streamed_blob_is_still_bound_by_the_grant_and_the_length() {
let outside = rig.member("StreamPut", ("juice/other/x", 2 * MIB)).await;
assert!(outside.get("err").is_some(), "{outside}");
let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
- assert!(
- handle
- .blobs()
- .head("juice/other/x")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(handle
+ .blobs()
+ .head("juice/other/x")
+ .await
+ .unwrap()
+ .is_none());
let denied_get = rig.member("StreamGet", ("juice/other/x",)).await;
assert!(
denied_get["err"].to_string().contains("target-not-granted"),
@@ -119,14 +113,12 @@ async fn an_inline_blob_no_frame_can_carry_fails_fast_instead_of_hanging() {
started.elapsed()
);
let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
- assert!(
- handle
- .blobs()
- .head("juice/ccr/over-frame")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(handle
+ .blobs()
+ .head("juice/ccr/over-frame")
+ .await
+ .unwrap()
+ .is_none());
let after: Value = rig.member("PutBlob", ("juice/ccr/after", 2048usize)).await;
assert!(
after.get("ok").is_some(),
@@ -150,11 +142,9 @@ async fn a_watch_signal_reaches_the_module_that_opened_the_watch() {
.await;
assert!(denied(&refused, "target-not-granted"), "{refused}");
let trail = rig.trail.0.lock().unwrap().clone();
- assert!(
- trail
- .iter()
- .any(|r| r.op == "WatchOpen" && r.outcome == "ok" && r.module == "tinymcp")
- );
+ assert!(trail
+ .iter()
+ .any(|r| r.op == "WatchOpen" && r.outcome == "ok" && r.module == "tinymcp"));
}
#[tokio::test(flavor = "multi_thread")]
@@ -259,14 +249,12 @@ async fn a_second_module_cannot_read_or_take_the_first_modules_streams() {
"a peer took another peer's stream: {hijack:?}"
);
let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
- assert!(
- handle
- .blobs()
- .head("juice/ccr/hijacked")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(handle
+ .blobs()
+ .head("juice/ccr/hijacked")
+ .await
+ .unwrap()
+ .is_none());
// The refused attempt did not spend the stream: its owner still uses it.
let used = rig.member("UseStream", ("juice/ccr/owned", MIB)).await;
assert!(
diff --git a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
index 54609b0e44..8a7c7bc2f7 100644
--- a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
@@ -23,7 +23,7 @@
use std::path::{Path, PathBuf};
use std::sync::{Mutex, OnceLock};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinybus::broker::Broker;
use tinybus::module::ModuleHost;
use tinybus::transport::memory::MemoryBus;
@@ -31,9 +31,9 @@ use tinybus::{Connection, Proxy};
use tinystoragedrivers::secrets::{DerivedKeys, KeyProvider};
use zeroize::Zeroizing;
-use crate::modules::storage_grants::{StorageGrant, declared};
+use crate::modules::storage_grants::{declared, StorageGrant};
use crate::modules::storage_host::{
- AuditRecord, AuditSink, CallerDirectory, Environment, StorageHost, module_scope,
+ module_scope, AuditRecord, AuditSink, CallerDirectory, Environment, StorageHost,
};
use crate::modules::storage_host_linked::attach;
use crate::storage::{Scope, StorageBackend, StorageError};
@@ -300,13 +300,12 @@ async fn a_loaded_module_reads_and_writes_its_own_granted_collection() {
assert!(read.to_string().contains("qualified_name"), "{read}");
// It landed in the module's own scope, in the backend the host opened.
let own = rig.backend.for_scope(&rig.scope("tinymcp")).unwrap();
- assert!(
- own.documents()
- .get("mcp.servers", "files")
- .await
- .unwrap()
- .is_some()
- );
+ assert!(own
+ .documents()
+ .get("mcp.servers", "files")
+ .await
+ .unwrap()
+ .is_some());
}
#[tokio::test(flavor = "multi_thread")]
@@ -367,22 +366,19 @@ async fn a_loaded_module_cannot_reach_another_modules_collections() {
}
// Untouched: the refusal came before the backend.
let after = victim.documents().get(&theirs, "session").await.unwrap();
- assert!(
- after
- .expect("the other module's document survives")
- .doc
- .to_string()
- .contains("OTHER-MODULES-SECRET")
- );
+ assert!(after
+ .expect("the other module's document survives")
+ .doc
+ .to_string()
+ .contains("OTHER-MODULES-SECRET"));
// And its own scope never got the collection.
let own = rig.backend.for_scope(&rig.scope("tinymcp")).unwrap();
- assert!(
- !own.documents()
- .collections("")
- .await
- .unwrap()
- .contains(&theirs)
- );
+ assert!(!own
+ .documents()
+ .collections("")
+ .await
+ .unwrap()
+ .contains(&theirs));
}
#[tokio::test(flavor = "multi_thread")]
@@ -436,14 +432,12 @@ async fn a_loaded_module_cannot_name_or_reach_another_scope() {
assert!(wrote.get("ok").is_some(), "{wrote}");
for scope in [Scope::local(), Scope::new("someone-else").unwrap()] {
let handle = rig.backend.for_scope(&scope).unwrap();
- assert!(
- handle
- .documents()
- .get("mcp.servers", "mine")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(handle
+ .documents()
+ .get("mcp.servers", "mine")
+ .await
+ .unwrap()
+ .is_none());
}
}
@@ -574,14 +568,12 @@ async fn a_blob_over_the_inline_cap_is_refused_and_stores_nothing() {
"an oversized inline blob must fail: {big}"
);
let handle = rig.backend.for_scope(&rig.scope("tinyjuice")).unwrap();
- assert!(
- handle
- .blobs()
- .head("juice/ccr/over-cap")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(handle
+ .blobs()
+ .head("juice/ccr/over-cap")
+ .await
+ .unwrap()
+ .is_none());
// The refusal does not take the module's connection down with it.
let after: Value = rig
.probe
@@ -619,16 +611,12 @@ async fn every_call_is_audited_under_the_module_id_without_a_payload() {
.await;
let trail = rig.trail.0.lock().unwrap().clone();
assert!(trail.iter().all(|record| record.module == "tinymcp"));
- assert!(
- trail
- .iter()
- .any(|record| record.op == "Put" && record.outcome == "ok")
- );
- assert!(
- trail
- .iter()
- .any(|record| record.outcome == "target-not-granted")
- );
+ assert!(trail
+ .iter()
+ .any(|record| record.op == "Put" && record.outcome == "ok"));
+ assert!(trail
+ .iter()
+ .any(|record| record.outcome == "target-not-granted"));
assert!(!format!("{trail:?}").contains("PAYLOAD-MARKER"));
}
diff --git a/crates/openhuman-core/src/modules/storage_host_queues_tests.rs b/crates/openhuman-core/src/modules/storage_host_queues_tests.rs
index 88ca08163f..977d6f3895 100644
--- a/crates/openhuman-core/src/modules/storage_host_queues_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_queues_tests.rs
@@ -5,9 +5,9 @@
use super::*;
use crate::modules::storage_queue_manifest::QueueManifest;
-use tinybus::Connection;
use tinybus::broker::Broker;
use tinybus::transport::memory::MemoryBus;
+use tinybus::Connection;
use tinystoragedrivers::ErrorKind;
use tinystoragedrivers_types::{NewMessage, QueueSpec};
@@ -106,13 +106,11 @@ async fn a_module_granted_a_manifest_enqueues_receives_and_acks_over_the_bus() {
assert_eq!(leased.len(), 1);
assert_eq!(leased[0].payload, json!({"n": 1}));
assert!(queues.ack("inbox", &leased[0].receipt).await.unwrap());
- assert!(
- queues
- .receive("inbox", 4, 30_000, "test")
- .await
- .unwrap()
- .is_empty()
- );
+ assert!(queues
+ .receive("inbox", 4, 30_000, "test")
+ .await
+ .unwrap()
+ .is_empty());
// The messages live in the module's own scope on the host backend.
let scope = module_scope(None, "alpha").unwrap();
diff --git a/crates/openhuman-core/src/modules/storage_host_stream_tests.rs b/crates/openhuman-core/src/modules/storage_host_stream_tests.rs
index 11b528a694..6b821d25a5 100644
--- a/crates/openhuman-core/src/modules/storage_host_stream_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_stream_tests.rs
@@ -50,11 +50,9 @@ async fn a_streamed_blob_is_stored_in_the_callers_scope_and_read_back() {
.unwrap();
assert!(other.is_none());
let trail = rig.trail.0.lock().unwrap().clone();
- assert!(
- trail
- .iter()
- .any(|r| r.op == "PutStream" && r.outcome == "ok" && r.module == "alpha")
- );
+ assert!(trail
+ .iter()
+ .any(|r| r.op == "PutStream" && r.outcome == "ok" && r.module == "alpha"));
}
#[tokio::test]
@@ -96,16 +94,15 @@ async fn a_streamed_blob_is_decided_like_any_other_call() {
));
// Nothing was stored by any of the refusals.
let scope = rig.env.module_scope("alpha").unwrap();
- assert!(
- rig.backend
- .for_scope(&scope)
- .unwrap()
- .blobs()
- .head("files/a")
- .await
- .unwrap()
- .is_none()
- );
+ assert!(rig
+ .backend
+ .for_scope(&scope)
+ .unwrap()
+ .blobs()
+ .head("files/a")
+ .await
+ .unwrap()
+ .is_none());
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/modules/storage_host_tests.rs b/crates/openhuman-core/src/modules/storage_host_tests.rs
index 4bf15d36a0..f837c18eb4 100644
--- a/crates/openhuman-core/src/modules/storage_host_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::Mutex;
use serde_json::json;
use tinystoragedrivers::secrets::DerivedKeys;
diff --git a/crates/openhuman-core/src/storage/blob_sweep_tests.rs b/crates/openhuman-core/src/storage/blob_sweep_tests.rs
index aa8426622f..9b6a5b47ec 100644
--- a/crates/openhuman-core/src/storage/blob_sweep_tests.rs
+++ b/crates/openhuman-core/src/storage/blob_sweep_tests.rs
@@ -95,12 +95,10 @@ async fn module_blob_scopes_are_swept_alongside_the_acting_scope() {
#[cfg(not(feature = "modules"))]
#[test]
fn no_module_blob_scopes_without_the_modules_feature() {
- assert!(
- crate::modules::expiring_blob_module_scopes(
- &crate::core::runtime::DispatchCtx::host_default()
- )
- .is_empty()
- );
+ assert!(crate::modules::expiring_blob_module_scopes(
+ &crate::core::runtime::DispatchCtx::host_default()
+ )
+ .is_empty());
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/storage/lease_documents.rs b/crates/openhuman-core/src/storage/lease_documents.rs
index 5aedc1f43f..721b0df2b1 100644
--- a/crates/openhuman-core/src/storage/lease_documents.rs
+++ b/crates/openhuman-core/src/storage/lease_documents.rs
@@ -14,10 +14,10 @@ use tinystoragedrivers::{
Version, Versioned, WriteOptions,
};
-use super::StorageError;
use super::lease::{
- CLUSTER_SCOPE, LEASE_COLLECTION, LeaseError, LeaseGrant, LeaseRecord, LeaseStore, validate_key,
+ validate_key, LeaseError, LeaseGrant, LeaseRecord, LeaseStore, CLUSTER_SCOPE, LEASE_COLLECTION,
};
+use super::StorageError;
/// The owner namespace of the host's process-placement lease documents.
pub const LEASE_OWNER: &str = "profiles";
diff --git a/crates/openhuman-core/src/storage/mod_tests.rs b/crates/openhuman-core/src/storage/mod_tests.rs
index 1944e2b31e..b1f08a7bb4 100644
--- a/crates/openhuman-core/src/storage/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/mod_tests.rs
@@ -3,7 +3,9 @@ use super::*;
fn round_trip_through_storage_bridge() -> serde_json::Value {
let backend: Arc<dyn StorageBackend> =
Arc::new(tinystoragedrivers_testkit::MemoryBackend::new());
- let storage = backend.for_scope(&Scope::new("bridge-test").unwrap()).unwrap();
+ let storage = backend
+ .for_scope(&Scope::new("bridge-test").unwrap())
+ .unwrap();
let docs = Arc::clone(storage.documents());
block_on(async move {
docs.ensure_collection(&CollectionSpec::new("bridge.records"))
@@ -157,12 +159,18 @@ fn block_on_runs_a_future_from_sync_code() {
#[tokio::test(flavor = "current_thread")]
async fn block_on_works_inside_a_current_thread_runtime() {
- assert_eq!(round_trip_through_storage_bridge(), serde_json::json!({"value": 42}));
+ assert_eq!(
+ round_trip_through_storage_bridge(),
+ serde_json::json!({"value": 42})
+ );
}
#[tokio::test(flavor = "multi_thread")]
async fn block_on_works_inside_a_multi_thread_runtime() {
- assert_eq!(round_trip_through_storage_bridge(), serde_json::json!({"value": 42}));
+ assert_eq!(
+ round_trip_through_storage_bridge(),
+ serde_json::json!({"value": 42})
+ );
}
#[test]