Skip to content

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

refactor(memory): split brain tests into a dedicated module

Steven Enamakel86bedd47a2ba
diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rs
index fc948c54fb..14ec1f456f 100644
--- a/crates/openhuman-core/src/memory/brain_tests.rs
+++ b/crates/openhuman-core/src/memory/brain_tests.rs
@@ -1,5 +1,6 @@
use super::*;
+
use tinymemory_tools::layout::placement::file_into;
use tinymemory_api::{ItemKind, MemoryMeta, MetaFilter};
@@ -56,7 +57,7 @@ async fn a_sources_collections_count_and_forget_with_it() {
};
engine.store(StoreItem::document(text, meta)).await.unwrap();
}
- let view = sources(&config).await.unwrap();
+ let view = sources(&config, &MemoryIdentity::root()).await.unwrap();
let counts: Vec<(&str, u64)> = view
.sources
.iter()
@@ -67,6 +68,7 @@ async fn a_sources_collections_count_and_forget_with_it() {
let gone = forget(
&config,
+ &MemoryIdentity::root(),
BrainForgetParams {
source: "github".into(),
},
@@ -92,6 +94,7 @@ async fn text_is_ingested_searched_counted_and_forgotten_per_source() {
let ingested = ingest(
&config,
+ &MemoryIdentity::root(),
BrainIngestParams {
path: None,
text: Some("Refunds are issued within 14 days.".into()),
@@ -104,6 +107,7 @@ async fn text_is_ingested_searched_counted_and_forgotten_per_source() {
assert_eq!(ingested.source, "notion");
ingest(
&config,
+ &MemoryIdentity::root(),
BrainIngestParams {
path: None,
text: Some("Onboarding takes a week.".into()),
@@ -122,13 +126,14 @@ async fn text_is_ingested_searched_counted_and_forgotten_per_source() {
"one belief build per source"
);
- let counts = sources(&config).await.unwrap();
+ let counts = sources(&config, &MemoryIdentity::root()).await.unwrap();
assert_eq!(counts.root, "root");
assert_eq!(counts.sources.len(), 2);
assert_eq!(counts.unfiled, 0);
let found = search(
&config,
+ &MemoryIdentity::root(),
BrainSearchParams {
query: "refunds".into(),
source: Some("notion".into()),
@@ -141,6 +146,7 @@ async fn text_is_ingested_searched_counted_and_forgotten_per_source() {
let gone = forget(
&config,
+ &MemoryIdentity::root(),
BrainForgetParams {
source: "notion".into(),
},
@@ -182,12 +188,13 @@ async fn ingest_refuses_bad_input() {
},
] {
assert!(matches!(
- ingest(&config, params).await,
+ ingest(&config,&MemoryIdentity::root(), params).await,
Err(MemoryError::InvalidRequest(_))
));
}
assert!(search(
&config,
+ &MemoryIdentity::root(),
BrainSearchParams {
query: " ".into(),
source: None,
@@ -207,6 +214,7 @@ async fn a_file_is_converted_and_filed_under_files() {
std::fs::write(&path, "# Guide\n\nAlways tag releases.").unwrap();
let ingested = ingest(
&config,
+ &MemoryIdentity::root(),
BrainIngestParams {
path: Some(path.display().to_string()),
text: None,
@@ -236,6 +244,7 @@ async fn an_ingest_queues_a_belief_build_only_for_an_engine_that_waits_for_one()
);
ingest(
&config,
+ &MemoryIdentity::root(),
BrainIngestParams {
path: None,
text: Some("Refunds are issued within 14 days.".into()),
@@ -280,7 +289,7 @@ async fn ingest_refuses_a_credential_store_a_system_root_traversal_and_null_byte
format!("{}/../guide.md", notes.display()),
format!("{}\0.md", tmp.path().join("guide").display()),
] {
- let result = ingest(&config, path_params(path.clone())).await;
+ let result = ingest(&config,&MemoryIdentity::root(), path_params(path.clone())).await;
assert!(
matches!(result, Err(MemoryError::InvalidRequest(_))),
"{path:?}: {result:?}"
@@ -301,7 +310,7 @@ async fn ingest_refuses_a_symlink_into_a_credential_store() {
let link = tmp.path().join("innocent.md");
std::os::unix::fs::symlink(aws.join("credentials"), &link).unwrap();
- let result = ingest(&config, path_params(link.display().to_string())).await;
+ let result = ingest(&config,&MemoryIdentity::root(), path_params(link.display().to_string())).await;
assert!(
matches!(result, Err(MemoryError::InvalidRequest(_))),
"{result:?}"