Skip to content

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

refactor(storage): clean up blob sweep logic and tests

Steven Enamakeladbb3b7168dc
diff --git a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
index b13219587f..bfe772e27d 100644
--- a/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_grant_schemas_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::modules::storage_grants::{authorize, declared, Denied, Object, Plan};
+use crate::modules::storage_grants::{Denied, Object, Plan, authorize, declared};
use serde_json::json;
fn allowed(
@@ -24,12 +24,7 @@ fn every_row_has_a_valid_generated_grant() {
.unwrap_or_else(|why| panic!("{}: {why}", row.module));
assert!(grant.writable);
let items = module_collections(row.owner);
- assert_eq!(
- grant.collections.len(),
- items.len(),
- "{}",
- row.module
- );
+ assert_eq!(grant.collections.len(), items.len(), "{}", row.module);
}
assert!(declared("not-a-module").is_none());
}
diff --git a/crates/openhuman-core/src/storage/blob_sweep.rs b/crates/openhuman-core/src/storage/blob_sweep.rs
index 9a49bdafef..c985a86c55 100644
--- a/crates/openhuman-core/src/storage/blob_sweep.rs
+++ b/crates/openhuman-core/src/storage/blob_sweep.rs
@@ -17,8 +17,8 @@ use std::time::Duration;
use tinystoragedrivers::{Scope, StorageBackend};
use tinystoragedrivers_api::BlobStore;
use tinystoragedrivers_types::{
- is_reserved_blob_key, BlobListPage, Result as StorageResult, StorageError,
- MAX_BLOB_LIST_PAGE_ITEMS, SEALED_BLOB_PREFIX,
+ BlobListPage, MAX_BLOB_LIST_PAGE_ITEMS, Result as StorageResult, SEALED_BLOB_PREFIX,
+ StorageError, is_reserved_blob_key,
};
/// How often the sweeper wakes. Lapsed blobs are already invisible to readers,
@@ -98,7 +98,9 @@ fn orphan_age_is_eligible(written_at_ms: Option<u64>, older_than_ms: u64) -> boo
fn validate_orphan_sweep_prefix(prefix: &str, max_key_len: usize) -> StorageResult<()> {
if prefix.is_empty()
|| prefix.len() > max_key_len
- || prefix.bytes().any(|byte| byte == 0 || byte.is_ascii_control())
+ || prefix
+ .bytes()
+ .any(|byte| byte == 0 || byte.is_ascii_control())
|| SEALED_BLOB_PREFIX.starts_with(prefix)
|| prefix.starts_with(SEALED_BLOB_PREFIX)
|| prefix
diff --git a/crates/openhuman-core/src/storage/blob_sweep_tests.rs b/crates/openhuman-core/src/storage/blob_sweep_tests.rs
index 403a3f85a5..4aedc904b5 100644
--- a/crates/openhuman-core/src/storage/blob_sweep_tests.rs
+++ b/crates/openhuman-core/src/storage/blob_sweep_tests.rs
@@ -95,10 +95,12 @@ async fn module_blob_scopes_are_swept_alongside_the_acting_scope() {
#[cfg(not(feature = "modules"))]
#[test]
fn no_module_blob_scopes_without_the_modules_feature() {
- assert!(crate::modules::expiring_blob_module_scopes(
- &crate::core::runtime::DispatchCtx::host_default()
- )
- .is_empty());
+ assert!(
+ crate::modules::expiring_blob_module_scopes(
+ &crate::core::runtime::DispatchCtx::host_default()
+ )
+ .is_empty()
+ );
}
#[tokio::test]
@@ -223,7 +225,9 @@ fn orphan_sweep_age_is_strict_and_unknown_ages_are_retained() {
fn orphan_sweep_refuses_empty_and_engine_owned_prefixes() {
for prefix in ["", "_tsd/", "_tsd/sealed", "_tsd/sealed/stream/"] {
assert_eq!(
- validate_orphan_sweep_prefix(prefix, 1024).unwrap_err().kind(),
+ validate_orphan_sweep_prefix(prefix, 1024)
+ .unwrap_err()
+ .kind(),
tinystoragedrivers_types::ErrorKind::InvalidInput,
"prefix {prefix:?}"
);
@@ -351,7 +355,7 @@ async fn orphan_sweep_stops_on_reference_error_after_preserving_prior_progress()
async fn orphan_sweep_stops_on_listing_error_before_touching_blobs() {
use std::sync::Arc;
use tinystoragedrivers_api::BlobStore;
- use tinystoragedrivers_testkit::{memory_storage, Failing, FaultPlan};
+ use tinystoragedrivers_testkit::{Failing, FaultPlan, memory_storage};
use tinystoragedrivers_types::{ErrorKind, Scope};
let storage = memory_storage(&Scope::local());
@@ -373,7 +377,7 @@ async fn orphan_sweep_stops_on_listing_error_before_touching_blobs() {
async fn orphan_sweep_stops_on_delete_error_after_preserving_prior_progress() {
use std::sync::Arc;
use tinystoragedrivers_api::BlobStore;
- use tinystoragedrivers_testkit::{memory_storage, Failing, FaultPlan};
+ use tinystoragedrivers_testkit::{Failing, FaultPlan, memory_storage};
use tinystoragedrivers_types::{ErrorKind, Scope};
let storage = memory_storage(&Scope::local());