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/memory/backfill.rs,crates/openhuman-core/src/memory/b

Steven Enamakel9f4893c57a6b
diff --git a/crates/openhuman-core/src/memory/backfill.rs b/crates/openhuman-core/src/memory/backfill.rs
index 28fcf5ea95..ccefa29014 100644
--- a/crates/openhuman-core/src/memory/backfill.rs
+++ b/crates/openhuman-core/src/memory/backfill.rs
@@ -8,18 +8,20 @@
use std::path::{Path, PathBuf};
use std::sync::Arc;
-use async_trait::async_trait;
-use crate::core::runtime::DispatchCtx;
use crate::config::Config;
+use crate::core::runtime::DispatchCtx;
use crate::memory::engine;
use crate::memory::run_slots::{self, BACKFILL, IMPORT, MIGRATION};
use crate::threads::store::blocking as threads;
+use async_trait::async_trait;
use tinymemory_api::{Error, Result};
-use tinymemory_tools::backfill::{BackfillFile, Backfiller, CounterStore, ThreadMessage, ThreadSource};
+use tinymemory_tools::backfill::{
+ BackfillFile, Backfiller, CounterStore, ThreadMessage, ThreadSource,
+};
use tinymemory_tools::layout::identity::Identity;
pub use tinymemory_tools::backfill::{
- BackfillPhase, BackfillState, BackfillView, BACKFILL_TAG, MAIN_AGENT, PastTurn, pending_range,
+ BACKFILL_TAG, BackfillPhase, BackfillState, BackfillView, MAIN_AGENT, PastTurn, pending_range,
turns_of,
};
@@ -96,7 +98,8 @@ fn driver(
config: &Config,
engine: Arc<dyn tinymemory_api::MemoryEngine>,
) -> Result<Backfiller> {
- let identity = Identity::agent(MAIN_AGENT).resolve(&crate::memory::scope::identity_pins(config));
+ let identity =
+ Identity::agent(MAIN_AGENT).resolve(&crate::memory::scope::identity_pins(config));
Ok(Backfiller::new(
engine,
identity.layout,
@@ -155,7 +158,11 @@ pub async fn start(
let _guard = guard;
let state = backfiller.run(run).await;
if state.phase == BackfillPhase::Done {
- tracing::info!(items = state.items_stored, turns = state.turns_stored, "[memory:backfill] done");
+ tracing::info!(
+ items = state.items_stored,
+ turns = state.turns_stored,
+ "[memory:backfill] done"
+ );
}
});
Ok(view)
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rs
index caee994556..d6ba64d3fb 100644
--- a/crates/openhuman-core/src/memory/brain.rs
+++ b/crates/openhuman-core/src/memory/brain.rs
@@ -17,8 +17,8 @@ use tinymemory_integrations::documents::RawDocument;
use tinymemory_tools::layout::placement::{brain_node_with, files_source};
use tinymemory_tools::{Brain, BrainSource, BrainSourcesView, MemoryLayout};
-use crate::config::schema::MemorySourceKind;
use crate::config::Config;
+use crate::config::schema::MemorySourceKind;
use super::engine;
use super::lifecycle::jobs;
diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rs
index a6571a7683..d65760fecb 100644
--- a/crates/openhuman-core/src/memory/brain_tests.rs
+++ b/crates/openhuman-core/src/memory/brain_tests.rs
@@ -207,17 +207,19 @@ async fn ingest_refuses_bad_input() {
Err(Error::InvalidRequest(_))
));
}
- assert!(search(
- &config,
- &tinymemory_tools::layout::identity::Identity::root(),
- BrainSearchParams {
- query: " ".into(),
- source: None,
- limit: None
- }
- )
- .await
- .is_err());
+ assert!(
+ search(
+ &config,
+ &tinymemory_tools::layout::identity::Identity::root(),
+ BrainSearchParams {
+ query: " ".into(),
+ source: None,
+ limit: None
+ }
+ )
+ .await
+ .is_err()
+ );
}
#[tokio::test]
@@ -294,8 +296,8 @@ async fn a_file_is_converted_and_filed_under_files() {
#[tokio::test]
async fn an_ingest_queues_a_belief_build_only_for_an_engine_that_waits_for_one() {
use std::sync::Arc;
- use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::Consolidation;
+ use tinymemory_api::conformance::ReferenceEngine;
for (consolidation, queued) in [(Consolidation::OnDemand, 1), (Consolidation::Automatic, 0)] {
let tmp = tempfile::tempdir().unwrap();
diff --git a/crates/openhuman-core/src/memory/bus_tests.rs b/crates/openhuman-core/src/memory/bus_tests.rs
index b066b757cc..e44c385b3b 100644
--- a/crates/openhuman-core/src/memory/bus_tests.rs
+++ b/crates/openhuman-core/src/memory/bus_tests.rs
@@ -61,7 +61,7 @@ fn the_deletions_subscriber_listens_on_auth() {
#[tokio::test]
async fn a_sign_in_drains_the_deletions_queued_while_signed_out() {
- use crate::memory::deletion::{enqueue, pending, PendingDeletion};
+ use crate::memory::deletion::{PendingDeletion, enqueue, pending};
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
@@ -86,7 +86,7 @@ async fn a_sign_in_drains_the_deletions_queued_while_signed_out() {
#[tokio::test]
async fn the_background_job_retries_pending_deletions() {
- use crate::memory::deletion::{enqueue, pending, PendingDeletion};
+ use crate::memory::deletion::{PendingDeletion, enqueue, pending};
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
diff --git a/crates/openhuman-core/src/memory/confinement_tests.rs b/crates/openhuman-core/src/memory/confinement_tests.rs
index bf98d178da..f216ed1c38 100644
--- a/crates/openhuman-core/src/memory/confinement_tests.rs
+++ b/crates/openhuman-core/src/memory/confinement_tests.rs
@@ -131,10 +131,12 @@ async fn rpc_list_fetch_and_recall_never_read_another_root() {
)
.await
.unwrap();
- assert!(answer
- .citations
- .iter()
- .all(|citation| citation.id.0 != theirs));
+ assert!(
+ answer
+ .citations
+ .iter()
+ .all(|citation| citation.id.0 != theirs)
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/memory/deletion_tests.rs b/crates/openhuman-core/src/memory/deletion_tests.rs
index a865cb7feb..043011d0b6 100644
--- a/crates/openhuman-core/src/memory/deletion_tests.rs
+++ b/crates/openhuman-core/src/memory/deletion_tests.rs
@@ -24,7 +24,7 @@ fn thread(id: &str) -> PendingDeletion {
#[tokio::test]
async fn offline_conversation_purge_queues_exact_thread_ids_in_its_workspace() {
- use crate::threads::store::{ensure_thread, purge_threads, CreateConversationThread};
+ use crate::threads::store::{CreateConversationThread, ensure_thread, purge_threads};
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
@@ -102,12 +102,15 @@ async fn offline_conversation_purge_queues_exact_thread_ids_in_its_workspace() {
let left = stored(&engine, MetaFilter::default()).await;
assert_eq!(left.len(), 3);
- assert!(left
- .iter()
- .any(|item| { item.kind == ItemKind::Learning && item.text == "durable preference" }));
- assert!(left
- .iter()
- .any(|item| { item.kind == ItemKind::Document && item.text == "durable brain document" }));
+ assert!(
+ left.iter()
+ .any(|item| { item.kind == ItemKind::Learning && item.text == "durable preference" })
+ );
+ assert!(
+ left.iter().any(|item| {
+ item.kind == ItemKind::Document && item.text == "durable brain document"
+ })
+ );
assert!(left.iter().any(|item| {
item.kind == ItemKind::Conversation
&& item.meta.thread_id.as_deref() == Some("unrelated-thread")
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index 0b94d4a465..15a413a5fe 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -46,8 +46,8 @@ pub use tinymemory_api::Error as MemoryError;
pub use tinymemory_integrations::cortex::CallbackBearerSource;
pub use tinymemory_integrations::{BearerSource, Binding, BoundEngine, EngineBinder};
-use crate::config::schema::MEMORY_CORTEXDB_KEY_NAME;
use crate::config::Config;
+use crate::config::schema::MEMORY_CORTEXDB_KEY_NAME;
use crate::security::credentials::session_support::resolve_backend_credential;
use crate::security::credentials::{AuthService, DEFAULT_AUTH_PROFILE_NAME};
@@ -439,7 +439,7 @@ fn resolve_cortexdb(config: &Config, root: Option<&str>) -> Binding {
Some(CORTEXDB_ENGINE),
Some(endpoint),
"add a CortexDB API key to use CortexDB memory",
- )
+ );
}
Err(error) => {
tracing::warn!(error = %error, "[memory:engine] reading the CortexDB key failed");
diff --git a/crates/openhuman-core/src/memory/engine_tests.rs b/crates/openhuman-core/src/memory/engine_tests.rs
index 7977ef934f..ee9d2d2201 100644
--- a/crates/openhuman-core/src/memory/engine_tests.rs
+++ b/crates/openhuman-core/src/memory/engine_tests.rs
@@ -2,7 +2,7 @@ use super::*;
use crate::memory::test_fixtures::config_in;
use crate::security::credentials::api_key::store_api_key;
-use crate::security::credentials::{AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME};
+use crate::security::credentials::{APP_SESSION_PROVIDER, AuthService, DEFAULT_AUTH_PROFILE_NAME};
struct ClearInstalledHostEngine;
diff --git a/crates/openhuman-core/src/memory/explore.rs b/crates/openhuman-core/src/memory/explore.rs
index cb8bb4f4fe..edb012ed1c 100644
--- a/crates/openhuman-core/src/memory/explore.rs
+++ b/crates/openhuman-core/src/memory/explore.rs
@@ -19,7 +19,7 @@ use tinymemory_tools::ops::ExploreOptions;
use crate::config::Config;
use super::engine;
-pub use tinymemory_tools::ops::{narrowed, PathStep, DEFAULT_BUCKETS, MAX_PATH_STEPS};
+pub use tinymemory_tools::ops::{DEFAULT_BUCKETS, MAX_PATH_STEPS, PathStep, narrowed};
/// `memory_explore` params.
#[derive(Debug, Clone, Deserialize)]
diff --git a/crates/openhuman-core/src/memory/guard_tests.rs b/crates/openhuman-core/src/memory/guard_tests.rs
index 8589826f70..f53a2e488d 100644
--- a/crates/openhuman-core/src/memory/guard_tests.rs
+++ b/crates/openhuman-core/src/memory/guard_tests.rs
@@ -1,8 +1,8 @@
use std::sync::Arc;
use tinymemory_api::{MemoryEngine, StoreItem};
-use tinymemory_integrations::safety::{scrub_item_with, Policy};
use tinymemory_integrations::EngineBinder;
+use tinymemory_integrations::safety::{Policy, scrub_item_with};
fn wrap(engine: Arc<dyn MemoryEngine>) -> Arc<dyn MemoryEngine> {
EngineBinder::default()
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index b05038a2d6..63b06a721d 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -192,11 +192,18 @@ pub(crate) async fn resume_interrupted_with(
let paused_for_batches = Some(paused);
match launch(ctx, config, mode, true, paused_for_batches).await {
Ok(state) => {
- tracing::info!(imported = state.imported, total = state.total, "[memory:import] resuming an interrupted import");
+ tracing::info!(
+ imported = state.imported,
+ total = state.total,
+ "[memory:import] resuming an interrupted import"
+ );
true
}
Err(error) => {
- tracing::warn!(code = error.code(), "[memory:import] interrupted import could not resume; stopped");
+ tracing::warn!(
+ code = error.code(),
+ "[memory:import] interrupted import could not resume; stopped"
+ );
tinymemory_integrations::import::record_resume_failure(&store, &error.to_string());
false
}
@@ -272,7 +279,11 @@ async fn launch(
Err(error) => return Err(Error::Engine(format!("import start failed: {error}"))),
};
let state = begun.state.clone();
- tracing::info!(total = state.total, retry = mode != Mode::Import, "[memory:import] run started");
+ tracing::info!(
+ total = state.total,
+ retry = mode != Mode::Import,
+ "[memory:import] run started"
+ );
let config = config.clone();
let task_ctx = ctx.clone();
task_ctx.spawn(async move {
diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rs
index c3cd9a846f..2f36409d38 100644
--- a/crates/openhuman-core/src/memory/import_tests.rs
+++ b/crates/openhuman-core/src/memory/import_tests.rs
@@ -138,7 +138,10 @@ async fn a_live_import_blocks_migration_and_does_not_make_a_stale_migration_look
let _reservation = crate::memory::run_slots::reserve(
&crate::memory::run_slots::IMPORT,
&workspace,
- &[&crate::memory::run_slots::BACKFILL, &crate::memory::run_slots::MIGRATION],
+ &[
+ &crate::memory::run_slots::BACKFILL,
+ &crate::memory::run_slots::MIGRATION,
+ ],
)
.expect("the test owns a live import slot");
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
index 58d9a28f2c..646b03326f 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
@@ -6,7 +6,9 @@
use async_trait::async_trait;
use tinymemory_api::Error as EngineError;
use tinymemory_tools::layout_migration as lm;
-use tinymemory_tools::layout_migration::{Engines, FlowPlacement, FsLegacyClaim, LegacyClaim, Placement};
+use tinymemory_tools::layout_migration::{
+ Engines, FlowPlacement, FsLegacyClaim, LegacyClaim, Placement,
+};
use super::state::FileStateStore;
use crate::config::{Config, MemoryLayoutMode};
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs b/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
index 40e93c7cdb..97504afa6b 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
@@ -1,13 +1,15 @@
use std::sync::Arc;
-use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::MemoryEngine;
+use tinymemory_api::conformance::ReferenceEngine;
use super::*;
use crate::memory::engine::install_test_engine_for_root;
use crate::memory::layout_migration::ops::scan;
use crate::memory::layout_migration::test_host::{count, fact};
-use tinymemory_tools::layout_migration::{FsLegacyClaim, LayoutHost, LegacyClaim, Outcome, Trigger};
+use tinymemory_tools::layout_migration::{
+ FsLegacyClaim, LayoutHost, LegacyClaim, Outcome, Trigger,
+};
const ACCOUNT: &str = "0123456789abcdef01234567";
@@ -90,7 +92,17 @@ fn every_account_on_a_self_hosted_engine_shares_one_claim() {
let key_a = claim(&a).unwrap().unwrap();
let key_b = claim(&b).unwrap().unwrap();
assert_eq!(key_a.marker_path(), key_b.marker_path());
- assert_eq!(key_a.marker_path().parent().unwrap().parent().unwrap().parent().unwrap(), tmp.path());
+ assert_eq!(
+ key_a
+ .marker_path()
+ .parent()
+ .unwrap()
+ .parent()
+ .unwrap()
+ .parent()
+ .unwrap(),
+ tmp.path()
+ );
assert_eq!(key_a.owner(), format!("user:{ACCOUNT}"));
let hosted = signed_in(&tmp);
@@ -147,12 +159,15 @@ async fn a_shared_tree_reaches_the_module_as_a_claim() {
// Another account on the machine took the tree first.
let key = claim(&config).unwrap().unwrap();
- let app_dir = key.marker_path().parent().unwrap().parent().unwrap().parent().unwrap();
- let other = FsLegacyClaim::new(
- app_dir,
- key.endpoint(),
- "user:fedcba9876543210fedcba98",
- );
+ let app_dir = key
+ .marker_path()
+ .parent()
+ .unwrap()
+ .parent()
+ .unwrap()
+ .parent()
+ .unwrap();
+ let other = FsLegacyClaim::new(app_dir, key.endpoint(), "user:fedcba9876543210fedcba98");
assert!(other.take().unwrap());
let view = scan(&host).await.unwrap();
assert!(!view.needed && view.shared, "{view:?}");
@@ -183,14 +198,16 @@ fn errors_keep_their_wire_codes_across_the_module_boundary() {
assert!(back.is_account_wide());
}
-
#[test]
fn one_endpoint_has_one_marker_however_it_is_spelled() {
let dir = tempfile::tempdir().unwrap();
let local = "http://127.0.0.1:3141";
let key = FsLegacyClaim::new(dir.path(), local, "user:a");
for spelling in ["HTTP://127.0.0.1:3141/", " http://127.0.0.1:3141 "] {
- assert_eq!(FsLegacyClaim::new(dir.path(), spelling, "user:b").marker_path(), key.marker_path());
+ assert_eq!(
+ FsLegacyClaim::new(dir.path(), spelling, "user:b").marker_path(),
+ key.marker_path()
+ );
}
assert_ne!(
FsLegacyClaim::new(dir.path(), "http://127.0.0.1:3142", "user:a").marker_path(),
diff --git a/crates/openhuman-core/src/memory/layout_migration/mod.rs b/crates/openhuman-core/src/memory/layout_migration/mod.rs
index 6e4ad78f08..9e4315ad7a 100644
--- a/crates/openhuman-core/src/memory/layout_migration/mod.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/mod.rs
@@ -11,7 +11,7 @@ pub mod state;
pub(crate) mod test_host;
pub use app_host::AppHost;
-pub use ops::{retry, scan, start, status, tick, StartParams};
+pub use ops::{StartParams, retry, scan, start, status, tick};
pub use state::FileStateStore;
pub use tinymemory_tools::layout_migration::{
LayoutHost, MigrationState, MigrationStateStore, MigrationStatus, Outcome, Phase, ScanView,
diff --git a/crates/openhuman-core/src/memory/layout_migration/ops.rs b/crates/openhuman-core/src/memory/layout_migration/ops.rs
index 971c8afc40..d1621ca43d 100644
--- a/crates/openhuman-core/src/memory/layout_migration/ops.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/ops.rs
@@ -10,14 +10,13 @@ use std::sync::Arc;
use tinymemory_tools::layout_migration as lm;
use tinymemory_tools::run_slots::{MigrationSpawner, MigrationTask};
-use super::app_host::{from_module, AppHost};
+use super::app_host::{AppHost, from_module};
use super::{LayoutHost, MigrationState, MigrationStatus, ScanView, Trigger};
use crate::config::Config;
use crate::core::runtime::DispatchCtx;
use crate::memory::run_slots::{self, BACKFILL, IMPORT, MIGRATION};
use tinymemory_api::Result;
-
/// `memory_migration_start` params.
#[derive(Debug, Clone, Default, serde::Deserialize)]
pub struct StartParams {
@@ -39,7 +38,9 @@ impl MigrationSpawner for ContextSpawner {
}
}
-fn service(ctx: &DispatchCtx) -> lm::MigrationService<tinymemory_tools::run_slots::RunStartGate, ContextSpawner> {
+fn service(
+ ctx: &DispatchCtx,
+) -> lm::MigrationService<tinymemory_tools::run_slots::RunStartGate, ContextSpawner> {
lm::MigrationService::new(
MIGRATION.clone(),
run_slots::START_GATE.clone(),
diff --git a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
index a65d371aef..0d6de974c7 100644
--- a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs
@@ -1,11 +1,11 @@
-use std::sync::atomic::Ordering;
use std::sync::Arc;
+use std::sync::atomic::Ordering;
use tinymemory_api::MemoryEngine;
use super::*;
-use crate::memory::layout_migration::test_host::{count, fact, FakeHost};
-use crate::memory::layout_migration::{state, Phase};
+use crate::memory::layout_migration::test_host::{FakeHost, count, fact};
+use crate::memory::layout_migration::{Phase, state};
fn never() -> Arc<dyn Fn() -> bool + Send + Sync> {
Arc::new(|| false)
@@ -131,7 +131,10 @@ async fn nothing_starts_while_an_import_is_unfinished() {
let import_guard = crate::memory::run_slots::reserve(
&crate::memory::run_slots::IMPORT,
&config.workspace_dir,
- &[&crate::memory::run_slots::BACKFILL, &crate::memory::run_slots::MIGRATION],
+ &[
+ &crate::memory::run_slots::BACKFILL,
+ &crate::memory::run_slots::MIGRATION,
+ ],
)
.expect("the import owns its separate live slot");
assert!(crate::memory::import::in_progress(&config));
diff --git a/crates/openhuman-core/src/memory/layout_migration/test_host.rs b/crates/openhuman-core/src/memory/layout_migration/test_host.rs
index be2e875deb..1172967e65 100644
--- a/crates/openhuman-core/src/memory/layout_migration/test_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/test_host.rs
@@ -7,10 +7,11 @@ use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::{
LearningKind, ListRequest, MemoryEngine, MemoryMeta, MetaFilter, Namespace, StoreItem,
};
+use tinymemory_tools::MemoryLayout;
use tinymemory_tools::layout_migration::{
- Engines, FlowPlacement, FsLegacyClaim, LayoutHost, LegacyClaim, MigrationStateStore, Placement, Result,
+ Engines, FlowPlacement, FsLegacyClaim, LayoutHost, LegacyClaim, MigrationStateStore, Placement,
+ Result,
};
-use tinymemory_tools::MemoryLayout;
use super::state::FileStateStore;
use crate::config::Config;
diff --git a/crates/openhuman-core/src/memory/lifecycle/adapter_tests.rs b/crates/openhuman-core/src/memory/lifecycle/adapter_tests.rs
index d246119df1..40121b6824 100644
--- a/crates/openhuman-core/src/memory/lifecycle/adapter_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/adapter_tests.rs
@@ -52,20 +52,22 @@ async fn background_prefetch_records_citations_only_when_returning_the_pack() {
.resolve(&crate::memory::scope::identity_pins(&config));
let ctx = crate::core::runtime::DispatchCtx::ambient();
- assert!(super::super::super::prefetch::pre_turn(
- &ctx,
- config.clone(),
- identity.clone(),
- "citation-thread".into(),
- 0,
- "what colour is preferred?".into(),
- 0,
- Utc::now(),
- false,
- None,
- None,
- )
- .is_none());
+ assert!(
+ super::super::super::prefetch::pre_turn(
+ &ctx,
+ config.clone(),
+ identity.clone(),
+ "citation-thread".into(),
+ 0,
+ "what colour is preferred?".into(),
+ 0,
+ Utc::now(),
+ false,
+ None,
+ None,
+ )
+ .is_none()
+ );
assert!(crate::web_chat::citations::take_turn_citations(&ctx, "citation-thread").is_empty());
super::super::super::prefetch::settle_for_test(
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks.rs b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
index d901874a38..26d383e825 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
@@ -19,7 +19,7 @@ use crate::config::Config;
use crate::core::runtime::{CoreContext, DispatchCtx};
use crate::memory::engine;
-pub use native_turn::{user_turn_index, CLOSE_TAG, MAX_TOOL_LINE_CHARS, OPEN_TAG};
+pub use native_turn::{CLOSE_TAG, MAX_TOOL_LINE_CHARS, OPEN_TAG, user_turn_index};
/// A native turn pack with the citation view used by OpenHuman's chat UI.
#[derive(Debug, Clone, PartialEq, Serialize)]
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
index ccc320b2d2..2fa57e628b 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
@@ -181,14 +181,16 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {
config.memory.recall.enabled = false;
let quiet = tinymemory_tools::layout::identity::Identity::agent("a")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &quiet,
- input("t", 0, "when do deploys happen?")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &quiet,
+ input("t", 0, "when do deploys happen?")
+ )
+ .await
+ .is_none()
+ );
assert_eq!(
stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))
.await
@@ -219,14 +221,16 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {
config.memory.recall.enabled = false;
let none = tinymemory_tools::layout::identity::Identity::agent("a")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &none,
- input("t", 4, "hi")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &none,
+ input("t", 4, "hi")
+ )
+ .await
+ .is_none()
+ );
}
#[tokio::test]
@@ -235,14 +239,16 @@ async fn pre_turn_without_an_engine_runs_the_turn_without_a_pack() {
let config = config_in(&tmp);
let identity = tinymemory_tools::layout::identity::Identity::agent("a")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &identity,
- input("t", 0, "hello")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &identity,
+ input("t", 0, "hello")
+ )
+ .await
+ .is_none()
+ );
run_post_turn(&config, &identity, reply("t", 1, "hi")).await;
}
@@ -313,15 +319,17 @@ async fn compaction_recalls_from_the_dropped_turns() {
)
.await;
assert!(pack.expect("a pack").markdown.contains("Heron"));
- assert!(compaction_work(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &identity,
- "t",
- Vec::new()
- )
- .await
- .is_none());
+ assert!(
+ compaction_work(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &identity,
+ "t",
+ Vec::new()
+ )
+ .await
+ .is_none()
+ );
}
#[tokio::test]
@@ -391,14 +399,16 @@ async fn an_engine_fault_that_is_not_account_wide_injects_nothing() {
let identity = tinymemory_tools::layout::identity::Identity::agent("orchestrator")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &identity,
- input("t", 0, "hello")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &identity,
+ input("t", 0, "hello")
+ )
+ .await
+ .is_none()
+ );
}
// ── the pack's token budget against a large store (#6718, #7023) ────────────
@@ -596,14 +606,16 @@ async fn a_blank_turn_is_refused_without_a_pack_with_or_without_logging() {
let engine = bind_reference(&config);
let identity = tinymemory_tools::layout::identity::Identity::agent("orchestrator")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &identity,
- input("t-blank", 0, " ")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &identity,
+ input("t-blank", 0, " ")
+ )
+ .await
+ .is_none()
+ );
assert!(
stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))
.await
@@ -614,24 +626,28 @@ async fn a_blank_turn_is_refused_without_a_pack_with_or_without_logging() {
config.memory.conversations.enabled = false;
let reader = tinymemory_tools::layout::identity::Identity::agent("orchestrator")
.resolve(&crate::memory::scope::identity_pins(&config));
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &reader,
- input("t-blank", 2, " ")
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &reader,
+ input("t-blank", 2, " ")
+ )
+ .await
+ .is_none()
+ );
let mut resumed = input(" ", 4, "where were we?");
resumed.5 = true;
- assert!(run_pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- &reader,
- resumed
- )
- .await
- .is_none());
+ assert!(
+ run_pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &reader,
+ resumed
+ )
+ .await
+ .is_none()
+ );
}
/// With `date_hint` on, the turn's text goes to the chat model with the date
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
index 6cf8f903a2..6719329443 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
@@ -22,8 +22,8 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, LazyLock, Mutex, Weak};
use tinymemory_api::Namespace;
-use tinymemory_tools::queue::{JobQueue as Queue, QueueError, QueueState, QueueStore};
use tinymemory_tools::BackgroundJob;
+use tinymemory_tools::queue::{JobQueue as Queue, QueueError, QueueState, QueueStore};
use tinymemory_tools::queue::{JobRun, Selection};
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
index 749431e52a..51cff36801 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use tinymemory_tools::queue::QueueState;
use tinymemory_tools::queue::MAX_ATTEMPTS;
+use tinymemory_tools::queue::QueueState;
use tinymemory_api::{ConsolidateRequest, ItemKind, Reach};
@@ -23,9 +23,11 @@ fn workspace_queues_are_released_after_the_last_holder_drops() {
drop(queue_of(&sentinel));
let queues = QUEUES.lock().unwrap();
- assert!(workspaces
- .iter()
- .all(|workspace| !queues.contains_key(workspace)));
+ assert!(
+ workspaces
+ .iter()
+ .all(|workspace| !queues.contains_key(workspace))
+ );
}
fn build(agent: &str) -> BackgroundJob {
diff --git a/crates/openhuman-core/src/memory/lifecycle/mod.rs b/crates/openhuman-core/src/memory/lifecycle/mod.rs
index ea89630045..09d996729f 100644
--- a/crates/openhuman-core/src/memory/lifecycle/mod.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/mod.rs
@@ -27,8 +27,8 @@ use std::sync::Arc;
use tinymemory_api::MemoryEngine;
use tinymemory_tools::{AgentMemory, RecallPolicy};
-use crate::config::schema::RecallSettings;
use crate::config::Config;
+use crate::config::schema::RecallSettings;
use super::engine;
use tinymemory_api::{Error, Result};
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
index bf30cf4f08..0b8ee7546d 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
@@ -13,7 +13,7 @@ use tinymemory_tools::prefetch::{
};
use crate::config::Config;
-use crate::core::runtime::{slot_for, DispatchCtx};
+use crate::core::runtime::{DispatchCtx, slot_for};
use tinymemory_tools::layout::identity::ResolvedIdentity;
use super::hooks::{self, TurnPack};
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
index a79d9e0da3..ec56f462be 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
@@ -123,20 +123,22 @@ async fn pre_turn_logs_channel_metadata_without_writing_legacy_thread_map() {
let key = Key::new(&config, &identity, thread_id, false);
let cache = cache(&crate::core::runtime::DispatchCtx::ambient());
- assert!(pre_turn(
- &crate::core::runtime::DispatchCtx::ambient(),
- config.clone(),
- identity,
- thread_id.into(),
- 0,
- "hello from telegram".into(),
- 0,
- chrono::Utc::now(),
- false,
- None,
- Some("telegram".into()),
- )
- .is_none());
+ assert!(
+ pre_turn(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ config.clone(),
+ identity,
+ thread_id.into(),
+ 0,
+ "hello from telegram".into(),
+ 0,
+ chrono::Utc::now(),
+ false,
+ None,
+ Some("telegram".into()),
+ )
+ .is_none()
+ );
drain(&cache, &key).await;
let turns = stored(
diff --git a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
index 4a065cb193..e788f4e227 100644
--- a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
@@ -251,18 +251,22 @@ async fn jobs_run_needs_an_engine_and_names_an_unknown_job() {
let config = config_in(&tmp);
assert!(jobs_run(&config, JobsRunParams::default()).await.is_err());
bind_reference(&config);
- assert!(jobs_run(&config, JobsRunParams::default())
+ assert!(
+ jobs_run(&config, JobsRunParams::default())
+ .await
+ .unwrap()
+ .runs
+ .is_empty()
+ );
+ assert!(
+ jobs_run(
+ &config,
+ JobsRunParams {
+ id: Some("x".into())
+ }
+ )
.await
- .unwrap()
- .runs
- .is_empty());
- assert!(jobs_run(
- &config,
- JobsRunParams {
- id: Some("x".into())
- }
- )
- .await
- .is_err());
+ .is_err()
+ );
assert!(jobs_list(&config).await.pending.is_empty());
}
diff --git a/crates/openhuman-core/src/memory/mod.rs b/crates/openhuman-core/src/memory/mod.rs
index d387b25db7..633f2aa20f 100644
--- a/crates/openhuman-core/src/memory/mod.rs
+++ b/crates/openhuman-core/src/memory/mod.rs
@@ -57,4 +57,4 @@ pub use schemas::{
all_controller_schemas as all_memory_controller_schemas,
all_registered_controllers as all_memory_registered_controllers,
};
-pub use tools::{MemoryTool, MEMORY_TOOL_NAME};
+pub use tools::{MEMORY_TOOL_NAME, MemoryTool};
diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rs
index 1843f68628..04d36391ae 100644
--- a/crates/openhuman-core/src/memory/ops.rs
+++ b/crates/openhuman-core/src/memory/ops.rs
@@ -167,12 +167,12 @@ pub fn apply_engine_set(config: &mut Config, params: &EngineSetParams) -> Result
TINYHUMANS_ENGINE => {
return Err(Error::InvalidRequest(
("the tinyhumans engine uses your sign-in, not an API key").into(),
- ))
+ ));
}
_ => {
return Err(Error::InvalidRequest(
("this engine takes no API key").into(),
- ))
+ ));
}
}
}
diff --git a/crates/openhuman-core/src/memory/ops_compat_tests.rs b/crates/openhuman-core/src/memory/ops_compat_tests.rs
index 722092347f..1245e43504 100644
--- a/crates/openhuman-core/src/memory/ops_compat_tests.rs
+++ b/crates/openhuman-core/src/memory/ops_compat_tests.rs
@@ -83,10 +83,12 @@ async fn single_user_reads_writes_and_forgets_ancestor_and_service_memory() {
)
.await
.unwrap();
- assert!(service_reader
- .items
- .iter()
- .any(|item| item.id.0 == service_id));
+ assert!(
+ service_reader
+ .items
+ .iter()
+ .any(|item| item.id.0 == service_id)
+ );
let service_item = stored(
&engine,
MetaFilter {
@@ -110,14 +112,16 @@ async fn single_user_reads_writes_and_forgets_ancestor_and_service_memory() {
.await
.unwrap();
assert_eq!(forgotten.forgotten, 1);
- assert!(stored(
- &engine,
- MetaFilter {
- reach: Some(tinymemory_api::Reach::exact(service_item.meta.namespace)),
- ..MetaFilter::default()
- },
- )
- .await
- .iter()
- .all(|item| item.id.0 != service_id));
+ assert!(
+ stored(
+ &engine,
+ MetaFilter {
+ reach: Some(tinymemory_api::Reach::exact(service_item.meta.namespace)),
+ ..MetaFilter::default()
+ },
+ )
+ .await
+ .iter()
+ .all(|item| item.id.0 != service_id)
+ );
}
diff --git a/crates/openhuman-core/src/memory/ops_saas_tests.rs b/crates/openhuman-core/src/memory/ops_saas_tests.rs
index 51fdc02d1d..3a2739cc53 100644
--- a/crates/openhuman-core/src/memory/ops_saas_tests.rs
+++ b/crates/openhuman-core/src/memory/ops_saas_tests.rs
@@ -1,8 +1,8 @@
use super::*;
use crate::memory::test_fixtures::{bind_reference, config_in};
use std::sync::{
- atomic::{AtomicUsize, Ordering},
Arc,
+ atomic::{AtomicUsize, Ordering},
};
use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::{
@@ -123,8 +123,7 @@ fn invalid_saas_root_is_refused_before_engine_operations() {
#[test]
fn valid_saas_identity_clamps_memory_operations_in_an_isolated_process() {
const CHILD: &str = "OPENHUMAN_TEST_SAAS_MEMORY_CLAMP";
- const TEST_NAME: &str =
- "memory::ops::saas_tests::valid_saas_identity_clamps_memory_operations_in_an_isolated_process";
+ const TEST_NAME: &str = "memory::ops::saas_tests::valid_saas_identity_clamps_memory_operations_in_an_isolated_process";
if std::env::var_os(CHILD).is_none() {
let output = std::process::Command::new(std::env::current_exe().unwrap())
@@ -278,10 +277,12 @@ fn valid_saas_identity_clamps_memory_operations_in_an_isolated_process() {
)
.await
.unwrap();
- assert!(recalled
- .citations
- .iter()
- .all(|citation| citation.id.0 != foreign));
+ assert!(
+ recalled
+ .citations
+ .iter()
+ .all(|citation| citation.id.0 != foreign)
+ );
let learned = learn(
&config,
diff --git a/crates/openhuman-core/src/memory/ops_tests.rs b/crates/openhuman-core/src/memory/ops_tests.rs
index d822099571..18d3a1f46e 100644
--- a/crates/openhuman-core/src/memory/ops_tests.rs
+++ b/crates/openhuman-core/src/memory/ops_tests.rs
@@ -369,9 +369,11 @@ async fn stores_are_scrubbed_of_secrets() {
.unwrap();
let items = stored(&engine, MetaFilter::default()).await;
assert_eq!(items.len(), 1);
- assert!(!items[0]
- .text
- .contains("abcdefghijklmnopqrstuvwxyz0123456789"));
+ assert!(
+ !items[0]
+ .text
+ .contains("abcdefghijklmnopqrstuvwxyz0123456789")
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/memory/schemas.rs b/crates/openhuman-core/src/memory/schemas.rs
index 5996f1c821..c2cbe7a778 100644
--- a/crates/openhuman-core/src/memory/schemas.rs
+++ b/crates/openhuman-core/src/memory/schemas.rs
@@ -3,10 +3,10 @@
mod defs;
mod handlers;
-use crate::core::all::RegisteredController;
use crate::core::ControllerSchema;
+use crate::core::all::RegisteredController;
-pub use defs::{schema, FUNCTIONS};
+pub use defs::{FUNCTIONS, schema};
/// Every memory function paired with the handler it dispatches to.
const HANDLERS: &[(&str, crate::core::all::ControllerHandler)] = &[
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 1338a725c2..6fb09fdc95 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -17,9 +17,9 @@ use crate::memory::types::{
SourcesSyncView,
};
use crate::memory::{backfill, brain, engine, import, layout_migration, ops, sources};
-use serde::de::DeserializeOwned;
use serde::Serialize;
-use serde_json::{json, Map, Value};
+use serde::de::DeserializeOwned;
+use serde_json::{Map, Value, json};
use tinymemory_api::{Error, Reach, Result};
use tinymemory_tools::confine::{Confinement, Policy};
use tinymemory_tools::layout::identity::Identity;
diff --git a/crates/openhuman-core/src/memory/schemas_tests.rs b/crates/openhuman-core/src/memory/schemas_tests.rs
index 3cdcf0d509..cd85d9d51d 100644
--- a/crates/openhuman-core/src/memory/schemas_tests.rs
+++ b/crates/openhuman-core/src/memory/schemas_tests.rs
@@ -1,10 +1,10 @@
use super::*;
use crate::config::Config;
-use crate::core::runtime::context::CoreContext;
use crate::core::runtime::DispatchCtx;
use crate::core::runtime::DomainSet;
+use crate::core::runtime::context::CoreContext;
use crate::memory::test_fixtures::{bind_reference, config_in};
-use serde_json::{json, Map, Value};
+use serde_json::{Map, Value, json};
use tinymemory_api::MemoryEngine;
/// Every method of the spec's RPC table (`docs/specs/memory-v2.md`), exactly.
@@ -470,10 +470,12 @@ async fn lifecycle_handlers_answer_over_a_bound_engine() {
.unwrap();
let preview = preview.get("result").unwrap_or(&preview);
assert_eq!(preview["mode"], "turn");
- assert!(preview["pack"]["markdown"]
- .as_str()
- .unwrap()
- .contains("9:30"));
+ assert!(
+ preview["pack"]["markdown"]
+ .as_str()
+ .unwrap()
+ .contains("9:30")
+ );
let ran = call(&config, "jobs_run", json!({})).await.unwrap();
assert_eq!(
@@ -555,20 +557,22 @@ async fn rpc_learn_invalidates_a_cached_prefetch_pack() {
let config = Arc::new(config.clone());
let (thread_id, turn_index, user_text, in_prompt_from, at, resumed, observed_actor) =
input();
- assert!(crate::memory::lifecycle::prefetch::pre_turn(
- &dispatch,
- config.clone(),
- identity.clone(),
- thread_id,
- turn_index,
- user_text,
- in_prompt_from,
- at,
- resumed,
- observed_actor,
- None,
- )
- .is_none());
+ assert!(
+ crate::memory::lifecycle::prefetch::pre_turn(
+ &dispatch,
+ config.clone(),
+ identity.clone(),
+ thread_id,
+ turn_index,
+ user_text,
+ in_prompt_from,
+ at,
+ resumed,
+ observed_actor,
+ None,
+ )
+ .is_none()
+ );
crate::memory::lifecycle::prefetch::settle_for_test(
&dispatch, &config, &identity, thread, false,
)
diff --git a/crates/openhuman-core/src/memory/scope_tests.rs b/crates/openhuman-core/src/memory/scope_tests.rs
index 7931494e94..c309839735 100644
--- a/crates/openhuman-core/src/memory/scope_tests.rs
+++ b/crates/openhuman-core/src/memory/scope_tests.rs
@@ -4,8 +4,8 @@ use crate::config::schema::MemoryAgentConfig;
use tinymemory_api::{MetaFilter, Namespace, Reach};
use tinymemory_tools::confine::{Confinement, Policy};
use tinymemory_tools::layout::identity::{
- account_root, actor_of_root, chat_node, validate_root, Identity, ResolvedIdentity,
- DEFAULT_AGENT_ID,
+ DEFAULT_AGENT_ID, Identity, ResolvedIdentity, account_root, actor_of_root, chat_node,
+ validate_root,
};
fn ns(value: &str) -> Namespace {
@@ -73,12 +73,13 @@ fn upstream_identity_and_confinement_keep_embedded_root_and_rpc_policy() {
.reach,
Some(Reach::exact(narrow))
);
- assert!(rpc
- .filter(Some(MetaFilter {
+ assert!(
+ rpc.filter(Some(MetaFilter {
reach: Some(Reach::subtree(ns("project:embed/team:other"))),
..MetaFilter::default()
}))
- .is_err());
+ .is_err()
+ );
let saas = Confinement {
allowed,
diff --git a/crates/openhuman-core/src/memory/sources/mod.rs b/crates/openhuman-core/src/memory/sources/mod.rs
index f55910daa0..027a04bca0 100644
--- a/crates/openhuman-core/src/memory/sources/mod.rs
+++ b/crates/openhuman-core/src/memory/sources/mod.rs
@@ -14,8 +14,8 @@ use tinymemory_integrations::sources::SourceState;
use tinymemory_integrations::sources::{Error as SourceError, SourceSpec};
use tinymemory_tools::ops::MemoryOps;
-use crate::config::schema::{MemorySourceConfig, MemorySourceKind};
use crate::config::Config;
+use crate::config::schema::{MemorySourceConfig, MemorySourceKind};
use super::engine;
use super::types::{SourceView, SourcesAddParams};
diff --git a/crates/openhuman-core/src/memory/sources/sync.rs b/crates/openhuman-core/src/memory/sources/sync.rs
index 2fbbf07246..6951112ad3 100644
--- a/crates/openhuman-core/src/memory/sources/sync.rs
+++ b/crates/openhuman-core/src/memory/sources/sync.rs
@@ -11,15 +11,15 @@ use std::path::PathBuf;
use std::sync::{Arc, LazyLock, Mutex, PoisonError};
use chrono::{DateTime, Utc};
+use tinymemory_integrations::sources::SourceKind;
+use tinymemory_integrations::sources::SourceStatus;
use tinymemory_integrations::sources::sync::{
self as module, RegisteredSource, SourceRegistry, SyncError, SyncState, SyncStatus, SyncUpdate,
Syncer,
};
-use tinymemory_integrations::sources::SourceKind;
-use tinymemory_integrations::sources::SourceStatus;
-use crate::config::schema::{MemorySourceConfig, MemorySourceKind};
use crate::config::Config;
+use crate::config::schema::{MemorySourceConfig, MemorySourceKind};
use crate::memory::engine;
use tinymemory_api::{Error, Result};
diff --git a/crates/openhuman-core/src/memory/sources/sync_tests.rs b/crates/openhuman-core/src/memory/sources/sync_tests.rs
index eed0b49518..129e75be63 100644
--- a/crates/openhuman-core/src/memory/sources/sync_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/sync_tests.rs
@@ -102,9 +102,11 @@ async fn sync_one_reports_memory_off_and_unreadable_sources() {
bind_reference(&config);
let missing = config.action_dir.join("does-not-exist");
- assert!(sync_one(&config, &folder_source("s", &missing, None))
- .await
- .is_err());
+ assert!(
+ sync_one(&config, &folder_source("s", &missing, None))
+ .await
+ .is_err()
+ );
}
#[tokio::test]
@@ -197,13 +199,15 @@ async fn a_source_already_syncing_is_not_started_twice() {
// Hold a claim as a running sync would: a second request starts nothing.
let held = syncer_for(&config).start(Some("src-once")).unwrap();
assert_eq!(held.len(), 1);
- assert!(start_sync(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- Some("src-once")
- )
- .unwrap()
- .is_empty());
+ assert!(
+ start_sync(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ Some("src-once")
+ )
+ .unwrap()
+ .is_empty()
+ );
drop(held);
assert_eq!(
start_sync(
@@ -266,12 +270,14 @@ fn sync_due_with_memory_off_starts_nothing() {
.memory
.sources
.push(folder_source("s", tmp.path(), Some(15)));
- assert!(sync_due(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- Utc::now()
- )
- .is_empty());
+ assert!(
+ sync_due(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ Utc::now()
+ )
+ .is_empty()
+ );
}
#[test]
@@ -296,8 +302,8 @@ fn reset_interrupted_marks_syncing_sources_idle() {
#[tokio::test]
async fn a_sync_queues_a_belief_build_only_for_an_engine_that_waits_for_one() {
use std::sync::Arc;
- use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::Consolidation;
+ use tinymemory_api::conformance::ReferenceEngine;
let note = || {
tinymemory_api::StoreItem::document(
diff --git a/crates/openhuman-core/src/memory/tool_budget_tests.rs b/crates/openhuman-core/src/memory/tool_budget_tests.rs
index 626e7d36eb..612385d1b8 100644
--- a/crates/openhuman-core/src/memory/tool_budget_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_budget_tests.rs
@@ -148,10 +148,12 @@ async fn parallel_memory_reads_reserve_from_the_same_time_budget() {
async fn completed_run_tracking_is_bounded() {
let budget = budget();
for i in 0..200 {
- assert!(budget
- .run(Some(&format!("turn-{i}")), async { "ok" })
- .await
- .is_ok());
+ assert!(
+ budget
+ .run(Some(&format!("turn-{i}")), async { "ok" })
+ .await
+ .is_ok()
+ );
}
// The first idle record was evicted, so it receives a fresh call allowance.
for _ in 0..8 {
@@ -170,10 +172,12 @@ async fn an_outstanding_memory_call_survives_other_runs_and_keeps_its_timeout_ci
tokio::pin!(call);
assert!(futures::poll!(call.as_mut()).is_pending());
for i in 0..128 {
- assert!(budget
- .run(Some(&format!("other-{i}")), async { "ok" })
- .await
- .is_ok());
+ assert!(
+ budget
+ .run(Some(&format!("other-{i}")), async { "ok" })
+ .await
+ .is_ok()
+ );
}
assert_eq!(call.await, Err(Refusal::TimedOut));
assert_eq!(
diff --git a/crates/openhuman-core/src/memory/tool_writes.rs b/crates/openhuman-core/src/memory/tool_writes.rs
index cef6a0011d..0af42b76a7 100644
--- a/crates/openhuman-core/src/memory/tool_writes.rs
+++ b/crates/openhuman-core/src/memory/tool_writes.rs
@@ -20,14 +20,14 @@ use async_trait::async_trait;
use serde::Deserialize;
use sha2::{Digest, Sha256};
use tinymemory_api::{Namespace, Reach, StoreItem, WriteOptions};
+use tinymemory_tools::ToolScope;
+use tinymemory_tools::WriteSink;
use tinymemory_tools::confine::Policy;
use tinymemory_tools::list_store::{ListStore, StoreError};
use tinymemory_tools::pending::{
Ack, Binding, Entry, Epoch, FenceToken, Limits, PendingError, PendingWrites, WriteExecutor,
WriteGate, WriteOperation,
};
-use tinymemory_tools::ToolScope;
-use tinymemory_tools::WriteSink;
use super::types::ForgetParams;
use crate::config::Config;
diff --git a/crates/openhuman-core/src/memory/tool_writes_tests.rs b/crates/openhuman-core/src/memory/tool_writes_tests.rs
index 2d94c5a51d..82852c6b63 100644
--- a/crates/openhuman-core/src/memory/tool_writes_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_writes_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::memory::test_fixtures::{bind_reference, config_in, stored, RefusingEngine};
+use crate::memory::test_fixtures::{RefusingEngine, bind_reference, config_in, stored};
use crate::memory::tools::CallFacts;
use serde_json::json;
use tinymemory_api::{MetaFilter, Namespace, Reach};
@@ -230,12 +230,14 @@ fn private_outbox_is_scrubbed_before_persistence_and_has_a_size_limit() {
);
}
let huge = "x".repeat(MAX_BYTES);
- assert!(enqueue(
- &config,
- &json!({"action":"learn","text":huge}),
- &facts(&config)
- )
- .is_err());
+ assert!(
+ enqueue(
+ &config,
+ &json!({"action":"learn","text":huge}),
+ &facts(&config)
+ )
+ .is_err()
+ );
assert_eq!(read(&config.workspace_dir).unwrap().len(), 1);
}
@@ -346,12 +348,14 @@ fn corrupt_existing_outbox_is_preserved_and_refuses_new_writes() {
let config = config_in(&tmp);
let file = path(&config.workspace_dir);
super::super::files::write_private(&file, b"corrupt existing state").unwrap();
- assert!(enqueue(
- &config,
- &json!({"action":"learn","text":"Prefers tea"}),
- &facts(&config)
- )
- .is_err());
+ assert!(
+ enqueue(
+ &config,
+ &json!({"action":"learn","text":"Prefers tea"}),
+ &facts(&config)
+ )
+ .is_err()
+ );
assert_eq!(std::fs::read(&file).unwrap(), b"corrupt existing state");
}
@@ -420,12 +424,14 @@ fn a_full_outbox_keeps_existing_writes_and_refuses_a_new_one() {
let mut entries = read(&config.workspace_dir).unwrap();
entries.resize(MAX_PENDING, entries[0].clone());
write(&config.workspace_dir, &entries).unwrap();
- assert!(enqueue(
- &config,
- &json!({"action":"learn","text":"new"}),
- &facts(&config)
- )
- .is_err());
+ assert!(
+ enqueue(
+ &config,
+ &json!({"action":"learn","text":"new"}),
+ &facts(&config)
+ )
+ .is_err()
+ );
assert_eq!(read(&config.workspace_dir).unwrap().len(), MAX_PENDING);
}
@@ -654,12 +660,16 @@ async fn erasing_one_owner_fences_pending_writes_from_every_team_root() {
let fence = fence_and_clear(&crate::core::runtime::DispatchCtx::ambient(), &first)
.await
.unwrap();
- assert!(read_at(&queue_path(&first, &facts(&first).reach.at))
- .unwrap()
- .is_empty());
- assert!(read_at(&queue_path(&second, &facts(&second).reach.at))
- .unwrap()
- .is_empty());
+ assert!(
+ read_at(&queue_path(&first, &facts(&first).reach.at))
+ .unwrap()
+ .is_empty()
+ );
+ assert!(
+ read_at(&queue_path(&second, &facts(&second).reach.at))
+ .unwrap()
+ .is_empty()
+ );
drop(fence);
let engine = bind_reference(&first);
assert_eq!(drain(&first).await, 0);
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index f009391539..5febe686da 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -6,11 +6,11 @@ use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinymemory_api::{Namespace, Reach, ThreadWindow, ToolCallRef};
use tinymemory_tools::{
- concurrency_for, is_write_action, permission_for, CallContext, ConcurrencyClass, MemoryTools,
- PermissionClass, Refusal, RunBudget, SingleTool, ToolScope,
+ CallContext, ConcurrencyClass, MemoryTools, PermissionClass, Refusal, RunBudget, SingleTool,
+ ToolScope, concurrency_for, is_write_action, permission_for,
};
use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunContext};
@@ -203,7 +203,7 @@ impl MemoryTool {
Err(_) => {
return ToolResult::error(render_error(tinymemory_api::Error::Unavailable(
"memory write queue unavailable".into(),
- )))
+ )));
}
}
} else {
@@ -310,8 +310,7 @@ fn budget_refusal(refusal: Refusal) -> ToolResult {
}
_ => format!("Memory budget exhausted for this run. {CONTINUE_WITHOUT_MEMORY}"),
};
- ToolResult::error(message)
- .with_metadata(json!({ REFUSAL_METADATA_KEY: "refused" }))
+ ToolResult::error(message).with_metadata(json!({ REFUSAL_METADATA_KEY: "refused" }))
}
Refusal::TimedOut => ToolResult::error(format!(
"Memory did not finish within its latency budget and is unavailable for this run. {CONTINUE_WITHOUT_MEMORY}"
diff --git a/crates/openhuman-core/src/memory/tools_offline_tests.rs b/crates/openhuman-core/src/memory/tools_offline_tests.rs
index 85d2a98125..f9c6e89283 100644
--- a/crates/openhuman-core/src/memory/tools_offline_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_offline_tests.rs
@@ -40,9 +40,11 @@ async fn queued_writes_work_without_an_available_engine_but_not_when_explicitly_
&pending[1].operation,
tinymemory_tools::pending::WriteOperation::Forget { .. }
));
- assert!(pending
- .iter()
- .all(|entry| entry.scope_root == facts.reach.at));
+ assert!(
+ pending
+ .iter()
+ .all(|entry| entry.scope_root == facts.reach.at)
+ );
let mut disabled = config.clone();
disabled.components.memory = false;
diff --git a/crates/openhuman-core/src/memory/tools_saas_tests.rs b/crates/openhuman-core/src/memory/tools_saas_tests.rs
index 141bc93370..39c1f5e382 100644
--- a/crates/openhuman-core/src/memory/tools_saas_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_saas_tests.rs
@@ -2,8 +2,8 @@ use super::*;
use crate::config::schema::MemoryAgentConfig;
use crate::memory::test_fixtures::config_in;
use std::sync::{
- atomic::{AtomicUsize, Ordering},
Arc,
+ atomic::{AtomicUsize, Ordering},
};
use tinymemory_api::conformance::ReferenceEngine;
use tinymemory_api::{
@@ -79,8 +79,7 @@ fn isolate(test_name: &str, marker: &str) -> Option<std::process::Output> {
#[test]
fn invalid_saas_roots_and_agent_overrides_reject_memory_tool_reads() {
const MARKER: &str = "OPENHUMAN_TEST_SAAS_MEMORY_TOOL_INVALID_ROOT";
- const TEST_NAME: &str =
- "memory::tools::saas_tests::invalid_saas_roots_and_agent_overrides_reject_memory_tool_reads";
+ const TEST_NAME: &str = "memory::tools::saas_tests::invalid_saas_roots_and_agent_overrides_reject_memory_tool_reads";
if let Some(output) = isolate(TEST_NAME, MARKER) {
assert!(
output.status.success()
@@ -159,8 +158,7 @@ fn invalid_saas_roots_and_agent_overrides_reject_memory_tool_reads() {
#[test]
fn valid_saas_root_keeps_tool_reads_inside_the_authenticated_namespace() {
const MARKER: &str = "OPENHUMAN_TEST_SAAS_MEMORY_TOOL_VALID_ROOT";
- const TEST_NAME: &str =
- "memory::tools::saas_tests::valid_saas_root_keeps_tool_reads_inside_the_authenticated_namespace";
+ const TEST_NAME: &str = "memory::tools::saas_tests::valid_saas_root_keeps_tool_reads_inside_the_authenticated_namespace";
if let Some(output) = isolate(TEST_NAME, MARKER) {
assert!(
output.status.success()
@@ -227,14 +225,18 @@ fn valid_saas_root_keeps_tool_reads_inside_the_authenticated_namespace() {
.unwrap();
assert!(!recall.is_error, "{}", recall.text());
let evidence: Value = serde_json::from_str(&recall.text()).unwrap();
- assert!(evidence["evidence"]
- .as_str()
- .unwrap()
- .contains("acme boundary marker"));
- assert!(!evidence["evidence"]
- .as_str()
- .unwrap()
- .contains("foreign boundary marker"));
+ assert!(
+ evidence["evidence"]
+ .as_str()
+ .unwrap()
+ .contains("acme boundary marker")
+ );
+ assert!(
+ !evidence["evidence"]
+ .as_str()
+ .unwrap()
+ .contains("foreign boundary marker")
+ );
let fetch = tool
.execute_with_context(
@@ -246,14 +248,18 @@ fn valid_saas_root_keeps_tool_reads_inside_the_authenticated_namespace() {
.unwrap();
assert!(!fetch.is_error, "{}", fetch.text());
let page: Value = serde_json::from_str(&fetch.text()).unwrap();
- assert!(page["matches"]
- .as_str()
- .unwrap()
- .contains("acme boundary marker"));
- assert!(!page["matches"]
- .as_str()
- .unwrap()
- .contains("foreign boundary marker"));
+ assert!(
+ page["matches"]
+ .as_str()
+ .unwrap()
+ .contains("acme boundary marker")
+ );
+ assert!(
+ !page["matches"]
+ .as_str()
+ .unwrap()
+ .contains("foreign boundary marker")
+ );
assert_eq!(reads.load(Ordering::SeqCst), 2);
});
println!("SAAS_MEMORY_TOOL_VALID_ROOT_CHILD_PASSED");
diff --git a/crates/openhuman-core/src/memory/tools_test_support.rs b/crates/openhuman-core/src/memory/tools_test_support.rs
index 1ca289bf2a..63b0a93362 100644
--- a/crates/openhuman-core/src/memory/tools_test_support.rs
+++ b/crates/openhuman-core/src/memory/tools_test_support.rs
@@ -1,6 +1,6 @@
//! Shared test adapters for the memory tool's native facade.
-use super::{is_write_action, CallFacts, MemoryTool};
+use super::{CallFacts, MemoryTool, is_write_action};
use crate::config::Config;
use crate::core::runtime::DispatchCtx;
use serde_json::Value;
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index 4006bfce81..568dc97f0b 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -456,9 +456,11 @@ async fn learnings_are_shared_under_a_root_and_a_team_root_is_kept_apart() {
);
assert!(after_forget.iter().any(|hit| hit.id == main_item.id));
assert!(after_forget.iter().any(|hit| hit.text.contains("arxiv")));
- assert!(after_forget
- .iter()
- .any(|hit| hit.text.contains("british english")));
+ assert!(
+ after_forget
+ .iter()
+ .any(|hit| hit.text.contains("british english"))
+ );
}
/// The reference engine, recording how far each single store waited.