fix(rag): mirror scoped corrector into schema.sql + regenerate drift manifest (F10)#701
Conversation
…manifest (F10) Completes the F10 corrector tenancy fix. Migration 20260717120000_corrector_public_titles_only (merged in #697) scoped the SECURITY DEFINER query-term corrector's vocabulary — both rag_aliases reads and the document-title scan — to the public corpus (owner_id is null). This mirrors that same predicate into the canonical supabase/schema.sql corrector definition so a disaster-recovery restore or manifest/schema reconciliation cannot recreate the unscoped, cross-tenant vocabulary (Codex review P1 on #697). Regenerated supabase/drift-manifest.json via `npm run drift:manifest` (real Docker Postgres replay): schema_sha256 and only the corrector function's def_hash change (8f1094c4… → a5ebdd1e…), confirming the sole schema delta is the scoped corrector. Offline drift-detection + schema tests pass (66). Live apply of the migration to the Clinical KB Database project remains a separate, confirmation-gated deploy-pipeline step (needs service-role env); after applying, `npm run check:drift` should report clean against live. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJpsbpsmjJ2tLLXFfSe9GK
|
Updates to Preview Branch (claude/audit-findings-review-phgz92) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe clinical query correction function now builds vocabulary from public aliases and indexed public documents only. Drift manifest metadata and the function definition hash were refreshed to reflect the schema change. ChangesPublic vocabulary scope
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Completes the F10 corrector-tenancy fix by closing the one gap left by #697's migration-only approach — the canonical
supabase/schema.sqlstill carried the unscoped corrector, which a disaster-recovery restore or manifest/schema reconciliation would replay (Codex review P1 on #697).supabase/schema.sql: mirror theowner_id is nullscope into all three vocabulary sources ofcorrect_clinical_query_terms(bothrag_aliasesreads + the document-title scan), matching the merged migration20260717120000_corrector_public_titles_only.sql.supabase/drift-manifest.json: regenerated vianpm run drift:manifest— a real Docker Postgres replay of the updatedschema.sql. The only snapshot delta is the corrector function'sdef_hash(8f1094c4…→a5ebdd1e…), plusschema_sha256/generated_at/replay_seconds; nothing else changed, confirming the sole schema difference is the scoped corrector.After this,
mainhas the migration,schema.sql, and the drift manifest all consistent — no DR/reconciliation path can reintroduce the cross-tenant vocabulary.Verification
npm run drift:manifest— replayedschema.sqlinto a scratchsupabase/postgres:17.6.1.127container (60s), regenerated the manifestnpx vitest run tests/drift-detection.test.ts tests/supabase-schema.test.ts— 66 passed (schema_sha256now matchesschema.sql; corrector scope asserted)git diff --check+prettier --check supabase/drift-manifest.json— cleannpm run check:driftagainst live — not run (needs service-role env; belongs to the live-apply step below)Clinical Governance Preflight
Touches source governance (retrieval query correction) + Supabase schema:
Clinical KB Database(sjrfecxgysukkwxsowpy)SECURITY DEFINER,executegranted only toservice_roleRemaining step — live apply (deploy pipeline, confirmation-gated)
The migration is not yet applied to the live project (this sandbox has no service-role env, and a clinical-production mutation belongs in the normal linked-migration deploy workflow). To finish end-to-end:
20260717120000_corrector_public_titles_only.sqltoClinical KB Databasevia the normal migration workflow.npm run check:driftagainst live — should report clean (live now matches thisschema.sql+ manifest).npm run check:supabase-project.No production mutations or provider calls were performed in this PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FJpsbpsmjJ2tLLXFfSe9GK
Generated by Claude Code
Summary by CodeRabbit