Documentation

Docs / Reference

ADR 0051 - Schema claim contract and Postgres oracle

Status: Accepted (delegated review, 2026-11-09)

Numbering: the task (T018a2) asked for the next free number; 0048-0050 are taken and 0052 is taken by T016j's re-index ADR, so this is 0051.

Context

T018a (ADR 0047) modelled sqlx migration sets with PostgreSQL 17 semantics and took nine reviews. Three causes (developer discussion of 2026-11-04): the task said "model Postgres DDL" without a closed list of what the pass claims, so every reviewer found one more form; correctness was judged by reasoning although a real Postgres 17 was available in CI; and coverage was never measured, so over-conservative rules crept in unseen. The convergence rule that ended T018a left known wrong facts and coverage gaps (ADR 0047, Known gaps): K1 a foreign key to a table the set creates later (applied: true where one migration must fail), K2 ALTER TYPE ... ADD VALUE of an existing label or a missing type, C2 widening a referenced key, C3 DROP CONSTRAINT of a written name forgetting every key, C4 -- no-transaction not read, C5 generated-name shapes on partial tables.

T018a2's investigation built a differential oracle and measured today's code: 3 fixture root causes and 96 repros besides K1 and K2. Revision 1 brought each root into a class rule (P1-P10), and steps B1a-B3 (2026-11-04 to 2026-11-07) implemented them; three later precision stops became Revisions 1.1-1.3 (volatility, column references of DML, values of DML).

Options considered

  1. Keep case review. Reviewers read the code against Postgres sources and report wrong facts. This is what T018a did; it does not converge because the space of forms is open and each finding is a new case.
  2. Contract only. A finite table of the forms the pass models, their claims and refusal conditions, everything else to a default branch. Review becomes row by row, but whether a row is right is still judged by reasoning.
  3. Contract and oracle. The table of option 2, plus a harness that applies fixture, real and generated histories to a real Postgres 17 and compares the catalog with the records; zero disagreements is the precision gate, and coverage is measured on real histories.

Decision

Option 3.

Consequences

Known gaps

Review notes (2026-11-09, delegated review, 2026-11-09)

Report a problem with this pageSource: docs/adr/0051-schema-claim-contract-and-postgres-oracle.md