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

TML-2991: diff uniques and indexes structurally — delete the reconciliation pass - #947

Merged
wmadden merged 7 commits into
mainfrom
slice/unify-unique-and-index-nodes
Jul 10, 2026
Merged

wmadden merged 7 commits into
mainfrom
slice/unify-unique-and-index-nodes

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-2991 (slice 2.6 of postgres-rls). Between slice 2.5 (one-differ-two-ir-planner, #921) and slice 3 (explicit-rls-control, #945).

At a glance

The schema differ compares two derived schema-IR trees and does nothing else — no pre-diff pass that transforms a tree to make the verdict come out "satisfied". This PR deletes the one place that violated that:

 export function diffSqliteSchema(input: { … }) {
-  const expected = neutralizeFlatExpectedFkSchemas(
-    normalizeActualForSatisfaction(contractToSchemaIR(input.contract, { … })),
-  );
-  const actual = normalizeFlatActualForDiff(expected, introspect(input.db));
-  return diffSchemas(expected, actual);
+  const expected = contractToSchemaIR(input.contract);
+  return diffSchemas(expected, introspect(input.db));
 }

diff-tree-normalization.ts — the 211-line resolveSemanticSatisfaction reconciliation pass — is gone.

Decision

A unique constraint (pg_constraint) and an index (pg_index) are different schema elements — different catalog, different DDL, independent lifecycle. They stay two structural nodes (SqlUniqueIR, SqlIndexIR), exactly as primary keys, foreign keys, and check constraints are already separate nodes. The debt slice 2.5 left behind was not the two node kinds — it was the pre-diff pass that massaged the actual tree to fake "semantic satisfaction" (a live unique index silently counting as a declared unique constraint, and vice-versa).

  1. Delete the reconciliation pass. resolveSemanticSatisfaction / normalizeFlatActualForDiff and the caller-less isUniqueConstraintSatisfied / isIndexSatisfied are removed; both diff paths run diffSchemas(expected, actual) on the trees as derived.
  2. Keep the two nodes. SqlIndexIR.isEqualTo becomes purely symmetric structural equality — unique === unique && type === type && options — dropping the "stronger-satisfies-weaker" rule. No constraint marker, no merging, no dedupe, no fail-loud rule: none is needed once the two elements are honestly two nodes.
  3. Resolve the FK referenced-namespace from the namespace node, at derivation. The FK schema-segment normalization (the other, unrelated half of the deleted file) moves into derivation — but not via a flag. "Does this database have namespaces?" is answered by asking the namespace node (NamespaceBase.isUnbound), never by comparing an __unbound__ string. An FK targeting the unbound namespace stamps no referenced-namespace (matching what flat introspection produces, so the two sides' FK ids meet by construction); a bound one stamps it as before. No pre-diff normalization pass survives, and the sentinel string never enters the schema-IR layer. (The broader sweep — routing the ~15 remaining id === UNBOUND_NAMESPACE_ID consumers through isUnbound and banning the literal — is tracked as TML-2997; this PR lands the seam.)

Behavior change

Deleting satisfaction makes a unique-vs-index mismatch plain structural drift (verdicts and planner ops flip only for the mismatch cases; the general strict/lenient extra-tolerance and cross-space ownership are untouched — schema-verify.ts is byte-identical to main):

  • contract @@unique vs a live unique index → fails (constraint missing + index extra).
  • contract @@index vs a live unique constraint → fails.
  • contract @@index vs a live unique index (both indexes, differ on unique) → recreate (indexIncompatible) — a plain and a unique index are genuinely different objects.
  • a stray, undeclared live unique index → an ordinary extra (strict-fails, lenient-passes), like any other extra.
  • contract @@unique vs the live unique constraint it created (the normal round-trip) → clean.

The planner needs no new code: a mismatch is a missing node plus an extra node, which its existing independent SqlUniqueIR / SqlIndexIR arms map to drop-the-extra + create-the-missing, with the existing control-policy disposition suppressing the drop under an additive policy.

Reviewer notes

  • This supersedes an earlier approach on this branch. An initial attempt merged unique and index into a single node with a constraint boolean. That merge — two schema elements in one node keyed by column tuple — forced new tree-massaging back in (an introspection dedupe and a fail-loud derivation rule) to avoid id collisions, which is the exact anti-pattern the slice exists to remove. It was discarded; this is the corrected, deletion-dominated design. If you saw the prior force-pushed history, ignore it.
  • The fence. git diff main -- packages/2-sql/9-family/src/core/diff/schema-verify.ts is empty. The verdict grading, control-policy disposition, and cross-space ownership are byte-unchanged; the behavior flips fall out purely of the node model, not the grading.
  • One fixture edited — sqlite/.../runner.across-spaces.test.ts declared both @@unique and @@index on email but its hand-written DDL created only email TEXT UNIQUE. It passed before only because satisfaction masked the missing index. Added CREATE INDEX so the live schema honestly carries both declared elements.
  • FK namespace identity is now node behavior. NamespaceBase.isUnbound is added as the single encapsulated place the __unbound__ sentinel is compared; derivation reads it instead of the string. The Postgres target re-stamps referencedSchema ?? UNBOUND_NAMESPACE_ID for its own REFERENCES-clause DDL (keeping Postgres byte-identical — proven by fixtures:check clean); that lone sentinel-as-value in the target layer is the kind of thing TML-2997 sweeps up.
  • Rebased through slice 3. #945 (RLS control) and native-enums merged into main mid-flight and touched these files. This branch rebased onto them: our reconciliation deletion and slice-3's rlsEnabled/nativeEnums coexist (deleting the actual-tree-rebuild function is safer than merging — the introspected tree flows to the differ unmodified, RLS/enum data intact). The full RLS suite is green on the new base.
  • Deletion-dominated. SqlUniqueIR and SqlIndexIR are otherwise unchanged from main; both planners are untouched.

Verification

Run on final HEAD (rebased onto current main):

  • pnpm build, pnpm typecheck — clean.
  • pnpm lint:deps, pnpm lint, pnpm lint:casts, pnpm lint:framework-vocabulary, pnpm check:upgrade-coverage --mode pr — pass.
  • pnpm fixtures:check — no drift.
  • pnpm test:packages — pass (only the known macOS /var→/private/var config-loader symlink flake).
  • pnpm test:integration, pnpm test:e2e (109/109) — green (documented environmental flakes only; each passes in isolation).
  • The four multi-space guards — pass, untouched.
  • RLS suites (slice 3, now in the base) — target-postgres RLS units 104/104, RLS + cross-space integration 19/19 (incl. runner.unbound-namespace, which drives the isUnbound path end-to-end on live PGlite). Our deletions do not disturb RLS.

Alternatives considered

  • Merge unique and index into one node (a SqlIndexIR with a constraint flag). Rejected — it conflates two distinct catalog elements into one node keyed by column tuple, which cannot represent a unique constraint and a same-column index at once, forcing an introspection dedupe and a fail-loud contract rule to paper over the collision. That re-introduces the tree-massaging this slice removes.
  • Preserve the satisfaction semantics. Rejected — "a stronger live object satisfies a weaker declared one" is a fuzzy "sometimes different is fine" rule requiring a pre-diff pass or classifier special-cases. Plain structural equality is simpler and more correct: if the projected schema and the live schema disagree on a matched object, that is drift.

Skill update

One extension-author upgrade entry recorded (schema-ir-fk-unbound-referenced-schema-absent, 0.14→0.15): contractToSchemaIR no longer stamps referencedSchema for an FK targeting the unbound namespace (identity is read via NamespaceBase.isUnbound); target tree re-builders default with ?? UNBOUND_NAMESPACE_ID. No public API/CLI/config surface change and the emitted contract is unchanged; the behavior change is to db verify / migration plan drift semantics for unique-vs-index mismatches, documented above.

Checklist

  • All commits are signed off (git commit -s) per the DCO.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated.
  • The PR title is in TML-NNNN: <title> form.
  • The Skill update section is filled in.

Summary by CodeRabbit

  • New Features

    • Added clearer namespace identity handling for foreign keys, improving schema matching across bound and unbound namespaces.
    • Added structural validation for unique constraints and indexes, including migration planning coverage.
  • Bug Fixes

    • Unique constraints and indexes are now compared symmetrically, preventing mismatches from being treated as equivalent.
    • Schema verification and migration planning now produce more accurate results without legacy normalization behavior.
  • Documentation

    • Added upgrade guidance for foreign keys targeting unbound namespaces.

@wmadden-electric
wmadden-electric requested a review from a team as a code owner July 10, 2026 09:19
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR removes semantic-satisfaction normalization and the standalone unique schema IR, makes index equality symmetric, changes unbound foreign-key namespace projection, and updates Postgres, SQLite, verification, and migration tests for structural comparisons.

Changes

Structural schema diffing

Layer / File(s) Summary
Namespace and foreign-key contracts
packages/1-framework/..., packages/2-sql/1-core/..., packages/2-sql/9-family/src/core/migrations/..., packages/3-targets/..., packages/3-extensions/...
Namespaces expose isUnbound; foreign-key projections and related test doubles update referencedSchema handling for unbound and bound targets.
IR equality and diff contracts
packages/2-sql/1-core/schema-ir/..., packages/2-sql/9-family/src/core/diff/..., packages/2-sql/9-family/src/exports/diff.ts
SqlIndexIR requires matching unique flags, and semantic-satisfaction helpers and exports are removed or narrowed.
Direct schema verification
packages/2-sql/9-family/test/schema-verify.verdict.test.ts
Verification compares contract-derived expected trees and introspection-shaped actual trees directly, with structural uniqueness and index expectations.
Postgres and SQLite diff paths
packages/3-targets/3-targets/{postgres,sqlite}/src/core/migrations/...
Target diff and plan generation no longer normalize semantic satisfaction before calling diffSchemas; Postgres retains ownership filtering.
Migration planner validation
packages/3-targets/6-adapters/postgres/test/migrations/..., packages/3-targets/6-adapters/sqlite/test/migrations/...
Tests cover structural unique constraint/index behavior, and the SQLite fixture adds an email index.
Upgrade guidance
skills/extension-author/.../instructions.md
Upgrade instructions document the unbound foreign-key referencedSchema change.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: wmadden, aqrln

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: structural diffing for uniques/indexes and removal of the reconciliation pass.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slice/unify-unique-and-index-nodes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@947

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@947

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@947

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@947

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@947

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@947

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@947

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@947

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@947

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@947

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@947

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@947

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@947

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@947

@prisma-next/extension-supabase

npm i https://pkg.pr.new/@prisma-next/extension-supabase@947

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@947

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@947

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@947

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@947

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@947

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@947

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@947

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@947

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@947

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@947

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@947

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@947

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@947

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@947

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@947

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@947

@prisma-next/config-loader

npm i https://pkg.pr.new/@prisma-next/config-loader@947

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@947

@prisma-next/language-server

npm i https://pkg.pr.new/@prisma-next/language-server@947

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@947

prisma-next

npm i https://pkg.pr.new/prisma-next@947

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@947

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@947

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@947

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@947

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@947

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@947

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@947

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@947

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@947

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@947

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@947

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@947

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@947

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@947

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@947

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@947

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@947

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@947

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@947

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@947

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@947

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@947

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@947

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@947

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@947

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@947

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@947

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@947

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@947

commit: afab1b9

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 154.12 KB (+0.01% 🔺)
postgres / emit 129.25 KB (+0.02% 🔺)
mongo / no-emit 98.57 KB (+0.02% 🔺)
mongo / emit 89.41 KB (+0.03% 🔺)
cf-worker / no-emit 181.28 KB (+0.02% 🔺)
cf-worker / emit 153.94 KB (+0.01% 🔺)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/3-targets/3-targets/sqlite/src/core/migrations/issue-planner.ts (1)

272-291: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Preserve unique on SQLite indexes

CreateIndexCall drops the index’s unique flag, even though buildCreateIndexSql() already supports CREATE UNIQUE INDEX. Both buildCreateTableCalls() and mapIndexIssue() should thread index.unique through; otherwise a bare unique: true index is recreated as a plain non-unique index and loses its guarantee. packages/3-targets/3-targets/sqlite/src/core/migrations/issue-planner.ts:272-291, 392-393

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/3-targets/3-targets/sqlite/src/core/migrations/issue-planner.ts`
around lines 272 - 291, Preserve SQLite index uniqueness by passing each index’s
unique flag into CreateIndexCall in buildCreateTableCalls, and update
mapIndexIssue to thread index.unique through its CreateIndexCall construction as
well. Verify both paths retain unique: true so buildCreateIndexSql emits CREATE
UNIQUE INDEX.
packages/2-sql/1-core/schema-ir/README.md (1)

81-81: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update stale uniques field in the Basic Usage example.

The example still uses uniques: [{ columns: ['email'] }], but SqlTableIRInput no longer has a uniques field — it was removed as part of this PR. This example would cause a TypeScript error for anyone following it. Replace it with a constraint-marked index entry.

As per coding guidelines for **/*.{md,mdc}: Keep docs current.

📝 Proposed fix for the stale README example
       primaryKey: { columns: ['id'] },
       foreignKeys: [],
-      uniques: [{ columns: ['email'] }],
-      indexes: [],
+      indexes: [{ columns: ['email'], unique: true, constraint: true }],
     },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/2-sql/1-core/schema-ir/README.md` at line 81, Update the Basic Usage
example by replacing the removed `uniques` property with an index entry marked
as a unique constraint, using the current `SqlTableIRInput` schema and
index/constraint field names. Verify the example remains valid TypeScript and
accurately represents a unique email constraint.

Source: Coding guidelines

🧹 Nitpick comments (1)
packages/3-targets/3-targets/sqlite/src/core/migrations/planner.ts (1)

233-237: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the pass 3 comment to mention isSuperfluousConstraintOnlyNotEqual filtering.

The comment at lines 209–213 describes pass 3 as dropping only not-expected issues outside strict mode, but the changed filter now also drops isSuperfluousConstraintOnlyNotEqual issues. The comment should reflect this addition to avoid confusing future readers about what the non-strict filter does.

♻️ Suggested comment update
 * 3. Strict-mode extras gating — `not-expected` (extra table/column/
 *    constraint) issues and `isSuperfluousConstraintOnlyNotEqual`
 *    (undeclared-constraint-marker) `not-equal` index issues are dropped
 *    entirely outside strict mode, mirroring the retired coordinate walk's
 *    `if (strict) { ...extra_* } }` guards: an additive-only plan must never
 *    even consider dropping an unclaimed object, not just refuse to emit
 *    the drop.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/3-targets/3-targets/sqlite/src/core/migrations/planner.ts` around
lines 233 - 237, Update the pass 3 comment near the issues filter to state that
non-strict mode drops both “not-expected” issues and issues identified by
isSuperfluousConstraintOnlyNotEqual, matching the filtering logic in the issues
computation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/2-sql/1-core/schema-ir/README.md`:
- Line 81: Update the Basic Usage example by replacing the removed `uniques`
property with an index entry marked as a unique constraint, using the current
`SqlTableIRInput` schema and index/constraint field names. Verify the example
remains valid TypeScript and accurately represents a unique email constraint.

In `@packages/3-targets/3-targets/sqlite/src/core/migrations/issue-planner.ts`:
- Around line 272-291: Preserve SQLite index uniqueness by passing each index’s
unique flag into CreateIndexCall in buildCreateTableCalls, and update
mapIndexIssue to thread index.unique through its CreateIndexCall construction as
well. Verify both paths retain unique: true so buildCreateIndexSql emits CREATE
UNIQUE INDEX.

---

Nitpick comments:
In `@packages/3-targets/3-targets/sqlite/src/core/migrations/planner.ts`:
- Around line 233-237: Update the pass 3 comment near the issues filter to state
that non-strict mode drops both “not-expected” issues and issues identified by
isSuperfluousConstraintOnlyNotEqual, matching the filtering logic in the issues
computation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7e55f40a-900f-48cb-98b4-96bf8ce369f3

📥 Commits

Reviewing files that changed from the base of the PR and between 09a6ce0 and f12e2ba.

📒 Files selected for processing (80)
  • packages/2-sql/1-core/schema-ir/README.md
  • packages/2-sql/1-core/schema-ir/src/exports/types.ts
  • packages/2-sql/1-core/schema-ir/src/ir/schema-node-kinds.ts
  • packages/2-sql/1-core/schema-ir/src/ir/sql-index-ir.ts
  • packages/2-sql/1-core/schema-ir/src/ir/sql-table-ir.ts
  • packages/2-sql/1-core/schema-ir/src/ir/sql-unique-ir.ts
  • packages/2-sql/1-core/schema-ir/src/types.ts
  • packages/2-sql/1-core/schema-ir/test/sql-flat-tree-diffable.test.ts
  • packages/2-sql/1-core/schema-ir/test/sql-index-ir.test.ts
  • packages/2-sql/1-core/schema-ir/test/sql-schema-ir-node.test.ts
  • packages/2-sql/1-core/schema-ir/test/sql-unique-ir.test.ts
  • packages/2-sql/9-family/src/core/control-instance.ts
  • packages/2-sql/9-family/src/core/diff/diff-tree-normalization.ts
  • packages/2-sql/9-family/src/core/diff/fk-schema-normalization.ts
  • packages/2-sql/9-family/src/core/diff/schema-verify.ts
  • packages/2-sql/9-family/src/core/diff/sql-schema-diff.ts
  • packages/2-sql/9-family/src/core/migrations/contract-to-schema-ir.ts
  • packages/2-sql/9-family/src/core/psl-contract-infer/relation-inference.ts
  • packages/2-sql/9-family/src/exports/diff.ts
  • packages/2-sql/9-family/test/contract-to-schema-ir.test.ts
  • packages/2-sql/9-family/test/psl-contract-infer/relation-inference.test.ts
  • packages/2-sql/9-family/test/schema-verify.classify.test.ts
  • packages/2-sql/9-family/test/schema-verify.helpers.ts
  • packages/2-sql/9-family/test/schema-verify.verdict.test.ts
  • packages/2-sql/9-family/test/schema-view.test.ts
  • packages/3-extensions/pgvector/test/migrations/planner.behavior.test.ts
  • packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/contract-to-postgres-database-schema-node.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/diff-database-schema.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner-schema-lookup.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/postgres/src/core/psl-infer/infer-psl-contract.ts
  • packages/3-targets/3-targets/postgres/src/core/schema-ir/postgres-table-schema-node.ts
  • packages/3-targets/3-targets/postgres/test/migrations/node-issue-planner.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner-schema-lookup.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner.check-constraints.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner.sibling-scoping.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/rls-planner.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/verdict-table-less-namespace.test.ts
  • packages/3-targets/3-targets/postgres/test/postgres-database-schema-node.test.ts
  • packages/3-targets/3-targets/postgres/test/postgres-namespace-schema-node.test.ts
  • packages/3-targets/3-targets/postgres/test/postgres-table-schema-node.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/infer-psl-contract-described-contracts.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/infer-psl-contract.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.core.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.defaults-and-types.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.enums.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.naming-and-constraints.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.relations.test.ts
  • packages/3-targets/3-targets/postgres/test/schema-node-subject-granularity.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/column-ddl-rendering.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/diff-database-schema.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/issue-planner.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/operations/tables.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/planner-strategies.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/planner.ts
  • packages/3-targets/3-targets/sqlite/test/migrations/node-issue-helpers.ts
  • packages/3-targets/3-targets/sqlite/test/migrations/nullability-backfill.test.ts
  • packages/3-targets/3-targets/sqlite/test/migrations/planner.sibling-scoping.test.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/fixtures/runner-fixtures.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner-schema-lookup.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner.integration.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/rls-collect-extension-issues.test.ts
  • packages/3-targets/6-adapters/sqlite/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/sqlite/test/control-adapter.test.ts
  • packages/3-targets/6-adapters/sqlite/test/migrations/db-init-update.cli.test.ts
  • packages/3-targets/6-adapters/sqlite/test/migrations/fixtures/runner-fixtures.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.14-to-0.15/instructions.md
  • test/e2e/framework/test/sqlite/migrations/additive.test.ts
  • test/e2e/framework/test/sqlite/migrations/fk-preservation.test.ts
  • test/integration/test/cross-package/postgres-control-policy-planner.test.ts
  • test/integration/test/cross-package/postgres-issue-planner.test.ts
  • test/integration/test/family.introspect.integration.test.ts
  • test/integration/test/family.introspect.test.ts
  • test/integration/test/family.schema-verify.constraints.test.ts
💤 Files with no reviewable changes (24)
  • packages/2-sql/1-core/schema-ir/src/ir/sql-unique-ir.ts
  • packages/3-targets/3-targets/postgres/test/postgres-database-schema-node.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner-schema-lookup.test.ts
  • packages/2-sql/1-core/schema-ir/test/sql-unique-ir.test.ts
  • packages/2-sql/9-family/src/core/diff/diff-tree-normalization.ts
  • packages/3-targets/3-targets/postgres/test/schema-node-subject-granularity.test.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/contract-to-postgres-database-schema-node.ts
  • packages/2-sql/1-core/schema-ir/src/exports/types.ts
  • packages/2-sql/1-core/schema-ir/src/types.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.enums.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/rls-collect-extension-issues.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/rls-planner.test.ts
  • packages/2-sql/9-family/test/schema-view.test.ts
  • packages/3-targets/3-targets/postgres/test/postgres-namespace-schema-node.test.ts
  • packages/3-targets/3-targets/sqlite/test/migrations/nullability-backfill.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner.check-constraints.test.ts
  • packages/3-targets/3-targets/sqlite/test/migrations/planner.sibling-scoping.test.ts
  • test/integration/test/cross-package/postgres-control-policy-planner.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/verdict-table-less-namespace.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/infer-psl-contract-described-contracts.test.ts
  • packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
  • test/integration/test/cross-package/postgres-issue-planner.test.ts
  • packages/3-targets/3-targets/postgres/test/migrations/planner.sibling-scoping.test.ts

@wmadden-electric wmadden-electric changed the title unify unique constraints and indexes into one schema-IR node TML-2991: unify unique constraints and indexes into one schema-IR node Jul 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.ts (1)

89-89: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Filename no longer matches content. The suite is now "structural reconcile (no satisfaction)" yet the file is still planner.semantic-satisfaction.test.ts. Consider renaming (e.g. planner.structural-reconcile.test.ts) so the file name reflects the reframed behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.ts`
at line 89, Rename the test file containing the “PostgresMigrationPlanner -
structural reconcile (no satisfaction)” suite from its semantic-satisfaction
name to a structural-reconcile name, such as
planner.structural-reconcile.test.ts, so the filename matches the suite’s
behavior.
packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts (1)

749-778: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the default unique-constraint name to a shared helper. The fallback ${tableName}_${index.columns.join('_')}_key is duplicated in dropIndexOrConstraintCall and createIndexOrConstraintCall. Since a drop must target the same name a prior AddUniqueCall created, centralizing keeps the two sides from silently diverging (mirroring how defaultIndexName is already shared).

♻️ Proposed helper
+function defaultUniqueConstraintName(tableName: string, columns: readonly string[]): string {
+  return `${tableName}_${columns.join('_')}_key`;
+}
+
 function dropIndexOrConstraintCall(
   schemaName: string,
   tableName: string,
   index: SqlIndexIR,
 ): PostgresOpFactoryCall {
   if (index.constraint === true) {
-    const name = index.name ?? `${tableName}_${index.columns.join('_')}_key`;
+    const name = index.name ?? defaultUniqueConstraintName(tableName, index.columns);
     return new DropConstraintCall(schemaName, tableName, name, 'unique');
   }
   const indexName = index.name ?? defaultIndexName(tableName, index.columns);
   return new DropIndexCall(schemaName, tableName, indexName);
 }
 
 function createIndexOrConstraintCall(
   schemaName: string,
   tableName: string,
   index: SqlIndexIR,
 ): PostgresOpFactoryCall {
   if (index.constraint === true) {
-    const name = index.name ?? `${tableName}_${index.columns.join('_')}_key`;
+    const name = index.name ?? defaultUniqueConstraintName(tableName, index.columns);
     return new AddUniqueCall(schemaName, tableName, name, [...index.columns]);
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts`
around lines 749 - 778, Extract the duplicated default unique-constraint naming
expression from dropIndexOrConstraintCall and createIndexOrConstraintCall into a
shared helper, analogous to defaultIndexName. Use that helper in both constraint
branches so DropConstraintCall and AddUniqueCall always target the same
generated name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts`:
- Around line 749-778: Extract the duplicated default unique-constraint naming
expression from dropIndexOrConstraintCall and createIndexOrConstraintCall into a
shared helper, analogous to defaultIndexName. Use that helper in both constraint
branches so DropConstraintCall and AddUniqueCall always target the same
generated name.

In
`@packages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.ts`:
- Line 89: Rename the test file containing the “PostgresMigrationPlanner -
structural reconcile (no satisfaction)” suite from its semantic-satisfaction
name to a structural-reconcile name, such as
planner.structural-reconcile.test.ts, so the filename matches the suite’s
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: a3984b36-bb60-4bb6-8682-b84b3e2d0c19

📥 Commits

Reviewing files that changed from the base of the PR and between 471a8df and c6ef2be.

📒 Files selected for processing (11)
  • packages/2-sql/1-core/schema-ir/src/ir/sql-index-ir.ts
  • packages/2-sql/1-core/schema-ir/test/sql-index-ir.test.ts
  • packages/2-sql/9-family/src/core/migrations/schema-differ.ts
  • packages/2-sql/9-family/src/exports/diff.ts
  • packages/2-sql/9-family/test/schema-verify.classify.test.ts
  • packages/2-sql/9-family/test/schema-verify.verdict.test.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/diff-database-schema.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts
  • packages/3-targets/3-targets/postgres/test/migrations/node-issue-planner.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/migrations/diff-database-schema.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.ts
💤 Files with no reviewable changes (1)
  • packages/2-sql/9-family/src/exports/diff.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/2-sql/9-family/src/core/migrations/schema-differ.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/3-targets/3-targets/postgres/test/migrations/node-issue-planner.test.ts

@wmadden-electric
wmadden-electric force-pushed the slice/unify-unique-and-index-nodes branch 2 times, most recently from 4eb5e7d to c57c0c1 Compare July 10, 2026 14:14
@wmadden-electric wmadden-electric changed the title TML-2991: unify unique constraints and indexes into one schema-IR node TML-2991: diff uniques and indexes structurally — delete the reconciliation pass Jul 10, 2026
…uctural nodes

Discard the merge-into-one-node approach: a unique constraint (pg_constraint)
and an index (pg_index) are distinct schema elements. The slice deletes the
semantic-satisfaction reconciliation pass and keeps SqlUniqueIR/SqlIndexIR as
two structural nodes, so the generic differ compares the trees with no
massaging. Deliberate behaviour change: a unique-vs-index mismatch is drift.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Drop the (!this.unique || node.unique) stronger-satisfies-weaker rule; a
unique index and a non-unique index on the same columns are different
objects and are not equal. Keep indexOptionsLooselyEqual and the
introspection-side btree->undefined type normalization (real value
normalization at construction). Unit matrix rewritten to a symmetric row.

Per projects/postgres-rls/slices/unify-unique-and-index-nodes/design.md.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…esolution into derivation

The differ now runs diffSchemas(expected, actual) on the trees exactly as
derived — no pre-diff transformation. Deleted:
- resolveSemanticSatisfaction / normalizeFlatActualForDiff / the
  SemanticSatisfaction* types (diff-tree-normalization.ts removed entirely)
  and their call sites: normalizePostgresActualForDiff (postgres) and the
  two SQLite normalize calls.
- the caller-less isUniqueConstraintSatisfied / isIndexSatisfied predicates
  (grep-confirmed zero callers) and their exports/diff.ts entries.

FK schema-segment normalization folds into derivation: a target-agnostic
flattenReferencedNamespace option on contractToSchemaIR stamps the flat
empty resolvedReferencedNamespace at derivation. SQLite passes it (its diff
path); Postgres omits it and re-resolves FK namespaces downstream in
contract-to-postgres-database-schema-node, so the family default is never
observed there — byte-neutral (FK verdict tests unchanged).

Behaviour flips (intended, structural equality): contract @@unique vs live
unique index → fails (constraint missing + index extra); contract @@index
vs live unique constraint → fails; stray live unique index → ordinary extra
(strict-fails / lenient-passes); @@unique round-trip → clean. Verdict suite
rewritten to these. Fence: schema-verify.ts is byte-unchanged vs origin/main
(general strict/lenient extra grading untouched).

Per projects/postgres-rls/slices/unify-unique-and-index-nodes/design.md.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…tale unique-ir debt note

The unique-vs-index planner cases no longer assert semantic satisfaction:
a contract @@unique against a live unique index adds the constraint (the
destructive index drop is suppressed under an additive policy), a contract
@@index against a live unique index is an incompatible index change, and a
contract @@index against a live unique constraint creates the index. Add a
derivation test for the flattenReferencedNamespace FK-fold and remove the
accepted-under-protest note on SqlUniqueIR (its premise — delete the node —
was rejected; the two-node model is the accepted design).

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ot a flag

Replace the rejected flattenReferencedNamespace option with node behavior:
NamespaceBase gains an isUnbound getter (the single encapsulated place the
UNBOUND_NAMESPACE_ID comparison lives — required on the base rather than a
singleton override because non-singleton SqliteDatabase instances with
tables also occupy the unbound slot). convertForeignKey resolves the FK
target namespace node from storage and stamps no referencedSchema when it
is unbound; flat introspection stamps nothing, so both diff sides FK ids
meet by construction. Bound and cross-space targets stamp verbatim as
before. The Postgres rebuild restores its own coordinate for the unbound
slot (referencedSchema ?? UNBOUND_NAMESPACE_ID, the fallback already used
for resolution in the same function) so REFERENCES qualification and the
expected tree stay byte-identical. Deletes the option, its threading, and
the SQLite/harness call sites; the schema-IR layer never sees the sentinel.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Rebasing onto the slice-3/native-enums base surfaces the extension substrate
touch (pgvector test double) to check:upgrade-coverage in the 0.14-to-0.15
window. Record the one genuine extension-facing consequence of the FK
node-identity work: contractToSchemaIR no longer stamps referencedSchema for
an unbound-namespace FK target (absent, not the __unbound__ sentinel), and
namespace identity is answered by NamespaceBase.isUnbound. Extensions that
rebuild a target schema-IR tree default the absent value with
`?? UNBOUND_NAMESPACE_ID`.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric force-pushed the slice/unify-unique-and-index-nodes branch from c57c0c1 to afab1b9 Compare July 10, 2026 15:26
@wmadden
wmadden enabled auto-merge July 10, 2026 15:35
@wmadden
wmadden added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit 813bc5a Jul 10, 2026
21 checks passed
@wmadden
wmadden deleted the slice/unify-unique-and-index-nodes branch July 10, 2026 15:53
wmadden-electric added a commit that referenced this pull request Jul 23, 2026
…ntity

Slice-0 reality check: postgres-rls 2.6 merged as #947 keeping SqlUniqueIR
and SqlIndexIR as two structural nodes, rejecting the merged-node-with-flag
shape this spec assumed. Operator confirmed the two-node substrate is the
principled one (discrete-entities: an index must not claim to also be a
constraint; ADR 161 superseding note, Data Contract design principle 4).

Amendments: name identity covers index nodes and policies only; unique
constraints keep tuple identity (fully structured, content comparison is
already exact). @@unique/constraints.unique surfaces unchanged; the @@unique
default wire-prefix is dropped. TS policy exact-naming is out of scope
(rls-ts-authoring was never built; postgres-rls closed in #979).

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden-electric added a commit that referenced this pull request Jul 23, 2026
…ntity

Slice-0 reality check: postgres-rls 2.6 merged as #947 keeping SqlUniqueIR
and SqlIndexIR as two structural nodes, rejecting the merged-node-with-flag
shape this spec assumed. Operator confirmed the two-node substrate is the
principled one (discrete-entities: an index must not claim to also be a
constraint; ADR 161 superseding note, Data Contract design principle 4).

Amendments: name identity covers index nodes and policies only; unique
constraints keep tuple identity (fully structured, content comparison is
already exact). @@unique/constraints.unique surfaces unchanged; the @@unique
default wire-prefix is dropped. TS policy exact-naming is out of scope
(rls-ts-authoring was never built; postgres-rls closed in #979).

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants