Search follow-ups: privacy-safe alias capture, telemetry persistence, loud demo fallback, owner-auth e2e, live chip counts - #333
Conversation
One small step for each open item from the universal-search workstream
(docs/rag-hybrid-findings-and-todo.md items 17-25):
- Item 17 (alias promotion blocked by redaction): weak-search misses now
store RET-H4-safe candidate aliases — canonical terms from the curated
clinical vocabulary that the query matched (output text comes from the
fixed vocabulary table, never the raw query), via new
queryVocabularyAliasesForStorage. Raw tokens still require
RAG_PERSIST_RAW_QUERY_TEXT.
- Item 19 (demo fallback masks live failures): the shared fallback choke
point (nonProductionSupabaseDemoFallbackReason) now console.warns loudly,
naming the env vars to check; behaviour and headers unchanged.
- Item 20 (governance-weighting guard): verified already covered by the
existing keys-free structural test in retrieval-selection.test.ts —
marked done in the findings doc.
- Item 21 (gate recalibration): synthetic_similarity_count and
text_or_relaxation_used now persist into rag_retrieval_logs.metadata
(they were computed but dropped by the telemetry whitelist), so the
recalibration has data to work from.
- Owner-auth e2e: new universal-search-owner-live.test.ts signs in with the
E2E password user via supabase-js and exercises the real route handler
with a genuine bearer token; skips cleanly when live env is absent
(browser-login coverage is not feasible — header sign-in is
magic-link/OAuth only).
- Cross-mode chips now show live counts ("Forms (2)") from the universal
typeahead response, only when fresh results exist for the exact query.
- Items 18 (index-unit HNSW/ef_search), 22 (registry-to-corpus embedding),
23 (finding #11 Phase 2), 24 (OCR dropped letters), 25 (latency):
upgraded from vague notes to concrete measured/stepped specs in the
findings doc — each needs live keys or major scope, so a spec is the
honest smallest step.
Verified: verify:cheap green (1143 tests; live spec skips without keys),
format:check clean, ui-universal-search.spec.ts 3/3 against a live
demo-mode dev server (npm run ensure now works in this container thanks to
the upstream EAFNOSUPPORT fix).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QiyE8jMm7VnrtknHF6jnJ
When authorizationHeader changes (sign-in, sign-out, or token refresh), clear cached result groups so the dropdown shows loading instead of stale results from the previous access tier until the refetch completes.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
CI status note: all three checks ( To confirm/resolve: check Settings → Billing → Actions (minutes/spending limit) or the run page banner at https://github.com/BigSimmo/Database/actions/runs/28812592369, then re-run the failed jobs. For confidence in the meantime, the local equivalents of these gates all passed on this exact head commit: Generated by Claude Code |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Use isUsableBrowserSupabaseKey and placeholder detection so CI with placeholder-ci-anon-key never runs the live route. When credentials are present but Supabase rejects sign-in, warn and return instead of failing the unit suite. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
…s staleness check check:medication-lexicon-report fails on clean main, so any PR whose scope reaches that gate is red before it starts. This is what #333 asked for as its next step, and it refutes #331's hypothesis of a comparison bug. The staleness was real but wrapping-only: normalising whitespace on the committed and regenerated files leaves them byte-identical across all 28 catalogue terms, so no content changed and no clinical review is implicated. Every branch saw the failure because main itself carried the stale copy, which is why "zero diff on my branch" was the wrong instrument. It escaped npm run format because prettier runs proseWrap: preserve, so both wrappings are valid. Regenerated with npm run medications:lexicon-report followed by prettier, the order the check expects. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BKNFogaYfCQBvFVqFQnfRt
Four merge-safe inbox requests; docs/outstanding-issues.md is untouched and is reconciled separately after this PR lands. - update #316: Phase 0 closed, including the forced-dispatch proof (run 31813064485 -> auto-created issue #1963). Also supersedes the stale 2026-08-09 drift figures with measured ones: 10 RPC mismatches unchanged, 20 missing indexes, 2 unexpected, and the two trigram indexes confirmed restored. - done #331: its comparison-bug hypothesis is refuted; the staleness was real and wrapping-only, inherited from main by every branch. - update #333: the regeneration half is done here; its real question - the check runs in verify:pr-local but in no CI job - stays open. - update #292: records the #1938/#1939 Phase 0 duplicate against the existing duplicate-work row rather than opening a near-identical new one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BKNFogaYfCQBvFVqFQnfRt
Merge-safe inbox request; docs/outstanding-issues.md is untouched and is reconciled separately after this PR lands. Both halves of the row are addressed: the regeneration in #1951 and the CI wiring in this PR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BKNFogaYfCQBvFVqFQnfRt
…rchived #333 was closed by another session while this branch was in flight, so the queued done request was invalid and made applyRequestBatch throw with "#333 is already archived", red-lining docs:check-links for this branch. Removing the request rather than cancelling it is the correct mechanism here: the file only ever existed on this branch and never reached main, so its removal nets to zero against the write-discipline guard's base. Verified: ledger write discipline passes and docs:check-links is green again. My pre-check was too weak and is worth recording. I checked that no competing mutation targeted #333 and that a #333 row existed, but the existence grep matched the ARCHIVED row. The check that mattered was whether the row was still in the open table. The substance is unaffected: the CI wiring in this PR is what #333 asked for, and the row's own closure note already records it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BKNFogaYfCQBvFVqFQnfRt
Summary
The smallest logical fix for each issue left open after #325 (tracked as items 17–25 in
docs/rag-hybrid-findings-and-todo.md):candidate_aliasesvia newqueryVocabularyAliasesForStorage— only canonical terms from the curated clinical vocabulary that the query matched are persisted, so the stored text always comes from the fixed vocabulary table and never from the raw query (a patient name cannot leak). Raw query tokens still requireRAG_PERSIST_RAW_QUERY_TEXT=true, unchanged.nonProductionSupabaseDemoFallbackReason(the shared choke point for/api/search,/api/answer,/api/answer/stream) now emits a prominentconsole.warnnaming the env vars to check whenever the non-prod demo fallback fires. Behaviour and theX-Clinical-KB-Fallbackheader are unchanged.tests/retrieval-selection.test.ts, "keeps relevance ordering and does not let source-governance metadata reorder selection") — marked done in the findings doc, no code needed.synthetic_similarity_countandtext_or_relaxation_usedwere computed by retrieval but dropped by the telemetry whitelist in/api/search; they now persist intorag_retrieval_logs.metadata, giving the future gate recalibration real data.tests/universal-search-owner-live.test.tssigns in with theE2E_USER_*password user via supabase-js and exercises the real/api/search/universalhandler with a genuine bearer token, asserting the owner rung of the access ladder (not demo, not public fixtures). Skips cleanly when live env is absent. Browser-login Playwright coverage is deliberately not attempted — the header sign-in UI is magic-link/OAuth only.fix: invalidate universal search typeahead when auth changes(rebased onto the new base).Verification
npm run verify:cheap— green (1,143 vitest passed; the new owner-live spec skips without keys)npm run verify:uiequivalent —ui-universal-search.spec.ts3/3 on Chromium against a live demo-mode dev server (npm run ensurenow works in sandboxed containers thanks to the earlier EAFNOSUPPORT fix)npm run verify:release— not run (release gate)npm run format:checknpm run eval:retrieval:quality— no retrieval, ranking, selection, chunking, or scoring behaviour changed in this PR (telemetry persistence, logging, UI, and tests only), so the golden eval is not triggered by this diff; the outstanding run for Universal search: fix core RAG search defects and federate medications/services/forms/differentials/tools into one cross-entity search #325's retrieval changes still applies.npm run eval:rag/eval:quality— answer generation untouchednpm run check:production-readinessbehaviour unchanged (the fallback warning is log-only)npm run check:deployment-readiness— no deployment behaviour changedClinical Governance Preflight
tests/privacy.test.ts(a query containing a patient name emits only vocabulary canonicals)Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_011QiyE8jMm7VnrtknHF6jnJ
Generated by Claude Code