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
fix(memory-sources): trust the backfill snapshot over content freshness
Shanue6fc6b849639
diff --git a/app/src/components/intelligence/sourcePipelineStatus.test.ts b/app/src/components/intelligence/sourcePipelineStatus.test.tsindex bb2bc778b8..179e6c5479 100644--- a/app/src/components/intelligence/sourcePipelineStatus.test.ts+++ b/app/src/components/intelligence/sourcePipelineStatus.test.ts@@ -209,15 +209,30 @@ describe('deriveSourcePipelineHealth — vectors pending vs stored without vectoexpect(h.state).toBe('vectors_pending');});- it('reads pending chunks as vectors_pending while the newest chunk is recent (under five minutes)', () => {+ it('reads pending chunks as vectors_pending while the newest chunk is recent, with no backfill snapshot', () => {const h = deriveSourcePipelineHealth(makeStatus({ chunks_synced: 10, chunks_pending: 4, freshness: 'recent' }),null,- makeBackfill({ in_progress: false })+ null);expect(h.state).toBe('vectors_pending');});+ it('lets an explicit "no chain queued" snapshot outrank a fresh chunk', () => {+ // `last_chunk_at_ms` is the content's own time (an email's sent date,+ // a file's mtime), not proof that a worker is alive; a future-dated item+ // reads `active` forever. When the engine says no chain is queued, the+ // backlog is stuck whatever the freshness pill shows.+ const h = deriveSourcePipelineHealth(+ makeStatus({ chunks_synced: 10, chunks_pending: 4, freshness: 'active' }),+ makePipeline(),+ makeBackfill({ in_progress: false })+ );+ expect(h.state).toBe('ingested_only');+ expect(h.issues).toEqual(['stored_without_vectors']);+ expect(h.vectorsPending).toBe(false);+ });+it('flags stored_without_vectors once the backlog is idle with no chain queued', () => {const h = deriveSourcePipelineHealth(makeStatus({ chunks_synced: 10, chunks_pending: 4, freshness: 'idle' }),diff --git a/app/src/components/intelligence/sourcePipelineStatus.ts b/app/src/components/intelligence/sourcePipelineStatus.tsindex cd51b769b0..65e0bf6d8f 100644--- a/app/src/components/intelligence/sourcePipelineStatus.ts+++ b/app/src/components/intelligence/sourcePipelineStatus.ts@@ -27,8 +27,9 @@* (openhuman#6025). A backlog that is being drained is *pending*, not* *failed*: the row shows a neutral note and keeps its freshness pill. The* amber warning is reserved for a backlog nothing will drain: the global- * recall latch, an embeddings-family blocking cause, or pending chunks with- * no chain queued and no chunk written for over five minutes.+ * recall latch, an embeddings-family blocking cause, a paused scheduler+ * gate, or pending chunks with no chain queued. The source's freshness+ * stands in only when that snapshot is unavailable.** The function is pure so it can be unit-tested exhaustively without a DOM.*/@@ -129,10 +130,15 @@ export function deriveSourcePipelineHealth(// may still be writing, but no worker will embed anything until the gate// lifts, so "shortly" would be a promise nobody is keeping. Pending// chunks are hard until then;- // - otherwise pending chunks are soft while the engine reports a re-embed- // chain with rows to process, OR this source's newest chunk landed inside- // the core's own `recent` window (≤ 5 min: ingest is still writing and- // the chain is queued behind it). A backlog with neither is stuck: hard.+ // - otherwise the engine's own word decides: pending chunks are soft while+ // `backfill.in_progress` reports a re-embed chain with rows to process,+ // and hard when that snapshot says no chain is queued. Only when the+ // snapshot is unavailable (RPC failed, older core) does the source's+ // freshness stand in: a chunk inside the core's `recent` window (≤ 5 min)+ // suggests ingest is still writing and the chain arms on the next extract+ // admit. A fallback, not evidence of a worker — `last_chunk_at_ms` is the+ // content's own time (an email's sent date), which is why it never+ // outranks an explicit "no chain queued".//// `backfill.in_progress` is process-wide on purpose, not a per-source// signal to be narrowed: the chain it reports is signature-wide — each@@ -147,9 +153,9 @@ export function deriveSourcePipelineHealth(pipeline?.is_paused === true || pipeline?.status === 'paused' || pipeline?.gate_paused === true;const draining =!paused &&- (backfill?.in_progress === true ||- status?.freshness === 'active' ||- status?.freshness === 'recent');+ (backfill+ ? backfill.in_progress === true+ : status?.freshness === 'active' || status?.freshness === 'recent');const storedWithoutVectors = recallLatched || (pending > 0 && (embeddingsBlocked || !draining));if (storedWithoutVectors) {issues.push('stored_without_vectors');diff --git a/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts b/app/test/playwright/specs/brain-embedding-truthfulness.spec.tsindex f09669104f..ea472a2e1e 100644--- a/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts+++ b/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts@@ -51,6 +51,16 @@ interface PipelineStatus {first_blocking_cause?: { code?: string } | null;}+/** `memory_tree_memory_backfill_status`: whether a re-embed chain is queued. */+interface BackfillStatus {+ in_progress: boolean;+ pending_jobs: number;+}++async function backfillStatus(): Promise<BackfillStatus> {+ return callCoreRpc<BackfillStatus>('openhuman.memory_tree_memory_backfill_status', {});+}+/** Mirrors `EMBEDDINGS_BLOCKING_CAUSES` in `sourcePipelineStatus.ts`. */const EMBEDDINGS_BLOCKING_CAUSES = new Set(['budget_exhausted',@@ -286,22 +296,30 @@ test.describe('Brain — the UI tells the truth about embedding state', () => {//// The backlog can finish draining between the RPC read above and the// row's next 5 s poll, so the expectation is decided at the assertion- // point from the core's own count: while chunks are still pending the- // note must be showing; once the count reaches zero the row is clean- // and the note is correctly gone. Only "pending but no note" is a- // failure, and it is polled past because the row refreshes on a timer.+ // point from the core's own account, the same two inputs the row reads:+ // chunks still pending with a re-embed chain queued must show the+ // waiting note; chunks pending with no chain queued are stuck and must+ // show the amber warning; a count of zero is a clean row. Only a row+ // that contradicts the core fails, and it is polled past because the+ // row refreshes on a timer.const note = row.getByTestId(`memory-source-vectors-pending-${id}`);+ const warning = row.getByTestId(`memory-source-pipeline-warning-${id}`);await expect.poll(async () => {const pendingNow = (await statusFor(id))?.chunks_pending ?? 0;if (pendingNow === 0) return 'drained';- return (await note.isVisible()) ? 'pending-shown' : 'pending-hidden';+ const draining = (await backfillStatus()).in_progress;+ if (draining) return (await note.isVisible()) ? 'pending-shown' : 'pending-hidden';+ return (await warning.isVisible()) ? 'stuck-shown' : 'stuck-hidden';},- { timeout: 30_000, message: 'chunks are pending but the row shows no waiting note' }+ {+ timeout: 30_000,+ message:+ 'the row contradicts the core: pending chunks with no note, or a stuck backlog with no warning',+ })- .not.toBe('pending-hidden');- await expect(row).not.toContainText('Stored without vectors');+ .not.toMatch(/-hidden$/);}});