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(storage): reorder imports and reformat code
Steven Enamakel3a287fe699cf
diff --git a/crates/openhuman-core/src/agent/multimodal.rs b/crates/openhuman-core/src/agent/multimodal.rsindex 56b92c8d4f..0925c0c736 100644--- a/crates/openhuman-core/src/agent/multimodal.rs+++ b/crates/openhuman-core/src/agent/multimodal.rs@@ -13,15 +13,15 @@ use std::time::Duration;use async_trait::async_trait;use reqwest::Client;-use crate::config::{MultimodalConfig, build_runtime_proxy_client_with_timeouts};+use crate::config::{build_runtime_proxy_client_with_timeouts, MultimodalConfig};use tinyagents_session::transcript::{TranscriptMessage, TranscriptPart};use tinyagents_harness::multimodal::{- BlobAttachmentStash,config::ImageLimits,markers,payload::sha256_prefix,- resolve::{TextExtractor, resolve_image},+ resolve::{resolve_image, TextExtractor},+ BlobAttachmentStash,};/// Hard upper bound on how long the `tinydocs` module may spend extracting adiff --git a/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs b/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rsindex 827d755baf..96487206e0 100644--- a/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs+++ b/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs@@ -56,11 +56,9 @@ async fn rehydrate_missing_stash_id_keeps_placeholder_text() {"see [Image: image #att:deadbeefdeadbeef]".to_string(),)];let out = rehydrate_image_placeholders(&messages).await;- assert!(- out[0]- .content- .contains("[Image: image #att:deadbeefdeadbeef]")- );+ assert!(out[0]+ .content+ .contains("[Image: image #att:deadbeefdeadbeef]"));assert!(!out[0].content.contains("[IMAGE:data:"));}diff --git a/crates/openhuman-core/src/config/schema/load/source/document.rs b/crates/openhuman-core/src/config/schema/load/source/document.rsindex 97473c7590..ccd6bb66c1 100644--- a/crates/openhuman-core/src/config/schema/load/source/document.rs+++ b/crates/openhuman-core/src/config/schema/load/source/document.rs@@ -2,21 +2,21 @@use std::sync::{Arc, Mutex};-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};use async_trait::async_trait;use serde_json::json;-use tinystoragedrivers::secrets::{KeyProvider, crypto};+use tinystoragedrivers::secrets::{crypto, KeyProvider};use tinystoragedrivers::{CollectionSpec, Precondition};use tinystoragedrivers_api::DocumentStore;use super::{- ConfigRead, ConfigSource, ConfigSourceAnchor, DocumentBackendIdentity, FileConfigSource,- apply_bootstrap, strip_bootstrap,+ apply_bootstrap, strip_bootstrap, ConfigRead, ConfigSource, ConfigSourceAnchor,+ DocumentBackendIdentity, FileConfigSource,};use crate::storage::Scope;-pub(crate) use super::storage_schema::CONFIG_COLLECTION;use super::storage_schema::document_id;+pub(crate) use super::storage_schema::CONFIG_COLLECTION;/// The document field holding the encrypted TOML body (`enc2:` hex).const BODY_FIELD: &str = "toml_enc";diff --git a/crates/openhuman-core/src/config/workspace/state.rs b/crates/openhuman-core/src/config/workspace/state.rsindex f066808c0b..d09d48d5c9 100644--- a/crates/openhuman-core/src/config/workspace/state.rs+++ b/crates/openhuman-core/src/config/workspace/state.rs@@ -8,7 +8,7 @@use std::path::{Path, PathBuf};use std::sync::Arc;-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};use serde::{Deserialize, Serialize};use serde_json::Value;use sha2::{Digest, Sha256};@@ -43,10 +43,9 @@ impl WatcherStateStore {pub fn open(db_path: &Path) -> Result<Self> {let url = format!("sqlite:{}", db_path.display());let config = StorageConfig::parse(&url).context("parse watcher storage URL")?;- let backend = crate::storage::block_on(async move {- tinystoragedrivers::open(&config).await- })- .context("open watcher storage backend")?;+ let backend =+ crate::storage::block_on(async move { tinystoragedrivers::open(&config).await })+ .context("open watcher storage backend")?;Self::from_backend(backend)}diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 45d37a50ef..890b57fca1 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -12,8 +12,8 @@ use std::{use serde_json::{Map, Value};-use crate::core::ControllerSchema;use crate::core::runtime::DispatchCtx;+use crate::core::ControllerSchema;/// A pinned, boxed future returned by a controller handler.pub type ControllerFuture = Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'static>>;diff --git a/crates/openhuman-core/src/desktop/notifications/mod.rs b/crates/openhuman-core/src/desktop/notifications/mod.rsindex c75e7e1d4a..63425c310d 100644--- a/crates/openhuman-core/src/desktop/notifications/mod.rs+++ b/crates/openhuman-core/src/desktop/notifications/mod.rs@@ -36,8 +36,8 @@ pub(crate) use store_documents::import_source;pub mod types;pub use bus::{- NotificationBridgeSubscriber, publish_core_notification,- register_notification_bridge_subscriber, subscribe_core_notifications,+ publish_core_notification, register_notification_bridge_subscriber,+ subscribe_core_notifications, NotificationBridgeSubscriber,};pub use schemas::{all_controller_schemas as all_notifications_controller_schemas,diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents.rs b/crates/openhuman-core/src/desktop/notifications/store_documents.rsindex e5142671b4..ef3d77e8f2 100644--- a/crates/openhuman-core/src/desktop/notifications/store_documents.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_documents.rs@@ -31,7 +31,7 @@ use std::sync::Arc;use anyhow::{Context, Result};use chrono::{DateTime, Duration, Utc};-use serde_json::{Map, Value, json};+use serde_json::{json, Map, Value};use sha2::{Digest, Sha256};use tinystoragedrivers::{CollectionSpec, ErrorKind, Filter, Precondition, Query, Sort, Versioned};@@ -40,13 +40,13 @@ use super::types::{NotificationStatus,};use crate::config::Config;-use crate::storage::documents::{Repo, compare_and_swap, text, update_or_insert};+use crate::storage::documents::{compare_and_swap, text, update_or_insert, Repo};use crate::storage::{DocumentStore, DocumentStoreExt, StorageError};#[cfg(feature = "legacy-import")]use super::storage_schema::legacy_collections;use super::storage_schema::specs;-pub(super) use super::storage_schema::{CORE, DEDUP, NOTIFICATIONS, SETTINGS, core_id};+pub(super) use super::storage_schema::{core_id, CORE, DEDUP, NOTIFICATIONS, SETTINGS};use crate::storage::schema_support::key_of;/// The `workspace` key of core notifications in the per-workspace defaultdiff --git a/crates/openhuman-core/src/integrations/task_sources/store_documents.rs b/crates/openhuman-core/src/integrations/task_sources/store_documents.rsindex 41a60adcac..e285c49ced 100644--- a/crates/openhuman-core/src/integrations/task_sources/store_documents.rs+++ b/crates/openhuman-core/src/integrations/task_sources/store_documents.rs@@ -19,24 +19,24 @@//! fields (`created_ms`, `ingested_ms`) carry the ordering. Removing a source//! removes its ledger entries, which the SQL schema did with a cascade.-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};use chrono::{DateTime, Utc};-use serde_json::{Map, Value, json};+use serde_json::{json, Map, Value};use tinystoragedrivers::{CollectionSpec, Filter, Precondition, Query, Sort, Versioned};-use super::store::{IngestedTaskRef, apply_patch, content_hash};+use super::store::{apply_patch, content_hash, IngestedTaskRef};use super::types::{FetchReason, FilterSpec, ProviderSlug, SourceTarget, TaskSource, TaskSourcePatch,};use crate::config::Config;use crate::integrations::composio::contract::NormalizedTask;-use crate::storage::documents::{Repo, compare_and_swap, text};+use crate::storage::documents::{compare_and_swap, text, Repo};use crate::storage::{DocumentStoreExt, StorageError};#[cfg(feature = "legacy-import")]use super::storage_schema::legacy_collections;use super::storage_schema::specs;-pub(super) use super::storage_schema::{INGESTED, SOURCES, ingested_id};+pub(super) use super::storage_schema::{ingested_id, INGESTED, SOURCES};use crate::storage::schema_support::key_of;const DOMAIN: &str = "task_sources::store";@@ -229,7 +229,11 @@ impl Docs {.await?;docs.delete(SOURCES, &key, Precondition::None).await})?;- if removed { Ok(()) } else { Err(not_found(id)) }+ if removed {+ Ok(())+ } else {+ Err(not_found(id))+ }}pub(super) fn record_fetch(diff --git a/crates/openhuman-core/src/security/approval/mod.rs b/crates/openhuman-core/src/security/approval/mod.rsindex 033cd89355..5ffd51a135 100644--- a/crates/openhuman-core/src/security/approval/mod.rs+++ b/crates/openhuman-core/src/security/approval/mod.rs@@ -31,9 +31,8 @@ pub(crate) use store_documents::import_source;pub mod types;pub use gate::{- APPROVAL_UNANSWERED_PHRASE, ApprovalChatContext, ApprovalError, ApprovalGate,- ApprovalTurnContext, FlowRunContext, is_detached_request, is_unanswered_approval_reason,- parse_approval_reply,+ is_detached_request, is_unanswered_approval_reason, parse_approval_reply, ApprovalChatContext,+ ApprovalError, ApprovalGate, ApprovalTurnContext, FlowRunContext, APPROVAL_UNANSWERED_PHRASE,};pub use redact::{redact_args, summarize_action};pub use schemas::all_controller_schemas as all_approval_controller_schemas;diff --git a/crates/openhuman-core/src/security/approval/store_documents.rs b/crates/openhuman-core/src/security/approval/store_documents.rsindex e90125d46d..8fb918a997 100644--- a/crates/openhuman-core/src/security/approval/store_documents.rs+++ b/crates/openhuman-core/src/security/approval/store_documents.rs@@ -24,14 +24,14 @@use std::sync::Arc;-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};use chrono::{DateTime, Utc};-use serde_json::{Value, json};+use serde_json::{json, Value};use crate::config::Config;use crate::storage::documents::compare_and_swap;use crate::storage::local;-use crate::storage::{DocumentStore, DocumentStoreExt, Storage, StorageError, block_on};+use crate::storage::{block_on, DocumentStore, DocumentStoreExt, Storage, StorageError};use tinystoragedrivers::{CollectionSpec, ErrorKind, Filter, Key, Precondition, Query, Sort, Versioned,};@@ -39,7 +39,7 @@ use tinystoragedrivers::{#[cfg(feature = "legacy-import")]use super::storage_schema::legacy_collections;use super::storage_schema::specs;-pub(super) use super::storage_schema::{APPROVALS, FLOW_TRUST, trust_id};+pub(super) use super::storage_schema::{trust_id, APPROVALS, FLOW_TRUST};use super::types::{ApprovalAuditEntry, ApprovalDecision, ApprovalSourceContext, ExecutionOutcome, PendingApproval,diff --git a/crates/openhuman-core/src/security/devices/store_documents.rs b/crates/openhuman-core/src/security/devices/store_documents.rsindex 4f41639245..d14ac487b9 100644--- a/crates/openhuman-core/src/security/devices/store_documents.rs+++ b/crates/openhuman-core/src/security/devices/store_documents.rs@@ -13,17 +13,17 @@use anyhow::Result;use chrono::Utc;-use serde_json::{Value, json};+use serde_json::{json, Value};use tinystoragedrivers::{CollectionSpec, Filter, Precondition, Query, Sort, Versioned};use crate::config::Config;use crate::security::devices::types::PairedDevice;+use crate::storage::documents::{compare_and_swap, text, Repo};use crate::storage::DocumentStoreExt;-use crate::storage::documents::{Repo, compare_and_swap, text};#[cfg(feature = "legacy-import")]use super::storage_schema::legacy_collections;-use super::storage_schema::{DEVICES, spec};+use super::storage_schema::{spec, DEVICES};use crate::storage::schema_support::{key_of, ms_rfc3339};const DOMAIN: &str = "devices::store";diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend/key_source_tests.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend/key_source_tests.rsindex aac5196dd6..70b244f18f 100644--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend/key_source_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend/key_source_tests.rs@@ -58,12 +58,10 @@ fn host_key_write_requires_matching_readback() {wrong_readback: true,..Default::default()};- assert!(- load_or_mint_master_key(&source)- .unwrap_err()- .to_string()- .contains("verification failed")- );+ assert!(load_or_mint_master_key(&source)+ .unwrap_err()+ .to_string()+ .contains("verification failed"));}#[test]@@ -114,7 +112,7 @@ fn corrupt_workspace_key_is_never_replaced() {#[cfg(unix)]#[test]fn workspace_key_rejects_shared_permissions_and_symlinks() {- use std::os::unix::fs::{PermissionsExt, symlink};+ use std::os::unix::fs::{symlink, PermissionsExt};let dir = tempfile::tempdir().unwrap();let path = dir.path().join("keyring/master.key");workspace_master_key(dir.path()).unwrap();diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rsindex ae3569f03b..ddccdabcb3 100644--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled.rs@@ -35,8 +35,8 @@ fn parse_master_key_hex(hex: &str) -> Result<[u8; KEY_LEN], String> {#[path = "encrypted_file_backend/key_source.rs"]pub mod key_source;pub use key_source::{- MasterKeySource, clear_master_key_source, install_master_key_source,- installed_master_key_source,+ clear_master_key_source, install_master_key_source, installed_master_key_source,+ MasterKeySource,};/// There is no encrypted-file initialization in a build without `secret-file`.diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled_tests.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled_tests.rsindex 026b0f49f4..d89ce7b205 100644--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_disabled_tests.rs@@ -4,18 +4,14 @@ use super::*;fn selecting_encrypted_file_fails_closed_when_the_feature_is_disabled() {let backend = EncryptedFileBackend::new(Path::new("unused"));assert_eq!(backend.name(), "encrypted_file");- assert!(- backend- .get("token")- .unwrap_err()- .to_string()- .contains("enable the secret-file feature")- );- assert!(- backend- .set("token", "value")- .unwrap_err()- .to_string()- .contains("enable the secret-file feature")- );+ assert!(backend+ .get("token")+ .unwrap_err()+ .to_string()+ .contains("enable the secret-file feature"));+ assert!(backend+ .set("token", "value")+ .unwrap_err()+ .to_string()+ .contains("enable the secret-file feature"));}diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_tests.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_tests.rsindex f9f7cbbe31..c1af887e97 100644--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend_tests.rs@@ -48,11 +48,9 @@ fn invalid_legacy_plaintext_is_preserved_for_recovery() {std::fs::write(&legacy_path, b"invalid JSON").unwrap();let backend = EncryptedFileBackend::new(dir.path());- assert!(- backend- .get_with_key(&[0x42; KEY_LEN], "user:token")- .is_err()- );+ assert!(backend+ .get_with_key(&[0x42; KEY_LEN], "user:token")+ .is_err());assert_eq!(std::fs::read(&legacy_path).unwrap(), b"invalid JSON");assert!(!backend.path.exists());}@@ -257,11 +255,9 @@ fn malformed_env_key_is_rejected_without_leaking_the_value() {#[test]fn empty_env_values_fall_through_to_the_keychain() {- assert!(- master_key_from_env(None, None, file_must_not_be_read)- .expect("nothing set is fine")- .is_none()- );+ assert!(master_key_from_env(None, None, file_must_not_be_read)+ .expect("nothing set is fine")+ .is_none());assert!(master_key_from_env(Some(""), Some(" "), file_must_not_be_read).expect("empty values count as unset")diff --git a/crates/openhuman-core/src/security/secret_storage/file_store.rs b/crates/openhuman-core/src/security/secret_storage/file_store.rsindex eedc584c9a..ef6ba19377 100644--- a/crates/openhuman-core/src/security/secret_storage/file_store.rs+++ b/crates/openhuman-core/src/security/secret_storage/file_store.rs@@ -322,7 +322,7 @@ fn replace_durably_with_sync(fn replace_durably(source: &Path, destination: &Path) -> std::io::Result<()> {use std::os::windows::ffi::OsStrExt;use windows_sys::Win32::Storage::FileSystem::{- MOVEFILE_REPLACE_EXISTING, MOVEFILE_WRITE_THROUGH, MoveFileExW,+ MoveFileExW, MOVEFILE_REPLACE_EXISTING, MOVEFILE_WRITE_THROUGH,};let source: Vec<u16> = source.as_os_str().encode_wide().chain(Some(0)).collect();diff --git a/crates/openhuman-core/src/security/secret_storage/mod.rs b/crates/openhuman-core/src/security/secret_storage/mod.rsindex fd337a6b86..e992b24b9c 100644--- a/crates/openhuman-core/src/security/secret_storage/mod.rs+++ b/crates/openhuman-core/src/security/secret_storage/mod.rs@@ -24,19 +24,19 @@ pub mod store;// ── Public re-exports ─────────────────────────────────────────────────────────pub use backend::SecretBackend;-pub use encrypted_file_backend::EncryptedFileBackend;pub use encrypted_file_backend::init_master_key;pub use encrypted_file_backend::key_source::{- MasterKeySource, clear_master_key_source, install_master_key_source,- installed_master_key_source,+ clear_master_key_source, install_master_key_source, installed_master_key_source,+ MasterKeySource,};+pub use encrypted_file_backend::EncryptedFileBackend;pub use encrypted_store::SecretStore;pub use error::SecretStorageError;pub use install::{clear_secret_backend, install_secret_backend, installed_secret_backend};pub use memory_backend::MemoryBackend;pub use ops::{- MigrationOutcome, backend_name, delete, get, get_or_create_random, is_available,- migrate_from_file, reset_availability_cache, set,+ backend_name, delete, get, get_or_create_random, is_available, migrate_from_file,+ reset_availability_cache, set, MigrationOutcome,};pub use store::init_workspace;diff --git a/crates/openhuman-core/src/security/secret_storage/mod_tests.rs b/crates/openhuman-core/src/security/secret_storage/mod_tests.rsindex 8fd6ca07b7..1d6af398de 100644--- a/crates/openhuman-core/src/security/secret_storage/mod_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/mod_tests.rs@@ -367,7 +367,7 @@ fn get_or_create_random_idempotent_file_backend() {// Manually implement the get_or_create_random logic using FileBackend.let first = {let mut bytes = vec![0u8; 32];- use chacha20poly1305::aead::{OsRng, rand_core::RngCore};+ use chacha20poly1305::aead::{rand_core::RngCore, OsRng};OsRng.fill_bytes(&mut bytes);let hex: String = bytes.iter().map(|b| format!("{b:02x}")).collect();fb.set(&nk, &hex).unwrap();diff --git a/crates/openhuman-core/src/security/secret_storage/ops.rs b/crates/openhuman-core/src/security/secret_storage/ops.rsindex 43eff70505..73bce25a77 100644--- a/crates/openhuman-core/src/security/secret_storage/ops.rs+++ b/crates/openhuman-core/src/security/secret_storage/ops.rs@@ -4,7 +4,7 @@use std::path::Path;-use chacha20poly1305::aead::{OsRng, rand_core::RngCore};+use chacha20poly1305::aead::{rand_core::RngCore, OsRng};use parking_lot::Mutex;use crate::security::secret_storage::error::SecretStorageError;@@ -47,8 +47,8 @@ pub enum MigrationOutcome {// belong to this process, not to an agent./// The storage-backed secret store for this call, when one is configured.-fn storage_secrets()--> Result<Option<tinystoragedrivers::secrets::DocumentSecrets>, SecretStorageError> {+fn storage_secrets(+) -> Result<Option<tinystoragedrivers::secrets::DocumentSecrets>, SecretStorageError> {crate::storage::secrets::current().map_err(|error| SecretStorageError::Backend(format!("storage secrets: {error}")))}diff --git a/crates/openhuman-core/src/security/secret_storage/ops_adoption_tests.rs b/crates/openhuman-core/src/security/secret_storage/ops_adoption_tests.rsindex 31552ea80c..d5d5647f01 100644--- a/crates/openhuman-core/src/security/secret_storage/ops_adoption_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/ops_adoption_tests.rs@@ -7,8 +7,8 @@ use std::sync::Arc;use tinystoragedrivers::secrets::{DerivedKeys, SecretStore as _};use zeroize::Zeroizing;-use crate::security::secret_storage::SecretBackend;use crate::security::secret_storage::backend::MockBackend;+use crate::security::secret_storage::SecretBackend;use crate::storage::{MemoryStorage, Scope, StorageBackend};#[test]diff --git a/crates/openhuman-core/src/security/secret_storage/store_test_scope_tests.rs b/crates/openhuman-core/src/security/secret_storage/store_test_scope_tests.rsindex e8e7e12ed2..1c9a92c2de 100644--- a/crates/openhuman-core/src/security/secret_storage/store_test_scope_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/store_test_scope_tests.rs@@ -5,7 +5,7 @@ use std::sync::{Arc, OnceLock};use parking_lot::Mutex;-use super::{SecretBackend, build_backend_at};+use super::{build_backend_at, SecretBackend};thread_local! {/// Workspace bound by [`ScopedWorkspace`] on this thread, if any.diff --git a/crates/openhuman-core/src/security/secret_storage/store_tests.rs b/crates/openhuman-core/src/security/secret_storage/store_tests.rsindex f3fd09d013..4be057a2b7 100644--- a/crates/openhuman-core/src/security/secret_storage/store_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/store_tests.rs@@ -19,8 +19,8 @@ use std::path::PathBuf;use super::test_scope::ScopedWorkspace;use super::{resolve_workspace_dir, workspace_dir_for_file_backend};-use crate::config::TEST_ENV_LOCK;use crate::config::test_env::EnvVarGuard;+use crate::config::TEST_ENV_LOCK;use crate::security::secret_storage;/// The root-cause pin: in test builds the keyring workspace must not bediff --git a/crates/openhuman-core/src/security/secret_storage/store_tests_2_tests.rs b/crates/openhuman-core/src/security/secret_storage/store_tests_2_tests.rsindex 26d88de553..a312aa21c8 100644--- a/crates/openhuman-core/src/security/secret_storage/store_tests_2_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/store_tests_2_tests.rs@@ -1,4 +1,4 @@-use super::{BackendKind, effective_backend_kind_for};+use super::{effective_backend_kind_for, BackendKind};#[test]fn explicit_file_backend_wins_over_staging_environment() {@@ -91,19 +91,15 @@ fn explicit_os_backend_requires_a_host_provider() {let _env =crate::config::test_env::EnvVarGuard::locked().with("OPENHUMAN_KEYRING_BACKEND", "os");let dir = tempfile::tempdir().unwrap();- assert!(- super::validate_backend_selection()- .unwrap_err()- .contains("host-installed OS")- );+ assert!(super::validate_backend_selection()+ .unwrap_err()+ .contains("host-installed OS"));let backend = super::build_backend_at(dir.path());- assert!(- backend- .get("user:key")- .unwrap_err()- .to_string()- .contains("host-installed OS")- );+ assert!(backend+ .get("user:key")+ .unwrap_err()+ .to_string()+ .contains("host-installed OS"));assert!(backend.set("user:key", "value").is_err());assert!(backend.delete("user:key").is_err());}diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rsindex 41d8d0a4fb..a96d0fa28e 100644--- a/crates/openhuman-core/src/storage/documents.rs+++ b/crates/openhuman-core/src/storage/documents.rs@@ -12,12 +12,12 @@ use std::collections::HashMap;use std::future::Future;use std::sync::{Arc, LazyLock, Mutex, PoisonError, Weak};-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};use serde_json::Value;use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition, Versioned};use super::{- DocumentStore, Scope, Storage, StorageBackend, StorageError, block_on, current_scope, installed,+ block_on, current_scope, installed, DocumentStore, Scope, Storage, StorageBackend, StorageError,};/// Collections already declared, per process: `(backend address, scope,diff --git a/crates/openhuman-core/src/storage/documents_tests.rs b/crates/openhuman-core/src/storage/documents_tests.rsindex 7d3857565c..c6ae455419 100644--- a/crates/openhuman-core/src/storage/documents_tests.rs+++ b/crates/openhuman-core/src/storage/documents_tests.rs@@ -186,10 +186,9 @@ fn one_time_work_runs_once_per_backend_and_scope_and_retries_failures() {};let first = backend();let repo = repo_on(&first, "once");- assert!(- repo.once_per_backend("k", || Err(anyhow::anyhow!("boom")))- .is_err()- );+ assert!(repo+ .once_per_backend("k", || Err(anyhow::anyhow!("boom")))+ .is_err());repo.once_per_backend("k", count).unwrap();repo.once_per_backend("k", count).unwrap();assert_eq!(runs.get(), 1, "a failure is retried, a success is recorded");diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rsindex 50e682d0a3..43edacf571 100644--- a/crates/openhuman-core/src/storage/import/mod.rs+++ b/crates/openhuman-core/src/storage/import/mod.rs@@ -69,20 +69,20 @@ use std::sync::Arc;use anyhow::Result;#[cfg(feature = "legacy-import")]-use anyhow::{Context, anyhow};+use anyhow::{anyhow, Context};#[cfg(feature = "legacy-import")]use sha2::Digest;use tinystoragedrivers::CollectionSpec;#[cfg(feature = "legacy-import")]use tinystoragedrivers::{ErrorKind, Precondition};-use super::StorageBackend;#[cfg(feature = "legacy-import")]use super::block_on;#[cfg(feature = "legacy-import")]use super::documents::Repo;#[cfg(feature = "legacy-import")]use super::rusqlite;+use super::StorageBackend;use crate::config::Config;#[cfg(feature = "legacy-import")]use rusqlite::Connection;diff --git a/crates/openhuman-core/src/storage/import/schemas.rs b/crates/openhuman-core/src/storage/import/schemas.rsindex b3114aff7c..66cb2187fe 100644--- a/crates/openhuman-core/src/storage/import/schemas.rs+++ b/crates/openhuman-core/src/storage/import/schemas.rs@@ -3,10 +3,10 @@use crate::core::runtime::DispatchCtx;use serde::Deserialize;-use serde_json::{Map, Value, json};+use serde_json::{json, Map, Value};-use crate::core::Outcome;use crate::core::all::{ControllerFuture, RegisteredController};+use crate::core::Outcome;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};#[derive(Debug, Deserialize, Default)]diff --git a/crates/openhuman-core/src/storage/journal_maintenance.rs b/crates/openhuman-core/src/storage/journal_maintenance.rsindex e87981c557..eec728cd1d 100644--- a/crates/openhuman-core/src/storage/journal_maintenance.rs+++ b/crates/openhuman-core/src/storage/journal_maintenance.rs@@ -9,9 +9,9 @@ use std::collections::BTreeSet;use std::sync::Arc;use std::time::Duration;-use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition, Scope, StorageBackend};use tinyagents_harness::observability::{DriverStatusStore, JournalMaintenanceReport};use tinyagents_harness::HarnessStatusStore;+use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition, Scope, StorageBackend};/// How often the sweep wakes.pub const SWEEP_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);@@ -95,7 +95,10 @@ async fn maintain_scope(let backfill_done = match docs.get(BACKFILL_COLLECTION, &key).await? {None => false,Some(record) => {- let version = record.doc.get("version").and_then(serde_json::Value::as_u64);+ let version = record+ .doc+ .get("version")+ .and_then(serde_json::Value::as_u64);if version != Some(BACKFILL_VERSION) {return Err(crate::storage::StorageError::invalid_input(format!("invalid journal backfill marker in scope {}",diff --git a/crates/openhuman-core/src/storage/journal_maintenance_tests.rs b/crates/openhuman-core/src/storage/journal_maintenance_tests.rsindex 5fdc5a335d..31271aaaf4 100644--- a/crates/openhuman-core/src/storage/journal_maintenance_tests.rs+++ b/crates/openhuman-core/src/storage/journal_maintenance_tests.rs@@ -104,7 +104,10 @@ async fn backfill_seals_finished_runs_but_not_active_ones_and_records_itself() {let storage = backend.for_scope(&Scope::local()).unwrap();let marker = storage.documents()- .get(BACKFILL_COLLECTION, &crate::storage::schema_support::key_of("inactive-journal-backfill-v1").unwrap())+ .get(+ BACKFILL_COLLECTION,+ &crate::storage::schema_support::key_of("inactive-journal-backfill-v1").unwrap(),+ ).await.unwrap().unwrap();@@ -128,14 +131,24 @@ async fn maintenance_deletes_a_sealed_journal_after_the_configured_retention() {.sealed_ms.unwrap();// Inside the window: kept.- let early = maintain_scope(&backend, &Scope::local(), DAY_MS, sealed_at + DAY_MS as i64 / 2)- .await- .unwrap();+ let early = maintain_scope(+ &backend,+ &Scope::local(),+ DAY_MS,+ sealed_at + DAY_MS as i64 / 2,+ )+ .await+ .unwrap();assert_eq!(early.deleted, 0);// Past one day, the configured retention (not the schema's 30).- let late = maintain_scope(&backend, &Scope::local(), DAY_MS, sealed_at + DAY_MS as i64 + 10)- .await- .unwrap();+ let late = maintain_scope(+ &backend,+ &Scope::local(),+ DAY_MS,+ sealed_at + DAY_MS as i64 + 10,+ )+ .await+ .unwrap();assert_eq!(late.deleted, 1);let storage = backend.for_scope(&Scope::local()).unwrap();assert!(storage@@ -161,9 +174,14 @@ async fn zero_retention_days_keeps_sealed_journals_forever() {.unwrap().sealed_ms.unwrap();- let summary = maintain_scope(&backend, &Scope::local(), 0, sealed_at + 400 * DAY_MS as i64)- .await- .unwrap();+ let summary = maintain_scope(+ &backend,+ &Scope::local(),+ 0,+ sealed_at + 400 * DAY_MS as i64,+ )+ .await+ .unwrap();assert_eq!(summary.deleted, 0);assert!(sealed(&backend, "run.keep").await);}diff --git a/crates/openhuman-core/src/storage/layout/credentials.rs b/crates/openhuman-core/src/storage/layout/credentials.rsindex 318efbc96b..a6264b4682 100644--- a/crates/openhuman-core/src/storage/layout/credentials.rs+++ b/crates/openhuman-core/src/storage/layout/credentials.rs@@ -21,9 +21,9 @@ use std::path::Path;#[cfg(feature = "legacy-import")]use tinystoragedrivers::secrets::SecretStore as _;+use super::state::LayoutError;#[cfg(feature = "legacy-import")]use super::Target;-use super::state::LayoutError;use crate::security::credentials::http_creds::{self, STORAGE_SECRET_NAME, STORE_FILENAME};use crate::security::credentials::profiles::{self, PROFILES_FILENAME, PROFILES_SECRET_NAME};#[cfg(feature = "legacy-import")]diff --git a/crates/openhuman-core/src/storage/layout/credentials_tests.rs b/crates/openhuman-core/src/storage/layout/credentials_tests.rsindex 8c93253a37..e4e8499d88 100644--- a/crates/openhuman-core/src/storage/layout/credentials_tests.rs+++ b/crates/openhuman-core/src/storage/layout/credentials_tests.rs@@ -1,9 +1,9 @@use super::*;use crate::security::secret_storage::{- MasterKeySource, SecretStorageError, clear_master_key_source, install_master_key_source,+ clear_master_key_source, install_master_key_source, MasterKeySource, SecretStorageError,};-use crate::storage::layout::test_fixtures::{Fixture, v1_profile, write};-use crate::storage::layout::{Options, Outcome, migrate, restore};+use crate::storage::layout::test_fixtures::{v1_profile, write, Fixture};+use crate::storage::layout::{migrate, restore, Options, Outcome};use std::sync::Arc;use tinystoragedrivers::secrets::DerivedKeys;use zeroize::Zeroizing;diff --git a/crates/openhuman-core/src/storage/layout/mod.rs b/crates/openhuman-core/src/storage/layout/mod.rsindex 1a2b3d24ab..7be803fcb9 100644--- a/crates/openhuman-core/src/storage/layout/mod.rs+++ b/crates/openhuman-core/src/storage/layout/mod.rs@@ -57,15 +57,15 @@ use std::path::{Path, PathBuf};use serde::Serialize;#[cfg(feature = "legacy-import")]-pub use run::{Options, auto_migrate, migrate, restore};+pub use run::{auto_migrate, migrate, restore, Options};pub use state::{LayoutError, Step};#[cfg(feature = "legacy-import")]-pub use status::{Status, status};+pub use status::{status, Status};-use crate::config::Config;use crate::config::schema::profile_layout::{PROFILE_FILES_DIR, PROFILE_STORAGE_FILE, PROFILE_WORKSPACE_DIR,};+use crate::config::Config;/// Directory under the root that holds the archives.pub const BACKUPS_DIR: &str = "backups";diff --git a/crates/openhuman-core/src/storage/layout/status.rs b/crates/openhuman-core/src/storage/layout/status.rsindex 0a941ab653..4919940827 100644--- a/crates/openhuman-core/src/storage/layout/status.rs+++ b/crates/openhuman-core/src/storage/layout/status.rs@@ -3,9 +3,9 @@use serde::{Deserialize, Serialize};use super::state::{LayoutError, LayoutState, Step};-use super::{Target, legacy};-use crate::config::Config;+use super::{legacy, Target};use crate::config::schema::profile_layout::LayoutVersion;+use crate::config::Config;/// The schema version one owner has reached in the profile's database.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]diff --git a/crates/openhuman-core/src/storage/local.rs b/crates/openhuman-core/src/storage/local.rsindex 6b16ed9599..00b38108a4 100644--- a/crates/openhuman-core/src/storage/local.rs+++ b/crates/openhuman-core/src/storage/local.rs@@ -21,9 +21,9 @@ use std::collections::HashMap;use std::path::{Path, PathBuf};use std::sync::{Arc, LazyLock, Mutex, PoisonError};-use anyhow::{Context, Result, anyhow};+use anyhow::{anyhow, Context, Result};-use super::{Scope, Storage, StorageBackend, current_scope, installed};+use super::{current_scope, installed, Scope, Storage, StorageBackend};/// A backend and the scope a store's records live under in it.#[derive(Clone)]diff --git a/crates/openhuman-core/src/storage/mod.rs b/crates/openhuman-core/src/storage/mod.rsindex fb2c5963fc..3aa52ea514 100644--- a/crates/openhuman-core/src/storage/mod.rs+++ b/crates/openhuman-core/src/storage/mod.rs@@ -51,12 +51,12 @@ pub mod sessions;pub mod state_kv;pub use scope::{- ParsedScope, Principal, Scope, Tenant, scope_for_agent, scope_for_module, scope_for_profile,- tenant_scope,+ scope_for_agent, scope_for_module, scope_for_profile, tenant_scope, ParsedScope, Principal,+ Scope, Tenant,};use std::future::Future;-use std::sync::{Arc, LazyLock, Mutex, OnceLock, RwLock, mpsc};+use std::sync::{mpsc, Arc, LazyLock, Mutex, OnceLock, RwLock};/// SQLite bindings re-exported by the storage driver crate, for the two/// consumers that open a SQLite file that is not a storage backend: the@@ -187,8 +187,8 @@ impl Blocking {}}-use crate::config::Config;use crate::config::schema::storage::redact_url;+use crate::config::Config;/// The environment variable that overrides `[storage] url`.pub const STORAGE_URL_VAR: &str = "OPENHUMAN_STORAGE_URL";diff --git a/crates/openhuman-core/src/storage/mod_tests.rs b/crates/openhuman-core/src/storage/mod_tests.rsindex 0971a0467c..46d5440dc2 100644--- a/crates/openhuman-core/src/storage/mod_tests.rs+++ b/crates/openhuman-core/src/storage/mod_tests.rs@@ -91,14 +91,12 @@ fn install_installed_and_clear() {assert!(slot.installed().is_none());let backend: Arc<dyn StorageBackend> = Arc::new(tinystoragedrivers::MemoryStorage::new());assert!(slot.install(Arc::clone(&backend)).is_none());- assert!(- slot.installed()- .is_some_and(|got| Arc::ptr_eq(&got, &backend))- );- assert!(- slot.install(Arc::new(tinystoragedrivers::MemoryStorage::new()))- .is_some()- );+ assert!(slot+ .installed()+ .is_some_and(|got| Arc::ptr_eq(&got, &backend)));+ assert!(slot+ .install(Arc::new(tinystoragedrivers::MemoryStorage::new()))+ .is_some());assert!(slot.clear());assert!(!slot.clear());}@@ -106,11 +104,9 @@ fn install_installed_and_clear() {#[test]fn agent_scopes_sit_under_the_local_tenant() {assert_eq!(scope_for_agent("agent-7").as_str(), "local/agent:agent-7");- assert!(- scope_for_agent("has a space")- .as_str()- .starts_with("local/agent:~")- );+ assert!(scope_for_agent("has a space")+ .as_str()+ .starts_with("local/agent:~"));}#[test]@@ -148,11 +144,9 @@ fn a_profile_scopes_storage_over_its_agents() {let odd = scope_for_profile("has a space");assert!(odd.as_str().starts_with("u:~"), "{odd}");assert_ne!(odd, scope_for_profile("has a space"));- assert!(- scope_for_profile(&"x".repeat(400))- .as_str()- .starts_with("u:~")- );+ assert!(scope_for_profile(&"x".repeat(400))+ .as_str()+ .starts_with("u:~"));}#[test]