Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(composio): thread DispatchCtx through composio and flow test call sites

Steven Enamakel6d81f2e136ca
diff --git a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
index 646a46650c..e91bd05d1f 100644
--- a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
@@ -97,7 +97,7 @@ async fn compute_required_connections_flags_missing_composio_toolkits() {
"edges": [ { "from_node": "t", "to_node": "send" } ]
});
let graph = tinyflows::migrate::deserialize_graph(graph_json).unwrap();
- let required = compute_required_connections(&config, &graph).await;
+ let required = compute_required_connections(&crate::core::runtime::DispatchCtx::ambient(), &config, &graph).await;
assert_eq!(required.len(), 1);
assert_eq!(required[0]["toolkit"], "gmail");
assert_eq!(required[0]["status"], "missing");
@@ -121,7 +121,7 @@ async fn compute_required_connections_skips_native_and_http_nodes() {
]
});
let graph = tinyflows::migrate::deserialize_graph(graph_json).unwrap();
- let required = compute_required_connections(&config, &graph).await;
+ let required = compute_required_connections(&crate::core::runtime::DispatchCtx::ambient(), &config, &graph).await;
assert!(
required.is_empty(),
"native oh: and http_request need no connection: {required:?}"
diff --git a/crates/openhuman-core/src/flows/ops_validate_warnings_and_connections_tests.rs b/crates/openhuman-core/src/flows/ops_validate_warnings_and_connections_tests.rs
index d75c97277c..30d32225ad 100644
--- a/crates/openhuman-core/src/flows/ops_validate_warnings_and_connections_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_validate_warnings_and_connections_tests.rs
@@ -483,7 +483,7 @@ async fn flows_list_connections_aggregates_http_creds_and_tolerates_composio() {
.upsert(&HttpCredential::bearer("stripe", "sk_live_seed_secret"))
.unwrap();
- let outcome = flows_list_connections(&config).await.unwrap();
+ let outcome = flows_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap();
let refs: Vec<_> = outcome
.value
.iter()
diff --git a/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs b/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs
index 706f15387e..06ec171a9a 100644
--- a/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs
@@ -54,11 +54,11 @@ async fn the_file_store_dispatches_to_documents_when_a_backend_is_pinned() {
value.insert("gmail".to_string(), 7u32);
// Pin on this thread for the awaits below (a current-thread runtime).
super::TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = Some(docs.clone()));
- super::super::file_store::save(&config, "composio_identities.json", &value)
+ super::super::file_store::save(&crate::core::runtime::DispatchCtx::ambient(), &crate::core::runtime::DispatchCtx::ambient(), &config, "composio_identities.json", &value)
.await
.unwrap();
let loaded: BTreeMap<String, u32> =
- super::super::file_store::load(&config, "composio_identities.json")
+ super::super::file_store::load(&crate::core::runtime::DispatchCtx::ambient(), &crate::core::runtime::DispatchCtx::ambient(), &config, "composio_identities.json")
.await
.unwrap();
super::TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = None);
diff --git a/crates/openhuman-core/src/integrations/composio/identity_store_tests.rs b/crates/openhuman-core/src/integrations/composio/identity_store_tests.rs
index 0962ec1e30..ec2a58389e 100644
--- a/crates/openhuman-core/src/integrations/composio/identity_store_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/identity_store_tests.rs
@@ -24,12 +24,12 @@ async fn persist_then_load_groups_fields_per_connection() {
let dir = tempfile::tempdir().unwrap();
let config = config_in(&dir);
- let written = persist_provider_profile(&config, &slack_profile("conn-1"))
+ let written = persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &slack_profile("conn-1"))
.await
.unwrap();
assert_eq!(written, 4);
- let identities = load_connected_identities(&config).await.unwrap();
+ let identities = load_connected_identities(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap();
assert_eq!(identities.len(), 1);
let identity = &identities[0];
assert_eq!(identity.source, "slack");
@@ -43,7 +43,7 @@ async fn persist_then_load_groups_fields_per_connection() {
async fn persist_merges_into_the_stored_identity() {
let dir = tempfile::tempdir().unwrap();
let config = config_in(&dir);
- persist_provider_profile(&config, &slack_profile("conn-1"))
+ persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &slack_profile("conn-1"))
.await
.unwrap();
@@ -53,9 +53,9 @@ async fn persist_merges_into_the_stored_identity() {
display_name: Some("Ada L.".into()),
..ProviderUserProfile::default()
};
- persist_provider_profile(&config, &partial).await.unwrap();
+ persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &partial).await.unwrap();
- let identities = load_connected_identities(&config).await.unwrap();
+ let identities = load_connected_identities(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap();
assert_eq!(identities.len(), 1);
assert_eq!(identities[0].display_name.as_deref(), Some("Ada L."));
assert_eq!(identities[0].user_id.as_deref(), Some("U123ABC"));
@@ -69,34 +69,34 @@ async fn empty_profile_writes_nothing() {
toolkit: "gmail".into(),
..ProviderUserProfile::default()
};
- assert_eq!(persist_provider_profile(&config, &empty).await.unwrap(), 0);
- let stored: Vec<ConnectedIdentity> = file_store::load(&config, IDENTITIES_FILE).await.unwrap();
+ assert_eq!(persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &empty).await.unwrap(), 0);
+ let stored: Vec<ConnectedIdentity> = file_store::load(&crate::core::runtime::DispatchCtx::ambient(), &config, IDENTITIES_FILE).await.unwrap();
assert!(stored.is_empty());
- assert!(load_connected_identities(&config).await.unwrap().is_empty());
+ assert!(load_connected_identities(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap().is_empty());
}
#[tokio::test]
async fn delete_removes_only_the_named_connection() {
let dir = tempfile::tempdir().unwrap();
let config = config_in(&dir);
- persist_provider_profile(&config, &slack_profile("conn-1"))
+ persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &slack_profile("conn-1"))
.await
.unwrap();
- persist_provider_profile(&config, &slack_profile("conn-2"))
+ persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, &slack_profile("conn-2"))
.await
.unwrap();
- let deleted = delete_connected_identity_facets(&config, "SLACK", "conn-1")
+ let deleted = delete_connected_identity_facets(&crate::core::runtime::DispatchCtx::ambient(), &config, "SLACK", "conn-1")
.await
.unwrap();
assert_eq!(deleted, 4);
- let identities = load_connected_identities(&config).await.unwrap();
+ let identities = load_connected_identities(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap();
assert_eq!(identities.len(), 1);
assert_eq!(identities[0].identifier, "conn-2");
assert_eq!(
- delete_connected_identity_facets(&config, "slack", "conn-1")
+ delete_connected_identity_facets(&crate::core::runtime::DispatchCtx::ambient(), &config, "slack", "conn-1")
.await
.unwrap(),
0
diff --git a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs_tests.rs
index c5d2a8d6df..70a89fef69 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
@@ -45,7 +45,7 @@ async fn a_legacy_pref_either_reaches_the_module_or_stays_stored() {
let dir = tempfile::tempdir().unwrap();
let config = config_in(&dir);
let legacy = serde_json::json!({"github":{"read":true,"write":false,"admin":true}});
- file_store::save(&config, USER_SCOPES_FILE, &legacy)
+ file_store::save(&crate::core::runtime::DispatchCtx::ambient(), &config, USER_SCOPES_FILE, &legacy)
.await
.unwrap();
let stored = UserScopePref {
@@ -56,7 +56,7 @@ async fn a_legacy_pref_either_reaches_the_module_or_stays_stored() {
let pref = load_or_default(&config, "github").await;
let done = migrated().lock().unwrap().contains(&config.workspace_dir);
- let left: LegacyScopeFile = file_store::load(&config, USER_SCOPES_FILE).await.unwrap();
+ let left: LegacyScopeFile = file_store::load(&crate::core::runtime::DispatchCtx::ambient(), &config, USER_SCOPES_FILE).await.unwrap();
if done {
assert_eq!(pref, stored, "the migrated row must decide visibility");
assert!(left.is_empty(), "the stored value is emptied once moved");
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.rs
index 9dfbe44a72..7147302e6a 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
@@ -520,7 +520,7 @@ async fn enrich_leaves_unmatched_connection_unchanged() {
let config = test_config(&tmp);
// Persist a profile for a DIFFERENT connection id.
- persist_provider_profile(
+ persist_provider_profile(&crate::core::runtime::DispatchCtx::ambient(),
&config,
&ProviderUserProfile {
toolkit: "gmail".to_string(),
diff --git a/crates/openhuman-core/src/integrations/composio/ops_fetch_integrations_and_triggers_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_fetch_integrations_and_triggers_tests.rs
index aa55269560..1fb05284d4 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_fetch_integrations_and_triggers_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_fetch_integrations_and_triggers_tests.rs
@@ -578,7 +578,7 @@ async fn composio_list_connections_routes_through_direct_mode() {
// remote will reject the test request, so we assert on the error
// shape: it must reference `composio` AND must NOT reference the
// backend-session path (proving the factory routed us to direct).
- let result = composio_list_connections(&config).await;
+ let result = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &config).await;
match result {
Ok(outcome) => {
// Some sandboxes resolve OK with an empty list — accept
@@ -646,7 +646,7 @@ async fn composio_list_connections_returns_empty_when_direct_mode_no_key() {
// RC of TAURI-RUST-R4: this MUST be Ok(empty), not Err — no error is
// constructed, so nothing reaches Sentry and the 5 s poll stops
// churning.
- let outcome = composio_list_connections(&config)
+ let outcome = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &config)
.await
.expect("direct mode with no key must return an empty list, not an error");
assert!(
diff --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.rs
index 803cb310ed..21712187c9 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
@@ -57,7 +57,7 @@ async fn composio_list_connections_is_quietly_unavailable_without_session() {
// answer and the reconcile / flows callers keep their fail-open handling —
// but nothing is reported to Sentry, and the JSON-RPC boundary demotes the
// wording as expected user state (`is_session_expired_message`).
- let err = composio_list_connections(&config).await.unwrap_err();
+ let err = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap_err();
assert!(
err.contains("no backend session token"),
"the error should say what is missing: {err}"
@@ -97,7 +97,7 @@ async fn composio_delete_connection_errors_without_session() {
let _serialised = module_guard().await;
let tmp = tempfile::tempdir().unwrap();
let config = test_config(&tmp);
- let err = composio_delete_connection(&config, "c-1")
+ let err = composio_delete_connection(&crate::core::runtime::DispatchCtx::ambient(), &config, "c-1")
.await
.unwrap_err();
assert!(
@@ -150,7 +150,7 @@ async fn composio_get_user_profile_errors_without_session() {
let _serialised = module_guard().await;
let tmp = tempfile::tempdir().unwrap();
let config = test_config(&tmp);
- let err = composio_get_user_profile(&config, "c-1").await.unwrap_err();
+ let err = composio_get_user_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, "c-1").await.unwrap_err();
// Fails while resolving which toolkit `c-1` belongs to, because that needs
// the connection list and the connection list needs a credential. Still a
// failure that names the domain, which is the contract here.
@@ -235,7 +235,7 @@ async fn composio_list_connections_via_mock_counts_active() {
let base = start_mock_backend(app).await;
let tmp = tempfile::tempdir().unwrap();
let config = config_with_backend(&tmp, base);
- let outcome = composio_list_connections(&config).await.unwrap();
+ let outcome = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &config).await.unwrap();
assert_eq!(outcome.value.connections.len(), 3);
// 2 active, 3 total
assert!(outcome.logs.iter().any(|l| l.contains("3 connection")));
@@ -262,7 +262,7 @@ async fn composio_list_connections_drops_the_module_route_once_signed_out() {
let signed_in_tmp = tempfile::tempdir().unwrap();
let signed_in = config_with_backend(&signed_in_tmp, base);
// Signed in: the module is loaded and routed to the mock backend.
- let outcome = composio_list_connections(&signed_in).await.unwrap();
+ let outcome = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &signed_in).await.unwrap();
assert_eq!(outcome.value.connections.len(), 1);
assert!(
!last_route_is_none(),
@@ -276,7 +276,7 @@ async fn composio_list_connections_drops_the_module_route_once_signed_out() {
// answering.
let signed_out_tmp = tempfile::tempdir().unwrap();
let signed_out = test_config(&signed_out_tmp);
- let err = composio_list_connections(&signed_out).await.unwrap_err();
+ let err = composio_list_connections(&crate::core::runtime::DispatchCtx::ambient(), &signed_out).await.unwrap_err();
assert!(err.contains("no backend session token"), "{err}");
assert!(
last_route_is_none(),
@@ -387,6 +387,6 @@ async fn composio_delete_connection_via_mock() {
let base = start_mock_backend(app).await;
let tmp = tempfile::tempdir().unwrap();
let config = config_with_backend(&tmp, base);
- let outcome = composio_delete_connection(&config, "c1").await.unwrap();
+ let outcome = composio_delete_connection(&crate::core::runtime::DispatchCtx::ambient(), &config, "c1").await.unwrap();
assert!(outcome.value.deleted);
}
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.rs
index 823736c8e9..0df0d53f35 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
@@ -64,7 +64,7 @@ async fn composio_get_user_profile_via_mock_returns_provider_profile() {
let _workspace_env_guard = EnvVarGuard::workspace_unlocked(tmp.path());
config.save().await.unwrap();
- let outcome = composio_get_user_profile(&config, "c1").await.unwrap();
+ let outcome = composio_get_user_profile(&crate::core::runtime::DispatchCtx::ambient(), &config, "c1").await.unwrap();
assert_eq!(outcome.value.toolkit, "gmail");
assert_eq!(outcome.value.connection_id.as_deref(), Some("c1"));
@@ -205,7 +205,7 @@ async fn composio_list_tools_honours_a_preference_still_in_the_legacy_file() {
let base = start_mock_backend(app).await;
let tmp = tempfile::tempdir().unwrap();
let config = config_with_backend(&tmp, base);
- crate::integrations::composio::file_store::save(
+ crate::integrations::composio::file_store::save(&crate::core::runtime::DispatchCtx::ambient(),
&config,
crate::integrations::composio::file_store::USER_SCOPES_FILE,
&json!({"gmail": {"read": true, "write": false, "admin": false}}),
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.rs
index 3e7259826f..043e07ea4d 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
@@ -155,7 +155,7 @@ async fn a_preference_still_in_the_legacy_file_gates_execution() {
let mut config = Config::default();
config.workspace_dir = tmp.path().join("workspace");
config.config_path = tmp.path().join("config.toml");
- crate::integrations::composio::file_store::save(
+ crate::integrations::composio::file_store::save(&crate::core::runtime::DispatchCtx::ambient(),
&config,
crate::integrations::composio::file_store::USER_SCOPES_FILE,
&serde_json::json!({"gmail": {"read": true, "write": false, "admin": false}}),