The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/channels/module_fixture_tests.rs
Steven Enamakel5908739e47c3
diff --git a/crates/openhuman-core/src/channels/module_fixture_tests.rs b/crates/openhuman-core/src/channels/module_fixture_tests.rsindex c9bd4651d7..07d4e73a1a 100644--- a/crates/openhuman-core/src/channels/module_fixture_tests.rs+++ b/crates/openhuman-core/src/channels/module_fixture_tests.rs@@ -1,83 +1,36 @@//! A linked TinyChannels module fixture for host-side unit tests.//!//! These tests exercise the real owning module over TinyBus without downloading-//! a release artifact or reaching a provider service. The fixture broker and-//! module stay on a dedicated process-lifetime runtime because TinyBus module-//! tasks must outlive the short Tokio runtimes used by individual tests.+//! a release artifact or reaching a provider service. The module is attached+//! through the same seam local development uses: the factory is registered with+//! [`register_linked`] and `[modules] source = "linked"` makes+//! `ops::ensure_loaded` attach it to the process-wide module host, which lives+//! on a process-lifetime runtime, so it outlives the short Tokio runtimes of+//! individual tests.+use crate::config::schema::ModuleSourceMode;+use crate::config::Config;use crate::modules::client::ModuleClient;-use std::sync::{Mutex, OnceLock};-use tinybus::Proxy;+use crate::modules::linked::register_linked;+use crate::modules::{host, ops};use tinychannels_bus::methods;-static FIXTURE_PROXY: OnceLock<Proxy> = OnceLock::new();-static FIXTURE_INIT: Mutex<()> = Mutex::new(());+const MODULE_ID: &str = "tinychannels";/// Return a client for the compiled, linked TinyChannels module fixture.pub(crate) async fn client() -> ModuleClient {- if let Some(proxy) = FIXTURE_PROXY.get() {- return ModuleClient::fixture(proxy.clone());- }-- let _guard = FIXTURE_INIT- .lock()- .expect("the TinyChannels fixture initialization lock is not poisoned");- if let Some(proxy) = FIXTURE_PROXY.get() {- return ModuleClient::fixture(proxy.clone());- }-- let (ready_tx, ready_rx) = std::sync::mpsc::sync_channel(1);- std::thread::Builder::new()- .name("tinychannels-test-module".into())- .spawn(move || {- let runtime = tokio::runtime::Builder::new_multi_thread()- .worker_threads(2)- .enable_all()- .thread_name("tinychannels-test-bus")- .build()- .expect("the TinyChannels test runtime should start");- runtime.block_on(async move {- let transport = tinybus::transport::memory::MemoryBus::new();- let broker = tinybus::broker::Broker::new();- broker.spawn(transport.clone());- let connection = tinybus::Connection::connect(- transport- .connect()- .await- .expect("the TinyChannels fixture broker should accept a connection"),- )- .await- .expect("the TinyChannels fixture host should connect to its broker");- let host = tinybus::module::ModuleHost::new(broker);- host.attach_linked_with_config(- tinychannels_module::linked_module()- .expect("the linked TinyChannels module should be available"),- serde_json::json!({}),- )- .expect("the linked TinyChannels module should be admitted");- let proxy = connection- .proxy(- tinychannels_module::BUS_NAME,- tinychannels_module::OBJECT_PATH,- tinychannels_module::BUS_NAME,- )- .expect("the linked TinyChannels proxy should be valid");- let _ = ready_tx.send(proxy);-- // Keep the connection and module host alive with the broker- // until process exit. Aborting this task would fault the- // attached module and invalidate proxies held by other tests.- let (_connection, _host) = (connection, host);- std::future::pending::<()>().await;- });- })- .expect("the TinyChannels fixture thread should start");-- let proxy = ready_rx- .recv()- .expect("the linked TinyChannels module should finish setup");- let _ = FIXTURE_PROXY.set(proxy.clone());- ModuleClient::fixture(FIXTURE_PROXY.get().unwrap().clone())+ register_linked(MODULE_ID, tinychannels_module::linked_module);+ let mut config = Config::default();+ config.modules.source = ModuleSourceMode::Linked;+ ops::ensure_loaded(&config, MODULE_ID)+ .await+ .expect("the linked TinyChannels module should be admitted through the seam");+ let proxy = host::runtime()+ .await+ .expect("the module host should be running")+ .proxy(tinychannels_module::BUS_NAME, tinychannels_module::OBJECT_PATH)+ .expect("the linked TinyChannels proxy should be valid");+ ModuleClient::fixture(proxy)}#[tokio::test]