-=======
->>>>>>> theirs
@@ -693,10 +687,7 @@ export function ServicesNavigatorPage() {
{[
{ label: "Best fit", query: defaultQuery },
{ label: "Crisis", query: "crisis" },
- { label: "Culturally safe", query: "Aboriginal and Torres Strait Islander" },
-=======
{ label: "Culturally safe", query: "Aboriginal Torres Strait Islander" },
->>>>>>> theirs
{ label: "Phone referral", query: "phone referral" },
{ label: "Free", query: "free" },
{ label: "WA", query: "WA" },
@@ -744,4 +735,3 @@ export function ServicesNavigatorPage() {
);
}
-
diff --git a/supabase/drift-manifest.json b/supabase/drift-manifest.json
index cf17e3e01..3bec0a518 100644
--- a/supabase/drift-manifest.json
+++ b/supabase/drift-manifest.json
@@ -1,9 +1,9 @@
{
- "generated_at": "2026-07-23T23:41:25.333Z",
+ "generated_at": "2026-07-25T11:36:54.504Z",
"generator": "scripts/generate-drift-manifest.ts",
"postgres_image": "supabase/postgres:17.6.1.127",
- "schema_sha256": "19b45be58ad5999f6df80429cd66097e14ab8ad727cc90cd97f3917b0f9e8d6c",
- "replay_seconds": 16,
+ "schema_sha256": "e15600503c3a133c7cb7b1ac3fe66213be230a4af4fd429e10e38497422874a1",
+ "replay_seconds": 64,
"snapshot": {
"views": [
{
@@ -6774,6 +6774,14 @@
"def_hash": "cb65883a561cb1f5cd2247213f417a41",
"signature": "public.correct_clinical_query_terms(text,real)"
},
+ {
+ "acl": [
+ "postgres=X/postgres",
+ "service_role=X/postgres"
+ ],
+ "def_hash": "54f1ab21c9d7cee9555b187dec088371",
+ "signature": "public.create_uploaded_document_with_ingestion_job(jsonb,integer)"
+ },
{
"acl": [
"postgres=X/postgres",
@@ -6890,7 +6898,7 @@
"postgres=X/postgres",
"service_role=X/postgres"
],
- "def_hash": "5028a7406b7014ea8e274d29c8bbf6f9",
+ "def_hash": "6e95d81f1c01d31a5405fba42ba4b089",
"signature": "public.invoke_ingestion_worker(integer)"
},
{
From 6c6555dd8c346164085ad0a1099198a192ae22de Mon Sep 17 00:00:00 2001
From: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
Date: Sat, 25 Jul 2026 23:30:19 +0800
Subject: [PATCH 4/6] docs: ledger PR #1197 fix-forward after Bugbot
remediation
Record sync-to-main outcome, restored clinical contracts, dropped
unattested RAG pre-classifier, and retained SQL URL remediation only.
---
docs/branch-review-ledger.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/branch-review-ledger.md b/docs/branch-review-ledger.md
index 9381e74bf..ae6d13a7a 100644
--- a/docs/branch-review-ledger.md
+++ b/docs/branch-review-ledger.md
@@ -962,3 +962,4 @@ This file is append-only. Never rewrite or delete an existing review record; app
| 2026-07-25 | `cursor/ledger-066-067-519b` | f04392a408eceee14215c15169cbd6b70ac2041c | Close stale ledger #066/#067 (+ drop resolved #030/#075 from queue) | READY. #066 proven on main via #1174; #067 already fixed in #1191 in-process preflight. Docs-only ledger sync; no code change. | Local proof: `git show`/`log` for #1174/#1191; preflight test already in-process on main; ledger integrity asserts. No providers. |
| 2026-07-25 | execute-audit-remediation-plan (PR #1188) | 8b8639113925601e1687bfe4f1f29c44a4308b61 | Bugbot/diff-review: maintainability remediation tip | BLOCK: tip tree carries unresolved conflict markers (answer/upload APIs, clinical-dashboard, services, tests); invalid `async export function sha256Hex` in indexing-v3 utils; ClinicalDashboard still calls removed `renderSystemNotice`; merge-tree vs main conflicts in check-github-action-pins.mjs + ui-primitives.tsx. Intended notices extraction/dynamic imports look mostly sound; search-scope/migration not in three-dot product delta. | `git grep` conflict markers on tip (none on origin/main); `git show` for ClinicalDashboard:3824 + utils.ts:191; `git merge-tree --write-tree origin/main 8b8639113`; no provider-backed checks. |
| 2026-07-25 | PR #1209 / `cursor/pr1186-audit-remediation-c94c` | `4cb22e45dfe46b1975fa15ddd028c7e14ceb5fab` | Close #1186 + babysit #1209 CI | DONE. Closed #1186 as superseded. Synced origin/main (MERGEABLE/CLEAN). Fixed PR-policy RAG impact line. Hosted PR required SUCCESS (Static/Safety/Unit/Build/Production UI/Advisory UI/containers) on pre-ledger tip; docs-only follow-up pushed. Ready to merge; auto-merge not enabled. | gh pr checks; local policy ok; no provider/eval runs. |
+| 2026-07-25 | cursor/pr1197-fix-regressions-d06a (PR #1197 fix) | c1e9696de6000440ad5b44e4d2fb2738a858deae | Fix-forward after Bugbot do-not-merge review | FIXED for tip. Synced to origin/main; restored clinical-notes trust gate + boundary tests + summaryMode 400 contract by taking main; removed ISSUE-07 RAG pre-classifier (rag.ts matches main � RAG impact: no retrieval behaviour change). Kept only additive SQL remediation: migration 20260725000000 (real worker URL + ISSUE-05 revokes), schema.sql URL/[REDACTED] fix + ISSUE-05, regenerated drift-manifest. Dropped broken upload authority refs (undefined canonicalAuthority). | Vitest: summaryMode reject + ClinicalNotes boundary 4/4; rag-classifier-memo + rag-tail-latency 17/17; upload smart-title/cleanup 3/3; check:migration-role pass; drift:manifest regenerated via Docker. No provider-backed checks. |
From c7ae011683614c8de6027347b49e8b3fb79dfa34 Mon Sep 17 00:00:00 2001
From: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
Date: Sat, 25 Jul 2026 23:45:48 +0800
Subject: [PATCH 5/6] fix(pr-1197): harden audit migration grants for merge
safety
Reassert service_role EXECUTE after CREATE OR REPLACE for
invoke_ingestion_worker and the ISSUE-05 invoker RPCs, align schema.sql
trailing ACL with the migration, and regenerate the drift manifest.
---
supabase/drift-manifest.json | 4 +-
...60725000000_audit_security_remediation.sql | 45 +++++++++++++------
supabase/schema.sql | 6 ++-
3 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/supabase/drift-manifest.json b/supabase/drift-manifest.json
index d895d45ae..6bedb04da 100644
--- a/supabase/drift-manifest.json
+++ b/supabase/drift-manifest.json
@@ -1,8 +1,8 @@
{
- "generated_at": "2026-07-25T15:26:27.983Z",
+ "generated_at": "2026-07-25T15:45:24.778Z",
"generator": "scripts/generate-drift-manifest.ts",
"postgres_image": "supabase/postgres:17.6.1.127@sha256:be60aee15997daca475b710b734bc6bfe52cd544dcd7e9fd2ff58210b6747d83",
- "schema_sha256": "e29595579b9b77ea4b3605665695a51428c9a4dfca22c58b659d7403cea34e40",
+ "schema_sha256": "81240cb662ec8a9da27eca60a3908587f565c3eb67981aa0c21961d6b333a3d5",
"replay_seconds": 15,
"snapshot": {
"views": [
diff --git a/supabase/migrations/20260725000000_audit_security_remediation.sql b/supabase/migrations/20260725000000_audit_security_remediation.sql
index 271ea5866..fb6b88053 100644
--- a/supabase/migrations/20260725000000_audit_security_remediation.sql
+++ b/supabase/migrations/20260725000000_audit_security_remediation.sql
@@ -1,6 +1,15 @@
--- Audit Remediation: Security and Hardening (ISSUE-04, ISSUE-05, ISSUE-08)
+-- Audit remediation: correct invoke_ingestion_worker URL fallback + harden grants.
+--
+-- Context: migration 20260724130100 introduced the GUC-backed worker URL pattern
+-- but landed with a literal `[REDACTED]` fallback (from an earlier audit export).
+-- Hosted apply of that migration can leave cron ingestion pointing at an invalid
+-- base URL when `app.ingestion_worker_base_url` is unset. This follow-up restores
+-- the real Clinical KB Database project URL and reasserts fail-closed grants.
+--
+-- ISSUE-05 / ISSUE-04 reasserts are idempotent with earlier migrations and with
+-- supabase/schema.sql. Do not edit the already-applied 20260724130100 blob.
--- ISSUE-08: Replace hardcoded project URL in invoke_ingestion_worker with a GUC-based setting.
+-- ISSUE-08: set GUC + replace function with the real project URL fallback.
do $$
begin
execute format('alter database %I set app.ingestion_worker_base_url = %L',
@@ -11,17 +20,17 @@ exception
end
$$;
-CREATE OR REPLACE FUNCTION public.invoke_ingestion_worker(p_limit integer DEFAULT 25)
- RETURNS bigint
- LANGUAGE plpgsql
- SECURITY DEFINER
- SET search_path TO 'public', 'extensions', 'vault', 'pg_temp'
-AS $function$
+create or replace function public.invoke_ingestion_worker(p_limit integer default 25)
+returns bigint
+language plpgsql
+security definer
+set search_path = public, extensions, vault, pg_temp
+as $$
declare
v_request_id bigint;
v_jwt text;
- v_base_url text;
v_limit integer := greatest(1, least(coalesce("p_limit", 25), 200));
+ v_base_url text;
begin
select "decrypted_secret" into v_jwt
from "vault"."decrypted_secrets"
@@ -32,6 +41,8 @@ begin
raise exception 'Missing Vault secret: cron_ingestion_jwt';
end if;
+ -- Prefer the GUC; fall back to the hardcoded production URL so that
+ -- existing deployments that have not yet set the GUC continue to work.
v_base_url := coalesce(
nullif(current_setting('app.ingestion_worker_base_url', true), ''),
'https://sjrfecxgysukkwxsowpy.supabase.co'
@@ -50,16 +61,22 @@ begin
return v_request_id;
end;
-$function$;
+$$;
+
+-- CREATE OR REPLACE can leave grants ambiguous across platforms; reassert explicitly.
+revoke execute on function public.invoke_ingestion_worker(integer) from public, anon, authenticated;
+grant execute on function public.invoke_ingestion_worker(integer) to service_role;
--- ISSUE-05: Revoke PUBLIC Execution on Invoker RPCs
+-- ISSUE-05: revoke PUBLIC / client-role execute on invoker RPCs (idempotent).
revoke execute on function public.detect_legacy_ivfflat_indexes() from public, anon, authenticated;
revoke execute on function public.document_summary_text(uuid) from public, anon, authenticated;
revoke execute on function public.search_document_chunks(uuid, text, integer, uuid) from public, anon, authenticated;
revoke execute on function public.set_document_embedding_field_content_hash() from public, anon, authenticated;
+grant execute on function public.detect_legacy_ivfflat_indexes() to service_role;
+grant execute on function public.document_summary_text(uuid) to service_role;
+grant execute on function public.search_document_chunks(uuid, text, integer, uuid) to service_role;
+grant execute on function public.set_document_embedding_field_content_hash() to service_role;
--- ISSUE-04: Align Data API Table Grants
--- To ensure fail-closed posture matches live, we explicitly revoke all privileges on all tables
--- and sequences in schema public from anon and authenticated.
+-- ISSUE-04: Data API table/sequence fail-closed posture (idempotent with schema.sql).
revoke all privileges on all tables in schema public from anon, authenticated;
revoke all privileges on all sequences in schema public from anon, authenticated;
diff --git a/supabase/schema.sql b/supabase/schema.sql
index b9fb69de0..0dde9afc4 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -1,4 +1,4 @@
--- Medical RAG Knowledge Base schema.
+-- Medical RAG Knowledge Base schema.
-- Run this in the Supabase SQL editor or with the Supabase CLI.
-- Tables are RLS protected; the local Next.js API and worker use the service role.
--
@@ -9141,3 +9141,7 @@ revoke execute on function public.detect_legacy_ivfflat_indexes() from public, a
revoke execute on function public.document_summary_text(uuid) from public, anon, authenticated;
revoke execute on function public.search_document_chunks(uuid, text, integer, uuid) from public, anon, authenticated;
revoke execute on function public.set_document_embedding_field_content_hash() from public, anon, authenticated;
+grant execute on function public.detect_legacy_ivfflat_indexes() to service_role;
+grant execute on function public.document_summary_text(uuid) to service_role;
+grant execute on function public.search_document_chunks(uuid, text, integer, uuid) to service_role;
+grant execute on function public.set_document_embedding_field_content_hash() to service_role;
From 44f68a3aec692f488257710a43c8cb10145daa7f Mon Sep 17 00:00:00 2001
From: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
Date: Sat, 25 Jul 2026 23:46:12 +0800
Subject: [PATCH 6/6] docs: ledger PR #1197 merge-ready grant harden
---
docs/branch-review-ledger.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/branch-review-ledger.md b/docs/branch-review-ledger.md
index 1b8cbb46e..b3028f41a 100644
--- a/docs/branch-review-ledger.md
+++ b/docs/branch-review-ledger.md
@@ -964,3 +964,4 @@ This file is append-only. Never rewrite or delete an existing review record; app
| 2026-07-25 | execute-audit-remediation-plan (PR #1188) | 8b8639113925601e1687bfe4f1f29c44a4308b61 | Bugbot/diff-review: maintainability remediation tip | BLOCK: tip tree carries unresolved conflict markers (answer/upload APIs, clinical-dashboard, services, tests); invalid `async export function sha256Hex` in indexing-v3 utils; ClinicalDashboard still calls removed `renderSystemNotice`; merge-tree vs main conflicts in check-github-action-pins.mjs + ui-primitives.tsx. Intended notices extraction/dynamic imports look mostly sound; search-scope/migration not in three-dot product delta. | `git grep` conflict markers on tip (none on origin/main); `git show` for ClinicalDashboard:3824 + utils.ts:191; `git merge-tree --write-tree origin/main 8b8639113`; no provider-backed checks. |
| 2026-07-25 | PR #1209 / `cursor/pr1186-audit-remediation-c94c` | `4cb22e45dfe46b1975fa15ddd028c7e14ceb5fab` | Close #1186 + babysit #1209 CI | DONE. Closed #1186 as superseded. Synced origin/main (MERGEABLE/CLEAN). Fixed PR-policy RAG impact line. Hosted PR required SUCCESS (Static/Safety/Unit/Build/Production UI/Advisory UI/containers) on pre-ledger tip; docs-only follow-up pushed. Ready to merge; auto-merge not enabled. | gh pr checks; local policy ok; no provider/eval runs. |
| 2026-07-25 | cursor/pr1197-fix-regressions-d06a (PR #1197 fix) | c1e9696de6000440ad5b44e4d2fb2738a858deae | Fix-forward after Bugbot do-not-merge review | FIXED for tip. Synced to origin/main; restored clinical-notes trust gate + boundary tests + summaryMode 400 contract by taking main; removed ISSUE-07 RAG pre-classifier (rag.ts matches main � RAG impact: no retrieval behaviour change). Kept only additive SQL remediation: migration 20260725000000 (real worker URL + ISSUE-05 revokes), schema.sql URL/[REDACTED] fix + ISSUE-05, regenerated drift-manifest. Dropped broken upload authority refs (undefined canonicalAuthority). | Vitest: summaryMode reject + ClinicalNotes boundary 4/4; rag-classifier-memo + rag-tail-latency 17/17; upload smart-title/cleanup 3/3; check:migration-role pass; drift:manifest regenerated via Docker. No provider-backed checks. |
+| 2026-07-25 | execute-system-audit-remediation (PR #1197) | c7ae011683614c8de6027347b49e8b3fb79dfa34 | Merge-ready polish: grant reassert + CI green path | READY. Hardened migration/schema to reassert service_role EXECUTE after CREATE OR REPLACE / ISSUE-05 revokes; drift regenerated. Prior regressions remain fixed (trust gate, summaryMode, no RAG pre-classifier). Delta vs main: migration + schema + drift + ledger only. | check:migration-role; drift:manifest; supabase-schema + function-grants Vitest 83/83; awaiting hosted PR required on tip. |