Skip to content

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

chore: files changed crates/openhuman-core/src/memory/deletion_tests.rs,crates/openhuman-core/src/me

Steven Enamakel5543ec46ae82
diff --git a/crates/openhuman-core/src/memory/deletion_tests.rs b/crates/openhuman-core/src/memory/deletion_tests.rs
index 1087526616..fe632facbe 100644
--- a/crates/openhuman-core/src/memory/deletion_tests.rs
+++ b/crates/openhuman-core/src/memory/deletion_tests.rs
@@ -182,7 +182,7 @@ async fn a_failed_forget_is_kept_for_the_next_drain() {
}
#[test]
-fn an_unparsable_legacy_queue_is_ignored_and_left_in_place() {
+fn an_unparsable_legacy_queue_is_quarantined_and_retry_queue_remains_usable() {
let tmp = tempfile::tempdir().unwrap();
let file = crate::memory::state_store::legacy_path(tmp.path(), "pending_deletions");
std::fs::create_dir_all(file.parent().unwrap()).unwrap();
@@ -190,7 +190,12 @@ fn an_unparsable_legacy_queue_is_ignored_and_left_in_place() {
assert!(pending(tmp.path()).is_empty());
enqueue(tmp.path(), thread("t"));
assert_eq!(pending(tmp.path()), vec![thread("t")]);
- assert_eq!(std::fs::read_to_string(&file).unwrap(), "not json");
+ assert!(!file.exists(), "the corrupt legacy file is removed from the active path");
+ assert_eq!(
+ std::fs::read_to_string(file.with_extension("json.corrupt")).unwrap(),
+ "not json",
+ "quarantine preserves the original bytes"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/memory/error_tests.rs b/crates/openhuman-core/src/memory/error_tests.rs
index e52922da54..5b38ac396a 100644
--- a/crates/openhuman-core/src/memory/error_tests.rs
+++ b/crates/openhuman-core/src/memory/error_tests.rs
@@ -79,13 +79,14 @@ fn upstream_errors_keep_the_memory_rpc_wire_codes_and_messages() {
}
#[test]
-fn upstream_account_wide_classification_includes_credits_and_unavailable() {
+fn upstream_unavailable_is_transient_not_account_wide() {
use tinymemory_api::Error as E;
assert!(E::Off("disabled".into()).is_account_wide());
assert!(E::Unauthorized("bad key".into()).is_account_wide());
assert!(E::InsufficientCredits("top up".into()).is_account_wide());
- assert!(E::Unavailable("timeout".into()).is_account_wide());
+ assert!(!E::Unavailable("timeout".into()).is_account_wide());
+ assert!(E::Unavailable("timeout".into()).is_transient());
assert!(!E::InvalidRequest("bad filter".into()).is_account_wide());
assert!(!E::Conflict("duplicate".into()).is_account_wide());
assert!(!E::Engine("corrupt index".into()).is_account_wide());
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 1338a725c2..0b98937dc2 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -106,11 +106,22 @@ pub(super) fn engine_get(ctx: DispatchCtx, params: Map<String, Value>) -> Contro
}
pub(super) fn engine_set(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
- rpc::<EngineSetParams, _>(ctx, params, |_, mut config, params| async move {
- ops::apply_engine_set(&mut config, &params)?;
- save(&config).await?;
+ Box::pin(async move {
+ let params = parse::<EngineSetParams>(params)?;
+ let mut config = load(&ctx).await?;
+ if let Err(error) = ops::apply_engine_set(&mut config, &params) {
+ return finish(Err(error));
+ }
+ if let Err(error) = config.save().await {
+ if let Some(conflict) = crate::config::ops::config_save_conflict(&error, false) {
+ return Err(conflict.encode());
+ }
+ return finish(Err(Error::Engine(format!(
+ "saving config failed: {error:#}"
+ ))));
+ }
engine::invalidate();
- Ok(ops::engine_get(&config).await)
+ finish(Ok(ops::engine_get(&config).await))
})
}
diff --git a/crates/openhuman-core/src/memory/state_store_tests.rs b/crates/openhuman-core/src/memory/state_store_tests.rs
index 69fa928c3d..82796bfbf8 100644
--- a/crates/openhuman-core/src/memory/state_store_tests.rs
+++ b/crates/openhuman-core/src/memory/state_store_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::storage::StorageBackend;
use tinymemory_api::{ConsolidateRequest, ItemKind, Namespace, Reach};
use tinymemory_tools::BackgroundJob;