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: update storage and lease tests for new APIs
Steven Enamakel588b8268d2ff
diff --git a/crates/openhuman-core/src/inbound/settings_tests.rs b/crates/openhuman-core/src/inbound/settings_tests.rsindex 3130af4880..d34a40f3df 100644--- a/crates/openhuman-core/src/inbound/settings_tests.rs+++ b/crates/openhuman-core/src/inbound/settings_tests.rs@@ -113,7 +113,7 @@ async fn the_module_config_is_what_the_storage_grant_declares() {assert_eq!(blob["queues"]["queues"][0]["max_attempts"], 4);assert_eq!(blob["pipeline"]["version"], 1);let grant = queue_grant().unwrap();- assert_eq!(grant.manifest.queues[0].max_attempts, 4);+ assert_eq!(grant.manifest.get("teq.ingress").unwrap().spec().max_attempts, 4);assert_eq!(grant.backend, QueueConfig::Storage);assert_eq!(current().manifest, grant.manifest);diff --git a/crates/openhuman-core/src/modules/storage_grants_queues_tests.rs b/crates/openhuman-core/src/modules/storage_grants_queues_tests.rsindex 364c18df6d..7ef8e6e513 100644--- a/crates/openhuman-core/src/modules/storage_grants_queues_tests.rs+++ b/crates/openhuman-core/src/modules/storage_grants_queues_tests.rs@@ -191,8 +191,9 @@ fn a_read_only_grant_may_inspect_queues_but_not_lease_or_enqueue() {#[test]fn validate_refuses_an_invalid_manifest_and_storage_layer_collections() {assert!(with_queues().validate().is_ok());- let mut broken = (*manifest()).clone();- broken.version = 99;+ let mut broken = serde_json::to_value(manifest()).unwrap();+ broken["version"] = json!(99);+ let broken: QueueManifest = serde_json::from_value(broken).unwrap();let bad_manifest = StorageGrant {queues: Some(Arc::new(broken)),queue_backend: None,diff --git a/crates/openhuman-core/src/modules/storage_host_queues_tests.rs b/crates/openhuman-core/src/modules/storage_host_queues_tests.rsindex 6bd6a69c8c..0eb5dfd2bf 100644--- a/crates/openhuman-core/src/modules/storage_host_queues_tests.rs+++ b/crates/openhuman-core/src/modules/storage_host_queues_tests.rs@@ -80,13 +80,11 @@ async fn peers() -> Peers {}}-async fn queues_of(connection: &Connection, module_id: &str) -> Arc<dyn QueueStore> {+async fn queues_of(connection: &Connection, _module_id: &str) -> Arc<dyn QueueStore> {let storage = tinystoragedrivers_busproxy::connect_storage(connection.clone()).await.expect("every module connects, with or without queues");- let scope = module_scope(None, module_id).unwrap();- let scoped = storage.for_scope(&scope).unwrap();- Arc::clone(scoped.queues())+ Arc::clone(storage.queues())}#[tokio::test(flavor = "multi_thread", worker_threads = 2)]diff --git a/crates/openhuman-core/src/modules/storage_host_stream_tests.rs b/crates/openhuman-core/src/modules/storage_host_stream_tests.rsindex 6b821d25a5..82e894d0f7 100644--- a/crates/openhuman-core/src/modules/storage_host_stream_tests.rs+++ b/crates/openhuman-core/src/modules/storage_host_stream_tests.rs@@ -1,9 +1,11 @@//! Streamed blobs and watch signals, decided by the host without a bus.use super::*;+use bytes::Bytes;+use futures_util::{StreamExt, stream};fn blob_body(bytes: Vec<u8>) -> BlobReader {- Box::pin(std::io::Cursor::new(bytes))+ Box::pin(stream::iter([Ok(Bytes::from(bytes))]))}fn head(key: &str, len: u64) -> PutBlobStreamRequest {@@ -35,9 +37,9 @@ async fn a_streamed_blob_is_stored_in_the_callers_scope_and_read_back() {.expect("the blob is there");assert_eq!(meta.meta.len, bytes.len() as u64);let mut read = Vec::new();- tokio::io::AsyncReadExt::read_to_end(&mut reader, &mut read)- .await- .unwrap();+ while let Some(chunk) = reader.next().await {+ read.extend_from_slice(&chunk.unwrap());+ }assert_eq!(read, bytes);// Another module never sees it, even by the same key.let other = rigdiff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rsindex 1880e1ee9f..f74898ac75 100644--- a/crates/openhuman-core/src/profiles/lease_tests.rs+++ b/crates/openhuman-core/src/profiles/lease_tests.rs@@ -188,7 +188,7 @@ async fn renewal_keeps_the_lease_and_a_lost_lease_fences_the_profile() {// Another node takes the profile over once the lease has (by its clock)// run out.let thief = crate::storage::lease::DocumentLeases::cluster(- backend.as_ref(),+ backend.backend.as_ref(),"node-b",None,Duration::from_secs(TTL_SECS),diff --git a/crates/openhuman-core/src/storage/blob_sweep_tests.rs b/crates/openhuman-core/src/storage/blob_sweep_tests.rsindex 551c36e9ad..711d30333c 100644--- a/crates/openhuman-core/src/storage/blob_sweep_tests.rs+++ b/crates/openhuman-core/src/storage/blob_sweep_tests.rs@@ -1,7 +1,8 @@use super::*;use std::{ops::Range, sync::Arc, time::Duration};use tinystoragedrivers_api::{BlobStore, Storage, StorageBackend};-use tinystoragedrivers_types::{Blob, BlobMeta, Capabilities, Result, Scope};+use tinystoragedrivers_types::{Blob, BlobMeta, Capabilities, Result};+use crate::storage::Scope;/// The TSD testkit memory engine uses its real clock; tests wait on the/// backend's observable expiry instead of mutating a process-global clock.@@ -234,7 +235,7 @@ async fn a_hung_scope_sweep_times_out_and_counts_as_zero() {async fn a_hung_profile_listing_times_out_instead_of_stalling() {let hung = bounded_listing(Duration::from_millis(20),- std::future::pending::<Result<Vec<String>, String>>(),+ std::future::pending::<std::result::Result<Vec<String>, String>>(),).await;assert!(hung.is_none());diff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rsindex 64226b4979..1447478e22 100644--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs@@ -35,6 +35,19 @@ fn backend() -> TestBackend {TestBackend(sqlite_backend().unwrap())}+fn session_provider(backend: &Arc<dyn StorageBackend>) -> DriverSessionStores {+ let backend = Arc::clone(backend);+ let factory: tinyagents_session::port::AgentStorageFactory = Arc::new(move |agent_id| {+ let scope = crate::storage::scope_for_agent(agent_id);+ let storage = backend.for_scope(&scope)?;+ Ok(tinyagents_storage_kit::ScopedStorage::new(+ storage,+ (*scope).clone(),+ ))+ });+ DriverSessionStores::new(factory).unwrap()+}+#[test]fn host_jsonl_reader_preserves_meta_usage_typed_rows_and_tool_state() {use tinyagents_session::transcript::DisplayRecord;@@ -290,7 +303,7 @@ fn a_classic_workspace_moves_into_the_backend_and_its_files_are_untouched() {let outcome = reports.into_iter().next().unwrap().outcome.unwrap();assert!(matches!(outcome, Outcome::Imported { .. }), "{outcome:?}");- let provider = DriverSessionStores::new(Arc::clone(&backend), Scope::local()).unwrap();+ let provider = session_provider(&backend);// The transcript landed in the orchestrator's scope, where its session// resumes it.let orchestrator = provider.try_for_agent("orchestrator").unwrap();@@ -349,7 +362,7 @@ fn a_transcript_naming_an_unknown_agent_lands_in_the_default_agent() {run_with(&backend, &config).remove(0).outcome.unwrap();- let provider = DriverSessionStores::new(Arc::clone(&backend), Scope::local()).unwrap();+ let provider = session_provider(&backend);let default = provider.try_for_agent(DEFAULT_AGENT).unwrap();assert!(default.transcripts.root_for_thread("thread-9").is_some());}@@ -386,6 +399,7 @@ fn database_import_totals_source_families_not_derived_fts_rows() {members: counts(9, 8),tasks: counts(10, 9),tool_effects: counts(11, 10),+ entries: ImportCounts::default(),fts_rows: 1_000,};diff --git a/crates/openhuman-core/src/storage/lease_documents_tests.rs b/crates/openhuman-core/src/storage/lease_documents_tests.rsindex e59da2eb46..1e2db7ffb8 100644--- a/crates/openhuman-core/src/storage/lease_documents_tests.rs+++ b/crates/openhuman-core/src/storage/lease_documents_tests.rs@@ -116,7 +116,7 @@ async fn bad_keys_and_corrupt_records_are_storage_errors() {.documents().put(LEASE_COLLECTION,- tinystoragedrivers_types::Key::of([LEASE_OWNER, "k"])+ tinystoragedrivers_types::Key::new(format!("{LEASE_OWNER}/k")).unwrap().as_str(),serde_json::json!({ "holder": 7 }),@@ -169,7 +169,7 @@ async fn another_instances_grant_cannot_renew_or_release() {#[tokio::test]async fn sub_millisecond_ttl_does_not_expire_at_acquisition() {let storage = crate::storage::test_support::sqlite_backend().unwrap();- let a = DocumentLeases::cluster(&storage, "a", None, Duration::ZERO).unwrap();+ let a = DocumentLeases::cluster(storage.backend.as_ref(), "a", None, Duration::ZERO).unwrap();let b = node(&storage, "b");let grant = a.acquire("k", 5).await.unwrap();assert!(grant.expires_at_ms > 5);