Skip to content

Commit 3ff5306

Browse files
committed
[recipes] Fix REVIEW-MEDIUM-1: filter restricted thoughts from preview views
Why: ops_recent_thoughts and ops_enrichment_gaps both emit left(content, 180) as a preview column without filtering on sensitivity_tier. Today the views are service_role-only, so there is no blast radius -- but the README markets them as queryable via PostgREST and "your dashboard", which primes a future maintainer to add GRANT SELECT ... TO authenticated. The moment that happens, the first 180 chars of every restricted thought flow out through these views. Add WHERE sensitivity_tier IS DISTINCT FROM 'restricted' to both views. This matches the convention used by search_thoughts_text(p_exclude_restricted) in schemas/enhanced-thoughts/schema.sql and costs one clause per view. Cheap insurance against a future "widen the grants for the dashboard" regression.
1 parent d9d9405 commit 3ff5306

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

recipes/brain-health-monitoring/ops-views.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SELECT
4343
enriched,
4444
left(content, 180) AS preview
4545
FROM public.thoughts
46+
WHERE sensitivity_tier IS DISTINCT FROM 'restricted'
4647
ORDER BY created_at DESC;
4748

4849
-- ============================================================
@@ -60,6 +61,7 @@ SELECT
6061
left(content, 180) AS preview
6162
FROM public.thoughts
6263
WHERE enriched IS NOT TRUE
64+
AND sensitivity_tier IS DISTINCT FROM 'restricted'
6365
ORDER BY created_at DESC;
6466

6567
-- ============================================================

0 commit comments

Comments
 (0)