Skip to content

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

feat(config): add migration to retire subconscious medulla engine

Steven Enamakelcc71a5492f01
diff --git a/crates/openhuman-core/src/config/migrations/mod.rs b/crates/openhuman-core/src/config/migrations/mod.rs
index 1c6cfb27a9..5946ddf003 100644
--- a/crates/openhuman-core/src/config/migrations/mod.rs
+++ b/crates/openhuman-core/src/config/migrations/mod.rs
@@ -31,12 +31,13 @@ mod phase_out_profile_md;
mod reconcile_orphaned_providers;
mod remove_write_auto_approve;
mod repair_http_request_limits;
+mod retire_subconscious_medulla;
mod retire_chat_v1_model;
mod retire_local_whisper_stt;
mod unify_ai_provider_settings;
/// Current target schema version. Bumped alongside every new migration.
-pub const CURRENT_SCHEMA_VERSION: u32 = 11;
+pub const CURRENT_SCHEMA_VERSION: u32 = 12;
/// Give a brand-new [`Config`] the managed `openhuman` cloud-provider entry.
///
@@ -598,6 +599,39 @@ pub async fn run_pending(config: &mut Config) {
"[migrations] schema_version bumped to 11 (reseed_cloud_providers seeded={seeded})"
);
}
+
+ // 11 -> 12: rewrite the removed Medulla subconscious engine to the
+ // supported local engine. The enum retains the legacy variant so old
+ // config files can be parsed before this migration runs.
+ if config.schema_version == 11 {
+ let previous_engine = config.subconscious.engine;
+ match retire_subconscious_medulla::run(config) {
+ Ok(migrated) => {
+ let previous_version = config.schema_version;
+ config.schema_version = 12;
+ if let Err(err) = config.save().await {
+ config.subconscious.engine = previous_engine;
+ config.schema_version = previous_version;
+ log::warn!(
+ "[migrations] retire_subconscious_medulla ran but config.save failed: \
+ {err:#} — rolled in-memory schema_version back to {previous_version}, \
+ will retry on next launch"
+ );
+ return;
+ }
+ log::info!(
+ "[migrations] schema_version bumped to 12 (retire_subconscious_medulla \
+ engine_migrated={migrated})"
+ );
+ }
+ Err(err) => {
+ log::warn!(
+ "[migrations] retire_subconscious_medulla failed: {err:#} — \
+ will retry on next launch"
+ );
+ }
+ }
+ }
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla.rs b/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla.rs
new file mode 100644
index 0000000000..f1ef6d5348
--- /dev/null
+++ b/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla.rs
@@ -0,0 +1,33 @@
+//! Migration 11 → 12: retire the removed Medulla subconscious engine.
+//!
+//! Older configurations may select `engine = "medulla"`. The compatibility
+//! enum variant keeps those files deserializable, while this migration makes
+//! the persisted selection explicit and safe for the local engine now that
+//! the Medulla implementation has been removed.
+
+use crate::config::{schema::SubconsciousEngine, Config};
+
+/// Rewrite a legacy Medulla selection to the supported local engine.
+///
+/// The `medulla_local` section is intentionally left untouched so legacy
+/// configuration remains lossless if it is inspected or rewritten by a
+/// later tool. The caller persists the mutation and advances the schema
+/// version.
+pub fn run(config: &mut Config) -> anyhow::Result<bool> {
+ if config.subconscious.engine == SubconsciousEngine::Medulla {
+ config.subconscious.engine = SubconsciousEngine::Local;
+ log::info!(
+ "[migrations][retire-subconscious-medulla] engine=medulla -> engine=local"
+ );
+ Ok(true)
+ } else {
+ log::debug!(
+ "[migrations][retire-subconscious-medulla] no legacy Medulla engine selection found"
+ );
+ Ok(false)
+ }
+}
+
+#[cfg(test)]
+#[path = "retire_subconscious_medulla_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla_tests.rs b/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla_tests.rs
new file mode 100644
index 0000000000..3ee4099072
--- /dev/null
+++ b/crates/openhuman-core/src/config/migrations/retire_subconscious_medulla_tests.rs
@@ -0,0 +1,23 @@
+use super::*;
+
+#[test]
+fn rewrites_legacy_engine_to_local() {
+ let mut config = Config::default();
+ config.subconscious.engine = SubconsciousEngine::Medulla;
+ config.subconscious.medulla_local.serve_entry = "/legacy/serve.js".into();
+
+ assert!(run(&mut config).unwrap());
+ assert_eq!(config.subconscious.engine, SubconsciousEngine::Local);
+ assert_eq!(
+ config.subconscious.medulla_local.serve_entry,
+ "/legacy/serve.js"
+ );
+}
+
+#[test]
+fn leaves_local_engine_unchanged() {
+ let mut config = Config::default();
+
+ assert!(!run(&mut config).unwrap());
+ assert_eq!(config.subconscious.engine, SubconsciousEngine::Local);
+}
diff --git a/crates/openhuman-core/src/config/schema/README.md b/crates/openhuman-core/src/config/schema/README.md
index 87e0509638..77e63cba36 100644
--- a/crates/openhuman-core/src/config/schema/README.md
+++ b/crates/openhuman-core/src/config/schema/README.md
@@ -45,7 +45,7 @@ is mounted as a submodule of `load/dirs.rs` via `#[path]`.
| `[runtime_python]` | `runtime_python.rs` | `RuntimePythonConfig` |
| `[scheduler_gate]` | `scheduler_gate.rs` | `SchedulerGateConfig`, `SchedulerGateMode` |
| `[memory]`, `[memory_tree]`, `[storage]` | `storage_memory.rs` | `MemoryConfig`, `MemoryTreeConfig`, `StorageConfig`, `StorageProviderConfig`, `LlmBackend` |
-| `[subconscious]` | `subconscious.rs` | `SubconsciousConfig`, `MedullaLocalConfig`, `SubconsciousEngine` |
+| `[subconscious]` | `subconscious.rs` | `SubconsciousConfig`, `SubconsciousEngine` (`local`) |
| `[subsystems]` | `subsystems.rs` | `SubsystemsConfig`, `MemorySubsystemConfig` |
| `[task_sources]` | `task_sources.rs` | `TaskSourcesConfig` |
| `[tokenjuice]` | `tokenjuice.rs` | `TokenjuiceConfig` |