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
Tell a deliberately null-classed driver from a modules-off build
M3gA-Mind27215561e4ea
diff --git a/src/openhuman/config/migration_helpers/core.rs b/src/openhuman/config/migration_helpers/core.rsindex 6344056714..3ac730e099 100644--- a/src/openhuman/config/migration_helpers/core.rs+++ b/src/openhuman/config/migration_helpers/core.rs@@ -155,31 +155,56 @@ pub async fn migrate_openclaw_memory(/// and the user only discovers it later, with nothing left to re-run against./// So this refuses up front and names which of the three it was.///-/// The third case is the reason this reads `driver_id()` rather than only-/// `class()`. `admit` is pure config and never saw the feature flag, so it-/// returns the configured id — the binding then reports `driver_id =-/// "tinymemory"` with `class = Null` and **no** `fallback`, since nothing-/// refused. Keying the message on the class alone put that case in the-/// configured-null arm, which told a user whose config says `driver =-/// "tinycortex"` that they had set it to `"null"` and sent them to edit a line+/// Telling the third case apart needs what was *admitted*, not what was bound.+/// `admit` is pure config and never saw the feature flag, so it answers+/// `Module` for the configured `tinycortex`; `module_provider` then binds the+/// null provider, and the binding reports `class = Null` with **no**+/// `fallback`, since nothing refused. So `admitted != bound` is the signal, and+/// it is the only one that works: `driver_id` alone does not separate this from+/// a driver deliberately given `class = "null"`, because `admit` accepts a+/// non-built-in id with that class (the `built_in_class` check is skipped for+/// ids that are not built in) and returns it verbatim. Keying on the id would+/// tell a user with a working modules build that their `modules` feature was+/// off — the same class of misdirection this whole note exists to prevent.+///+/// Keying on the class alone was the original bug: it put the modules-off case+/// in the configured-null arm and told a user whose config says `driver =+/// "tinycortex"` that they had set it to `"null"`, sending them to edit a line/// that already said the opposite.fn target_memory_backend(config: &Config) -> Result<Arc<dyn Memory>> {let binding = crate::openhuman::memory::binding::for_config(config).map_err(|e| anyhow::anyhow!("bind memory for migration import: {e}"))?;if binding.class() == crate::core::subsystem::DriverClass::Null {- let because = match (binding.fallback(), binding.driver_id()) {+ let admitted = crate::openhuman::memory::binding::admit(&config.subsystems.memory).ok();+ let because = match (binding.fallback(), admitted) {(Some(fallback), _) => format!("driver '{}' refused to bind: {}",fallback.configured_driver, fallback.reason),- (None, tinymemory_api::null::NULL_DRIVER_ID) => {+ // Admitted as the null driver: the user asked for no memory.+ (None, Some((id, crate::core::subsystem::DriverClass::Null)))+ if id == tinymemory_api::null::NULL_DRIVER_ID =>+ {"memory is disabled by configuration ([subsystems.memory] driver = \"null\")".to_string()}- (None, driver_id) => format!(- "driver '{driver_id}' is configured, but this build has no memory module \+ (None, Some((id, crate::core::subsystem::DriverClass::Null))) => format!(+ "driver '{id}' is configured with class \"null\" under \+ [subsystems.memory.drivers.{id}], so every write is discarded"+ ),+ // Admitted as something that can hold data, bound to the null+ // provider anyway — the module substitution.+ (None, Some((id, _))) => format!(+ "driver '{id}' is configured, but this build has no memory module \compiled in (the 'modules' feature is off), so nothing can be written"),+ // `admit` refused: `build` records that as a fallback, so this is+ // unreachable. Named rather than merged into an arm that would+ // state a cause this branch cannot actually establish.+ (None, None) => format!(+ "driver '{}' bound the null provider and the reason was not recorded",+ binding.driver_id()+ ),};anyhow::bail!("refusing to import memory into the null driver — {because}. \diff --git a/src/openhuman/config/migration_helpers/ops.rs b/src/openhuman/config/migration_helpers/ops.rsindex d7e09c29ac..f455874ace 100644--- a/src/openhuman/config/migration_helpers/ops.rs+++ b/src/openhuman/config/migration_helpers/ops.rs@@ -143,7 +143,9 @@ mod tests {let source = tmp.path().join("openclaw-src");std::fs::create_dir_all(&source).unwrap();- std::fs::write(source.join("MEMORY.md"), "# Note\nwould be lost").unwrap();+ let entry = source.join("MEMORY.md");+ let original = "# Note\nwould be lost";+ std::fs::write(&entry, original).unwrap();let err = migrate_openclaw(&config, Some(source), false).await@@ -161,6 +163,66 @@ mod tests {err.contains("the source workspace is untouched"),"refusal must still promise the source survived; got: {err}");+ // The promise, checked rather than taken on trust: a refusal that moved+ // or truncated the source would be the very loss it claims to prevent.+ assert_eq!(+ std::fs::read_to_string(&entry).expect("source entry must still be readable"),+ original,+ "the refused import must leave the source workspace byte-identical"+ );+ }++ /// A driver deliberately given `class = "null"` is not a modules-off build.+ ///+ /// Codex raised this against the first version of the fix above, and it was+ /// right. `admit` skips its `built_in_class` check for an id that is not+ /// built in, so `[subsystems.memory] driver = "mynull"` with+ /// `class = "null"` is admitted verbatim: `class = Null`, no `fallback`, and+ /// a `driver_id` that is not `"null"`. Keyed on the id, that landed in the+ /// modules-off arm and told a user with a perfectly good modules build that+ /// their `modules` feature was off.+ ///+ /// Keying on what `admit` *answered* separates them: here it answers `Null`,+ /// where the modules-off case answers `Module` and is then bound to the null+ /// provider. This runs in **every** feature configuration, because the+ /// confusion it guards against is one a modules-enabled build can hit.+ #[tokio::test]+ async fn apply_names_a_deliberately_null_classed_driver_rather_than_the_build() {+ use crate::openhuman::config::schema::{MemoryDriverConfig, MemorySubsystemConfig};++ let tmp = TempDir::new().unwrap();+ let mut config = test_config(&tmp);+ let mut drivers = std::collections::BTreeMap::new();+ drivers.insert(+ "mynull".to_string(),+ MemoryDriverConfig {+ class: Some("null".to_string()),+ ..Default::default()+ },+ );+ config.subsystems.memory = MemorySubsystemConfig {+ driver: "mynull".to_string(),+ drivers,+ ..Default::default()+ };++ let source = tmp.path().join("openclaw-src");+ std::fs::create_dir_all(&source).unwrap();+ std::fs::write(source.join("MEMORY.md"), "# Note\nkeep me").unwrap();++ let err = migrate_openclaw(&config, Some(source), false)+ .await+ .expect_err("apply must refuse a null-classed driver");++ assert!(+ err.contains("mynull") && err.contains("class"),+ "refusal must name the driver and its configured class; got: {err}"+ );+ assert!(+ !err.contains("no memory module compiled in"),+ "a deliberately null-classed driver must not be reported as a \+ modules-off build; got: {err}"+ );}#[tokio::test]