Skip to content

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

test(memory): a finished import starts organizing into the per-user tree

M3gA-Mind0ebc417ee25b
diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rs
index 36d5d6181f..31f1197238 100644
--- a/crates/openhuman-core/src/memory/import_tests.rs
+++ b/crates/openhuman-core/src/memory/import_tests.rs
@@ -252,6 +252,46 @@ async fn a_full_import_stores_every_item_and_finishes_done() {
assert!(file_path(&config.workspace_dir).exists());
}
+#[tokio::test]
+async fn a_finished_import_starts_organizing_into_the_per_user_tree() {
+ let tmp = tempfile::tempdir().unwrap();
+ let mut config = config_in(&tmp);
+ let account = "0123456789abcdef01234567";
+ // Signed in: the move needs the account's own root, and the switch
+ // writes the account's config file.
+ config.config_path = tmp.path().join("users").join(account).join("config.toml");
+ std::fs::create_dir_all(config.config_path.parent().unwrap()).unwrap();
+ config.save().await.unwrap();
+ legacy_workspace(&config.workspace_dir);
+ let legacy = bind_reference(&config);
+ let tree = Arc::new(tinymemory_api::conformance::ReferenceEngine::new());
+ crate::memory::engine::install_test_engine_for_root(
+ &config.workspace_dir,
+ Some(&format!("user:{account}")),
+ tree.clone(),
+ );
+
+ start(&config, true).await.unwrap();
+ assert_eq!(wait_until_settled(&config).await.phase, ImportPhase::Done);
+
+ // The import's own task starts the move once it is done.
+ let mut moved = None;
+ for _ in 0..400 {
+ let migration = crate::memory::layout_migration::status(&config).unwrap();
+ if !migration.running
+ && migration.state.phase == crate::memory::layout_migration::Phase::Cleaned
+ {
+ moved = Some(migration.state);
+ break;
+ }
+ tokio::time::sleep(std::time::Duration::from_millis(25)).await;
+ }
+ let moved = moved.expect("the move never finished after the import");
+ assert_eq!(moved.copied, 5);
+ assert_eq!(stored(&tree, MetaFilter::default()).await.len(), 5);
+ assert!(stored(&legacy, MetaFilter::default()).await.is_empty());
+}
+
#[tokio::test]
async fn an_interrupted_import_resumes_from_its_checkpoint() {
let tmp = tempfile::tempdir().unwrap();