Skip to content

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

test(flows): cover owner cache invalidation when a flow is removed

Steven Enamakele7fd961d8127
diff --git a/crates/openhuman-core/src/flows/bus/owner_tests.rs b/crates/openhuman-core/src/flows/bus/owner_tests.rs
index 91238d9b59..0cdc426de8 100644
--- a/crates/openhuman-core/src/flows/bus/owner_tests.rs
+++ b/crates/openhuman-core/src/flows/bus/owner_tests.rs
@@ -23,3 +23,45 @@ fn a_forgotten_owner_is_resolved_again() {
forget("owner-test-flow");
assert!(!OWNERS.lock().unwrap().contains_key("owner-test-flow"));
}
+
+fn local_flow(id: &str) -> crate::flows::Flow {
+ crate::flows::Flow {
+ id: id.to_string(),
+ name: id.to_string(),
+ enabled: true,
+ graph: tinyflows::model::WorkflowGraph::default(),
+ created_at: "2026-01-01T00:00:00Z".to_string(),
+ updated_at: "2026-01-01T00:00:00Z".to_string(),
+ last_run_at: None,
+ last_status: None,
+ require_approval: false,
+ }
+}
+
+#[tokio::test]
+async fn a_cached_owner_is_dropped_once_its_scope_loses_the_flow() {
+ if crate::storage::installed().is_some() {
+ return;
+ }
+ let dir = tempfile::tempdir().unwrap();
+ let config = Config {
+ workspace_dir: dir.path().to_path_buf(),
+ ..Config::default()
+ };
+ crate::flows::store::upsert_flow(&config, &local_flow("owner-test-revalidate")).unwrap();
+
+ // Found in `local`, and remembered there.
+ assert_eq!(resolve(&config, "owner-test-revalidate").await, None);
+ assert_eq!(
+ OWNERS.lock().unwrap().get("owner-test-revalidate"),
+ Some(&None)
+ );
+ // Still there: the cached answer stands.
+ assert_eq!(resolve(&config, "owner-test-revalidate").await, None);
+ assert!(OWNERS.lock().unwrap().contains_key("owner-test-revalidate"));
+
+ // Gone: the cache entry is dropped and nothing is found.
+ crate::flows::store::remove_flow(&config, "owner-test-revalidate").unwrap();
+ assert_eq!(resolve(&config, "owner-test-revalidate").await, None);
+ assert!(!OWNERS.lock().unwrap().contains_key("owner-test-revalidate"));
+}