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
fix(memory): place legacy brain documents with main's brain_node
M3gA-Mind42df0d09e733
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rsindex 9fafb3721c..c0da42e150 100644--- a/crates/openhuman-core/src/memory/brain.rs+++ b/crates/openhuman-core/src/memory/brain.rs@@ -124,7 +124,18 @@ pub fn brain_node(source: &BrainSource,item: &StoreItem,) -> MemoryResult<Namespace> {- if config.memory.split_github_by_repo && *source == BrainSource::Github {+ brain_node_with(config.memory.split_github_by_repo, layout, source, item)+}++/// [`brain_node`] with `[memory] split_github_by_repo` given, for a caller+/// that holds the setting rather than the config (the layout migration).+pub fn brain_node_with(+ split_github_by_repo: bool,+ layout: &MemoryLayout,+ source: &BrainSource,+ item: &StoreItem,+) -> MemoryResult<Namespace> {+ if split_github_by_repo && *source == BrainSource::Github {if let Some(repo) = github_collection(item) {return Ok(layout.brain_collection(source, &repo)?);}diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rsindex cced44bcef..56e865cfe7 100644--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs@@ -37,6 +37,7 @@ impl LayoutHost for AppHost {layout,chat_node,flows: FlowPlacement::WithRoot,+ split_github_by_repo: config.memory.split_github_by_repo,})}diff --git a/crates/openhuman-core/src/memory/layout_migration/cleanup_tests.rs b/crates/openhuman-core/src/memory/layout_migration/cleanup_tests.rsindex e138dcd221..39311f4a41 100644--- a/crates/openhuman-core/src/memory/layout_migration/cleanup_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/cleanup_tests.rs@@ -17,6 +17,7 @@ fn placement() -> Placement {layout: MemoryLayout::new(Namespace::ROOT).unwrap(),chat_node: "ws:main".parse().unwrap(),flows: FlowPlacement::WithRoot,+ split_github_by_repo: false,}}diff --git a/crates/openhuman-core/src/memory/layout_migration/copy_tests.rs b/crates/openhuman-core/src/memory/layout_migration/copy_tests.rsindex 82465e00c9..632670729f 100644--- a/crates/openhuman-core/src/memory/layout_migration/copy_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/copy_tests.rs@@ -13,6 +13,7 @@ fn placement() -> Placement {layout: MemoryLayout::new(Namespace::ROOT).unwrap(),chat_node: "ws:main".parse().unwrap(),flows: FlowPlacement::WithRoot,+ split_github_by_repo: false,}}diff --git a/crates/openhuman-core/src/memory/layout_migration/map.rs b/crates/openhuman-core/src/memory/layout_migration/map.rsindex bb8abace98..b1446f7d38 100644--- a/crates/openhuman-core/src/memory/layout_migration/map.rs+++ b/crates/openhuman-core/src/memory/layout_migration/map.rs@@ -4,8 +4,10 @@//! later sync of the same item replays instead of storing a duplicate.//!//! - **Brain documents** at `source:<id>` go to W4's connector node:-//! [`legacy_brain_node`] then [`file_into`], the same placement new syncs-//! use (`pdf`, `markdown` and the other per-format nodes become `files`).+//! [`legacy_brain_node`], then [`brain_node_with`] and [`file_into`]: the+//! same placement new syncs use (`pdf`, `markdown` and the other+//! per-format nodes become `files`; GitHub splits by repository when the+//! setting is on).//! - **Conversations** are pooled at the chat node; the agent id stays in//! the item's metadata.//! - **Workflow items** (keyed memory and run digests, tagged `flow:<id>`)@@ -17,7 +19,7 @@use tinymemory_api::{ItemKind, Namespace, SegmentKind, StoreItem};use tinymemory_tools::MemoryLayout;-use crate::memory::brain::{file_into, legacy_brain_node};+use crate::memory::brain::{brain_node_with, file_into, legacy_brain_node};use crate::memory::error::MemoryResult;/// The tag every workflow item carries (`crate::flows::FLOWS_TAG`). Kept here@@ -42,6 +44,9 @@ pub struct Placement {pub chat_node: Namespace,/// Where workflow items go.pub flows: FlowPlacement,+ /// `[memory] split_github_by_repo`: GitHub documents go one collection+ /// per repository, as a sync files them now.+ pub split_github_by_repo: bool,}/// The flow a workflow item belongs to: its `flow:<id>` tag, when it also@@ -85,7 +90,9 @@ impl Placement {let namespace = item.meta().namespace.clone();if let Some(id) = legacy_source(self.layout.root(), &namespace) {let source = legacy_brain_node(id, &item);- return file_into(&self.layout, &source, item);+ let node =+ brain_node_with(self.split_github_by_repo, &self.layout, &source, &item)?;+ return Ok(file_into(node, item));}}Ok(item)diff --git a/crates/openhuman-core/src/memory/layout_migration/map_tests.rs b/crates/openhuman-core/src/memory/layout_migration/map_tests.rsindex 8ecc259683..18d0bb01a0 100644--- a/crates/openhuman-core/src/memory/layout_migration/map_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/map_tests.rs@@ -13,6 +13,7 @@ fn placement(root: &str) -> Placement {layout: MemoryLayout::new(ns(root)).unwrap(),chat_node: ns("ws:main"),flows: FlowPlacement::WithRoot,+ split_github_by_repo: false,}}@@ -94,6 +95,25 @@ fn a_connector_document_keeps_its_node() {assert_eq!(placed.meta().namespace, ns("source:gmail"));}+#[test]+fn a_github_document_goes_to_its_repository_when_the_setting_splits_them() {+ let mut item = document("source:github", SourceKind::Composio, None);+ item.meta_mut().repo = Some("Acme/Widgets".into());+ let mut placement = placement("root");+ assert_eq!(+ placement.place(item.clone()).unwrap().meta().namespace,+ ns("source:github")+ );+ placement.split_github_by_repo = true;+ assert_eq!(+ placement.place(item).unwrap().meta().namespace,+ placement+ .layout+ .brain_collection(&BrainSource::Github, "acme--widgets")+ .unwrap()+ );+}+#[test]fn a_conversation_is_pooled_at_the_chat_node_with_its_agent() {let placement = placement("root");diff --git a/crates/openhuman-core/src/memory/layout_migration/test_host.rs b/crates/openhuman-core/src/memory/layout_migration/test_host.rsindex 1cb58ed033..c486b160f2 100644--- a/crates/openhuman-core/src/memory/layout_migration/test_host.rs+++ b/crates/openhuman-core/src/memory/layout_migration/test_host.rs@@ -82,6 +82,7 @@ impl LayoutHost for FakeHost {.map_err(|e| MemoryError::invalid(e.to_string()))?,chat_node: "ws:main".parse().unwrap(),flows: FlowPlacement::WithRoot,+ split_github_by_repo: false,})}