Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(memory-tree): carry the queue-stall verdict so a stalled backfill is not "draining"\n\nCodex review follow-up on #6026. The #5324 stall check in\nderive_pipeline_status reports `degraded` once eligible work has waited six\nhours with nothing settling, but a stalled reembed_backfill row still keeps\nthe backfill snapshot `in_progress`, so the Sources row could show the\ndegraded warning and promise vectors "shortly" at the same time.\n\n`memory_tree_pipeline_status` gains the additive `queue_stalled` flag,\ncomputed by `queue_is_stalled()` — the status precedence's own predicate,\nfactored out so the flag and the status cannot disagree — and declared in\nthe controller outputs. The row's derivation and the Playwright oracle\ntreat it like a pause: pending chunks are stored without vectors until\nthe queue moves again. Tests: the predicate at and around the threshold,\nthe idle pipeline-status defaults, and a stalled queue with `in_progress`\nstill up.\n

Shanu1a421d609a6b
diff --git a/app/src/components/intelligence/sourcePipelineStatus.test.ts b/app/src/components/intelligence/sourcePipelineStatus.test.ts
index 179e6c5479..d20ff6a195 100644
--- a/app/src/components/intelligence/sourcePipelineStatus.test.ts
+++ b/app/src/components/intelligence/sourcePipelineStatus.test.ts
@@ -330,6 +330,21 @@ describe('deriveSourcePipelineHealth — vectors pending vs stored without vecto
}
);
+ it('reads a stalled queue as stuck even while the backfill snapshot says in progress', () => {
+ // The #5324 verdict: eligible work waiting six hours with nothing
+ // settling. A stalled `reembed_backfill` row still keeps `in_progress`
+ // up, but the core has ruled that nothing is draining, so the row must
+ // not promise "shortly" beside a degraded status.
+ const h = deriveSourcePipelineHealth(
+ makeStatus({ chunks_synced: 10, chunks_pending: 4, freshness: 'active' }),
+ makePipeline({ status: 'degraded', reason: 'queue stalled for 7h', queue_stalled: true }),
+ makeBackfill({ in_progress: true, pending_jobs: 1 })
+ );
+ expect(h.state).toBe('ingested_only');
+ expect(h.issues).toEqual(['stored_without_vectors']);
+ expect(h.vectorsPending).toBe(false);
+ });
+
it('stays retrieval_ready when a backfill runs but this source has nothing pending', () => {
const h = deriveSourcePipelineHealth(
makeStatus({ chunks_pending: 0 }),
diff --git a/app/src/components/intelligence/sourcePipelineStatus.ts b/app/src/components/intelligence/sourcePipelineStatus.ts
index 65e0bf6d8f..35e864440b 100644
--- a/app/src/components/intelligence/sourcePipelineStatus.ts
+++ b/app/src/components/intelligence/sourcePipelineStatus.ts
@@ -130,6 +130,10 @@ 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;
+ // - a stalled queue (`queue_stalled`: eligible work waiting six hours with
+ // nothing settling, the #5324 verdict): a stalled `reembed_backfill` row
+ // still keeps the snapshot `in_progress`, but the core has ruled that
+ // nothing is draining. 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
@@ -151,8 +155,10 @@ export function deriveSourcePipelineHealth(
const embeddingsBlocked = causeCode !== null && EMBEDDINGS_BLOCKING_CAUSES.has(causeCode);
const paused =
pipeline?.is_paused === true || pipeline?.status === 'paused' || pipeline?.gate_paused === true;
+ const stalled = pipeline?.queue_stalled === true;
const draining =
!paused &&
+ !stalled &&
(backfill
? backfill.in_progress === true
: status?.freshness === 'active' || status?.freshness === 'recent');
diff --git a/app/src/utils/tauriCommands/memoryTree.ts b/app/src/utils/tauriCommands/memoryTree.ts
index efec2193d9..641ad7c638 100644
--- a/app/src/utils/tauriCommands/memoryTree.ts
+++ b/app/src/utils/tauriCommands/memoryTree.ts
@@ -935,6 +935,14 @@ export interface MemoryTreePipelineStatus {
gate_paused?: boolean;
/** Why the gate is paused: `user_disabled` | `on_battery` | `cpu_pressure` | `signed_out` | `unknown`. */
gate_pause_reason?: string | null;
+ /**
+ * The #5324 stall verdict as a flag: eligible queue work has waited at
+ * least six hours without any job settling. `status` reads `degraded` for
+ * it; the flag tells that stall apart from the other degradations, because
+ * a stalled `reembed_backfill` row still keeps the backfill snapshot
+ * `in_progress` (openhuman#6025 review). Absent from an older core.
+ */
+ queue_stalled?: boolean;
/**
* #002 (FR-002/FR-005): degradation snapshot. Optional for back-compat with
* older cores that don't emit it (the Rust field is `#[serde(default)]`);
diff --git a/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts b/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts
index ca5b877b17..de793f02b7 100644
--- a/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts
+++ b/app/test/playwright/specs/brain-embedding-truthfulness.spec.ts
@@ -50,6 +50,7 @@ interface PipelineStatus {
status?: string;
is_paused?: boolean;
gate_paused?: boolean;
+ queue_stalled?: boolean;
degraded?: { semantic_recall?: boolean } | null;
first_blocking_cause?: { code?: string } | null;
}
@@ -298,8 +299,9 @@ test.describe('Brain — the UI tells the truth about embedding state', () => {
// the RIGHT text. The expectation is decided at the assertion point from
// the core's own account, through the same inputs and precedence as
// `deriveSourcePipelineHealth`: the recall latch, an embeddings-family
- // blocking cause, a paused scheduler gate (configured or live), or pending
- // chunks with no re-embed chain queued mean the amber warning; pending
+ // blocking cause, a paused scheduler gate (configured or live), a stalled
+ // queue, or pending chunks with no re-embed chain queued mean the amber
+ // warning; pending
// chunks the engine is draining mean the neutral note (openhuman#6025);
// a count of zero means a clean row. The backlog can drain, or the gate
// can pause, between one poll and the next, so only a row that
@@ -324,7 +326,10 @@ test.describe('Brain — the UI tells the truth about embedding state', () => {
const hard =
pipeline.degraded?.semantic_recall === true ||
(pending > 0 &&
- (embeddingsBlocked || schedulerPaused(pipeline) || !backfill.in_progress));
+ (embeddingsBlocked ||
+ schedulerPaused(pipeline) ||
+ pipeline.queue_stalled === true ||
+ !backfill.in_progress));
verdict.expected = hard ? 'warning' : pending > 0 ? 'note' : 'clean';
const shown = (await warning.isVisible())
? 'warning'
diff --git a/src/openhuman/memory/schema/schema_schema_part_02.rs b/src/openhuman/memory/schema/schema_schema_part_02.rs
index a2d254e549..87ad562d62 100644
--- a/src/openhuman/memory/schema/schema_schema_part_02.rs
+++ b/src/openhuman/memory/schema/schema_schema_part_02.rs
@@ -150,6 +150,15 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
running.",
required: false,
},
+ FieldSchema {
+ name: "queue_stalled",
+ ty: TypeSchema::Bool,
+ comment: "True when eligible queue work has waited at least six \
+ hours without any job settling (#5324). `status` reads \
+ `degraded` for it; the flag lets a client tell that stall \
+ from the other degradations (openhuman#6025).",
+ required: true,
+ },
FieldSchema {
name: "degraded",
ty: TypeSchema::Json,
diff --git a/src/openhuman/memory/tree/tree/rpc_part_02.rs b/src/openhuman/memory/tree/tree/rpc_part_02.rs
index 40fbb3109a..ab3738de40 100644
--- a/src/openhuman/memory/tree/tree/rpc_part_02.rs
+++ b/src/openhuman/memory/tree/tree/rpc_part_02.rs
@@ -207,6 +207,14 @@ pub struct PipelineStatusResponse {
/// `scheduler_policy` spells them the same way. `None` while running.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub gate_pause_reason: Option<String>,
+ /// The #5324 stall verdict as a flag: eligible work has waited at least
+ /// six hours without any job settling. `status` already reads `degraded`
+ /// for it, but a stalled `reembed_backfill` row still keeps the backfill
+ /// snapshot `in_progress`, and a row must not promise vectors "shortly"
+ /// while the queue is provably not draining (openhuman#6025 review).
+ /// Additive: `#[serde(default)]` keeps older clients deserialising.
+ #[serde(default)]
+ pub queue_stalled: bool,
/// #002 (FR-002/FR-004): "the pipeline ran but output quality is reduced"
/// — `semantic_recall` true when embeddings were skipped (no usable
/// provider, so recall falls back to recency), `structure` true when
@@ -367,6 +375,7 @@ pub async fn pipeline_status_rpc(
};
let failed_unrecoverable = queue.failed_unrecoverable;
let queue_idle_ms = queue_idle_ms(&queue, now_ms);
+ let queue_stalled = queue_is_stalled(queue_idle_ms);
// Disk size — best-effort. Permission errors etc. degrade to 0 with a
// warn log rather than failing the whole RPC. Scoped to the `wiki/`
@@ -484,6 +493,7 @@ pub async fn pipeline_status_rpc(
is_paused,
gate_paused,
gate_pause_reason,
+ queue_stalled,
degraded,
first_blocking_cause,
extraction_coverage,
diff --git a/src/openhuman/memory/tree/tree/rpc_part_03.rs b/src/openhuman/memory/tree/tree/rpc_part_03.rs
index b755a1557b..b42bf8a8bc 100644
--- a/src/openhuman/memory/tree/tree/rpc_part_03.rs
+++ b/src/openhuman/memory/tree/tree/rpc_part_03.rs
@@ -44,6 +44,14 @@ fn compute_dir_size_bytes(root: &std::path::Path) -> u64 {
/// machine or a laptop that was asleep for an hour.
pub(crate) const QUEUE_STALL_THRESHOLD_MS: i64 = 6 * 60 * 60 * 1000;
+/// The #5324 stall verdict on its own: eligible work has been waiting for at
+/// least [`QUEUE_STALL_THRESHOLD_MS`] without any job settling. Shared by the
+/// status precedence below and by the `queue_stalled` flag the response
+/// carries, so the two cannot disagree (openhuman#6025 review).
+pub(crate) fn queue_is_stalled(queue_idle_ms: Option<i64>) -> bool {
+ queue_idle_ms.is_some_and(|idle| idle >= QUEUE_STALL_THRESHOLD_MS)
+}
+
/// Pure derivation of `(status, reason)` from raw signals. Split out so the
/// unit tests can exercise the precedence rules without spinning up a
/// store.
@@ -106,7 +114,7 @@ fn derive_pipeline_status(
// degradation, and is deliberately NOT gated on `total_chunks` — a queue
// that never drained has no chunks to gate on, which is exactly the case
// that must not read as `idle`.
- if queue_idle_ms.is_some_and(|idle| idle >= QUEUE_STALL_THRESHOLD_MS) {
+ if queue_is_stalled(queue_idle_ms) {
let hours = queue_idle_ms.unwrap_or(0) / (60 * 60 * 1000);
return (
"degraded".to_string(),
diff --git a/src/openhuman/memory/tree/tree/rpc_tests_part_02_tests.rs b/src/openhuman/memory/tree/tree/rpc_tests_part_02_tests.rs
index 99590ea95a..a2380ead17 100644
--- a/src/openhuman/memory/tree/tree/rpc_tests_part_02_tests.rs
+++ b/src/openhuman/memory/tree/tree/rpc_tests_part_02_tests.rs
@@ -479,6 +479,8 @@ async fn pipeline_status_returns_idle_for_empty_store() {
// No gate sampler runs in unit tests, so the live policy is `Normal`.
assert!(!out.gate_paused);
assert!(out.gate_pause_reason.is_none());
+ // An empty queue has nothing waiting, so nothing is stalled.
+ assert!(!out.queue_stalled);
assert_eq!(out.wiki_size_bytes, 0, "no content dir yet");
assert!(out.reason.is_none());
}
@@ -625,3 +627,15 @@ fn gate_pause_state_maps_the_live_policy() {
assert_eq!(super::gate_pause_state(policy), (false, None));
}
}
+
+/// The stall flag the response carries is the status precedence's own
+/// predicate (openhuman#6025 review): nothing waiting is not a stall, one
+/// millisecond under the threshold is not a stall, the threshold is.
+#[test]
+fn queue_is_stalled_is_the_status_precedences_own_predicate() {
+ assert!(!super::queue_is_stalled(None));
+ assert!(!super::queue_is_stalled(Some(0)));
+ assert!(!super::queue_is_stalled(Some(QUEUE_STALL_THRESHOLD_MS - 1)));
+ assert!(super::queue_is_stalled(Some(QUEUE_STALL_THRESHOLD_MS)));
+ assert!(super::queue_is_stalled(Some(QUEUE_STALL_THRESHOLD_MS * 4)));
+}