Skip to content

docs(database): make pgTAP tests a required RLS procedure step - #49270

Closed
czenko wants to merge 2 commits into
cursor/rls-claim-verify-f756from
cursor/rls-eval-tests-f756
Closed

czenko wants to merge 2 commits into
cursor/rls-claim-verify-f756from
cursor/rls-eval-tests-f756

Conversation

@czenko

@czenko czenko commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Docs update, stacked on #49269, which is stacked on #49268, which is stacked on #49017.

Review #49017, then #49268, then #49269, then this PR.

Stack (bottom → top): #49017 (docs/rls-restructure → master) → #49268 (cursor/rls-accuracy-f756 → docs/rls-restructure) → #49269 (cursor/rls-claim-verify-f756 → cursor/rls-accuracy-f756) → this PR (cursor/rls-eval-tests-f756 → cursor/rls-claim-verify-f756).

Local tracking is via gh stack. Creating the GitHub Stack object failed here with Resource not accessible by integration. To attach official GitHub Stack metadata:

gh stack link --base master 49017 49268 49269 49270

What is the current behavior?

The latest build-docs-002-rls-guide refresh (evals#215) still fails. Grants, policies, access probes, indexes, and security-definer helpers all pass. The only misses are the three pgTAP checks.

That split is the signal. The guide already taught grants and already had a Test section. Grants are copyable SQL in the “enable RLS / public read” extract the agent actually fetches (web_fetch, ~6907 characters). Tests were a later section plus “remember to write tests” prose. The extract query asked for enable RLS, CREATE POLICY, auth.uid(), indexes, wrapping, roles, security definer functions, ownership, and public read. It did not ask for tests. More testing instructions in a Test section do not enter that extract.

The prompt never says test. Whether the agent writes pgTAP is the measurement.

What is the new behavior?

Stop adding testing prose. Put the test files in the examples the agent already copies.

  • Public read (enable-RLS extract): weather_readings now has enable + revoke + grant select + using (true) and the matching supabase/tests/weather_readings_rls.test.sql (allow select / deny writes for anon and authenticated).
  • Owner-private (CREATE POLICY extract): the four policies are followed immediately by supabase/tests/profiles_rls.test.sql (plan(12), allow and deny all four operations, returning on allowed writes, is_empty on using-filtered update/delete). A short note covers shared-member cases.
  • Security definer extract: glue to add member vs non-member cases on that table’s test file.
  • Test your policies shrinks to how to create and run the files. The skippable later example is gone.

-- File: supabase/tests/... is the first line of each test so the path survives if fence metadata is dropped.

The eval still hits the published URL, so this cannot pass until the stack is on master.

Additional context

Does not name the eval’s membership tables. Does not encode “revoke EXECUTE from authenticated.”

Open in Web Open in Cursor 

@vercel

vercel Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, v0 Aug 19, 2026 7:53pm
6 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 19, 2026 7:53pm
design-system Skipped Skipped Aug 19, 2026 7:53pm
studio-self-hosted Skipped Skipped Aug 19, 2026 7:53pm
studio-staging Skipped Skipped Aug 19, 2026 7:53pm
ui-library Skipped Skipped Aug 19, 2026 7:53pm
zone-www-dot-com Skipped Skipped Aug 19, 2026 7:53pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 07c5be3a-c569-4261-9900-515bc6d1615b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 19, 2026
@czenko czenko closed this Aug 19, 2026
@czenko czenko reopened this Aug 19, 2026
cursoragent and others added 2 commits August 19, 2026 12:47
The build-docs-002-rls-guide eval still fails only because agents skip
pgTAP: they fetch a short best-practices extract of enable/syntax/roles
and never reach tests. Put the CLI commands in that path, move Test
before indexes, and expand the example to allow and deny all four
operations.

Co-authored-by: Miranda Limonczenko <[email protected]>
… copy

Grants already pass this eval because they are copyable SQL in the
enable-RLS extract. A separate Test section does not: the agent fetches a
short best-practices summary of CREATE POLICY, auth.uid(), and public
read, and never reaches later testing prose.

Put the public-read test file next to the weather_readings grants, and the
owner-private test file immediately after the four CREATE POLICY examples,
so those extracts include supabase/tests/*.sql.

Co-authored-by: Miranda Limonczenko <[email protected]>
@czenko

czenko commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #49274, which carries this work as a single PR stacked on #49017. Nothing is lost: the combined branch produces a byte-identical guide to this chain's tip.

Closing and deleting the branch.

@czenko czenko closed this Aug 19, 2026
@czenko
czenko deleted the cursor/rls-eval-tests-f756 branch August 19, 2026 21:23
czenko added a commit that referenced this pull request Aug 19, 2026
## Problem

The guide alternated between context, procedure, and reference on almost
every heading. A reader who wanted to write a policy passed through four
context or reference sections to reach one. A reader who wanted the
model had to skip three procedures.

## Solution

- Group into three sections by information type: `Understand Row Level
Security`, `Secure a table with RLS`, and `RLS reference`, with a
navigation intro.
- Merge the four policy sections. They repeated the same setup block,
burying the clause that differed. One setup block now precedes four
short policy examples.
- Move the auto-enable recipe into `event-triggers.mdx`, whose stub
section's entire body was a link back here.
- Relocate the stranded `auth.uid()` caution into the `auth.uid()`
reference.
- Lift the revoke-and-grant procedure out of the danger admonition and
merge it with the two other places that taught `enable row level
security`.
- Point the Grafana IO chart entry at the performance guide. Its
`#rls-performance-recommendations` anchor went away when tuning split
out in #49016.

765 lines to 582. 30 headings to 25.

Headings are demoted rather than renamed wherever anything links to
them. Every inbound anchor in the repo still resolves; the only one
removed, `#auto-enable-rls-for-new-tables`, was referenced solely by the
`event-triggers.mdx` stub this PR replaces.

## Note on the history

Rebuilt from `master` after #49011, #49015, and #49016 merged. The
branch previously carried those 10 commits plus rebase churn against
them.

Rebasing naively would have reverted review feedback from #49016
(`70fa812`), which removed the benchmarks table and the "This guide"
opener from the performance guide. Those are deliberately not restored
here. The only changes to that file are two missing `await`s and a join
predicate that was a tautology while unqualified.

The three PRs stacked on this one (#49268, #49269, #49270) have been
rebased onto the new base.

## Manual testing

1. Open the [Row Level Security
guide](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/row-level-security)
on the preview. Three top-level sections appear in the table of
contents.
2. Select each link in the intro. All three jump to their section.
3. Open [Event
triggers](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/event-triggers).
The auto-enable section holds the full recipe instead of a link.
4. Open the [performance
guide](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/row-level-security-performance).
No benchmarks table, and the three bullets at the top link into the RLS
guide.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Reworked the Row Level Security guide with clearer guidance on grants,
policies, permissions, performance, testing, views, and secure
functions.
* Added a complete example for automatically enabling RLS on newly
created public tables.
* Improved SQL examples and clarified table references in RLS
performance guidance.
* Corrected grammar in the Grafana chart troubleshooting documentation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants