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(threads): cover legacy tsd v1 migration before owner reads
Steven Enamakel67880bb91222
diff --git a/crates/openhuman-core/src/threads/store/legacy_import_tests.rs b/crates/openhuman-core/src/threads/store/legacy_import_tests.rsindex 2917965f4b..5dae4e6ed9 100644--- a/crates/openhuman-core/src/threads/store/legacy_import_tests.rs+++ b/crates/openhuman-core/src/threads/store/legacy_import_tests.rs@@ -1,5 +1,8 @@use super::*;+use sha2::Digest;use std::path::Path;+use std::sync::Arc;+use tinystoragedrivers::{CollectionSpec, Precondition, WriteOptions};fn hex(id: &str) -> String {id.bytes().map(|b| format!("{b:02x}")).collect()@@ -82,6 +85,83 @@ fn legacy_jsonl_conversations_are_imported_and_the_files_stay_byte_identical() {assert_eq!(snapshot(&root), before, "legacy files must not change");}+#[test]+fn legacy_tsd_v1_threads_and_messages_are_migrated_before_owner_reads() {+ let dir = tempfile::tempdir().unwrap();+ let sqlite = crate::storage::test_support::sqlite_backend().unwrap();+ let backend = Arc::clone(&sqlite.backend);+ let _installed =+ crate::storage::test_support::install_for_test(&sqlite.url, Arc::clone(&backend));+ let scope = crate::storage::Scope::local();+ let scoped = backend.for_scope(&scope).unwrap();+ let thread_id = "legacy-thread";+ let incarnation = "6f9619ff-8b86-d011-b42d-00c04fc964ff";+ let digest = hex::encode(sha2::Sha256::digest(thread_id.as_bytes()));+ let stream = format!("conversation_messages_v1:{digest}:{incarnation}");++ crate::storage::block_on(async {+ let docs = scoped.documents();+ docs.ensure_collection(&CollectionSpec::new("conversation_threads_v1"))+ .await+ .unwrap();+ docs.put_with(+ "conversation_threads_v1",+ &digest,+ serde_json::json!({+ "schema": 1,+ "incarnation": incarnation,+ "deleted": false,+ "visible_end": 1,+ "thread": {+ "id": thread_id,+ "title": "Historical thread",+ "isActive": true,+ "messageCount": 1,+ "lastMessageAt": "2026-01-02T00:00:02Z",+ "createdAt": "2026-01-01T00:00:00Z",+ "labels": ["history"]+ }+ }),+ Precondition::Absent,+ WriteOptions::new().created_ms(1_700_000_000_000),+ )+ .await+ .unwrap();+ scoped+ .streams()+ .append(+ &stream,+ serde_json::json!({+ "schema": 1,+ "incarnation": incarnation,+ "message": {+ "id": "legacy-message",+ "content": "message from the TSD v1 profile",+ "type": "text",+ "extraMetadata": {},+ "sender": "user",+ "createdAt": "2026-01-02T00:00:02Z"+ }+ }),+ )+ .await+ .unwrap();+ });++ let store = ConversationStore::new(+ crate::core::runtime::DispatchCtx::ambient(),+ dir.path().to_path_buf(),+ );+ let listed = store.list_threads().unwrap();+ assert_eq!(listed.len(), 1);+ assert_eq!(listed[0].id, thread_id);+ assert_eq!(listed[0].title, "Historical thread");+ let messages = store.get_messages(thread_id).unwrap();+ assert_eq!(messages.len(), 1);+ assert_eq!(messages[0].id, "legacy-message");+ assert_eq!(messages[0].content, "message from the TSD v1 profile");+}+#[test]fn legacy_import_runs_once_even_when_the_files_change_afterwards() {let dir = tempfile::tempdir().unwrap();