Repository navigation
Faster keyword search, a 90 second limit per search database call, and DSM "depression" search - #3560
Conversation
DSM search has no stemming, so 'depression' never matched MDD's text
('depressed', 'depressive') and the diagnosis was missing from the
results while records that only mention depression in passing filled
the list. Add a small curated alias list: depression, major depression
and clinical depression for MDD, chronic depression for persistent
depressive disorder. Local catalogue search only, no retrieval change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
…lding rows match_governed_candidate_chunks_v3 kept the text match as a select-list column only, so a keyword-only call (match_document_chunks_text_v3) built labels, summary, images and metadata for every eligible public chunk before discarding the non-matching ones. On the live corpus that took 30-48 s per call. Add one WHERE predicate that drops non-matching chunks first when there is no embedding. Hybrid calls are unchanged, and keyword-only output is unchanged because those calls can only rank text-matched rows. Approved by the owner on 15 Oct 2026 (open as draft, live only when he marks it ready), with a live canary pair around it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
…limit PR #3554 removed the 30 s deadline so slow keyword searches could finish. A finite 90 s limit keeps that while bounding a stalled call, including the query-correction RPC that does not carry the caller's abort signal. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Warning Review limit reachedYour organization has reached its usage spending cap. Adjust your spending cap in the billing tab. Next included review available in 54 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
There was a problem hiding this comment.
BigSimmo has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by QodoSpeed up keyword retrieval and improve depression searches
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
No findings for this group No findings for this group No findings for this group Resolved findings 1.
|
|
Cancelled. View session → |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7383d79a63
ℹ️ 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".
Main gained 20261015160000, so the prefilter migration is renamed to 20261015180000 to stay in order, sealed, and the drift manifest is regenerated from the merged schema. The schema test now mirrors the effective (prefiltered) function and pins that it differs from 20260901130000 only by the one prefilter predicate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
Qodo pushed a77cdb0 (split text-index probes via a UNION CTE) to this branch unreviewed. It edits the old 20261015140000 file, which this branch has since renamed, and leaves the drift manifest stale. Keep the reviewed single-predicate prefilter; the per-row label/summary/image/jsonb work it avoids is the measured cost. The index-probe idea can follow separately with its own EXPLAIN evidence. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
|
Code review by qodo was updated up to the latest commit 7f86952 |
A timed-out or failed correction resolves with an error and null data, which is not evidence the query has no match (Qodo finding on #3560). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
It threw on any correction error, failing the whole search where the previous behaviour ignored the error. The preceding commit instead keeps the search and skips only the cache write, with a test. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
|
Code review by qodo was updated up to the latest commit e649e0f |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
|
PR mergeability is failing because #3557 (Open shifts) merged first and changed the same files: The migration order is still correct. This PR's I have not resolved the conflict yet. Resolving it means merging main and regenerating the drift manifest, and pushing that leads straight to a live database change, so it is waiting on the owner's explicit go-ahead. Until then, nothing in this PR has reached the live database. Generated by Claude Code |
Resolves the clash with #3557 (Open shifts). The migration seal keeps both entries in version order, and the drift manifest is regenerated on the pinned Postgres image. Only match_governed_candidate_chunks_v3's def_hash differs from main. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq
Code Review ✅ Approved 3 closed / 3 findings🔴 High risk · The migration replaces the production governed clinical retrieval function; a faulty prefilter could omit relevant clinical sources from keyword search. Keyword search now prefilters text-matched chunks before building candidate rows, adds DSM depression aliases, and bounds search database calls at 90 seconds. Query-correction RPC now honors abort signals and no longer caches empty results after failures, and the drift manifest and schema definition issues are resolved. No open issues remain. ✅ 3 closed✅ Bug: drift-manifest.json not regenerated after schema.sql function change
✅ Quality: Historical v3 definition in schema.sql edited with an unused join
✅ Bug: Aborted correction RPC falls through and caches an empty result
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Approved For more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 6 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
|
Code review by qodo was updated up to the latest commit 08f258d |
Brings in #3560's 20261015180000 migration. The seal keeps every entry unchanged and lists this PR's 20261015181500 after it. The drift manifest takes main's header with schema_sha256 recomputed over the merged schema.sql. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LuYbdEGXeMntVA9KMgtAEx
Summary
Before: searching DSM for "depression" did not find Major depressive disorder. Keyword search on the live corpus can take 30 to 48 seconds. Since PR #3554, search database calls have no time limit at all, including the query-correction call.
After: "depression", "major depression" and "clinical depression" find Major depressive disorder first, and "chronic depression" finds Persistent depressive disorder. Each search database call now stops after 90 seconds instead of never. A search that makes several calls in sequence can still take longer in total, and a whole-search deadline is left as a follow-up. The keyword-only retrieval function now keeps only the chunks that match the query before it builds candidate rows. Before, it built a row for every public chunk and threw the non-matches away afterwards.
How:
src/lib/dsm.ts. This is the local DSM list ranker, not the protected RAG path.src/lib/rag/rag.tspassestimeoutMs: 90_000to the search admin client. This answers the CodeRabbit finding on Fix source-number taps and stop search cutting off keyword results at 30 seconds #3554 about the unboundedcorrect_clinical_query_termscall. The correction call also carries the caller's abort signal now. When that call fails, times out or is cancelled, the empty short-circuit result is not cached.20261015180000_prefilter_text_only_governed_retrieval.sqlre-createsmatch_governed_candidate_chunks_v3with one extraWHEREpredicate. It sorts after main's20261015160000and Open shifts: post a gap once, even when the answer is lost and the post is retried #3557's20261015174500. The predicate only applies whenquery_embedding is null, so hybrid and vector calls are unchanged. With a null embedding only text-matched rows could ever be returned, so the output set is identical and only the work to reach it shrinks.supabase/schema.sql,supabase/drift-manifest.jsonand the migration seal are updated to match. After merging Open shifts: post a gap once, even when the answer is lost and the post is retried #3557 in, the manifest was regenerated on the pinned local Postgres image, and only this function'sdef_hashdiffers from main.20260901130000only by that predicate.Areas touched: Data platform and access, Clinical reference content, Answer engine
RAG impact: behaviour change — canary pair 38766713061 (post-#3554 baseline, matches pre-regression run 37226742946 case for case) -> post-merge run to follow
Verification
npm run test:focused -- --files src/lib/rag/rag.ts: 60 files, 1222 tests passednpm run check:migration-immutabilitypassed (312 shipped migrations unchanged) andnpm run check:migration-rolepassedRisk and rollout
Clinical Governance Preflight
PsychSift Production(sjrfecxgysukkwxsowpy)The DSM aliases only change which catalogue entry a search lands on. No diagnostic text, criteria or sign-off state changes.
Notes
MHSP.AssessmentDocumentation.pdfis never retrieved. So the keyword timeouts are not the cause. It is tracked under #J8SJQ9.🤖 Generated with Claude Code
https://claude.ai/code/session_01VkKjYakMrMXofU8foQCgbq