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
test: add document store tests for subagents, sessions, and composio
Steven Enamakel8034b83ab599
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents_tests.rsindex 1e42c5b2fb..2b4512c2e6 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents_tests.rs@@ -57,3 +57,98 @@ fn scopes_do_not_share_a_ledger() {let alice_again = DocumentTaskStore::open(repo_in(&storage, "alice")).unwrap();assert!(alice_again.get(&TaskId::from("t1")).is_some());}++fn id(raw: &str) -> TaskId {+ TaskId::from(raw)+}++#[test]+fn every_transition_is_written_through() {+ let storage = MemoryStorage::new();+ let store = DocumentTaskStore::open(repo_in(&storage, "local")).unwrap();+ for name in ["a", "b", "c", "d", "e", "f"] {+ store.insert(spec(name)).unwrap();+ }+ store.mark_awaiting(&id("a")).unwrap();+ store+ .mark_awaiting_with_question(&id("b"), "which one?".into())+ .unwrap();+ store.mark_running(&id("c")).unwrap();+ store+ .complete(&id("c"), OrchestrationTaskResult::text("done"))+ .unwrap();+ store.timeout(&id("d"), "too slow".into()).unwrap();+ store.request_cancel(&id("e")).unwrap();+ store.mark_cancelled(&id("e")).unwrap();+ store.kill(&id("f")).unwrap();+ store.set_timeout_ms(&id("a"), 5_000).unwrap();++ let reopened = DocumentTaskStore::open(repo_in(&storage, "local")).unwrap();+ let status = |name: &str| reopened.get(&id(name)).unwrap().status;+ assert_eq!(status("a"), OrchestrationTaskStatus::Awaiting);+ assert_eq!(status("b"), OrchestrationTaskStatus::Awaiting);+ assert_eq!(+ reopened.get(&id("b")).unwrap().error.as_deref(),+ Some("which one?")+ );+ assert_eq!(status("c"), OrchestrationTaskStatus::Completed);+ assert_eq!(status("d"), OrchestrationTaskStatus::TimedOut);+ assert_eq!(status("e"), OrchestrationTaskStatus::Cancelled);+ assert_eq!(status("f"), OrchestrationTaskStatus::Abandoned);+ assert_eq!(reopened.get(&id("a")).unwrap().spec.timeout_ms, Some(5_000));+}++#[test]+fn an_invalid_transition_is_rejected_and_not_written() {+ let storage = MemoryStorage::new();+ let store = DocumentTaskStore::open(repo_in(&storage, "local")).unwrap();+ store.insert(spec("a")).unwrap();+ assert!(store.mark_cancelled(&id("a")).is_err());+ assert!(store.mark_running(&id("missing")).is_err());+ assert_eq!(store.history(&id("a")).len(), 1);+}++#[test]+fn a_malformed_document_is_skipped_on_open() {+ let storage = MemoryStorage::new();+ let repo = repo_in(&storage, "local");+ repo.run(|docs| async move {+ docs.put(TASKS, "bad", serde_json::json!({ "record": 1 }), Precondition::None)+ .await+ .map(|_| ())+ })+ .unwrap();+ let store = DocumentTaskStore::open(repo.clone()).unwrap();+ assert!(store.list(OrchestrationTaskFilter::default()).is_empty());+ let boxed = open_or_memory(repo);+ assert!(boxed.list(OrchestrationTaskFilter::default()).is_empty());+}++#[test]+fn the_ledger_dispatches_to_documents_when_a_backend_is_pinned() {+ let storage = MemoryStorage::new();+ let workspace = tempfile::tempdir().unwrap();+ let repo = repo_in(&storage, "local");+ with_override(repo.clone(), || {+ let store = super::super::task_ledger::task_store_for_workspace(workspace.path());+ store.insert(spec("pinned")).unwrap();+ });+ // The record is in the documents, and no JSONL file was made.+ let reopened = DocumentTaskStore::open(repo).unwrap();+ assert!(reopened.get(&id("pinned")).is_some());+ assert!(!workspace+ .path()+ .join(".openhuman/orchestration_tasks.jsonl")+ .exists());+}++#[test]+fn the_ledger_uses_the_jsonl_file_with_no_backend() {+ let workspace = tempfile::tempdir().unwrap();+ let store = super::super::task_ledger::task_store_for_workspace(workspace.path());+ store.insert(spec("plain")).unwrap();+ assert!(workspace+ .path()+ .join(".openhuman/orchestration_tasks.jsonl")+ .exists());+}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.rsindex 1c33776a08..81f5a1aea4 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@@ -92,3 +92,18 @@ fn sessions_come_back_in_creation_order() {.collect();assert_eq!(ids, ["z", "a"]);}++#[test]+fn the_store_dispatches_to_documents_when_a_backend_is_pinned() {+ let storage = MemoryStorage::new();+ let dir = tempfile::tempdir().unwrap();+ let store = SubagentSessionStore::new(dir.path().to_path_buf());+ let docs = docs_in(&storage, "local");+ with_override(docs.clone(), || {+ assert!(store.load().unwrap().is_empty());+ store.save(&[session("a")]).unwrap();+ assert_eq!(store.load().unwrap().len(), 1);+ });+ assert_eq!(docs.load().unwrap().len(), 1);+ assert!(!dir.path().join(".openhuman/subagent_sessions.json").exists());+}diff --git a/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs b/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rsindex 3d1503293d..abdbf42b38 100644--- a/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/file_store_documents_tests.rs@@ -46,6 +46,24 @@ fn scopes_do_not_see_each_others_state() {assert!(bob.is_empty());}+#[tokio::test]+async fn the_file_store_dispatches_to_documents_when_a_backend_is_pinned() {+ let storage = MemoryStorage::new();+ let docs = docs_in(&storage, "local");+ let dir = tempfile::tempdir().unwrap();+ let file = dir.path().join("composio_identities.json");+ let mut value = BTreeMap::new();+ value.insert("gmail".to_string(), 7u32);+ with_override(docs.clone(), || ());+ // Pin on this thread for the awaits below (a current-thread runtime).+ super::TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = Some(docs.clone()));+ super::super::file_store::save(&file, &value).await.unwrap();+ let loaded: BTreeMap<String, u32> = super::super::file_store::load(&file).await.unwrap();+ super::TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = None);+ assert_eq!(loaded, value);+ assert!(!file.exists());+}+#[tokio::test]async fn the_file_path_still_works_with_no_backend() {let dir = tempfile::tempdir().unwrap();