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/inbound/deliver_tests.rs,crates/openhuman-core/src/in

Steven Enamakel075be3b26f41
diff --git a/crates/openhuman-core/src/inbound/deliver_tests.rs b/crates/openhuman-core/src/inbound/deliver_tests.rs
index 8d34e4cd9b..ad75d01eb5 100644
--- a/crates/openhuman-core/src/inbound/deliver_tests.rs
+++ b/crates/openhuman-core/src/inbound/deliver_tests.rs
@@ -61,7 +61,10 @@ async fn a_decision_is_accepted_and_applied() {
.await;
assert_eq!(response.status, DeliverStatus::Accepted);
let applied = triage.until_applied(1, Duration::from_secs(5)).await;
- assert_eq!(applied, vec!["composio/github/GITHUB_ISSUE_OPENED".to_owned()]);
+ assert_eq!(
+ applied,
+ vec!["composio/github/GITHUB_ISSUE_OPENED".to_owned()]
+ );
}
#[tokio::test]
@@ -174,7 +177,11 @@ async fn a_classification_is_reused_by_the_delivery() {
.deliver(turn(vec![event], Lane::Interactive, 1))
.await;
assert_eq!(response.status, DeliverStatus::Accepted);
- assert_eq!(triage.runs(), 1, "the delivery triaged a classified event again");
+ assert_eq!(
+ triage.runs(),
+ 1,
+ "the delivery triaged a classified event again"
+ );
}
#[tokio::test]
@@ -187,7 +194,14 @@ async fn a_classification_without_a_decision_keeps_the_score() {
.await;
assert!(refused.is_err());
}
- let chat = InboundEvent::new("web:chat", "1", "c", Sender::new("u"), EventKind::Message, 0);
+ let chat = InboundEvent::new(
+ "web:chat",
+ "1",
+ "c",
+ Sender::new("u"),
+ EventKind::Message,
+ 0,
+ );
assert!(deliverer
.classify(ClassifySalienceRequest::new(chat, 40))
.await
@@ -207,7 +221,10 @@ fn classifications_are_bounded() {
}
classified.keep("k1".to_owned(), run.clone());
assert_eq!(classified.runs.len(), CLASSIFIED_CAPACITY);
- assert!(classified.take("k0").is_none(), "the oldest was not evicted");
+ assert!(
+ classified.take("k0").is_none(),
+ "the oldest was not evicted"
+ );
assert!(classified.take("k1").is_some());
assert!(classified.take("k1").is_none());
}
diff --git a/crates/openhuman-core/src/inbound/events_tests.rs b/crates/openhuman-core/src/inbound/events_tests.rs
index bd19f53613..8e6fa0f07d 100644
--- a/crates/openhuman-core/src/inbound/events_tests.rs
+++ b/crates/openhuman-core/src/inbound/events_tests.rs
@@ -23,10 +23,14 @@ fn a_composio_trigger_round_trips_with_a_stable_identity() {
assert_eq!(event.event_id, "uuid-1");
assert_eq!(event.conversation_key, "composio:gmail:uuid-1");
assert_eq!(event.kind, EventKind::Trigger);
- assert!(event.text.starts_with("composio/gmail/GMAIL_NEW_GMAIL_MESSAGE"));
+ assert!(event
+ .text
+ .starts_with("composio/gmail/GMAIL_NEW_GMAIL_MESSAGE"));
// A redelivery is the same event to the queues.
assert_eq!(
- composio(&composio_envelope("uuid-1", "id-1")).unwrap().dedupe_key(),
+ composio(&composio_envelope("uuid-1", "id-1"))
+ .unwrap()
+ .dedupe_key(),
event.dedupe_key()
);
@@ -47,7 +51,10 @@ fn a_composio_trigger_round_trips_with_a_stable_identity() {
#[test]
fn a_composio_trigger_without_a_uuid_uses_its_id_or_a_fresh_one() {
- assert_eq!(composio(&composio_envelope("", "id-7")).unwrap().event_id, "id-7");
+ assert_eq!(
+ composio(&composio_envelope("", "id-7")).unwrap().event_id,
+ "id-7"
+ );
let fresh = composio(&composio_envelope("", "")).unwrap();
assert!(uuid::Uuid::parse_str(&fresh.event_id).is_ok());
}
@@ -104,8 +111,15 @@ fn an_event_that_is_not_a_trigger_has_no_envelope() {
#[test]
fn a_digest_lists_every_folded_event() {
let trigger = composio(&composio_envelope("u1", "")).unwrap();
- let chat = InboundEvent::new("web:chat", "9", "c", Sender::new("x"), EventKind::Message, 0)
- .text("hello");
+ let chat = InboundEvent::new(
+ "web:chat",
+ "9",
+ "c",
+ Sender::new("x"),
+ EventKind::Message,
+ 0,
+ )
+ .text("hello");
let turn = Turn::new("t-9", Lane::Digest, "c", vec![trigger, chat]);
let digest = digest_envelope(&turn);
assert_eq!(digest.display_label, "external/inbound-digest/t-9");
diff --git a/crates/openhuman-core/src/inbound/host.rs b/crates/openhuman-core/src/inbound/host.rs
index 1804e98da9..f6e1c47485 100644
--- a/crates/openhuman-core/src/inbound/host.rs
+++ b/crates/openhuman-core/src/inbound/host.rs
@@ -64,7 +64,11 @@ pub(crate) async fn install(connection: &tinybus::Connection) -> tinybus::Result
crate::config::schema::InboundConfig::default().triage_timeout_ms
}
};
- let deliverer = Deliverer::new(Arc::new(RemoteTriage), ctx, Duration::from_millis(timeout_ms));
+ let deliverer = Deliverer::new(
+ Arc::new(RemoteTriage),
+ ctx,
+ Duration::from_millis(timeout_ms),
+ );
connection
.serve_at(
ObjectPath::new(PATH)?,
diff --git a/crates/openhuman-core/src/inbound/ops_tests.rs b/crates/openhuman-core/src/inbound/ops_tests.rs
index a28a9f07f9..badc66bc74 100644
--- a/crates/openhuman-core/src/inbound/ops_tests.rs
+++ b/crates/openhuman-core/src/inbound/ops_tests.rs
@@ -13,7 +13,9 @@ async fn the_component_switch_refuses_every_operation() {
dead(&config, &client, None).await.map(|_| ()),
redrive(&config, &client, "x").await.map(|_| ()),
] {
- assert!(refused.unwrap_err().contains("COMPONENT_DISABLED:eventqueues"));
+ assert!(refused
+ .unwrap_err()
+ .contains("COMPONENT_DISABLED:eventqueues"));
}
}
@@ -28,7 +30,9 @@ async fn the_operations_reach_the_module() {
let parked = dead(&config, &rig.client, Some(10_000)).await.unwrap();
assert!(parked.value.items.is_empty());
- let gone = redrive(&config, &rig.client, "teq.dead/none").await.unwrap();
+ let gone = redrive(&config, &rig.client, "teq.dead/none")
+ .await
+ .unwrap();
assert!(!gone.value.redriven);
assert!(redrive(&config, &rig.client, " ")
.await
diff --git a/crates/openhuman-core/src/inbound/schemas_tests.rs b/crates/openhuman-core/src/inbound/schemas_tests.rs
index da0990115c..cf900b3644 100644
--- a/crates/openhuman-core/src/inbound/schemas_tests.rs
+++ b/crates/openhuman-core/src/inbound/schemas_tests.rs
@@ -11,7 +11,10 @@ fn every_function_has_a_schema_and_a_controller() {
let controllers = all_registered_controllers();
assert_eq!(controllers.len(), 3);
assert_eq!(schemas("unknown").function, "unknown");
- assert!(schemas("redrive").inputs.iter().any(|input| input.name == "id" && input.required));
+ assert!(schemas("redrive")
+ .inputs
+ .iter()
+ .any(|input| input.name == "id" && input.required));
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/inbound/settings_tests.rs b/crates/openhuman-core/src/inbound/settings_tests.rs
index e36de774e7..a7d0ca4d3a 100644
--- a/crates/openhuman-core/src/inbound/settings_tests.rs
+++ b/crates/openhuman-core/src/inbound/settings_tests.rs
@@ -84,7 +84,10 @@ fn a_queue_url_selects_the_backend() {
config.inbound.queue_url = Some("amqp://guest:guest@localhost/".into());
let refused = resolve(&config).unwrap_err();
assert!(refused.contains("rabbitmq"), "{refused}");
- assert!(!refused.contains("guest:guest"), "credentials leaked: {refused}");
+ assert!(
+ !refused.contains("guest:guest"),
+ "credentials leaked: {refused}"
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs
index 814caf83ef..17c6bbf7a5 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber_tests.rs
@@ -49,7 +49,11 @@ async fn a_deferred_composio_trigger_is_retried_at_its_defer_time_instead_of_dro
route(&rig, Some(active_config()), trigger("uuid-deferred")).await;
let applied = triage.until_applied(1, Duration::from_secs(15)).await;
- assert_eq!(applied, vec![LABEL.to_owned()], "the deferred trigger was dropped");
+ assert_eq!(
+ applied,
+ vec![LABEL.to_owned()],
+ "the deferred trigger was dropped"
+ );
assert_eq!(triage.runs(), 2, "triaged, deferred, then triaged again");
assert!(
started.elapsed() >= Duration::from_millis(350),
@@ -72,7 +76,11 @@ async fn a_redelivered_composio_trigger_produces_one_turn() {
assert_eq!(applied, vec![LABEL.to_owned()]);
// Give a second turn every chance to appear.
tokio::time::sleep(Duration::from_millis(500)).await;
- assert_eq!(triage.applied().len(), 1, "a redelivery produced another turn");
+ assert_eq!(
+ triage.applied().len(),
+ 1,
+ "a redelivery produced another turn"
+ );
assert_eq!(triage.runs(), 1, "a redelivery was triaged again");
}
diff --git a/crates/openhuman-core/src/platform/about_app/ops_tests.rs b/crates/openhuman-core/src/platform/about_app/ops_tests.rs
index 3be206d76f..033c2b7156 100644
--- a/crates/openhuman-core/src/platform/about_app/ops_tests.rs
+++ b/crates/openhuman-core/src/platform/about_app/ops_tests.rs
@@ -77,7 +77,10 @@ fn inbound_queue_capability_shows_disabled_when_the_eventqueues_component_is_off
CapabilityStatus::Disabled
);
let tasks = super::super::lookup("automation.task_sources").expect("task sources");
- assert_eq!(apply_components(tasks, &off("eventqueues")).status, tasks.status);
+ assert_eq!(
+ apply_components(tasks, &off("eventqueues")).status,
+ tasks.status
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/skills/webhooks/bus_tests.rs b/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
index 2b8860960f..1247be43c1 100644
--- a/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
+++ b/crates/openhuman-core/src/skills/webhooks/bus_tests.rs
@@ -166,8 +166,7 @@ mod inbound {
async fn route(rig: &Rig, config: Option<crate::config::Config>, correlation_id: &str) {
let envelope = request();
let queued =
- route_agent_trigger(config, &envelope, correlation_id, Some(rig.client.clone()))
- .await;
+ route_agent_trigger(config, &envelope, correlation_id, Some(rig.client.clone())).await;
if !queued {
triage_agent_directly(
DispatchCtx::host_default(),
@@ -189,7 +188,11 @@ mod inbound {
route(&rig, Some(active_config()), "corr-deferred").await;
let applied = triage.until_applied(1, Duration::from_secs(15)).await;
- assert_eq!(applied, vec![LABEL.to_owned()], "the deferred webhook was dropped");
+ 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),
@@ -210,7 +213,11 @@ mod inbound {
let applied = triage.until_applied(1, Duration::from_secs(15)).await;
assert_eq!(applied, vec![LABEL.to_owned()]);
tokio::time::sleep(Duration::from_millis(500)).await;
- assert_eq!(triage.applied().len(), 1, "a redelivery produced another turn");
+ assert_eq!(
+ triage.applied().len(),
+ 1,
+ "a redelivery produced another turn"
+ );
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
diff --git a/crates/openhuman-core/src/triage/origin_tests.rs b/crates/openhuman-core/src/triage/origin_tests.rs
index e0d5bdb6a7..7e61df7594 100644
--- a/crates/openhuman-core/src/triage/origin_tests.rs
+++ b/crates/openhuman-core/src/triage/origin_tests.rs
@@ -92,6 +92,8 @@ fn every_dispatch_site_scopes_an_origin() {
),
("crates/openhuman-core/src/skills/webhooks/ops.rs", "remote"),
("crates/openhuman-core/src/skills/webhooks/bus.rs", "remote"),
+ // The inbound event queues' `Deliver` callback (via `RemoteTriage`).
+ ("crates/openhuman-core/src/inbound/host.rs", "remote"),
// Locally initiated — trust root.
(
"crates/openhuman-core/src/desktop/notifications/rpc.rs",
@@ -130,6 +132,24 @@ fn every_dispatch_site_scopes_an_origin() {
let Ok(text) = std::fs::read_to_string(&path) else {
continue;
};
+ // A file that constructs `RemoteTriage` dispatches through it: the
+ // runner scopes the remote origin itself (pinned by
+ // `remote_triage_scopes_the_remote_origin`), so such a site is
+ // remote by construction and must be recorded as remote.
+ if !text.contains("apply_decision(") && text.contains("RemoteTriage") {
+ let kind = KNOWN_SITES
+ .iter()
+ .find(|(path, _)| *path == rel)
+ .map(|(_, kind)| *kind);
+ assert_eq!(
+ kind,
+ Some("remote"),
+ "{rel} dispatches triage through `RemoteTriage`; record it in \
+ KNOWN_SITES as `remote` (and use it only for remote payloads)"
+ );
+ found.push(rel);
+ continue;
+ }
if text.contains("apply_decision(") {
assert!(
text.contains("with_origin("),
@@ -190,3 +210,19 @@ fn every_dispatch_site_scopes_an_origin() {
and record it in KNOWN_SITES"
);
}
+
+/// `RemoteTriage` is the dispatch of every site that constructs it, so it
+/// must scope the remote origin, and never the local trust root.
+#[test]
+fn remote_triage_scopes_the_remote_origin() {
+ let root = std::path::Path::new(env!("OPENHUMAN_REPOSITORY_ROOT"));
+ let text =
+ std::fs::read_to_string(root.join("crates/openhuman-core/src/triage/runner.rs")).unwrap();
+ let apply = text
+ .split("impl TriageRunner for RemoteTriage")
+ .nth(1)
+ .expect("RemoteTriage implements TriageRunner");
+ assert!(apply.contains("remote_trigger_origin(envelope)"));
+ assert!(apply.contains("with_origin(origin, apply_decision("));
+ assert!(!apply.contains("local_trigger_origin"));
+}
diff --git a/crates/openhuman-core/src/triage/runner.rs b/crates/openhuman-core/src/triage/runner.rs
index 7a4aa2d48e..d3e10d0d31 100644
--- a/crates/openhuman-core/src/triage/runner.rs
+++ b/crates/openhuman-core/src/triage/runner.rs
@@ -8,6 +8,13 @@
//! inbound event queues' `Deliver` callback all go through this trait, so
//! their behavior is testable without a model: tests script the outcomes, and
//! production uses [`RemoteTriage`].
+//!
+//! [`RemoteTriage`] carries its provenance in its name: it applies every
+//! decision under [`remote_trigger_origin`], so it is only for payloads an
+//! outsider can influence. A locally initiated trigger keeps calling
+//! [`apply_decision`] under `local_trigger_origin` itself. The dispatch-site
+//! tripwire (`origin_tests::every_dispatch_site_scopes_an_origin`) counts a
+//! file that constructs `RemoteTriage` as a remote dispatch site.
use async_trait::async_trait;
@@ -44,7 +51,8 @@ pub trait TriageRunner: Send + Sync {
) -> anyhow::Result<()>;
}
-/// The production runner: [`run_triage`] and [`apply_decision`].
+/// The production runner for remote payloads: [`run_triage`], and
+/// [`apply_decision`] under [`remote_trigger_origin`].
#[derive(Debug, Clone, Copy, Default)]
pub struct RemoteTriage;