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
chore(config): add tests for profile.md phase-out migrations
Steven Enamakele6d5395e40a9
diff --git a/crates/openhuman-core/src/config/migrations/mod_tests.rs b/crates/openhuman-core/src/config/migrations/mod_tests.rsindex efcc74bcfc..d43e024648 100644--- a/crates/openhuman-core/src/config/migrations/mod_tests.rs+++ b/crates/openhuman-core/src/config/migrations/mod_tests.rs@@ -3,7 +3,8 @@ use std::fs;use std::path::Path;use tempfile::TempDir;use tinyagents_session::transcript::TranscriptMessage;-use tinyagents_session::transcript::{read_transcript, write_transcript, TranscriptMeta};+use tinyagents_session::transcript::TranscriptMeta;+use crate::util::classic_transcript_fixture::{read_classic_rows, write_classic};fn durable_messages(messages: impl IntoIterator<Item = TranscriptMessage>,@@ -87,7 +88,7 @@ fn seed_tainted_transcript(workspace_dir: &Path) -> std::path::PathBuf {TranscriptMessage::system(tainted_prompt()),TranscriptMessage::user("hello"),];- write_transcript(&path, &durable_messages(messages), &meta(), None).unwrap();+ write_classic(&path, &durable_messages(messages), &meta());path}@@ -116,11 +117,11 @@ async fn run_pending_runs_phase_out_when_version_zero() {run_pending(&mut config).await;assert_eq!(config.schema_version, CURRENT_SCHEMA_VERSION);- let session = read_transcript(&path).unwrap();+ let rows = read_classic_rows(&path);+ let first = rows[0]["content"].as_str().unwrap();assert!(- !session.messages[0].content.contains("### PROFILE.md"),- "PROFILE.md block must be stripped, got:\n{}",- session.messages[0].content+ !first.contains("### PROFILE.md"),+ "PROFILE.md block must be stripped, got:\n{first}");let on_disk = std::fs::read_to_string(&config.config_path).unwrap();diff --git a/crates/openhuman-core/src/config/migrations/phase_out_profile_md_tests.rs b/crates/openhuman-core/src/config/migrations/phase_out_profile_md_tests.rsindex 8dbe9aedeb..b344ae3cf1 100644--- a/crates/openhuman-core/src/config/migrations/phase_out_profile_md_tests.rs+++ b/crates/openhuman-core/src/config/migrations/phase_out_profile_md_tests.rs@@ -2,7 +2,8 @@ use super::*;use std::fs;use tempfile::TempDir;use tinyagents_session::transcript::TranscriptMessage;-use tinyagents_session::transcript::{read_transcript, write_transcript, TranscriptMeta};+use tinyagents_session::transcript::TranscriptMeta;+use crate::util::classic_transcript_fixture::{read_classic_rows, write_classic};fn durable_messages(messages: impl IntoIterator<Item = TranscriptMessage>,@@ -42,7 +43,7 @@ fn write_tainted_transcript(workspace_dir: &Path, stem: &str, system_body: &str)TranscriptMessage::user("hello"),TranscriptMessage::assistant("hi"),];- write_transcript(&path, &durable_messages(messages), &meta(), None).unwrap();+ write_classic(&path, &durable_messages(messages), &meta());path}@@ -158,11 +159,15 @@ fn sanitize_only_touches_first_system_message() {);// Add a later user message that also mentions PROFILE.md — it must// survive the migration unchanged.- let mut session = read_transcript(&path).unwrap();- session.messages.push(TranscriptMessage::user(- "Could you show me what was in ### PROFILE.md earlier?",- ));- write_transcript(&path, &session.messages, &session.meta, None).unwrap();+ let mut text = fs::read_to_string(&path).unwrap();+ text.push_str(+ &serde_json::to_string(&TranscriptMessage::user(+ "Could you show me what was in ### PROFILE.md earlier?",+ ))+ .unwrap(),+ );+ text.push('\n');+ fs::write(&path, text).unwrap();let stats = run(dir.path()).unwrap();assert_eq!(@@ -170,12 +175,11 @@ fn sanitize_only_touches_first_system_message() {"first system message had a block, must mutate");- let session = read_transcript(&path).unwrap();- assert!(!session.messages[0].content.contains("### PROFILE.md"));- assert!(session- .messages- .iter()- .any(|m| { m.role == "user" && m.content.contains("### PROFILE.md") }));+ let rows = read_classic_rows(&path);+ assert!(!rows[0]["content"].as_str().unwrap().contains("### PROFILE.md"));+ assert!(rows.iter().any(|m| {+ m["role"] == "user" && m["content"].as_str().unwrap().contains("### PROFILE.md")+ }));}#[test]@@ -197,7 +201,7 @@ fn run_cleans_flat_and_legacy_dirs_in_one_pass() {TranscriptMessage::system(prompt_with_profile_block("style/legacy")),TranscriptMessage::user("legacy"),];- write_transcript(&legacy_path, &durable_messages(messages), &meta(), None).unwrap();+ write_classic(&legacy_path, &durable_messages(messages), &meta());let stats = run(dir.path()).unwrap();assert_eq!(stats.scanned, 2);@@ -377,7 +381,7 @@ fn run_leaves_clean_transcripts_byte_identical() {TranscriptMessage::system("## Identity\n\nNo profile here.\n\n### Tools\n\n- shell\n"),TranscriptMessage::user("hi"),];- write_transcript(&path, &durable_messages(messages), &meta(), None).unwrap();+ write_classic(&path, &durable_messages(messages), &meta());let before = fs::read(&path).unwrap();let stats = run(dir.path()).unwrap();