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
feat(config): add migration to retire cloud provider type
Steven Enamakeld98dff4dd461
diff --git a/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type.rs b/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type.rsnew file mode 100644index 0000000000..f565abae59--- /dev/null+++ b/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type.rs@@ -0,0 +1,56 @@+//! Decode pre-v14 cloud-provider discriminators before the typed schema.+//!+//! The v13 -> v14 runner persists the normalized document once. This decoder+//! bridge is retained for offline upgrades from older configs.++use crate::config::schema::cloud_providers::builtin_cloud_provider;++// keep until v0.66 (review after 2027-01-11): removal requires a documented+// pre-schema-14 upgrade/import boundary, including offline workspace imports.+pub(crate) fn rewrite_document(document: &mut toml::Value) -> anyhow::Result<()> {+ let version = document.get("schema_version").and_then(toml::Value::as_integer).unwrap_or(0);+ if version >= 14 {+ return Ok(());+ }+ let Some(providers) = document.get_mut("cloud_providers").and_then(toml::Value::as_array_mut) else {+ return Ok(());+ };+ for (index, value) in providers.iter_mut().enumerate() {+ let Some(entry) = value.as_table_mut() else { continue; };+ let Some(discriminator) = entry.remove("type") else { continue; };+ let kind = discriminator.as_str().ok_or_else(|| anyhow::anyhow!(+ "cloud_providers[{index}].type: expected a string"+ ))?.trim();+ let builtin = builtin_cloud_provider(kind);+ for (field, default) in [+ ("slug", kind),+ ("label", builtin.map(|p| p.label).unwrap_or("Custom")),+ ("endpoint", builtin.map(|p| p.endpoint).unwrap_or("")),+ ] {+ match entry.get(field) {+ None => { entry.insert(field.into(), toml::Value::String(default.into())); }+ Some(toml::Value::String(current)) if current.is_empty() => {+ entry.insert(field.into(), toml::Value::String(default.into()));+ }+ _ => {}+ }+ }+ if !entry.contains_key("auth_style") {+ if let Some(provider) = builtin {+ entry.insert("auth_style".into(), toml::Value::String(+ match provider.auth_style {+ crate::config::schema::cloud_providers::AuthStyle::Bearer => "bearer",+ crate::config::schema::cloud_providers::AuthStyle::Anthropic => "anthropic",+ crate::config::schema::cloud_providers::AuthStyle::OpenhumanJwt => "openhuman_jwt",+ crate::config::schema::cloud_providers::AuthStyle::None => "none",+ }.into()+ ));+ }+ }+ }+ Ok(())+}++#[cfg(test)]+#[path = "retire_cloud_provider_type_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type_tests.rs b/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type_tests.rsnew file mode 100644index 0000000000..2fd7aa2f0a--- /dev/null+++ b/crates/openhuman-core/src/config/migrations/retire_cloud_provider_type_tests.rs@@ -0,0 +1,47 @@+use super::*;++#[test]+fn migration_preserves_explicit_values_and_unknown_provider_models() {+ let mut document: toml::Value = toml::from_str(r#"+schema_version = 13+[[cloud_providers]]+type = "anthropic"+slug = "chosen"+label = "Chosen Label"+endpoint = "https://proxy.example/v1"+auth_style = "bearer"+default_model = "claude-sonnet-4"+[[cloud_providers]]+type = " custom-provider "+default_model = "custom-model"+"#).unwrap();+ rewrite_document(&mut document).unwrap();+ let providers = document["cloud_providers"].as_array().unwrap();+ assert_eq!(providers[0]["slug"].as_str(), Some("chosen"));+ assert_eq!(providers[0]["label"].as_str(), Some("Chosen Label"));+ assert_eq!(providers[0]["endpoint"].as_str(), Some("https://proxy.example/v1"));+ assert_eq!(providers[0]["auth_style"].as_str(), Some("bearer"));+ assert_eq!(providers[0]["default_model"].as_str(), Some("claude-sonnet-4"));+ assert_eq!(providers[1]["slug"].as_str(), Some("custom-provider"));+ assert_eq!(providers[1]["label"].as_str(), Some("Custom"));+ assert_eq!(providers[1]["default_model"].as_str(), Some("custom-model"));+ assert!(providers.iter().all(|p| p.get("type").is_none()));+ let once = document.clone();+ rewrite_document(&mut document).unwrap();+ assert_eq!(document, once);+}++#[test]+fn malformed_discriminator_is_not_silently_discarded() {+ let mut document: toml::Value = toml::from_str("[[cloud_providers]]\ntype = 3").unwrap();+ let error = rewrite_document(&mut document).unwrap_err().to_string();+ assert!(error.contains("cloud_providers[0].type"));+}++#[test]+fn current_schema_does_not_reapply_the_decoder_migration() {+ let mut document: toml::Value = toml::from_str("schema_version = 14\n[[cloud_providers]]\ntype = \"old\"").unwrap();+ let before = document.clone();+ rewrite_document(&mut document).unwrap();+ assert_eq!(document, before);+}