Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Budget and missing-table failures bypass the stable error taxonomy, and the live SQL generation boundary needs correction.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 4
Open (5)
Use native_safer_sequence for synthesized policy replay · New Normalize derived deadline expiry as statement budget exceeded · New Map PostgreSQL lock and missing-table errors to stable outcomes · New Generate policy SQL from admitted catalog model · New Add end-to-end coverage for qualified external helper resolution · New
What changed in this PR
Adds an atomic Go executor for applying complete row-level security definitions to existing tables.
Changes:
- Adds bounded, transactional RLS replacement and convergence verification.
- Adds statement qualification, scratch introspection, reports, and outcome codes.
- Updates tests, capability metadata, safety contracts, and documentation.
| File | Description |
|---|---|
SAFETY.md |
Extends the trusted-core model for RLS execution. |
README.md |
Documents Go API support. |
.agents/checks/review.md |
Updates review guidance for RLS execution. |
pkg/statement/row_security_execution.go |
Generates qualified RLS statements. |
pkg/statement/row_security_execution_test.go |
Tests RLS statement qualification. |
pkg/statement/desired_rls.go |
Expands the declaration type’s execution scope. |
pkg/schemadiff/row_security_roundtrip.go |
Adds transactional desired-state inspection. |
pkg/schemadiff/desired.go |
Refactors scratch inspection around caller transactions. |
pkg/executor/row_security.go |
Implements atomic RLS execution. |
pkg/executor/row_security_test.go |
Tests input validation. |
pkg/executor/row_security_integration_test.go |
Covers execution, rollback, locking, and convergence. |
pkg/executor/code.go |
Adds an uncertain RLS commit outcome code. |
pkg/executor/code_test.go |
Tests outcome-code classification. |
pkg/capabilities/capabilities.yaml |
Records Go API RLS support. |
pkg/capabilities/capabilities_test.go |
Updates capability validation expectations. |
docs/tcb-model.md |
Documents the RLS declaration proof boundary. |
docs/limitations.md |
Narrows remaining RLS limitations. |
docs/invariants.md |
Defines atomic RLS invariants. |
docs/execution-model.md |
Documents the new outcome code. |
docs/declarative-row-security.md |
Updates the RLS workflow and roadmap. |
docs/capabilities.md |
Regenerates the support matrix. |
docs/atomic-row-security.md |
Documents the new API and execution contract. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Armand Parajon <armand@squareup.com>
|
🤖 Review findings - created by Kiran's code review agent - for pg-sprite/pull/123, 5761822. Verdict: 4 findings — 1 blocking (refusals mis-typed as retryable), 2 non-blocking, 1 suggestion. BlockingEvery RLS refusal escapes as an unmapped sibling-package sentinel, so Non-blockingThe
General suggestionsFive new error returns propagate bare errors against the repo's mandated wrapping style. The one thing that could have broken, verifiedThe convergence gate could have been outside the lock or the transaction, letting a concurrent writer's policy change land unnoticed. It is not: Verified correct
This review was generated by Claude Code (claude-opus-5). |
Signed-off-by: Armand Parajon <armand@squareup.com>
|
🤖 Addressed the review findings in 1803dba.
Focused PostgreSQL tests, unit/safety checks, lint, and the pre-push race tests pass. CI is running on the new commit. The PR remains ready for review. Generated with Codex (GPT-6) |
|
🤖 Review findings - created by Kiran's code review agent - for pg-sprite/pull/123, 1803dba. Verdict: 3 findings — 1 blocking (untested under-lock recheck), 2 non-blocking. BlockingThe new under-lock ownership recheck has no test — delete it and the suite still passes. Non-blockingThe doc promises permanent The pre-lock gate covers table ownership only; the scratch-schema CREATE privilege is still discovered after ACCESS EXCLUSIVE is held. The one thing that could have broken, verifiedWhether the under-lock recheck is real protection or dead code: Verified correct
This review was generated by Claude Code (claude-opus-5). |
Signed-off-by: Armand Parajon <armand@squareup.com>
|
🤖 Addressed all three follow-up findings in 64d16a9.
The focused PostgreSQL suite, unit/safety checks, lint, and pre-push race tests pass. CI is running on the new commit; the PR remains ready for review. Generated with Codex (GPT-6) |


Why
pg-sprite can compare row-level security (RLS) definitions, but cannot yet apply them declaratively. Policy replacement needs one transaction so applications never see an intermediate access rule.
What
Add
executor.ExecuteRowSecurityfor complete RLS declarations on existing supported tables. This is a Go API; it adds no CLI flags or fingerprint convention.How
The executor supports ENABLE/DISABLE, FORCE/NO FORCE, policies, and policy comments. A converged retry does no live DDL. Scratch inspection uses the same connection. Live policy SQL comes from the inspected catalog through the shared renderer.
Risk
This changes access rules and briefly blocks readers and writers with an exclusive table lock. Both lock waits and the whole attempt are bounded. Missing tables, unsupported table shapes, and mixed table/policy changes are refused. Unsupported declarations, table shapes, and insufficient privileges return a permanent refusal. Owner and scratch-schema privileges are checked before and after locking. An uncertain commit response requires catalog inspection before retrying.
Grants, role membership, helper bodies, and authentication remain outside this operation. A changed definition replaces the complete policy set, including unchanged policies.
Testing
No manual testing. Regression coverage includes real DDL fault injection, deadline rollback, lock contention, concurrent policy changes, non-owner default deny, quoted names, helper resolution despite shadowed built-ins, stable error codes, unsupported-table refusals, ownership changes during lock waits, scratch privileges, missing policy dependencies, and single-connection execution.
Bigger picture
Follows #119 and replaces the approach explored in closed #122. Orchestrators retain their existing replan and consent workflow. CLI execution and Supabase application-level validation are follow-ups.
Generated with Codex (GPT-6)