← Model losses

Head-to-head comparison

openai / gpt-6-luna / low / low effort preferred over deepseek / deepseek-flash / none / unknown effort · clear win.

Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.

Reviewed public evidence

Task goal

Assess a safe, backward-compatible rollout and rollback for the current [REDACTED: private project name] tenant schema represented by these migrations and SQL tests. Treat the schema as already deployed with existing tenant data while API services and workers may run mixed versions during rollout. Ground every claim in the supplied files and cite the relevant definitions or assertions. Identify concrete ordering, compatibility, lock/backfill, integrity, tenant-isolation, and rollback risks; separate proven behavior from assumptions about application code not included here. Give a phased expand/migrate/verify/contract plan, explicit rollback boundaries after writes, and measurable pre/post-deployment checks using the existing test contracts. Do not invent application APIs, claim tests were run, or edit code.

openai / gpt-6-luna / low / low effort answer

## Conclusion

Do not treat this schema as safe for a mixed-version rollout or rollback without first resolving migration compatibility and testing against the deployed database. The supplied migrations define tenant-scoped tables, membership-based RLS and later authenticated-role hardening, but they do not provide a data backfill, an online migration strategy, or evidence about how API services and workers read or write these tables. This assessment is limited to the supplied snapshot.

## Evidence and risks

- **Tenant integrity is not enforced across relationships.** `app.survey` stores both `tenant_id` and `asset_id`, but its foreign key checks only `asset_id` against `app.asset(id)`; `app.observation` similarly checks `survey_id` without ensuring the referenced survey has the same tenant (`00003`, lines 27–30, 44–48). A mismatched tenant/reference pair is therefore not ruled out by these definitions. The RLS policies check membership against the row’s `tenant_id`, not the referenced parent’s tenant (`00008`, lines 36–46). Whether application code prevents mismatched writes is unknown.
- **RLS changes can affect mixed-version access.** The policy helper grants members select and all modifications when `app.is_member(tenant_id)` is true (`00008`, lines 21–46). It is applied to a fixed list of tables, including tables not defined in the supplied core migration (`00008`, lines 51–66); it is not shown as an automatic policy for future tables. The migration also enables RLS on every app base table present when it runs (`00008`, lines 5–18), so the resulting coverage depends on migration ordering and which tables exist at that point. `tenant_member` has only a self-read policy in this migration (`00008`, lines 86–91); membership writes and the service roles’ effective privileges are not established here.
- **Hardening may break existing clients.** `00015` revokes authenticated access to all app tables, sequences, and functions, then grants authenticated only select on five `public.api_*` views (`00015`, lines 3–22). That is not shown as backward-compatible with clients that directly access `app` objects. The packet does not show view definitions, grants to service/worker roles, or whether older versions use those views.
- **Migration order and availability need verification.** `00002` sets the database-wide search path (`00002`, lines 8–9). `00003` creates tables with `IF NOT EXISTS`, but this does not demonstrate that an already-present table has the expected shape (`00003`, lines 6–20, 27–38, 44–56). `00008` applies policies to named tables that must exist, and `00015` grants on named views that must exist. The packet gives no transactional or deployment-order evidence for these migrations beyond `00015`’s explicit transaction (`00015`, lines 1–24). No lock duration, table size, backfill, or operational timing is specified; a safe lock/backfill profile cannot be inferred.
- **Rollback is asymmetric after writes.** No down migrations are supplied. Reversing `00015` by restoring broad grants could re-expose direct table access; reversing RLS or changing policies could expose tenant data. Removing or changing tenant constraints/columns could strand or misattribute writes. These are risks, not demonstrated outcomes: exact rollback behavior depends on the deployed schema and application writes, neither of which is fully supplied.
- **Test contracts have important limits.** `test-rls.sql` explicitly says SQL Editor/service-role checks cannot truly impersonate users and directs production verification via app login (`test-rls.sql`, lines 108–115, 170–185, 273–285). Its cross-tenant section describes expected visibility but its query is run as service role, which can see both tenants (`test-rls.sql`, lines 218–231). The integration test’s outsider smoke check uses `set role postgres` and a JWT claim (`test-integration.sql`, lines 54–64); that is not, by itself, proof of behavior under the actual API/worker roles. The integration script also expects Directus writes and policies including `app.is_directus()` (`test-integration.sql`, lines 160–199, 377–390), while the supplied `00008` policies use only `app.is_member()` (`00008`, lines 36–46). This is a concrete mismatch between the supplied policy definition and stated test expectation; later migrations or role-specific policy definitions are outside the packet.

## Phased rollout and rollback boundaries

1. **Preflight:** On a production-equivalent snapshot, record migration versions, table/view definitions, row counts by tenant, constraints, indexes, RLS flags and policies, grants, and active client versions/roles. Reconcile the Directus policy expectation with the deployed policy catalog before proceeding.
2. **Expand:** Apply only additive, backward-compatible schema changes first. Confirm old services and workers still operate with their existing grants and query assumptions. The supplied migrations do not identify a specific additive change or demonstrate this compatibility, so this is a rollout requirement rather than a claim that these files implement it.
3. **Migrate:** If data transformation is needed, perform a resumable, bounded backfill with tenant-aware validation and observe lock waits, duration, errors, and replication/queue lag. No backfill is defined in the packet; do not assume one is unnecessary.
4. **Verify:** Run the measurable checks below using real authenticated member, outsider, cross-tenant, Directus, and worker credentials. Do not count service-role visibility as an RLS pass.
5. **Contract:** Only after old versions are drained and dependent writes/reads are proven absent should permissions, old columns, or compatibility paths be removed. The `00015` authenticated revocation is a contract-like boundary for clients that directly access `app` tables; verify all such clients have moved before applying it.
6. **Rollback:** Before any transformed or new-format writes, rollback may be feasible by stopping rollout and retaining the expanded schema. After new writes/backfill begin, first stop or fence writers, reconcile data, and preserve the expanded schema; do not blindly reverse DDL or restore broad grants. Once old columns/contracts are removed or `00015` has revoked access relied on by old clients, rollback requires a coordinated application/permission plan and validated recovery—not just rerunning prior migration SQL.

## Measurable checks

Capture a baseline and compare post-deployment:

- **Schema/security:** Compare `pg_tables.rowsecurity` for `asset`, `survey`, and `observation` with the `true` contract (`test-rls.sql`, lines 116–122); enumerate policies and confirm expected select/modification policies (`test-rls.sql`, lines 124–131). Separately verify actual role grants and the Directus `is_directus()` expectation in the catalog (`test-integration.sql`, lines 347–390).
- **Tenant isolation:** With real JWT-backed sessions, member sees its tenant’s seeded assets; outsider sees zero rows for that tenant; a user belonging only to another tenant sees only that tenant’s data. These are the stated expectations in `test-rls.sql`, lines 140–153, 156–185, 218–231, and `test-integration.sql`, lines 54–64, 329–341. Record counts and tenant IDs before and after.
- **Referential integrity:** Check for surveys whose `tenant_id` differs from their asset’s tenant and observations whose `tenant_id` differs from their survey’s tenant. The supplied schema does not prevent these mismatches (`00003`, lines 27–30, 44–48); require zero mismatches before and after any migration that relies on tenant-consistent relationships.
- **Functional compatibility:** Preserve integration-test thresholds: at least 3 assets, 2 queued/parsed manifests, 2 parse jobs, 6 surveys across at least 3 assets, 15 observations, and 3 deltas with at least 1 deteriorating and 1 severe (`test-integration.sql`, lines 75–78, 95–120, 125–150). Check Directus unit-cost/LOS/AMP/unmatched operations and expected values (`test-integration.sql`, lines 160–199, 201–219, 221–248, 250–287), but execute with the actual intended Directus role.
- **Views and permissions:** Member view queries should return data and outsider queries zero as specified (`test-integration.sql`, lines 310–341). Confirm authenticated can select the five granted `public.api_*` views and that no required old client still needs revoked `app` access (`00015`, lines 15–22).

## Alternatives, caveats, next action

A single maintenance-window cutover could avoid mixed-version overlap, but the evidence does not establish that it is necessary or sufficient; it still requires validated backups, role grants, and RLS checks. Nor does the packet prove that a particular backfill, lock, or production failure will occur. Application APIs, worker SQL, deployed migration history, later policy migrations, view definitions, and live privileges are dependencies outside the supplied evidence.

**Next action:** Before scheduling rollout, reconcile the Directus policy mismatch and produce a production-equivalent inventory of deployed schema, grants, policies, and client query patterns; then exercise the phased checks against that inventory.

deepseek / deepseek-flash / none / unknown effort answer

## Evidence packet

### 1. Conclusion and recommendation

The snapshot is a **tenant-isolation-first schema with a working expand-friendly core**, but it is **not safe to roll out as a single idempotent migration set during mixed-version operation without staging**. The strongest, provable risks are: (a) `00002` mutates a **database-wide GUC** (`search_path`) the moment it runs; (b) `00008` enables RLS and installs policies via a `do $$` loop over **all** `app` base tables, then immediately references tables (`app.asset_delta`, `app.manifest`, `app.job`, `app.unmatched`, `app.unit_cost`, `app.los_target`, `app.amp_sections`, `app.amp_versions`, `app.kpi_card_defs`, `app.saved_views_meta`, `app.semantic_registry`, `app.doc_index`) and views (`public.api_*`) and roles (`directus`, `app.is_directus()`) that are **not defined anywhere in this packet**; (c) `00015` revokes broad privileges on **all** tables/sequences/functions in `app` from `authenticated` and grants only five `public.api_*` views. Any of these can break old service code during mixed-version rollout. The recommended shape is a **staged expand → migrate/ship-compatible → verify → contract**, with the migration files treated as already-applied baseline and new work delivered as *additive* migrations only.

### 2. Proven behavior (grounded in the supplied files)

- **Tenant model**: `app.tenant` has `id` UUID PK default `gen_random_uuid()`, `slug` unique not null (`00002:12–18`); `app.tenant_member` PK `(tenant_id, user_id)`, cascades on tenant delete, role constrained to `('admin','manager','viewer')` (`00002:24–30`).
- **Membership helper**: `app.is_member(_tenant uuid)` returns boolean, `stable security definer`, checks `tenant_member` for `auth.uid()` (`00002:36–47`). Security-definer nature is important: it can read `tenant_member` regardless of caller RLS, so it is the linchpin of every policy.
- **RLS enablement is dynamic**: `00008:6–18` loops `information_schema.tables` where `table_schema='app' and table_type='BASE TABLE'` and runs `alter table … enable row level security`. This means **any table added later in `app` is NOT automatically RLS-enabled** unless it could be seen at the time `00008` ran or a similar loop reruns. That is a real backward-compat hazard when old code and new code coexist.
- **Policy generation is helper-based and explicit-list**: `app.apply_member_policies(tbl_name)` drops/creates `r_<t>_select` (SELECT, `using app.is_member(tenant_id)`) and `r_<t>_mod` (ALL, `using`+`with check app.is_member(tenant_id)`) (`00008:21–47`). It is called for a fixed list of 15 tables (`00008:52–66`). Tables **not** in the list have RLS enabled by the loop but **no policy**, i.e. default-deny for non-superusers. That is a silent functional break for any table existing at `00008` time but omitted from lines 52–66.
- **Audit path is special-cased**: `audit_event` gets SELECT (`user_id = auth.uid() or app.is_member(tenant_id)`) and INSERT (`with check user_id = auth.uid()`) (`00008:69–77`). **No UPDATE/DELETE policy** exists for `audit_event` → once RLS is on, updates/deletes from `authenticated` are denied (default-deny). Correct for audit immutability, but old code that “fixes” an audit row will fail.
- **`tenant` and `tenant_member` are read-limited**: only SELECT policies (`tenant_select` `app.is_member(id)`, `tenant_member_select` `user_id = auth.uid()`) (`00008:80–91`). No INSERT/UPDATE/DELETE policy on either → tenant onboarding/membership edits via `authenticated` will be **denied** post-RLS. This is a likely real regression for admin flows.
- **Privilege hardening is global and one-shot**: `00015` is wrapped in `begin; … commit;` (`00015:1,24`), revokes `all` on `schema app` from `authenticated` then `grant usage` (`00015:4–5`), revokes all on **all tables, sequences, functions** in `app` (`00015:7–9`), sets default privileges to revoke (`00015:11–13`), and grants SELECT only on five `public.api_*` views (`00015:16–22`).
- **Test contract exists and is explicit**: `test-rls.sql` defines the operational PASS checks — RLS enabled on `asset/survey/observation` (`test-rls.sql:117–122`), policies `r_<table>_select`/`r_<table>_mod` exist (`test-rls.sql:125–131`), non-member sees 0 (`test-rls.sql:163–168`), cross-tenant isolation with two tenants (`test-rls.sql:188–231`), views respect RLS (`test-rls.sql:238–239`). `test-integration.sql` defines role checks (`directus` must be `rolsuper=false, rolbypassrls=false`, B5.1 lines 349–359), core-table denial (B5.2 lines 361–375), and a **literal expectation that policies include `app.is_directus()`** (B5.3 lines 379–390).

### 3. Concrete risks

**Ordering / dependency risks**
- `00008` depends on the `app` schema and on tables beyond `00002`/`00003` (it references `audit_event`, `asset_delta`, `manifest`, `job`, `unmatched`, `unit_cost`, `los_target`, `amp_sections`, `amp_versions`, `kpi_card_defs`, `saved_views_meta`, `semantic_registry`, `doc_index` at lines 55–66, 69). Those are **not in the packet**. If any listed table is absent when `00008` runs, `app.apply_member_policies('<missing>')` raises `relation does not exist` and, because the calls are plain `select` statements outside an explicit transaction in the file text shown, earlier statements may already have committed. **Consequence**: partial RLS state — some tables RLS-on with policies, later ones not yet enabled. Confidence: high (logic) / medium (actual ordering, since intermediate migrations 00004–00014 are not supplied).
- `00015` grants SELECT on `public.api_asset_geojson`, `api_top_deteriorating`, `api_new_severe`, `api_repeat_om`, `api_coverage_health` (`00015:16–22`). Those views are **not defined in the packet**. If they do not exist at `00015` time, the whole `begin;…commit;` rolls back → the hardening does **not** apply, and `authenticated` retains broad grants. Confidence: high that this is a hard-fail-or-noop branch; medium on which branch actually occurs (views presumably created in an earlier not-supplied migration; the API view names in the integration checks (`public.api_*`) suggest they exist).
- `00002:9` `alter database postgres set search_path = app, public, extensions;` is a **cluster-adjacent, database-scoped** change that affects new sessions. During mixed-version rollout, any code relying on `public`-only resolution or on unqualified names now resolves `app` first. This is a prime candidate for “worked in dev, broke in prod.” Confidence: high that the setting is applied; not proven here whether app code depends on it.

**Mixed-version compatibility risks**
- Old API nodes expecting to read/write `app.*` directly as `authenticated` will be **revoked** by `00015:7–9`. Only `public.api_*` SELECTs remain (`00015:16–22`). No INSERT/UPDATE/DELETE grant to `authenticated` exists after `00015`. So if any live code path writes via the `authenticated` role to `app` tables, it breaks at hardening time. Confidence: high from the grants; impact depends on app code not in packet.
- RLS is enabled per-table by a loop snapshot at `00008` time. Tables created *after* that migration (plausibly anything in 00004–00014 or newer) rely on their own migration enabling RLS. If a recent table exists without RLS, mixing new code with old DB or vice-versa can **expose rows across tenants**. This is the single highest-severity hypothesis; it is **not provable** because the intermediate migrations aren’t in the packet. Flag as dependency.
- `is_member` is `security definer` but has **no explicit `set search_path`** in its definition (`00002:36–47`). Under a changed DB `search_path` (`00002:9`) a security-definer function without a pinned `search_path` is a classic privilege-escalation/instability surface. Confidence: medium-high as a hardening gap; actual exploitability requires objects in `app` (or `extensions`/`public`) that a low-privilege role can manipulate — not established here.
- Role-specific denial: `directus` role is assumed by tests (`test-integration.sql:163,203,223,264`) and expected to see `is_directus()` policies (line 388), but **no `is_directus()` function and no directus-specific policies appear in `00008`**. `00008` only creates member policies. So either (a) directus policies live in a not-supplied migration, or (b) the integration test’s B5.3 expectation cannot currently be met. Either way this is a **compatibility gap to verify before relying on Directus during rollout**. Confidence: high that the packet lacks them; the tests explicitly expect them.

**Lock / backfill risks**
- No DDL here rewrites large tables (`00002`/`00003` are creates; `00008` enables RLS; `00015` changes grants). `enable row level security` takes a brief `ACCESS EXCLUSIVE` lock but is metadata-only and fast; `revoke/grant` is also fast metadata. So lock risk is **low** for these exact statements. Confidence: high.
- Backfill risk is **unspecified**: nothing in the packet computes `asset_delta`, `coverage`, etc. `app.compute_deltas()` is invoked as a bare `select` in the test plan (`test-integration.sql:140`), implying a function exists outside the packet. During rollout, concurrent `compute_deltas()` runs across mixed workers could race on `asset_delta`. This is plausible but **unproven** here.
- `test-integration.sql:169` uses `on conflict (tenant_id, method, diameter_in)` for `app.unit_cost`; this asserts a unique constraint exists on those columns. Not shown in `00002`/`00003`, so the constraint is defined elsewhere. Same for `los_target(tenant_id, metric)` (`:209`) and `amp_sections(tenant_id, section_key)` (`:232`). Fold into dependency list.

**Integrity / tenant-isolation risks**
- `app.tenant_member.user_id` has **no FK to `auth.users`** (`00002:26`, comment says “references auth.users(id)” but no constraint). This is intentional (referencing an external schema) but means orphan memberships are possible; `is_member` would then authorize a user ID that no longer exists. Low direct isolation risk (UUID collision effectively impossible) but data-integrity gap. Confidence: high, from the absence of constraint.
- `asset_delta`, `manifest`, `job`, `unmatched`, `unit_cost`, `los_target`, `amp_*`, `kpi_card_defs`, `saved_views_meta`, `semantic_registry`, `doc_index` are all assumed to have a `tenant_id` because `apply_member_policies` builds `using (app.is_member(tenant_id))` (`00008:38,44`). If any of those tables lacks a `tenant_id` column, the policy creation **fails at DDL time** → cascade of the ordering risk above. Confidence: high as a fail mode; the column’s presence is not proven in the packet.
- Cross-tenant leak via `public.api_*` views: `00015` grants **SELECT on the views** to `authenticated` (`00015:16–22`). If those views are `security definer` or owned by a role that bypasses RLS, they could leak across tenants regardless of base-table RLS. The test plan asserts views inherit RLS (`test-integration.sql:305–341`, `test-rls.sql:233–241`), but the view definitions are not in the packet, so **view security mode is unverified**. This is the most material isolation uncertainty. Confidence: high that it is unverified; consequence potentially severe.
- `audit_event` has no UPDATE/DELETE policy, consistent with tamper resistance, but any old code that “closes out” audit records will now silently affect 0 rows or error. Confidence: medium (behavioral).

**Rollback risks**
- `00015` is transactional (`begin;…commit;`), so that file alone is atomically reversible **if** a matching inverse migration is written. However, `00008` is **not** written as an explicit transaction and uses dynamic DDL in a loop; a partial failure leaves partial RLS. Rolling back RLS requires `alter table … disable row level security` plus `drop policy` for each — but disabling RLS on a table that is now the *only* isolation mechanism re-exposes tenant data instantly to any authenticated caller still holding SELECT (see `00015` grant asymmetry: after `00015`, `authenticated` has no direct `app` table grants, so disabling RLS without restoring grants doesn’t leak mid-flight — but if you roll back `00015` first, you restore nothing either, since `00015` only *revoked*; the pre-`00015` grants came from earlier defaults/YAML not in packet). **Key rollback boundary**: once `00015` commits, rolling back the schema without a written inverse leaves `authenticated` under-revoked or over-privileged unpredictably because the original grant baseline is not captured. Confidence: high.
- `00002:9` database-level `search_path` alteration is easy to revert (`alter database postgres reset search_path`) but affects all sessions immediately; a mid-flight revert changes name resolution for running app versions.
- Data writes during rollout: any writes to `app.*` by new code between `00008` and a rollback must be preserved. Because `00008` adds no columns, no data migration is needed for these three files — that is favorable. But writes to any table whose RLS was enabled without a policy would be *rejected*, not lost, so a rollback must also account for failed-write retries. Confidence: medium.

### 4. Measurable pre/post-deployment checks (using the existing test contracts)

Pre-deploy (baseline snapshot, read-only):
- Record `select tablename, rowsecurity from pg_tables where schemaname='app'` — expect `true` for `asset/survey/observation` per `test-rls.sql:117–122`; enumerate **all** `app` tables and flag any with `rowsecurity=false` (fills the `00008` loop gap concern).
- Record `select tablename, policyname, cmd from pg_policies where schemaname='app'` — expect `r_<t>_select` + `r_<t>_mod` for the 15 listed tables (`test-rls.sql:125–131`, `00008:52–66`); flag listed tables with no policy and unlisted tables with RLS but no policy.
- Confirm existence of the tables/policies the tests assume but the packet omits: `app.asset_delta`, `manifest`, `job`, `unmatched`, `unit_cost`, `los_target`, `amp_sections`, `amp_versions`, `audit_event`, `app.is_directus()`, `app.compute_deltas()`, the unique constraints at `test-integration.sql:169,209,232`, and the six `public.api_*` views in `00015:16–22`. Any absence invalidates parts of the test contract.
- Record `select rolname, rolsuper, rolbypassrls, rolcanlogin from pg_roles where rolname='directus'` expecting `false/false/true` (`test-integration.sql:349–359`).
- Capture `select current_setting('search_path')` and the DB-level setting for `postgres` to detect pre-existing drift from `00002:9`.

Post-deploy (must-pass gates):
- Outsider/non-member sees 0: replicate `test-integration.sql:54–64` (set jwt sub for outsider, count `app.asset` = 0) and `test-rls.sql:163–166` membership_count = 0.
- Cross-tenant: create second tenant, add non-member there, assert each user sees only their tenant’s assets (`test-rls.sql:188–231`).
- Views inherit RLS: member sees >0, outsider sees 0 across the eight views in `test-integration.sql:316–323` and `test-rls.sql:238–239`.
- Back-office RLS includes `is_directus()`: run the query at `test-integration.sql:379–386` and require the qual to contain `app.is_directus()`. If it does not, B5.3 is red — this is a likely failure given the function is absent from `00008`.
- Directus cannot touch core data: `test-integration.sql:361–375` expects 0 rows from `asset/survey/observation/asset_delta` under `set role directus`.
- Privilege gate after `00015`: assert `authenticated` has no direct `app` table privileges except via view ownership, and SELECT on exactly the five `public.api_*` views (`00015:16–22`); assert `has_table_privilege('authenticated','app.asset','SELECT') = false`.
- Negative/grant test for the write paths used by old workers: identify every role the app uses (only `authenticated`, `directus`, and `service_role` are named/implied by the packet) and confirm the privilege needed. **Unknown roles → cannot gate; flag.**
- Audit immutability: confirm `authenticated` cannot UPDATE/DELETE `audit_event` (no matching policy, `00008:69–77`) and the insert path enforces `user_id = auth.uid()`.

Metric thresholds (derived, not invented APIs): all RLS coverage = 100% of `app` base tables (`rowsecurity=true`), 0 tables with RLS and no policy, cross-tenant probe returns 0 rows for non-member on every generated test view and each core table listed in `00008:52–66`.

### 5. Phased expand / migrate / verify / contract plan

- **Phase 0 — Inventory (read-only).** Resolve the dependency list from §4 pre-deploy. Output: a matrix of tables, RLS flag, policy set, tenant_id presence, unique constraints, and grants. Gate: no listed table missing `tenant_id`; every table in the `00008:52–66` list exists.
- **Phase 1 — Expand (additive only).** Do **not** re-run `00002`/`00008`/`00015` as-is. Instead:
  - Additive migration to freeze `search_path` on `app.is_member` and any other security-definer helper (`set search_path = app, pg_temp` form; not present in `00002:36–47`, so this is a gap-closure, not a change to shown behavior).
  - Additive migration to **coverage-complete** RLS: a loop that enables RLS on every `app` base table **and** generates a policy for private tables not in the current list, plus explicit `is_directus()` policies if Directus is in scope (`test-integration.sql:388`). This replaces the fragile snapshot behavior of `00008:6–18` with a repeatable invariant, so old/new versions converge.
  - No columns added in these three files → no data backfill strictly needed for the shown schema. Any backfill belongs to the not-supplied delta/compute path.
- **Phase 2 — Migrate (compatible writes).** Keep base-table access **unchanged** during the transition: do not apply `00015`’s global revoke until read paths are cut over to `public.api_*`. If `00015` must run early, expand first by granting the minimum needed so old writers keep working, then contract later.
- **Phase 3 — Verify.** Run the §4 post-deploy gates in a transaction-scoped impersonation harness matching the tests (`set role postgres; set request.jwt.claim.sub = …`, `test-integration.sql:55–56,312–313`). All gates must be green; specifically the `is_directus()` qual check and the view-RLS counts.
- **Phase 4 — Contract.** Only after all readers/writers use `public.api_*` (or another granted path): apply `00015` (`00015:7–9` revoke + `00015:16–22` grant). Assert the privilege gate. This is the **first irreversible-after-writes boundary** — capture the exact pre-state grants first, because `00015` only revokes and the baseline grant set is not recorded in the packet.

### 6. Explicit rollback boundaries after writes

- **Boundary A (before `00015` commits):** reversible by dropping the new RLS/policies added in Phase 1. Data unaffected (no schema columns). Safe.
- **Boundary B (after `00015` commits, before app cutover):** rollback requires a written inverse that **re-grants** the exact pre-`00015` privileges. Those are not derivable from the packet — without a captured baseline, rollback is unspecified. **Do not cross this boundary without a captured grant inventory.**
- **Boundary C (after new-version writes via views):** rollback must preserve inserts made through `public.api_*` and/or `authenticated`-gated paths. Because `00015` leaves no direct DML grant, confirm which role actually writes before planning; this is an open dependency.
- **Boundary D (`00002:9` search_path):** independently revertible (`reset search_path`) but affects all live sessions; treat as a separate, explicitly-announced step, not part of a bulk migration rollback.

### 7. Alternatives, discarded hypotheses, likely false positives
- *Discarded:* “These migrations rewrite big tables and will lock `app.asset`.” No `alter table … add column`/`type change`/`set not null` appears; the only table DDL is `enable row level security` (`00008:16`). Low lock risk.
- *Alternative reading of `00008` loop:* it may intentionally capture only the tables that exist at that point, with later tables handled by their own migrations. If so, the coverage gap is not a bug but a convention. This can only be decided from the missing 00004–00014 files — treated as a hypothesis, not a proven defect.
- *Likely false positive:* “`is_member` is exploitable via search_path.” `security definer` is declared (`00002:40`), but without a pinned `search_path` (`00002:36–47`) the risk is real in principle and unproven in practice; do not claim an exploit.
- *Not a conflict:* the tests assume `is_directus()` and directus policies; their absence from `00008` is most likely “defined in a file outside this packet,” not “the schema contradicts its tests.”

### 8. Missing evidence / dependencies and consequences
- Migrations 00004–00014 (absent): determine real table set, `is_directus()`, `compute_deltas()`, the `public.api_*` view definitions, and unique constraints used at `test-integration.sql:169,209,232`. Without them, RLS coverage, view security mode, and privilege baseline cannot be confirmed.
- `public.api_*` view security mode (invoker vs definer/owner): decides whether the `00015` grants leak across tenants. Highest-consequence unknown.
- Actual role set used by live app/workers (only `authenticated`, `directus`, `service_role` appear/imply): determines which `00015` revokes break real traffic.
- Application code (explicitly not in scope): determines whether old versions depend on `search_path` ordering and direct `app` writes. All such claims here are marked as assumptions.

### 9. Next useful action
Produce the Phase-0 inventory query set from §4 against a **production-like read-only replica**, plus a `pg_dump --schema-only`-style extraction of `pg_policies` and `information_schema.role_table_grants` for `authenticated`/`directus`. That single snapshot resolves the top three uncertainties (RLS coverage gaps, view security mode, and the pre-`00015` grant baseline) and converts Boundaries B/C from “unspecified” to “reversible.”

Primary judge's stated reason

A provides a more defensible deployment decision: actual-role isolation checks and relationship-consistency checks better address existing tenant data and mixed-version operation. The preference is clear because B's verification plan can provide incomplete assurance on a central release gate, not because of presentation or additional optional detail.

This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.

Battle wave: d1711a3f-9f3b-4640-a160-e32f42e27c5f. Pair: brp1_e2440f552ee29a451c602385d3568fba3d81150cee7cab8a5519d4059195b51d. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.