Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

Commit 51ce667

Browse files
tml-2869: spec amendment — external verify grades RLS drift like relational drift
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]>
1 parent 011cfe1 commit 51ce667

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • projects/postgres-rls/slices/explicit-rls-control

‎projects/postgres-rls/slices/explicit-rls-control/spec.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace public {
3434
- **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.
3535
- **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`").
3636
- **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, external suppresses. 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.
3838

3939
### D3 — Policy rename plans as `ALTER POLICY … RENAME TO`
4040

@@ -46,7 +46,7 @@ namespace public {
4646

4747
### D4 — Managed/external grading, proven per op
4848

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 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.
5050

5151
## Behaviour contract
5252

@@ -76,7 +76,7 @@ New Postgres entity kind (`rls` marker) in namespace `entries` — serialized, r
7676

7777
- **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.
7878
- **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.
8080
- **Marker on a model with zero policies** is legal and plans `ENABLE` (deny-all is the point of fail-closed).
8181
- **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.
8282

0 commit comments

Comments
 (0)