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 Enamakel1a8b7ae81148
diff --git a/crates/openhuman-core/src/memory/deletion_tests.rs b/crates/openhuman-core/src/memory/deletion_tests.rs
index fe632facbe..df8e885fec 100644
--- a/crates/openhuman-core/src/memory/deletion_tests.rs
+++ b/crates/openhuman-core/src/memory/deletion_tests.rs
@@ -190,7 +190,10 @@ fn an_unparsable_legacy_queue_is_quarantined_and_retry_queue_remains_usable() {
assert!(pending(tmp.path()).is_empty());
enqueue(tmp.path(), thread("t"));
assert_eq!(pending(tmp.path()), vec![thread("t")]);
- assert!(!file.exists(), "the corrupt legacy file is removed from the active path");
+ 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",
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 0b98937dc2..088afd7463 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -93,6 +93,13 @@ async fn save(config: &Config) -> Result<()> {
.map_err(|error| Error::Engine(format!("saving config failed: {error:#}")))
}
+fn engine_set_save_error(error: anyhow::Error) -> String {
+ if let Some(conflict) = crate::config::ops::config_save_conflict(&error, false) {
+ return conflict.encode();
+ }
+ StructuredRpcError::from(Error::Engine(format!("saving config failed: {error:#}"))).encode()
+}
+
pub(super) fn engines_list(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
rpc::<EmptyParams, _>(ctx, params, |_, config, _| async move {
Ok(ops::engines_list(&config))
@@ -113,18 +120,29 @@ pub(super) fn engine_set(ctx: DispatchCtx, params: Map<String, Value>) -> Contro
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:#}"
- ))));
+ return Err(engine_set_save_error(error));
}
engine::invalidate();
finish(Ok(ops::engine_get(&config).await))
})
}
+#[cfg(test)]
+mod tests {
+ use super::engine_set_save_error;
+
+ #[test]
+ fn nonconflict_save_failures_remain_engine_errors() {
+ let raw = engine_set_save_error(anyhow::anyhow!("disk unavailable"));
+ let error = crate::core::StructuredRpcError::decode(&raw).unwrap();
+ assert_eq!(error.data.as_ref().unwrap()["code"], "ENGINE");
+ assert_eq!(
+ error.message,
+ "engine error: saving config failed: disk unavailable"
+ );
+ }
+}
+
pub(super) fn recall(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
rpc::<RecallParams, _>(
ctx,
diff --git a/crates/openhuman-core/src/memory/state_store.rs b/crates/openhuman-core/src/memory/state_store.rs
index 58ad2bec31..d68b7d2f05 100644
--- a/crates/openhuman-core/src/memory/state_store.rs
+++ b/crates/openhuman-core/src/memory/state_store.rs
@@ -15,8 +15,8 @@ use serde::de::DeserializeOwned;
use serde::Serialize;
use sha2::Digest;
-use crate::storage::StorageBackend;
use crate::storage::state_kv::StateKv;
+use crate::storage::StorageBackend;
const OWNER: &str = "memory";
const NS: &str = "state";
@@ -140,7 +140,9 @@ pub(crate) fn import_all(
// before the layout migrator archives the old files. Remove the source
// only after the target write succeeds so an interrupted migration can
// retry without losing owed deletions.
- if let Some(previous) = local_kv.get::<Vec<super::deletion::PendingDeletion>>("pending_deletions")? {
+ if let Some(previous) =
+ local_kv.get::<Vec<super::deletion::PendingDeletion>>("pending_deletions")?
+ {
let mut pending = queue_kv
.get::<Vec<super::deletion::PendingDeletion>>("pending_deletions")?
.unwrap_or_default();
diff --git a/crates/openhuman-core/src/memory/state_store_tests.rs b/crates/openhuman-core/src/memory/state_store_tests.rs
index 130b9b3e3d..a2fd2d7b33 100644
--- a/crates/openhuman-core/src/memory/state_store_tests.rs
+++ b/crates/openhuman-core/src/memory/state_store_tests.rs
@@ -51,26 +51,14 @@ fn workspace_scopes_keep_retry_queues_stable_and_isolated_on_shared_storage() {
let second_scope = super::workspace_scope(second.path()).unwrap();
let first_storage = backend.for_scope(&first_scope).unwrap();
let second_storage = backend.for_scope(&second_scope).unwrap();
- let first_state = crate::storage::state_kv::StateKv::over(
- &first_storage,
- "memory",
- "state",
- );
+ let first_state = crate::storage::state_kv::StateKv::over(&first_storage, "memory", "state");
first_state
.put("pending_deletions", &vec!["thread-a".to_string()])
.unwrap();
- let first_reopened = crate::storage::state_kv::StateKv::over(
- &first_storage,
- "memory",
- "state",
- );
- let second_state = crate::storage::state_kv::StateKv::over(
- &second_storage,
- "memory",
- "state",
- );
+ let first_reopened = crate::storage::state_kv::StateKv::over(&first_storage, "memory", "state");
+ let second_state = crate::storage::state_kv::StateKv::over(&second_storage, "memory", "state");
assert_eq!(
first_reopened
.get::<Vec<String>>("pending_deletions")