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
Keep forgetting by id after the rechecks; fix the test initializers
M3gA-Minde7307b5fb85d
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rsindex d659fe060e..9aaee0c0ba 100644--- a/crates/openhuman-core/src/memory/import.rs+++ b/crates/openhuman-core/src/memory/import.rs@@ -250,18 +250,11 @@ struct ImportFile {/// Whether the last import ended with its last batch not confirmed listed:/// the layout migration then forgets by id, never erasing scopes whole, and-/// copies again before it finishes. A confirming import, or it, clears it.+/// copies again before it finishes. Only an import that confirms clears it.pub(crate) fn listed_unconfirmed(workspace_dir: &Path) -> bool {read_file(workspace_dir).listed_unconfirmed}-/// Clears [`listed_unconfirmed`] once the migration has re-checked.-pub(crate) fn clear_listed_unconfirmed(workspace_dir: &Path) {- let mut file = read_file(workspace_dir);- file.listed_unconfirmed = false;- write_file(workspace_dir, &file);-}-fn file_path(workspace_dir: &Path) -> PathBuf {workspace_dir.join("memory").join("import_state.json")}diff --git a/crates/openhuman-core/src/memory/import_recovery_tests.rs b/crates/openhuman-core/src/memory/import_recovery_tests.rsindex 58461cc88c..1efe471063 100644--- a/crates/openhuman-core/src/memory/import_recovery_tests.rs+++ b/crates/openhuman-core/src/memory/import_recovery_tests.rs@@ -22,6 +22,7 @@ async fn a_resumed_import_keeps_its_total_instead_of_rescanning() {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,@@ -49,6 +50,7 @@ async fn a_resumed_import_keeps_its_total_instead_of_rescanning() {fn the_import_state_is_written_whole_and_leaves_no_staging_file() {let tmp = tempfile::tempdir().unwrap();let file = ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rsindex 36d5d6181f..6ee7cb3c05 100644--- a/crates/openhuman-core/src/memory/import_tests.rs+++ b/crates/openhuman-core/src/memory/import_tests.rs@@ -263,6 +263,7 @@ async fn an_interrupted_import_resumes_from_its_checkpoint() {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,@@ -299,6 +300,7 @@ fn a_running_state_with_no_live_import_reads_as_interrupted() {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,@@ -509,6 +511,7 @@ async fn an_import_the_app_quit_during_resumes_on_its_own() {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,@@ -542,6 +545,7 @@ async fn a_stopped_or_finished_import_is_not_resumed_on_its_own() {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,@@ -566,6 +570,7 @@ fn quit_mid_import(config: &Config) {write_file(&config.workspace_dir,&ImportFile {+ listed_unconfirmed: false,paused_for_credits: false,failed: Vec::new(),retrying: false,diff --git a/crates/openhuman-core/src/memory/layout_migration/job.rs b/crates/openhuman-core/src/memory/layout_migration/job.rsindex a5e5b2e648..2ec1943ad4 100644--- a/crates/openhuman-core/src/memory/layout_migration/job.rs+++ b/crates/openhuman-core/src/memory/layout_migration/job.rs@@ -141,7 +141,9 @@ wherelet mut state = state::load(dir)?;// Cleaned with the import still unconfirmed (a stop between cleanup and// the re-check below) goes round once more rather than counting as done.- if state.phase == Phase::Cleaned && !crate::memory::import::listed_unconfirmed(dir) {+ if state.phase == Phase::Cleaned+ && (state.rechecked || !crate::memory::import::listed_unconfirmed(dir))+ {return Ok(Outcome::Done);}let engines = host.engines(config)?;@@ -208,10 +210,16 @@ where// pass still moves something new, at most MAX_RECHECKS times. A late item// is never erased meanwhile (`cleanup`). Each recheck is saved before its// wait, so a stop or a restart resumes it.- while state.phase == Phase::Cleaned && crate::memory::import::listed_unconfirmed(dir) {+ while state.phase == Phase::Cleaned+ && !state.rechecked+ && crate::memory::import::listed_unconfirmed(dir)+ {let new = state.copied > state.replayed;if !((state.rechecks == 0 || new) && state.rechecks < MAX_RECHECKS) {- crate::memory::import::clear_listed_unconfirmed(dir);+ // Done re-checking. The import's flag stays: nothing here proves+ // its last batch is listed, so cleanup keeps forgetting by id.+ state.rechecked = true;+ state::save(dir, &state)?;break;}state.rechecks += 1;diff --git a/crates/openhuman-core/src/memory/layout_migration/job_tests.rs b/crates/openhuman-core/src/memory/layout_migration/job_tests.rsindex 879e32d995..b387c21c2d 100644--- a/crates/openhuman-core/src/memory/layout_migration/job_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/job_tests.rs@@ -198,12 +198,19 @@ async fn after_an_unconfirmed_import_an_item_listed_late_is_still_moved() {"the late item was moved");assert_eq!(count(host.legacy.as_ref()).await, 0);- assert!(!crate::memory::import::listed_unconfirmed(- &config.workspace_dir- ));+ let state = state::load(&config.workspace_dir).unwrap();assert_eq!(- state::load(&config.workspace_dir).unwrap().rechecks,- 2,+ state.rechecks, 2,"one forced recheck that moved the late item, one that moved nothing");+ assert!(state.rechecked, "re-checking is over");+ assert!(+ crate::memory::import::listed_unconfirmed(&config.workspace_dir),+ "the flag stays: later cleanups keep forgetting by id"+ );+ assert_eq!(+ go(&config, &host, Trigger::Auto).await,+ Outcome::Done,+ "settled, not re-checked again"+ );}diff --git a/crates/openhuman-core/src/memory/layout_migration/service.rs b/crates/openhuman-core/src/memory/layout_migration/service.rsindex 0540ebfe87..1fc30dbacf 100644--- a/crates/openhuman-core/src/memory/layout_migration/service.rs+++ b/crates/openhuman-core/src/memory/layout_migration/service.rs@@ -217,7 +217,8 @@ pub fn tick(match state::load(&config.workspace_dir) {Ok(state)if state.phase == Phase::Cleaned- && !crate::memory::import::listed_unconfirmed(&config.workspace_dir) =>+ && (state.rechecked+ || !crate::memory::import::listed_unconfirmed(&config.workspace_dir)) =>{false}diff --git a/crates/openhuman-core/src/memory/layout_migration/state.rs b/crates/openhuman-core/src/memory/layout_migration/state.rsindex 0a855039b0..6e3f496451 100644--- a/crates/openhuman-core/src/memory/layout_migration/state.rs+++ b/crates/openhuman-core/src/memory/layout_migration/state.rs@@ -77,6 +77,10 @@ pub struct MigrationState {/// batch not confirmed listed (see `job::run`).#[serde(default, skip_serializing_if = "is_zero")]pub rechecks: u32,+ /// Those passes are over (one moved nothing new, or the most were made).+ /// The import's flag stays set, so cleanup keeps forgetting by id.+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]+ pub rechecked: bool,}fn is_zero(n: &u32) -> bool {diff --git a/crates/openhuman-core/src/memory/layout_migration/state_tests.rs b/crates/openhuman-core/src/memory/layout_migration/state_tests.rsindex 77adba8877..427b238279 100644--- a/crates/openhuman-core/src/memory/layout_migration/state_tests.rs+++ b/crates/openhuman-core/src/memory/layout_migration/state_tests.rs@@ -25,6 +25,7 @@ fn a_saved_state_loads_back_and_leaves_no_temporary_file() {caught_up: false,takeover: true,rechecks: 1,+ rechecked: true,};save(tmp.path(), &state).unwrap();assert_eq!(load(tmp.path()).unwrap(), state);