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
test(storage): verify legacy profile migration archives and restores messages
Steven Enamakelf921163f735a
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rsindex 25ba5cdb20..acfeffafdb 100644--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/src/main.rs@@ -262,8 +262,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {.await?;// Threads predate the v1 storage database and remain in the workspace's- // read-only JSONL conversation files. Emit them beside storage.db so the- // host integration fixture exercises the real legacy thread importer.+ // read-only JSONL conversation files. Emit a thread and its message beside+ // storage.db so the host integration fixture exercises the real legacy+ // thread importer while preserving a message through the boot migration.let conversations = path.parent().ok_or("storage.db output must have a parent directory")?@@ -273,6 +274,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {conversations.join("threads.jsonl"),"{\"op\":\"upsert\",\"thread_id\":\"fixture-thread\",\"title\":\"Fixture thread\",\"created_at\":\"2025-02-03T04:05:06Z\"}\n",)?;+ let thread_id_hex: String = "fixture-thread"+ .bytes()+ .map(|byte| format!("{byte:02x}"))+ .collect();+ std::fs::write(+ conversations.join("threads").join(format!("{thread_id_hex}.jsonl")),+ "{\"id\":\"fixture-message\",\"content\":\"historical profile message\",\"type\":\"text\",\"extraMetadata\":null,\"sender\":\"user\",\"createdAt\":\"2025-02-03T04:05:07Z\"}\n",+ )?;backend.checkpoint(tinystoragedrivers::Checkpoint::Truncate).await?;diff --git a/tests/storage_legacy_profile_boot_e2e.rs b/tests/storage_legacy_profile_boot_e2e.rsindex ee20c15623..8156b2a54d 100644--- a/tests/storage_legacy_profile_boot_e2e.rs+++ b/tests/storage_legacy_profile_boot_e2e.rs@@ -145,10 +145,24 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {.collect::<Vec<_>>(),std::fs::read_to_string(home.path().join("core.stderr.log")).unwrap_or_default());+ assert!(!source.exists(), "migration should archive the old workspace storage path");+ let archive_dir = profile.join("backups");+ let archive = std::fs::read_dir(&archive_dir)+ .unwrap_or_else(|error| panic!("migration archive missing at {}: {error}", archive_dir.display()))+ .filter_map(Result::ok)+ .map(|entry| entry.path())+ .find(|path| path.extension().is_some_and(|extension| extension == "zst"))+ .expect("layout migration should archive the v1 workspace");+ let restored = tempfile::tempdir().unwrap();+ let manifest = openhuman_core::storage::layout::archive::restore(&archive, restored.path())+ .expect("migration archive should verify and restore");+ assert!(manifest.files.iter().any(|file| {+ file.path == "workspace/storage/storage.db" && file.size == source_bytes.len() as u64+ }), "archive manifest must record the historical storage.db");assert_eq!(- std::fs::read(&source).unwrap(),+ std::fs::read(restored.path().join("workspace/storage/storage.db")).unwrap(),source_bytes,- "boot must leave the historical v1 storage.db byte-for-byte unchanged"+ "migration must preserve the historical v1 storage.db bytes exactly");// The profile's V2 workspace resolves its default backend to the exact@@ -189,6 +203,10 @@ fn desktop_boot_reads_a_preserved_existing_v1_profile_database() {Some("fixture-transcript-key"),"thread owner did not read the v1 database transcript key");+ let messages = thread_store.get_messages("fixture-thread").unwrap();+ assert_eq!(messages.len(), 1, "thread owner did not read the historical message");+ assert_eq!(messages[0].id, "fixture-message");+ assert_eq!(messages[0].content, "historical profile message");let approvals =openhuman_core::security::approval::store::list_pending(&config).unwrap();assert_eq!(