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): remove unused retry_after_failure function and expand memory tool tests
Steven Enamakel801cc6886ffd
diff --git a/crates/openhuman-core/src/flows/memory_tools_tests.rs b/crates/openhuman-core/src/flows/memory_tools_tests.rsindex 71fa8b6006..60fca55af3 100644--- a/crates/openhuman-core/src/flows/memory_tools_tests.rs+++ b/crates/openhuman-core/src/flows/memory_tools_tests.rs@@ -1,17 +1,123 @@use super::*;+use crate::memory::types::ItemsListParams;+use tempfile::TempDir;+use tinymemory::conformance::ReferenceEngine;-// ── flow_namespace / FLOW_MEMORY_NAMESPACE_PREFIX ───────────────-// (relocated from `flows::mod` — see that module's re-export comment)+/// A config whose workspace is bound to a fresh in-memory reference engine.+fn engine_config() -> (TempDir, Config) {+ let tmp = TempDir::new().unwrap();+ let mut config = Config::default();+ config.workspace_dir = tmp.path().to_path_buf();+ crate::memory::engine::install_test_engine(+ &config.workspace_dir,+ Arc::new(ReferenceEngine::new()),+ );+ (tmp, config)+}++/// A config with no engine bound (memory off).+fn off_config() -> (TempDir, Config) {+ let tmp = TempDir::new().unwrap();+ let mut config = Config::default();+ config.workspace_dir = tmp.path().to_path_buf();+ config.memory.engine = String::new();+ (tmp, config)+}++async fn list(config: &Config, filter: MetaFilter) -> Vec<tinymemory::Hit> {+ crate::memory::ops::items_list(+ config,+ ItemsListParams {+ filter: Some(filter),+ limit: Some(100),+ cursor: None,+ },+ )+ .await+ .unwrap()+ .items+}++// ── tags ────────────────────────────────────────────────────────#[test]-fn flow_namespace_uses_the_shared_root_prefix() {- assert_eq!(flow_namespace("abc-123"), "flow_abc-123");- assert!(flow_namespace("abc-123").starts_with(FLOW_MEMORY_NAMESPACE_PREFIX));+fn flow_tag_is_distinct_per_flow() {+ assert_eq!(flow_tag("abc-123"), "flow:abc-123");+ assert_ne!(flow_tag("a"), flow_tag("b"));}#[test]-fn flow_namespace_is_distinct_per_flow() {- assert_ne!(flow_namespace("a"), flow_namespace("b"));+fn flow_meta_carries_flow_and_cross_flow_tags() {+ let meta = flow_meta("f1", &["extra".to_string()]);+ assert_eq!(meta.tags, vec!["flow:f1", FLOWS_TAG, "extra"]);+ assert_eq!(meta.source.kind, SourceKind::Agent);+ assert_eq!(meta.source.id.as_deref(), Some("flow:f1"));+}++#[test]+fn flow_key_round_trips_through_tags() {+ let meta = flow_meta("f1", &[flow_key_tag("f1", "sent:42")]);+ assert_eq!(flow_key_of(&meta), Some("sent:42"));+ assert_eq!(flow_key_of(&flow_meta("f1", &[])), None);+}++#[test]+fn learning_kind_maps_categories() {+ assert_eq!(learning_kind_for(None), LearningKind::Fact);+ assert_eq!(learning_kind_for(Some("core")), LearningKind::Fact);+ assert_eq!(learning_kind_for(Some("Preference")), LearningKind::Preference);+ assert_eq!(learning_kind_for(Some("daily")), LearningKind::Other);+}++// ── keyed writes / forget ───────────────────────────────────────++#[tokio::test]+async fn remember_keyed_replaces_the_previous_value() {+ let (_tmp, config) = engine_config();+ remember_keyed(&config, "f1", "k", "first", LearningKind::Fact)+ .await+ .unwrap();+ remember_keyed(&config, "f1", "k", "second", LearningKind::Fact)+ .await+ .unwrap();+ let items = list(&config, flow_filter("f1")).await;+ assert_eq!(items.len(), 1);+ assert!(items[0].text.contains("second"));+ assert_eq!(flow_key_of(&items[0].meta), Some("k"));+}++#[tokio::test]+async fn flow_filters_isolate_flows_and_cross_flow_sees_all() {+ let (_tmp, config) = engine_config();+ remember_keyed(&config, "f1", "k", "one", LearningKind::Fact)+ .await+ .unwrap();+ remember_keyed(&config, "f2", "k", "two", LearningKind::Fact)+ .await+ .unwrap();+ assert_eq!(list(&config, flow_filter("f1")).await.len(), 1);+ assert_eq!(list(&config, cross_flow_filter()).await.len(), 2);+ assert_eq!(forget_matching(&config, flow_filter("f1")).await.unwrap(), 1);+ assert_eq!(list(&config, cross_flow_filter()).await.len(), 1);+}++#[tokio::test]+async fn forget_matching_refuses_an_empty_filter() {+ let (_tmp, config) = engine_config();+ let err = forget_matching(&config, MetaFilter::default())+ .await+ .unwrap_err();+ assert_eq!(err.code(), crate::memory::error::INVALID_REQUEST);+}++#[tokio::test]+async fn memory_off_forgets_nothing_and_refuses_writes() {+ let (_tmp, config) = off_config();+ assert_eq!(forget_matching(&config, flow_filter("f1")).await.unwrap(), 0);+ let err = remember_keyed(&config, "f1", "k", "v", LearningKind::Fact)+ .await+ .unwrap_err();+ assert_eq!(err.code(), crate::memory::error::MEMORY_OFF);}// ── FlowMemoryRecallTool ────────────────────────────────────────@@ -25,6 +131,21 @@ fn recall_name_and_schema() {assert!(schema["properties"]["flow_id"].is_object());assert!(schema["properties"]["scope"].is_object());}++#[tokio::test]+async fn recall_rejects_unknown_scope() {+ let result = FlowMemoryRecallTool::new()+ .execute(json!({"query": "q", "flow_id": "f1", "scope": "user"}))+ .await+ .unwrap();+ assert!(result.is_error);+}++#[test]+fn render_recall_reports_no_citations() {+ assert!(render_recall("x", &[]).contains("No flow memories"));+}+// ── FlowMemoryRememberTool ──────────────────────────────────────#[test]@@ -35,8 +156,19 @@ fn remember_name_and_schema() {assert!(schema["properties"]["flow_id"].is_object());assert!(schema["properties"]["key"].is_object());assert!(schema["properties"]["content"].is_object());- // No `namespace` parameter exists — the security invariant that a- // flow can never target another namespace.+ // No `namespace`/`tags` parameter: a flow can never target another+ // flow's memory.assert!(schema["properties"]["namespace"].is_null());+ assert!(schema["properties"]["tags"].is_null());assert_eq!(tool.permission_level(), PermissionLevel::Write);}++#[tokio::test]+async fn remember_outside_a_workflow_run_is_refused() {+ let tool = FlowMemoryRememberTool::new(Arc::new(SecurityPolicy::default()));+ let result = tool+ .execute(json!({"flow_id": "f1", "key": "k", "content": "v"}))+ .await+ .unwrap();+ assert!(result.is_error);+}diff --git a/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs b/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rsindex 92d701d2d6..275ead1b10 100644--- a/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs@@ -1,5 +1,5 @@-//! When a connector sync pass has failed, and how long a Sources-row run waits-//! before asking again (openhuman#6255).+//! When a connector sync pass has failed, and how long a `composio_sync` run+//! waits before asking again (openhuman#6255).//!//! The connector module reports a page it could not read as//! [`SyncStage::Failed`]: it keeps the pages it had already read, puts the@@ -19,7 +19,7 @@ use tinyconnectors_bus::records::{ConnectorSyncResponse, SyncStage};/// the source row and written to the log, so it is cut rather than kept whole.pub(crate) const MAX_REASON_CHARS: usize = 300;-/// Attempts a Sources-row run makes at a pass the connector keeps failing:+/// Attempts a `composio_sync` run makes at a pass the connector keeps failing:/// the first try and two retries.pub(crate) const MAX_FAILED_ATTEMPTS: u32 = 3;@@ -106,19 +106,6 @@ pub(crate) fn retry_delay(failed_attempts: u32) -> Option<Duration> {Some(Duration::from_secs(5 * 2_u64.pow(failed_attempts - 1)))}-/// [`retry_delay`], unless the failed pass left no room under the run's item-/// cap.-///-/// A failed pass still writes what it read, and that can fill the cap. Waiting-/// then only reaches the loop's cap check, which ends the run as completed and-/// loses the failure; ending it here reports the failure with what was written.-pub(crate) fn retry_after_failure(failed_attempts: u32, cap_left: bool) -> Option<Duration> {- if !cap_left {- return None;- }- retry_delay(failed_attempts)-}-#[cfg(test)]#[path = "pass_failure_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rsindex a7eddc6a48..06abcb836d 100644--- a/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs@@ -106,17 +106,6 @@ fn a_reason_is_cut_on_a_character_boundary() {assert!(reason.starts_with('é') && reason.ends_with('…'));}-#[test]-fn a_failed_pass_that_filled_the_item_cap_is_not_retried() {- assert_eq!(retry_after_failure(1, true), Some(Duration::from_secs(5)));- assert_eq!(- retry_after_failure(1, false),- None,- "no room left: the run ends failed rather than completing at the cap"- );- assert_eq!(retry_after_failure(MAX_FAILED_ATTEMPTS, true), None);-}-#[test]fn the_retry_schedule_waits_five_then_ten_seconds_then_gives_up() {assert_eq!(retry_delay(0), None, "nothing has failed yet");