Skip to content

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

refactor(memory): move the legacy brain-node mapping to the migration

M3gA-Mind4171b6ab2550
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rs
index d843ee102b..cb0a71363b 100644
--- a/crates/openhuman-core/src/memory/brain.rs
+++ b/crates/openhuman-core/src/memory/brain.rs
@@ -53,39 +53,6 @@ pub fn brain_source(kind: MemorySourceKind, target: &str) -> BrainSource {
}
}
-/// The brain source a document filed under the old per-type layout belongs
-/// to now, for the migration that moves it: `old_source_id` is the id of
-/// the `source:<id>` node it sits at, `item` the document itself.
-///
-/// - Per-format nodes (`pdf`, `markdown`, `docx`, `xlsx`, `pptx`, `code`,
-/// `other`) held local files: `files`.
-/// - `web` held links and feeds, but also HTML files from a folder or an
-/// upload; a document with a file kind or a file path is a file.
-/// - Any other node was a connector: its canonical slug (`google_drive`
-/// becomes `googledrive`), so `notion`, `github` and `gmail` stay put.
-#[must_use]
-pub fn legacy_brain_node(old_source_id: &str, item: &StoreItem) -> BrainSource {
- let id = crate::integrations::composio::tools::canonicalize_toolkit_slug(old_source_id);
- match id.as_str() {
- "files" | "pdf" | "markdown" | "md" | "docx" | "xlsx" | "pptx" | "code" | "other" => {
- files_source()
- }
- "web" => {
- let meta = item.meta();
- let file = matches!(
- meta.source.kind,
- tinymemory_api::SourceKind::File | tinymemory_api::SourceKind::Folder
- ) || meta.file_path.is_some();
- if file {
- files_source()
- } else {
- BrainSource::Web
- }
- }
- _ => id.parse().unwrap_or_else(|_| files_source()),
- }
-}
-
/// `item` placed in `layout`'s brain under `source`: the source's node, and
/// no agent id (the brain belongs to every agent).
pub fn file_into(
diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rs
index 5956f7db52..154a7af44c 100644
--- a/crates/openhuman-core/src/memory/brain_tests.rs
+++ b/crates/openhuman-core/src/memory/brain_tests.rs
@@ -45,52 +45,6 @@ fn synced_items_are_filed_by_their_connector() {
assert_eq!(files_source().to_string(), "files");
}
-#[test]
-fn legacy_nodes_map_to_their_connector() {
- use tinymemory_api::{SourceKind, SourceRef};
- let item = |kind: SourceKind, path: Option<&str>| {
- let mut item = document(None, path);
- item.meta_mut().source = SourceRef { kind, id: None };
- item
- };
- let link = item(SourceKind::Link, None);
- for old in [
- "pdf", "markdown", "md", "docx", "xlsx", "pptx", "code", "other", "files",
- ] {
- assert_eq!(legacy_brain_node(old, &link), files_source(), "{old}");
- }
- // `web` held links and feeds, and HTML files that were filed beside them.
- assert_eq!(legacy_brain_node("web", &link), BrainSource::Web);
- assert_eq!(
- legacy_brain_node("web", &item(SourceKind::Rss, None)),
- BrainSource::Web
- );
- assert_eq!(
- legacy_brain_node("web", &item(SourceKind::Folder, None)),
- files_source()
- );
- assert_eq!(
- legacy_brain_node("web", &item(SourceKind::File, None)),
- files_source()
- );
- // An upload carried the `Link` kind `web` implies, but kept its path.
- assert_eq!(
- legacy_brain_node("web", &item(SourceKind::Link, Some("/u/pricing.html"))),
- files_source()
- );
- // Connectors keep their node, under the slug Composio uses.
- assert_eq!(legacy_brain_node("notion", &link), BrainSource::Notion);
- assert_eq!(legacy_brain_node("github", &link), BrainSource::Github);
- assert_eq!(
- legacy_brain_node("gmail", &link),
- BrainSource::Other("gmail".into())
- );
- assert_eq!(
- legacy_brain_node("google_drive", &link),
- BrainSource::Other("googledrive".into())
- );
-}
-
#[test]
fn filing_moves_an_item_to_its_source_node_without_an_agent() {
let team = MemoryLayout::new("team:acme".parse().unwrap()).unwrap();
diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rs
index c5dced4785..a0eb5bbdfd 100644
--- a/tests/memory_v2_e2e.rs
+++ b/tests/memory_v2_e2e.rs
@@ -1326,45 +1326,9 @@ async fn local_files_and_text_file_under_the_files_source() {
}
#[tokio::test]
-async fn legacy_brain_nodes_stay_readable_and_aliased_toolkits_are_one_source() {
+async fn an_aliased_toolkit_is_one_memory_source() {
let f = Fixture::new(true).await;
- // A document at a per-format node from before (`source:pdf`) stays
- // listed, searchable and forgettable beside `files`, until the
- // migration re-files it.
- let legacy = f
- .ok(
- "openhuman.memory_brain_ingest",
- json!({ "text": "The old vendor code is PV-7023", "source": "pdf" }),
- )
- .await;
- assert_eq!(legacy["source"], json!("pdf"), "{legacy}");
- f.ok(
- "openhuman.memory_brain_ingest",
- json!({ "text": "The new vendor code is PV-9000" }),
- )
- .await;
- let sources = f.ok("openhuman.memory_brain_sources", json!({})).await;
- let mut listed: Vec<String> = sources["sources"]
- .as_array()
- .expect("sources")
- .iter()
- .map(|s| s["source"].as_str().unwrap_or_default().to_string())
- .collect();
- listed.sort();
- assert_eq!(listed, ["files", "pdf"], "{sources}");
- let found = f
- .ok(
- "openhuman.memory_brain_search",
- json!({ "query": "vendor code", "source": "pdf" }),
- )
- .await;
- assert_eq!(found["hits"].as_array().unwrap().len(), 1, "{found}");
- let gone = f
- .ok("openhuman.memory_brain_forget", json!({ "source": "pdf" }))
- .await;
- assert_eq!(gone["forgotten"], json!(1), "{gone}");
-
// A toolkit added under an alias is stored under the slug Composio uses,
// and adding it again under that slug is a duplicate.
let drive = f