Skip to content

feat(platform): move file indexing onto workpools - #3078

Merged
Israeltheminer merged 1 commit into
mainfrom
feat/rag-indexing-workpool
Aug 26, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
feat/rag-indexing-workpool

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

File indexing now runs on two Convex workpools instead of a hand-rolled queue. A background backlog can no longer hold every slot, and a waiting job can no longer be stranded with no signal.

Closes #2986 and #2987.

Why

One budget served everything that indexes — a member uploading a file, and every connector sync, crawl and email attachment. On a live deployment a connector minting one queued row every five minutes held the cap of 3 and no member upload indexed for seven days (#2987).

The queue itself was ours to run: count an org's in-flight rows, count the global total, then either schedule or set ragParked and wait for a later terminal transition to promote it. A parked row was excluded from the watchdog, so a promotion that never fired left it queued forever with nothing reporting it (#2986).

What changed

Two pools, ragInteractivePool (3) and ragBackgroundPool (2), chosen by the row's source. Only user is interactive; every other provenance, including an unstamped row, is background. That direction is the safe one — a background job mistaken for interactive can starve a member's upload, while the reverse only makes an import wait.

maybeDispatchRagIndexing keeps its signature and its callers. Inside, the counting and parking are gone: it guards, then enqueues.

There is no parked state left to strand. The pool owns the queue and drains itself, and its own recovery pass fails a job whose completion never ran, so a job lost to a restart or a hard kill cannot sit invisible. promoteQueuedRagJobs and its two call sites are deleted.

An onComplete mutation records a failed or canceled job on the row. Success is left alone, because the indexing action writes completed with chunk counts this mutation does not have.

Migration 0.4.1/07 enqueues rows that were already 'queued' when this deploys. Nothing else would ever pick them up: writers enqueue at the moment they queue a row, and the promotion pass that used to sweep the backlog is gone.

Risk

The 30-minute action ceiling is unchanged. A workpool cannot lift a platform limit, and it would retry a file that is simply too large, so maxAttempts is 3. Slicing is still what keeps an invocation short.

The two concurrency numbers are tied to KNOWLEDGE_DB_POOL_MAX (default 10). They sum to 5 so RAG search and status polls keep connections. Raising the env var without revisiting them leaves the pools as the binding constraint; both files say so.

Per-org fairness is gone. The old promoter walked parked rows oldest-first so a busy org could not starve a quiet one. A pool is FIFO. This is deliberate: one org per deployment is the normal shape, and multiple orgs are never concurrently busy. It is a throughput property, not an isolation one — no data is shared, every job carries its own org, and every read still resolves through that org's own pool.

Registering a component changes what convex-test needs. Any suite whose mutations queue a row must register the pools or it throws. rag_pools.testkit.ts exists so that is one call, and five suites now use it.

Tests

Nineteen unit cases over routing and the completion callback, plus the migration's own suite through the shared harness.

Nine deliberate breakages were introduced one at a time, all caught: the non-queued guard, the superseded-Hub-row check, the legacy park-flag clear, chat-bound routing, success-writes-nothing, completed-is-protected, and three on the routing rule itself — widening interactive to agent, always-background, and treating an unstamped row as interactive.

The routing rule has its own suite that imports the real module, because the dispatch suite mocks the pools and would otherwise only restate the rule it is meant to test.

Two suites asserted indexing by reading _scheduled_functions. A component's internal scheduling is not visible there — verified by probing it — so they now observe the pool's enqueues, and their headers say so.

Scope

Does not touch rag_watchdog.ts. The pool's recovery covers a lost job, but a genuinely stuck running row predating this change still needs the sweep, and retiring it deserves its own change with its own evidence.

Gate: typecheck, oxlint --type-aware, oxfmt, knip, SAST 0 findings, migrations:check (corpus, schema and config snapshots), platform suite 75,775 passing.

@Israeltheminer
Israeltheminer force-pushed the feat/rag-indexing-workpool branch from f7aab83 to 4cadbf9 Compare August 26, 2026 11:36
@Israeltheminer
Israeltheminer merged commit fc13fa3 into main Aug 26, 2026
52 checks passed
@Israeltheminer
Israeltheminer deleted the feat/rag-indexing-workpool branch August 26, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: a parked RAG indexing job has no recovery path and no signal

1 participant