Skip to content

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

chore(storage): regenerate legacy v1 profile fixture

Steven Enamakelb0ceb670ee79
diff --git a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/README.md b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/README.md
index 8471eede1f..68a5f1b825 100644
--- a/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/README.md
+++ b/crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/README.md
@@ -24,10 +24,13 @@ owner models and writer transformations from `2d3e22636e^`:
The approvals and threads owners migrate those into their current
collections and ids before their public APIs read them.
- The thread owner also has a committed thread and message in the historical
- SQLite database. The generator's typed rows mirror TinyAgents' committed
- `ThreadDto` and `MessageDto` storage bodies at submodule commit
- `bed24d72c923f6daefc780e7fdbf2b2892a5b334`. The desktop owner APIs must
- read the thread, message, and migrated transcript key after boot.
+ SQLite database. These are TinyAgents' actual v1 inputs: a
+ `conversation_threads_v1` row keyed by the thread id's SHA-256 and a
+ `conversation_messages_v1:<sha>:<incarnation>` stream whose entries carry
+ the v1 `schema`, `incarnation`, and camelCase `thread` / `message` payloads.
+ The boot schema migration converts them to the current conversation
+ collections; the fixture test reads the thread and message through the
+ current typed owner API after migration.
- The TinyFlows catalog fixture uses its historical `flows_definitions`
collection with `graph_json` and RFC3339 timestamps. The catalog's schema
migration converts it, and the public `flows_list` operation must return it.
@@ -56,6 +59,7 @@ or product dependency. Regenerate a fresh database at a caller-selected path:
cargo run --locked --manifest-path crates/openhuman-core/src/storage/import/fixtures/legacy-v1-profile/generator/Cargo.toml -- /absolute/path/to/storage.db
```
-The checked-in database SHA-256 is
-`393c350410e8426abdf8f8178edc06d4ed261aa57825daa6e31ba21b29ce34e9`.
-Regenerate and verify it with `sha256sum` when updating the fixture.
+The fixture is semantically reproducible. Its SQLite bytes can differ between
+generations because `DocumentSecrets` encrypts the secret with randomized
+ciphertext; verify fixture updates by running the focused fixture test rather
+than comparing a fixed whole-file SHA-256.
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 2aa060cdac..23c0daf640 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,7 +4,6 @@ use std::sync::Arc;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
-use tinyagents_storage_kit::Key;
use tinystoragedrivers::secrets::{DerivedKeys, DocumentSecrets, SecretStore};
use tinystoragedrivers::{CollectionSpec, Precondition, Scope, StorageConfig, WriteOptions};
use zeroize::Zeroizing;
@@ -137,41 +136,6 @@ struct LegacyTranscriptKey {
key: String,
}
-/// The committed TinyAgents `ThreadDto` body in `conversations.threads`.
-#[derive(Serialize)]
-struct LegacyConversationThread {
- id: String,
- title: String,
- #[serde(skip_serializing_if = "Option::is_none")]
- chat_id: Option<i64>,
- is_active: bool,
- created_ms: i64,
- last_message_ms: i64,
- #[serde(skip_serializing_if = "Option::is_none")]
- parent_thread_id: Option<String>,
- labels: Vec<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- personality_id: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- working_dir: Option<String>,
- incarnation: String,
- deleted: bool,
- visible_end: u64,
- #[serde(skip_serializing_if = "Option::is_none")]
- messages_key: Option<String>,
-}
-
-/// A committed TinyAgents `MessageDto` stream value.
-#[derive(Serialize)]
-struct LegacyConversationMessage {
- id: String,
- content: String,
- message_type: String,
- extra_metadata: Value,
- sender: String,
- created_ms: i64,
-}
-
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = std::env::args_os()
@@ -298,47 +262,45 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.await?;
let thread_id = "fixture-thread";
+ let thread_digest = "d033a44fe04c14424be31d765b05f363fddeef939017517f69cf2914980ae87f";
let incarnation = "6f9619ff-8b86-d011-b42d-00c04fc964ff";
- let thread_key = Key::of([thread_id])?.as_str().to_owned();
- let thread = LegacyConversationThread {
- id: thread_id.into(),
- title: "Fixture thread".into(),
- chat_id: None,
- is_active: true,
- created_ms: 1_738_555_506_000,
- last_message_ms: 1_738_555_507_000,
- parent_thread_id: None,
- labels: Vec::new(),
- personality_id: None,
- working_dir: None,
- incarnation: incarnation.into(),
- deleted: false,
- visible_end: 1,
- messages_key: None,
- };
put(
user_scope.documents(),
- "conversations.threads",
- &thread_key,
- serde_json::to_value(thread)?,
+ "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-04T04:05:07Z",
+ "createdAt": "2025-02-04T04:05:06Z",
+ "labels": ["history"]
+ }
+ }),
)
.await?;
- let message = LegacyConversationMessage {
- id: "fixture-message".into(),
- content: "historical profile message".into(),
- message_type: "text".into(),
- extra_metadata: Value::Null,
- sender: "user".into(),
- created_ms: 1_738_555_507_000,
- };
user_scope
.streams()
.append(
- &format!(
- "conversations.messages/{}",
- Key::of([thread_id, incarnation])?.as_str()
- ),
- serde_json::to_value(message)?,
+ &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-04T04:05:07Z"
+ }
+ }),
)
.await?;
// The thread owner historically keyed transcript rows by the raw thread
diff --git a/crates/openhuman-core/src/storage/import/mod_tests.rs b/crates/openhuman-core/src/storage/import/mod_tests.rs
index 0173615415..33d26471c2 100644
--- a/crates/openhuman-core/src/storage/import/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/import/mod_tests.rs
@@ -275,7 +275,7 @@ async fn historical_profile_fixture_boots_into_typed_owner_records_without_resur
// the actual TinyAgents v1 collections and stream, not already-current v2
// rows that happen to deserialize through today's owner API.
let source_url = format!("sqlite:{}", source_db.display());
- let source_backend = storage::block_on_anyhow(async {
+ let source_backend = storage::block_on_anyhow(async move {
storage::open(&source_url).await.map_err(anyhow::Error::from)
})
.unwrap();
@@ -285,7 +285,7 @@ async fn historical_profile_fixture_boots_into_typed_owner_records_without_resur
.unwrap()
.documents(),
);
- let legacy_threads = storage::block_on(async {
+ let legacy_threads = storage::block_on(async move {
source_docs
.query_all("conversation_threads_v1", &Query::all())
.await