Skip to content

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

fix(core): replace event_bus::global with bus::BUS singleton

Steven Enamakel90fe84c34bf8
diff --git a/src/core/jsonrpc.rs b/src/core/jsonrpc.rs
index 2df27b67bb..32b55c68b3 100644
--- a/src/core/jsonrpc.rs
+++ b/src/core/jsonrpc.rs
@@ -1965,7 +1965,7 @@ fn group_first_time(group: crate::core::all::DomainGroup) -> bool {
group_first_time_when_bus_ready(
DONE.get_or_init(|| Mutex::new(HashSet::new())),
group,
- crate::core::event_bus::global().is_some(),
+ crate::core::bus::BUS.get().is_some(),
)
}
@@ -1995,7 +1995,7 @@ fn learning_first_time() -> bool {
static DONE: std::sync::OnceLock<std::sync::Mutex<bool>> = std::sync::OnceLock::new();
learning_first_time_when_bus_ready(
DONE.get_or_init(|| std::sync::Mutex::new(false)),
- crate::core::event_bus::global().is_some(),
+ crate::core::bus::BUS.get().is_some(),
)
}
diff --git a/src/core/jsonrpc_tests.rs b/src/core/jsonrpc_tests.rs
index c8c16b7ccc..f8270b93cb 100644
--- a/src/core/jsonrpc_tests.rs
+++ b/src/core/jsonrpc_tests.rs
@@ -178,12 +178,18 @@ fn learning_subscriber_registration_is_idempotent_after_success() {
assert!(!learning_first_time_when_bus_ready(&completed, true));
}
+/// The wrapper reads readiness off the process-wide `BUS` singleton. Unit
+/// tests never stand that bus up (see `core::bus::init` on runtime affinity),
+/// so the observable contract here is the deferred case: with no bus the
+/// token is *not* consumed, and a later call can still claim it. The
+/// consumed/not-consumed transitions are pinned above through
+/// `group_first_time_when_bus_ready`.
#[test]
-fn domain_subscriber_registration_wrapper_uses_the_global_bus() {
+fn domain_subscriber_registration_wrapper_defers_without_a_global_bus() {
use crate::core::all::DomainGroup;
- crate::core::event_bus::init_global(crate::core::event_bus::DEFAULT_CAPACITY);
- assert!(group_first_time(DomainGroup::Media));
+ assert!(crate::core::bus::BUS.get().is_none());
+ assert!(!group_first_time(DomainGroup::Media));
assert!(!group_first_time(DomainGroup::Media));
}
diff --git a/src/openhuman/agent/agent_tests_part_03_tests.rs b/src/openhuman/agent/agent_tests_part_03_tests.rs
index 27c304219a..d26588ee5f 100644
--- a/src/openhuman/agent/agent_tests_part_03_tests.rs
+++ b/src/openhuman/agent/agent_tests_part_03_tests.rs
@@ -54,7 +54,7 @@ async fn poll_for_stored_user_message(mem: &Arc<dyn Memory>) -> Vec<String> {
async fn an_external_channel_turn_stores_the_user_message() {
use crate::openhuman::agent::turn_origin::{with_origin, AgentTurnOrigin};
- let (mem, _tmp) = make_sqlite_memory();
+ let (mem, _tmp) = make_retaining_memory();
let provider = Arc::new(ScriptedProvider::new(vec![text_response("got it")]));
let (mut agent, _tmp2) = build_agent_with_memory(provider, vec![], mem.clone(), true);
@@ -83,7 +83,7 @@ async fn an_external_channel_turn_stores_the_user_message() {
async fn a_direct_chat_turn_stores_the_user_message() {
use crate::openhuman::agent::turn_origin::{with_origin, AgentTurnOrigin};
- let (mem, _tmp) = make_sqlite_memory();
+ let (mem, _tmp) = make_retaining_memory();
let provider = Arc::new(ScriptedProvider::new(vec![text_response("noted")]));
let (mut agent, _tmp2) = build_agent_with_memory(provider, vec![], mem.clone(), true);
@@ -112,7 +112,7 @@ async fn an_automation_turn_does_not_store_its_prompt_as_the_users_memory() {
with_origin, AgentTurnOrigin, TrustedAutomationSource,
};
- let (mem, _tmp) = make_sqlite_memory();
+ let (mem, _tmp) = make_retaining_memory();
let provider = Arc::new(ScriptedProvider::new(vec![text_response("goals updated")]));
let (mut agent, _tmp2) = build_agent_with_memory(
provider,
@@ -145,7 +145,7 @@ async fn an_automation_turn_does_not_store_its_prompt_as_the_users_memory() {
/// quietly write host text into the user's memory.
#[tokio::test]
async fn an_unscoped_turn_stores_no_user_message() {
- let (mem, _tmp) = make_sqlite_memory();
+ let (mem, _tmp) = make_retaining_memory();
let provider = Arc::new(ScriptedProvider::new(vec![text_response("ok")]));
let (mut agent, _tmp2) = build_agent_with_memory(provider, vec![], mem.clone(), true);