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
style: collapse multi-line call arguments onto fewer lines
Steven Enamakel4bece1eb431c
diff --git a/crates/openhuman-core/src/modules/import_once_tests.rs b/crates/openhuman-core/src/modules/import_once_tests.rsindex 6f92163191..86909ef9a1 100644--- a/crates/openhuman-core/src/modules/import_once_tests.rs+++ b/crates/openhuman-core/src/modules/import_once_tests.rs@@ -14,31 +14,19 @@ 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)};@@ -54,53 +42,29 @@ 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/storage_host_endpoint.rs b/crates/openhuman-core/src/modules/storage_host_endpoint.rsindex e49bcae7d2..549cc0c7c0 100644--- a/crates/openhuman-core/src/modules/storage_host_endpoint.rs+++ b/crates/openhuman-core/src/modules/storage_host_endpoint.rs@@ -102,28 +102,26 @@ 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);- }- 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,+ 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,}- }),- );+ }+ }));}}diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rsindex 96dc6c0a4c..3e95b8bf42 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors_tests.rs@@ -70,9 +70,7 @@ 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!(@@ -119,9 +117,7 @@ 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);}@@ -129,9 +125,7 @@ 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@@ -140,9 +134,7 @@ 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@@ -173,9 +165,7 @@ 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 {@@ -205,17 +195,13 @@ 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 { .. }));}@@ -230,11 +216,7 @@ 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")@@ -244,9 +226,7 @@ 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_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rsindex 9302591773..442d24a4fc 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs@@ -49,8 +49,7 @@ 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)),@@ -84,15 +83,9 @@ 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 {@@ -107,15 +100,9 @@ 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"@@ -136,15 +123,9 @@ 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 {@@ -158,15 +139,9 @@ 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);}@@ -177,29 +152,17 @@ 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, .. }));}@@ -225,15 +188,9 @@ 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_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rsindex 702edbd3b7..2f413b9291 100644--- a/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp_tests.rs@@ -77,14 +77,9 @@ 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 {@@ -146,28 +141,18 @@ 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!(@@ -182,14 +167,9 @@ 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@@ -219,14 +199,9 @@ 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 {@@ -251,14 +226,9 @@ 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);}@@ -274,14 +244,9 @@ 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_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rsindex 3857958e18..3f9ef05843 100644--- a/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet_tests.rs@@ -41,9 +41,7 @@ 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 {@@ -79,9 +77,7 @@ 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);}@@ -89,13 +85,9 @@ 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);@@ -114,9 +106,7 @@ 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@@ -130,16 +120,12 @@ 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 { .. }));}@@ -151,18 +137,12 @@ 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: 0diff --git a/crates/openhuman-core/src/modules/wallet_service_tests.rs b/crates/openhuman-core/src/modules/wallet_service_tests.rsindex 52eaad7610..ac194d05d2 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 {