refactor(rag): extract candidate-source searchers into rag-candidate-sources.ts#641
Conversation
…sources.ts Audit 2026-07-13 deferred item D3, rag.ts decomposition phase 1 (finding 11). Zero behavior change: 1,014 lines moved verbatim (script-extracted with boundary guards and per-symbol assertions), nothing rewritten. Moved: the versioned-RPC plumbing (callVersionedRetrievalRpc, legacy owner/public merge, RPC error + variant-fanout telemetry), the lexical chunk / document-lookup / table-fact / embedding-field / index-unit candidate searchers, the chunk hydrators for memory cards and signal matches, and the memory-boost merge step. rag.ts (5,779 -> ~4,790 lines) imports the surfaces it orchestrates and re-exports callVersionedRetrievalRpc, loadChunksForMemoryCards, and loadChunksForSignalMatches so existing test imports are untouched. The extracted module depends only on non-rag lib modules - no import cycle. Verified: typecheck + lint clean, eval:rag:offline green (279 contract tests), verify:cheap green (2,301 tests), verify:pr-local green (build + client-bundle scan). The extracted module is byte-identical whether generated from the pre- or post-#626 base (the hardening PR touched no moved range). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds ChangesRAG candidate retrieval
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant RAG
participant CandidateSources
participant Supabase
RAG->>CandidateSources: request candidate search
CandidateSources->>Supabase: execute retrieval RPC or fallback query
Supabase-->>CandidateSources: candidate rows and metadata
CandidateSources->>Supabase: hydrate authorized chunks
Supabase-->>CandidateSources: chunk records
CandidateSources-->>RAG: ranked and boosted SearchResult candidates
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
Summary
Deferred audit item D3 — rag.ts decomposition phase 1 (2026-07-13 audit, finding 11). Zero behavior change: 1,014 lines moved verbatim, nothing rewritten.
What moved (rag.ts 5,779 → ~4,790 lines)
New module
src/lib/rag-candidate-sources.ts— the candidate retrieval surfaces for the search waterfall:callVersionedRetrievalRpc, the legacy owner/public row merge, RPC-error and variant-fanout telemetry recorders,SupabaseRpcError.searchTextChunkCandidates(with trigram-correction + OR-relaxation fallbacks),searchDocumentLookupFastPath(+ title-alias and best-chunk helpers),searchTableFactCandidates,searchEmbeddingFieldCandidates,searchIndexUnitCandidates.loadChunksForMemoryCards/loadChunksForSignalMatchesand thewithMemoryBoostedCandidatesmerge step, plusmergeSearchResults/memoryCardChunkScore.How the move was made safe
callVersionedRetrievalRpc,loadChunksForMemoryCards,loadChunksForSignalMatches— existing test imports (tests/retrieval-access-scope,tests/retrieval-hydration-scope) are untouched.Verification
typecheck+lintclean (14 now-unused rag.ts imports removed)eval:rag:offlinegreen — 279 offline RAG production-contract tests (the zero-behavior-change guard)verify:cheapgreen (2,301 tests)verify:pr-localgreen (production build + client-bundle secret scan)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes