openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Source status reports every chunk as pending: chunks_pending reads a column nothing writes

Open yh928 opened this issue 4 months ago • 2 comments

What happens

Memory source status shows 620 chunks / 620 pending for a Gmail source. The two numbers are identical, and they are identical for every source that has chunks — chunks_pending can never be lower than chunks_synced.

Why

src/openhuman/memory_sources/status.rs:65 counts pending chunks like this:

SELECT COUNT(*),
       SUM(CASE WHEN embedding IS NULL THEN 1 ELSE 0 END),
       MAX(timestamp_ms)
  FROM mem_tree_chunks
 WHERE source_id LIKE ?1

mem_tree_chunks has no embedding column in the current schema — embeddings live in the sidecar table mem_tree_chunk_embeddings, keyed by (chunk_id, model_signature) (vendor/tinycortex/src/memory/chunks/schema.rs:66).

The column still exists at runtime only because a migration keeps adding it back:

// vendor/tinycortex/src/memory/chunks/connection.rs:162
add_column_if_missing(conn, "mem_tree_chunks", "embedding", "BLOB")?;

Nothing in production writes it (the only writers are in store_conn_tests.rs), so it is NULL for every row. The query therefore reports pending == total, always.

Impact

The number is not a signal. A user watching it cannot tell a healthy store from a store with zero embeddings, and neither can a support conversation — the display is the same either way.

Expected

Count chunks that have no embedding row for the active signature, the same condition has_uncovered_reembed_work already uses (vendor/tinycortex/src/memory/chunks/embeddings.rs:404):

NOT EXISTS (SELECT 1 FROM mem_tree_chunk_embeddings e
             WHERE e.chunk_id = c.id AND e.model_signature IN (...))

Repro

Any instance with an ingested Composio source:

openhuman.memory_sources_status_list {}
→ {"chunks_pending": 620, "chunks_synced": 620, ...}

Observed on a live instance running v0.63.x.

yh928 avatar Aug 03 '26 07:08 yh928

Follow-on filed as #6025. The counting half described here is fixed in tinymemory 1.14 (crates/tinymemory-core/src/sources/status.rs now derives chunks_pending from the mem_tree_chunk_embeddings sidecar, the dropped/skipped ledgers, not the dead inline column), and the pinned module on main is 1.14.1. What remains is the UI reading a genuinely transient pending count as a failure, which #6025 covers. This one is probably closable once someone confirms on a desktop build.

YellowSnnowmann avatar Sep 04 '26 10:09 YellowSnnowmann

Verified fixed on main f5c5ba892 with the pinned tinymemory 1.14.1 module. The count is now driver-side (crates/tinymemory-core/src/sources/status.rs INGEST_COUNTS_SQL: no sidecar row, not dropped, not skipped) and no embedding IS NULL reader remains in the host, tinymemory, or the pinned tinycortex. Live store shows chunks_pending below chunks_synced and draining to zero (681/327 → 694/0 within five minutes). The one leftover is the stale doc comment in app/src/components/intelligence/sourcePipelineStatus.ts:15, the TypeScript half asked for when #5344 was closed; it ships with the fix for #6025. The transient-count-shown-as-failure follow-on is tracked in #6025.

YellowSnnowmann avatar Sep 04 '26 11:09 YellowSnnowmann