Skip to content

Search follow-ups: privacy-safe alias capture, telemetry persistence, loud demo fallback, owner-auth e2e, live chip counts - #333

Merged
BigSimmo merged 5 commits into
mainfrom
claude/universal-search-algorithm-ryrps7
Jul 7, 2026
Merged

Search follow-ups: privacy-safe alias capture, telemetry persistence, loud demo fallback, owner-auth e2e, live chip counts#333
BigSimmo merged 5 commits into
mainfrom
claude/universal-search-algorithm-ryrps7

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 6, 2026

Copy link
Copy Markdown
Owner

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):

  • Item 17 — alias promotion unblocked (partially): weak-search misses now store RET-H4-safe candidate_aliases via new queryVocabularyAliasesForStorage — 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 require RAG_PERSIST_RAW_QUERY_TEXT=true, unchanged.
  • Item 19 — demo fallback made loud: nonProductionSupabaseDemoFallbackReason (the shared choke point for /api/search, /api/answer, /api/answer/stream) now emits a prominent console.warn naming the env vars to check whenever the non-prod demo fallback fires. Behaviour and the X-Clinical-KB-Fallback header are unchanged.
  • Item 20 — governance-weighting guard: verified the keys-free structural test already exists (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.
  • Item 21 — recalibration data now flowing: synthetic_similarity_count and text_or_relaxation_used were computed by retrieval but dropped by the telemetry whitelist in /api/search; they now persist into rag_retrieval_logs.metadata, giving the future gate recalibration real data.
  • Owner-auth e2e: new tests/universal-search-owner-live.test.ts signs in with the E2E_USER_* password user via supabase-js and exercises the real /api/search/universal handler 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.
  • Cross-mode chips show live counts ("Forms (2)") from the universal typeahead response, only when fresh results exist for the exact current query, so a stale count is never rendered. Includes a React Compiler memoization fix (destructured deps).
  • Items 18 / 22 / 23 / 24 / 25 (index-unit HNSW measurement, registry-to-corpus embedding, finding Improve Clinical KB dashboard and RAG hardening #11 Phase 2, OCR dropped-letter repair, retrieval latency): each needs live keys or major scope, so the honest smallest step was upgrading their doc entries from vague notes to concrete, stepped specs with measurement plans.
  • Preserves the post-merge branch commit 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:ui equivalent — ui-universal-search.spec.ts 3/3 on Chromium against a live demo-mode dev server (npm run ensure now works in sandboxed containers thanks to the earlier EAFNOSUPPORT fix)
  • npm run verify:release — not run (release gate)
  • npm run format:check
  • npm run eval:retrieval:qualityno 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 untouched
  • npm run check:production-readiness behaviour unchanged (the fallback warning is log-only)
  • npm run check:deployment-readiness — no deployment behaviour changed

Clinical Governance Preflight

  • Source-backed claims still require linked source verification (answer pipeline untouched)
  • No patient-identifiable workflow introduced or expanded — the new candidate-alias capture is strictly more conservative than raw retention: stored strings come only from the fixed curated vocabulary table, verified by new tests in tests/privacy.test.ts (a query containing a patient name emits only vocabulary canonicals)
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated — the fallback change only makes the existing demo swap louder
  • Source metadata / governance behaviour unchanged; item 20 confirms the structural guard that governance metadata never weights selection ordering
  • No clinical decision-support output changed

Notes

  • The chip counts and auth-invalidation are the only user-visible changes; everything else is observability, tests, and docs.
  • Follow-up specs now concrete enough to execute directly: items 18 (recall measurement plan), 22 (five-step registry-embedding spec with fabrication controls), 23 (finding Improve Clinical KB dashboard and RAG hardening #11 Phase 2), 24 (ingestion-time dictionary repair for OCR), 25 (two measured latency steps).

🤖 Generated with Claude Code

https://claude.ai/code/session_011QiyE8jMm7VnrtknHF6jnJ


Generated by Claude Code

claude and others added 2 commits July 6, 2026 18:01
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.
@supabase

supabase Bot commented Jul 6, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

BigSimmo commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

CI status note: all three checks (verify, ui-smoke, Gitleaks) are failing at startup with no logs and empty output — both on the original run and on a re-run. Jobs complete in ~2 seconds without a runner ever executing a step. That signature points to a GitHub Actions account/repo-level block (typically exhausted Actions minutes or a spending-limit/billing hold on a private repo), not to anything in this diff — the same workflows ran green on this repo earlier today (this was run #1415 of the day).

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: npm run verify:cheap green (1,143 vitest, lint, typecheck, runtime + sitemap checks), ui-universal-search.spec.ts 3/3 on Chromium against a live demo-mode dev server, and format:check clean.


Generated by Claude Code

@BigSimmo
BigSimmo marked this pull request as ready for review July 6, 2026 18:12
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@BigSimmo
BigSimmo enabled auto-merge July 6, 2026 18:14
cursoragent and others added 2 commits July 7, 2026 03:03
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>
@BigSimmo
BigSimmo merged commit 3f67a79 into main Jul 7, 2026
5 checks passed
@BigSimmo
BigSimmo deleted the claude/universal-search-algorithm-ryrps7 branch July 8, 2026 16:23
BigSimmo pushed a commit that referenced this pull request Aug 14, 2026
…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
BigSimmo pushed a commit that referenced this pull request Aug 14, 2026
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
BigSimmo pushed a commit that referenced this pull request Aug 15, 2026
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
BigSimmo pushed a commit that referenced this pull request Aug 15, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants