Skip to content

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

style: reformat subagent session tests and imports

Steven Enamakel5f3d60e6944d
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs
index eea15c284e..ed9c81e07f 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs
@@ -106,43 +106,51 @@ fn stale_completion_cannot_overwrite_reused_or_closed_session() {
.unwrap();
assert_eq!(first.subagent_session_id, second.subagent_session_id);
- assert!(mark_finished(
- &store,
- &second.subagent_session_id,
- "first-task",
- &SubagentRunStatus::Completed,
- vec![TranscriptMessage::user("stale")],
- )
- .is_err());
+ assert!(
+ mark_finished(
+ &store,
+ &second.subagent_session_id,
+ "first-task",
+ &SubagentRunStatus::Completed,
+ vec![TranscriptMessage::user("stale")],
+ )
+ .is_err()
+ );
let current = store.load().unwrap().remove(0);
assert_eq!(current.current_task_id.as_deref(), Some("second-task"));
assert_eq!(current.status, DurableSubagentStatus::Running);
assert!(current.latest_history.is_none());
- assert!(mark_failed(
- &store,
- &second.subagent_session_id,
- "first-task",
- "stale failure".into(),
- )
- .is_err());
+ assert!(
+ mark_failed(
+ &store,
+ &second.subagent_session_id,
+ "first-task",
+ "stale failure".into(),
+ )
+ .is_err()
+ );
assert!(store.load().unwrap()[0].latest_error.is_none());
close(&store, &second.subagent_session_id).unwrap();
- assert!(mark_finished(
- &store,
- &second.subagent_session_id,
- "second-task",
- &SubagentRunStatus::Completed,
- vec![TranscriptMessage::user("late after close")],
- )
- .is_err());
- assert!(mark_failed(
- &store,
- &second.subagent_session_id,
- "second-task",
- "late failure".into(),
- )
- .is_err());
+ assert!(
+ mark_finished(
+ &store,
+ &second.subagent_session_id,
+ "second-task",
+ &SubagentRunStatus::Completed,
+ vec![TranscriptMessage::user("late after close")],
+ )
+ .is_err()
+ );
+ assert!(
+ mark_failed(
+ &store,
+ &second.subagent_session_id,
+ "second-task",
+ "late failure".into(),
+ )
+ .is_err()
+ );
let closed = store.load().unwrap().remove(0);
assert_eq!(closed.status, DurableSubagentStatus::Closed);
assert!(closed.latest_history.is_none());
@@ -287,14 +295,16 @@ fn upsert_persists_the_full_lifecycle_key_without_collapsing_to_task_id() {
)
.unwrap();
assert_eq!(resolved, key);
- assert!(resolve_lifecycle_key(
- &store,
- &session.subagent_session_id,
- "another-parent",
- Some("thread-a"),
- dir.path(),
- )
- .is_err());
+ assert!(
+ resolve_lifecycle_key(
+ &store,
+ &session.subagent_session_id,
+ "another-parent",
+ Some("thread-a"),
+ dir.path(),
+ )
+ .is_err()
+ );
}
#[test]
@@ -355,12 +365,14 @@ fn list_for_parent_without_thread_id_does_not_filter_by_thread() {
let all = list_for_parent(&store, "parent-a", None).unwrap();
assert_eq!(all.len(), 2);
- assert!(all
- .iter()
- .any(|session| session.subagent_session_id == first.subagent_session_id));
- assert!(all
- .iter()
- .any(|session| session.subagent_session_id == second.subagent_session_id));
+ assert!(
+ all.iter()
+ .any(|session| session.subagent_session_id == first.subagent_session_id)
+ );
+ assert!(
+ all.iter()
+ .any(|session| session.subagent_session_id == second.subagent_session_id)
+ );
let thread_a = list_for_parent(&store, "parent-a", Some("thread-a")).unwrap();
assert_eq!(thread_a.len(), 1);
@@ -371,14 +383,16 @@ fn list_for_parent_without_thread_id_does_not_filter_by_thread() {
fn missing_session_updates_return_errors() {
let dir = tempfile::tempdir().unwrap();
let store = SubagentSessionStore::new(dir.path().to_path_buf());
- assert!(mark_finished(
- &store,
- "missing",
- "sub-1",
- &SubagentRunStatus::Completed,
- vec![]
- )
- .is_err());
+ assert!(
+ mark_finished(
+ &store,
+ "missing",
+ "sub-1",
+ &SubagentRunStatus::Completed,
+ vec![]
+ )
+ .is_err()
+ );
assert!(mark_failed(&store, "missing", "sub-1", "boom".into()).is_err());
assert!(!close(&store, "missing").unwrap());
}
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
index 445c93f1b8..0cf5de3a91 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
@@ -24,8 +24,8 @@ use serde_json::Value;
use tinystoragedrivers::{CollectionSpec, Precondition, Query, Sort};
use super::types::DurableSubagentSession;
-use crate::storage::documents::Repo;
use crate::storage::DocumentStoreExt;
+use crate::storage::documents::Repo;
const SESSIONS: &str = "subagent_sessions";
/// Holds the marker document that records the one-time legacy file import, in
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
index 6998431619..dcd62a85ba 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
@@ -35,10 +35,12 @@ fn session(id: &str) -> DurableSubagentSession {
#[test]
fn a_missing_list_loads_empty() {
- assert!(docs_in(&MemoryStorage::new(), "local")
- .load()
- .unwrap()
- .is_empty());
+ assert!(
+ docs_in(&MemoryStorage::new(), "local")
+ .load()
+ .unwrap()
+ .is_empty()
+ );
}
#[test]
@@ -81,10 +83,11 @@ fn the_store_uses_the_workspace_default_with_no_backend_installed() {
store.save(&[session("a")]).unwrap();
assert_eq!(store.load().unwrap().len(), 1);
// No JSON file store: the records are in the workspace's own database.
- assert!(!dir
- .path()
- .join(".openhuman/subagent_sessions.json")
- .exists());
+ assert!(
+ !dir.path()
+ .join(".openhuman/subagent_sessions.json")
+ .exists()
+ );
assert!(dir.path().join("storage").exists());
}
@@ -117,10 +120,11 @@ fn the_store_dispatches_to_documents_when_a_backend_is_pinned() {
assert_eq!(store.load().unwrap().len(), 1);
});
assert_eq!(docs.load().unwrap().len(), 1);
- assert!(!dir
- .path()
- .join(".openhuman/subagent_sessions.json")
- .exists());
+ assert!(
+ !dir.path()
+ .join(".openhuman/subagent_sessions.json")
+ .exists()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
index 2ff2a91bf5..e1f0e3ecd6 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/tiny_port_tests.rs
@@ -39,16 +39,18 @@ async fn old_rows_without_checkpoint_identity_remain_readable_without_fabricated
assert_eq!(sessions[0].subagent_session_id, "legacy-session");
assert_eq!(sessions[0].current_task_id.as_deref(), Some("legacy-task"));
assert!(sessions[0].lifecycle_key.is_none());
- assert!(port
- .list_for_parent("foreign-owner", Some("thread"))
- .await
- .unwrap()
- .is_empty());
- assert!(port
- .list_for_parent("owner", Some("other-thread"))
- .await
- .unwrap()
- .is_empty());
+ assert!(
+ port.list_for_parent("foreign-owner", Some("thread"))
+ .await
+ .unwrap()
+ .is_empty()
+ );
+ assert!(
+ port.list_for_parent("owner", Some("other-thread"))
+ .await
+ .unwrap()
+ .is_empty()
+ );
assert_eq!(port.list_for_parent("owner", None).await.unwrap().len(), 1);
assert!(port.get("legacy-session").await.unwrap().is_some());
let other_thread = OpenHumanTinySubagentSessionStore::new(
@@ -95,11 +97,12 @@ async fn unthreaded_port_lists_only_unthreaded_rows() {
let sessions = port.list_for_parent("owner", None).await.unwrap();
assert_eq!(sessions.len(), 1);
assert_eq!(sessions[0].subagent_session_id, "unthreaded-session");
- assert!(port
- .list_for_parent("owner", Some("thread-a"))
- .await
- .unwrap()
- .is_empty());
+ assert!(
+ port.list_for_parent("owner", Some("thread-a"))
+ .await
+ .unwrap()
+ .is_empty()
+ );
}
#[tokio::test]
@@ -204,37 +207,41 @@ async fn upsert_rejects_a_selector_or_lifecycle_key_outside_bound_scope() {
}
};
- assert!(port
- .upsert_running(upsert(
+ assert!(
+ port.upsert_running(upsert(
"foreign",
Some("thread-a"),
key(Some("thread-a"), "task-1")
))
.await
- .is_err());
- assert!(port
- .upsert_running(upsert(
+ .is_err()
+ );
+ assert!(
+ port.upsert_running(upsert(
"owner",
Some("thread-b"),
key(Some("thread-b"), "task-1")
))
.await
- .is_err());
- assert!(port
- .upsert_running(upsert(
+ .is_err()
+ );
+ assert!(
+ port.upsert_running(upsert(
"owner",
Some("thread-a"),
key(Some("thread-b"), "task-1")
))
.await
- .is_err());
- assert!(port
- .upsert_running(upsert(
+ .is_err()
+ );
+ assert!(
+ port.upsert_running(upsert(
"owner",
Some("thread-a"),
key(Some("thread-a"), "other-task")
))
.await
- .is_err());
+ .is_err()
+ );
assert!(store.load().unwrap().is_empty());
}