Skip to content

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

chore: files changed crates/openhuman-core/src/cron/channel_bridge.rs,crates/openhuman-core/src/cron

Steven Enamakelac59558cf0f1
diff --git a/crates/openhuman-core/src/cron/channel_bridge.rs b/crates/openhuman-core/src/cron/channel_bridge.rs
index db9614c05c..5feffb8fe5 100644
--- a/crates/openhuman-core/src/cron/channel_bridge.rs
+++ b/crates/openhuman-core/src/cron/channel_bridge.rs
@@ -56,6 +56,9 @@ pub fn register_channel_bridge(
static MAX_HISTORY: std::sync::atomic::AtomicUsize =
std::sync::atomic::AtomicUsize::new(MAX_HISTORY_MESSAGES);
+#[cfg(test)]
+pub(crate) static TEST_BRIDGE_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+
/// The `(role, text)` messages of one chat's history, oldest first. Empty when
/// no channel runtime is registered or the chat has no history.
pub fn history_messages(history_key: &str) -> Vec<(String, String)> {
diff --git a/crates/openhuman-core/src/cron/channel_bridge_tests.rs b/crates/openhuman-core/src/cron/channel_bridge_tests.rs
index 541bdc3ce2..ac9be981e8 100644
--- a/crates/openhuman-core/src/cron/channel_bridge_tests.rs
+++ b/crates/openhuman-core/src/cron/channel_bridge_tests.rs
@@ -31,6 +31,7 @@ impl Channel for MockChannel {
// One test: the bridge is process-global, so keep its steps sequential.
#[tokio::test]
async fn bridge_reads_appends_trims_and_sends() {
+ let _bridge_lock = TEST_BRIDGE_LOCK.lock().await;
let histories: ChannelHistories = Arc::new(Mutex::new(HashMap::new()));
histories.lock().unwrap().insert(
"k".into(),
diff --git a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
index 3a75827293..baa9a1f5fd 100644
--- a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
@@ -148,6 +148,7 @@ async fn announce_to_unavailable_channel_is_reported_as_failed() {
#[tokio::test]
async fn announce_send_failure_is_reported_as_failed() {
+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp).await;
let channel = format!("failing-{}", uuid::Uuid::new_v4());
@@ -177,6 +178,7 @@ async fn announce_send_failure_is_reported_as_failed() {
#[tokio::test]
async fn announce_success_is_reported_and_uses_a_run_idempotency_key() {
+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp).await;
let channel = format!("working-{}", uuid::Uuid::new_v4());