Skip to content

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

refactor(flows): collapse owner map initializer onto one line

Steven Enamakela5c78f61b286
diff --git a/crates/openhuman-core/src/flows/bus/owner.rs b/crates/openhuman-core/src/flows/bus/owner.rs
index abc6c2d7bd..702a3bc228 100644
--- a/crates/openhuman-core/src/flows/bus/owner.rs
+++ b/crates/openhuman-core/src/flows/bus/owner.rs
@@ -13,8 +13,7 @@ use std::sync::{LazyLock, Mutex};
use crate::config::Config;
/// Flows whose owner this process has resolved (`None` = `local`).
-static OWNERS: LazyLock<Mutex<HashMap<String, Option<String>>>> =
- LazyLock::new(Default::default);
+static OWNERS: LazyLock<Mutex<HashMap<String, Option<String>>>> = LazyLock::new(Default::default);
/// The agent `flow_id` belongs to: `None` for `local`, or when no scope has
/// the flow (the handler then reports the flow as unknown, as before).
diff --git a/crates/openhuman-core/src/flows/bus/owner_tests.rs b/crates/openhuman-core/src/flows/bus/owner_tests.rs
new file mode 100644
index 0000000000..91238d9b59
--- /dev/null
+++ b/crates/openhuman-core/src/flows/bus/owner_tests.rs
@@ -0,0 +1,25 @@
+use super::*;
+
+#[tokio::test]
+async fn without_a_backend_every_flow_is_local() {
+ // The lib test binary never installs a backend into the process slot.
+ if crate::storage::installed().is_some() {
+ return;
+ }
+ let dir = tempfile::tempdir().unwrap();
+ let config = Config {
+ workspace_dir: dir.path().to_path_buf(),
+ ..Config::default()
+ };
+ assert_eq!(flow_owner(&config, "any-flow").await, None);
+}
+
+#[test]
+fn a_forgotten_owner_is_resolved_again() {
+ OWNERS
+ .lock()
+ .unwrap()
+ .insert("owner-test-flow".to_string(), Some("agent-1".to_string()));
+ forget("owner-test-flow");
+ assert!(!OWNERS.lock().unwrap().contains_key("owner-test-flow"));
+}