Repository navigation
feat(platform): move file indexing onto workpools - #3078
Merged
Merged
Conversation
Israeltheminer
force-pushed
the
feat/rag-indexing-workpool
branch
from
August 26, 2026 11:36
f7aab83 to
4cadbf9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ragParkedand 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) andragBackgroundPool(2), chosen by the row'ssource. Onlyuseris 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.maybeDispatchRagIndexingkeeps 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.
promoteQueuedRagJobsand its two call sites are deleted.An
onCompletemutation records a failed or canceled job on the row. Success is left alone, because the indexing action writescompletedwith chunk counts this mutation does not have.Migration
0.4.1/07enqueues 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
maxAttemptsis 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.tsexists 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 stuckrunningrow 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.