Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(embed): report skipped pages in the scheduled backfill tick (#526)
Fabio Akitac2cc9477d925
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 275c57d0..a222aa0d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -75,6 +75,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0listing error is now reported on stderr, which the detached drainerredirects into `logs/hook-drain.log`, and individual unreadable entries arecounted and reported rather than silently shortening the queue (#493).+- The scheduled embedding backfill now reports how many pages it skipped.+ It logged `embedded`, `failed` and `errors`, so a tick that passed over+ every page and a tick with nothing to do produced the same completion+ line — a page being skipped once an hour was indistinguishable from a+ quiet, healthy scheduler. The count was already being returned by the+ backfill and discarded at the caller. Reported by @barrosohub, who also+ read the source to narrow it down (#509).+## [1.35.0] - 2026-08-29diff --git a/crates/ai-memory-cli/src/commands/serve.rs b/crates/ai-memory-cli/src/commands/serve.rsindex bf5a32e1..e9510b9a 100644--- a/crates/ai-memory-cli/src/commands/serve.rs+++ b/crates/ai-memory-cli/src/commands/serve.rs@@ -1107,6 +1107,7 @@ async fn start_maintenance_scheduler(Ok(outcome) => info!(scopes = outcome.scopes,embedded = outcome.embedded,+ skipped = outcome.skipped,failed = outcome.failed,errors = outcome.errors,elapsed_ms = started.elapsed().as_millis(),@@ -1308,6 +1309,10 @@ async fn run_scheduled_lint_tick(struct ScheduledEmbeddingBackfillTickOutcome {scopes: usize,embedded: usize,+ /// Pages that already had a current embedding. Reported because a+ /// tick that skipped everything and a tick that had nothing to do+ /// are otherwise indistinguishable in the log.+ skipped: usize,failed: usize,errors: usize,}@@ -1338,6 +1343,7 @@ async fn run_scheduled_embedding_backfill_tick({Ok(counts) => {outcome.embedded += counts.embedded;+ outcome.skipped += counts.skipped;outcome.failed += counts.failed;}Err(e) => {@@ -2654,6 +2660,58 @@ mod tests {}}+ /// A tick that skipped every page and a tick that had nothing to do+ /// both embed zero pages. Without `skipped` in the completion line+ /// they are the same log entry, so a page being passed over every+ /// hour reads as a quiet, healthy scheduler (#509).+ #[tokio::test]+ async fn scheduled_embedding_tick_distinguishes_skipped_work_from_an_idle_pass() {+ let (_tmp, store, wiki, ws, first, second) = two_project_wiki().await;+ let embedder: Arc<dyn Embedder> = Arc::new(SyntheticEmbedder::new(16));++ let idle =+ run_scheduled_embedding_backfill_tick(&store.reader, &store.writer, &wiki, &embedder)+ .await+ .unwrap();+ assert_eq!(+ (idle.embedded, idle.skipped),+ (0, 0),+ "no pages yet: nothing embedded and nothing skipped"+ );++ for (project, name) in [(first, "first"), (second, "second")] {+ write_test_page(+ &wiki,+ ws,+ project,+ &format!("notes/{name}.md"),+ name,+ Tier::Semantic,+ )+ .await;+ }++ let first_pass =+ run_scheduled_embedding_backfill_tick(&store.reader, &store.writer, &wiki, &embedder)+ .await+ .unwrap();+ assert_eq!((first_pass.embedded, first_pass.skipped), (2, 0));++ let second_pass =+ run_scheduled_embedding_backfill_tick(&store.reader, &store.writer, &wiki, &embedder)+ .await+ .unwrap();+ assert_eq!(+ (second_pass.embedded, second_pass.failed),+ (0, 0),+ "the work is done, so the tick embeds nothing"+ );+ assert_eq!(+ second_pass.skipped, 2,+ "but it must still say it passed over two pages, or it is indistinguishable from the idle tick above"+ );+ }+#[test]fn host_allowed_accepts_host_with_port() {let allowed = vec!["127.0.0.1".to_string(), "localhost".to_string()];