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
fix(config): preserve legacy memory migration diagnostics
Steven Enamakelcfeed6794a40
diff --git a/crates/openhuman-core/src/config/schema/load/impl_load.rs b/crates/openhuman-core/src/config/schema/load/impl_load.rsindex ad4b87015b..5dfad03b99 100644--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs@@ -213,13 +213,14 @@ pub(super) async fn parse_config_boxed(config_path: &Path, contents: &str) -> (B/// backup may be the source used to build the config when the primary TOML is/// malformed.pub(super) async fn migration_source(config_path: &Path, contents: &str) -> String {- if toml::from_str::<toml::Value>(contents).is_ok() {+ if parse_toml_off_worker(contents.to_owned()).await.is_ok() {return contents.to_owned();}let backup_path = config_path.with_extension("toml.bak");- fs::read_to_string(backup_path)- .await- .unwrap_or_else(|_| contents.to_owned())+ match fs::read_to_string(backup_path).await {+ Ok(backup) if parse_toml_off_worker(backup.clone()).await.is_ok() => backup,+ _ => contents.to_owned(),+ }}async fn parse_toml_off_worker(contents: String) -> Result<Box<Config>, String> {diff --git a/crates/openhuman-core/src/config/schema/load/migrate.rs b/crates/openhuman-core/src/config/schema/load/migrate.rsindex 5828203130..21dd68cc5e 100644--- a/crates/openhuman-core/src/config/schema/load/migrate.rs+++ b/crates/openhuman-core/src/config/schema/load/migrate.rs@@ -254,7 +254,7 @@ pub(crate) fn migrate_legacy_memory_backend(config: &mut Config, raw: &str) {}config.memory.engine.clear();- config.memory.legacy_backend = Some(backend.to_string());+ config.memory.legacy_backend_unsupported = true;tracing::warn!("[config] legacy memory backend is unsupported; select an explicit v2 memory engine");diff --git a/crates/openhuman-core/src/config/schema/load_migration_tests.rs b/crates/openhuman-core/src/config/schema/load_migration_tests.rsindex 1730ef0e9f..fef60eb576 100644--- a/crates/openhuman-core/src/config/schema/load_migration_tests.rs+++ b/crates/openhuman-core/src/config/schema/load_migration_tests.rs@@ -221,6 +221,37 @@ backend = "sqlite".engine().unwrap_err();assert_eq!(off.code(), crate::memory::error::MEMORY_OFF);+ assert!(off.to_string().contains("legacy memory backend"));+}++#[tokio::test]+async fn recovery_migrates_the_backup_when_primary_is_toml_but_not_config() {+ let tmp = tempfile::tempdir().unwrap();+ write_file(+ &tmp.path().join("config.toml"),+ r#"+[memory]+engine = 42+"#,+ )+ .await;+ write_file(+ &tmp.path().join("config.toml.bak"),+ r#"+[memory]+backend = "sqlite"+"#,+ )+ .await;++ let config = load_or_init_for_workspace(tmp.path()).await;++ assert_eq!(config.memory.engine, "");+ let reason = crate::memory::engine::resolve(&config)+ .engine()+ .unwrap_err()+ .to_string();+ assert!(reason.contains("legacy memory backend"));}#[test]diff --git a/crates/openhuman-core/src/config/schema/memory.rs b/crates/openhuman-core/src/config/schema/memory.rsindex b8fcd94f6b..2b548efed5 100644--- a/crates/openhuman-core/src/config/schema/memory.rs+++ b/crates/openhuman-core/src/config/schema/memory.rs@@ -75,6 +75,11 @@ pub struct MemoryConfig {#[serde(rename = "backend", default, skip_serializing)]#[schemars(skip)]pub(crate) legacy_backend: Option<String>,+ /// Whether a retired v1 backend was found and disabled during migration.+ /// This marker is safe to persist and keeps the diagnostic after reload.+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]+ #[schemars(skip)]+ pub(crate) legacy_backend_unsupported: bool,/// Per-engine settings, keyed by engine id.#[serde(skip_serializing_if = "BTreeMap::is_empty")]pub engines: BTreeMap<String, MemoryEngineSettings>,@@ -146,6 +151,7 @@ impl Default for MemoryConfig {Self {engine: DEFAULT_MEMORY_ENGINE.to_string(),legacy_backend: None,+ legacy_backend_unsupported: false,engines: BTreeMap::new(),agent_id: None,root: None,diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rsindex 4f7a6e38f5..e4c81646b1 100644--- a/crates/openhuman-core/src/memory/engine.rs+++ b/crates/openhuman-core/src/memory/engine.rs@@ -181,14 +181,14 @@ pub fn resolve(config: &Config) -> Binding {TINYHUMANS_ENGINE => resolve_tinyhumans(config),CORTEXDB_ENGINE => resolve_cortexdb(config),"" => {- let reason = config.memory.legacy_backend.as_deref().map_or_else(- || "no memory engine selected".to_string(),- |backend| {- format!(- "legacy memory backend `{backend}` is unsupported; select an explicit v2 memory engine"- )- },- );+ let reason = if config.memory.legacy_backend_unsupported+ || config.memory.legacy_backend.is_some()+ {+ "legacy memory backend is unsupported; select an explicit v2 memory engine"+ .to_string()+ } else {+ "no memory engine selected".to_string()+ };off(None, None, &reason)}other => {