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(approval): wait for audit row before dropping env in TTL tests
Steven Enamakelfb93c98f620d
diff --git a/src/openhuman/security/approval/gate_tests_part_01_tests.rs b/src/openhuman/security/approval/gate_tests_part_01_tests.rsindex 8ecefaf77b..ea760c1747 100644--- a/src/openhuman/security/approval/gate_tests_part_01_tests.rs+++ b/src/openhuman/security/approval/gate_tests_part_01_tests.rs@@ -511,16 +511,27 @@ async fn auto_approve_all_allows_a_remote_triage_dispatch_without_an_audit_row()#[tokio::test]async fn timeout_returns_deny() {- let (gate, _dir, _env) = expiry_gate();+ let (gate, _dir, env) = expiry_gate();let gate = Arc::new(gate);- let outcome = turn_origin::with_origin(- web_origin(),- APPROVAL_CHAT_CONTEXT.scope(- chat_ctx(),- gate.intercept("composio", "timed out", serde_json::json!({})),- ),- )- .await;+ let g = gate.clone();+ let handle = tokio::spawn(async move {+ turn_origin::with_origin(+ web_origin(),+ APPROVAL_CHAT_CONTEXT.scope(+ chat_ctx(),+ g.intercept("composio", "timed out", serde_json::json!({})),+ ),+ )+ .await+ });+ let mut tries = 0;+ while gate.list_pending().unwrap().is_empty() {+ tries += 1;+ assert!(tries < 50, "audit row never appeared for timeout test");+ tokio::time::sleep(Duration::from_millis(10)).await;+ }+ drop(env);+ let outcome = handle.await.unwrap();match outcome {GateOutcome::Deny { reason } => assert!(reason.contains("timed out")),other => panic!("expected deny, got {other:?}"),@@ -538,20 +549,31 @@ async fn timeout_returns_deny() {/// unapproved, mirroring `timeout_returns_deny` above.#[tokio::test]async fn cancel_flow_run_parks_for_approval_when_a_gate_is_present() {- let (gate, _dir, _env) = expiry_gate();+ let (gate, _dir, env) = expiry_gate();let gate = Arc::new(gate);- let outcome = turn_origin::with_origin(- web_origin(),- APPROVAL_CHAT_CONTEXT.scope(- chat_ctx(),- gate.intercept(- "cancel_flow_run",- "cancel run r-1 of flow f-1",- serde_json::json!({ "flow_id": "f-1", "run_id": "r-1" }),+ let g = gate.clone();+ let handle = tokio::spawn(async move {+ turn_origin::with_origin(+ web_origin(),+ APPROVAL_CHAT_CONTEXT.scope(+ chat_ctx(),+ g.intercept(+ "cancel_flow_run",+ "cancel run r-1 of flow f-1",+ serde_json::json!({ "flow_id": "f-1", "run_id": "r-1" }),+ ),),- ),- )- .await;+ )+ .await+ });+ let mut tries = 0;+ while gate.list_pending().unwrap().is_empty() {+ tries += 1;+ assert!(tries < 50, "audit row never appeared for cancel_flow_run");+ tokio::time::sleep(Duration::from_millis(10)).await;+ }+ drop(env);+ let outcome = handle.await.unwrap();// No decision ever arrives — the call must NOT auto-execute. It// parks until the gate's TTL elapses, then denies (never `Allow`).match outcome {diff --git a/src/openhuman/security/approval/gate_tests_part_02_tests.rs b/src/openhuman/security/approval/gate_tests_part_02_tests.rsindex 405dc05106..a985df5e64 100644--- a/src/openhuman/security/approval/gate_tests_part_02_tests.rs+++ b/src/openhuman/security/approval/gate_tests_part_02_tests.rs@@ -594,7 +594,7 @@ async fn intercept_with_workflow_require_approval_persists_and_ttl_denies() {// trust root — same conservative park-and-audit shape as// `GoalContinuation` / `ExternalChannel`, since there is no flow// review surface to route the prompt to yet (B3).- let (gate, _dir, _env) = expiry_gate();+ let (gate, _dir, env) = expiry_gate();let gate = Arc::new(gate);let origin = AgentTurnOrigin::TrustedAutomation {job_id: "flow-2".into(),@@ -625,6 +625,7 @@ async fn intercept_with_workflow_require_approval_persists_and_ttl_denies() {tokio::time::sleep(Duration::from_millis(10)).await;}+ drop(env);let outcome = handle.await.unwrap();match outcome {GateOutcome::Deny { reason } => assert!(reason.contains("timed out")),diff --git a/src/openhuman/security/approval/gate_tests_part_03_tests.rs b/src/openhuman/security/approval/gate_tests_part_03_tests.rsindex 99aef3ec2c..0589e94e05 100644--- a/src/openhuman/security/approval/gate_tests_part_03_tests.rs+++ b/src/openhuman/security/approval/gate_tests_part_03_tests.rs@@ -136,7 +136,7 @@ async fn intercept_with_external_channel_origin_persists_and_ttl_denies() {// Non-web channel inbound (Telegram / Discord / Slack / etc.):// persist an audit row but TTL-deny — there is no channel-routed// approval surface yet, and the input is remote-attacker text.- let (gate, _dir, _env) = expiry_gate();+ let (gate, _dir, env) = expiry_gate();let gate = Arc::new(gate);let origin = AgentTurnOrigin::ExternalChannel {channel: "telegram".into(),@@ -407,17 +407,28 @@ async fn flow_tool_trust_auto_allows_before_parking() {// A different tool on the same trusted flow is unaffected — it still// parks, and nothing decides it, so it TTL-denies after// `EXPIRY_TEST_TTL`.- let untrusted_outcome = turn_origin::with_origin(- flow_origin("flow-trusted", true),- APPROVAL_FLOW_RUN_CONTEXT.scope(- FlowRunContext {- flow_id: "flow-trusted".to_string(),- run_id: "run-1".to_string(),- },- gate.intercept("pushover", "send push", serde_json::json!({})),- ),- )- .await;+ let g = gate.clone();+ let handle = tokio::spawn(async move {+ turn_origin::with_origin(+ flow_origin("flow-trusted", true),+ APPROVAL_FLOW_RUN_CONTEXT.scope(+ FlowRunContext {+ flow_id: "flow-trusted".to_string(),+ run_id: "run-1".to_string(),+ },+ g.intercept("pushover", "send push", serde_json::json!({})),+ ),+ )+ .await+ });+ let mut tries = 0;+ while gate.list_pending().unwrap().is_empty() {+ tries += 1;+ assert!(tries < 50, "audit row never appeared for untrusted flow tool");+ tokio::time::sleep(Duration::from_millis(10)).await;+ }+ drop(env);+ let untrusted_outcome = handle.await.unwrap();assert!(matches!(untrusted_outcome, GateOutcome::Deny { .. }),"trust must be scoped to the exact tool granted, not the whole flow"