← Model losses

Head-to-head comparison

openai / gpt-6-astra / high / high effort preferred over openai / gpt-6.1-sol / low / low effort · close 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-astra / high / high effort answer

## Conclusion

**Treat these files as deployed history, not a migration sequence to replay.** A backward-compatible rollout requires additive changes followed by verified application/worker compatibility before tightening access or constraints. The main risks are:

1. `00015` removes direct `authenticated` access that earlier policies and test instructions appear to expect.
2. The core foreign keys allow cross-tenant parent/child relationships.
3. Existing tests do not establish effective tenant isolation under production execution roles.
4. Safe rollback after new writes depends on preserving old-readable data and worker compatibility—not merely reversing DDL.

This was an independent, read-only assessment of the supplied snapshot. No tests were run.

**Citation shorthand:** `M02`, `M03`, `M08`, `M15` denote the four supplied migrations; `IT` denotes `supabase/test-integration.sql`; `RT` denotes `supabase/test-rls.sql`.

## 1. Evidence and concrete risks

### Deployment ordering and mixed-version compatibility

- **The supplied migrations have prerequisites beyond the tenant/core definitions.** `M08` applies policies to numerous additional tables, and `M15` grants access to five existing `public.api_*` views (`M08:51–66`; `M15:15–22`). Their definitions are outside this packet. Confirm their deployed existence, ownership and definitions before any dependent change. These files alone do not establish their compatibility or security.

- **`M15` is an access-contract change, not just additive hardening.** It revokes `authenticated` privileges on all existing `app` tables, sequences and functions, then grants SELECT on five public views (`M15:4–22`). With no other privilege path, old clients accessing `app.asset`, `app.survey`, functions or internal views will receive permission errors. RLS policies cannot supply missing SQL privileges. Whether actual services use those paths is unknown.

- **Mixed versions must agree on more than columns.** Membership roles are restricted to `admin`, `manager`, `viewer`; coverage, direction and grade have explicit checks (`M02:24–29`; `M03:33–35,49`). Changing accepted values or making currently nullable fields mandatory can break old writers. No application or job payload compatibility is demonstrated by the supplied SQL.

- **Database `search_path` is a connection-sensitive dependency.** `M02:9` changes the database default to `app, public, extensions`; existing sessions need not adopt a new default. New and old pooled connections can therefore resolve unqualified names differently during a change. Supplied SQL largely qualifies application objects, but application behavior is unknown.

- **Replay is unsafe.** `CREATE TABLE IF NOT EXISTS` does not reconcile an existing table’s structure. Index creation in `M02:52–53` is unguarded, and named policies in `M08:71–91` are not dropped before creation. The helper also replaces policies on every invocation (`M08:32–45`). Use new forward migrations based on catalog inspection, not rerunning historical files.

### Tenant isolation and integrity

**High-confidence schema gap:** the parent identifiers and tenant identifiers are independently constrained.

- Surveys reference `app.tenant(id)` and `app.asset(id)` separately.
- Observations reference `app.tenant(id)` and `app.survey(id)` separately.
- Neither relationship enforces equal tenant IDs (`M03:27–30,44–47`).

Consequently, a survey can carry tenant A while referencing tenant B’s asset, and an observation can carry tenant A while referencing tenant B’s survey. Standard policies check only the row’s own `tenant_id` (`M08:38–44`), not the parent’s tenant.

**Implications:** incorrect joins, derived data and cascading deletion across tenant boundaries are possible. Actual read leakage depends on the absent view/query definitions; it is not proven here. Foreign-key checks do not substitute for parent visibility checks under RLS.

Other important boundaries:

- **`viewer` is not read-only at the policy layer.** The role comment promises that distinction, but `is_member` checks membership alone, and the modification policy grants `FOR ALL` to any member (`M02:27,33,36–46`; `M08:42–45`). Actual write ability still depends on SQL grants. Removing hardening to restore compatibility could expose member-wide writes if grants are restored indiscriminately.
- **Users belonging to two tenants can satisfy both sides of a tenant-ID update.** The modification policy checks membership in the old and new row tenant, without making tenant ownership immutable (`M08:44`). Whether applications allow such updates is unknown.
- **Membership has no declared auth-user foreign key.** `user_id` is a UUID with a comment mentioning `auth.users`, not a reference constraint (`M02:24–29`). Stale memberships are therefore not excluded by the shown schema.
- **Delete cascades are material rollback boundaries.** Tenant deletion cascades into memberships and core rows; asset deletion cascades into surveys, and survey deletion into observations (`M02:25`; `M03:8,29–30,46–47`). Reversing schema changes cannot recover these deleted rows.
- **Replay deduplication is incomplete in the shown core schema.** Assets have `(tenant_id, asset_id)` uniqueness, but surveys and observations have only generated UUID primary keys for identity (`M03:7,20,28,45`). The test’s `ON CONFLICT DO NOTHING` does not prevent repeated logical survey or observation insertion with fresh IDs (`RT:82–102`). Worker retry idempotency remains an application uncertainty.

### RLS, grants and privileged helpers

- **RLS enablement is a snapshot, not an automatic rule for future tables.** The loop enables RLS on then-existing `app` base tables (`M08:5–18`). Future tables require explicit grants, RLS and policies.
- **Enabled RLS is not evidence of enforcement for every role.** No `FORCE ROW LEVEL SECURITY` appears in the supplied migration. PostgreSQL superusers and `BYPASSRLS` roles bypass RLS; owners ordinarily do too. Inventory actual ownership and execution roles before interpreting test results.
- **The policy installer is a privileged surface.** `app.apply_member_policies(text)` is `SECURITY DEFINER` and interpolates caller-provided text into dynamic SQL with `%s` (`M08:21–45`). If callable by an untrusted role, it can at least replace policies on caller-selected tables within the definer’s authority; unsafe interpolation further enlarges the risk. Actual exploitability depends on deployed ownership and effective EXECUTE privileges.
- **Revoking from `authenticated` does not revoke privileges inherited through `PUBLIC` or other roles.** This is especially important for security-definer functions (`M02:36–47`; `M08:21–47`; `M15:9,13`). Conversely, if the runtime has no other EXECUTE path, revoking `is_member` execution can break policy evaluation for callers relying on it.
- **Default privileges are creator-specific.** `M15:11–13` does not establish defaults for every future object owner and does not revoke `PUBLIC` grants. Verify both current effective privileges and defaults for each deployment role.
- **Public-view safety is unproven.** Granting SELECT on `public.api_*` views does not prove tenant filtering or read-only effective access (`M15:15–22`). View definitions, owner privileges, security options and existing inherited grants must be checked.

There is also a comment/implementation discrepancy in audit access: the comment says users read only their own events, while the policy permits their own **or any event in a tenant they belong to**. Its insert check requires only `user_id = auth.uid()`, not tenant membership (`M08:68–77`). Effective table grants determine whether those paths are reachable.

### Locks, transactions and backfills

- **No data backfill is defined in these migrations.** Any tenant repair or conversion is a new operational step, not an existing tested behavior.
- On populated tables, ordinary index creation and constraint changes can block work or scan substantial data. RLS and policy DDL also require relation locks. `M02:52–53` uses ordinary index creation; `M08:5–18` touches every current `app` base table. Use bounded lock waits, inspect blockers and stage changes on representative data.
- `M15` explicitly groups revocation and grants in one transaction (`M15:1–24`). Failure before commit rolls that transaction back; a long wait should not trigger a duplicate attempt.
- `M08` has no explicit file-wide transaction. Its effective atomicity depends on the migration runner. If statements are separately committed, execution can leave only part of the intended policy set installed (`M08:5–91`).

## 2. What the existing tests establish—and what they do not

These are mostly manual test plans and commented expectations, not self-enforcing assertions.

| Existing contract | Required interpretation |
|---|---|
| Member sees data; outsider sees zero (`IT:40–64`; `RT:134–185`) | `IT` switches to `postgres`; setting a JWT subject does not remove that role’s bypass/ownership privileges. Its `SET … = (SELECT …)` form also requires correction for normal PostgreSQL execution. Resolve IDs first and use a verified non-bypass role with supported claim configuration. |
| RLS enabled and policies present (`RT:116–131`) | Necessary catalog checks, but not proof of effective isolation, correct policy expressions or permitted runtime access. |
| Cross-tenant isolation (`RT:188–231`) | The SQL actually displays both tenants as a privileged role; isolation is described rather than exercised. Test both authenticated identities independently. |
| Views respect RLS (`IT:310–341`; `RT:234–241`) | Owner/bypass execution cannot prove this. The tested `app.v_*` views also differ from the `public.api_*` surface granted in `M15`. Test both where supported. |
| Directus permitted back-office access but blocked from core (`IT:160–287,347–390`) | Role creation/grants and `is_directus()` policy definitions are outside the packet. These are intended contracts, not proven deployed behavior. |
| Ingestion counts and computed deltas (`IT:75–150`) | Useful controlled-fixture acceptance thresholds, but existing tenant data can satisfy them before a rollout. Compare fixture-specific changes and outputs, not only whole-tenant totals. |

A scalar `count(*)` returning **0** is one result row containing zero—not “zero rows.” Distinguish successful filtering from permission errors. After hardening, denied direct base-table access may be intentional, but it does not prove RLS filtering.

**Do not run the scripts unchanged against existing production tenants.** They upsert memberships and business data, create surveys/observations, update costs and unmatched records, and offer tenant-wide cleanup (`RT:29–37,82–102,247–254`; `IT:165–171,183–187,271–275,426–432`). Use dedicated fixtures and ID-scoped cleanup; do not elevate an existing user or delete tenant-wide records to satisfy a test.

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

### Phase 0 — Establish the deployed baseline

1. Record schema definitions, owners, effective grants, default privileges, policies, RLS flags, view security properties and role bypass flags. Compare with the cited definitions rather than assuming migration history guarantees structure.
2. Identify the actual database roles and object paths used by every live API/worker version. Verify supported claim propagation and job retry behavior. These are deployment prerequisites because application code is not supplied.
3. Record per-tenant row counts, core integrity violations, job status distributions and representative derived results. Establish a recoverable backup/PITR point and demonstrate recovery in an isolated environment before data-changing work.
4. Run the corrected test contracts against dedicated fixtures using actual execution roles.

**Gate:** no unexplained catalog drift; identified compatibility matrix for all versions that will coexist; verified recovery procedure.

### Phase 1 — Expand

- Preserve existing column names, types and old-readable representations. Introduce any new representation additively, with nullable columns or compatible defaults as appropriate.
- If strengthening parent/tenant integrity, first create suitable unique parent keys such as `(tenant_id, id)`, then add composite foreign keys:
  - survey `(tenant_id, asset_id)` → asset `(tenant_id, id)`;
  - observation `(tenant_id, survey_id)` → survey `(tenant_id, id)`.
- On large tables, use concurrent index creation where applicable and attach suitable constraints in short bounded DDL steps. Concurrent index creation cannot run inside an ordinary transaction block.
- Add foreign keys `NOT VALID` before historical validation where appropriate. **They still check new writes and relevant updates**, so first prove all active writers satisfy them; old invalid rows can also make unrelated workflow updates fail.
- Add explicit security for new objects. Restrict the policy-management helper based on audited callers; retain only the runtime helper access actually required.

**Gate:** all still-live versions read and write successfully through their authorized paths; no unbounded lock wait; no increase in permission or integrity failures.

### Phase 2 — Migrate

- Repair cross-tenant relationships only after determining authoritative ownership. Do not blindly copy tenant IDs from parents: that can move data between security domains.
- Backfill in bounded, resumable batches using stable IDs, checkpoints and before-images or a repair ledger. Make writes conditional so they do not overwrite newer concurrent edits.
- Reconcile concurrent writes before final validation. If correctness cannot be maintained while old workers write, drain or pause the affected workflow.
- For any new data/job format, demonstrate old-reader compatibility or drain old consumers before enabling production writes. The SQL packet does not establish dual-write, job versioning or idempotency support.

**Gate:** migration coverage is complete, mismatch count is zero, every repair is accounted for, and reconciliation finds no continuing drift.

### Phase 3 — Verify and canary

Exercise both application versions and applicable worker versions against dedicated tenant fixtures. Check effective access, pipeline results and integrity during concurrent traffic.

**Gate:** all applicable existing test contracts pass through the real supported access surface; unauthorized visibility is zero; no integrity drift or rollout-induced error increase.

### Phase 4 — Contract

Only after old processes, pooled sessions and queued work are retired:

- validate added constraints;
- enforce stronger nullability or accepted-value restrictions;
- retire compatibility representations;
- complete intended access revocations.

If `M15` is already deployed, preserve its effective access boundary during rollback. If staging equivalent hardening elsewhere, apply it only after clients have proved compatibility with the five public views and their actual permissions (`M15:15–22`).

## 4. Explicit rollback boundaries

| Boundary | Safe rollback |
|---|---|
| Before migration commit or data writes | Abort the active transaction. For already-committed additive objects, retain them while reverting application deployment unless removal is independently safe. |
| After compatible new writes | Application rollback is safe only if old binaries can read, update and process all resulting rows/jobs. Prefer leaving additive schema in place. |
| After backfill or tenant repair | Use the repair ledger/before-images and reconcile subsequent writes. DDL reversal does not restore original values or ownership. |
| After new-only values or job formats | Drain, translate or otherwise make them old-compatible before restoring old consumers. Binary rollback alone is unsafe. |
| After privilege/policy changes | Restore only an audited compatible grant/policy set. Do not disable RLS or broadly regrant `ALL` as an availability fix. Exact prior privileges cannot be reconstructed from `M15` alone. |
| After dropping old representations | Old-version rollback requires reconstruction or restore plus reconciliation. This is a deliberate compatibility boundary. |
| After cascading deletion | Recover deleted data from retained evidence/backup and reconcile intervening writes. Recreating constraints or tables cannot undo deletion. |

A whole-database restore can discard unrelated tenant writes after the restore point. It is a recovery operation, not a transparent tenant-local rollback.

## 5. Measurable deployment checks

Run these before and after, with fixture-specific attribution and the same execution-role matrix:

- **Integrity:** zero survey/asset tenant mismatches and zero observation/survey tenant mismatches; zero orphaned parent references; count stale membership user IDs against `auth.users` for investigation. These checks derive from `M02:24–29` and `M03:27–30,44–47`.
- **Membership/isolation:** A has exactly one pilot membership, B has none; A sees its fixture, B sees zero pilot rows; repeat in the other direction with B’s tenant (`IT:40–52`; `RT:188–231`). Exercise unfiltered queries too, not only caller-supplied tenant filters.
- **Write isolation:** unauthorized insert, tenant reassignment and cross-tenant parent references fail under every relevant writer role. Include the multi-tenant-member case. Keep expected SQL privilege denial distinct from RLS or FK rejection.
- **Security catalog:** all intended tenant tables have RLS; policy expressions match intent; Directus has `rolsuper=false`, `rolbypassrls=false`, `rolcanlogin=true` (`RT:116–131`; `IT:349–357`). Also check ownership and helper EXECUTE privileges.
- **Read surface:** member fixture data is visible and outsider data exposure is zero for each of the five public API views (`M15:16–21`). Preserve applicable internal-view checks from `IT:315–337`.
- **Controlled ingestion fixture:** at least 3 assets, 2 manifests, 2 parse jobs, 6 surveys spanning 3 assets, 15 observations, 3 deltas, 1 deteriorating and 1 severe result (`IT:75–150`). Verify repeated processing does not introduce unintended duplicates.
- **Directus fixture:** unit-cost update reads back `70.00`; two LOS targets; four AMP sections and at least one version; one resolved unmatched fixture; uploaded test file at the specified tenant path (`IT:160–302`). Core-table access remains blocked under the intended access contract.
- **Operational:** record lock wait duration, deadlocks, permission/FK failures, batch duration, replication lag where applicable, and job backlog age. Set explicit stop thresholds before deployment; the packet supplies no production performance budgets.

## Alternatives, uncertainty and next action

- Blanket grants are not a safe compatibility solution; disabling RLS is not a safe rollback.
- A `viewer` write vulnerability is **conditional on effective grants**, not proven solely by its permissive policy.
- Public-view leakage, Directus correctness and worker incompatibility are unresolved—not demonstrated failures—because their implementations and runtime privileges are outside the packet.
- The next useful action is a **deployed catalog/role inventory plus a corrected, two-tenant compatibility test matrix**, before changing either data or permissions.

MATERIAL_EVIDENCE_CONFLICT: `M15:7–22` revokes authenticated access to `app` tables and grants five public API views, while `RT:276–283` expects authenticated users to query `app.asset` successfully; additionally, the “own events only” statement at `M08:68` conflicts with the tenant-member read allowance at `M08:71–73`.

openai / gpt-6.1-sol / low / low effort answer

## Conclusion

**Do not replay these migrations or treat the SQL test comments as proof of deployment safety.** For an already-populated database, use additive, versioned changes and defer privilege contraction until all live API and worker versions demonstrably work with it.

This is an independent, read-only assessment of the supplied snapshot. No tests were run.

### Evidence-backed risks

| Finding | Evidence | Implication / confidence |
|---|---|---|
| Hardening is a breaking access change, not an expansion. | `supabase/migrations/00015_hardening.sql:4–22` revokes authenticated access to app tables, sequences and functions, then grants SELECT on five public API views. | Old authenticated clients using app tables or functions can fail immediately after commit. Whether existing clients do so is unknown. **High confidence.** |
| Public-view isolation is unproven. | Hardening grants access to `public.api_*` views (`00015:16–22`), while integration tests query `app.v_*` views (`supabase/test-integration.sql:315–337`). Neither view definitions nor ownership/security settings are supplied. | Passing the app-view tests would not establish isolation of the newly granted public surface. **High confidence.** |
| Membership policies do not implement member-role authorization. | `app.is_member` checks tenant/user only (`00002_create_schema_and_tenant.sql:36–47`); the modification policy allows every member (`00008_enable_rls_and_policies.sql:42–46`). Role documentation describes viewers as read-only (`00002:27,33`). | Where underlying grants permit writes, viewers also satisfy write policies. Hardening restricts direct authenticated access but does not make the policies role-aware. **High confidence.** |
| Cross-tenant parent links are possible under the declared constraints. | Survey has separate tenant and asset FKs (`00003_create_core_tables.sql:29–30`); observation has separate tenant and survey FKs (`00003:46–47`). | Neither FK establishes that child and parent have equal tenant IDs. RLS checks the child’s tenant, not its parent’s. This can produce contaminated joins and cross-tenant cascade effects; actual exploitation depends on effective privileges. **High confidence.** |
| Cascades make deletion an irreversible boundary without recovery evidence. | Tenant membership cascades (`00002:25`); assets, surveys and observations cascade through their FKs (`00003:8,29–30,46–47`). | Dropping a tenant or parent can delete existing descendants, including incorrectly linked cross-tenant descendants. Reverting DDL does not restore deleted rows. **High confidence.** |
| Security-definer functions need privilege review. | Both helpers are `SECURITY DEFINER` (`00002:40`; `00008:24`). Policy helper interpolates a caller-provided relation using `%s` (`00008:33–45`); neither declaration fixes a function search path. | Inspect ownership, executable roles, effective PUBLIC privileges and search-path safety. Revoking authenticated’s direct function grants (`00015:9`) alone does not prove PUBLIC/inherited execution is denied. Actual exploitability is not established. **High confidence on review need.** |
| RLS coverage is time-dependent. | `00008:10–17` enables RLS on app base tables existing at execution; policy application is an explicit list (`00008:52–66`). | Future tables are not automatically protected by this loop. An additive rollout must explicitly establish RLS and policies before granting access. **High confidence.** |
| Replay is unsafe and dependency order matters. | Table creation uses `IF NOT EXISTS`, but index creation does not (`00002:52–53`); named tenant/audit policies are created without replacement (`00008:71–91`). `00008:55–66` and `00015:16–21` reference objects not defined in this packet. | `IF NOT EXISTS` does not reconcile an existing table’s shape. Replay can fail or overwrite selected policies. Referenced tables/views must already exist; their definitions remain external dependencies, not presumed absent. **High confidence.** |

Additional integrity limits: `tenant_member.user_id` has only a comment referencing auth users, not a declared FK (`00002:26`); nullable grade/coverage/direction remain allowed despite checks (`00003:33–35,49`); no survey business-key uniqueness or observation deduplication key is declared (`00003:27–56`). Consequently, test `ON CONFLICT DO NOTHING` does not make repeated survey/observation fixtures idempotent (`supabase/test-rls.sql:82–102`).

Audit policies also differ from their comment: SELECT permits any tenant member, not only the event’s user, and INSERT checks user identity without tenant membership (`00008:68–77`). Actual audit grants and table constraints are unknown.

## Phased rollout

### 1. Baseline and prepare

Before changes:

- Capture live schema, constraints, indexes, policy expressions, view definitions/security settings, owners, role memberships, effective grants and default privileges.
- Establish which roles and database objects each deployed API/worker version actually uses. The packet contains no application implementation or version compatibility evidence.
- Record tenant-scoped row counts and ingestion progress; audit:
  - survey/asset tenant mismatches;
  - observation/survey tenant mismatches;
  - membership user IDs without corresponding auth users;
  - unexpected duplicates against the intended, explicitly agreed business keys.
- Require **zero unresolved cross-tenant links** before enforcing tenant-consistent relationships.
- Verify recovery with a restore rehearsal and record a recovery point before repairs or destructive changes.

Do not run these fixture scripts unmodified against existing production tenants. Integration tests update unit costs, create AMP versions and modify unmatched records (`test-integration.sql:165–171,183–187,235–238,271–275`); optional cleanup deletes all AMP sections and LOS targets for the tenant (`:428–432`).

### 2. Expand

- Preserve current columns, read surfaces and safe grants needed by old versions.
- Add replacement structures without requiring old writers to populate new mandatory fields immediately.
- Establish tenant protection before exposing new objects.
- If repairing cross-tenant relationships, prepare tenant-qualified parent uniqueness and corresponding composite FKs while retaining current identifiers and FK interfaces.
- Do not apply the broad authenticated revocations as the first compatibility step.

**Lock controls:** use bounded lock/statement timeouts, inspect blockers, and stage work in short transactions. The supplied index statements are ordinary, non-concurrent creation (`00002:52–53`); RLS changes execute across tables (`00008:6–18`); hardening bundles privilege changes in one transaction (`00015:1–24`). None specifies lock budgets or an online backfill strategy.

For new integrity enforcement, consider concurrent supporting-index construction where applicable, staged FK validation and separately scheduled short-lock operations. These are proposed techniques, not behavior implemented in this snapshot.

### 3. Migrate

- Deploy compatible application versions before relying on new representations or access paths.
- Establish a single authoritative write representation or verified dual-write strategy; no such strategy is evidenced here.
- Backfill in restartable, bounded batches with tenant-level progress, mismatch counts, latency and replication/WAL monitoring.
- Prevent old writers from recreating invalid links while repairs run. Composite FKs staged without validating historical rows can constrain subsequent writes, but may reject legacy behavior: test it first.
- Do not “repair” child tenant IDs automatically. That changes visibility; determining the correct tenant requires evidence beyond these files.
- Test old-worker retries and processing of records written by new versions. The scripts name manifests/jobs and expected states but do not define queue claiming, retry or idempotency behavior (`test-integration.sql:95–123`).

### 4. Verify

Require all checks below across old/new API and worker combinations, including delayed jobs and retries.

### 5. Contract

Only after old versions and incompatible queued work are drained:

- Enforce validated constraints and any new mandatory fields.
- Remove compatibility paths individually.
- Apply privilege contraction only after proving intended public-view access and tenant isolation.
- Revoke narrowly and verify effective privileges; do not assume direct-role revocations remove inherited access.
- Retain rollback artifacts and old representations until the agreed observation window expires.

The supplied database-level search-path change (`00002:9`) also warrants connection-pool verification: do not assume existing and fresh sessions resolve unqualified names identically.

## Measurable verification gates

1. **RLS catalog checks:** reproduce rowsecurity and policy inspection (`test-rls.sql:116–131`), expanding coverage to every exposed tenant table. Require intended policy expressions, not merely matching names.

2. **Real identity tests:** test a non-bypass member and outsider with genuine request identity, plus the two-tenant case (`test-rls.sql:188–231,276–285`). Require zero foreign-tenant rows and rejected cross-tenant INSERT/UPDATE attempts.

   The integration script’s `SET ROLE postgres` plus JWT setting (`test-integration.sql:55–60,312–337`) does not prove non-bypass RLS enforcement. Its `SET ... = (SELECT ...)` expressions also require adaptation to executable identity setup. The RLS script explicitly acknowledges service-role limitations (`test-rls.sql:170–176`).

3. **Post-hardening access matrix:** authenticated app-table/function denial where intended; successful permitted public-view reads; zero outsider/foreign-tenant results through **each of the five public views** (`00015:16–21`). Permission denial and an RLS-filtered zero-row result are different outcomes.

4. **Ingestion fixture contract:** in an isolated, tagged tenant, meet B2 expectations: ≥3 assets, ≥2 manifests queued/parsed, ≥2 parse jobs, ≥6 surveys across ≥3 assets, ≥15 observations, and ≥3 deltas including ≥1 deteriorating and ≥1 severe (`test-integration.sql:75–150`). Compare against baseline deltas, not only absolute counts. These thresholds alone do not prove correctness or deduplication.

5. **Directus contracts:** reproduce unit-cost 70.00 update, LOS targets, AMP authoring and unmatched resolution (`test-integration.sql:160–287`); require `rolsuper=false`, `rolbypassrls=false`, `rolcanlogin=true` (`:349–357`). Verify both USING and WITH CHECK expressions and tenant isolation.

6. **Operational gates:** zero unexplained count changes, zero tenant-link mismatches, zero unvalidated required constraints, and no regression beyond predetermined latency/error/backlog thresholds. The packet supplies no operational thresholds; agree them before deployment.

## Explicit rollback boundaries

- **Before commit:** `00015` is transaction-wrapped; aborting before commit restores that transaction’s prior privilege state (`00015:1–24`).
- **After privilege-only commit:** a narrowly reconstructed prior privilege configuration can restore compatibility without changing rows. Restoring blanket access may reopen security risks; use the captured baseline, not an indiscriminate grant.
- **After compatible additive writes:** application rollback is safe only if old versions can read/process every new row and retained columns remain authoritative. Otherwise stop or gate writers and reconcile first.
- **After backfill or tenant-link repair:** DDL rollback cannot undo data changes. Use recorded row-level before-images or a verified recovery/replay procedure; tenant changes can alter visibility immediately.
- **After new-only writes or destructive contract:** old binaries are not a safe rollback by default. Restore/translate the representation or roll forward.
- **After cascaded deletes:** require data recovery. Neither re-creating schema objects nor reinstating grants restores descendants.
- **After external ingestion/upload actions:** database rollback cannot undo S3 objects or processing side effects; the integration plan explicitly includes uploads (`test-integration.sql:80–93,291–302`).

## Uncertainty and next action

A legitimate alternative is that later, unsupplied migrations already implement Directus policies, safe public views and required grants. That possibility prevents declaring the live system broken—but does not validate it. Likewise, privilege contraction may already match every production client; the snapshot cannot prove this.

**Next action:** produce a live privilege/policy/view inventory and an old/new-version compatibility matrix, then run the corrected identity and isolated-fixture checks before any contraction.

MATERIAL_EVIDENCE_CONFLICT: Viewer roles are documented as read-only (`supabase/migrations/00002_create_schema_and_tenant.sql:33`) but member modification policies ignore role (`supabase/migrations/00008_enable_rls_and_policies.sql:42–46`); integration expects `app.is_directus()` policies (`supabase/test-integration.sql:377–390`) while the supplied policy creation uses only `app.is_member()` (`supabase/migrations/00008_enable_rls_and_policies.sql:36–46,52–66`).

Primary judge's stated reason

A receives a forced, weak preference because its verification checklist more explicitly preserves the supplied Directus security and upload acceptance checks. This slightly improves deployment sign-off coverage, but does not establish a material quality difference; an independent review could reasonably favor B's external-side-effect rollback treatment.

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

Battle wave: e1d38d25-feb4-4436-82c7-b4ad3c059a64. Pair: brp1_19c0508b656d873ea4bf425c8486f2f86c813dc89ed677a94a60e220c336d17c. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.