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(storage): adapt tests to scoped storage backends
Steven Enamakel4163fe93d408
diff --git a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rsindex 4660f73874..5617424c71 100644--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs@@ -68,24 +68,6 @@ async fn artifact_history_refresh_failure_fails_closed_for_cached_files() {.is_err());}-struct PartialThenFail(bool);--impl tokio::io::AsyncRead for PartialThenFail {- fn poll_read(- self: std::pin::Pin<&mut Self>,- _cx: &mut std::task::Context<'_>,- buf: &mut tokio::io::ReadBuf<'_>,- ) -> std::task::Poll<std::io::Result<()>> {- let this = self.get_mut();- if this.0 {- return std::task::Poll::Ready(Err(std::io::Error::other("reader failed")));- }- this.0 = true;- buf.put_slice(b"partial media");- std::task::Poll::Ready(Ok(()))- }-}-/// A minimal stand-in for `GenerateImageTool` / `GenerateVideoTool`: writes/// a fixed number of files under `<action_dir>/generated-media/` and reports/// them in the same `artifacts` array shape the real vendor tools use.@@ -190,7 +172,13 @@ async fn files_a_blob_backed_generated_artifact() {let root = tempfile::tempdir().unwrap();let workspace = root.path().join("workspace");let files_dir = root.path().join("Files");- let blobs = MediaOutput::new(root.path()).blobs.clone();+ let backend = crate::storage::test_support::memory_backend();+ let blobs = backend+ .for_scope(&crate::storage::Scope::local())+ .unwrap()+ .blobs();+ let blobs: Arc<dyn BlobStore> = Arc::from(blobs);+ let _output = MediaOutput::new(root.path(), Arc::clone(&blobs));let wrapped = MediaArtifactTool::new(BlobBackedMediaTool {blobs: Arc::clone(&blobs),@@ -304,11 +292,11 @@ async fn removes_partial_destination_when_blob_read_fails() {let dest = root.path().join("partial.png");std::fs::write(&dest, b"reserved placeholder").unwrap();- let error = copy_blob_to_file(- &mut PartialThenFail(false),- &dest,- "generated-media/fail.png",- )+ let reader: tinyagents_storage_kit::blob::BlobReader = Box::pin(futures_util::stream::iter([+ Ok(bytes::Bytes::from_static(b"partial media")),+ Err(tinystoragedrivers_types::StorageError::backend("reader failed")),+ ]));+ let error = copy_blob_to_file(&mut reader.as_mut(), &dest, "generated-media/fail.png").await.unwrap_err();@@ -320,7 +308,12 @@ async fn removes_partial_destination_when_blob_read_fails() {async fn keeps_source_blob_when_artifact_finalization_fails() {let root = tempfile::tempdir().unwrap();let workspace = root.path().join("workspace");- let blobs = MediaOutput::new(root.path()).blobs.clone();+ let backend = crate::storage::test_support::memory_backend();+ let blobs = backend+ .for_scope(&crate::storage::Scope::local())+ .unwrap()+ .blobs();+ let blobs: Arc<dyn BlobStore> = Arc::from(blobs);let key = "generated-media/finalize-failure.png";blobs.put(key, b"media bytes".to_vec(), Some("image/png"))diff --git a/crates/openhuman-core/src/profiles/storage_schema_tests.rs b/crates/openhuman-core/src/profiles/storage_schema_tests.rsindex 49e55225ca..4095f1e7a5 100644--- a/crates/openhuman-core/src/profiles/storage_schema_tests.rs+++ b/crates/openhuman-core/src/profiles/storage_schema_tests.rs@@ -104,7 +104,7 @@ async fn migrate_cluster_moves_v1_leases_into_tsd_leases_and_keeps_their_epoch()// The host's lease store reads the moved records: alice is still held,// bob's released record is taken over cleanly at the next epoch.- let b = DocumentLeases::cluster(&backend, "node-b", None, std::time::Duration::from_secs(1))+ let b = DocumentLeases::cluster(backend.as_ref(), "node-b", None, std::time::Duration::from_secs(1)).unwrap();let held = b.holder("alice").await.unwrap().unwrap();assert_eq!((held.owner.as_str(), held.epoch), ("node-a", 4));diff --git a/crates/openhuman-core/src/storage/scope_move_tests.rs b/crates/openhuman-core/src/storage/scope_move_tests.rsindex 247309b3f7..41c7e3a4ec 100644--- a/crates/openhuman-core/src/storage/scope_move_tests.rs+++ b/crates/openhuman-core/src/storage/scope_move_tests.rs@@ -284,8 +284,9 @@ fn boot_import_moves_profile_v1_scope_and_keeps_source_unchanged() {let destination = backend.for_scope(&scope_for_profile("alice").agent("agent").unwrap()).unwrap();- let copied = storage::block_on(async {- destination+ let copied_storage = destination.clone();+ let copied = storage::block_on(async move {+ copied_storage.documents().query_all("scope_move_fixture", &Query::all()).await@@ -297,8 +298,9 @@ fn boot_import_moves_profile_v1_scope_and_keeps_source_unchanged() {// A completed scope claim prevents a later boot from resurrecting a row// deleted by the current owner, and the source bytes remain untouched.- storage::block_on(async {- destination+ let delete_storage = destination.clone();+ storage::block_on(async move {+ delete_storage.documents().delete("scope_move_fixture", "stable-id", Precondition::None).await@@ -310,11 +312,12 @@ fn boot_import_moves_profile_v1_scope_and_keeps_source_unchanged() {.find(|report| report.domain == IMPORT_DOMAIN).unwrap();assert_eq!(- outcome.outcome.unwrap(),+ outcome.outcome.as_ref().unwrap(),crate::storage::import::Outcome::AlreadyDone);- let after = storage::block_on(async {- destination+ let after_storage = destination.clone();+ let after = storage::block_on(async move {+ after_storage.documents().query_all("scope_move_fixture", &Query::all()).await@@ -341,7 +344,7 @@ fn boot_import_reports_no_source_for_a_workspace_without_legacy_storage() {.find(|report| report.domain == IMPORT_DOMAIN).expect("scope migration is in the boot importer pipeline");assert_eq!(- report.outcome.unwrap(),+ report.outcome.as_ref().unwrap(),crate::storage::import::Outcome::NoSource);}diff --git a/crates/openhuman-core/src/storage/sessions/rebound_tests.rs b/crates/openhuman-core/src/storage/sessions/rebound_tests.rsindex 985f2aacc8..dd591939e3 100644--- a/crates/openhuman-core/src/storage/sessions/rebound_tests.rs+++ b/crates/openhuman-core/src/storage/sessions/rebound_tests.rs@@ -120,9 +120,18 @@ fn the_provider_surface_forwards_to_the_current_backend() {// Binding an actor goes through the inner provider, with and without an// explicit schema admission mode; both agree on whether it binds.let other: Arc<dyn StorageBackend> = memory_backend();- let plain = stores.bind_actor(Arc::clone(&other)).unwrap().is_some();+ let factory_backend = Arc::clone(&other);+ let factory: tinyagents_session::port::AgentStorageFactory = Arc::new(move |agent_id| {+ let scope = crate::storage::Scope::local().agent(agent_id)?;+ let port_scope = tinyagents_session::port::Scope::new(scope.as_str())?;+ Ok(crate::storage::sessions::ScopedStorage::new(+ factory_backend.for_scope(&scope)?,+ port_scope,+ ))+ });+ let plain = stores.bind_actor(Arc::clone(&factory)).unwrap().is_some();let admitted = stores- .bind_actor_with_schema_admission(other, SchemaAdmission::Declare)+ .bind_actor_with_schema_admission(factory, SchemaAdmission::Declare).unwrap().is_some();assert_eq!(plain, admitted);