Skip to content

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

refactor(inbound): drop storage wiring from linked fixture

Steven Enamakel214604cca803
diff --git a/crates/openhuman-core/src/inbound/linked_fixture.rs b/crates/openhuman-core/src/inbound/linked_fixture.rs
index 54356c39f1..69469bb42c 100644
--- a/crates/openhuman-core/src/inbound/linked_fixture.rs
+++ b/crates/openhuman-core/src/inbound/linked_fixture.rs
@@ -21,12 +21,6 @@ use tinybus::transport::memory::MemoryBus;
use tinybus::{Connection, ObjectPath};
use tinyeventqueues_bus::names;
use tinyeventqueues_bus::storage::SHIPPED_PIPELINE_JSON;
-use tinystoragedrivers_api::StorageBackend;
-use tinystoragedrivers_busproxy::{
- prepare_storage_host_callbacks, serve_with_host_callbacks, PerCallerEndpoint, StorageServer,
-};
-use tinystoragedrivers_testkit::MemoryBackend;
-use tinystoragedrivers_types::Scope;
use super::deliver::Deliverer;
use super::host::InboundHost;
@@ -304,7 +298,6 @@ pub(crate) struct Rig {
pub(crate) triage: Arc<ScriptedTriage>,
_host: Connection,
_modules: ModuleHost,
- _storage: tinystoragedrivers_busproxy::ServedStorage,
}
impl Rig {
@@ -327,20 +320,9 @@ impl Rig {
let bus = MemoryBus::new();
let broker = Broker::new();
broker.clone().spawn(bus.clone());
- let modules = ModuleHost::new(broker);
let host = Connection::connect(bus.connect().await.unwrap())
.await
.unwrap();
- let binding = prepare_storage_host_callbacks(&modules).await.unwrap();
- let backend = Arc::new(MemoryBackend::new());
- let storage_backend = Arc::clone(&backend);
- let endpoint = PerCallerEndpoint::new(move |_sender| {
- let storage = storage_backend.for_scope(&Scope::new("local").ok()?).ok()?;
- Some(StorageServer::new(storage))
- });
- let storage = serve_with_host_callbacks(binding.clone(), Arc::new(endpoint))
- .await
- .unwrap();
let deliverer = Deliverer::new(
triage.clone() as Arc<dyn TriageRunner>,
DispatchCtx::host_default(),
@@ -363,44 +345,27 @@ impl Rig {
.unwrap();
host.request_name(names::host::INTERFACE).await.unwrap();
- let mut module_config = json!({
- "pipeline": pipeline,
- "timer": { "min_interval_ms": 5, "max_interval_ms": 25 },
- });
- module_config["storage_callback"] = json!(binding.unique_name().as_str());
+ let modules = ModuleHost::new(broker);
modules
- .attach_linked_with_config(tinyeventqueues::linked_module().unwrap(), module_config)
+ .attach_linked_with_config(
+ tinyeventqueues::linked_module().unwrap(),
+ json!({
+ "pipeline": pipeline,
+ "timer": { "min_interval_ms": 5, "max_interval_ms": 25 },
+ }),
+ )
.unwrap();
- let state = tokio::time::timeout(Duration::from_secs(10), async {
+ tokio::time::timeout(Duration::from_secs(10), async {
loop {
- if let Some(info) = modules
- .list()
- .into_iter()
- .find(|info| info.name == "tinyeventqueues")
- {
- if matches!(
- info.state,
- tinybus::module::ModuleState::Ready
- | tinybus::module::ModuleState::Serving
- | tinybus::module::ModuleState::Failed { .. }
- | tinybus::module::ModuleState::Faulted { .. }
- ) {
- break info.state;
- }
+ let names = host.list_names().await.unwrap();
+ if names.iter().any(|name| name.as_str() == names::INTERFACE) {
+ break;
}
tokio::time::sleep(Duration::from_millis(5)).await;
}
})
.await
- .expect("the linked tinyeventqueues module reaches a terminal setup state");
- assert!(
- matches!(
- state,
- tinybus::module::ModuleState::Ready | tinybus::module::ModuleState::Serving
- ),
- "the linked tinyeventqueues module must be ready: {:?}",
- state
- );
+ .expect("the linked tinyeventqueues module claimed its name");
let proxy = host
.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)
.unwrap();
@@ -409,7 +374,6 @@ impl Rig {
triage,
_host: host,
_modules: modules,
- _storage: storage,
}
}
}
diff --git a/crates/openhuman-core/src/skills/webhooks/bus_tests.rs b/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
index f7a0a60d9e..534ac10f14 100644
--- a/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
+++ b/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
@@ -148,7 +148,7 @@ mod inbound {
use std::sync::Arc;
use std::time::{Duration, Instant};
- use super::super::triage_agent_directly;
+ use super::super::{route_agent_trigger, triage_agent_directly};
use crate::core::runtime::DispatchCtx;
use crate::inbound::fixture::{active_config, decision, deferred, Rig, ScriptedTriage};
use crate::triage::{TriageAction, TriggerEnvelope};
@@ -165,13 +165,9 @@ mod inbound {
}
async fn route(rig: &Rig, config: Option<crate::config::Config>, correlation_id: &str) {
- let queues_active = config.as_ref().is_some_and(crate::inbound::active);
let envelope = request();
- let event = crate::inbound::events::webhook(&envelope, correlation_id).unwrap();
- let handoff =
- crate::inbound::route::offer(config.as_ref().unwrap(), &rig.client, event).await;
- let queued = handoff.is_queued();
- assert_eq!(queued, queues_active, "webhook queue handoff: {handoff:?}");
+ let queued =
+ route_agent_trigger(config, &envelope, correlation_id, Some(rig.client.clone())).await;
if !queued {
triage_agent_directly(
DispatchCtx::host_default(),
@@ -193,12 +189,12 @@ mod inbound {
route(&rig, Some(active_config()), "corr-deferred").await;
let applied = triage.until_applied(1, Duration::from_secs(15)).await;
- assert_eq!(triage.runs(), 2, "triage must run again after the deferral");
assert_eq!(
applied,
vec![LABEL.to_owned()],
"the deferred webhook was dropped"
);
+ assert_eq!(triage.runs(), 2, "triaged, deferred, then triaged again");
assert!(
started.elapsed() >= Duration::from_millis(350),
"retried before the deferral ran out: {:?}",