feat(knowledge): fill the projection source and ACL in shards - #8112
Conversation
The fill's cost is graph insertion per row, which scales with cores while one run uses one. The runner takes an upper bound on its id range; a run may fill one shard of the chunk id space, sliced on the first hex digit so every shard is a contiguous range; the task admits one run per shard; the enqueue starts one chain per shard; and the warm after the fill runs once nothing is left unfilled anywhere.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
…ysis to whoever finishes A start's runs carry a per-shard idempotency key, so a retried start finds its runs rather than making more; a sliced start refuses a cursor, which belongs to one chain; the shard count is bounded by the runs the queue admits at once; a run reports its range done rather than the projection, and the run that finds nothing left anywhere analyzes and warms both projections once; the script reads its flag up front and refuses it where there is no worker to slice across.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ng another A start no longer relies on an idempotency key, which would have blocked a legitimate restart for its window and collided across options. Every run of a chain carries the chain's tag, continuations included, and a start lists in-flight runs by that tag first: a range whose chain is still running is left to it, whether the start is sliced or not, and a start after a chain ended starts anew.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
…its start The in-flight lookup and the trigger are two calls, so two starts in the same instant could both find no chain. Each trigger now carries the chain's tag as a short-lived idempotency key, long enough to cover that instant and short enough never to hold a later restart.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 6 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/knowledge/search/projection-source-acl-backfill.ts">
<violation number="1" location="apps/sim/lib/knowledge/search/projection-source-acl-backfill.ts:152">
P2: When a projection contains an orphaned row, `projectionsFilled` never returns true because the backfill intentionally cannot populate rows without a matching document. Ignore rows without a document in this completion probe so the final `ANALYZE` and prewarm still run for searchable data.</violation>
<violation number="2" location="apps/sim/lib/knowledge/search/projection-source-acl-backfill.ts:193">
P2: When `shards` remains `1`, an invalid `payload.shard` bypasses validation and creates a run that fails only when the worker computes its range. Validate `payload.shard` before the trigger regardless of the `shards` argument.</violation>
<violation number="3" location="apps/sim/lib/knowledge/search/projection-source-acl-backfill.ts:226">
P2: When an operator retries a terminal chain within two minutes, the same `idempotencyKey` suppresses the new backfill after the active-run lookup has stopped finding the old run. Use an idempotency key scoped to the individual start, or otherwise exclude terminal runs from the deduplication window.</violation>
</file>
…only rows the fill can finish A start's idempotency key is the chain's latest run, so two starts that saw the same state collapse into one while a start after another chain ended is its own; a start validates any shard it is handed; and the completion probe counts only unfilled rows whose document exists, since a row whose document is gone is not the fill's to finish.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
enqueueProjectionSourceAclBackfill(payload, shards)starts one chain per shard; the operator script takes--shards <n>. Without shards nothing changes: one chain over the whole space, one run at a timeType of Change
Testing
s.id < $2) so shards never meetvitestfor the backfill test file (15 tests) and the db package's runner tests,bun run lint,bun run check:auditsand nativetsc --noEmitpassChecklist