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
refactor(caps_host): simplify capability error handling in tests and tools
Steven Enamakel6f39d615ae2c
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rsindex 5b8e52c9c0..33cc1c57db 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops.rs@@ -151,7 +151,7 @@ pub fn upsert_running(let now = chrono::Utc::now().to_rfc3339();let session_id = format!("subsess-{}", uuid::Uuid::new_v4());- let mut session = DurableSubagentSession {+ let session = DurableSubagentSession {subagent_session_id: session_id.clone(),parent_session: upsert.selector.parent_session.clone(),parent_thread_id: upsert.selector.parent_thread_id.clone(),diff --git a/crates/openhuman-core/src/flows/caps_host/ops_tier_gate_and_timeouts_tests.rs b/crates/openhuman-core/src/flows/caps_host/ops_tier_gate_and_timeouts_tests.rsindex 47152197ea..5aa889ba78 100644--- a/crates/openhuman-core/src/flows/caps_host/ops_tier_gate_and_timeouts_tests.rs+++ b/crates/openhuman-core/src/flows/caps_host/ops_tier_gate_and_timeouts_tests.rs@@ -21,14 +21,11 @@ fn http_request_node_tier_gate_blocks_readonly_allows_higher() {"http_request",).expect_err("read-only must block a Network-class http_request node");- if let EngineError::Capability(msg) = err {- assert!(- msg.contains(POLICY_BLOCKED_MARKER),- "read-only block must carry the policy-blocked marker: {msg}"- );- } else {- panic!("expected EngineError::Capability for a blocked node");- }+ let EngineError::Capability(msg) = err;+ assert!(+ msg.contains(POLICY_BLOCKED_MARKER),+ "read-only block must carry the policy-blocked marker: {msg}"+ );// Supervised/full do not hard-block — they fall through to the// ApprovalGate (which performs the Prompt round-trip).@@ -96,14 +93,11 @@ async fn http_adapter_blocks_under_readonly_tier() {.request(request, None).await.expect_err("read-only http_request node must be blocked");- if let EngineError::Capability(msg) = err {- assert!(- msg.contains(POLICY_BLOCKED_MARKER),- "expected a policy-blocked refusal, got: {msg}"- );- } else {- panic!("expected EngineError::Capability");- }+ let EngineError::Capability(msg) = err;+ assert!(+ msg.contains(POLICY_BLOCKED_MARKER),+ "expected a policy-blocked refusal, got: {msg}"+ );}/// End-to-end at the adapter: a Composio `tool_call` node under a@@ -130,14 +124,11 @@ async fn composio_tool_call_blocks_under_readonly_tier() {.invoke("SLACK_SEND_MESSAGE", json!({}), None).await.expect_err("read-only tier must block a Composio tool_call node before dispatch");- if let EngineError::Capability(msg) = err {- assert!(- msg.contains(POLICY_BLOCKED_MARKER),- "expected a policy-blocked refusal, got: {msg}"- );- } else {- panic!("expected EngineError::Capability");- }+ let EngineError::Capability(msg) = err;+ assert!(+ msg.contains(POLICY_BLOCKED_MARKER),+ "expected a policy-blocked refusal, got: {msg}"+ );}// ── Effect-aware Composio tier gating (fixes reads parking as pending@@ -179,14 +170,11 @@ async fn composio_read_action_allowed_under_readonly_tier() {.invoke("TWITTER_RECENT_SEARCH", json!({}), None).await.expect_err("no live Composio session is configured in this test");- if let EngineError::Capability(msg) = err {- assert!(- !msg.contains(POLICY_BLOCKED_MARKER),- "a curated read must never be refused by the autonomy-tier gate, got: {msg}"- );- } else {- panic!("expected EngineError::Capability");- }+ let EngineError::Capability(msg) = err;+ assert!(+ !msg.contains(POLICY_BLOCKED_MARKER),+ "a curated read must never be refused by the autonomy-tier gate, got: {msg}"+ );}/// A curated read under Supervised classifies as `CommandClass::Read`,@@ -220,14 +208,11 @@ async fn composio_read_action_does_not_prompt_under_supervised_tier() {.invoke("TWITTER_RECENT_SEARCH", json!({}), None).await.expect_err("no live Composio session is configured in this test");- if let EngineError::Capability(msg) = err {- assert!(- !msg.contains(POLICY_BLOCKED_MARKER),- "a curated read must pass the tier gate under Supervised, got: {msg}"- );- } else {- panic!("expected EngineError::Capability");- }+ let EngineError::Capability(msg) = err;+ assert!(+ !msg.contains(POLICY_BLOCKED_MARKER),+ "a curated read must pass the tier gate under Supervised, got: {msg}"+ );}/// Guard: a curated *write* action must still resolve to adiff --git a/crates/openhuman-core/src/flows/caps_host/ops_tier_live_config_tests.rs b/crates/openhuman-core/src/flows/caps_host/ops_tier_live_config_tests.rsindex 79f7bc7b98..ce5eba9ef2 100644--- a/crates/openhuman-core/src/flows/caps_host/ops_tier_live_config_tests.rs+++ b/crates/openhuman-core/src/flows/caps_host/ops_tier_live_config_tests.rs@@ -159,10 +159,7 @@ async fn malformed_live_config_is_denied_without_echoing_its_contents() {enforce_current_node_tier_gate(&ctx, &config, &baseline, CommandClass::Write, "code").await.expect_err("malformed persisted policy must deny rather than reuse Full");- let message = match error {- EngineError::Capability(message) => message,- other => panic!("expected capability denial, got {other:?}"),- };+ let EngineError::Capability(message) = error;assert!(message.contains(POLICY_BLOCKED_MARKER));assert!(!message.contains(canary), "config text leaked: {message}");}@@ -443,10 +440,7 @@ async fn http_adapter_passes_its_live_upgrade_to_the_http_gate_without_egress().request(json!({ "method": "GET", "url": "not-a-url" }), None).await.expect_err("invalid URL must fail before network access");- let message = match error {- EngineError::Capability(message) => message,- other => panic!("expected capability error, got {other:?}"),- };+ let EngineError::Capability(message) = error;assert_eq!(message, "Only http:// and https:// URLs are allowed","the refreshed policy must pass the inner NetGate and reach URL validation"diff --git a/crates/openhuman-core/src/flows/caps_host/tools/composio.rs b/crates/openhuman-core/src/flows/caps_host/tools/composio.rsindex 37adc4b99d..3ece7213bf 100644--- a/crates/openhuman-core/src/flows/caps_host/tools/composio.rs+++ b/crates/openhuman-core/src/flows/caps_host/tools/composio.rs@@ -61,7 +61,6 @@ impl FlowCallPolicy for FlowPolicy {fn capability_payload(error: EngineError) -> String {match error {EngineError::Capability(message) => message,- other => other.to_string(),}}diff --git a/crates/openhuman-core/src/flows/caps_host/tools/native.rs b/crates/openhuman-core/src/flows/caps_host/tools/native.rsindex dca54ef54f..f235abbf8f 100644--- a/crates/openhuman-core/src/flows/caps_host/tools/native.rs+++ b/crates/openhuman-core/src/flows/caps_host/tools/native.rs@@ -50,10 +50,7 @@ impl crate::tools::native_ops::flow_backend::FlowPolicyHooks for NativeFlowPolicsuper::super::current_tier_policy(self.ctx.dispatch, config, self.ctx.security).await.map(std::sync::Arc::new)- .map_err(|error| match error {- EngineError::Capability(body) => body,- other => other.to_string(),- })+ .map_err(|EngineError::Capability(body)| body)}async fn authorize(@@ -64,10 +61,7 @@ impl crate::tools::native_ops::flow_backend::FlowPolicyHooks for NativeFlowPolicargs: &Value,) -> std::result::Result<Option<String>, String> {let tier_decision = super::super::enforce_node_tier_gate(policy, class, "tool_call")- .map_err(|error| match error {- EngineError::Capability(body) => body,- other => other.to_string(),- })?;+ .map_err(|EngineError::Capability(body)| body)?;let summary = crate::security::approval::summarize_action(tool_name, args);let redacted = crate::security::approval::redact_args(args);let (outcome, audit_id) = super::super::gate_call_for_tier(diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rsindex 4cc0d15953..cf4ad81428 100644--- a/crates/openhuman-core/src/flows/ops/streaming.rs+++ b/crates/openhuman-core/src/flows/ops/streaming.rs@@ -60,7 +60,7 @@ pub(super) fn attach_flow_progress_bridge(agent: &mut crate::agent::OpenHumanSessionHost,target: &FlowStreamTarget,source: &str,- config: &Config,+ _config: &Config,) {let (progress_tx, progress_rx) = tokio::sync::mpsc::channel(64);agent.set_on_progress(Some(progress_tx));diff --git a/crates/openhuman-core/src/flows/ops/validation.rs b/crates/openhuman-core/src/flows/ops/validation.rsindex bc75cb02a6..a3149514a1 100644--- a/crates/openhuman-core/src/flows/ops/validation.rs+++ b/crates/openhuman-core/src/flows/ops/validation.rs@@ -153,7 +153,7 @@ pub async fn flows_validate("flow validation failed",);}- let graph: WorkflowGraph = match report+ let _graph: WorkflowGraph = match report.graph.ok_or_else(|| "TinyFlows validation returned no graph".to_string()).and_then(|graph| serde_json::from_value(graph).map_err(|error| error.to_string()))