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
refactor(memory): simplify state store loading and testing
Steven Enamakelb81976505e3b
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/memory_tests.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/memory_tests.rsindex 03a2f86a8d..7ce2d79e8f 100644--- a/crates/openhuman-core/src/channels/controllers/ops/connect/memory_tests.rs+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/memory_tests.rs@@ -292,11 +292,8 @@ async fn missing_or_corrupt_legacy_map_does_not_block_stamped_forget() {assert_eq!(clear_channel_memory(&config, "discord").await.unwrap(), 1);assert!(engine.is_empty());if corrupt {- assert!(!legacy_file.exists());- assert_eq!(- std::fs::read(legacy_file.with_extension("json.corrupt")).unwrap(),- corrupt_bytes- );+ assert_eq!(std::fs::read(&legacy_file).unwrap(), corrupt_bytes);+ assert!(!legacy_file.with_extension("json.corrupt").exists());} else {assert!(!legacy_file.exists());}diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rsindex a799e88471..71b8ae97c4 100644--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs@@ -54,7 +54,7 @@ struct FileQueueStore {impl QueueStore for FileQueueStore {fn load(&self) -> QueueState {- match super::super::state_store::load_workspace_strict(&self.workspace_dir, STATE) {+ match super::super::state_store::load_strict(&self.workspace_dir, STATE) {Ok(Some(queue)) => queue,Ok(None) => QueueState::default(),Err(error) => {@@ -65,7 +65,7 @@ impl QueueStore for FileQueueStore {}fn save(&self, state: &QueueState) -> std::result::Result<(), String> {- super::super::state_store::save_workspace(&self.workspace_dir, STATE, state)+ super::super::state_store::save(&self.workspace_dir, STATE, state).map_err(|error| error.to_string())}}diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex 3a05c61d14..91726fa722 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -498,8 +498,8 @@ fn channel_key(channel: &str) -> String {channel.trim().to_ascii_lowercase()}-/// Reads only the legacy map written by prior releases. Corrupt JSON keeps the-/// existing quarantine behavior; current code never creates or updates it.+/// Reads only the legacy map written by prior releases. Corrupt JSON is skipped+/// without moving the source; current code never creates or updates it.#[cfg(feature = "channels")]fn legacy_channel_threads(workspace: &Path, channel: &str) -> BTreeSet<String> {// Prefer the workspace state value, which may have imported and removeddiff --git a/crates/openhuman-core/src/memory/state_store.rs b/crates/openhuman-core/src/memory/state_store.rsindex 79f098be76..df09b52747 100644--- a/crates/openhuman-core/src/memory/state_store.rs+++ b/crates/openhuman-core/src/memory/state_store.rs@@ -260,21 +260,6 @@ pub(crate) fn load_workspace<T: DeserializeOwned + Send + 'static>(open_workspace_quarantining::<T>(workspace_dir, name)?.get(name)}-/// Reads a workspace-owned state value without quarantining malformed legacy-/// bytes. Host-owned readers use this when the legacy file is a read-only-/// compatibility source; the returned error is logged and the original file-/// remains available for diagnosis or a later explicit migration.-pub(crate) fn load_workspace_strict<T: DeserializeOwned + Send + 'static>(- workspace_dir: &Path,- name: &str,-) -> Result<Option<T>> {- let scope = workspace_scope(workspace_dir)?;- let backend = crate::storage::local::backend_for(workspace_dir)?;- let kv = StateKv::on_backend(&backend, &scope, OWNER, NS)?;- kv.import_file_strict(name, &legacy_path(workspace_dir, name))?;- kv.get(name)-}-/// Stores a workspace-owned state value in its deterministic local module scope.pub(crate) fn save_workspace<T>(workspace_dir: &Path, name: &str, value: &T) -> Result<()>where