Skip to content

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

test: assert installed storage url and use scoped storage handles

Steven Enamakel2d11841cf807
diff --git a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
index 5617424c71..9c5b1adeeb 100644
--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
@@ -173,11 +173,10 @@ async fn files_a_blob_backed_generated_artifact() {
let workspace = root.path().join("workspace");
let files_dir = root.path().join("Files");
let backend = crate::storage::test_support::memory_backend();
- let blobs = backend
+ let scoped = backend
.for_scope(&crate::storage::Scope::local())
- .unwrap()
- .blobs();
- let blobs: Arc<dyn BlobStore> = Arc::from(blobs);
+ .unwrap();
+ let blobs: Arc<dyn BlobStore> = Arc::clone(scoped.blobs());
let _output = MediaOutput::new(root.path(), Arc::clone(&blobs));
let wrapped = MediaArtifactTool::new(
BlobBackedMediaTool {
@@ -296,7 +295,7 @@ async fn removes_partial_destination_when_blob_read_fails() {
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")
+ let error = copy_blob_to_file(&mut reader, &dest, "generated-media/fail.png")
.await
.unwrap_err();
@@ -309,11 +308,10 @@ async fn keeps_source_blob_when_artifact_finalization_fails() {
let root = tempfile::tempdir().unwrap();
let workspace = root.path().join("workspace");
let backend = crate::storage::test_support::memory_backend();
- let blobs = backend
+ let scoped = backend
.for_scope(&crate::storage::Scope::local())
- .unwrap()
- .blobs();
- let blobs: Arc<dyn BlobStore> = Arc::from(blobs);
+ .unwrap();
+ let blobs: Arc<dyn BlobStore> = Arc::clone(scoped.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/storage/sessions/rebound_tests.rs b/crates/openhuman-core/src/storage/sessions/rebound_tests.rs
index dd591939e3..07244cc4d6 100644
--- a/crates/openhuman-core/src/storage/sessions/rebound_tests.rs
+++ b/crates/openhuman-core/src/storage/sessions/rebound_tests.rs
@@ -123,8 +123,8 @@ fn the_provider_surface_forwards_to_the_current_backend() {
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(
+ let port_scope = tinyagents_storage_kit::Scope::new(scope.as_str())?;
+ Ok(tinyagents_storage_kit::ScopedStorage::new(
factory_backend.for_scope(&scope)?,
port_scope,
))
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index 518f30c79a..9d8f8da92d 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -452,7 +452,8 @@ pub mod platform {
pub mod storage {
pub use openhuman_core::storage::{
block_on, block_on_anyhow, clear, configured_url, driver_is_shared, install,
- install_for_url, installed, open, url_from, StorageBackend, StorageUrl, STORAGE_URL_VAR,
+ install_for_url, installed, installed_url, open, url_from, StorageBackend, StorageUrl,
+ STORAGE_URL_VAR,
};
/// The layout v1 -> v2 migration the host runs at boot when
diff --git a/crates/openhuman-rpc/src/session_store/mod_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rs
index 856e0894cf..b7fa5ece06 100644
--- a/crates/openhuman-rpc/src/session_store/mod_tests.rs
+++ b/crates/openhuman-rpc/src/session_store/mod_tests.rs
@@ -33,6 +33,7 @@ async fn a_storage_url_installs_the_driver_backed_store() {
provider.destination_key()
);
assert!(crate::core_host::storage::installed().is_some());
+ assert_eq!(crate::core_host::storage::installed_url().as_deref(), Some("memory"));
// Agents are kept apart in the shared backend.
let alice = provider.for_agent("alice");
alice
@@ -61,9 +62,10 @@ async fn driver_backed_store_keeps_agents_apart(url: String) {
let _turn = SLOTS.lock().await;
let previous = crate::core_host::agent::session_store::installed();
let previous_backend = crate::core_host::storage::installed();
- install_for_url(Some(url)).await.unwrap();
+ install_for_url(Some(url.clone())).await.unwrap();
assert!(crate::core_host::storage::installed().is_some());
+ assert_eq!(crate::core_host::storage::installed_url().as_deref(), Some(url.as_str()));
let provider = crate::core_host::agent::session_store::installed().unwrap();
let alice = provider.for_agent("alice");
alice
@@ -111,7 +113,7 @@ async fn the_host_reads_the_storage_url_from_the_environment() {
std::env::set_var(var, " memory ");
let booted = install_for_host().await;
- let installed = crate::core_host::storage::installed().is_some();
+ let installed_url = crate::core_host::storage::installed_url();
std::env::set_var(var, "ftp://nowhere");
let refused = install_for_host().await;
@@ -124,7 +126,7 @@ async fn the_host_reads_the_storage_url_from_the_environment() {
crate::core_host::agent::session_store::restore(previous);
booted.unwrap();
- assert!(installed);
+ assert_eq!(installed_url.as_deref(), Some("memory"));
assert!(refused.is_err(), "an unusable env URL fails the boot");
}
@@ -137,7 +139,7 @@ async fn provider_for_url_returns_the_store_without_installing_it() {
let backed = provider_for_url(Some("memory".into())).await.unwrap();
let backed_key = backed.destination_key();
- let backend_installed = crate::core_host::storage::installed().is_some();
+ let installed_url = crate::core_host::storage::installed_url();
let left_uninstalled = crate::core_host::agent::session_store::installed().is_none();
// No URL: each workspace keeps its sessions in its own default database.
@@ -153,7 +155,7 @@ async fn provider_for_url_returns_the_store_without_installing_it() {
.is_some_and(|key| key.starts_with("memory://")),
"{backed_key:?}"
);
- assert!(backend_installed, "the backend is installed");
+ assert_eq!(installed_url.as_deref(), Some("memory"), "the backend is installed");
assert!(
left_uninstalled,
"the provider is handed back, not installed"