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
Anchor switch_to_v3 to the person's config; bind a plain test engine
M3gA-Mind57d264e5828a
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rsindex e34c06249a..968ffb602e 100644--- a/crates/openhuman-core/src/memory/engine.rs+++ b/crates/openhuman-core/src/memory/engine.rs@@ -247,10 +247,13 @@ pub fn bind_with_root(config: &Config, root: Option<&str>) -> MemoryResult<Bound.read().unwrap_or_else(std::sync::PoisonError::into_inner).contains_key(&config.workspace_dir);- if one_engine && root.is_some() {- return Err(MemoryError::Engine(- "the installed test engine cannot be bound below a scope root".to_string(),- ));+ if one_engine {+ return match root {+ None => resolve(config).engine(),+ Some(_) => Err(MemoryError::Engine(+ "the installed test engine cannot be bound below a scope root".to_string(),+ )),+ };}}if host_engine().is_some() && root.is_some() {diff --git a/crates/openhuman-core/src/memory/engine_tests.rs b/crates/openhuman-core/src/memory/engine_tests.rsindex c79c928732..add9169da4 100644--- a/crates/openhuman-core/src/memory/engine_tests.rs+++ b/crates/openhuman-core/src/memory/engine_tests.rs@@ -247,6 +247,11 @@ fn an_installed_engine_has_one_layout_unless_one_is_installed_per_root() {Arc::new(tinymemory_api::conformance::ReferenceEngine::new()),);assert!(bind_with_root(&config, Some("user:42")).is_err());+ assert_eq!(+ bind_with_root(&config, None).unwrap().endpoint,+ "test://engine",+ "the legacy layout binds the installed test engine"+ );install_test_engine_for_root(&config.workspace_dir,@@ -273,3 +278,32 @@ fn a_root_sets_the_scope_root_its_owner_and_the_cache_key() {assert_eq!(settings.scope_root, None);assert_eq!(key, "|root=legacy");}++#[tokio::test]+async fn switching_to_v3_persists_and_rebinds_the_persons_own_config() {+ let tmp = tempfile::tempdir().unwrap();+ let mut config = user_config(&tmp, "6512ab0f6512ab0f6512ab0f");+ config.memory.engine = CORTEXDB_ENGINE.to_string();+ config.save().await.unwrap();+ store_cortexdb_key(&config, "cdb-key-switch").unwrap();+ let legacy = resolve(&config).engine().expect("legacy bound");++ super::super::scope::switch_to_v3(&config).await.unwrap();++ let saved = Config::load_from_config_path(&config.config_path, &config.workspace_dir)+ .await+ .unwrap();+ assert!(+ super::super::scope::layout_is_v3(&saved),+ "v3 written to this person's file"+ );+ let v3 = resolve(&saved).engine().expect("v3 bound");+ assert!(+ !Arc::ptr_eq(&legacy.engine, &v3.engine),+ "the switch rebinds"+ );+ assert!(+ !super::super::scope::layout_is_v3(&config),+ "the caller's copy is not the source of truth"+ );+}diff --git a/crates/openhuman-core/src/memory/scope.rs b/crates/openhuman-core/src/memory/scope.rsindex 5f39f7a7ee..46e10ed1b5 100644--- a/crates/openhuman-core/src/memory/scope.rs+++ b/crates/openhuman-core/src/memory/scope.rs@@ -219,19 +219,20 @@ fn user_root_for(id: &str) -> Option<String> {Some(format!("user:local-{digest}"))}-/// Switches the signed-in person's memory to layout v3: loads the config-/// fresh (a long migration's own copy would revert settings changed since),-/// sets `[memory] layout = "v3"`, saves it and drops the bound engines so-/// the next binding uses the new layout. Called by the layout migration-/// once every scope has moved, never on its own.+/// Switches the memory of the person `config` belongs to to layout v3:+/// reloads that person's own config file (`config.config_path`) fresh, so+/// neither a long migration's stale copy nor a different account signed in+/// meanwhile is written, sets `[memory] layout = "v3"`, saves it and drops+/// the bound engines so the next binding uses the new layout. Called by the+/// layout migration once every scope has moved, never on its own.////// # Errors////// The config could not be loaded or saved.-pub async fn switch_to_v3() -> MemoryResult<()> {- let mut config = crate::config::rpc::load_config_with_timeout()+pub async fn switch_to_v3(config: &Config) -> MemoryResult<()> {+ let mut config = Config::load_from_config_path(&config.config_path, &config.workspace_dir).await- .map_err(MemoryError::Engine)?;+ .map_err(|error| MemoryError::Engine(format!("loading config failed: {error:#}")))?;config.memory.layout = MemoryLayoutMode::V3;config.save()