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(composio): add coverage for scope gating and tool execution
Steven Enamakele3be3410e00f
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tool_results_and_credentials_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tool_results_and_credentials_tests.rsindex 5959e44b82..ae8e86d71a 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tool_results_and_credentials_tests.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tool_results_and_credentials_tests.rs@@ -163,7 +163,7 @@ async fn unknown_toolkit_still_rejects() {assert!(catalog_for_toolkit("flowstestkit").is_none());// No connected set at all → fail-closed reject.- assert!(!flow_tool_allowed(&config, "FLOWSTESTKIT_DO_THING", None).await);+ assert!(!flow_tool_allowed(&crate::core::runtime::DispatchCtx::ambient(), &config, "FLOWSTESTKIT_DO_THING", None).await);// Connected set present but does not include this toolkit → reject.assert!(!flow_tool_allowed(@@ -174,7 +174,7 @@ async fn unknown_toolkit_still_rejects() {.await);// A blank slug is always rejected.- assert!(!flow_tool_allowed(&config, "", Some(&["flowstestkit".to_string()])).await);+ assert!(!flow_tool_allowed(&crate::core::runtime::DispatchCtx::ambient(), &config, "", Some(&["flowstestkit".to_string()])).await);}/// A real Composio toolkit OpenHuman ships no static catalog for now PASSESdiff --git a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rsindex 133ec55c95..4a89067237 100644--- a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rs@@ -33,7 +33,7 @@ fn row_key_normalises_the_toolkit() {async fn save_rejects_an_empty_toolkit() {let dir = tempfile::tempdir().unwrap();let config = config_in(&dir);- assert!(save(&config, " ", UserScopePref::default()).await.is_err());+ assert!(save(&crate::core::runtime::DispatchCtx::ambient(), &config, " ", UserScopePref::default()).await.is_err());}/// A stored preference is never lost: either the module took it (the read@@ -59,7 +59,7 @@ async fn a_legacy_pref_either_reaches_the_module_or_stays_stored() {admin: true,};- let pref = load_or_default(&config, "github").await;+ let pref = load_or_default(&crate::core::runtime::DispatchCtx::ambient(), &config, "github").await;let done = migrated().lock().unwrap().contains(&config.workspace_dir);let left: LegacyScopeFile = file_store::load(&crate::core::runtime::DispatchCtx::ambient(),@@ -85,6 +85,6 @@ async fn a_legacy_pref_either_reaches_the_module_or_stays_stored() {async fn a_workspace_with_no_legacy_file_is_marked_migrated() {let dir = tempfile::tempdir().unwrap();let config = config_in(&dir);- migrate_legacy(&config).await;+ migrate_legacy(&crate::core::runtime::DispatchCtx::ambient(), &config).await;assert!(migrated().lock().unwrap().contains(&config.workspace_dir));}diff --git a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rsindex 6981a6a3d4..56d0438b51 100644--- a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs@@ -134,7 +134,7 @@ async fn composio_list_tools_in_direct_mode_does_not_fall_back_to_backend() {let _serialised = module_guard().await;let tmp = tempfile::tempdir().unwrap();let config = direct_mode_config(&tmp);- let result = composio_list_tools(&config, None, None).await;+ let result = composio_list_tools(&crate::core::runtime::DispatchCtx::ambient(), &config, None, None).await;match result {Ok(outcome) => {// If the prefetch returns empty connections (test env maydiff --git a/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rsindex e0bc7e78b5..eb00d6a6c7 100644--- a/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs@@ -123,7 +123,7 @@ async fn composio_list_tools_errors_without_session() {let _serialised = module_guard().await;let tmp = tempfile::tempdir().unwrap();let config = test_config(&tmp);- let err = composio_list_tools(&config, None, None).await.unwrap_err();+ let err = composio_list_tools(&crate::core::runtime::DispatchCtx::ambient(), &config, None, None).await.unwrap_err();// Same contract as `composio_list_toolkits_errors_without_session`.assert!(err.to_lowercase().contains("composio"),@@ -184,7 +184,7 @@ async fn composio_list_trigger_history_errors_when_store_not_init() {// reading history reports that rather than answering with an empty list —// "no triggers have fired" and "nothing is recording them" are different// things to tell someone debugging a trigger.- let err = composio_list_trigger_history(&config, Some(10))+ let err = composio_list_trigger_history(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(10)).await.unwrap_err();assert!(err.contains("list_trigger_history failed"), "{err}");diff --git a/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rsindex f03743799b..e111d73dab 100644--- a/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs@@ -94,7 +94,7 @@ async fn composio_list_tools_via_mock_with_filter() {let base = start_mock_backend(app).await;let tmp = tempfile::tempdir().unwrap();let config = config_with_backend(&tmp, base);- let outcome = composio_list_tools(&config, Some(vec!["gmail".into()]), None)+ let outcome = composio_list_tools(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(vec!["gmail".into()]), None).await.unwrap();assert_eq!(outcome.value.tools.len(), 2);@@ -122,7 +122,7 @@ async fn composio_list_tools_lets_the_module_apply_the_scope_preference_and_catalet base = start_mock_backend(app).await;let tmp = tempfile::tempdir().unwrap();let config = config_with_backend(&tmp, base);- let outcome = composio_list_tools(&config, Some(vec!["gmail".into()]), None)+ let outcome = composio_list_tools(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(vec!["gmail".into()]), None).await.unwrap();let names: Vec<&str> = outcome@@ -217,10 +217,10 @@ async fn composio_list_tools_honours_a_preference_still_in_the_legacy_file() {.await.unwrap();- let outcome = composio_list_tools(&config, Some(vec!["gmail".into()]), None).await;+ let outcome = composio_list_tools(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(vec!["gmail".into()]), None).await;// The module's preference store is process-wide: put the default back// before asserting so a failure cannot leak `write=false` into other tests.- let restored = save_user_scope_pref(&config, "gmail", Default::default()).await;+ let restored = save_user_scope_pref(&crate::core::runtime::DispatchCtx::ambient(), &config, "gmail", Default::default()).await;let outcome = outcome.unwrap();restored.unwrap();diff --git a/crates/openhuman-core/src/integrations/composio/tools/scope_gate_tests.rs b/crates/openhuman-core/src/integrations/composio/tools/scope_gate_tests.rsindex ce1fabbffb..8f2e729940 100644--- a/crates/openhuman-core/src/integrations/composio/tools/scope_gate_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/scope_gate_tests.rs@@ -164,8 +164,9 @@ async fn a_preference_still_in_the_legacy_file_gates_execution() {.await.unwrap();- let decision = evaluate_tool_visibility(&config, "GMAIL_SEND_EMAIL").await;+ let decision = evaluate_tool_visibility(&crate::core::runtime::DispatchCtx::ambient(), &config, "GMAIL_SEND_EMAIL").await;let restored = crate::integrations::composio::ops::save_user_scope_pref(+ &crate::core::runtime::DispatchCtx::ambient(),&config,"gmail",Default::default(),diff --git a/crates/openhuman-core/src/integrations/composio/trigger_history_tests.rs b/crates/openhuman-core/src/integrations/composio/trigger_history_tests.rsindex 91908c3d7e..b12fc0e585 100644--- a/crates/openhuman-core/src/integrations/composio/trigger_history_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/trigger_history_tests.rs@@ -13,7 +13,7 @@ async fn disabled_archive_operations_leave_the_host_filesystem_untouched() {fixture: None,};assert!(owner- .read(&config, Some(10))+ .read(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(10)).await.unwrap_err().contains("module unavailable"));@@ -112,9 +112,9 @@ async fn changing_users_releases_the_old_archive_before_opening_the_next_scope());let mut config = Config::default();config.workspace_dir = PathBuf::from("first");- owner.read(&config, Some(2)).await.unwrap();+ owner.read(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(2)).await.unwrap();config.workspace_dir = PathBuf::from("second");- owner.read(&config, Some(2)).await.unwrap();+ owner.read(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(2)).await.unwrap();owner.close().await.unwrap();owner.close().await.unwrap();assert_eq!(@@ -144,7 +144,7 @@ async fn cancelling_a_pending_open_retains_a_handle_that_shutdown_can_release()config.workspace_dir = PathBuf::from("cancelled");let opening = tokio::spawn({let owner = owner.clone();- async move { owner.read(&config, Some(1)).await }+ async move { owner.read(&crate::core::runtime::DispatchCtx::ambient(), &config, Some(1)).await }});observed.open_started.notified().await;opening.abort();