Skip to content

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

test(orchestration): add test for unexpired completion claim after router reopen

Steven Enamakel0219131411ed
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs
index 7fbecf6d69..09eeeb39ff 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_recovery_tests.rs
@@ -1,6 +1,44 @@
use super::*;
use crate::core::runtime::DispatchCtx;
+#[tokio::test]
+async fn an_unexpired_completion_claim_stays_leased_after_router_reopen() {
+ let _g = test_guard().await;
+ let ws = workspace();
+ let w = ws.path();
+ record(
+ w,
+ "bd-claimed-restart",
+ "sub-1",
+ "claimed before restart",
+ "thread-claimed-restart",
+ )
+ .await;
+
+ let router = router_for_workspace(w);
+ let claimed = router
+ .claim_pending("thread-claimed-restart", usize::MAX)
+ .unwrap();
+ assert_eq!(claimed.len(), 1, "the first owner holds the completion");
+ drop(claimed);
+ drop(router);
+ forget_workspace_for_test(w);
+
+ let reopened = router_for_workspace(w);
+ assert!(
+ reopened
+ .claim_pending("thread-claimed-restart", usize::MAX)
+ .unwrap()
+ .is_empty(),
+ "an unexpired durable claim prevents duplicate delivery after reopening"
+ );
+ assert_eq!(
+ pending_ids(w, "thread-claimed-restart"),
+ ["sub-1"],
+ "the leased completion remains pending for delivery after its visibility lease expires"
+ );
+}
+
#[tokio::test]
async fn a_mixed_batch_that_partly_gives_up_still_retries_the_rest() {
let _g = test_guard().await;
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
index 06e9e4afec..23faa10880 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_tests.rs
@@ -457,44 +457,6 @@ async fn a_pending_completion_survives_a_restart_and_is_delivered() {
assert!(background_completions::recover_pending_threads(&cx(), w).is_empty());
}
-#[tokio::test]
-async fn an_unexpired_completion_claim_stays_leased_after_router_reopen() {
- let _g = test_guard().await;
- let ws = workspace();
- let w = ws.path();
- record(
- w,
- "bd-claimed-restart",
- "sub-1",
- "claimed before restart",
- "thread-claimed-restart",
- )
- .await;
-
- let router = router_for_workspace(w);
- let claimed = router
- .claim_pending("thread-claimed-restart", usize::MAX)
- .unwrap();
- assert_eq!(claimed.len(), 1, "the first owner holds the completion");
- drop(claimed);
- drop(router);
- forget_workspace_for_test(w);
-
- let reopened = router_for_workspace(w);
- assert!(
- reopened
- .claim_pending("thread-claimed-restart", usize::MAX)
- .unwrap()
- .is_empty(),
- "an unexpired durable claim prevents duplicate delivery after reopening"
- );
- assert_eq!(
- pending_ids(w, "thread-claimed-restart"),
- ["sub-1"],
- "the leased completion remains pending for delivery after its visibility lease expires"
- );
-}
-
#[tokio::test]
async fn every_subagent_terminal_event_schedules_a_drain_through_the_handler() {
// #4896 regression: EVERY subagent terminal event must schedule a drain for