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
test(orchestration): add a test-only delivery pass and tidy formatting
Steven Enamakel7279d2320c69
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rsindex 215a863ec7..61c26c5666 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs@@ -355,7 +355,9 @@ fn claim_ready(router: &CompletionRouter, thread_id: &str) -> Option<Vec<Complet/// delivering. Batches everything ready at this instant into one system turn.async fn try_deliver(thread_id: String, fence: DrainFence) {if !fence.admits() {- log::info!("[background_delivery] profile lease lost; not delivering thread_id={thread_id}");+ log::info!(+ "[background_delivery] profile lease lost; not delivering thread_id={thread_id}"+ );return;}let Some(workspace_dir) = background_completions::workspace_for_thread(&thread_id) else {@@ -391,6 +393,26 @@ async fn try_deliver(thread_id: String, fence: DrainFence) {}}+/// One pass of the delivery loop whose turn only counts itself, for tests+/// outside this module.+#[cfg(test)]+pub(super) async fn try_deliver_for_test(+ thread_id: String,+ router: Arc<CompletionRouter>,+ turns: Arc<std::sync::atomic::AtomicU32>,+) -> Option<Duration> {+ try_deliver_with(+ thread_id,+ router,+ move |_, _| {+ turns.fetch_add(1, std::sync::atomic::Ordering::SeqCst);+ async { Ok(String::new()) }+ },+ |_, _| async {},+ )+ .await+}+/// Backoff before retrying a delivery whose record has now failed `attempts` times.fn retry_backoff(attempts: u32) -> Duration {Duration::from_secs(2u64.saturating_pow(attempts.min(5)))diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rsindex 2e4ca7ece0..fb2054dcd7 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs@@ -690,7 +690,11 @@ async fn recover_on_open_rescans_a_workspace_already_recovered() {forget_workspace_for_test(w);assert_eq!(recover_on_boot(w), 1);assert_eq!(recover_on_boot(w), 0, "boot recovery claims once");- assert_eq!(recover_on_open(w, DrainFence::none()), 1, "a re-open scans again");+ assert_eq!(+ recover_on_open(w, DrainFence::none()),+ 1,+ "a re-open scans again"+ );}#[tokio::test]diff --git a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rsindex af63d0b81e..d73992eaef 100644--- a/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs+++ b/crates/openhuman-core/src/agent/orchestration/delivery_drain.rs@@ -105,7 +105,9 @@ whereFut: Future<Output = ()>,{if !fence.sleep(delay).await {- log::info!("[background_delivery] profile lease lost; dropping the drain thread_id={thread_id}");+ log::info!(+ "[background_delivery] profile lease lost; dropping the drain thread_id={thread_id}"+ );return DrainOutcome::Fenced;}if wait_idle {@@ -125,7 +127,9 @@ where}}if !fence.admits() {- log::info!("[background_delivery] profile lease lost; dropping the drain thread_id={thread_id}");+ log::info!(+ "[background_delivery] profile lease lost; dropping the drain thread_id={thread_id}"+ );return DrainOutcome::Fenced;}deliver().await;diff --git a/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs b/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rsindex 98d66b6603..63e587a8b9 100644--- a/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/delivery_drain_tests.rs@@ -30,7 +30,12 @@ fn live_fence() -> (Arc<dyn LeaseStore>, Arc<LeaseFence>) {}/// Run a drain whose `deliver` only notes that it ran.-async fn drain(thread: &str, delay: Duration, wait_idle: bool, fence: &DrainFence) -> (DrainOutcome, bool) {+async fn drain(+ thread: &str,+ delay: Duration,+ wait_idle: bool,+ fence: &DrainFence,+) -> (DrainOutcome, bool) {let ran = Arc::new(AtomicBool::new(false));let flag = Arc::clone(&ran);let outcome = run_drain(thread, delay, wait_idle, fence, SHORT, || async move {@@ -78,7 +83,10 @@ async fn losing_the_lease_during_the_delay_cuts_the_drain_short() {.await;assert_eq!(outcome, DrainOutcome::Fenced);assert!(!ran);- assert!(started.elapsed() < Duration::from_secs(10), "aborted, not slept out");+ assert!(+ started.elapsed() < Duration::from_secs(10),+ "aborted, not slept out"+ );}#[tokio::test]@@ -161,11 +169,19 @@ async fn a_delivery_waits_while_a_relayed_turn_runs_on_its_thread() {let relayed = TurnBusy::start_on_thread(thread);attempt(Arc::clone(&turns)).await;- assert_eq!(turns.load(Ordering::SeqCst), 0, "no delivery over a running relayed turn");+ assert_eq!(+ turns.load(Ordering::SeqCst),+ 0,+ "no delivery over a running relayed turn"+ );assert_eq!(pending_for(w, thread).len(), 1, "the result stays pending");drop(relayed);attempt(Arc::clone(&turns)).await;- assert_eq!(turns.load(Ordering::SeqCst), 1, "delivered once the turn ends");+ assert_eq!(+ turns.load(Ordering::SeqCst),+ 1,+ "delivered once the turn ends"+ );assert!(pending_for(w, thread).is_empty());}diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rsindex b4b4ff0304..f168bc5147 100644--- a/crates/openhuman-core/src/agent/orchestration/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs@@ -23,8 +23,8 @@ pub mod command_center;pub(crate) mod completion_notice;pub(crate) mod completion_owners;pub(crate) mod completion_target;-pub(crate) mod delivery_drain;pub(crate) mod delegation;+pub(crate) mod delivery_drain;pub use delegation::open_delegation_checkpointer;pub(crate) mod fleet_tools;mod ops;