Skip to content

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

chore: files changed crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents

Steven Enamakel28ab369bef91
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
index b4df1624e4..dde83b8e15 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs
@@ -29,12 +29,12 @@ use serde_json::Value;
use tinyagents_session::transcript::TranscriptMessage;
use tinystoragedrivers::{CollectionSpec, Query, Sort};
-use super::storage_schema::{spec, SESSIONS};
+use super::storage_schema::{SESSIONS, spec};
use super::types::{DurableSubagentSession, DurableSubagentStatus};
+use crate::storage::DocumentStoreExt;
use crate::storage::documents::Repo;
use crate::storage::import_state;
use crate::storage::schema_support::{key_of, ms_rfc3339, rfc3339_ms};
-use crate::storage::DocumentStoreExt;
/// The `tsd.migrations` owner of the legacy-file import.
const OWNER: &str = "subagents";
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
index c49ecd7499..a77bd3291b 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents_tests.rs
@@ -35,10 +35,12 @@ fn session(id: &str) -> DurableSubagentSession {
#[test]
fn a_missing_list_loads_empty() {
- assert!(docs_in(&MemoryStorage::new(), "local")
- .load()
- .unwrap()
- .is_empty());
+ assert!(
+ docs_in(&MemoryStorage::new(), "local")
+ .load()
+ .unwrap()
+ .is_empty()
+ );
}
#[test]
@@ -81,10 +83,11 @@ fn the_store_uses_the_workspace_default_with_no_backend_installed() {
store.save(&[session("a")]).unwrap();
assert_eq!(store.load().unwrap().len(), 1);
// No JSON file store: the records are in the workspace's own database.
- assert!(!dir
- .path()
- .join(".openhuman/subagent_sessions.json")
- .exists());
+ assert!(
+ !dir.path()
+ .join(".openhuman/subagent_sessions.json")
+ .exists()
+ );
assert!(dir.path().join("storage").exists());
}
@@ -117,10 +120,11 @@ fn the_store_dispatches_to_documents_when_a_backend_is_pinned() {
assert_eq!(store.load().unwrap().len(), 1);
});
assert_eq!(docs.load().unwrap().len(), 1);
- assert!(!dir
- .path()
- .join(".openhuman/subagent_sessions.json")
- .exists());
+ assert!(
+ !dir.path()
+ .join(".openhuman/subagent_sessions.json")
+ .exists()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/artifacts/tiny_store.rs b/crates/openhuman-core/src/artifacts/tiny_store.rs
index 2e06de89e3..a74720d8d8 100644
--- a/crates/openhuman-core/src/artifacts/tiny_store.rs
+++ b/crates/openhuman-core/src/artifacts/tiny_store.rs
@@ -308,7 +308,9 @@ pub fn artifacts_service(
match crate::storage::local::open("artifacts::files", workspace_dir)
.and_then(|opened| opened.scoped())
{
- Ok(scoped) => service.with_file_store(Arc::new(tiny_artifacts::BlobFileStore::new(&scoped))),
+ Ok(scoped) => {
+ service.with_file_store(Arc::new(tiny_artifacts::BlobFileStore::new(&scoped)))
+ }
Err(error) => {
log::warn!("[artifacts] file storage unavailable: {error:#}");
service
diff --git a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs b/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
index d726beb6fc..73cbcf0acb 100644
--- a/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
+++ b/crates/openhuman-core/src/artifacts/tiny_store_tests.rs
@@ -154,16 +154,20 @@ async fn deleting_an_artifact_removes_its_card() {
.await
.unwrap();
let id = saved.record.id;
- assert!(super::super::store::get_artifact(&workspace, &id)
- .await
- .is_ok());
+ assert!(
+ super::super::store::get_artifact(&workspace, &id)
+ .await
+ .is_ok()
+ );
let (removed, notice) = artifacts.delete(&id).await.unwrap();
assert!(removed);
assert!(notice.is_none(), "{notice:?}");
- assert!(super::super::store::get_artifact(&workspace, &id)
- .await
- .is_err());
+ assert!(
+ super::super::store::get_artifact(&workspace, &id)
+ .await
+ .is_err()
+ );
}
struct NoopPublisher;
diff --git a/crates/openhuman-core/src/config/workspace/state.rs b/crates/openhuman-core/src/config/workspace/state.rs
index d2ec48df08..15daa7923f 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::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::{Digest, Sha256};
diff --git a/crates/openhuman-core/src/cron/documents_port.rs b/crates/openhuman-core/src/cron/documents_port.rs
index 838eafcc21..5de3ca4720 100644
--- a/crates/openhuman-core/src/cron/documents_port.rs
+++ b/crates/openhuman-core/src/cron/documents_port.rs
@@ -24,7 +24,7 @@ use std::path::PathBuf;
use std::sync::{Arc, LazyLock};
use anyhow::{Context, Result};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinybus::Result as BusResult;
use tinyflows_bus::schedule::CallbackAddress;
use tinystoragedrivers::StorageBackend;
@@ -34,8 +34,8 @@ use tinystoragedrivers_types::{
};
use crate::config::Config;
-use crate::storage::Scope;
use crate::modules::tinyflows as module;
+use crate::storage::Scope;
/// Schedule-owned collections, including the v1 sources read and retired by
/// the module's v1-to-v2 migration.
diff --git a/crates/openhuman-core/src/cron/documents_port_tests.rs b/crates/openhuman-core/src/cron/documents_port_tests.rs
index 2c077720c5..66dae0ecab 100644
--- a/crates/openhuman-core/src/cron/documents_port_tests.rs
+++ b/crates/openhuman-core/src/cron/documents_port_tests.rs
@@ -187,11 +187,12 @@ async fn shared_schedule_records_are_owner_scoped_and_never_scanned() {
)
.await;
assert!(record.get("error").is_none(), "{record}");
- assert!(docs
- .get("tsd.counters", "cron/runs")
- .await
- .unwrap()
- .is_some());
+ assert!(
+ docs.get("tsd.counters", "cron/runs")
+ .await
+ .unwrap()
+ .is_some()
+ );
let requests = [
json!({"op":"get","collection":"tsd.counters","id":"other/runs"}),
diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents.rs b/crates/openhuman-core/src/desktop/notifications/store_documents.rs
index 3010bd8d51..e36034a374 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::{json, Map, Value};
+use serde_json::{Map, Value, json};
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::{compare_and_swap, text, update_or_insert, Repo};
+use crate::storage::documents::{Repo, compare_and_swap, text, update_or_insert};
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_id, CORE, DEDUP, NOTIFICATIONS, SETTINGS};
+pub(super) use super::storage_schema::{CORE, DEDUP, NOTIFICATIONS, SETTINGS, core_id};
use crate::storage::schema_support::key_of;
/// The `workspace` key of core notifications in the per-workspace default
diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
index ed387c0c77..d3570eeaa6 100644
--- a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
+++ b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
@@ -75,15 +75,21 @@ fn identical_content_within_a_minute_is_skipped() {
assert!(store.insert(&note("a", "slack", "hi", 0), true).unwrap());
assert!(!store.insert(&note("b", "slack", "hi", 0), true).unwrap());
assert!(store.insert(&note("c", "slack", "other", 0), true).unwrap());
- assert!(store
- .exists_recent("slack", Some("acct"), "New message", "hi")
- .unwrap());
- assert!(!store
- .exists_recent("slack", None, "New message", "hi")
- .unwrap());
- assert!(!store
- .exists_recent("gmail", Some("acct"), "New message", "hi")
- .unwrap());
+ assert!(
+ store
+ .exists_recent("slack", Some("acct"), "New message", "hi")
+ .unwrap()
+ );
+ assert!(
+ !store
+ .exists_recent("slack", None, "New message", "hi")
+ .unwrap()
+ );
+ assert!(
+ !store
+ .exists_recent("gmail", Some("acct"), "New message", "hi")
+ .unwrap()
+ );
assert_eq!(ids(&store.list(10, 0, None, None).unwrap()).len(), 2);
}
@@ -105,9 +111,11 @@ fn content_older_than_the_window_is_not_a_duplicate() {
.map(|_| ())
})
.unwrap();
- assert!(!store
- .exists_recent("slack", Some("acct"), "New message", "hi")
- .unwrap());
+ assert!(
+ !store
+ .exists_recent("slack", Some("acct"), "New message", "hi")
+ .unwrap()
+ );
assert!(store.insert(&note("b", "slack", "hi", 0), true).unwrap());
}
@@ -116,16 +124,22 @@ fn dedup_follows_arrival_not_the_notifications_own_timestamp() {
let store = docs();
// A delayed event (stamped two minutes ago) and a future-dated one both
// arrived now, so identical content right after is a duplicate either way.
- assert!(store
- .insert(&note("a", "slack", "late", 120), true)
- .unwrap());
+ assert!(
+ store
+ .insert(&note("a", "slack", "late", 120), true)
+ .unwrap()
+ );
assert!(!store.insert(&note("b", "slack", "late", 0), true).unwrap());
- assert!(store
- .insert(&note("c", "slack", "future", -3600), true)
- .unwrap());
- assert!(!store
- .insert(&note("d", "slack", "future", 0), true)
- .unwrap());
+ assert!(
+ store
+ .insert(&note("c", "slack", "future", -3600), true)
+ .unwrap()
+ );
+ assert!(
+ !store
+ .insert(&note("d", "slack", "future", 0), true)
+ .unwrap()
+ );
}
#[test]
@@ -135,37 +149,47 @@ fn a_failed_insert_releases_its_dedup_claim() {
.insert(&note("taken", "slack", "first", 0), false)
.unwrap();
// Same id, new content: the claim succeeds, the notification put fails.
- assert!(store
- .insert(&note("taken", "slack", "second", 0), true)
- .is_err());
+ assert!(
+ store
+ .insert(&note("taken", "slack", "second", 0), true)
+ .is_err()
+ );
assert!(
!store
.exists_recent("slack", Some("acct"), "New message", "second")
.unwrap(),
"the claim was rolled back"
);
- assert!(store
- .insert(&note("fresh", "slack", "second", 0), true)
- .unwrap());
+ assert!(
+ store
+ .insert(&note("fresh", "slack", "second", 0), true)
+ .unwrap()
+ );
}
#[test]
fn workspaces_keep_core_notifications_apart() {
let store = docs();
- assert!(store
- .insert_core_notification("/workspace/a", &event("e", 1))
- .unwrap());
- assert!(store
- .insert_core_notification("/workspace/b", &event("e", 2))
- .unwrap());
+ assert!(
+ store
+ .insert_core_notification("/workspace/a", &event("e", 1))
+ .unwrap()
+ );
+ assert!(
+ store
+ .insert_core_notification("/workspace/b", &event("e", 2))
+ .unwrap()
+ );
let a = store
.list_core_notifications("/workspace/a", false, 10)
.unwrap();
assert_eq!(a.len(), 1);
assert_eq!(a[0].timestamp_ms, 1);
- assert!(store
- .mark_core_notification_read("/workspace/a", "e")
- .unwrap());
+ assert!(
+ store
+ .mark_core_notification_read("/workspace/a", "e")
+ .unwrap()
+ );
assert_eq!(
store
.unread_core_notification_count("/workspace/a")
@@ -178,9 +202,11 @@ fn workspaces_keep_core_notifications_apart() {
.unwrap(),
1
);
- assert!(!store
- .mark_core_notification_read("/workspace/c", "e")
- .unwrap());
+ assert!(
+ !store
+ .mark_core_notification_read("/workspace/c", "e")
+ .unwrap()
+ );
}
#[test]
@@ -221,9 +247,11 @@ fn triage_status_and_score_filter() {
assert_eq!(store.unread_count().unwrap(), 3);
assert!(store.set_status("low", NotificationStatus::Read).unwrap());
assert!(store.set_status("high", NotificationStatus::Acted).unwrap());
- assert!(!store
- .set_status("missing", NotificationStatus::Dismissed)
- .unwrap());
+ assert!(
+ !store
+ .set_status("missing", NotificationStatus::Dismissed)
+ .unwrap()
+ );
assert_eq!(store.unread_count().unwrap(), 1);
let stats = store.stats().unwrap();
@@ -278,10 +306,12 @@ fn core_notifications_persist_once_and_mark_read() {
["a"]
);
assert_eq!(store.unread_core_notification_count(WS).unwrap(), 1);
- assert!(store
- .list_core_notifications(WS, false, 0)
- .unwrap()
- .is_empty());
+ assert!(
+ store
+ .list_core_notifications(WS, false, 0)
+ .unwrap()
+ .is_empty()
+ );
}
#[test]
@@ -329,9 +359,10 @@ fn scopes_keep_notifications_apart() {
.unwrap();
let bob = docs_in(&storage, "bob");
assert!(bob.list(10, 0, None, None).unwrap().is_empty());
- assert!(!bob
- .exists_recent("slack", Some("acct"), "New message", "hi")
- .unwrap());
+ assert!(
+ !bob.exists_recent("slack", Some("acct"), "New message", "hi")
+ .unwrap()
+ );
assert!(bob.insert(&note("a", "slack", "hi", 0), true).unwrap());
}
diff --git a/crates/openhuman-core/src/flows/catalog_storage.rs b/crates/openhuman-core/src/flows/catalog_storage.rs
index 1b0b980da9..658cbb8c37 100644
--- a/crates/openhuman-core/src/flows/catalog_storage.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage.rs
@@ -29,9 +29,9 @@ use tinystoragedrivers_types::{
};
use crate::config::Config;
-use crate::storage::Scope;
use crate::core::runtime::DispatchCtx;
use crate::modules::tinyflows as module;
+use crate::storage::Scope;
/// A callback scope captured from a dispatch, with no ambient identity or
/// backend handle retained. The workspace backend is resolved for each call.
diff --git a/crates/openhuman-core/src/inbound/settings.rs b/crates/openhuman-core/src/inbound/settings.rs
index a00ab649ae..0085fe5f8e 100644
--- a/crates/openhuman-core/src/inbound/settings.rs
+++ b/crates/openhuman-core/src/inbound/settings.rs
@@ -10,7 +10,7 @@
use std::path::Path;
use std::sync::{Arc, RwLock};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinyeventqueues_bus::storage::{SHIPPED_PIPELINE_JSON, SHIPPED_QUEUES_JSON};
use tinyeventqueues_bus::{Lane, PipelineConfig};
use tinystoragedrivers::QueueConfig;
diff --git a/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
index f5ccc4cdf1..9f191ad70e 100644
--- a/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
@@ -6,8 +6,8 @@ use serde::Deserialize;
use serde_json::{Map, Value};
use super::{deserialize_params, to_json};
-use crate::core::all::ControllerFuture;
use crate::core::Outcome;
+use crate::core::all::ControllerFuture;
#[derive(Debug, Deserialize)]
pub(super) struct InferenceClaudeCodeSetFullAccessParams {
@@ -55,7 +55,9 @@ pub(super) fn handle_inference_claude_code_settings(
.map_err(|error| error.to_string())?;
let scoped = opened.scoped().map_err(|error| error.to_string())?;
let kv = settings::store(scoped.documents()).map_err(|error| error.to_string())?;
- let settings = settings::load(&kv).await.map_err(|error| error.to_string())?;
+ let settings = settings::load(&kv)
+ .await
+ .map_err(|error| error.to_string())?;
log::debug!(
"[rpc][inference.claude_code_settings] full_access={}",
settings.full_access
diff --git a/crates/openhuman-core/src/inference/tokenjuice/focus.rs b/crates/openhuman-core/src/inference/tokenjuice/focus.rs
index 636669d56b..568c4301a5 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/focus.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/focus.rs
@@ -8,7 +8,7 @@
use serde_json::Value;
-use tinyjuice_bus::tools::{summary_focus_property, SUMMARY_FOCUS_ARG};
+use tinyjuice_bus::tools::{SUMMARY_FOCUS_ARG, summary_focus_property};
/// Whether a tool's parameter schema declares TinyJuice's `summary_focus`,
/// as opposed to a parameter of its own that happens to share the name.
diff --git a/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs
index 33180e7a1c..351fc7c29f 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs
@@ -33,10 +33,12 @@ fn arguments_without_a_focus_are_untouched() {
fn the_property_is_an_optional_string() {
let property = summary_focus_property();
assert_eq!(property["type"], "string");
- assert!(property["description"]
- .as_str()
- .unwrap()
- .contains("summarized"));
+ assert!(
+ property["description"]
+ .as_str()
+ .unwrap()
+ .contains("summarized")
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
index d48777c017..323ad90317 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
@@ -49,9 +49,11 @@ async fn the_module_defers_a_summary_until_requested() {
.await;
assert_eq!(output.summarized_from_bytes, None);
- assert!(!output
- .text
- .contains("the rate limit is 60 requests a minute"));
+ assert!(
+ !output
+ .text
+ .contains("the rate limit is 60 requests a minute")
+ );
assert!(
output.text.contains(tinyjuice_bus::tools::RETRIEVE),
"the original stays retrievable: {}",
diff --git a/crates/openhuman-core/src/inference/tokenjuice/tools.rs b/crates/openhuman-core/src/inference/tokenjuice/tools.rs
index e757e6e143..44de5738b8 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/tools.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/tools.rs
@@ -9,7 +9,7 @@
//! Read-only, no side effects, no path/network access.
use async_trait::async_trait;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinytools::{PermissionLevel, Tool, ToolResult};
use {tinyjuice_bus::wire::RangeUnit, tinyjuice_bus::wire::RetrieveRange};
diff --git a/crates/openhuman-core/src/media/generation/artifact_tool.rs b/crates/openhuman-core/src/media/generation/artifact_tool.rs
index afe3dc536e..e28435ca05 100644
--- a/crates/openhuman-core/src/media/generation/artifact_tool.rs
+++ b/crates/openhuman-core/src/media/generation/artifact_tool.rs
@@ -30,21 +30,21 @@ use std::sync::Arc;
use async_trait::async_trait;
use futures_util::StreamExt;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinytools::{
PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolContent, ToolPolicy, ToolResult,
ToolRunContext, ToolScope, ToolTimeout,
};
use tokio::io::AsyncWriteExt;
-use crate::artifacts::production::Production;
use crate::artifacts::ArtifactKind;
+use crate::artifacts::production::Production;
use crate::security::approval::ApprovalChatContext;
use crate::tools::host_extensions::tool_call_id;
use tinyagents_harness::tinyinference_video::ProgressFn;
use tinystoragedrivers_api::BlobStore;
-use super::progress::{video_status_observer, JobStateSlot};
+use super::progress::{JobStateSlot, video_status_observer};
const FILE_REFERENCE_FIELDS: [&str; 8] = [
"references",
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 919b67df3c..b3430b01c4 100644
--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
@@ -1,12 +1,12 @@
use async_trait::async_trait;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use std::path::Path;
use std::sync::Arc;
use tinyagents_harness::media::MediaOutput;
use tinystoragedrivers::BlobStore;
use tinytools::{PermissionLevel, Tool, ToolCategory, ToolContent, ToolResult};
-use super::{copy_blob_to_file, has_reusable_files_reference, MediaArtifactTool};
+use super::{MediaArtifactTool, copy_blob_to_file, has_reusable_files_reference};
use crate::artifacts::{ArtifactKind, ArtifactStatus, FileRoots};
#[test]
@@ -62,10 +62,11 @@ async fn artifact_history_refresh_failure_fails_closed_for_cached_files() {
.with_reference_allowlist(Arc::clone(&allowed));
assert!(allowed.lock().unwrap().contains(&replacement));
- assert!(tool
- .execute(json!({ "references": [replacement.to_string_lossy()] }))
- .await
- .is_err());
+ assert!(
+ tool.execute(json!({ "references": [replacement.to_string_lossy()] }))
+ .await
+ .is_err()
+ );
}
struct PartialThenFail(bool);
@@ -222,11 +223,13 @@ async fn files_a_blob_backed_generated_artifact() {
Some(format!("Saved image at {}\nCost: $0.01", canonical_file.display()).as_str())
);
assert_eq!(std::fs::read(&file).unwrap(), b"blob-media-bytes");
- assert!(blobs
- .get("generated-media/stub-0.png")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ blobs
+ .get("generated-media/stub-0.png")
+ .await
+ .unwrap()
+ .is_none()
+ );
let (_, failed_file) = crate::artifacts::create_artifact_for_call(
&workspace,
@@ -289,13 +292,15 @@ async fn files_a_blob_backed_generated_artifact() {
"failed regeneration retains the previous non-empty file"
);
fresh.refresh_allowed_references().await.unwrap();
- assert!(!fresh
- .allowed_references
- .as_ref()
- .unwrap()
- .lock()
- .unwrap()
- .contains(&canonical_file));
+ assert!(
+ !fresh
+ .allowed_references
+ .as_ref()
+ .unwrap()
+ .lock()
+ .unwrap()
+ .contains(&canonical_file)
+ );
}
#[tokio::test]
@@ -433,10 +438,11 @@ async fn files_every_artifact_when_n_greater_than_one() {
.await
.expect("artifact metadata is persisted");
assert_eq!(meta.status, ArtifactStatus::Ready);
- assert!(meta
- .file
- .as_deref()
- .is_some_and(|file| std::path::Path::new(file).exists()));
+ assert!(
+ meta.file
+ .as_deref()
+ .is_some_and(|file| std::path::Path::new(file).exists())
+ );
}
}
diff --git a/crates/openhuman-core/src/media/generation/tools.rs b/crates/openhuman-core/src/media/generation/tools.rs
index d8209dfd3b..983b2844aa 100644
--- a/crates/openhuman-core/src/media/generation/tools.rs
+++ b/crates/openhuman-core/src/media/generation/tools.rs
@@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
use async_trait::async_trait;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinyagents_harness::media::{GenerateImageTool, GenerateVideoTool, MediaOutput};
use tinyagents_harness::tinyinference_image::ImageGenerator;
use tinyagents_harness::tinyinference_video::{VideoGenerator, WaitPolicy};
@@ -292,7 +292,7 @@ impl Tool for MediaListModelsTool {
Err(error) => {
return Ok(ToolResult::error(format!(
"Listing image models failed: {error}"
- )))
+ )));
}
}
}
@@ -312,7 +312,7 @@ impl Tool for MediaListModelsTool {
Err(error) => {
return Ok(ToolResult::error(format!(
"Listing video models failed: {error}"
- )))
+ )));
}
}
}
diff --git a/crates/openhuman-core/src/media/generation/tools_tests.rs b/crates/openhuman-core/src/media/generation/tools_tests.rs
index 998dab33e7..6b676e14ef 100644
--- a/crates/openhuman-core/src/media/generation/tools_tests.rs
+++ b/crates/openhuman-core/src/media/generation/tools_tests.rs
@@ -8,7 +8,7 @@ use tinyagents_harness::tinyinference_video::{MockVideoGenerator, MockVideoScrip
use tinytools::{PermissionLevel, Tool, ToolCategory};
use super::{
- media_tools_from, reference_policy, IMAGE_TOOL_NAME, LIST_MODELS_TOOL_NAME, VIDEO_TOOL_NAME,
+ IMAGE_TOOL_NAME, LIST_MODELS_TOOL_NAME, VIDEO_TOOL_NAME, media_tools_from, reference_policy,
};
use crate::media::generation::MediaGenerators;
diff --git a/crates/openhuman-core/src/modules/site_memory_host.rs b/crates/openhuman-core/src/modules/site_memory_host.rs
index 3deb65543e..f507c8037b 100644
--- a/crates/openhuman-core/src/modules/site_memory_host.rs
+++ b/crates/openhuman-core/src/modules/site_memory_host.rs
@@ -20,8 +20,8 @@ use std::time::UNIX_EPOCH;
use tinybus::ObjectPath;
use tinycomputer_bus::site_memory::{
- ForgetSiteRequest, ForgetSiteResponse, LoadSiteRequest, LoadSiteResponse, SaveSiteRequest,
- SaveSiteResponse, SiteMemory, INTERFACE, OBJECT_PATH,
+ ForgetSiteRequest, ForgetSiteResponse, INTERFACE, LoadSiteRequest, LoadSiteResponse,
+ OBJECT_PATH, SaveSiteRequest, SaveSiteResponse, SiteMemory,
};
/// Largest site file read or written: anything bigger was not written here.
diff --git a/crates/openhuman-core/src/modules/site_memory_host_tests.rs b/crates/openhuman-core/src/modules/site_memory_host_tests.rs
index c88ba44421..c3a1f15df5 100644
--- a/crates/openhuman-core/src/modules/site_memory_host_tests.rs
+++ b/crates/openhuman-core/src/modules/site_memory_host_tests.rs
@@ -22,10 +22,12 @@ async fn saved_memory_loads_back_and_empty_save_removes_the_site() {
let back = store.load("example.com").await.unwrap();
assert_eq!(back, memory());
let _: &SavedHint = &back.hints[0];
- assert!(store
- .save("example.com", &SiteMemory::default())
- .await
- .unwrap());
+ assert!(
+ store
+ .save("example.com", &SiteMemory::default())
+ .await
+ .unwrap()
+ );
assert!(store.load("example.com").await.unwrap().is_empty());
}
diff --git a/crates/openhuman-core/src/skills/run_log.rs b/crates/openhuman-core/src/skills/run_log.rs
index c5a6e71f55..b0459cd565 100644
--- a/crates/openhuman-core/src/skills/run_log.rs
+++ b/crates/openhuman-core/src/skills/run_log.rs
@@ -23,7 +23,7 @@ use tokio_util::sync::CancellationToken;
use crate::progress::AgentProgress;
use crate::storage::StorageError;
-pub use tinyskills::run_log::{detect_repeated_line, RunLogSlice, RunOutcome};
+pub use tinyskills::run_log::{RunLogSlice, RunOutcome, detect_repeated_line};
use tinyskills::run_log::{parse_runs, parse_terminal_outcome, short, truncate};
type RunLogStore = tinyskills_drivers::StreamRunLogStore;
diff --git a/crates/openhuman-core/src/skills/run_log_tests.rs b/crates/openhuman-core/src/skills/run_log_tests.rs
index 7ec4e5eb0e..2b0fd1bdce 100644
--- a/crates/openhuman-core/src/skills/run_log_tests.rs
+++ b/crates/openhuman-core/src/skills/run_log_tests.rs
@@ -16,17 +16,21 @@ fn run_cancel_registry_roundtrip() {
#[test]
fn noisy_events_are_skipped_steps_are_kept() {
- assert!(format_event(&AgentProgress::TextDelta {
- delta: "hi".into(),
- iteration: 1
- })
- .is_none());
+ assert!(
+ format_event(&AgentProgress::TextDelta {
+ delta: "hi".into(),
+ iteration: 1
+ })
+ .is_none()
+ );
// Content (prompt/reply) rides its own event and is never logged here.
- assert!(format_event(&AgentProgress::TurnContent {
- input: Some("secret prompt".into()),
- output: Some("secret reply".into()),
- })
- .is_none());
+ assert!(
+ format_event(&AgentProgress::TurnContent {
+ input: Some("secret prompt".into()),
+ output: Some("secret reply".into()),
+ })
+ .is_none()
+ );
let line = format_event(&AgentProgress::ToolCallStarted {
call_id: "c1".into(),
tool_name: "memory_search".into(),
diff --git a/crates/openhuman-core/src/storage/agents.rs b/crates/openhuman-core/src/storage/agents.rs
index 0122d2f211..53d2d6bf71 100644
--- a/crates/openhuman-core/src/storage/agents.rs
+++ b/crates/openhuman-core/src/storage/agents.rs
@@ -28,11 +28,11 @@ use std::collections::{BTreeMap, HashSet};
use std::future::Future;
use std::sync::{Arc, LazyLock, Mutex};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinystoragedrivers::{CollectionSpec, Precondition, Query};
use super::schema_support::key_of;
-use super::{block_on, installed, DocumentStoreExt, StorageBackend};
+use super::{DocumentStoreExt, StorageBackend, block_on, installed};
use crate::core::runtime::{AgentContextRegistry, CoreContext, DispatchCtx};
/// The `local`-scope collection recording which agents have their own scope.
@@ -98,11 +98,7 @@ fn record_in(backend: Arc<dyn StorageBackend>, agent: &str) {
}
let id = agent.to_string();
let result = block_on(async move {
- let docs = Arc::clone(
- backend
- .for_scope(&super::Scope::local())?
- .documents(),
- );
+ let docs = Arc::clone(backend.for_scope(&super::Scope::local())?.documents());
docs.ensure_collection(&CollectionSpec::new(AGENTS)).await?;
docs.put(
AGENTS,
@@ -130,11 +126,7 @@ fn record_in(backend: Arc<dyn StorageBackend>, agent: &str) {
/// Agent ids recorded in the backend by this or an earlier process.
fn recorded(backend: Arc<dyn StorageBackend>) -> Vec<String> {
let result = block_on(async move {
- let docs = Arc::clone(
- backend
- .for_scope(&super::Scope::local())?
- .documents(),
- );
+ let docs = Arc::clone(backend.for_scope(&super::Scope::local())?.documents());
docs.ensure_collection(&CollectionSpec::new(AGENTS)).await?;
let stored = docs.query_all(AGENTS, &Query::all()).await?;
Ok(stored
diff --git a/crates/openhuman-core/src/storage/agents_tests.rs b/crates/openhuman-core/src/storage/agents_tests.rs
index 2e7ecff80a..3f26664b8d 100644
--- a/crates/openhuman-core/src/storage/agents_tests.rs
+++ b/crates/openhuman-core/src/storage/agents_tests.rs
@@ -119,10 +119,12 @@ fn reset_recorded_empties_the_cache() {
let backend = memory_backend();
record_in(Arc::clone(&backend), "agents-test-reset");
reset_recorded();
- assert!(!RECORDED
- .lock()
- .unwrap()
- .contains(&(backend_key(&backend), "agents-test-reset".to_string())));
+ assert!(
+ !RECORDED
+ .lock()
+ .unwrap()
+ .contains(&(backend_key(&backend), "agents-test-reset".to_string()))
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/storage/config.rs b/crates/openhuman-core/src/storage/config.rs
index e5f5b424cc..7ef6a48ec6 100644
--- a/crates/openhuman-core/src/storage/config.rs
+++ b/crates/openhuman-core/src/storage/config.rs
@@ -26,8 +26,8 @@
use std::path::Path;
-use crate::config::schema::profile_layout::{LayoutVersion, ProfileLayout};
use crate::config::Config;
+use crate::config::schema::profile_layout::{LayoutVersion, ProfileLayout};
/// The directory under the workspace the v1 default backend lives in.
pub const DEFAULT_DIR: &str = "storage";
diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rs
index bc85ce177a..0b494a9c9e 100644
--- a/crates/openhuman-core/src/storage/documents.rs
+++ b/crates/openhuman-core/src/storage/documents.rs
@@ -12,13 +12,13 @@ use std::collections::HashMap;
use std::future::Future;
use std::sync::{Arc, LazyLock, Mutex, PoisonError, Weak};
-use anyhow::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
use serde_json::Value;
use tinystoragedrivers::WriteCondition;
use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition, Versioned};
use super::{
- block_on, current_scope, installed, DocumentStore, Scope, Storage, StorageBackend, StorageError,
+ DocumentStore, Scope, Storage, StorageBackend, StorageError, block_on, current_scope, installed,
};
/// 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.rs
index c6ae455419..7d3857565c 100644
--- a/crates/openhuman-core/src/storage/documents_tests.rs
+++ b/crates/openhuman-core/src/storage/documents_tests.rs
@@ -186,9 +186,10 @@ 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/fence.rs b/crates/openhuman-core/src/storage/fence.rs
index 6a50ef819a..786de7cb55 100644
--- a/crates/openhuman-core/src/storage/fence.rs
+++ b/crates/openhuman-core/src/storage/fence.rs
@@ -59,8 +59,8 @@ use std::sync::{Arc, LazyLock, Mutex, PoisonError, Weak};
use tinystoragedrivers_types::WriteCondition;
-use super::lease::LeaseStore;
use super::StorageError;
+use super::lease::LeaseStore;
/// Why a fenced write was refused.
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
diff --git a/crates/openhuman-core/src/storage/fence_tests.rs b/crates/openhuman-core/src/storage/fence_tests.rs
index 9d2f0e2bff..235d4571ca 100644
--- a/crates/openhuman-core/src/storage/fence_tests.rs
+++ b/crates/openhuman-core/src/storage/fence_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::storage::lease::{DocumentLeases, LeaseError, LeaseGrant, LeaseRecord};
use crate::storage::MemoryStorage;
+use crate::storage::lease::{DocumentLeases, LeaseError, LeaseGrant, LeaseRecord};
use std::time::Duration;
const TTL: Duration = Duration::from_secs(30);
diff --git a/crates/openhuman-core/src/storage/fenced_backend_tests.rs b/crates/openhuman-core/src/storage/fenced_backend_tests.rs
index f0ea8c2004..f872801a7d 100644
--- a/crates/openhuman-core/src/storage/fenced_backend_tests.rs
+++ b/crates/openhuman-core/src/storage/fenced_backend_tests.rs
@@ -6,8 +6,8 @@ use crate::storage::fence::{FenceError, LeaseFence, ScopeMatch};
use crate::storage::lease::{DocumentLeases, LeaseGrant, LeaseStore};
use serde_json::json;
use std::sync::{
- atomic::{AtomicU64, Ordering},
Arc,
+ atomic::{AtomicU64, Ordering},
};
use std::time::Duration;
use tinystoragedrivers_api::StorageBackend as _;
@@ -112,12 +112,14 @@ async fn cached_handles_enforce_local_expiry_margin_and_accept_same_epoch_renewa
fence_error(&error),
Some(FenceError::Expired { .. })
));
- assert!(storage
- .documents()
- .get("items", "too-late")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ storage
+ .documents()
+ .get("items", "too-late")
+ .await
+ .unwrap()
+ .is_none()
+ );
}
#[tokio::test]
@@ -160,39 +162,45 @@ async fn a_cached_handle_cannot_mutate_after_cross_process_takeover_on_any_port(
// A's local clock is deliberately behind. The local precheck succeeds;
// the driver's atomic condition is what refuses each cached-handle write.
a.set_now(1_000);
- assert!(storage
- .documents()
- .put("items", "late", json!({}), Precondition::Absent)
- .await
- .is_err());
+ assert!(
+ storage
+ .documents()
+ .put("items", "late", json!({}), Precondition::Absent)
+ .await
+ .is_err()
+ );
assert!(storage.streams().append("events", json!(1)).await.is_err());
- assert!(storage
- .blobs()
- .put("blob", b"x".to_vec(), None)
- .await
- .is_err());
+ assert!(
+ storage
+ .blobs()
+ .put("blob", b"x".to_vec(), None)
+ .await
+ .is_err()
+ );
assert!(storage.kv().put("key", json!(1)).await.is_err());
assert!(storage.queues().ack("work", &receipt).await.is_err());
let raw = shared
.for_scope(&Scope::new("profile:alice").unwrap())
.unwrap();
- assert!(raw
- .documents()
- .get("items", "late")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ raw.documents()
+ .get("items", "late")
+ .await
+ .unwrap()
+ .is_none()
+ );
assert_eq!(raw.streams().len("events").await.unwrap(), 0);
assert!(raw.blobs().get("blob").await.unwrap().is_none());
assert!(raw.kv().get("key").await.unwrap().is_none());
assert_eq!(raw.queues().stats("work").await.unwrap().leased, 1);
- assert!(raw
- .documents()
- .get("items", "kept")
- .await
- .unwrap()
- .is_some());
+ assert!(
+ raw.documents()
+ .get("items", "kept")
+ .await
+ .unwrap()
+ .is_some()
+ );
}
#[tokio::test]
@@ -207,19 +215,23 @@ async fn a_manually_latched_cached_fence_refuses_mutations_before_driver_io() {
.await
.unwrap();
fence.fence();
- assert!(storage
- .documents()
- .put("items", "late", json!({}), Precondition::Absent)
- .await
- .is_err());
- assert!(shared
- .for_scope(&Scope::new("profile:alice").unwrap())
- .unwrap()
- .documents()
- .get("items", "late")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ storage
+ .documents()
+ .put("items", "late", json!({}), Precondition::Absent)
+ .await
+ .is_err()
+ );
+ assert!(
+ shared
+ .for_scope(&Scope::new("profile:alice").unwrap())
+ .unwrap()
+ .documents()
+ .get("items", "late")
+ .await
+ .unwrap()
+ .is_none()
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/storage/fenced_ports.rs b/crates/openhuman-core/src/storage/fenced_ports.rs
index ee713c7d03..6068c1194e 100644
--- a/crates/openhuman-core/src/storage/fenced_ports.rs
+++ b/crates/openhuman-core/src/storage/fenced_ports.rs
@@ -9,20 +9,19 @@ use std::{ops::Range, sync::Arc, time::Duration};
use async_trait::async_trait;
use serde_json::Value;
use tinystoragedrivers_api::{
- BlobReader, BlobStore, BlobStream, DocumentStore, DocumentWatch, KvStore, QueueStore,
- Storage, StreamStore,
+ BlobReader, BlobStore, BlobStream, DocumentStore, DocumentWatch, KvStore, QueueStore, Storage,
+ StreamStore,
};
use tinystoragedrivers_types::{
- Blob, BlobMeta, Capabilities, Capability, CollectionSpec, Cursor, DeadLetter,
- Delivery, Enqueued, Filter, NewMessage, Page, Precondition, Query, QueueFeatures, QueueSpec,
- QueueStats, ReadCheck, Receipt, Result, Retry, SealOutcome, SearchHit, Sort, StreamEntry,
- StreamInfo, TreeEntry, TreeFile, Version, Versioned, WatchOptions, WriteOp, WriteOptions,
- WriteResult,
+ Blob, BlobMeta, Capabilities, Capability, CollectionSpec, Cursor, DeadLetter, Delivery,
+ Enqueued, Filter, NewMessage, Page, Precondition, Query, QueueFeatures, QueueSpec, QueueStats,
+ ReadCheck, Receipt, Result, Retry, SealOutcome, SearchHit, Sort, StreamEntry, StreamInfo,
+ TreeEntry, TreeFile, Version, Versioned, WatchOptions, WriteOp, WriteOptions, WriteResult,
};
use super::{
- fence::{FenceRegistry, LeaseFence},
StorageError,
+ fence::{FenceRegistry, LeaseFence},
};
fn check(fence: &LeaseFence, clock: &FenceRegistry) -> Result<()> {
@@ -68,7 +67,9 @@ struct GuardedDocuments {
clock: Arc<FenceRegistry>,
}
impl std::fmt::Debug for GuardedDocuments {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GuardedDocuments").finish_non_exhaustive() }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("GuardedDocuments").finish_non_exhaustive()
+ }
}
#[async_trait]
impl DocumentStore for GuardedDocuments {
@@ -157,7 +158,9 @@ struct GuardedStreams {
clock: Arc<FenceRegistry>,
}
impl std::fmt::Debug for GuardedStreams {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GuardedStreams").finish_non_exhaustive() }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("GuardedStreams").finish_non_exhaustive()
+ }
}
#[async_trait]
impl StreamStore for GuardedStreams {
@@ -212,7 +215,9 @@ struct GuardedKv {
clock: Arc<FenceRegistry>,
}
impl std::fmt::Debug for GuardedKv {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GuardedKv").finish_non_exhaustive() }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("GuardedKv").finish_non_exhaustive()
+ }
}
#[async_trait]
impl KvStore for GuardedKv {
@@ -249,7 +254,9 @@ struct GuardedBlobs {
clock: Arc<FenceRegistry>,
}
impl std::fmt::Debug for GuardedBlobs {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GuardedBlobs").finish_non_exhaustive() }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("GuardedBlobs").finish_non_exhaustive()
+ }
}
#[async_trait]
impl BlobStore for GuardedBlobs {
@@ -374,7 +381,9 @@ struct GuardedQueues {
clock: Arc<FenceRegistry>,
}
impl std::fmt::Debug for GuardedQueues {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GuardedQueues").finish_non_exhaustive() }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("GuardedQueues").finish_non_exhaustive()
+ }
}
#[async_trait]
impl QueueStore for GuardedQueues {
diff --git a/crates/openhuman-core/src/storage/host_migration_tests.rs b/crates/openhuman-core/src/storage/host_migration_tests.rs
index 6f5e6af3d6..b55df601d6 100644
--- a/crates/openhuman-core/src/storage/host_migration_tests.rs
+++ b/crates/openhuman-core/src/storage/host_migration_tests.rs
@@ -4,7 +4,7 @@
use std::sync::Arc;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinystoragedrivers::schema::Migrations;
use tinystoragedrivers::{
DocumentStore, DocumentStoreExt, Kv, MemoryStorage, Precondition, Query, Scope, ScopedStorage,
@@ -242,10 +242,12 @@ async fn the_host_domains_v1_records_arrive_in_the_v2_collections() {
get(&docs, "task_sources.ingested", "src/ext").await["ingested_ms"],
8000
);
- assert!(get(&docs, "artifacts.records", "art-1")
- .await
- .get("created_at")
- .is_none());
+ assert!(
+ get(&docs, "artifacts.records", "art-1")
+ .await
+ .get("created_at")
+ .is_none()
+ );
assert_eq!(
get(&docs, "artifacts.args", "art-1").await,
json!({ "prompt": "x" })
@@ -254,9 +256,11 @@ async fn the_host_domains_v1_records_arrive_in_the_v2_collections() {
get(&docs, "artifacts.versions", "art-1").await["versions"][0]["created_ms"],
1
);
- assert!(get(&docs, "cost.records", "c1").await["usage"]
- .get("timestamp")
- .is_none());
+ assert!(
+ get(&docs, "cost.records", "c1").await["usage"]
+ .get("timestamp")
+ .is_none()
+ );
assert_eq!(
get(&docs, "config.documents", "local").await,
json!({ "toml_enc": "enc2:00" })
@@ -304,17 +308,21 @@ async fn the_host_domains_v1_records_arrive_in_the_v2_collections() {
// The older builds' markers are finished imports now.
let migrations = Migrations::new(&scoped);
- assert!(migrations
- .done("storage", &step_id("storage_import", "approval@abcd"))
- .await
- .unwrap());
- assert!(migrations
- .done(
- "threads",
- &step_id("threads_import", "legacy-conversations:k")
- )
- .await
- .unwrap());
+ assert!(
+ migrations
+ .done("storage", &step_id("storage_import", "approval@abcd"))
+ .await
+ .unwrap()
+ );
+ assert!(
+ migrations
+ .done(
+ "threads",
+ &step_id("threads_import", "legacy-conversations:k")
+ )
+ .await
+ .unwrap()
+ );
// A second boot has nothing left to do.
let again = prepare_and_migrate(&backend).await.unwrap();
diff --git a/crates/openhuman-core/src/storage/import/layout_db_tests.rs b/crates/openhuman-core/src/storage/import/layout_db_tests.rs
index 60f232d28e..7ad0aa6f21 100644
--- a/crates/openhuman-core/src/storage/import/layout_db_tests.rs
+++ b/crates/openhuman-core/src/storage/import/layout_db_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::storage::layout::test_fixtures::{fixture_docs, v1_profile};
-use crate::storage::layout::{legacy, Target};
+use crate::storage::layout::{Target, legacy};
use tempfile::TempDir;
#[test]
diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rs
index 20fe6c38d2..3e888df408 100644
--- a/crates/openhuman-core/src/storage/import/mod.rs
+++ b/crates/openhuman-core/src/storage/import/mod.rs
@@ -77,20 +77,20 @@ use std::sync::Arc;
use anyhow::Result;
#[cfg(feature = "legacy-import")]
-use anyhow::{anyhow, Context};
+use anyhow::{Context, anyhow};
#[cfg(feature = "legacy-import")]
use sha2::Digest;
use tinystoragedrivers::CollectionSpec;
#[cfg(feature = "legacy-import")]
use tinystoragedrivers::{ErrorKind, Precondition, WriteOptions};
+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/mod_tests.rs b/crates/openhuman-core/src/storage/import/mod_tests.rs
index d2c948ef41..8809342202 100644
--- a/crates/openhuman-core/src/storage/import/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/import/mod_tests.rs
@@ -258,16 +258,18 @@ fn processes_importing_one_workspace_at_once_import_it_once() {
.filter(|o| matches!(o, Outcome::Imported { .. }))
.count();
assert_eq!(imports, 1, "exactly one process imports: {outcomes:?}");
- assert!(outcomes
- .iter()
- .all(|o| !matches!(o, Outcome::Imported { .. })
- || matches!(
- o,
- Outcome::Imported {
- found: 20,
- written: 20
- }
- )));
+ assert!(
+ outcomes
+ .iter()
+ .all(|o| !matches!(o, Outcome::Imported { .. })
+ || matches!(
+ o,
+ Outcome::Imported {
+ found: 20,
+ written: 20
+ }
+ ))
+ );
assert!(is_done(&backend, &config, &source).unwrap());
assert_eq!(dump(&backend, &source, "devices.paired").len(), 20);
}
@@ -434,9 +436,11 @@ async fn without_an_installed_backend_the_host_import_does_nothing() {
legacy_device(&config, "chan-a", "Phone", false);
assert!(crate::storage::installed().is_none());
- assert!(run(&crate::core::runtime::DispatchCtx::unbound(), &config)
- .await
- .is_empty());
+ assert!(
+ run(&crate::core::runtime::DispatchCtx::unbound(), &config)
+ .await
+ .is_empty()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/storage/import/schemas.rs b/crates/openhuman-core/src/storage/import/schemas.rs
index 66cb2187fe..b3114aff7c 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::{json, Map, Value};
+use serde_json::{Map, Value, json};
-use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::Outcome;
+use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
#[derive(Debug, Deserialize, Default)]
diff --git a/crates/openhuman-core/src/storage/import/scope_move.rs b/crates/openhuman-core/src/storage/import/scope_move.rs
index c7af393689..421dc70c12 100644
--- a/crates/openhuman-core/src/storage/import/scope_move.rs
+++ b/crates/openhuman-core/src/storage/import/scope_move.rs
@@ -9,7 +9,7 @@ use std::collections::HashSet;
use std::path::Path;
use crate::storage::rusqlite::{self, Connection, OpenFlags};
-use anyhow::{bail, Context, Result};
+use anyhow::{Context, Result, bail};
use serde_json::Value;
use tinystoragedrivers::Meta;
diff --git a/crates/openhuman-core/src/storage/import/session_db.rs b/crates/openhuman-core/src/storage/import/session_db.rs
index 56c2090e42..f50428c278 100644
--- a/crates/openhuman-core/src/storage/import/session_db.rs
+++ b/crates/openhuman-core/src/storage/import/session_db.rs
@@ -6,9 +6,9 @@
use std::path::Path;
-use anyhow::{bail, Context, Result};
+use anyhow::{Context, Result, bail};
use serde::de::DeserializeOwned;
-use serde_json::{json, Map, Number, Value};
+use serde_json::{Map, Number, Value, json};
use tinyagents_session::run_ledger::tool_effects::{ToolEffectRow, ToolEffectStatus};
use tinyagents_session::run_ledger::{
AgentRun, AgentTeam, AgentTeamMember, AgentTeamTask, RunEvent, RunTelemetry, WorkflowRun,
diff --git a/crates/openhuman-core/src/storage/import/session_db_tests.rs b/crates/openhuman-core/src/storage/import/session_db_tests.rs
index e43bc11d48..46f0ca3b4f 100644
--- a/crates/openhuman-core/src/storage/import/session_db_tests.rs
+++ b/crates/openhuman-core/src/storage/import/session_db_tests.rs
@@ -2,7 +2,7 @@ use super::*;
use std::path::Path;
-use crate::storage::rusqlite::{params, Connection};
+use crate::storage::rusqlite::{Connection, params};
fn classic_session_file(path: &Path) {
let connection = Connection::open(path).unwrap();
@@ -124,7 +124,9 @@ fn rejects_a_database_without_classic_session_tables() {
let error = SessionDatabase::read(&path).unwrap_err();
- assert!(error
- .to_string()
- .contains("none of the classic session database tables"));
+ assert!(
+ error
+ .to_string()
+ .contains("none of the classic session database tables")
+ );
}
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs b/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
index 3989529f1c..abfe4b32ef 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_reader/flow_reader.rs
@@ -11,7 +11,7 @@ use tinyflows_bus::catalog::{
MAX_IMPORT_RECORD_PAYLOAD_BYTES,
};
-use super::legacy_db::{column_or, LegacyDb};
+use super::legacy_db::{LegacyDb, column_or};
/// Reads legacy flow database rows and draft files as bounded ordered batches.
///
@@ -120,9 +120,9 @@ async fn page_rows<T, ToRecord, F, Fut>(
what: &'static str,
query: &str,
decode: impl Fn(&crate::storage::rusqlite::Row<'_>) -> crate::storage::rusqlite::Result<T>
- + Send
- + Sync
- + 'static,
+ + Send
+ + Sync
+ + 'static,
to_record: ToRecord,
batches: &mut BatchSender,
send: &mut F,
diff --git a/crates/openhuman-core/src/storage/journal_maintenance.rs b/crates/openhuman-core/src/storage/journal_maintenance.rs
index 945552f3c2..3d47ba95ce 100644
--- a/crates/openhuman-core/src/storage/journal_maintenance.rs
+++ b/crates/openhuman-core/src/storage/journal_maintenance.rs
@@ -277,8 +277,8 @@ async fn maintain_scope(
/// by another host. Cluster scope is intentionally excluded: harness run
/// journals have historically been tenant/local data, not cluster data.
#[cfg(test)]
-fn known_scopes(
-) -> Result<(Vec<Arc<crate::profiles::Profile>>, Vec<Scope>), crate::storage::StorageError> {
+fn known_scopes()
+-> Result<(Vec<Arc<crate::profiles::Profile>>, Vec<Scope>), crate::storage::StorageError> {
let mut scopes = BTreeSet::new();
if !crate::core::runtime::mode::is_saas() {
scopes.insert(Scope::local());
diff --git a/crates/openhuman-core/src/storage/journal_maintenance_tests.rs b/crates/openhuman-core/src/storage/journal_maintenance_tests.rs
index 4b28c08d74..d4dbccc885 100644
--- a/crates/openhuman-core/src/storage/journal_maintenance_tests.rs
+++ b/crates/openhuman-core/src/storage/journal_maintenance_tests.rs
@@ -1,10 +1,10 @@
use super::*;
+use tinyagents_harness::HarnessStatusStore;
use tinyagents_harness::events::{AgentEvent, EventSink, HarnessRunStatus};
use tinyagents_harness::ids::{ComponentId, HarnessPhase, RunId};
use tinyagents_harness::observability::replay::read_run_events_page;
use tinyagents_harness::observability::{AgentObservation, HarnessEventJournal, StoreEventJournal};
use tinyagents_harness::store::{AppendStore, DriverAppendStore};
-use tinyagents_harness::HarnessStatusStore;
use tinystoragedrivers_testkit::memory_backend as test_memory_backend;
fn backend() -> Arc<dyn StorageBackend> {
@@ -158,12 +158,14 @@ async fn maintenance_deletes_a_sealed_journal_after_the_configured_retention() {
.unwrap();
assert_eq!(late.deleted, 1);
let storage = backend.for_scope(&Scope::local()).unwrap();
- assert!(storage
- .streams()
- .info(&format!("{JOURNAL_STREAM}/run.old"))
- .await
- .unwrap()
- .is_none());
+ assert!(
+ storage
+ .streams()
+ .info(&format!("{JOURNAL_STREAM}/run.old"))
+ .await
+ .unwrap()
+ .is_none()
+ );
}
#[tokio::test]
@@ -246,14 +248,16 @@ async fn dormant_or_expired_profile_fences_receive_no_journal_maintenance_writes
.await
.unwrap();
assert_eq!(expired.deleted, 0);
- assert!(backend
- .for_scope(&profile_scope)
- .unwrap()
- .streams()
- .info(&stream)
- .await
- .unwrap()
- .is_some());
+ assert!(
+ backend
+ .for_scope(&profile_scope)
+ .unwrap()
+ .streams()
+ .info(&stream)
+ .await
+ .unwrap()
+ .is_some()
+ );
}
#[tokio::test]
@@ -312,15 +316,16 @@ async fn captured_profile_lease_expiry_between_snapshot_and_mutation_refuses_wri
let raw = backend.for_scope(&scope).unwrap();
assert!(raw.streams().info(&stream).await.unwrap().is_some());
- assert!(raw
- .documents()
- .get(
- BACKFILL_COLLECTION,
- &crate::storage::schema_support::key_of("inactive-journal-backfill-v1").unwrap(),
- )
- .await
- .unwrap()
- .is_none());
+ assert!(
+ raw.documents()
+ .get(
+ BACKFILL_COLLECTION,
+ &crate::storage::schema_support::key_of("inactive-journal-backfill-v1").unwrap(),
+ )
+ .await
+ .unwrap()
+ .is_none()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/storage/layout/credentials.rs b/crates/openhuman-core/src/storage/layout/credentials.rs
index a6264b4682..318efbc96b 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.rs
index e4e8499d88..8c93253a37 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::{
- clear_master_key_source, install_master_key_source, MasterKeySource, SecretStorageError,
+ MasterKeySource, SecretStorageError, clear_master_key_source, install_master_key_source,
};
-use crate::storage::layout::test_fixtures::{v1_profile, write, Fixture};
-use crate::storage::layout::{migrate, restore, Options, Outcome};
+use crate::storage::layout::test_fixtures::{Fixture, v1_profile, write};
+use crate::storage::layout::{Options, Outcome, migrate, restore};
use std::sync::Arc;
use tinystoragedrivers::secrets::DerivedKeys;
use zeroize::Zeroizing;
diff --git a/crates/openhuman-core/src/storage/layout/db.rs b/crates/openhuman-core/src/storage/layout/db.rs
index ac49f061d6..4f4ac45686 100644
--- a/crates/openhuman-core/src/storage/layout/db.rs
+++ b/crates/openhuman-core/src/storage/layout/db.rs
@@ -4,4 +4,4 @@
//! the `legacy-import` feature. Layout migration code depends on this narrow
//! wrapper and does not open or query SQLite itself.
-pub use crate::storage::import::layout_db::{checkpoint, copy, table_counts, Counts, DbCopy};
+pub use crate::storage::import::layout_db::{Counts, DbCopy, checkpoint, copy, table_counts};
diff --git a/crates/openhuman-core/src/storage/layout/legacy.rs b/crates/openhuman-core/src/storage/layout/legacy.rs
index 0672c171bf..9b9b5c941d 100644
--- a/crates/openhuman-core/src/storage/layout/legacy.rs
+++ b/crates/openhuman-core/src/storage/layout/legacy.rs
@@ -28,8 +28,8 @@
use std::path::Path;
use std::sync::Arc;
-use super::state::LayoutError;
use super::Target;
+use super::state::LayoutError;
use crate::config::Config;
use crate::storage::{self, StorageBackend};
diff --git a/crates/openhuman-core/src/storage/layout/mod.rs b/crates/openhuman-core/src/storage/layout/mod.rs
index 7be803fcb9..1a2b3d24ab 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::{auto_migrate, migrate, restore, Options};
+pub use run::{Options, auto_migrate, migrate, restore};
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/plan_tests.rs b/crates/openhuman-core/src/storage/layout/plan_tests.rs
index b78fd97b25..c351f88897 100644
--- a/crates/openhuman-core/src/storage/layout/plan_tests.rs
+++ b/crates/openhuman-core/src/storage/layout/plan_tests.rs
@@ -67,10 +67,12 @@ fn scan_classifies_a_v1_workspace_and_totals_it() {
#[test]
fn a_missing_workspace_is_an_empty_plan() {
let dir = tempfile::TempDir::new().unwrap();
- assert!(scan(&dir.path().join("workspace"))
- .unwrap()
- .entries
- .is_empty());
+ assert!(
+ scan(&dir.path().join("workspace"))
+ .unwrap()
+ .entries
+ .is_empty()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/storage/layout/run.rs b/crates/openhuman-core/src/storage/layout/run.rs
index 25dcd93224..d47ffd2182 100644
--- a/crates/openhuman-core/src/storage/layout/run.rs
+++ b/crates/openhuman-core/src/storage/layout/run.rs
@@ -5,9 +5,9 @@ use std::path::{Path, PathBuf};
use super::archive::{self, Source};
use super::plan::{self, Action, Plan};
use super::state::{LayoutError, LayoutState, Lock, Step};
-use super::{db, legacy, DryRun, Noop, Outcome, Report, Target};
-use crate::config::schema::profile_layout::{LayoutVersion, PROFILE_LAYOUT_MARKER};
+use super::{DryRun, Noop, Outcome, Report, Target, db, legacy};
use crate::config::Config;
+use crate::config::schema::profile_layout::{LayoutVersion, PROFILE_LAYOUT_MARKER};
/// How a migration runs.
#[derive(Debug, Clone, Default)]
diff --git a/crates/openhuman-core/src/storage/layout/run_tests.rs b/crates/openhuman-core/src/storage/layout/run_tests.rs
index 080ea6d1b6..05a6c52609 100644
--- a/crates/openhuman-core/src/storage/layout/run_tests.rs
+++ b/crates/openhuman-core/src/storage/layout/run_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::storage::layout::state::STATE_FILE;
-use crate::storage::layout::test_fixtures::{fixture_docs, tree, v1_profile, write, Fixture};
+use crate::storage::layout::test_fixtures::{Fixture, fixture_docs, tree, v1_profile, write};
fn opts() -> Options {
Options::default()
@@ -107,9 +107,11 @@ fn assert_migrated(fx: &Fixture) {
] {
assert!(paths.contains(&want), "{want} not archived: {paths:?}");
}
- assert!(!paths
- .iter()
- .any(|p| p.contains("mystery") || p.contains("notes.tmp")));
+ assert!(
+ !paths
+ .iter()
+ .any(|p| p.contains("mystery") || p.contains("notes.tmp"))
+ );
// the config layer now reads it as v2
let layout = crate::config::schema::ProfileLayout::resolve_at(profile.clone());
assert_eq!(
diff --git a/crates/openhuman-core/src/storage/layout/schemas.rs b/crates/openhuman-core/src/storage/layout/schemas.rs
index 566f2c1d8b..c248311e13 100644
--- a/crates/openhuman-core/src/storage/layout/schemas.rs
+++ b/crates/openhuman-core/src/storage/layout/schemas.rs
@@ -5,7 +5,7 @@
use serde_json::{Map, Value};
-use super::{migrate, restore, status, Options, Target};
+use super::{Options, Target, migrate, restore, status};
use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::runtime::DispatchCtx;
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
@@ -52,8 +52,18 @@ pub fn schemas(function: &str) -> ControllerSchema {
Imports the legacy files, copies and verifies the database, moves user files, archives the originals to \
<root>/backups/<user>-<timestamp>.tar.zst, then deletes only what was archived. Resumable. \
dry_run returns the plan and writes nothing. Stop the core before running it for real.",
- inputs: vec![field("dry_run", TypeSchema::Option(Box::new(TypeSchema::Bool)), "Plan only: list what would be archived, moved, deleted and left alone, with byte totals.", false)],
- outputs: vec![field("result", TypeSchema::String, "noop, dry_run or migrated, with the plan or report alongside.", true)],
+ inputs: vec![field(
+ "dry_run",
+ TypeSchema::Option(Box::new(TypeSchema::Bool)),
+ "Plan only: list what would be archived, moved, deleted and left alone, with byte totals.",
+ false,
+ )],
+ outputs: vec![field(
+ "result",
+ TypeSchema::String,
+ "noop, dry_run or migrated, with the plan or report alongside.",
+ true,
+ )],
},
"status" => ControllerSchema {
namespace: "storage",
@@ -67,15 +77,35 @@ pub fn schemas(function: &str) -> ControllerSchema {
function: "restore",
description: "Put the active profile back to layout v1 from a migration archive: verifies the archive, restores its entries under workspace/, \
sets the v2 storage.db aside and removes the layout marker.",
- inputs: vec![field("archive", TypeSchema::String, "Path of the .tar.zst archive.", true)],
- outputs: vec![field("entries", TypeSchema::U64, "Top-level entries restored.", true)],
+ inputs: vec![field(
+ "archive",
+ TypeSchema::String,
+ "Path of the .tar.zst archive.",
+ true,
+ )],
+ outputs: vec![field(
+ "entries",
+ TypeSchema::U64,
+ "Top-level entries restored.",
+ true,
+ )],
},
_ => ControllerSchema {
namespace: "storage",
function: "unknown",
description: "Unknown storage controller function.",
- inputs: vec![field("function", TypeSchema::String, "Unknown function requested for schema lookup.", true)],
- outputs: vec![field("error", TypeSchema::String, "Lookup error details.", true)],
+ inputs: vec![field(
+ "function",
+ TypeSchema::String,
+ "Unknown function requested for schema lookup.",
+ true,
+ )],
+ outputs: vec![field(
+ "error",
+ TypeSchema::String,
+ "Lookup error details.",
+ true,
+ )],
},
}
}
diff --git a/crates/openhuman-core/src/storage/layout/schemas_tests.rs b/crates/openhuman-core/src/storage/layout/schemas_tests.rs
index 94eeda7166..5c99792414 100644
--- a/crates/openhuman-core/src/storage/layout/schemas_tests.rs
+++ b/crates/openhuman-core/src/storage/layout/schemas_tests.rs
@@ -15,13 +15,17 @@ fn the_three_controllers_are_registered_under_storage() {
]
);
assert_eq!(all_controller_schemas().len(), 3);
- assert!(schemas("restore")
- .inputs
- .iter()
- .any(|f| f.name == "archive" && f.required));
- assert!(schemas("migrate")
- .inputs
- .iter()
- .any(|f| f.name == "dry_run" && !f.required));
+ assert!(
+ schemas("restore")
+ .inputs
+ .iter()
+ .any(|f| f.name == "archive" && f.required)
+ );
+ assert!(
+ schemas("migrate")
+ .inputs
+ .iter()
+ .any(|f| f.name == "dry_run" && !f.required)
+ );
assert_eq!(schemas("nope").function, "unknown");
}
diff --git a/crates/openhuman-core/src/storage/layout/state.rs b/crates/openhuman-core/src/storage/layout/state.rs
index d7f4521298..89e83889e3 100644
--- a/crates/openhuman-core/src/storage/layout/state.rs
+++ b/crates/openhuman-core/src/storage/layout/state.rs
@@ -64,7 +64,9 @@ pub enum LayoutError {
#[error("LAYOUT_LOCKED: another migration holds {0}")]
Locked(PathBuf),
/// The running core serves this profile's v1 database.
- #[error("LAYOUT_LIVE: this process serves {0}; stop the core and migrate offline, or set [storage] auto_migrate_layout and restart")]
+ #[error(
+ "LAYOUT_LIVE: this process serves {0}; stop the core and migrate offline, or set [storage] auto_migrate_layout and restart"
+ )]
Live(String),
/// A test stopped the migration after `Step`'s work, before recording it.
#[error("LAYOUT_CRASH: injected crash after {0:?}")]
diff --git a/crates/openhuman-core/src/storage/layout/status.rs b/crates/openhuman-core/src/storage/layout/status.rs
index 4919940827..0a941ab653 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::{legacy, Target};
-use crate::config::schema::profile_layout::LayoutVersion;
+use super::{Target, legacy};
use crate::config::Config;
+use crate::config::schema::profile_layout::LayoutVersion;
/// 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/layout/test_fixtures.rs b/crates/openhuman-core/src/storage/layout/test_fixtures.rs
index d7962a16b8..c7b0678170 100644
--- a/crates/openhuman-core/src/storage/layout/test_fixtures.rs
+++ b/crates/openhuman-core/src/storage/layout/test_fixtures.rs
@@ -7,7 +7,7 @@ use std::path::Path;
use sha2::Digest;
use tempfile::TempDir;
-use super::{legacy, Target};
+use super::{Target, legacy};
use crate::config::Config;
use crate::storage::{self, DocumentStoreExt, Precondition, Scope};
diff --git a/crates/openhuman-core/src/storage/lease_documents.rs b/crates/openhuman-core/src/storage/lease_documents.rs
index d74eef72c3..173d69abf9 100644
--- a/crates/openhuman-core/src/storage/lease_documents.rs
+++ b/crates/openhuman-core/src/storage/lease_documents.rs
@@ -14,10 +14,10 @@ use tinystoragedrivers_types::{
Filter, Key, Scope as DriverScope, Version, Versioned, WriteCondition, WriteOptions,
};
+use super::StorageError;
use super::lease::{
- validate_key, LeaseError, LeaseGrant, LeaseRecord, LeaseStore, CLUSTER_SCOPE, LEASE_COLLECTION,
+ CLUSTER_SCOPE, LEASE_COLLECTION, LeaseError, LeaseGrant, LeaseRecord, LeaseStore, validate_key,
};
-use super::StorageError;
/// The owner namespace of the host's process-placement lease documents.
pub const LEASE_OWNER: &str = "profiles";
@@ -177,7 +177,9 @@ impl DocumentLeases {
}
fn id(key: &str) -> Result<String, StorageError> {
- Ok(Key::new(format!("{LEASE_OWNER}/{key}"))?.as_str().to_owned())
+ Ok(Key::new(format!("{LEASE_OWNER}/{key}"))?
+ .as_str()
+ .to_owned())
}
async fn read(&self, key: &str) -> Result<Option<Versioned<LeaseBody>>, StorageError> {
diff --git a/crates/openhuman-core/src/storage/lease_local.rs b/crates/openhuman-core/src/storage/lease_local.rs
index 18ea7f9f69..322310a65a 100644
--- a/crates/openhuman-core/src/storage/lease_local.rs
+++ b/crates/openhuman-core/src/storage/lease_local.rs
@@ -25,8 +25,8 @@ use async_trait::async_trait;
use fs2::FileExt;
use tinystoragedrivers::Version;
-use super::lease::{local_dir, validate_key, LeaseError, LeaseGrant, LeaseRecord, LeaseStore};
use super::StorageError;
+use super::lease::{LeaseError, LeaseGrant, LeaseRecord, LeaseStore, local_dir, validate_key};
const LOCK_FILE: &str = ".lease";
const RECORD_FILE: &str = ".lease.json";
diff --git a/crates/openhuman-core/src/storage/local.rs b/crates/openhuman-core/src/storage/local.rs
index 00b38108a4..6b16ed9599 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::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
-use super::{current_scope, installed, Scope, Storage, StorageBackend};
+use super::{Scope, Storage, StorageBackend, current_scope, installed};
/// 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.rs
index dd064f035c..48b9b15258 100644
--- a/crates/openhuman-core/src/storage/mod.rs
+++ b/crates/openhuman-core/src/storage/mod.rs
@@ -52,12 +52,12 @@ pub mod sessions;
pub mod state_kv;
pub use scope::{
- scope_for_agent, scope_for_module, scope_for_profile, tenant_scope, ParsedScope, Principal,
- Scope, Tenant,
+ ParsedScope, Principal, Scope, Tenant, scope_for_agent, scope_for_module, scope_for_profile,
+ tenant_scope,
};
use std::future::Future;
-use std::sync::{mpsc, Arc, LazyLock, Mutex, OnceLock, RwLock};
+use std::sync::{Arc, LazyLock, Mutex, OnceLock, RwLock, mpsc};
/// 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
@@ -188,8 +188,8 @@ impl Blocking {
}
}
-use crate::config::schema::storage::redact_url;
use crate::config::Config;
+use crate::config::schema::storage::redact_url;
/// 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.rs
index 46d5440dc2..0971a0467c 100644
--- a/crates/openhuman-core/src/storage/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/mod_tests.rs
@@ -91,12 +91,14 @@ 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());
}
@@ -104,9 +106,11 @@ 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]
@@ -144,9 +148,11 @@ 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]
diff --git a/crates/openhuman-core/src/storage/rebind.rs b/crates/openhuman-core/src/storage/rebind.rs
index 36ea57fd9d..a9858ed728 100644
--- a/crates/openhuman-core/src/storage/rebind.rs
+++ b/crates/openhuman-core/src/storage/rebind.rs
@@ -21,8 +21,8 @@ use std::sync::Arc;
use anyhow::{Context, Result};
-use super::import;
use super::StorageBackend;
+use super::import;
use crate::config::Config;
/// What a rebind did.
diff --git a/crates/openhuman-core/src/storage/scope_tests.rs b/crates/openhuman-core/src/storage/scope_tests.rs
index 96a8b6daf8..14d36825de 100644
--- a/crates/openhuman-core/src/storage/scope_tests.rs
+++ b/crates/openhuman-core/src/storage/scope_tests.rs
@@ -52,7 +52,9 @@ fn hashed_segments_use_the_stable_lowercase_base32_alphabet() {
let segment = first.as_str().strip_prefix("u:~").unwrap();
assert_eq!(segment.len(), 26);
assert_eq!(segment, "sxpjfw7gwtcgocxriok7rbxl7t");
- assert!(segment
- .bytes()
- .all(|byte| byte.is_ascii_lowercase() || (b'2'..=b'7').contains(&byte)));
+ assert!(
+ segment
+ .bytes()
+ .all(|byte| byte.is_ascii_lowercase() || (b'2'..=b'7').contains(&byte))
+ );
}
diff --git a/crates/openhuman-core/src/storage/secrets.rs b/crates/openhuman-core/src/storage/secrets.rs
index 4fa587a80f..de65b2f34f 100644
--- a/crates/openhuman-core/src/storage/secrets.rs
+++ b/crates/openhuman-core/src/storage/secrets.rs
@@ -21,7 +21,7 @@ use std::sync::{Arc, OnceLock};
use tinystoragedrivers::secrets::{DerivedKeys, DocumentSecrets, KeyProvider};
use zeroize::Zeroizing;
-use super::{current_scope, current_scoped, Scope, Storage, StorageError};
+use super::{Scope, Storage, StorageError, current_scope, current_scoped};
/// The key provider every scope's secrets use, built once per process.
pub(crate) fn keys() -> Result<Arc<dyn KeyProvider>, StorageError> {
diff --git a/crates/openhuman-core/src/storage/sessions/mod.rs b/crates/openhuman-core/src/storage/sessions/mod.rs
index 8fdef7bb4c..280fe74272 100644
--- a/crates/openhuman-core/src/storage/sessions/mod.rs
+++ b/crates/openhuman-core/src/storage/sessions/mod.rs
@@ -22,13 +22,13 @@ mod rebound;
mod tenant_router;
mod workspace;
-pub use rebound::{rebind_all, ReboundSessionStores, StoreRegistry};
+pub use rebound::{ReboundSessionStores, StoreRegistry, rebind_all};
pub use tenant_router::TenantSessionStores;
pub use workspace::{
- artifact_blobs_for, attachment_stash_for, current_documents_for, default_turn_states_for,
- ledger_for, provider_for_workspace, release_workspace, release_workspace_defaults,
- require_ledger, session_scope, status_store_for, stores_for, stores_or_ephemeral,
- turn_states_for, with_ledger, with_ledger_async, WorkspaceSessionStores,
+ WorkspaceSessionStores, artifact_blobs_for, attachment_stash_for, current_documents_for,
+ default_turn_states_for, ledger_for, provider_for_workspace, release_workspace,
+ release_workspace_defaults, require_ledger, session_scope, status_store_for, stores_for,
+ stores_or_ephemeral, turn_states_for, with_ledger, with_ledger_async,
};
static PROVIDER: LazyLock<RwLock<Option<Arc<dyn SessionStoreProvider>>>> =
diff --git a/crates/openhuman-core/src/storage/sessions/mod_tests.rs b/crates/openhuman-core/src/storage/sessions/mod_tests.rs
index 549e277dd4..2fbd5afda7 100644
--- a/crates/openhuman-core/src/storage/sessions/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/sessions/mod_tests.rs
@@ -318,11 +318,13 @@ async fn a_stashed_attachment_survives_a_restart_of_the_workspace_store() {
resumed.read_data_uri("att-1").await.unwrap().as_deref(),
Some(data_uri)
);
- assert!(resumed
- .read_data_uri("never-stashed")
- .await
- .unwrap()
- .is_none());
+ assert!(
+ resumed
+ .read_data_uri("never-stashed")
+ .await
+ .unwrap()
+ .is_none()
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/storage/sessions/tenant_router.rs b/crates/openhuman-core/src/storage/sessions/tenant_router.rs
index ce55e97315..3ac6c1b0fe 100644
--- a/crates/openhuman-core/src/storage/sessions/tenant_router.rs
+++ b/crates/openhuman-core/src/storage/sessions/tenant_router.rs
@@ -13,8 +13,8 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex, PoisonError};
use tinyagents_harness::store::SchemaAdmission;
-use tinyagents_session::port::{AgentStorageFactory, AgentStores, SessionStoreProvider};
use tinyagents_session::DriverSessionStores;
+use tinyagents_session::port::{AgentStorageFactory, AgentStores, SessionStoreProvider};
use tinyagents_storage_kit::{Blocking, Scope as PortScope, ScopedStorage};
use tinystoragedrivers::{StorageBackend, StorageError};
diff --git a/crates/openhuman-core/src/threads/store/backend.rs b/crates/openhuman-core/src/threads/store/backend.rs
index 302ae019de..bcdbfaf114 100644
--- a/crates/openhuman-core/src/threads/store/backend.rs
+++ b/crates/openhuman-core/src/threads/store/backend.rs
@@ -82,7 +82,7 @@ fn describe(error: &ConversationError, subject: Subject<'_>) -> String {
let text = inner.to_string();
match (subject.thread, subject.message) {
(Some(t), Some(m)) if text.contains("message") => {
- return format!("message {m} not found in thread {t}")
+ return format!("message {m} not found in thread {t}");
}
(Some(t), _) => return format!("thread {t} not found"),
_ => {}
diff --git a/crates/openhuman-core/src/threads/store/legacy_import.rs b/crates/openhuman-core/src/threads/store/legacy_import.rs
index e794fa8eb8..2032a064eb 100644
--- a/crates/openhuman-core/src/threads/store/legacy_import.rs
+++ b/crates/openhuman-core/src/threads/store/legacy_import.rs
@@ -11,7 +11,7 @@
use std::collections::BTreeMap;
use std::path::Path;
-use anyhow::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
use serde::Deserialize;
use sha2::{Digest, Sha256};
use tinyagents_session::threads::{
@@ -147,10 +147,7 @@ fn fold_threads(root: &Path) -> Result<Vec<CreateConversationThread>> {
///
/// A legacy file that cannot be read, or a storage failure; the next call
/// retries (a thread or message already imported is skipped).
-pub(super) fn import_once(
- workspace_dir: &Path,
- repo: &Repo,
-) -> Result<()> {
+pub(super) fn import_once(workspace_dir: &Path, repo: &Repo) -> Result<()> {
let root = super::backend::legacy_root(workspace_dir);
let source = crate::storage::source_key(&root);
let step = import_state::step_id(IMPORT_KIND, &format!("{MARKER_PREFIX}:{source}"));
@@ -160,7 +157,7 @@ pub(super) fn import_once(
Ok(_) => return Ok(()),
Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),
Err(error) => {
- return Err(anyhow::Error::new(error).context("stat the legacy threads log"))
+ return Err(anyhow::Error::new(error).context("stat the legacy threads log"));
}
}
if import_state::is_done(repo, OWNER, &step)? {