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
feat(composio): add load_or_default for user scope preferences
Steven Enamakel6abff421f2bb
diff --git a/crates/openhuman-core/src/integrations/composio/ops/mod.rs b/crates/openhuman-core/src/integrations/composio/ops/mod.rsindex 45a9e765d8..70d5c59d14 100644--- a/crates/openhuman-core/src/integrations/composio/ops/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/mod.rs@@ -75,7 +75,7 @@ pub use triggers::{// it was `tinymemory_core::sync::composio::providers::user_scopes` reached// through the in-process engine handle until openhuman#5560; see the module.pub(crate) use user_scopes::{- as load_user_scope_pref, save as save_user_scope_pref,+ load_or_default as load_user_scope_pref, save as save_user_scope_pref,};// ── Re-export connected_integrations public items ──────────────────────────diff --git a/crates/openhuman-core/src/integrations/composio/ops/user_scopes.rs b/crates/openhuman-core/src/integrations/composio/ops/user_scopes.rsindex b8a10bec8c..35a7a53298 100644--- a/crates/openhuman-core/src/integrations/composio/ops/user_scopes.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/user_scopes.rs@@ -55,6 +55,86 @@ fn kv_key(toolkit: &str) -> String {toolkit.trim().to_ascii_lowercase()}+/// The scope pref stored for `toolkit`, or the default when none is.+///+/// **This read fails open, and that is inherited behaviour, not a new+/// decision.** The engine's `load` documented it: "the agent should always be+/// able to use connected integrations productively, even if pref storage is+/// temporarily unavailable". Every failure mode — no driver, no `Graph` family,+/// a backend error, a row that will not deserialise — lands on the same default+/// (`read+write`, no `admin`) that a user who has never opened the toggle gets.+/// Each is logged with its own reason so "defaulted because nothing is stored"+/// stays distinguishable from "defaulted because the store is down".+///+/// The opposite choice would be worse: a failed read is not evidence that the+/// user revoked anything, and refusing every integration on a transient KV+/// error would break a working app to protect a preference it could not see.+/// The **write** below does not fail open — see [`save`].+pub(crate) async fn load_or_default(config: &Config, toolkit: &str) -> UserScopePref {+ let key = kv_key(toolkit);+ if key.is_empty() {+ return UserScopePref::default();+ }++ let binding = match crate::memory::binding::for_config(config) {+ Ok(binding) => binding,+ Err(error) => {+ tracing::warn!(+ toolkit = %key,+ %error,+ "[composio][scopes] memory driver unavailable, using default pref (read+write)"+ );+ return UserScopePref::default();+ }+ };+ let Some(graph) = binding.provider().as_graph() else {+ tracing::warn!(+ toolkit = %key,+ driver = binding.driver_id(),+ "[composio][scopes] driver does not serve Graph, using default pref (read+write)"+ );+ return UserScopePref::default();+ };++ match graph.kv_get(Some(KV_NAMESPACE), &key).await {+ Ok(Some(record)) => match serde_json::from_value::<UserScopePref>(record.value) {+ Ok(pref) => {+ tracing::debug!(+ toolkit = %key,+ read = pref.read,+ write = pref.write,+ admin = pref.admin,+ "[composio][scopes] pref loaded"+ );+ pref+ }+ Err(error) => {+ tracing::warn!(+ toolkit = %key,+ %error,+ "[composio][scopes] pref deserialize failed, falling back to default"+ );+ UserScopePref::default()+ }+ },+ Ok(None) => {+ tracing::debug!(+ toolkit = %key,+ "[composio][scopes] no pref stored, using default (read+write)"+ );+ UserScopePref::default()+ }+ Err(error) => {+ tracing::warn!(+ toolkit = %key,+ %error,+ "[composio][scopes] kv_get failed, falling back to default"+ );+ UserScopePref::default()+ }+ }+}+/// Persist the scope pref for `toolkit`.////// **This one fails closed.** A write that reported success without storing