Skip to content

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

chore(modules): apply rustfmt formatting to storage import code

Steven Enamakel9274bc019212
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index 60210974d0..372b8e4eb0 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -151,6 +151,7 @@ pub async fn install_from_config(config: &crate::config::Config) -> Result<(), S
// disk tier wrote move across first (once per directory, best effort).
if let Some(root) = request.disk_tier_root.as_deref() {
crate::modules::import_legacy_tinyjuice(
+ &crate::core::runtime::DispatchCtx::ambient(),
std::path::Path::new(root),
request.ccr_ttl_secs.map(std::time::Duration::from_secs),
)
diff --git a/crates/openhuman-core/src/mcp/module_client.rs b/crates/openhuman-core/src/mcp/module_client.rs
index bdef0e0063..3c03fbac08 100644
--- a/crates/openhuman-core/src/mcp/module_client.rs
+++ b/crates/openhuman-core/src/mcp/module_client.rs
@@ -464,7 +464,11 @@ impl McpConfiguredClient {
// Servers and audit rows from before the storage contract
// move into the module's storage before it reads them.
// Best effort: a failure is retried at the next open.
- crate::modules::import_legacy_mcp(&crate::core::runtime::DispatchCtx::ambient(), std::path::Path::new(&self.data_dir)).await;
+ crate::modules::import_legacy_mcp(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ std::path::Path::new(&self.data_dir),
+ )
+ .await;
let reply = self.port.open_configured(&self.data_dir, &config).await;
state.open_replied(reply.clone().map_err(|_| ()));
reply?;
diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rs
index 2fc2dd8854..51469e3c59 100644
--- a/crates/openhuman-core/src/modules/connectors.rs
+++ b/crates/openhuman-core/src/modules/connectors.rs
@@ -283,7 +283,11 @@ async fn ensure_routed(config: &Config, proxy: &Proxy) -> Result<(), String> {
// Preferences and trigger history from before the storage contract move
// into the module's storage before it first serves a call. Once per state
// directory, best effort: a failure is retried on the next call.
- super::import_legacy_connectors(&crate::core::runtime::DispatchCtx::ambient(), &config.workspace_dir.join("state")).await;
+ super::import_legacy_connectors(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config.workspace_dir.join("state"),
+ )
+ .await;
let current = fingerprint(&route);
if *last_route()
diff --git a/crates/openhuman-core/src/modules/import_once_tests.rs b/crates/openhuman-core/src/modules/import_once_tests.rs
index 86909ef9a1..6f92163191 100644
--- a/crates/openhuman-core/src/modules/import_once_tests.rs
+++ b/crates/openhuman-core/src/modules/import_once_tests.rs
@@ -14,19 +14,31 @@ async fn a_concurrent_caller_waits_for_the_running_import() {
let dir = std::path::PathBuf::from("/import-once/concurrent");
let finished = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
let flag = finished.clone();
- let first = import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-concurrent", MODULE_FOR_TEST, &dir, async move {
- tokio::time::sleep(std::time::Duration::from_millis(100)).await;
- flag.store(true, std::sync::atomic::Ordering::SeqCst);
- Ok(Done(true))
- });
+ let first = import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-concurrent",
+ MODULE_FOR_TEST,
+ &dir,
+ async move {
+ tokio::time::sleep(std::time::Duration::from_millis(100)).await;
+ flag.store(true, std::sync::atomic::Ordering::SeqCst);
+ Ok(Done(true))
+ },
+ );
let flag = finished.clone();
let second = async {
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
- import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-concurrent", MODULE_FOR_TEST, &dir, async {
- panic!("a settled import must not run a second time");
- #[allow(unreachable_code)]
- Ok(Done(true))
- })
+ import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-concurrent",
+ MODULE_FOR_TEST,
+ &dir,
+ async {
+ panic!("a settled import must not run a second time");
+ #[allow(unreachable_code)]
+ Ok(Done(true))
+ },
+ )
.await;
flag.load(std::sync::atomic::Ordering::SeqCst)
};
@@ -42,29 +54,53 @@ async fn an_unsettled_outcome_and_a_cancelled_import_are_retried() {
let dir = std::path::PathBuf::from("/import-once/retry");
let runs = std::sync::atomic::AtomicUsize::new(0);
let count = || runs.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
- import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
- count();
- Ok(Done(false))
- })
+ import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-retry",
+ MODULE_FOR_TEST,
+ &dir,
+ async {
+ count();
+ Ok(Done(false))
+ },
+ )
.await;
let cancelled = tokio::time::timeout(
std::time::Duration::from_millis(500),
- import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
- count();
- std::future::pending::<anyhow::Result<Done>>().await
- }),
+ import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-retry",
+ MODULE_FOR_TEST,
+ &dir,
+ async {
+ count();
+ std::future::pending::<anyhow::Result<Done>>().await
+ },
+ ),
)
.await;
assert!(cancelled.is_err());
- import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
- count();
- Ok(Done(true))
- })
+ import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-retry",
+ MODULE_FOR_TEST,
+ &dir,
+ async {
+ count();
+ Ok(Done(true))
+ },
+ )
.await;
- import_once(&crate::core::runtime::DispatchCtx::host_default(), "test-retry", MODULE_FOR_TEST, &dir, async {
- count();
- Ok(Done(true))
- })
+ import_once(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ "test-retry",
+ MODULE_FOR_TEST,
+ &dir,
+ async {
+ count();
+ Ok(Done(true))
+ },
+ )
.await;
assert_eq!(runs.load(std::sync::atomic::Ordering::SeqCst), 3);
}
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rs
index 9a02edbf72..bbac80e115 100644
--- a/crates/openhuman-core/src/modules/mod.rs
+++ b/crates/openhuman-core/src/modules/mod.rs
@@ -271,7 +271,10 @@ where
/// Imports the connector module's legacy preference and trigger-archive files
/// under `state_dir` into its storage, once per directory. Never fails the
/// caller: an error is logged and the import is retried at the next call.
-pub async fn import_legacy_connectors(ctx: &crate::core::runtime::DispatchCtx, state_dir: &std::path::Path) {
+pub async fn import_legacy_connectors(
+ ctx: &crate::core::runtime::DispatchCtx,
+ state_dir: &std::path::Path,
+) {
#[cfg(feature = "modules")]
import_once(
ctx,
@@ -290,7 +293,10 @@ pub async fn import_legacy_connectors(ctx: &crate::core::runtime::DispatchCtx, s
/// caller: an error is logged and the import is retried at the next call. Returns
/// false when the import failed, so the caller can refuse to open a ledger that
/// would ignore the legacy payments.
-pub async fn import_legacy_x402(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &std::path::Path) -> bool {
+pub async fn import_legacy_x402(
+ ctx: &crate::core::runtime::DispatchCtx,
+ workspace_dir: &std::path::Path,
+) -> bool {
#[cfg(all(feature = "modules", feature = "web3"))]
return import_once(
ctx,
@@ -310,7 +316,10 @@ pub async fn import_legacy_x402(ctx: &crate::core::runtime::DispatchCtx, workspa
/// Imports the legacy jail registry index under `<workspace_dir>/jails` into
/// the tinybox module's storage, once. Never fails the caller: an error is
/// logged and the import is retried at the next call.
-pub async fn import_legacy_tinybox(ctx: &crate::core::runtime::DispatchCtx, workspace_dir: &std::path::Path) {
+pub async fn import_legacy_tinybox(
+ ctx: &crate::core::runtime::DispatchCtx,
+ workspace_dir: &std::path::Path,
+) {
#[cfg(feature = "modules")]
import_once(
ctx,
diff --git a/crates/openhuman-core/src/modules/storage_host_endpoint.rs b/crates/openhuman-core/src/modules/storage_host_endpoint.rs
index 549cc0c7c0..e49bcae7d2 100644
--- a/crates/openhuman-core/src/modules/storage_host_endpoint.rs
+++ b/crates/openhuman-core/src/modules/storage_host_endpoint.rs
@@ -102,26 +102,28 @@ impl StorageHost {
let mut signals = binding.server.signals();
let tx = relay.tx.clone();
relay.fed_by = Some(Arc::downgrade(binding));
- relay.bridge = Some(crate::core::runtime::DispatchCtx::ambient().spawn(async move {
- loop {
- match signals.recv().await {
- Ok(signal) => {
- // No receiver just means the bus forwarder is gone.
- let _ = tx.send(signal);
+ relay.bridge = Some(
+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {
+ loop {
+ match signals.recv().await {
+ Ok(signal) => {
+ // No receiver just means the bus forwarder is gone.
+ let _ = tx.send(signal);
+ }
+ Err(broadcast::error::RecvError::Lagged(missed)) => {
+ // The watch ids in the skipped batch are gone; the
+ // signal carries no reset form, so record the loss.
+ tracing::warn!(
+ target: "storage_host",
+ missed,
+ "[storage-host] watch relay lagged; dropped watch signals"
+ );
+ }
+ Err(broadcast::error::RecvError::Closed) => return,
}
- Err(broadcast::error::RecvError::Lagged(missed)) => {
- // The watch ids in the skipped batch are gone; the
- // signal carries no reset form, so record the loss.
- tracing::warn!(
- target: "storage_host",
- missed,
- "[storage-host] watch relay lagged; dropped watch signals"
- );
- }
- Err(broadcast::error::RecvError::Closed) => return,
}
- }
- }));
+ }),
+ );
}
}
diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
index 2706f9ada9..1983436302 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs
@@ -26,8 +26,8 @@ use serde_json::{json, Value};
use tinystoragedrivers::{CollectionSpec, ScopedStorage};
use super::storage_grant_tinybox::{JAIL_INDEX_COLLECTION, MODULE_ID};
-use crate::core::runtime::DispatchCtx;
use super::storage_import_support as support;
+use crate::core::runtime::DispatchCtx;
const LOG_PREFIX: &str = "[tinybox-import]";
/// The registry the module opens over the workspace's jails directory.
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
index 5a9193d8a1..f2238fd863 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs
@@ -27,8 +27,8 @@ use serde_json::{json, Value};
use tinystoragedrivers::{CollectionSpec, ScopedStorage};
use super::storage_grant_tinyconnectors::{MODULE_ID, PREFS_COLLECTION, TRIGGER_STREAM_PREFIX};
-use crate::core::runtime::DispatchCtx;
use super::storage_import_support as support;
+use crate::core::runtime::DispatchCtx;
const LOG_PREFIX: &str = "[connectors-import]";
const PREFS_DIR: &str = "composio-user-scopes";
@@ -96,10 +96,10 @@ async fn import_into(
return Ok(Outcome::NoSource);
}
- let legacy =
- ctx.spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir))
- .await
- .context("the legacy reader panicked")??;
+ let legacy = ctx
+ .spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir))
+ .await
+ .context("the legacy reader panicked")??;
docs.ensure_collection(&CollectionSpec::new(PREFS_COLLECTION))
.await
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs
index 3e95b8bf42..96dc6c0a4c 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs
@@ -70,7 +70,9 @@ fn tree_digest(root: &Path) -> Vec<(String, Vec<u8>)> {
async fn preferences_and_the_trigger_archive_move_into_the_modules_storage() {
let legacy = legacy_state();
let scoped = scoped();
- let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap();
+ let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap();
// gmail + slack; the corrupt preference, the non-day archive name and the
// unparsable archive line are skipped.
assert_eq!(
@@ -117,7 +119,9 @@ async fn preferences_and_the_trigger_archive_move_into_the_modules_storage() {
async fn the_legacy_files_are_left_untouched() {
let legacy = legacy_state();
let before = tree_digest(legacy.path());
- import_into(&DispatchCtx::host_default(), &scoped(), legacy.path()).await.unwrap();
+ import_into(&DispatchCtx::host_default(), &scoped(), legacy.path())
+ .await
+ .unwrap();
assert_eq!(tree_digest(legacy.path()), before);
}
@@ -125,7 +129,9 @@ async fn the_legacy_files_are_left_untouched() {
async fn a_second_run_is_a_noop_even_after_the_module_changed_the_data() {
let legacy = legacy_state();
let scoped = scoped();
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap();
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap();
// The user later deletes a preference; the untouched file must not bring
// it back.
scoped
@@ -134,7 +140,9 @@ async fn a_second_run_is_a_noop_even_after_the_module_changed_the_data() {
.await
.unwrap();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::AlreadyDone
);
assert!(scoped
@@ -165,7 +173,9 @@ async fn records_the_module_already_wrote_are_never_replaced_or_duplicated() {
.await
.unwrap();
- let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap();
+ let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap();
assert_eq!(
outcome,
Outcome::Imported {
@@ -195,13 +205,17 @@ async fn a_state_directory_without_legacy_files_writes_no_marker() {
let empty = tempfile::tempdir().unwrap();
let scoped = scoped();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, empty.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, empty.path())
+ .await
+ .unwrap(),
Outcome::NoSource
);
// Files that show up later (an older build still running) are still taken.
let legacy = legacy_state();
assert!(matches!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::Imported { .. }
));
}
@@ -216,7 +230,11 @@ async fn an_unreadable_preference_file_is_retried_instead_of_marked_done() {
)
.unwrap();
let scoped = scoped();
- assert!(import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.is_err());
+ assert!(
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .is_err()
+ );
assert!(scoped
.documents()
.get(PREFS_COLLECTION, "gmail")
@@ -226,7 +244,9 @@ async fn an_unreadable_preference_file_is_retried_instead_of_marked_done() {
std::fs::remove_file(legacy.path().join(PREFS_DIR).join("bad.json")).unwrap();
assert!(matches!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::Imported { prefs: 2, .. }
));
}
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
index 178a8b1fec..75edd9c104 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs
@@ -28,8 +28,8 @@ use serde_json::json;
use tinystoragedrivers::{Capability, ScopedStorage};
use super::storage_grant_tinyjuice::{CCR_BLOB_PREFIX, MODULE_ID};
-use crate::core::runtime::DispatchCtx;
use super::storage_import_support as support;
+use crate::core::runtime::DispatchCtx;
const LOG_PREFIX: &str = "[tinyjuice-import]";
/// `tinyjuice::cache::store::short_hash`: 16 bytes, hex encoded.
@@ -59,7 +59,11 @@ pub(crate) enum Outcome {
/// Imports the CCR files under `root` into the module's scope of the installed
/// backend. `ttl` is the configured original lifetime; `None` keeps them.
-pub(crate) async fn import_legacy(ctx: &DispatchCtx, root: &Path, ttl: Option<Duration>) -> Result<Outcome> {
+pub(crate) async fn import_legacy(
+ ctx: &DispatchCtx,
+ root: &Path,
+ ttl: Option<Duration>,
+) -> Result<Outcome> {
let Some(scoped) = support::module_scope(ctx, MODULE_ID)? else {
return Ok(Outcome::NoBackend);
};
@@ -94,10 +98,10 @@ async fn import_into(
}
let dir = root.to_owned();
- let (originals, mut skipped) =
- ctx.spawn_blocking(move || read_originals(&dir, now))
- .await
- .context("the legacy reader panicked")??;
+ let (originals, mut skipped) = ctx
+ .spawn_blocking(move || read_originals(&dir, now))
+ .await
+ .context("the legacy reader panicked")??;
let (mut imported, mut expired) = (0usize, 0usize);
for original in originals {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs
index 442d24a4fc..9302591773 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs
@@ -49,7 +49,8 @@ async fn read(scoped: &ScopedStorage, token: &str) -> Option<String> {
async fn originals_within_their_ttl_move_into_the_modules_blobs() {
let legacy = legacy_root();
let scoped = scoped();
- let outcome = import_into(&DispatchCtx::host_default(),
+ let outcome = import_into(
+ &DispatchCtx::host_default(),
&scoped,
legacy.path(),
Some(Duration::from_secs(3600)),
@@ -83,9 +84,15 @@ async fn originals_within_their_ttl_move_into_the_modules_blobs() {
async fn without_a_ttl_every_readable_original_is_kept() {
let legacy = legacy_root();
let scoped = scoped();
- let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path(), None, SystemTime::now())
- .await
- .unwrap();
+ let outcome = import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ legacy.path(),
+ None,
+ SystemTime::now(),
+ )
+ .await
+ .unwrap();
assert_eq!(
outcome,
Outcome::Imported {
@@ -100,9 +107,15 @@ async fn without_a_ttl_every_readable_original_is_kept() {
#[tokio::test]
async fn the_legacy_files_are_left_in_place() {
let legacy = legacy_root();
- import_into(&DispatchCtx::host_default(), &scoped(), legacy.path(), None, SystemTime::now())
- .await
- .unwrap();
+ import_into(
+ &DispatchCtx::host_default(),
+ &scoped(),
+ legacy.path(),
+ None,
+ SystemTime::now(),
+ )
+ .await
+ .unwrap();
assert_eq!(
std::fs::read_to_string(legacy.path().join(FRESH)).unwrap(),
"fresh original\nline two"
@@ -123,9 +136,15 @@ async fn a_second_run_is_a_noop_and_a_blob_already_stored_is_kept() {
)
.await
.unwrap();
- let first = import_into(&DispatchCtx::host_default(), &scoped, legacy.path(), None, SystemTime::now())
- .await
- .unwrap();
+ let first = import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ legacy.path(),
+ None,
+ SystemTime::now(),
+ )
+ .await
+ .unwrap();
assert_eq!(
first,
Outcome::Imported {
@@ -139,9 +158,15 @@ async fn a_second_run_is_a_noop_and_a_blob_already_stored_is_kept() {
Some("written by the module")
);
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path(), None, SystemTime::now())
- .await
- .unwrap(),
+ import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ legacy.path(),
+ None,
+ SystemTime::now()
+ )
+ .await
+ .unwrap(),
Outcome::AlreadyDone
);
}
@@ -152,17 +177,29 @@ async fn a_missing_directory_writes_no_marker() {
let missing = dir.path().join("ccr");
let scoped = scoped();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, &missing, None, SystemTime::now())
- .await
- .unwrap(),
+ import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ &missing,
+ None,
+ SystemTime::now()
+ )
+ .await
+ .unwrap(),
Outcome::NoSource
);
std::fs::create_dir(&missing).unwrap();
std::fs::write(missing.join(FRESH), "late").unwrap();
assert!(matches!(
- import_into(&DispatchCtx::host_default(), &scoped, &missing, None, SystemTime::now())
- .await
- .unwrap(),
+ import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ &missing,
+ None,
+ SystemTime::now()
+ )
+ .await
+ .unwrap(),
Outcome::Imported { imported: 1, .. }
));
}
@@ -188,9 +225,15 @@ async fn a_symlinked_token_is_never_followed_into_storage() {
let dir = tempfile::tempdir().unwrap();
std::os::unix::fs::symlink(outside.path().join("secret"), dir.path().join(FRESH)).unwrap();
let scoped = scoped();
- let outcome = import_into(&DispatchCtx::host_default(), &scoped, dir.path(), None, SystemTime::now())
- .await
- .unwrap();
+ let outcome = import_into(
+ &DispatchCtx::host_default(),
+ &scoped,
+ dir.path(),
+ None,
+ SystemTime::now(),
+ )
+ .await
+ .unwrap();
assert!(matches!(
outcome,
Outcome::Imported {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
index e86d31e211..6bda90c9c6 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs
@@ -111,8 +111,8 @@ async fn import_into(
}
// The files are read on a blocking thread, from copies.
- let (legacy_servers, legacy_audit) =
- ctx.spawn_blocking(move || -> Result<_> {
+ let (legacy_servers, legacy_audit) = ctx
+ .spawn_blocking(move || -> Result<_> {
let servers = if clients.exists() {
read_servers(&clients)?
} else {
diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
index 2f413b9291..702edbd3b7 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs
@@ -77,9 +77,14 @@ fn digest(path: &Path) -> Vec<u8> {
async fn servers_env_and_audit_rows_move_into_the_modules_storage() {
let legacy = legacy_dir();
let rig = rig();
- let outcome = import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, legacy.path())
- .await
- .unwrap();
+ let outcome = import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ legacy.path(),
+ )
+ .await
+ .unwrap();
assert_eq!(
outcome,
Outcome::Imported {
@@ -141,18 +146,28 @@ async fn servers_env_and_audit_rows_move_into_the_modules_storage() {
async fn the_import_runs_once_and_never_resurrects_a_deleted_server() {
let legacy = legacy_dir();
let rig = rig();
- import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, legacy.path())
- .await
- .unwrap();
+ import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ legacy.path(),
+ )
+ .await
+ .unwrap();
let docs = rig.scoped.documents();
let held = docs.get(SERVERS, "srv-1").await.unwrap().unwrap();
docs.delete(SERVERS, "srv-1", held.unchanged())
.await
.unwrap();
- let again = import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, legacy.path())
- .await
- .unwrap();
+ let again = import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ legacy.path(),
+ )
+ .await
+ .unwrap();
assert_eq!(again, Outcome::AlreadyDone);
assert!(docs.get(SERVERS, "srv-1").await.unwrap().is_none());
assert_eq!(
@@ -167,9 +182,14 @@ async fn the_legacy_files_are_left_untouched() {
let legacy = legacy_dir();
let before = [CLIENTS_DB, AUDIT_DB].map(|path| digest(&legacy.path().join(path)));
let rig = rig();
- import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, legacy.path())
- .await
- .unwrap();
+ import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ legacy.path(),
+ )
+ .await
+ .unwrap();
let after = [CLIENTS_DB, AUDIT_DB].map(|path| digest(&legacy.path().join(path)));
assert_eq!(before, after);
assert!(!legacy
@@ -199,9 +219,14 @@ async fn a_record_the_module_already_wrote_is_not_overwritten() {
.await
.unwrap();
- let outcome = import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, legacy.path())
- .await
- .unwrap();
+ let outcome = import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ legacy.path(),
+ )
+ .await
+ .unwrap();
assert_eq!(
outcome,
Outcome::Imported {
@@ -226,9 +251,14 @@ async fn a_data_dir_with_no_legacy_files_is_a_no_op() {
let empty = tempfile::tempdir().unwrap();
let rig = rig();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, empty.path())
- .await
- .unwrap(),
+ import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ empty.path()
+ )
+ .await
+ .unwrap(),
Outcome::NoSource
);
}
@@ -244,9 +274,14 @@ async fn an_unreadable_file_writes_no_marker_so_the_next_start_retries() {
)
.unwrap();
let rig = rig();
- assert!(import_into(&DispatchCtx::host_default(), &rig.scoped, &rig.secrets, dir.path())
- .await
- .is_err());
+ assert!(import_into(
+ &DispatchCtx::host_default(),
+ &rig.scoped,
+ &rig.secrets,
+ dir.path()
+ )
+ .await
+ .is_err());
let marker = rig
.scoped
.documents()
diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
index 7289527029..faf4e585d4 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs
@@ -27,8 +27,8 @@ use serde_json::json;
use tinystoragedrivers::ScopedStorage;
use super::storage_grant_tinywallet::{MODULE_ID, PAYMENTS_STREAM};
-use crate::core::runtime::DispatchCtx;
use super::storage_import_support as support;
+use crate::core::runtime::DispatchCtx;
const LOG_PREFIX: &str = "[x402-import]";
const LEDGER_FILE: &str = "x402/payments.jsonl";
@@ -71,13 +71,14 @@ async fn import_into(
if !ledger.is_file() {
return Ok(Outcome::NoSource);
}
- let (records, skipped) = ctx.spawn_blocking(move || -> Result<_> {
- let text = std::fs::read_to_string(&ledger)
- .with_context(|| format!("read {}", ledger.display()))?;
- Ok(support::parse_jsonl(&text))
- })
- .await
- .context("the legacy reader panicked")??;
+ let (records, skipped) = ctx
+ .spawn_blocking(move || -> Result<_> {
+ let text = std::fs::read_to_string(&ledger)
+ .with_context(|| format!("read {}", ledger.display()))?;
+ Ok(support::parse_jsonl(&text))
+ })
+ .await
+ .context("the legacy reader panicked")??;
let payments = support::append_if_empty(scoped, PAYMENTS_STREAM, records)
.await
diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs
index 3f9ef05843..3857958e18 100644
--- a/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs
@@ -41,7 +41,9 @@ fn digest(path: &Path) -> Vec<u8> {
async fn the_payment_history_moves_into_the_modules_stream_in_order() {
let legacy = legacy_workspace();
let scoped = scoped();
- let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap();
+ let outcome = import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap();
assert_eq!(
outcome,
Outcome::Imported {
@@ -77,7 +79,9 @@ async fn the_legacy_ledger_is_left_untouched() {
let legacy = legacy_workspace();
let file = legacy.path().join(LEDGER_FILE);
let before = digest(&file);
- import_into(&DispatchCtx::host_default(), &scoped(), legacy.path()).await.unwrap();
+ import_into(&DispatchCtx::host_default(), &scoped(), legacy.path())
+ .await
+ .unwrap();
assert_eq!(digest(&file), before);
}
@@ -85,9 +89,13 @@ async fn the_legacy_ledger_is_left_untouched() {
async fn a_second_run_does_not_repeat_the_history() {
let legacy = legacy_workspace();
let scoped = scoped();
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap();
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::AlreadyDone
);
assert_eq!(scoped.streams().len(PAYMENTS_STREAM).await.unwrap(), 3);
@@ -106,7 +114,9 @@ async fn a_stream_the_module_already_wrote_is_not_preceded_by_old_records() {
.await
.unwrap();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::Imported {
payments: 0,
skipped: 1
@@ -120,12 +130,16 @@ async fn a_workspace_without_a_ledger_writes_no_marker() {
let empty = tempfile::tempdir().unwrap();
let scoped = scoped();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, empty.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, empty.path())
+ .await
+ .unwrap(),
Outcome::NoSource
);
let legacy = legacy_workspace();
assert!(matches!(
- import_into(&DispatchCtx::host_default(), &scoped, legacy.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, legacy.path())
+ .await
+ .unwrap(),
Outcome::Imported { .. }
));
}
@@ -137,12 +151,18 @@ async fn an_unreadable_ledger_is_retried_instead_of_marked_done() {
std::fs::create_dir_all(file.parent().unwrap()).unwrap();
std::fs::write(&file, [0xff, 0xfe]).unwrap();
let scoped = scoped();
- assert!(import_into(&DispatchCtx::host_default(), &scoped, dir.path()).await.is_err());
+ assert!(
+ import_into(&DispatchCtx::host_default(), &scoped, dir.path())
+ .await
+ .is_err()
+ );
assert_eq!(scoped.streams().len(PAYMENTS_STREAM).await.unwrap(), 0);
std::fs::write(&file, format!("{}\n", record("p1", "settled"))).unwrap();
assert_eq!(
- import_into(&DispatchCtx::host_default(), &scoped, dir.path()).await.unwrap(),
+ import_into(&DispatchCtx::host_default(), &scoped, dir.path())
+ .await
+ .unwrap(),
Outcome::Imported {
payments: 1,
skipped: 0
diff --git a/crates/openhuman-core/src/modules/tinybox.rs b/crates/openhuman-core/src/modules/tinybox.rs
index 30fdead365..fe1b6e58b2 100644
--- a/crates/openhuman-core/src/modules/tinybox.rs
+++ b/crates/openhuman-core/src/modules/tinybox.rs
@@ -435,7 +435,11 @@ where
{
// A registry index from before the storage contract moves into the
// module's storage before its first call. Once per workspace, best effort.
- super::import_legacy_tinybox(&crate::core::runtime::DispatchCtx::ambient(), &config.workspace_dir).await;
+ super::import_legacy_tinybox(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config.workspace_dir,
+ )
+ .await;
call_with_client(&module_client(config), member, request, confidential).await
}
diff --git a/crates/openhuman-core/src/modules/wallet_service_tests.rs b/crates/openhuman-core/src/modules/wallet_service_tests.rs
index ac194d05d2..52eaad7610 100644
--- a/crates/openhuman-core/src/modules/wallet_service_tests.rs
+++ b/crates/openhuman-core/src/modules/wallet_service_tests.rs
@@ -195,7 +195,7 @@ fn native_service_reuses_its_handle_for_identical_user_state() {
#[tokio::test]
async fn unconfirmed_execution_is_rejected_before_wallet_service_or_secret_access() {
let error = execute_native_transfer(
-&crate::core::runtime::DispatchCtx::ambient(),
+ &crate::core::runtime::DispatchCtx::ambient(),
&crate::config::Config::default(),
None,
tinywallet_bus::wire::ExecutePreparedParams {