Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}

Expand Down Expand Up @@ -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(),
)
}

Expand Down
12 changes: 9 additions & 3 deletions src/core/jsonrpc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop assuming the process-global bus is unset

When this test runs after—or concurrently with—another test that calls core::bus::init(), such as openhuman::agent::learning::startup_tests::register_with_memory_registers_both_handles_when_ready, the non-resettable BUS singleton is already populated, so this assertion fails nondeterministically. This commit’s scoped CI run includes both the changed core::jsonrpc and openhuman::agent tests in the same libtest process, and full-suite runs contain many additional initializers; test the readiness helper with local state instead of asserting global singleton state.

AGENTS.md reference: AGENTS.md:L66-L66

Useful? React with 👍 / 👎.

assert!(!group_first_time(DomainGroup::Media));
assert!(!group_first_time(DomainGroup::Media));
}

Expand Down
8 changes: 4 additions & 4 deletions src/openhuman/agent/agent_tests_part_03_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/openhuman/agent/tinyagents/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ include!("middleware_part_03.rs");
include!("middleware_part_04.rs");
include!("middleware_part_05.rs");
include!("middleware_part_06.rs");
include!("middleware_part_07.rs");
Loading
Loading