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(composio): extract cache key helper for testability
Steven Enamakelf67a389d326c
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rsindex 9da559be5c..e18bb8e886 100644--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache.rs@@ -52,15 +52,16 @@ pub(crate) fn composio_cache_test_lock() -> std::sync::MutexGuard<'static, ()> {/// cache key and logs while preventing an old identity's cache hit during a/// credential rotation, even before invalidation completes.pub(crate) fn cache_key(config: &Config) -> String {+ let backend_url = crate::backend::base_url(&config.api_url).unwrap_or_default();+ cache_key_with_backend_url(config, &backend_url)+}++fn cache_key_with_backend_url(config: &Config, backend_url: &str) -> String {let mut digest = Sha256::new();digest.update(b"openhuman-integrations-cache-v2\0");digest.update(config.config_path.to_string_lossy().as_bytes());digest.update(b"\0");- digest.update(- crate::backend::base_url(&config.api_url)- .unwrap_or_default()- .as_bytes(),- );+ digest.update(backend_url.as_bytes());digest.update(b"\0");match crate::security::credentials::session_support::resolve_backend_credential(config) {Ok(credential) => {diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache_tests.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache_tests.rsindex 74f4d15797..31352710fc 100644--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/cache_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/cache_tests.rs@@ -34,3 +34,18 @@ fn cache_key_changes_when_backend_url_changes() {config.api_url = Some("https://other.example".to_string());assert_ne!(first, cache_key(&config));}++#[test]+fn cache_key_changes_when_resolved_fallback_url_changes() {+ let tmp = tempfile::TempDir::new().unwrap();+ let config = Config {+ workspace_dir: tmp.path().join("workspace"),+ action_dir: tmp.path().join("workspace"),+ config_path: tmp.path().join("config.toml"),+ api_url: Some("http://localhost:11434/v1".to_string()),+ ..Config::default()+ };+ let first = cache_key_with_backend_url(&config, "https://backend-one.example");+ let second = cache_key_with_backend_url(&config, "https://backend-two.example");+ assert_ne!(first, second);+}