Skip to content

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

chore(spawn_parallel): move test module declaration to end of staging.rs

Steven Enamakel4f32c8ff06d4
diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging.rs
index 58539a8e4c..d243067540 100644
--- a/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging.rs
+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging.rs
@@ -390,10 +390,6 @@ pub(crate) fn prepare_spawn_parallel_tasks_from_defs(
.collect()
}
-#[cfg(test)]
-#[path = "staging_tests.rs"]
-mod tests;
-
/// Render a claim conflict as the sentence the calling model reads.
///
/// The crate reports conflicts as data precisely so this phrasing — the
@@ -414,3 +410,7 @@ fn shared_workspace_conflict_message(agent_id: &str, conflict: &ClaimConflict) -
),
}
}
+
+#[cfg(test)]
+#[path = "staging_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging_tests.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging_tests.rs
new file mode 100644
index 0000000000..a09c58b163
--- /dev/null
+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/staging_tests.rs
@@ -0,0 +1,46 @@
+use super::*;
+
+use std::sync::Arc;
+
+#[test]
+fn admission_rejection_kinds_remain_indexed_under_concurrent_policy_calls() {
+ let kinds = Arc::new(RejectionKinds::default());
+ let calls = [
+ (0, ParallelTaskRejectionKind::MissingAgentOrPrompt),
+ (1, ParallelTaskRejectionKind::UnknownAgent),
+ (2, ParallelTaskRejectionKind::OutsideAllowlist),
+ (3, ParallelTaskRejectionKind::RequiresIsolation),
+ ];
+ let workers = calls
+ .into_iter()
+ .map(|(index, kind)| {
+ let kinds = Arc::clone(&kinds);
+ std::thread::spawn(move || kinds.insert(index, kind))
+ })
+ .collect::<Vec<_>>();
+ for worker in workers {
+ worker.join().unwrap();
+ }
+
+ let kinds = match Arc::try_unwrap(kinds) {
+ Ok(kinds) => kinds.into_inner(),
+ Err(_) => panic!("all admission callers released the shared policy state"),
+ };
+ assert_eq!(kinds.len(), 4);
+ assert_eq!(
+ kinds.get(&0),
+ Some(&ParallelTaskRejectionKind::MissingAgentOrPrompt)
+ );
+ assert_eq!(
+ kinds.get(&1),
+ Some(&ParallelTaskRejectionKind::UnknownAgent)
+ );
+ assert_eq!(
+ kinds.get(&2),
+ Some(&ParallelTaskRejectionKind::OutsideAllowlist)
+ );
+ assert_eq!(
+ kinds.get(&3),
+ Some(&ParallelTaskRejectionKind::RequiresIsolation)
+ );
+}