Skip to content

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

Tell a deliberately null-classed driver from a modules-off build\n\n#5799 taught the migration import to name which of three ways the binding\nanswered the null driver, so the refusal stops blaming the user's config.\nIt got the third case right and the discriminator wrong.\n\nIt keyed on `binding.driver_id()`, with the modules-off case as the\ncatch-all arm. That arm catches more than it describes.\n`DriverClass::parse("null")` is a valid class, and `binding::admit` skips\nits `built_in_class` consistency check for an id that is not built in — the\nmatch answers `None` for such ids, meaning "nothing to enforce". So:\n\n [subsystems.memory]\n driver = "mynull"\n [subsystems.memory.drivers.mynull]\n class = "null"\n\nis admitted verbatim. `build` takes its `class == Null` branch and binds\n`NullMemoryProvider` directly, so the binding reports `class = Null`,\n`fallback = None`, and `driver_id = "mynull"` — not `"null"`, so it fell\ninto the catch-all. A user who deliberately switched memory off on a\nperfectly good modules-enabled build was told their `modules` feature was\noff and sent to investigate their build. That is the same misdirection\n#5799 existed to remove, and its own note said the message must never\nstate a cause it cannot establish.\n\nKeying on what `admit` *answered* separates them, and is the only signal\nthat does: modules-off answers `Module` and is then bound to `Null`, while\na null-classed driver answers `Null` and nothing was substituted. Both\nproduce a non-`null` driver id, so the id cannot tell them apart. `admit`\nis pure config, so this asks it directly. Four arms, each stating only what\nits own branch establishes, including a named arm for the\n`admit`-refused-with-no-fallback shape — unreachable, because `build`\nrecords that as a fallback, but named rather than folded into a neighbour\nthat would then be guessing.\n\nAlso, from CodeRabbit on the same PR: the refusal promises "the source\nworkspace is untouched" and nothing checked it. The gates-off test now\nasserts the source entry is byte-identical afterwards.\n\nFound by the Codex reviewer on #5799; the correction did not land before\nthat PR merged, so it comes separately.\n\nMessage text only — the same imports are refused either way, and the\n`fallback` and built-in-null arms keep their previous wording verbatim.\nThe new test is ungated: the confusion is reachable in a modules build.\n\nVerified on 68b2496fc: applying only the test to unmodified main fails it\non its own assertion; with the fix, gates-off scope 953 passed, product-set\nmigration_helpers 23 passed, clippy clean on both sets, fmt and\n--no-default-features clean.\n

M3gA-Minda5ae10225213
diff --git a/src/openhuman/config/migration_helpers/core.rs b/src/openhuman/config/migration_helpers/core.rs
index 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.rs
index 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]