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
test(flows): add runs adapter test module and document caps host scoping
Steven Enamakel7e151895e190
diff --git a/crates/openhuman-core/src/flows/bus/run_digest.rs b/crates/openhuman-core/src/flows/bus/run_digest.rsindex 0fa6d34930..fddc39b84e 100644--- a/crates/openhuman-core/src/flows/bus/run_digest.rs+++ b/crates/openhuman-core/src/flows/bus/run_digest.rs@@ -59,7 +59,7 @@ impl FlowRunDigestSubscriber {Self { config }}- async fn handle_finished(+ pub(super) async fn handle_finished(&self,ctx: crate::core::runtime::DispatchCtx,flow_id: &str,diff --git a/crates/openhuman-core/src/flows/caps_host/binding.rs b/crates/openhuman-core/src/flows/caps_host/binding.rsindex f635ad0691..c0fde6a456 100644--- a/crates/openhuman-core/src/flows/caps_host/binding.rs+++ b/crates/openhuman-core/src/flows/caps_host/binding.rs@@ -36,8 +36,9 @@ pub(crate) struct CapsHostBinding {}/// Bounds invocation records and cancel-before-start tombstones retained by-/// one run binding. Once either capacity is exhausted, new ids fail closed for-/// the remaining lifetime of the binding.+/// one run binding. IDs only correlate requests within this binding; the+/// callback address remains the authority boundary. Once capacity is exhausted,+/// new ids fail closed for the remaining lifetime of the binding.const MAX_AGENT_RUN_RECORDS: usize = 10_000;const MAX_AGENT_CANCEL_TOMBSTONES: usize = 4_096;diff --git a/crates/openhuman-core/src/flows/caps_host/service.rs b/crates/openhuman-core/src/flows/caps_host/service.rsindex 8b1d953d7d..790f1fae29 100644--- a/crates/openhuman-core/src/flows/caps_host/service.rs+++ b/crates/openhuman-core/src/flows/caps_host/service.rs@@ -219,6 +219,8 @@ impl CapsHostService {Ok(runs::AgentRunHandle { handle })}+ /// Cancel one host task; the id is scoped to this callback binding and+ /// grants no authority outside its object path.async fn agent_cancel(&self, request: runs::AgentCancelRequest) -> tinybus::Result<()> {if !valid_agent_request_id(&request.client_request_id) {return Err(tinybus::Error::failed(diff --git a/crates/openhuman-core/src/flows/runs_adapter.rs b/crates/openhuman-core/src/flows/runs_adapter.rsindex 9f68ab5ef6..f2a3091215 100644--- a/crates/openhuman-core/src/flows/runs_adapter.rs+++ b/crates/openhuman-core/src/flows/runs_adapter.rs@@ -511,6 +511,10 @@ fn bus_trigger(trigger: FlowRunTrigger) -> runs::FlowRunTrigger {}}+#[cfg(test)]+#[path = "runs_adapter_tests.rs"]+mod tests;+async fn run_exists(config: &Config,storage: tinyflows_bus::catalog::CatalogStorage,diff --git a/crates/openhuman-core/src/flows/runs_adapter_tests.rs b/crates/openhuman-core/src/flows/runs_adapter_tests.rsnew file mode 100644index 0000000000..82d0874fe8--- /dev/null+++ b/crates/openhuman-core/src/flows/runs_adapter_tests.rs@@ -0,0 +1,91 @@+use super::*;++fn finished(data: Value) -> runs::RunFinished {+ serde_json::from_value(data).expect("valid RunFinished event")+}++#[test]+fn failed_graph_with_engine_output_keeps_the_legacy_success_payload() {+ let output = json!({"partial": [1, 2], "nodes": {"node": "result"}});+ let outcome = finished_outcome(+ finished(json!({+ "status": "failed",+ "successful": false,+ "error": "a graph step failed",+ "output": output,+ "timed_out": false+ })),+ "flow:example:run",+ )+ .expect("an engine RunOutcome remains the legacy RPC payload, even for failed status");++ assert_eq!(outcome.run_id, "flow:example:run");+ assert_eq!(outcome.output, json!({"partial": [1, 2], "nodes": {"node": "result"}}));+ assert!(outcome.pending_approvals.is_empty());+ assert_eq!(outcome.status, "failed");+}++#[test]+fn explicit_cancel_maps_to_the_legacy_null_output_without_changing_module_data() {+ let module_output = json!({"partial": ["kept in module event"]});+ let outcome = finished_outcome(+ finished(json!({+ "status": "cancelled",+ "successful": false,+ "error": "run cancelled",+ "output": module_output,+ "timed_out": false+ })),+ "flow:example:cancelled",+ )+ .expect("explicit cancellation preserves the old null result");++ assert_eq!(outcome.output, Value::Null);+ assert_eq!(outcome.status, "cancelled");+}++#[test]+fn timeout_metadata_maps_to_legacy_error_without_parsing_error_text() {+ let error = finished_outcome(+ finished(json!({+ "status": "cancelled",+ "successful": false,+ "error": "run exceeded its 600000 ms timeout",+ "output": {"partial": true},+ "timed_out": true+ })),+ "flow:example:timeout",+ )+ .expect_err("timeouts remain errors in the synchronous legacy RPC");++ assert_eq!(error, "run exceeded its 600000 ms timeout");+}++#[test]+fn missing_engine_outcome_is_not_reconstructed_as_an_empty_object() {+ let error = finished_outcome(+ finished(json!({+ "status": "failed",+ "successful": false,+ "error": "capability setup failed",+ "timed_out": false+ })),+ "flow:example:no-output",+ )+ .expect_err("absence of an engine outcome must keep the legacy error path");++ assert_eq!(error, "capability setup failed");+}++#[test]+fn pre_output_wire_payload_deserializes_with_safe_defaults() {+ let finished = finished(json!({+ "status": "failed",+ "successful": false,+ "error": "legacy module event",+ "graph_run_id": null+ }));++ assert_eq!(finished.output, None);+ assert!(!finished.timed_out);+}diff --git a/crates/openhuman-core/src/modules/tinyflows.rs b/crates/openhuman-core/src/modules/tinyflows.rsindex ed48acfd83..ed15054a42 100644--- a/crates/openhuman-core/src/modules/tinyflows.rs+++ b/crates/openhuman-core/src/modules/tinyflows.rs@@ -263,6 +263,8 @@ mod imp {/// Serve one callback interface on the module runtime and return an RAII/// registration for it. The token is created inside the spawned task so/// cancellation of the caller cannot leave an unowned interface behind.+ /// CapsHost registrations advertise the v2 callback contract before their+ /// address can be handed to the Runs module.pub(crate) async fn serve_registered(path: String,object: impl tinybus::service::Interface + 'static,