Skip to content

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

style: apply rustfmt import ordering and assertion formatting

Steven Enamakel958d0fb36545
diff --git a/crates/openhuman-core/src/threads/attachments_tests.rs b/crates/openhuman-core/src/threads/attachments_tests.rs
index 7d5859990d..41c1cfbec1 100644
--- a/crates/openhuman-core/src/threads/attachments_tests.rs
+++ b/crates/openhuman-core/src/threads/attachments_tests.rs
@@ -48,12 +48,10 @@ fn public_projection_hides_paths_but_keeps_opaque_attachment_refs() {
vec![(part.clone(), "uploads/thread/a.png".into())],
);
assert_eq!(public, vec![part]);
- assert!(
- metadata[STORAGE_KEY][0]["path"]
- .as_str()
- .unwrap()
- .contains("uploads/")
- );
+ assert!(metadata[STORAGE_KEY][0]["path"]
+ .as_str()
+ .unwrap()
+ .contains("uploads/"));
let projected = public_refs(&metadata);
assert_eq!(projected, public);
@@ -184,17 +182,15 @@ async fn multipart_claim_failure_keeps_prior_claim_owned_by_retry() {
insert_record(&repo, &staged_record(first.clone(), "first.png"));
insert_record(&repo, &staged_record(second.clone(), "second.png"));
let second_claim = claim("", second.clone(), true);
- assert!(
- cancel_staged_record(
- &repo,
- &second_claim.tenant,
- "thread",
- &staged_doc_id(&second_id).unwrap(),
- &second,
- &second_claim,
- )
- .unwrap()
- );
+ assert!(cancel_staged_record(
+ &repo,
+ &second_claim.tenant,
+ "thread",
+ &staged_doc_id(&second_id).unwrap(),
+ &second,
+ &second_claim,
+ )
+ .unwrap());
let entries = vec![
StoredAttachment {
part: first.clone(),
@@ -205,41 +201,35 @@ async fn multipart_claim_failure_keeps_prior_claim_owned_by_retry() {
path: "second.png".into(),
},
];
- assert!(
- claim_staged_refs(
- &crate::core::runtime::DispatchCtx::ambient(),
- "thread",
- &config,
- "user:req",
- &entries,
- )
- .await
- .is_err()
- );
+ assert!(claim_staged_refs(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ "thread",
+ &config,
+ "user:req",
+ &entries,
+ )
+ .await
+ .is_err());
let first_claim = claim("user:req", first.clone(), false);
- assert!(
- !claim_staged_record(
- &repo,
- &first_claim.tenant,
- "thread",
- &staged_doc_id(&first_id).unwrap(),
- &first,
- &first_claim,
- )
- .unwrap()
- );
+ assert!(!claim_staged_record(
+ &repo,
+ &first_claim.tenant,
+ "thread",
+ &staged_doc_id(&first_id).unwrap(),
+ &first,
+ &first_claim,
+ )
+ .unwrap());
let other = claim("user:other", first.clone(), false);
- assert!(
- claim_staged_record(
- &repo,
- &other.tenant,
- "thread",
- &staged_doc_id(&first_id).unwrap(),
- &first,
- &other,
- )
- .is_err()
- );
+ assert!(claim_staged_record(
+ &repo,
+ &other.tenant,
+ "thread",
+ &staged_doc_id(&first_id).unwrap(),
+ &first,
+ &other,
+ )
+ .is_err());
}
#[tokio::test]
@@ -257,17 +247,15 @@ async fn discarding_claimed_attachment_preserves_row_owned_file() {
let repo = test_repo(&config.workspace_dir);
insert_record(&repo, &staged_record(part.clone(), "committed.png"));
let bound = claim("user:req", part.clone(), false);
- assert!(
- claim_staged_record(
- &repo,
- &bound.tenant,
- "thread",
- &staged_doc_id(&opaque_id).unwrap(),
- &part,
- &bound,
- )
- .unwrap()
- );
+ assert!(claim_staged_record(
+ &repo,
+ &bound.tenant,
+ "thread",
+ &staged_doc_id(&opaque_id).unwrap(),
+ &part,
+ &bound,
+ )
+ .unwrap());
let workspace = crate::agent::attachments::thread_action_dir(
&crate::core::runtime::DispatchCtx::ambient(),
&config,
diff --git a/crates/openhuman-core/src/threads/channel_projection.rs b/crates/openhuman-core/src/threads/channel_projection.rs
index c7f1f82b4b..120c2ddd2f 100644
--- a/crates/openhuman-core/src/threads/channel_projection.rs
+++ b/crates/openhuman-core/src/threads/channel_projection.rs
@@ -7,17 +7,17 @@
//! guesses from a sender, recent message, or equality between provider and row
//! identifiers.
-use anyhow::{Context, Result, anyhow};
+use anyhow::{anyhow, Context, Result};
use serde::{Deserialize, Serialize};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use tinychannels_bus::{ChannelRef, ConversationRef};
use tinystoragedrivers::{CollectionSpec, ErrorKind, Precondition};
-use crate::core::runtime::{DispatchCtx, Tenant, tenant::tenant_key};
+use crate::core::runtime::{tenant::tenant_key, DispatchCtx, Tenant};
use crate::storage::{
self,
- documents::{Repo, compare_and_swap},
+ documents::{compare_and_swap, Repo},
};
const DOMAIN: &str = "threads::channel_projection";
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index c573196a11..0feb01f40f 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -5,11 +5,11 @@ use super::support::{
counts, envelope, message_to_record, record_to_message, run_to_completion, thread_to_summary,
workspace_dir,
};
-use crate::core::Outcome;
use crate::core::runtime::DispatchCtx;
-use crate::threads::ThreadsError;
+use crate::core::Outcome;
use crate::threads::store as conversations;
use crate::threads::store::{ConversationMessagePatch, CrossThreadHit};
+use crate::threads::ThreadsError;
use crate::threads::{
ApiEnvelope, AppendConversationMessageRequest, ConversationMessageRecord,
ConversationMessagesRequest, ConversationMessagesResponse, ConversationThreadSummary,
diff --git a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
index d6c80a2e18..fb5b64490d 100644
--- a/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/crud_message_append_tests.rs
@@ -125,55 +125,47 @@ async fn user_append_stages_original_strips_upload_bytes_and_reuses_returned_con
.await
.unwrap();
assert_eq!(persisted.len(), 2);
- assert!(
- !serde_json::to_string(&persisted)
- .unwrap()
- .contains("base64,")
- );
+ assert!(!serde_json::to_string(&persisted)
+ .unwrap()
+ .contains("base64,"));
}
#[tokio::test]
async fn rejected_upload_never_appends_a_message() {
let (_temp, mut config) = setup().await;
config.multimodal_files.max_files = 0;
- assert!(
- append_with_test_config(
- request(
- "disabled",
- "[IMAGE:data:image/png;base64,iVBORw0KGgo=]",
- "user"
- ),
- &config,
- None,
- )
- .await
- .is_err()
- );
+ assert!(append_with_test_config(
+ request(
+ "disabled",
+ "[IMAGE:data:image/png;base64,iVBORw0KGgo=]",
+ "user"
+ ),
+ &config,
+ None,
+ )
+ .await
+ .is_err());
config.multimodal_files.max_files = 3;
- assert!(
- append_with_test_config(
- request("bad", "[FILE:data:application/zip;base64,!]", "user"),
- &config,
- None,
- )
- .await
- .is_err()
- );
+ assert!(append_with_test_config(
+ request("bad", "[FILE:data:application/zip;base64,!]", "user"),
+ &config,
+ None,
+ )
+ .await
+ .is_err());
assert!(
append_with_test_config(request("missing", "image.png", "user"), &config, None)
.await
.is_err()
);
- assert!(
- conversations::blocking::get_messages(
- crate::core::runtime::DispatchCtx::ambient(),
- config.workspace_dir.clone(),
- "uploads".into()
- )
- .await
- .unwrap()
- .is_empty()
- );
+ assert!(conversations::blocking::get_messages(
+ crate::core::runtime::DispatchCtx::ambient(),
+ config.workspace_dir.clone(),
+ "uploads".into()
+ )
+ .await
+ .unwrap()
+ .is_empty());
}
#[tokio::test]
@@ -202,16 +194,14 @@ async fn external_origin_cannot_reuse_an_existing_attachment_marker() {
.await
.is_err()
);
- assert!(
- conversations::blocking::get_messages(
- crate::core::runtime::DispatchCtx::ambient(),
- config.workspace_dir,
- "uploads".into()
- )
- .await
- .unwrap()
- .is_empty()
- );
+ assert!(conversations::blocking::get_messages(
+ crate::core::runtime::DispatchCtx::ambient(),
+ config.workspace_dir,
+ "uploads".into()
+ )
+ .await
+ .unwrap()
+ .is_empty());
}
#[tokio::test]
@@ -280,16 +270,14 @@ async fn append_uses_host_persistence_workspace_separate_from_rpc_config() {
.await
.unwrap();
assert_eq!(persisted.len(), 1);
- assert!(
- conversations::blocking::get_messages(
- crate::core::runtime::DispatchCtx::ambient(),
- config.workspace_dir,
- "uploads".into()
- )
- .await
- .unwrap()
- .is_empty()
- );
+ assert!(conversations::blocking::get_messages(
+ crate::core::runtime::DispatchCtx::ambient(),
+ config.workspace_dir,
+ "uploads".into()
+ )
+ .await
+ .unwrap()
+ .is_empty());
}
#[tokio::test]
@@ -300,21 +288,17 @@ async fn poster_only_user_metadata_is_rejected_before_persistence() {
"attachmentNames": ["video.mp4"],
"attachmentPosters": ["data:image/png;base64,iVBORw0KGgo="]
});
- assert!(
- append_with_test_config(upload, &config, None)
- .await
- .is_err()
- );
- assert!(
- conversations::blocking::get_messages(
- crate::core::runtime::DispatchCtx::ambient(),
- config.workspace_dir.clone(),
- "uploads".into()
- )
+ assert!(append_with_test_config(upload, &config, None)
.await
- .unwrap()
- .is_empty()
- );
+ .is_err());
+ assert!(conversations::blocking::get_messages(
+ crate::core::runtime::DispatchCtx::ambient(),
+ config.workspace_dir.clone(),
+ "uploads".into()
+ )
+ .await
+ .unwrap()
+ .is_empty());
}
#[tokio::test]
@@ -369,12 +353,10 @@ async fn append_cannot_forge_private_attachment_storage_metadata() {
.data
.unwrap();
assert!(saved.attachments.is_empty());
- assert!(
- saved
- .extra_metadata
- .get("__openhumanStoredAttachments")
- .is_none()
- );
+ assert!(saved
+ .extra_metadata
+ .get("__openhumanStoredAttachments")
+ .is_none());
let mut user_req = request("forged-user", "hello", "user");
user_req.message.extra_metadata = json!({});
user_req.message.extra_metadata["__openhumanStoredAttachments"] = json!([{
@@ -388,12 +370,10 @@ async fn append_cannot_forge_private_attachment_storage_metadata() {
.data
.unwrap();
assert!(saved_user.attachments.is_empty());
- assert!(
- saved_user
- .extra_metadata
- .get("__openhumanStoredAttachments")
- .is_none()
- );
+ assert!(saved_user
+ .extra_metadata
+ .get("__openhumanStoredAttachments")
+ .is_none());
let stored = crate::threads::store::get_messages(
&crate::core::runtime::DispatchCtx::ambient(),
config.workspace_dir.clone(),
@@ -455,12 +435,10 @@ async fn typed_attachment_is_staged_like_a_marker_and_leaves_the_text_clean() {
);
assert_eq!(saved.content, "look");
assert_eq!(saved.attachments.len(), 1);
- assert!(
- saved
- .extra_metadata
- .get("__openhumanStoredAttachments")
- .is_none()
- );
+ assert!(saved
+ .extra_metadata
+ .get("__openhumanStoredAttachments")
+ .is_none());
let opaque_id = match &saved.attachments[0] {
ContentPart::Image { media, .. } => {
assert!(media.path.is_none());
diff --git a/crates/openhuman-core/src/threads/store/storage_schema.rs b/crates/openhuman-core/src/threads/store/storage_schema.rs
index a42757a908..3a84c7a9cf 100644
--- a/crates/openhuman-core/src/threads/store/storage_schema.rs
+++ b/crates/openhuman-core/src/threads/store/storage_schema.rs
@@ -33,11 +33,7 @@ pub fn storage_schema() -> Schema {
// These collections are new in owner schema v2, so each collection
// starts at its own version 1; owner versioning does not imply that
// a new collection has a v1→v2 migration step.
- .collection_with(
- 1,
- CollectionSpec::new(CHANNEL_MESSAGES),
- ScopeClass::Tenant,
- )
+ .collection_with(1, CollectionSpec::new(CHANNEL_MESSAGES), ScopeClass::Tenant)
.collection_with(
1,
CollectionSpec::new(STAGED_ATTACHMENTS),
diff --git a/crates/openhuman-core/src/threads/store/storage_schema_tests.rs b/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
index 28e210f864..fc2440825c 100644
--- a/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
+++ b/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinystoragedrivers::schema::ScopeClass;
use tinystoragedrivers::{Meta, Precondition, StorageBackend};
@@ -36,7 +36,7 @@ fn channel_attachment_and_viseme_records_are_declared_in_the_threads_owner() {
#[tokio::test]
async fn schema_prepares_the_scoped_projection_and_media_collections() {
- use crate::storage::{MemoryStorage, scope_for_profile};
+ use crate::storage::{scope_for_profile, MemoryStorage};
let registry = tinystoragedrivers::schema::Registry::compose([storage_schema()]).unwrap();
let backend = MemoryStorage::new();
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence.rs b/crates/openhuman-core/src/web_chat/reply_persistence.rs
index a96860cb78..8f0dc3175a 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence.rs
@@ -24,7 +24,7 @@ use std::path::Path;
use serde_json::json;
use crate::memory::types::TurnCitation;
-use crate::threads::store::{self as conversations, ConversationMessage, run_reply_message_id};
+use crate::threads::store::{self as conversations, run_reply_message_id, ConversationMessage};
/// Metadata scope stamped on a reply persisted by the web-channel delivery path.
///
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
index 615ec2baba..e236379367 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
@@ -111,15 +111,13 @@ fn an_empty_reply_is_not_stored() {
)
.expect("no error");
assert!(!stored, "an empty reply reports that nothing was stored");
- assert!(
- conversations::get_messages(
- &crate::core::runtime::DispatchCtx::ambient(),
- ws.clone(),
- "t-3"
- )
- .expect("messages")
- .is_empty()
- );
+ assert!(conversations::get_messages(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ ws.clone(),
+ "t-3"
+ )
+ .expect("messages")
+ .is_empty());
}
#[test]
diff --git a/crates/openhuman-core/src/web_chat/voice_notes.rs b/crates/openhuman-core/src/web_chat/voice_notes.rs
index c5972ab60a..df55675b84 100644
--- a/crates/openhuman-core/src/web_chat/voice_notes.rs
+++ b/crates/openhuman-core/src/web_chat/voice_notes.rs
@@ -13,7 +13,7 @@
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinystoragedrivers::{CollectionSpec, Precondition};
use crate::storage::{self, documents::Repo};