Skip to content

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

chore(fixtures): move legacy thread fixture into storage

Steven Enamakelaf062dd0fca8
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
index 1a876f9e62..732b9e3b91 100644
--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml
@@ -11,5 +11,6 @@ tinystoragedrivers = { git = "https://github.com/tinyhumansai/tinystoragedrivers
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+sha2 = "0.11"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
zeroize = "1"
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.rs
index 35da895ba1..a26f838023 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
@@ -4,8 +4,11 @@ use std::sync::Arc;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
+use sha2::{Digest, Sha256};
use tinystoragedrivers::secrets::{DerivedKeys, DocumentSecrets, SecretStore};
-use tinystoragedrivers::{CollectionSpec, Precondition, Scope, StorageConfig, WriteOptions};
+use tinystoragedrivers::{
+ CollectionSpec, Precondition, Scope, StorageConfig, StreamStore, WriteOptions,
+};
use zeroize::Zeroizing;
const PROFILE_ID: &str = "u1";
@@ -228,8 +231,50 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}),
)
.await?;
+ let thread_id = "fixture-thread";
+ let incarnation = "fixture-incarnation";
+ let thread_digest = hex(&Sha256::digest(thread_id.as_bytes()));
put(
- user_scope.documents(),
+ docs,
+ "conversation_threads_v1",
+ &thread_digest,
+ json!({
+ "schema": 1,
+ "incarnation": incarnation,
+ "deleted": false,
+ "visible_end": 1,
+ "thread": {
+ "id": thread_id,
+ "title": "Fixture thread",
+ "isActive": true,
+ "messageCount": 1,
+ "lastMessageAt": "2025-02-03T04:05:07Z",
+ "createdAt": "2025-02-03T04:05:06Z",
+ "labels": []
+ }
+ }),
+ )
+ .await?;
+ user_scope
+ .streams()
+ .append(
+ &format!("conversation_messages_v1:{thread_digest}:{incarnation}"),
+ json!({
+ "schema": 1,
+ "incarnation": incarnation,
+ "message": {
+ "id": "fixture-message",
+ "content": "historical profile message",
+ "type": "text",
+ "extraMetadata": null,
+ "sender": "user",
+ "createdAt": "2025-02-03T04:05:07Z"
+ }
+ }),
+ )
+ .await?;
+ put(
+ docs,
"threads_transcript_keys",
"fixture-thread",
json!({"transcript_key": "fixture-transcript-key"}),
@@ -261,29 +306,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.set("fixture-secret", b"historical-secret-value")
.await?;
- // Threads predate the v1 storage database and remain in the workspace's
- // 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")?
- .join("legacy-workspace/memory/conversations");
- std::fs::create_dir_all(conversations.join("threads"))?;
- std::fs::write(
- 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?;
@@ -291,6 +313,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
+fn hex(bytes: &[u8]) -> String {
+ bytes.iter().map(|byte| format!("{byte:02x}")).collect()
+}
+
async fn put(
docs: &std::sync::Arc<dyn tinystoragedrivers::DocumentStore>,
collection: &str,