The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(memory): extract place_and_store from source sync
Steven Enamakel43988a9a366f
diff --git a/crates/openhuman-core/src/memory/sources/mod_tests.rs b/crates/openhuman-core/src/memory/sources/mod_tests.rsindex 0797724d28..249b0767e2 100644--- a/crates/openhuman-core/src/memory/sources/mod_tests.rs+++ b/crates/openhuman-core/src/memory/sources/mod_tests.rs@@ -1,7 +1,8 @@use super::*;use crate::memory::error::INVALID_REQUEST;use crate::memory::test_fixtures::{bind_reference, config_in, stored};-use chrono::Duration;+use chrono::Utc;+use crate::memory::types::SourceStatus;use tinymemory_api::{DocumentBody, MemoryMeta, SourceKind, SourceRef, StoreItem};fn add_params(kind: &str, target: &str) -> SourcesAddParams {diff --git a/crates/openhuman-core/src/memory/sources/sync.rs b/crates/openhuman-core/src/memory/sources/sync.rsindex 18894a2907..5c859c06c9 100644--- a/crates/openhuman-core/src/memory/sources/sync.rs+++ b/crates/openhuman-core/src/memory/sources/sync.rs@@ -146,17 +146,37 @@ async fn run(config: &Config, source: &MemorySourceConfig) -> Result<u64, SyncEr).await?;let layout = super::layout_of_source(config, source);- let brain_source = crate::memory::brain::brain_source(source.kind);+ place_and_store(+ config,+ &bound,+ collected.items,+ (source.kind, &source.id),+ &layout,+ )+ .await+}++/// Files `items` into `layout`'s brain, each under the brain source it+/// belongs to (`memory::brain::brain_node`), stores them through the module,+/// and queues one belief build per node touched. Returns how many were stored.+pub(crate) async fn place_and_store(+ config: &Config,+ bound: &engine::BoundEngine,+ items: Vec<tinymemory_api::StoreItem>,+ (kind, source_id): (MemorySourceKind, &str),+ layout: &tinymemory_tools::MemoryLayout,+) -> Result<u64, SyncError> {+ let brain_source = crate::memory::brain::brain_source(kind);// Placing an item under its brain node is pure, so every one is placed up// front: the module stores `(node, item)` pairs and reports the nodes hit.- let mut placed = Vec::with_capacity(collected.items.len());- for item in collected.items {- let node = crate::memory::brain::brain_node(config, &layout, &brain_source, &item)+ let mut placed = Vec::with_capacity(items.len());+ for item in items {+ let node = crate::memory::brain::brain_node(config, layout, &brain_source, &item).map_err(|error| SyncError::Invalid(error.to_string()))?;let item = tinymemory_tools::layout::placement::file_into(node.clone(), item);placed.push((node, item));}- let stored = module::store_all(bound.engine.as_ref(), &source.id, placed).await?;+ let stored = module::store_all(bound.engine.as_ref(), source_id, placed).await?;// An engine that rebuilds beliefs on its own needs no build job.let automatic =bound.engine.descriptor().consolidation == tinymemory_api::Consolidation::Automatic;diff --git a/crates/openhuman-core/src/memory/sources/sync_tests.rs b/crates/openhuman-core/src/memory/sources/sync_tests.rsindex f2fa96cfa6..c2268bb6dd 100644--- a/crates/openhuman-core/src/memory/sources/sync_tests.rs+++ b/crates/openhuman-core/src/memory/sources/sync_tests.rs@@ -274,7 +274,7 @@ async fn a_sync_queues_a_belief_build_only_for_an_engine_that_waits_for_one() {id: "reference".into(),endpoint: "memory://reference".into(),};- let stored = store_all(+ let stored = place_and_store(&config,&bound,vec![note()],@@ -306,7 +306,7 @@ async fn github_files_per_repository_only_when_switched_on() {let sync = |config: Config, items| {let bound = bound.clone();async move {- store_all(+ place_and_store(&config,&bound,items,