Skip to content

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

test(memory): cover hosted folder deletes and the episodic step end to end

Shanuda75f0098816
diff --git a/tests/memory_engine_migrate_e2e.rs b/tests/memory_engine_migrate_e2e.rs
index d3094534c8..8890bd829f 100644
--- a/tests/memory_engine_migrate_e2e.rs
+++ b/tests/memory_engine_migrate_e2e.rs
@@ -50,9 +50,8 @@ fn engine_migrate_copies_the_module_into_the_hosted_engine_then_switches() {
.is_some_and(|t| t.contains("canary fact carried across engines"))),
"the migrated record must exist in the hosted engine"
);
- // Past the keyed records, every step reports, in order. The pinned
- // module serves documents, goals and the profile, so those ran; what it
- // does not serve is named rather than failed.
+ // Past the keyed records, every step reports, in order, and none
+ // fails.
let steps = status["steps"].as_array().expect("steps");
let names: Vec<&str> = steps.iter().filter_map(|s| s["step"].as_str()).collect();
assert_eq!(
@@ -63,6 +62,14 @@ fn engine_migrate_copies_the_module_into_the_hosted_engine_then_switches() {
for step in steps {
assert_eq!(step["failed"], 0, "{step}");
}
+ // The pinned module serves `EpisodicPortability` and hosted memory
+ // takes it, so the conversation history step runs over the bus rather
+ // than being skipped.
+ let episodic = &steps[3];
+ assert!(
+ episodic["skipped_because"].is_null(),
+ "the conversation history step must run: {episodic}"
+ );
let documents = &steps[0];
assert!(documents["skipped_because"].is_null(), "{documents}");
assert!(
diff --git a/tests/memory_hosted_surface_e2e.rs b/tests/memory_hosted_surface_e2e.rs
index e82cefedc1..94b9e2af4a 100644
--- a/tests/memory_hosted_surface_e2e.rs
+++ b/tests/memory_hosted_surface_e2e.rs
@@ -237,6 +237,80 @@ fn a_local_folder_syncs_into_hosted_memory() {
});
}
+/// Adds `folder` as a folder source and answers its id.
+async fn add_folder(fx: &Fixture, folder: &std::path::Path) -> String {
+ let v = fx
+ .call(
+ "openhuman.memory_sources_add",
+ json!({
+ "kind": "folder",
+ "label": "Notes",
+ "enabled": true,
+ "path": folder.to_string_lossy(),
+ }),
+ )
+ .await;
+ result_of(&v, "add a folder source")["source"]["id"]
+ .as_str()
+ .expect("a source id")
+ .to_string()
+}
+
+/// Whether the hosted double holds an event whose text contains `needle`.
+fn hosted_holds(fx: &Fixture, needle: &str) -> bool {
+ fx.hosted.events.lock().unwrap().iter().any(|event| {
+ event["content"]["text"]
+ .as_str()
+ .is_some_and(|text| text.contains(needle))
+ })
+}
+
+/// A file deleted from a host-synced folder is forgotten from hosted memory
+/// on the next sync, by the id the sink answered for it. A walk that finds
+/// the folder empty forgets nothing and keeps the record, so a later walk
+/// still can.
+#[test]
+fn a_file_deleted_from_a_synced_folder_is_forgotten_from_hosted_memory() {
+ run_on_big_stack("hosted-folder-delete", || async {
+ let fx = Fixture::new().await;
+ bind_hosted(&fx).await;
+ let folder = fx._tmp.path().join("deletes");
+ std::fs::create_dir_all(&folder).expect("folder");
+ std::fs::write(folder.join("tea.md"), "# Tea\n\nOolong, always.").expect("tea");
+ std::fs::write(folder.join("coffee.md"), "# Coffee\n\nNever before noon.").expect("coffee");
+ let source_id = add_folder(&fx, &folder).await;
+ let sync = || {
+ fx.call(
+ "openhuman.memory_sources_sync",
+ json!({ "source_id": source_id }),
+ )
+ };
+ result_of(&sync().await, "first sync");
+ assert!(hosted_holds(&fx, "Never before noon."), "coffee is synced");
+
+ let tea = std::fs::read_to_string(folder.join("tea.md")).expect("read tea");
+ std::fs::remove_file(folder.join("tea.md")).expect("hide tea");
+ std::fs::remove_file(folder.join("coffee.md")).expect("delete coffee");
+ result_of(&sync().await, "sync over an empty folder");
+ assert!(
+ hosted_holds(&fx, "Never before noon."),
+ "an empty walk forgets nothing"
+ );
+
+ std::fs::write(folder.join("tea.md"), tea).expect("tea is back");
+ result_of(&sync().await, "sync after the delete");
+ assert!(
+ !hosted_holds(&fx, "Never before noon."),
+ "the deleted file is forgotten by its stored id"
+ );
+ assert!(
+ hosted_holds(&fx, "Oolong, always."),
+ "the file still there stays"
+ );
+ unbind(&fx).await;
+ });
+}
+
/// The first `documentId` anywhere in `value`.
fn document_id(value: &serde_json::Value) -> Option<String> {
match value {
diff --git a/vendor/tinymemory b/vendor/tinymemory
index c9c94a9a50..0c0042c0eb 160000
--- a/vendor/tinymemory
+++ b/vendor/tinymemory
@@ -1 +1 @@
-Subproject commit c9c94a9a506914777482c35c16a1128729ea7151
+Subproject commit 0c0042c0ebc81541b472c8d8573f7e29250ca590