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
feat(inbound): add linked fixture for delivery tests
Steven Enamakel1b7046426a32
diff --git a/crates/openhuman-core/src/inbound/deliver_tests.rs b/crates/openhuman-core/src/inbound/deliver_tests.rsindex e332dbaa8f..5b020c68f0 100644--- a/crates/openhuman-core/src/inbound/deliver_tests.rs+++ b/crates/openhuman-core/src/inbound/deliver_tests.rs@@ -282,3 +282,42 @@ async fn the_default_deliverer_reads_attempts_from_the_configured_queues() {.await;assert_eq!(response.status, DeliverStatus::Retry { after_ms: None });}++#[tokio::test]+async fn a_failed_apply_is_retried_instead_of_acknowledged() {+ // The agent dispatch fails: the turn must stay recoverable.+ let triage = ScriptedTriage::new([+ decision(TriageAction::React),+ decision(TriageAction::React),+ ]);+ triage.fail_next_applies(1);+ let deliverer = deliverer(&triage);+ let first = deliverer+ .deliver(turn(vec![trigger_event("u1")], Lane::Background, 1))+ .await;+ assert_eq!(first.status, DeliverStatus::Retry { after_ms: None });+ assert!(triage.applied().is_empty());+ // The redelivery is not treated as already accepted: it decides and+ // applies again.+ let second = deliverer+ .deliver(turn(vec![trigger_event("u1")], Lane::Background, 2))+ .await;+ assert_eq!(second.status, DeliverStatus::Accepted);+ assert_eq!(triage.applied().len(), 1);+ assert_eq!(triage.runs(), 2);+}++#[tokio::test]+async fn a_long_apply_is_acknowledged_at_the_budget_and_finishes_on_its_own() {+ let triage = ScriptedTriage::new([decision(TriageAction::Escalate)]);+ triage.slow_applies(Duration::from_millis(300));+ let deliverer = deliverer(&triage).with_budget(Duration::from_millis(50));+ let started = std::time::Instant::now();+ let response = deliverer+ .deliver(turn(vec![trigger_event("u1")], Lane::Background, 1))+ .await;+ assert_eq!(response.status, DeliverStatus::Accepted);+ assert!(started.elapsed() < Duration::from_millis(300));+ let applied = triage.until_applied(1, Duration::from_secs(5)).await;+ assert_eq!(applied.len(), 1);+}diff --git a/crates/openhuman-core/src/inbound/linked_fixture.rs b/crates/openhuman-core/src/inbound/linked_fixture.rsindex bf8ad49ef5..96ed8f04fd 100644--- a/crates/openhuman-core/src/inbound/linked_fixture.rs+++ b/crates/openhuman-core/src/inbound/linked_fixture.rs@@ -80,6 +80,8 @@ pub(crate) struct ScriptedTriage {script: Mutex<VecDeque<Step>>,runs: AtomicUsize,applied: Mutex<Vec<String>>,+ failing_applies: AtomicUsize,+ apply_delay: Mutex<Duration>,}impl ScriptedTriage {@@ -91,6 +93,16 @@ impl ScriptedTriage {})}+ /// Fail the next `n` applies.+ pub(crate) fn fail_next_applies(&self, n: usize) {+ self.failing_applies.store(n, Ordering::SeqCst);+ }++ /// Take `delay` over every apply.+ pub(crate) fn slow_applies(&self, delay: Duration) {+ *self.apply_delay.lock().unwrap() = delay;+ }+/// How many triage runs happened.pub(crate) fn runs(&self) -> usize {self.runs.load(Ordering::SeqCst)@@ -147,6 +159,17 @@ impl TriageRunner for ScriptedTriage {_run: TriageRun,envelope: &TriggerEnvelope,) -> anyhow::Result<()> {+ let delay = *self.apply_delay.lock().unwrap();+ if !delay.is_zero() {+ tokio::time::sleep(delay).await;+ }+ let failing = self+ .failing_applies+ .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |n| n.checked_sub(1))+ .is_ok();+ if failing {+ return Err(anyhow::anyhow!("scripted apply failure"));+ }self.applied.lock().unwrap()