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
chore: files changed crates/openhuman-core/src/memory/deletion.rs,crates/openhuman-core/src/memory/i
Steven Enamakel34a65c1fab73
diff --git a/crates/openhuman-core/src/memory/deletion.rs b/crates/openhuman-core/src/memory/deletion.rsindex 71abecf1fa..7432e4bd73 100644--- a/crates/openhuman-core/src/memory/deletion.rs+++ b/crates/openhuman-core/src/memory/deletion.rs@@ -29,19 +29,6 @@ use tinymemory_api::Error;const STATE: &str = "pending_deletions";-fn quarantine_corrupt_legacy_file(workspace_dir: &Path) {- let legacy = super::state_store::legacy_path(workspace_dir, STATE);- let Ok(bytes) = std::fs::read(&legacy) else {- return;- };- if serde_json::from_slice::<Vec<PendingDeletion>>(&bytes).is_ok() {- return;- }- if let Err(error) = std::fs::rename(&legacy, legacy.with_extension("json.corrupt")) {- tracing::warn!(%error, "[memory:deletion] could not set the file aside");- }-}-/// The workspace's `pending_deletions` state value: a stop mid-write never/// loses the queue (the storage write is atomic). An unparsable value is/// dropped and logged; an empty queue removes the value.@@ -53,13 +40,9 @@ impl ListStore<PendingDeletion> for FileStore {fn load(&self) -> std::result::Result<Vec<PendingDeletion>, StoreError> {match super::state_store::load(&self.workspace_dir, STATE) {Ok(Some(pending)) => Ok(pending),- Ok(None) => {- quarantine_corrupt_legacy_file(&self.workspace_dir);- Ok(Vec::new())- }+ Ok(None) => Ok(Vec::new()),Err(error) => {tracing::warn!(%error, "[memory:deletion] reading pending deletions failed");- quarantine_corrupt_legacy_file(&self.workspace_dir);Err(StoreError("pending deletions unreadable".into()))}}diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rsindex 7cec741375..406f64bbdb 100644--- a/crates/openhuman-core/src/memory/import.rs+++ b/crates/openhuman-core/src/memory/import.rs@@ -35,8 +35,6 @@ pub(crate) struct StateKvCheckpointStore {const STATE: &str = "import_state";/// Backwards-compatible name for the former file checkpoint adapter.-pub(crate) type FileCheckpointStore = StateKvCheckpointStore;-impl StateKvCheckpointStore {pub(crate) fn new(workspace_dir: &Path) -> Self {Self {@@ -188,7 +186,7 @@ pub(crate) async fn resume_interrupted_with(if is_running(&config.workspace_dir) {return false;}- let store = FileCheckpointStore::new(&config.workspace_dir);+ let store = StateKvCheckpointStore::new(&config.workspace_dir);let file = store.load();let plan = Importer::resume_plan(&file, billing(config), paused());let mode = match plan {diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rsindex dba2945dff..64eed8ceac 100644--- a/crates/openhuman-core/src/memory/import_tests.rs+++ b/crates/openhuman-core/src/memory/import_tests.rs@@ -171,7 +171,7 @@ async fn a_credit_paused_import_waits_for_billing_and_records_a_resume_failure()let mut file = ImportFile::default();file.state.phase = ImportPhase::Error;file.paused_for_credits = true;- FileCheckpointStore::new(&config.workspace_dir)+ StateKvCheckpointStore::new(&config.workspace_dir).save(&file).unwrap();@@ -221,7 +221,7 @@ async fn resume_with_live_import_slot_does_not_claim_a_new_run() {bind_reference(&config);let mut file = ImportFile::default();file.state.phase = ImportPhase::Running;- let store = FileCheckpointStore::new(&config.workspace_dir);+ let store = StateKvCheckpointStore::new(&config.workspace_dir);store.save(&file).unwrap();let guard = crate::memory::run_slots::reserve(&crate::memory::run_slots::IMPORT,@@ -393,7 +393,7 @@ async fn a_real_legacy_document_imports_through_the_host_adapter() {let done = wait_for_host_import(&config).await;assert_eq!(done.imported, 1);assert_eq!(done.failed, 0);- let file = FileCheckpointStore::new(&config.workspace_dir).load();+ let file = StateKvCheckpointStore::new(&config.workspace_dir).load();assert_eq!(file.checkpoint.documents.as_deref(),Some("host-import-doc")@@ -416,7 +416,7 @@ async fn an_interrupted_import_resumes_through_the_host_adapter() {let mut interrupted = ImportFile::default();interrupted.state.phase = ImportPhase::Running;interrupted.state.total = 1;- FileCheckpointStore::new(&config.workspace_dir)+ StateKvCheckpointStore::new(&config.workspace_dir).save(&interrupted).unwrap();@@ -433,7 +433,7 @@ async fn an_interrupted_import_resumes_through_the_host_adapter() {let done = wait_for_host_import(&config).await;assert_eq!(done.imported, 1);assert_eq!(done.failed, 0);- let file = FileCheckpointStore::new(&config.workspace_dir).load();+ let file = StateKvCheckpointStore::new(&config.workspace_dir).load();assert_eq!(file.checkpoint.documents.as_deref(),Some("host-resume-doc")@@ -462,7 +462,7 @@ async fn retry_failed_reimports_a_real_legacy_row_through_the_host_adapter() {id: "memory_docs:host-retry-doc".to_string(),reason: "the prior engine refused this row".to_string(),});- FileCheckpointStore::new(&config.workspace_dir)+ StateKvCheckpointStore::new(&config.workspace_dir).save(&retry_state).unwrap();@@ -473,7 +473,7 @@ async fn retry_failed_reimports_a_real_legacy_row_through_the_host_adapter() {let done = wait_for_host_import(&config).await;assert_eq!(done.failed, 0);assert_eq!(done.imported, 1);- let file = FileCheckpointStore::new(&config.workspace_dir).load();+ let file = StateKvCheckpointStore::new(&config.workspace_dir).load();assert!(file.failed.is_empty());assert!(!file.retrying);assert_reference_contains(&engine, "retried legacy body").await;@@ -501,7 +501,7 @@ async fn an_interrupted_retry_resumes_its_real_legacy_row() {id: "memory_docs:host-retry-resume-doc".to_string(),reason: "the prior retry was interrupted".to_string(),});- FileCheckpointStore::new(&config.workspace_dir)+ StateKvCheckpointStore::new(&config.workspace_dir).save(&interrupted).unwrap();diff --git a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rsindex 90cc4f6b64..65aa5bf3b2 100644--- a/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/ops_tests.rs@@ -278,7 +278,7 @@ fn pause_import_for_credits(config: &Config) {let mut file = ImportFile::default();file.state.phase = ImportPhase::Error;file.paused_for_credits = true;- crate::memory::import::FileCheckpointStore::new(&config.workspace_dir)+ crate::memory::import::StateKvCheckpointStore::new(&config.workspace_dir).save(&file).unwrap();}diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rsindex e47c551f72..ad5e5e5030 100644--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs@@ -42,19 +42,6 @@ pub type JobQueue = QueueState;const STATE: &str = "jobs";-fn quarantine_corrupt_legacy_file(workspace_dir: &Path) {- let legacy = path(workspace_dir);- let Ok(bytes) = std::fs::read(&legacy) else {- return;- };- if serde_json::from_slice::<QueueState>(&bytes).is_ok() {- return;- }- if let Err(error) = std::fs::rename(&legacy, legacy.with_extension("json.corrupt")) {- tracing::warn!(%error, "[memory:jobs] could not set queue file aside");- }-}-/// The queue file of a workspace.fn path(workspace_dir: &Path) -> PathBuf {super::super::state_store::legacy_path(workspace_dir, STATE)@@ -69,13 +56,9 @@ impl QueueStore for FileQueueStore {fn load(&self) -> QueueState {match super::super::state_store::load(&self.workspace_dir, STATE) {Ok(Some(queue)) => queue,- Ok(None) => {- quarantine_corrupt_legacy_file(&self.workspace_dir);- QueueState::default()- }+ Ok(None) => QueueState::default(),Err(error) => {tracing::warn!(%error, "[memory:jobs] reading the queue failed");- quarantine_corrupt_legacy_file(&self.workspace_dir);QueueState::default()}}diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex 04d36391ae..dc3874091b 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -502,18 +502,17 @@ fn channel_key(channel: &str) -> String {/// existing quarantine behavior; current code never creates or updates it.#[cfg(feature = "channels")]fn legacy_channel_threads(workspace: &Path, channel: &str) -> BTreeSet<String> {- let file = workspace.join("memory").join("channel_threads.json");- let Ok(text) = std::fs::read_to_string(&file) else {- return BTreeSet::new();+ let all = match super::state_store::load::<BTreeMap<String, BTreeSet<String>>>(+ workspace,+ "channel_threads",+ ) {+ Ok(Some(all)) => all,+ Ok(None) => return BTreeSet::new(),+ Err(error) => {+ tracing::warn!(%error, "[memory:channels] reading legacy channel map failed");+ return BTreeSet::new();+ }};- let all: BTreeMap<String, BTreeSet<String>> =- serde_json::from_str(&text).unwrap_or_else(|error| {- tracing::warn!(%error, "[memory:channels] legacy channel map unparsable; set aside");- if let Err(error) = std::fs::rename(&file, file.with_extension("json.corrupt")) {- tracing::warn!(%error, "[memory:channels] could not set legacy map aside");- }- BTreeMap::new()- });all.get(&channel_key(channel)).cloned().unwrap_or_default()}diff --git a/crates/openhuman-core/src/memory/sources/state.rs b/crates/openhuman-core/src/memory/sources/state.rsindex 0d906b136f..60643d70b4 100644--- a/crates/openhuman-core/src/memory/sources/state.rs+++ b/crates/openhuman-core/src/memory/sources/state.rs@@ -23,13 +23,9 @@ fn path(workspace_dir: &Path) -> PathBuf {fn read_all(workspace_dir: &Path) -> BTreeMap<String, SourceState> {match crate::memory::state_store::load(workspace_dir, STATE) {Ok(Some(state)) => state,- Ok(None) => {- quarantine_legacy_file(workspace_dir);- BTreeMap::new()- }+ Ok(None) => BTreeMap::new(),Err(error) => {tracing::warn!(%error, "[memory:sources] reading sync state failed");- quarantine_legacy_file(workspace_dir);BTreeMap::new()}}@@ -41,19 +37,6 @@ fn write_all(workspace_dir: &Path, all: &BTreeMap<String, SourceState>) {}}-fn quarantine_legacy_file(workspace_dir: &Path) {- let file = path(workspace_dir);- let Ok(bytes) = std::fs::read(&file) else {- return;- };- if serde_json::from_slice::<BTreeMap<String, SourceState>>(&bytes).is_ok() {- return;- }- if let Err(error) = std::fs::rename(&file, file.with_extension("json.corrupt")) {- tracing::warn!(%error, "[memory:sources] could not set sync state file aside");- }-}-/// Every source's state.#[must_use]pub fn load(workspace_dir: &Path) -> BTreeMap<String, SourceState> {