You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 25, 2026. It is now read-only.
Repository navigation
Commit 51ce667
Browse filesBrowse the repository at this point in the historyBrowse files
The spec claimed external tables verify-suppress RLS drift; the framework
disposition under external suppresses only extras and value drift, and
declared-shape incompatibilities fail (same as external column drift).
The code follows the framework; the spec follows the code. An external
table that genuinely runs RLS declares @@rls as part of its shape.
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Copy file name to clipboardExpand all lines: projects/postgres-rls/slices/explicit-rls-control/spec.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ namespace public {
34
34
-**Diff:** table `isEqualTo` compares `rlsEnabled` — the first table-attribute comparison (today it is identity-only, `postgres-table-schema-node.ts:95-97`). A `not-equal` table issue plans `EnableRowLevelSecurityCall` (expected `true`) or a **new `DisableRowLevelSecurityCall`** (expected `false`). Disable is classed destructive — it opens row access, so it requires the destructive allowance like `dropRlsPolicy`; enable stays additive.
35
35
-**The imperative path dies:**`planPostgresSchemaDiff`'s enable-on-first-new-policy (`seenEnableTables`, `planner.ts:348-367`) is deleted. This fixes today's gap where a table with in-sync policies but RLS off is never re-enabled (project DoD: "policies declared with RLS off → `ENABLE`").
36
36
-**Fail-closed semantics fall out of the model:** removing the last policy on a marked table changes nothing about enablement (expected `true`, actual `true` → no issue; deny-all). `DISABLE` plans only when the marker is removed. No special cases.
37
-
-**Verify:** enablement drift is a table `not-equal` issue → `declaredIncompatible` (`schema-verify.ts:101-121` fallthrough), graded per the table's control policy by the existing disposition — managed fails, externalsuppresses. No verify plumbing changes.
37
+
-**Verify:** enablement drift is a table `not-equal` issue → `declaredIncompatible` (`schema-verify.ts:101-121` fallthrough), graded per the table's control policy by the existing disposition. **Amended during W5 (spec was wrong, code follows the framework):** under `external` the documented disposition suppresses only extras and value drift; declared-shape incompatibilities fail — the same verdict external *column* drift gets. So external enablement drift and a declared-missing policy fail verify (the plan side still never touches an external table). An external table that genuinely runs RLS declares `@@rls` — the marker is part of its declared shape. No verify plumbing changes.
The machinery already exists (`@@control` → `StorageTable.control`; `partitionCallsByControlPolicy` on the RLS call list, `planner.ts:278-287`; per-issue resolution in verify). This slice proves and completes the RLS behaviors: on an **external** table no enable/disable/create/drop/rename op is ever emitted and verify suppresses RLS drift; on a **managed** table the contract owns the full policy set and the enablement bit (extras dropped under the destructive allowance, drift fails verify). The rename call resolves its control-policy subject via the owning table like create/drop.
49
+
The machinery already exists (`@@control` → `StorageTable.control`; `partitionCallsByControlPolicy` on the RLS call list, `planner.ts:278-287`; per-issue resolution in verify). This slice proves and completes the RLS behaviors: on an **external** table no enable/disable/create/drop/rename op is ever emitted, and verify grades RLS drift exactly as it grades relational drift under `external` (extras suppressed; declared-shape incompatibilities fail — amended during W5, see D2); on a **managed** table the contract owns the full policy set and the enablement bit (extras dropped under the destructive allowance, drift fails verify). The rename call resolves its control-policy subject via the owning table like create/drop.
50
50
51
51
## Behaviour contract
52
52
@@ -76,7 +76,7 @@ New Postgres entity kind (`rls` marker) in namespace `entries` — serialized, r
76
76
77
77
-**Table with policies in sync but RLS off** re-enables under the attribute diff — today's imperative path misses it (`planner.ts:336-387`); pin it.
78
78
-**Multiple same-hash policies on one table** during rename pairing — deterministic sorted-name pairing, leftovers create/drop (D3).
79
-
-**External table with RLS enabled and no marker** — expected `false` vs actual `true` is a real issue, suppressed by disposition; must not plan a `DISABLE`.
79
+
-**External table with RLS enabled and no marker** — expected `false` vs actual `true` is a real issue; never plans a `DISABLE`, and per the amended D2 it fails verify like any external declared-shape drift — the fix is declaring `@@rls` on the external model.
80
80
-**Marker on a model with zero policies** is legal and plans `ENABLE` (deny-all is the point of fail-closed).
81
81
-**Existing example migration chains:** adding `@@rls` changes each example's current `contract.json` (new entity) but not historical migration snapshots; live DB state already has RLS on from slice-1 ops, so post-apply verify stays clean with no new migration. `fixtures:check` must be green after regen.
0 commit comments