Skip to content

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

refactor(artifacts): clean up artifact module exports and imports

Steven Enamakel6aa8ea0de9ee
diff --git a/crates/openhuman-core/src/artifacts/artifact_wiring.rs b/crates/openhuman-core/src/artifacts/artifact_wiring.rs
index 865b28d9e3..c73627ffde 100644
--- a/crates/openhuman-core/src/artifacts/artifact_wiring.rs
+++ b/crates/openhuman-core/src/artifacts/artifact_wiring.rs
@@ -14,7 +14,7 @@
use std::path::Path;
use std::sync::Arc;
-use crate::agent::harness::tool_result_artifacts::{new_tool_result_store, HostArtifactStore};
+use crate::agent::harness::tool_result_artifacts::{HostArtifactStore, new_tool_result_store};
use crate::security::policy::tool_result_artifacts_dir;
use crate::storage::sessions::artifact_blobs_for;
use tinystoragedrivers::{MemoryStorage, Scope, StorageBackend};
diff --git a/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs b/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
index 7c293fd93f..1a82c7a76e 100644
--- a/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
+++ b/crates/openhuman-core/src/artifacts/artifact_wiring_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::security::policy::tool_result_artifacts_dir;
use serde_json::json;
-use tinyagents_harness::artifacts::tool_results::{apply_per_result_persistence, ArtifactRead};
+use tinyagents_harness::artifacts::tool_results::{ArtifactRead, apply_per_result_persistence};
const DAY: std::time::Duration = std::time::Duration::from_secs(24 * 60 * 60);
diff --git a/crates/openhuman-core/src/artifacts/files.rs b/crates/openhuman-core/src/artifacts/files.rs
index 72e57037aa..34efd0a92f 100644
--- a/crates/openhuman-core/src/artifacts/files.rs
+++ b/crates/openhuman-core/src/artifacts/files.rs
@@ -167,7 +167,7 @@ pub(crate) async fn reserve_file(
Err(e) => {
return Err(format!(
"[artifacts] failed to reserve {candidate:?} for id={id}: {e}"
- ))
+ ));
}
}
}
diff --git a/crates/openhuman-core/src/artifacts/mod.rs b/crates/openhuman-core/src/artifacts/mod.rs
index 80f25a90ed..8fd2a54b1f 100644
--- a/crates/openhuman-core/src/artifacts/mod.rs
+++ b/crates/openhuman-core/src/artifacts/mod.rs
@@ -15,11 +15,11 @@ pub mod types;
pub mod version_documents;
pub(crate) use files::resolve_ready_file_meta;
-pub use files::{resolve_ready_file, FileRoots};
-pub use migrate::{migrate_legacy_artifacts, MigrationReport};
+pub use files::{FileRoots, resolve_ready_file};
+pub use migrate::{MigrationReport, migrate_legacy_artifacts};
pub use publisher_slot::{
- artifact_publisher, register_artifact_publisher, register_artifact_publisher_in,
- unregister_artifact_publisher, ArtifactPublisherBinder, ArtifactPublisherFactory,
+ ArtifactPublisherBinder, ArtifactPublisherFactory, artifact_publisher,
+ register_artifact_publisher, register_artifact_publisher_in, unregister_artifact_publisher,
};
pub use schemas::{
all_controller_schemas as all_artifacts_controller_schemas,
diff --git a/crates/openhuman-core/src/artifacts/storage_schema.rs b/crates/openhuman-core/src/artifacts/storage_schema.rs
index d4d189bb43..c1648252ea 100644
--- a/crates/openhuman-core/src/artifacts/storage_schema.rs
+++ b/crates/openhuman-core/src/artifacts/storage_schema.rs
@@ -12,7 +12,7 @@
//! `{"_args": <value>}`, so the body is always an object and
//! [`args_of_body`] reads either form back.
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinystoragedrivers::schema::{Schema, ScopeClass, SourceRecord, Step, TargetRecord};
use tinystoragedrivers::{CollectionSpec, IndexSpec, Result};
diff --git a/crates/openhuman-core/src/artifacts/store.rs b/crates/openhuman-core/src/artifacts/store.rs
index 451f4a296a..ad6599ef78 100644
--- a/crates/openhuman-core/src/artifacts/store.rs
+++ b/crates/openhuman-core/src/artifacts/store.rs
@@ -233,7 +233,7 @@ pub(crate) async fn delete_artifact(
Err(e) => {
return Err(format!(
"[artifacts] failed to delete file for id={artifact_id}: {e}"
- ))
+ ));
}
},
Err(e) => log::warn!("[artifacts] delete_artifact: leaving file in place: {e}"),
diff --git a/crates/openhuman-core/src/artifacts/store_documents.rs b/crates/openhuman-core/src/artifacts/store_documents.rs
index b4b97dda29..61bc7397c1 100644
--- a/crates/openhuman-core/src/artifacts/store_documents.rs
+++ b/crates/openhuman-core/src/artifacts/store_documents.rs
@@ -38,12 +38,12 @@ use serde_json::Value;
use tinystoragedrivers::{CollectionSpec, Filter, Precondition, Query, Sort};
use super::storage_schema::{
- args_body, args_of_body, meta_from_body, meta_to_body, records_spec, ARGS, RECORDS as ARTIFACTS,
+ ARGS, RECORDS as ARTIFACTS, args_body, args_of_body, meta_from_body, meta_to_body, records_spec,
};
use super::types::ArtifactMeta;
+use crate::storage::DocumentStoreExt;
use crate::storage::documents::Repo;
use crate::storage::schema_support::key_of;
-use crate::storage::DocumentStoreExt;
const DOMAIN: &str = "artifacts::store";
@@ -199,7 +199,7 @@ impl Docs {
Ok(entries) => entries,
Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(0),
Err(error) => {
- return Err(error).with_context(|| format!("read {}", artifacts_dir.display()))
+ return Err(error).with_context(|| format!("read {}", artifacts_dir.display()));
}
};
let mut imported = 0;
@@ -308,7 +308,7 @@ pub(super) async fn delete_record(docs: Docs, artifact_dir: &Path, id: &str) ->
Err(e) => {
return Err(format!(
"[artifacts] failed to delete legacy record for id={id}: {e}"
- ))
+ ));
}
}
let owned = id.to_string();
diff --git a/crates/openhuman-core/src/artifacts/store_documents_tests.rs b/crates/openhuman-core/src/artifacts/store_documents_tests.rs
index e00790c523..8c2b238947 100644
--- a/crates/openhuman-core/src/artifacts/store_documents_tests.rs
+++ b/crates/openhuman-core/src/artifacts/store_documents_tests.rs
@@ -1,10 +1,10 @@
use super::*;
+use crate::artifacts::FileRoots;
use crate::artifacts::store::{
delete_artifact, get_artifact, list_artifacts, read_artifact_args, save_artifact_args,
save_artifact_meta,
};
use crate::artifacts::types::{ArtifactKind, ArtifactStatus};
-use crate::artifacts::FileRoots;
use crate::storage::{MemoryStorage, Scope, StorageBackend};
use chrono::{TimeZone, Utc};
diff --git a/crates/openhuman-core/src/artifacts/version_documents.rs b/crates/openhuman-core/src/artifacts/version_documents.rs
index 642f003033..20c8e50b1b 100644
--- a/crates/openhuman-core/src/artifacts/version_documents.rs
+++ b/crates/openhuman-core/src/artifacts/version_documents.rs
@@ -28,10 +28,10 @@ use serde_json::Value;
use tiny_artifacts::{ArtifactRecord, ArtifactStore};
use tinystoragedrivers::{CollectionSpec, Precondition, Query, Sort};
-use super::storage_schema::{version_body, version_record, VERSIONS};
+use super::storage_schema::{VERSIONS, version_body, version_record};
+use crate::storage::DocumentStoreExt;
use crate::storage::documents::Repo;
use crate::storage::schema_support::key_of;
-use crate::storage::DocumentStoreExt;
const DOMAIN: &str = "artifacts::versions";
@@ -138,7 +138,7 @@ impl ArtifactStore for DocumentArtifactStore {
Ok(()) => {}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(err) => {
- return Err(err).with_context(|| format!("remove {}", legacy.display()))
+ return Err(err).with_context(|| format!("remove {}", legacy.display()));
}
}
}
diff --git a/crates/openhuman-core/src/artifacts/version_documents_tests.rs b/crates/openhuman-core/src/artifacts/version_documents_tests.rs
index e2f7c982c3..b436a48336 100644
--- a/crates/openhuman-core/src/artifacts/version_documents_tests.rs
+++ b/crates/openhuman-core/src/artifacts/version_documents_tests.rs
@@ -35,9 +35,11 @@ async fn records_round_trip_through_the_document_store() {
assert!(store.get("a-1").await.unwrap().is_none());
assert!(!store.delete("a-1").await.unwrap());
// Nothing is written as a file.
- assert!(!super::super::tiny_store::legacy_versioned_dir(&ws)
- .join("a-2.json")
- .exists());
+ assert!(
+ !super::super::tiny_store::legacy_versioned_dir(&ws)
+ .join("a-2.json")
+ .exists()
+ );
}
#[tokio::test]