Skip to content

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

chore: files changed crates/openhuman-core/src/flows/bus/owner_tests.rs,crates/openhuman-core/src/st

Steven Enamakelea4868054f62
diff --git a/crates/openhuman-core/src/flows/bus/owner_tests.rs b/crates/openhuman-core/src/flows/bus/owner_tests.rs
index 0cdc426de8..3a880fb50c 100644
--- a/crates/openhuman-core/src/flows/bus/owner_tests.rs
+++ b/crates/openhuman-core/src/flows/bus/owner_tests.rs
@@ -11,7 +11,7 @@ async fn without_a_backend_every_flow_is_local() {
workspace_dir: dir.path().to_path_buf(),
..Config::default()
};
- assert_eq!(flow_owner(&config, "any-flow").await, None);
+ assert_eq!(flow_owner(&config, "any-flow").await, Ok(None));
}
#[test]
@@ -51,17 +51,17 @@ async fn a_cached_owner_is_dropped_once_its_scope_loses_the_flow() {
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!(resolve(&config, "owner-test-revalidate").await, Ok(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_eq!(resolve(&config, "owner-test-revalidate").await, Ok(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_eq!(resolve(&config, "owner-test-revalidate").await, Ok(None));
assert!(!OWNERS.lock().unwrap().contains_key("owner-test-revalidate"));
}
diff --git a/crates/openhuman-core/src/storage/agents_tests.rs b/crates/openhuman-core/src/storage/agents_tests.rs
index 801eba9b58..eb593ee20e 100644
--- a/crates/openhuman-core/src/storage/agents_tests.rs
+++ b/crates/openhuman-core/src/storage/agents_tests.rs
@@ -139,17 +139,23 @@ async fn without_a_backend_only_the_local_scope_runs() {
assert_eq!(runs[0].0, None);
assert!(for_each_agent("test", || async {}).await.is_empty());
assert_eq!(
- find_owner("test", || async { false }).await,
- None,
+ find_owner("test", || async { Ok(false) }).await,
+ Ok(None),
"nothing anywhere"
);
- assert_eq!(find_owner("test", || async { true }).await, Some(None));
+ assert_eq!(find_owner("test", || async { Ok(true) }).await, Ok(Some(None)));
+ assert!(
+ find_owner("test", || async { Err("down".to_string()) })
+ .await
+ .is_err(),
+ "a failed lookup with no match fails closed"
+ );
let inside = within_agent(Some("agents-test-unvisited"), async {
CoreContext::current().and_then(|c| c.session_agent().map(str::to_string))
})
.await;
- assert_eq!(inside.as_deref(), Some("agents-test-unvisited"));
- assert_eq!(within_agent(None, async { 7 }).await, 7);
+ assert_eq!(inside.flatten().as_deref(), Some("agents-test-unvisited"));
+ assert_eq!(within_agent(None, async { 7 }).await, Some(7));
AgentContextRegistry::deregister("agents-test-unvisited", &agent);
}
@@ -163,3 +169,39 @@ async fn without_a_backend_the_live_pass_runs_only_local() {
assert_eq!(runs, vec![(None, 1)]);
AgentContextRegistry::deregister("agents-test-live-pass", &agent);
}
+
+#[test]
+fn the_first_scope_reporting_the_record_owns_it() {
+ let found = decide(vec![
+ (None, Ok(false)),
+ (Some("a".into()), Err("down".into())),
+ (Some("b".into()), Ok(true)),
+ ]);
+ assert_eq!(found, Ok(Some(Some("b".to_string()))));
+ let failed = decide(vec![(None, Ok(false)), (Some("a".into()), Err("down".into()))]);
+ let failed = failed.unwrap_err();
+ assert_eq!(failed.agent.as_deref(), Some("a"));
+ assert_eq!(failed.to_string(), "lookup failed in scope a: down");
+ assert_eq!(decide(Vec::new()), Ok(None));
+}
+
+#[tokio::test]
+async fn the_local_pass_runs_outside_the_callers_agent() {
+ if installed().is_some() {
+ return;
+ }
+ let agent = live_agent("agents-test-caller");
+ let seen = CoreContext::scope(Arc::clone(&agent), async {
+ for_each_scope("test", || async {
+ CoreContext::current().and_then(|c| c.session_agent().map(str::to_string))
+ })
+ .await
+ })
+ .await;
+ // Without a default context the caller's own context stays; with one,
+ // the local pass leaves the agent.
+ if CoreContext::default_context().is_some() {
+ assert_eq!(seen, vec![(None, None)]);
+ }
+ AgentContextRegistry::deregister("agents-test-caller", &agent);
+}