fix: serialize reindex with active enrichment#1143
Conversation
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bce85d0bf0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Use an owner-scoped transactional RPC and shared document-row locks so full or retry reindex cannot overlap active agent enrichment. Preserve preflight-wide bulk conflict reporting and verify the schema in disposable Postgres.
…nrichment-guard # Conflicts: # src/app/api/documents/[id]/reindex/route.ts # src/app/api/documents/bulk/reindex/route.ts # supabase/drift-manifest.json
GraphQL review-thread reply returned 403; resolved the fixed reindex thread directly after validation. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
…nrichment-guard # Conflicts: # docs/branch-review-ledger.md
Resolve ledger conflict with #1143. Clear differential LRU on 401, reset document progressive-reveal by result ids, pass stable Related Documents callbacks, restore therapy/formulation clear via live state, and make Sheet focus-restore skip on unmount via layout mount flag. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Summary
ON CONFLICT (document_id)expression, proven against real PostgreSQLRAG impact: no retrieval behaviour change — this changes ingestion/reindex queue serialization only; retrieval ranking, selection, answer generation and cache semantics are unchanged.
Why
A route-level lease check can pass immediately before an enrichment worker claims the same document. Reindex and enrichment can then mutate overlapping artifacts concurrently. Both paths now serialize on the document row, and the RPC re-checks the enrichment lease while that lock is held.
Verification
origin/main:npx vitest run tests/ingestion-mutation-safety.test.ts tests/private-access-routes.test.ts tests/reindex-enrichment-lease.test.ts tests/stranded-queued-recovery.test.ts tests/supabase-schema.test.ts --maxWorkers=1— 221/221 passedagent_enrichment_active; zero ingestion jobsnpm run typechecknpm run check:migration-rolenpm run check:function-grants— all 31 security-definer functions protectednpm run check:owner-scope— 40 API files cleanClinical KB Database(sjrfecxgysukkwxsowpy); configuration-only, no API requestEarlier on this PR,
npm run verify:cheappassed runtime, policy/config, owner scope, lint and typecheck; the unit suite reached 3,265 passed/1 skipped before tracked issue #67 (reconciliation-preflight) hit its 30-second timeout. The exact post-migration focused suite is green above; the unchanged full wrapper was not repeated locally.UI/browser verification was not run because no UI, routing or styling changed. No OpenAI/Railway/live RAG call was made. No live Supabase migration or data mutation was performed.
Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)