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
refactor(tinyjuice): derive ccr blob prefix from module storage
Steven Enamakelcbdeaba99078
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas.rs b/crates/openhuman-core/src/modules/storage_grant_schemas.rsindex ed10e446aa..5b3db30a37 100644--- a/crates/openhuman-core/src/modules/storage_grant_schemas.rs+++ b/crates/openhuman-core/src/modules/storage_grant_schemas.rs@@ -180,8 +180,6 @@ pub(super) mod tinyeventqueues {pub(super) mod tinyjuice {pub(crate) const MODULE_ID: &str = "tinyjuice";- /// The v1 CCR blob prefix the importer writes.- pub(crate) const CCR_BLOB_PREFIX: &str = "tinyjuice_ccr/";}#[cfg(test)]diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rsindex d920bc47fe..25fdc163d3 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs@@ -2,10 +2,10 @@//! module's blob storage.//!//! The compress-cache-retrieve tier used to write each offloaded original to-//! `<workspace>/.tokenjuice/ccr/<token>`, expiring by file age. From v0.10.0-//! the module keeps them as expiring blobs `tinyjuice_ccr/<token>` in its own-//! scope and writes no files. A model that was handed a recovery handle before-//! the upgrade can still fetch the original afterwards.+//! `<workspace>/.tokenjuice/ccr/<token>`, expiring by file age. The module+//! keeps them as expiring blobs `juice/ccr/<token>` in its own scope and writes+//! no files. A model that was handed a recovery handle before the upgrade can+//! still fetch the original afterwards.//!//! * **Legacy files are never modified or deleted.** They are only read.//! * **Nothing is overwritten.** A blob that already exists is kept.@@ -26,7 +26,7 @@ use std::time::{Duration, SystemTime};use anyhow::{anyhow, Context, Result};use tinystoragedrivers::{Capability, ScopedStorage};-use super::storage_grant_schemas::tinyjuice::{CCR_BLOB_PREFIX, MODULE_ID};+use super::storage_grant_schemas::tinyjuice::MODULE_ID;use super::storage_import_support as support;use crate::core::runtime::DispatchCtx;@@ -113,7 +113,7 @@ async fn import_into(},None => None,};- let key = format!("{CCR_BLOB_PREFIX}{}", original.token);+ let key = ccr_key(&original.token);let present = blobs.head(&key).await@@ -145,6 +145,10 @@ async fn import_into(})}+fn ccr_key(token: &str) -> String {+ format!("{}/{token}", tinyjuice_bus::storage::CCR_PREFIX)+}+fn is_token(name: &str) -> bool {name.len() == TOKEN_LEN && name.bytes().all(|byte| byte.is_ascii_hexdigit())}diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rsindex 9302591773..27c7160e32 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_tests.rs@@ -39,7 +39,7 @@ fn legacy_root() -> tempfile::TempDir {async fn read(scoped: &ScopedStorage, token: &str) -> Option<String> {scoped.blobs()- .get(&format!("{CCR_BLOB_PREFIX}{token}"))+ .get(&ccr_key(token)).await.unwrap().map(|blob| String::from_utf8(blob.bytes).unwrap())@@ -130,7 +130,7 @@ async fn a_second_run_is_a_noop_and_a_blob_already_stored_is_kept() {scoped.blobs().put(- &format!("{CCR_BLOB_PREFIX}{FRESH}"),+ &ccr_key(FRESH),b"written by the module".to_vec(),None,)diff --git a/crates/openhuman-core/src/storage/blob_sweep_tests.rs b/crates/openhuman-core/src/storage/blob_sweep_tests.rsindex 9b6a5b47ec..538dc445c3 100644--- a/crates/openhuman-core/src/storage/blob_sweep_tests.rs+++ b/crates/openhuman-core/src/storage/blob_sweep_tests.rs@@ -87,7 +87,7 @@ async fn module_blob_scopes_are_swept_alongside_the_acting_scope() {&crate::core::runtime::DispatchCtx::host_default(),);assert!(!module_scopes.is_empty(), "TinyJuice owns expiring blobs");- put_expiring(&backend, &module_scopes[0], "tinyjuice_ccr/t", 10).await;+ put_expiring(&backend, &module_scopes[0], "juice/ccr/t", 10).await;now.store(2_000, Ordering::SeqCst);assert_eq!(sweep_all(backend).await, 1);}@@ -138,7 +138,7 @@ async fn sweep_profiles_reaches_the_modules_scopes_for_that_profile() {let (now, backend) = backend_with_clock();let module_scopes = crate::modules::expiring_blob_module_scopes_for("acme");assert!(!module_scopes.is_empty(), "TinyJuice owns expiring blobs");- put_expiring(&backend, &module_scopes[0], "tinyjuice_ccr/t", 10).await;+ put_expiring(&backend, &module_scopes[0], "juice/ccr/t", 10).await;now.store(2_000, Ordering::SeqCst);assert_eq!(sweep_profiles(backend.as_ref(), &["acme".to_string()]).await,