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(artifacts): read stored files through the blob store
Steven Enamakel28efa99db790
diff --git a/crates/openhuman-core/src/artifacts/production_tests.rs b/crates/openhuman-core/src/artifacts/production_tests.rsindex 0cd1605107..6bc8c5f3be 100644--- a/crates/openhuman-core/src/artifacts/production_tests.rs+++ b/crates/openhuman-core/src/artifacts/production_tests.rs@@ -1,6 +1,6 @@use std::path::PathBuf;-use tiny_artifacts::{ArtifactKind, ArtifactStatus as RecordStatus, ArtifactStore};+use tiny_artifacts::{ArtifactKind, ArtifactStatus as RecordStatus, ArtifactStore, FileStore};use super::*;use crate::artifacts::store::get_artifact;@@ -25,6 +25,17 @@ fn files_in(dir: &PathBuf) -> Vec<String> {names}+async fn stored_file_bytes(workspace: &std::path::Path, key: &str) -> Vec<u8> {+ let storage = crate::storage::local::open("artifacts::files", workspace)+ .unwrap()+ .scoped()+ .unwrap();+ tiny_artifacts::BlobFileStore::new(&storage)+ .read(key)+ .await+ .unwrap()+}+async fn produce(workspace: &std::path::Path,files: &std::path::Path,@@ -92,11 +103,7 @@ async fn a_new_artifact_shares_one_id_and_one_file_between_card_and_record() {let file = record.latest().unwrap().file.clone().unwrap();let expected_key = format!("artifacts/files/{id}/v1.pptx");assert_eq!(file.key, expected_key);- let kept = crate::artifacts::tiny_store::stored_file_path(&workspace, &file);- assert_eq!(- kept,- crate::artifacts::tiny_store::version_files_dir(&workspace).join(&expected_key)- );+ assert_eq!(stored_file_bytes(&workspace, &file.key).await, b"deck-v1");assert_eq!(files_in(&files),vec!["quarterly-deck.pptx"],@@ -124,14 +131,10 @@ async fn a_revision_reuses_the_id_and_file_and_keeps_the_history() {b"deck-v2!");// Each version still holds what it was.- let bytes_of = |n: u32| {- let file = record.version(n).unwrap().file.clone().unwrap();- std::fs::read(crate::artifacts::tiny_store::stored_file_path(- &workspace, &file,- ))- };- assert_eq!(bytes_of(1).unwrap(), b"deck-v1");- assert_eq!(bytes_of(2).unwrap(), b"deck-v2!");+ let file_v1 = record.version(1).unwrap().file.clone().unwrap();+ let file_v2 = record.version(2).unwrap().file.clone().unwrap();+ assert_eq!(stored_file_bytes(&workspace, &file_v1.key).await, b"deck-v1");+ assert_eq!(stored_file_bytes(&workspace, &file_v2.key).await, b"deck-v2!");}#[tokio::test]diff --git a/crates/openhuman-core/src/artifacts/tiny_store.rs b/crates/openhuman-core/src/artifacts/tiny_store.rsindex b1cc6141cc..a397df4605 100644--- a/crates/openhuman-core/src/artifacts/tiny_store.rs+++ b/crates/openhuman-core/src/artifacts/tiny_store.rs@@ -362,9 +362,9 @@ pub fn version_files_dir(workspace_dir: &Path) -> PathBuf {.join("files")}-/// Where a version's stored file lives on disk: its storage key under-/// [`version_files_dir`]. A key that is an absolute path (a record written-/// before files were kept behind a store) names that path itself.+/// Legacy filesystem location for a version file key. New versions live in+/// the configured blob store; this path is only used to read records created+/// before that store was introduced. An absolute key names that path itself.pub fn stored_file_path(workspace_dir: &Path, file: &tiny_artifacts::FileRef) -> PathBuf {version_files_dir(workspace_dir).join(&file.key)}