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

TML-2536: route on-disk contract reads through ContractSerializer + strict deserializer - #520

Closed
wmadden wants to merge 15 commits into
mainfrom
tml-2536-bug-snapshot-contracts-on-disk-are-read-without
Closed

wmadden wants to merge 15 commits into
mainfrom
tml-2536-bug-snapshot-contracts-on-disk-are-read-without

Conversation

@wmadden

@wmadden wmadden commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-2536.

Related: TML-2512 (prerequisite, already merged — consolidated snapshot reads into readPredecessorEndContract), TML-2537 (follow-up — Postgres-enum layering bleed in family core; notes added there).

At a glance

SqlStorage now refuses on-disk contracts that smuggle untagged polymorphic-storage-type entries past the deserializer, instead of silently stamping them and letting downstream consumers crash later:

function normaliseTypeEntry(entry: unknown, name: string): StorageTypeEntry {
  if (isPostgresEnumStorageEntry(entry)) {
    return entry;
  }
  if (isStorageTypeInstance(entry)) {
    return entry;
  }
  const kind =
    typeof entry === 'object' && entry !== null && 'kind' in entry
      ? String((entry as { kind: unknown }).kind)
      : 'undefined';
  throw new Error(
    `storage.types["${name}"] has missing \`kind\` discriminator or unknown kind="${kind}" — every polymorphic storage.types entry must declare its kind`,
  );
}

Before this PR, prisma-next migration plan against examples/prisma-next-demo crashed with PN-CLI-4999 deep inside the planner because untagged codec triples written by older versions were silently coerced in-memory on the validator path but bypassed entirely on the snapshot-read path. After this PR, the strict throw fires at the family seam regardless of who is loading the contract, the demo's snapshots are regenerated under the strict shape, and a CI gate keeps the demo's migration plan workflow green going forward.

Reviewer notes

Worth knowing before you read the diff:

  • d98d9dc50 (chore(demo): regenerate migration snapshots …) is the largest commit because it replaces three old migration directories under examples/prisma-next-demo/migrations/app/ with a single regenerated 20260516T1816_initial whose start-/end-contract.json files comply with the strict deserializer. The diff looks scarier than it is — it's a 1-for-3 history collapse, not novel migration content. Spot-check Embedding1536 and user_type in the new end-contract.json to confirm both now carry their kind discriminator.
  • The grep-based as Contract lint surfaced ten additional cast sites that weren't on the TML-2536 bypass list (none of them were the JSON.parse(...) as Contract pattern — they were generic narrowing). They're rewritten to as unknown as Contract (the documented escape hatch from .cursor/rules/type-predicates.mdc) in commit f147bbfb6, then commented per the rule's required-comment pattern in ec2fa2576. Two of those ten turned out not to need a cast at all and were dropped — ContractSpaceMember.contract is already typed Contract. Diff is in aggregate/strategies/{graph-walk,synth}.ts.
  • Demo migration plan runs in CI now via a new demo-migration-plan job (commit e74dde07f) that calls pnpm --filter prisma-next-demo migration:plan:check. The check is a semantic JSON-equality diff (not byte-for-byte) because the CLI emits compact JSON and lint-staged pretty-prints — running migration plan against the checked-in history must report ok: true / noOp: true / operations: [].
  • prisma-next-postgis-demo carries the same TML-2536-class bug (WgsGeometry / geometry are untagged) and is explicitly out of scope here — regen needs the Postgis Docker image, and the unattended drive ran without it. The new snapshot-read scan excludes the postgis files with a TODO; follow-up ticket recommended in ## Follow-ups.
  • 5 @prisma-next/adapter-postgres integration tests failed locally during the end-of-round gate run — verified non-regression by reproducing the identical failure set against origin/main and confirming they all need a live local Postgres instance the CI provides. CI will exercise them on push.
  • Project artefacts left on disk: projects/tml-2536-contract-deserializer-seam/ (spec + plan + locally-gitignored reviews/) is the orchestrator's working surface and will be removed at close-out per the project's drive-close-project skill. It is not referenced from any shipped artefact in docs/ or READMEs.
  • wip/unattended-decisions.md records ten orchestrator decisions made on the user's behalf while the loop ran unattended (gitignored; for the user's audit only).

Decision

This PR makes the family ContractSerializer the single seam every on-disk contract read crosses, and makes the seam strict so format drift is loud at every code path simultaneously. Concretely:

  1. Route every CLI on-disk contract read through familyInstance.validateContract. Five bypass sites that previously cast JSON.parse(raw) as Contract (migration-plan, migration-new, migration-apply, migration-show, db-verify) now deserialize through the family seam.
  2. Strip normaliseTypeEntry's permissive fallthrough in sql-storage.ts so an untagged codec triple throws naming the offending entry instead of being silently stamped with kind: 'codec-instance'. The deserializer is now the canonical format-drift alarm.
  3. Regenerate the demo's migration snapshots under the strict deserializer so the checked-in history complies.
  4. Add an as Contract-cast CI lint (pnpm lint:no-contract-cast, wired into lint:deps) that fails on the bypass pattern outside the allowlist.
  5. Rewrite the misleading .cursor/rules/contract-normalization-responsibilities.mdc and add a new as-contract-cast-smell.mdc rule, cross-referenced from the review skills so reviewers flag the smell.
  6. Add a per-polymorphic-kind fixture set + a checked-in *-contract.json snapshot-validation test so any future on-disk shape drift breaks something concrete.
  7. Add a CI job that runs the demo's migration plan workflow so the demo silently rotting in tree (the actual failure mode this bug exposed) is impossible.

No backwards compatibility for the old on-disk shape. Per .cursor/rules/no-backward-compatibility.md we're in 0.x; the demo's old snapshots are regenerated rather than upcast.

How it fits together

The bug lived at the intersection of three things that on their own looked innocent.

  1. The seam exists, but the type system doesn't enforce it. The framework ships a ContractSerializer SPI at packages/1-framework/1-core/framework-components/src/control/contract-serializer.ts whose explicit purpose is to translate between on-disk JSON and in-memory IR. The SQL family implementation at packages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.ts composes arktype structural validation with hydrateSqlStorage. familyInstance.validateContract(json) is the named entry point. But Contract in packages/1-framework/0-foundation/contract/src/contract-types.ts is a structural interface, so JSON.parse(raw) as Contract compiles cleanly. The fix: route every CLI read site through the family seam (commit 9fae5f785 / 551bf2e6e pre-rebase), and add a grep-based lint that fails on the cast pattern outside the allowlist so the next bypass site can't merge by accident (commit bbc2b0dfe).

  2. A silent normaliser in family core was absorbing the legacy shape. SqlStorage's constructor at packages/2-sql/1-core/contract/src/ir/sql-storage.ts called normaliseTypeEntry (~line 100–130). Its fallthrough at line 129 silently stamped kind: 'codec-instance' on untagged codec triples via toStorageTypeInstance(entry as StorageTypeInstanceInput). Every path that went through the deserializer absorbed the old shape — so the migration tests never saw a problem. Only the planner's dispatch on raw entry.kind on the snapshot-read path that bypassed the deserializer hit the missing discriminator and crashed. The fix: strip the fallthrough; throw a diagnostic naming the offending entry and the missing-or-unknown kind (commit ef20acaf9). Unit tests pin the three shapes — tagged codec-instance, postgres-enum, untagged triple — so future polymorphic-slot kinds can't quietly regress.

  3. The demo was the only checked-in artefact that triggered the convergence, and the demo wasn't in CI. No fixture in cli/test/commands/migration-e2e.test.ts built a contract with a polymorphic storage.types entry; the demo did, but its CLI workflow wasn't part of any CI gate. The bug accumulated silently between TML-2512 (which removed the inlined contracts from migration.json and consolidated snapshot reads into readPredecessorEndContract) and TML-2536 surfacing it. The fix, two parts: regenerate the demo's start-/end-contract.json files under the strict deserializer (commit 180c9e8ee); and add a CI job that runs pnpm --filter prisma-next-demo migration:plan:check against the checked-in history on every PR (commit 9fa979af5). For belt-and-braces, add per-polymorphic-kind fixtures + a scan that round-trips every checked-in *-contract.json through the seam (commit 4f51455ec).

The remaining commits are the prevention story: a rewrite of contract-normalization-responsibilities.mdc (the prior version actively misled reviewers by claiming "validators do NOT normalize" while hydrateSqlStorage demonstrably does), a new as-contract-cast-smell.mdc rule, and cross-references from the review skills so the smell catches a reviewer's eye on future PRs (commit ad24df899).

Behavior changes & evidence

  • Untagged polymorphic storage.types entries are now rejected at load time with a diagnostic naming the entry. Implementation: packages/2-sql/1-core/contract/src/ir/sql-storage.ts. Evidence: packages/2-sql/1-core/contract/test/sql-storage.test.ts (three describes: tagged codec-instance accepted, postgres-enum accepted, untagged triple throws with entry name + missing-kind in the message).

  • prisma-next migration plan against the demo is a no-op. Implementation: the demo's regenerated history under examples/prisma-next-demo/migrations/app/20260516T1816_initial/ (the three prior migrations were collapsed into one regenerated initial migration that complies with the strict shape). Evidence: the new examples/prisma-next-demo/scripts/check-migration-plan.ts asserts ok: true / noOp: true / operations: [] and does a semantic JSON-equality diff against the checked-in migrations/**/*.json; wired into a CI job in .github/workflows/ci.yml as demo-migration-plan.

  • All CLI commands that read on-disk contracts now go through familyInstance.validateContract. Implementation: packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts (readPredecessorEndContract takes the validator as a parameter; executeMigrationPlanCommand resolves familyInstance once and reuses it) — and parallel changes in migration-new.ts, migration-apply.ts, migration-show.ts, and db-verify.ts. Evidence: pnpm lint:no-contract-cast returns clean against the tree.

  • A grep-based CI lint catches future as Contract casts. Implementation: scripts/lint-no-contract-cast.mjs (uses a negative-lookbehind regex that filters the documented as unknown as Contract escape hatch but catches the bare as Contract pattern). Wired into pnpm lint:deps. Evidence: try planting const x = JSON.parse(s) as Contract; anywhere in packages/**/src/** outside the allowlist and observe pnpm lint:no-contract-cast exit non-zero.

  • Per-polymorphic-kind fixtures round-trip through the snapshot-read seam. Implementation: packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/ (one fixture file per kind: codec-instance.json, postgres-enum.json). Evidence: snapshot-read-shapes.test.ts loads each fixture, runs it through familyInstance.validateContract, asserts the hydrated shape matches the expected class hierarchy. A separate scan in the same file round-trips every checked-in *-contract.json under examples/** and packages/**/test/**/fixtures/** through the seam (with honest exclusions for the postgis demo + the pre-existing stale basic-contract.json fixture).

  • The misleading normalisation rule is rewritten and a new bypass-smell rule is added. Implementation: .cursor/rules/contract-normalization-responsibilities.mdc (rewritten around "the serializer is the single normalisation seam") and a new .cursor/rules/as-contract-cast-smell.mdc cross-referenced from validate-contract-usage.mdc and from the review skills .agents/skills/drive-code-review/ and .agents/skills/drive-pr-local-review/.

Compatibility / migration / risk

  • On-disk contract shape: breaking, no migration provided. Per the 0.x semver stance + .cursor/rules/no-backward-compatibility.md, untagged codec triples are rejected on load. Existing migration directories built before this PR will fail to load — they need to be re-emitted. The only such artefacts in tree were the demo's migrations, which are regenerated here.
  • postgres-next-postgis-demo is broken by this PR until its migrations are regenerated. Known issue; not blocking; follow-up ticket recommended (see ## Follow-ups).
  • Behavioral compatibility otherwise unchanged. CLI command interfaces unchanged; framework SPI signatures unchanged; family-instance method shape unchanged. The seam-and-strict-throw changes are internal to the read path.

Verification

Ran on the final HEAD (ce0916ed8):

  • pnpm typecheck — PASS (134/134)
  • pnpm lint:deps (including the new lint:no-contract-cast) — PASS, clean
  • pnpm lint:no-contract-cast standalone — PASS, 0 hits
  • pnpm --filter prisma-next-demo migration:plan:check — PASS (ok: true / noOp: true / operations: []; no file drift)
  • pnpm test:packages — 8661 / 8666 PASS. The 5 failures are all in @prisma-next/adapter-postgres integration tests (packages/3-targets/6-adapters/postgres/test/migrations/*.integration.test.ts) that require a live local Postgres instance. Verified non-regression by reproducing the identical failure set against origin/main; CI runs them against the project's Postgres service and will catch any real regression.

Follow-ups

  • Regenerate examples/prisma-next-postgis-demo/migrations/** under the strict deserializer. Needs Postgis Docker image. Will hit PN-CLI-4999 immediately after this PR merges if pnpm prisma-next migration plan is run against that demo. Worth its own ticket — small but env-dependent.
  • Sweep pre-existing transient task-ID leaks out of committed test descriptions. cli/test/commands/migration-tamper.test.ts and a handful of related files reference T3.x / T6.5.2 from a closed-out project — pre-existing per git blame ^57c098183. Worth a small cleanup ticket (sweep **/{src,test}/** for \bT\d+\.\d+(\.\d+)?\b + strip-or-rename describes; optionally add a lint:no-transient-ids script).
  • TML-2515 (back-compat policy for on-disk contracts) is unblocked by this PR's "no back-compat" stance becoming concrete. When TML-2515 lands, the strict throw in normaliseTypeEntry can sprout a real upcaster behind the seam without re-introducing the bypass class.
  • TML-2537 (family-core layering — PostgresEnumStorageEntry + PostgresEnumTypeSchema shouldn't live in SQL family core) already carries the architectural notes from this PR's design discussion; no action here.

Alternatives considered

  • Versioning the contract JSON (a formatRevision field + an upcaster). TML-2536's original proposal. Rejected — adds a back-compat shape to maintain forever, against .cursor/rules/no-backward-compatibility.md and the 0.x stance. Strict + regenerate is cheaper now and a real upcaster can land behind the same seam later when TML-2515 defines the policy.
  • Adding tolerant per-consumer dispatch in contract-to-schema-ir.ts and verify-sql-schema.ts. TML-2536's "wrong-layer" alternative. Rejected for the reasons the ticket itself names — silent miscategorisation; recurring back-compat surface at every consumer.
  • A branded Contract type for compile-time enforcement of the seam. Considered during the design discussion. Rejected — the structural interface Contract is load-bearing across many files and branding it now would cascade into a much larger refactor without changing the actual safety story. The grep-based lint + the smell rule + the review-skill cross-references are the prevention story; if the lint becomes annoying in practice, brand-vs-convention reopens.
  • A narrow envelope-extractor helper (e.g. readContractStorageHash(path): Promise<string>) on the snapshot-read path. Tempting because the CLI bypass sites only need a fraction of the contract data. Rejected — it normalises the "this read is small enough to skip the seam" pattern that enabled the original bug to look innocent in the first place. Paying the deserialize cost on CLI commands is trivial.
  • Fixing the Postgres-enum layering in family core in this PR. Real smell — PostgresEnumStorageEntry is hardcoded into SQL family core, target-specific enum dispatch lives in validators.ts. Pulled out to TML-2537 to keep this PR scoped to the deserializer seam; notes added to that ticket during the design discussion.

Skill update

n/a — internal only. CLI command interfaces, framework SPI signatures, error codes, and user-facing surface are all unchanged. The change is internal hygiene plus a behaviour-tightening of the deserializer that only surfaces if a caller hands it a malformed contract — in which case the diagnostic is more informative than the prior silent-then-crash-elsewhere behaviour.

Checklist

  • All commits are signed off (git commit -s) per the DCO. The DCO status check will block merge if any commit is missing a Signed-off-by: trailer.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated.
  • The PR title is in TML-NNNN: <sentence-case title> form.
  • The Skill update section above is filled in (n/a — internal only).

Summary by CodeRabbit

  • New Features

    • Added migration plan verification check for demo project.
    • Enhanced contract validation enforcement through proper serialization pathways.
  • Bug Fixes

    • Improved contract type normalization with strict discriminator enforcement.
    • Corrected contract validation routing across database commands.
  • Documentation

    • Updated architecture guidance on contract normalization responsibilities.
    • Added code review standards for contract casting patterns.
  • Tests

    • New test coverage for contract deserialization and shape validation.
    • Added storage type normalization test suite.
  • Chores

    • Reorganized example migrations to snapshot-based structure.
    • Added linting script to prevent improper contract casting.

Review Change Stack

@wmadden
wmadden requested a review from a team as a code owner May 16, 2026 19:18
@coderabbitai

coderabbitai Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: ebf1fac7-8e9e-4728-8f0f-149d8e1fbc51

📥 Commits

Reviewing files that changed from the base of the PR and between 3465fea and 92b3c64.

⛔ Files ignored due to path filters (2)
  • projects/tml-2536-contract-deserializer-seam/plans/plan.md is excluded by !projects/**
  • projects/tml-2536-contract-deserializer-seam/spec.md is excluded by !projects/**
📒 Files selected for processing (60)
  • .cursor/rules/as-contract-cast-smell.mdc
  • .cursor/rules/contract-normalization-responsibilities.mdc
  • .cursor/rules/validate-contract-usage.mdc
  • .github/workflows/ci.yml
  • docs/architecture docs/subsystems/7. Migration System.md
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.json
  • examples/prisma-next-demo/migrations/pgvector/contract.d.ts
  • examples/prisma-next-demo/migrations/pgvector/contract.json
  • examples/prisma-next-demo/migrations/pgvector/refs/head.json
  • examples/prisma-next-demo/package.json
  • examples/prisma-next-demo/scripts/check-migration-plan.ts
  • package.json
  • packages/1-framework/0-foundation/contract/src/hashing.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-new.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
  • packages/2-sql/1-core/contract/src/ir/sql-storage.ts
  • packages/2-sql/1-core/contract/test/sql-storage.test.ts
  • packages/2-sql/4-lanes/query-builder/src/root.ts
  • packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts
  • packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
  • packages/3-mongo-target/1-mongo-target/src/core/control-target.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.json
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.json
  • packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/control-target.ts
  • scripts/lint-no-contract-cast.mjs
  • skills-contrib/drive-code-review/SKILL.md
  • skills-contrib/drive-pr-local-review/SKILL.md
💤 Files with no reviewable changes (15)
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
✅ Files skipped from review due to trivial changes (17)
  • skills-contrib/drive-code-review/SKILL.md
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
  • docs/architecture docs/subsystems/7. Migration System.md
  • skills-contrib/drive-pr-local-review/SKILL.md
  • .cursor/rules/validate-contract-usage.mdc
  • examples/prisma-next-demo/migrations/pgvector/contract.d.ts
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.json
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/0-foundation/contract/src/hashing.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.json
  • packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
  • .cursor/rules/as-contract-cast-smell.mdc
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.json
  • examples/prisma-next-demo/migrations/pgvector/refs/head.json
  • examples/prisma-next-demo/migrations/pgvector/contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.json
🚧 Files skipped from review as they are similar to previous changes (19)
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/2-sql/4-lanes/query-builder/src/root.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.ts
  • .github/workflows/ci.yml
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/3-targets/3-targets/sqlite/src/core/control-target.ts
  • packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts
  • packages/3-mongo-target/1-mongo-target/src/core/control-target.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.ts
  • scripts/lint-no-contract-cast.mjs
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.json
  • .cursor/rules/contract-normalization-responsibilities.mdc
  • packages/1-framework/3-tooling/cli/src/commands/migration-new.ts
  • examples/prisma-next-demo/scripts/check-migration-plan.ts

📝 Walkthrough

Walkthrough

This PR establishes contract validation as a single serialization seam by (1) introducing a "cast bypass smell" rule and linting to prevent direct as Contract casts, (2) refactoring all CLI contract reads through familyInstance.validateContract(...) with unified error handling, (3) enforcing strict type discriminators in SqlStorage normalization, and (4) consolidating demo migrations with explicit kind: 'codec-instance' tags and pgvector extension support.

Changes

Contract Validation Seam & Type Safety Enforcement

Layer / File(s) Summary
Cast Bypass Smell Rule & Documentation Links
.cursor/rules/as-contract-cast-smell.mdc, .cursor/rules/validate-contract-usage.mdc, skills-contrib/*
New Cursor rule documents the as Contract anti-pattern, specifies allowlist locations, and integrates into validate-contract usage guide and skill workflow docs for code review surface.
Contract Normalization Responsibilities & Caller Guidance
.cursor/rules/contract-normalization-responsibilities.mdc
Rewritten rule establishes familyInstance.validateContract(...) as the single normalization seam, documents correct patterns for on-disk reads and IR construction with kind-tagged types, and clarifies validation/hydration responsibilities.
CLI Commands Routed Through Validation Seam
packages/1-framework/3-tooling/cli/src/commands/{db-verify,migration-apply,migration-new,migration-plan,migration-show}.ts, packages/1-framework/3-tooling/cli/src/control-api/client.ts, packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
Five CLI entry points now construct control stack + family instance and validate contracts via familyInstance.validateContract(JSON.parse(...) as unknown) instead of direct casting; error handling distinguishes file-read vs. validation failures.
SqlStorage Polymorphic Type Discriminator Enforcement
packages/2-sql/1-core/contract/src/ir/sql-storage.ts, packages/2-sql/1-core/contract/test/sql-storage.test.ts
SqlStorage constructor now enforces strict kind discriminator via normaliseTypeEntry() helper, rejecting untagged codec triples and raw postgres-enum JSON; comprehensive test suite validates six polymorphic dispatch scenarios.
Blind Cast Pattern Standardization & Type Comments
packages/1-framework/0-foundation/contract/src/hashing.ts, packages/1-framework/3-tooling/cli/src/load-ts-contract.ts, packages/2-sql/4-lanes/query-builder/src/root.ts, packages/3-mongo-target/1-mongo-target/src/core/control-target.ts, packages/3-targets/3-targets/{postgres,sqlite}/src/exports/control.ts, packages/1-framework/3-tooling/migration/src/aggregate/strategies/{graph-walk,synth}.ts
Standardizes cast expressions to use as unknown as TargetType blind-cast pattern with explanatory comments throughout the codebase; removes unused Contract imports.
Contract Snapshot Fixtures & Deserialization Test Suite
packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/{codec-instance,postgres-enum}.json, packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts, packages/1-framework/3-tooling/cli/test/commands/{migration-invariants,migration-tamper}.test.ts, packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts, packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
Adds JSON snapshot fixtures for codec-instance and postgres-enum shapes; introduces comprehensive Postgres contract deserialization test suite validating round-trip serialization; updates test mocks to support contract validation seam.
Cast Prevention Linting & Build Integration
scripts/lint-no-contract-cast.mjs, package.json
New CLI script scans packages/**/src/ for forbidden as Contract casts outside allowlist, preprocesses files to avoid false positives in comments/strings, and integrates into npm lint:deps and lint:no-contract-cast scripts.
Demo Migrations Consolidated & Discriminator Tagging
examples/prisma-next-demo/migrations/app/{20260422T*,20260516T1816_initial}/*, examples/prisma-next-demo/package.json
Consolidates obsolete migrations and replaces with new 20260516T1816_initial that adds displayName column, uses createEnumType instead of rawSql, reorders index/foreign-key operations, and tags all storage types with explicit kind: 'codec-instance' discriminators.
pgvector Extension Migration & Namespace Infrastructure
examples/prisma-next-demo/migrations/pgvector/{20260601T0000_install_vector_extension,contract,refs}/*
Adds standalone pgvector extension migration namespace with new migration enabling the vector extension via precheck/execute/postcheck SQL; includes contract skeleton and refs head tracking for extension invariant lifecycle.
Migration Plan No-op Check & CI Integration
examples/prisma-next-demo/scripts/check-migration-plan.ts, .github/workflows/ci.yml
Adds CI guard script validating migration plan is a no-op and detecting on-disk drift; integrates into demo package scripts and new demo-migration-plan CI job that runs on every PR.
Documentation Updates
docs/architecture docs/subsystems/7. Migration System.md
Updates example migration directory structure to show snapshot-based start-contract.json/d.ts and end-contract.json/d.ts pairs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • prisma/prisma-next#499: Tightly related contract-serialization seam work; both PRs touch SqlStorage normalization and the framework's ContractSerializer/validation infrastructure for polymorphic type discrimination.
  • prisma/prisma-next#502: Related to migration pipeline changes; retrieved PR modifies migration manifest structure while this PR routes hydration through validateContract and updates demo migration fixtures.

Suggested reviewers

  • saevarb

Poem

A rabbit hops through types with care,
No casts allowed without a stare,
The seam now guards what flows inside,
With kind discriminators as our guide,
Validation flows where chaos hid! 🐰✨

✨ 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 tml-2536-bug-snapshot-contracts-on-disk-are-read-without

@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 (1)
docs/architecture docs/subsystems/7. Migration System.md (1)

27-31: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Align the introductory directory example with the new start/end snapshot model.

Line 29-Line 30 still show contract.json / contract.d.ts, but the rest of this document now standardizes on start-contract.* and end-contract.*. This creates conflicting guidance in one page.

Suggested doc fix
-    contract.json           # destination contract snapshot
-    contract.d.ts           # TypeScript types for the contract
+    start-contract.json     # source contract snapshot
+    start-contract.d.ts     # TypeScript types for the source contract
+    end-contract.json       # destination contract snapshot
+    end-contract.d.ts       # TypeScript types for the destination contract

As per coding guidelines, "**/*.md: Keep docs current (READMEs, rules, links)".

🤖 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 `@docs/architecture` docs/subsystems/7. Migration System.md around lines 27 -
31, The directory example still lists contract.json and contract.d.ts which
conflicts with the rest of the doc that uses the start/end snapshot naming;
update the example to use start-contract.* and end-contract.* consistently
(e.g., replace contract.json → start-contract.json and end-contract.json and
contract.d.ts → start-contract.d.ts and end-contract.d.ts) and ensure any
references in that snippet or nearby text reflect the new start/end snapshot
model used elsewhere in this document.
🧹 Nitpick comments (1)
.cursor/rules/as-contract-cast-smell.mdc (1)

34-46: ⚡ Quick win

Consider documenting the allowlist maintenance protocol.

The allowlist paths are hardcoded here and must stay in sync with the actual lint script allowlist (presumably in package.json or a separate lint config). Line 46 mentions adding a comment at the call site when extending the allowlist, but doesn't explicitly say "also update this documentation." If someone extends the lint allowlist but forgets to update this doc, the two will drift.

Suggested clarification
-Adding a new allowlisted file requires a comment at the call site explaining why the seam can't be used (typically: the file *is* the seam).
+Adding a new allowlisted file requires:
+1. A comment at the call site explaining why the seam can't be used (typically: the file *is* the seam).
+2. Updating both the lint script allowlist and this documentation to keep them in sync.
🤖 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 @.cursor/rules/as-contract-cast-smell.mdc around lines 34 - 46, Update the
"## Where the cast is allowed (allowlist)" section to explicitly require that
any change to the lint allowlist (the grep-based lint invoked by pnpm
lint:no-contract-cast) must also update this document; extend the existing
sentence "Adding a new allowlisted file requires a comment at the call site..."
to add "and update this allowlist documentation and the lint config (e.g.
package.json or lint config) with the rationale," and add a short checklist or
one-line example showing the required call-site comment format and the doc
update step so future changes stay in sync.
🤖 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 `@docs/architecture` docs/subsystems/7. Migration System.md:
- Around line 27-31: The directory example still lists contract.json and
contract.d.ts which conflicts with the rest of the doc that uses the start/end
snapshot naming; update the example to use start-contract.* and end-contract.*
consistently (e.g., replace contract.json → start-contract.json and
end-contract.json and contract.d.ts → start-contract.d.ts and end-contract.d.ts)
and ensure any references in that snippet or nearby text reflect the new
start/end snapshot model used elsewhere in this document.

---

Nitpick comments:
In @.cursor/rules/as-contract-cast-smell.mdc:
- Around line 34-46: Update the "## Where the cast is allowed (allowlist)"
section to explicitly require that any change to the lint allowlist (the
grep-based lint invoked by pnpm lint:no-contract-cast) must also update this
document; extend the existing sentence "Adding a new allowlisted file requires a
comment at the call site..." to add "and update this allowlist documentation and
the lint config (e.g. package.json or lint config) with the rationale," and add
a short checklist or one-line example showing the required call-site comment
format and the doc update step so future changes stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 6fb697bc-22ce-44a3-a577-cc03a5bba85e

📥 Commits

Reviewing files that changed from the base of the PR and between f79849d and ce0916e.

⛔ Files ignored due to path filters (4)
  • projects/migration-manifest-drop-inline-contracts/plan.md is excluded by !projects/**
  • projects/migration-manifest-drop-inline-contracts/spec.md is excluded by !projects/**
  • projects/tml-2536-contract-deserializer-seam/plans/plan.md is excluded by !projects/**
  • projects/tml-2536-contract-deserializer-seam/spec.md is excluded by !projects/**
📒 Files selected for processing (218)
  • .agents/skills/drive-code-review/SKILL.md
  • .agents/skills/drive-pr-local-review/SKILL.md
  • .cursor/rules/as-contract-cast-smell.mdc
  • .cursor/rules/contract-normalization-responsibilities.mdc
  • .cursor/rules/validate-contract-usage.mdc
  • .github/workflows/ci.yml
  • docs/architecture docs/adrs/ADR 169 - On-disk migration persistence.md
  • docs/architecture docs/subsystems/7. Migration System.md
  • examples/cipherstash-integration/migrations/app/20260512T1716_migration/migration.json
  • examples/cipherstash-integration/migrations/cipherstash/20260601T0000_install_eql_bundle/migration.json
  • examples/mongo-demo/migrations/app/20260409T1030_migration/migration.json
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/migration.json
  • examples/multi-extension-monorepo/packages/audit/migrations/20260601T0000_create_audit_event/migration.json
  • examples/multi-extension-monorepo/packages/feature-flags/migrations/20260601T0000_create_feature_flag/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1200_staging_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260305T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1000_merge_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1100_merge_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1200_merge_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1200_bob_experiment/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1200_bob_experiment_2/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1100_widen_email/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260303T1000_email_default/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260304T1000_change_default/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260305T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260307T1000_kitchen_sink/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260308T1000_rollback/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260326T1428_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/app/20260302T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260305T1000_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1100_late_branch/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260308T1000_add_everything/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1430_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1432_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1100_staging/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260305T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260306T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260306T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1000_merge_1a/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1100_merge_1b/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1100_add_posts_branch/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1000_merge_2a/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1100_merge_2b/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260305T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260306T1000_rollback_to_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1100_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1300_add_category/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1400_add_settings/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.json
  • examples/prisma-next-demo/migrations/pgvector/contract.d.ts
  • examples/prisma-next-demo/migrations/pgvector/contract.json
  • examples/prisma-next-demo/migrations/pgvector/refs/head.json
  • examples/prisma-next-demo/package.json
  • examples/prisma-next-demo/scripts/check-migration-plan.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/migration.json
  • examples/prisma-next-postgis-demo/migrations/postgis/20260601T0000_install_postgis_extension/migration.json
  • examples/retail-store/migrations/app/20260513T0505_initial/migration.json
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.json
  • package.json
  • packages/0-shared/extension-upgrade-skill/upgrades/0.8-to-0.9/instructions.md
  • packages/0-shared/extension-upgrade-skill/upgrades/0.8-to-0.9/strip-inline-contracts.ts
  • packages/0-shared/upgrade-skill/upgrades/0.8-to-0.9/instructions.md
  • packages/0-shared/upgrade-skill/upgrades/0.8-to-0.9/strip-inline-contracts.ts
  • packages/1-framework/0-foundation/contract/src/hashing.ts
  • packages/1-framework/1-core/framework-components/src/control/control-migration-types.ts
  • packages/1-framework/1-core/framework-components/src/control/control-spaces.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-new.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/control-api/types.ts
  • packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-apply.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-e2e.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-plan-command.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-plan.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-ref.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-show.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.ts
  • packages/1-framework/3-tooling/cli/test/control-api/db-init.test.ts
  • packages/1-framework/3-tooling/cli/test/control-api/db-update.test.ts
  • packages/1-framework/3-tooling/cli/test/migration-cli.test.ts
  • packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.test.ts
  • packages/1-framework/3-tooling/migration/README.md
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
  • packages/1-framework/3-tooling/migration/src/errors.ts
  • packages/1-framework/3-tooling/migration/src/hash.ts
  • packages/1-framework/3-tooling/migration/src/io.ts
  • packages/1-framework/3-tooling/migration/src/migration-base.ts
  • packages/1-framework/3-tooling/migration/test/deletable-node-modules.test.ts
  • packages/1-framework/3-tooling/migration/test/fixtures.ts
  • packages/1-framework/3-tooling/migration/test/hash.test.ts
  • packages/1-framework/3-tooling/migration/test/io.test.ts
  • packages/1-framework/3-tooling/migration/test/materialise-extension-migration-package-if-missing.test.ts
  • packages/1-framework/3-tooling/migration/test/materialise-migration-package.test.ts
  • packages/1-framework/3-tooling/migration/test/migration-base.test.ts
  • packages/2-sql/1-core/contract/src/ir/sql-storage.ts
  • packages/2-sql/1-core/contract/test/sql-storage.test.ts
  • packages/2-sql/4-lanes/query-builder/src/root.ts
  • packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts
  • packages/2-sql/9-family/src/core/migrations/types.ts
  • packages/3-extensions/cipherstash/migrations/20260601T0000_install_eql_bundle/migration.json
  • packages/3-extensions/paradedb/migrations/20260601T0000_install_pg_search_extension/migration.json
  • packages/3-extensions/pgvector/migrations/20260601T0000_install_vector_extension/migration.json
  • packages/3-extensions/pgvector/migrations/20260601T0000_install_vector_extension/migration.ts
  • packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
  • packages/3-extensions/postgis/migrations/20260601T0000_install_postgis_extension/migration.json
  • packages/3-extensions/postgis/migrations/20260601T0000_install_postgis_extension/migration.ts
  • packages/3-mongo-target/1-mongo-target/src/core/control-target.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.json
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.json
  • packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/control-target.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/db-init-update.cli.integration.test.ts
  • packages/3-targets/6-adapters/sqlite/test/migrations/db-init-update.cli.test.ts
  • scripts/lint-no-contract-cast.mjs
  • test/integration/test/contract-space-fixture-mongo/migrations.ts
  • test/integration/test/contract-space-fixture/migrations.ts
  • test/integration/test/extension-pgvector-scenario-a.e2e.integration.test.ts
💤 Files with no reviewable changes (113)
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260304T1000_change_default/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260305T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1200_merge_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260306T1000_add_posts/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260306T1000_rollback_to_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1100_add_posts_branch/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260307T1000_kitchen_sink/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1000_merge_1a/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260305T1000_add_tags/migration.json
  • examples/prisma-next-demo/migration-fixtures/single-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260305T1000_add_tags/migration.json
  • examples/mongo-demo/migrations/app/20260409T1030_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1100_widen_email/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1300_add_category/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1100_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1400_add_settings/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260308T1000_rollback/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260326T1428_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1100_staging/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260303T1000_email_default/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1100_merge_1b/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1000_merge_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1200_staging_posts/migration.json
  • examples/multi-extension-monorepo/packages/audit/migrations/20260601T0000_create_audit_event/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260306T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1432_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260305T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260303T1000_add_bio/migration.json
  • examples/multi-extension-monorepo/packages/feature-flags/migrations/20260601T0000_create_feature_flag/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260304T1000_rollback_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260306T1000_rollback_to_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260308T1000_add_everything/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_foobar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1200_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1430_migration/migration.json
  • examples/prisma-next-demo/migration-fixtures/multi-branch/app/20260303T1000_add_bio/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/complex/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1000_merge_2a/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback/app/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1000_add_comments/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260305T1000_rollback_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260305T1000_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1200_bob_experiment/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1200_bob_experiment_2/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260304T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1100_late_branch/migration.json
  • examples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1100_merge_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1100_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/linear/app/20260302T1000_add_posts/migration.json
  • examples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1000_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1100_merge_2b/migration.json

@wmadden
wmadden force-pushed the tml-2536-bug-snapshot-contracts-on-disk-are-read-without branch from ce0916e to 230d8a0 Compare May 16, 2026 21:07
@pkg-pr-new

pkg-pr-new Bot commented May 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/extension-cipherstash

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-cipherstash@520

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 92b3c64

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (2)
packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts (1)

80-97: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Wrap malformed predecessor snapshots in the contract-validation envelope.

If end-contract.json is syntactically invalid or fails validateContract, this helper throws a raw error and Lines 270-289 rewrap it as errorUnexpected(...). That loses the contract-validation exit path and the specific snapshot path, even though this is another strict on-disk contract boundary.

🩹 Suggested fix
 async function readPredecessorEndContract(
   migrationDir: string,
   validateContract: (json: unknown) => Contract,
 ): Promise<Contract> {
   const path = join(migrationDir, 'end-contract.json');
   let raw: string;
   try {
     raw = await readFile(path, 'utf-8');
   } catch (error) {
     if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
       throw errorFileNotFound(path, {
         why: `Predecessor migration is missing its destination contract snapshot at ${path}`,
         fix: 'Re-emit the predecessor migration (`prisma-next migration plan` from its source) so its sibling `end-contract.json` is restored, then re-run this command.',
       });
     }
     throw error;
   }
-  return validateContract(JSON.parse(raw) as unknown);
+  try {
+    return validateContract(JSON.parse(raw) as unknown);
+  } catch (error) {
+    throw errorContractValidationFailed(
+      `Contract validation failed: ${error instanceof Error ? error.message : String(error)}`,
+      { where: { path } },
+    );
+  }
 }
🤖 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/1-framework/3-tooling/cli/src/commands/migration-plan.ts` around
lines 80 - 97, readPredecessorEndContract currently parses and validates
end-contract.json but lets JSON.parse or validateContract errors bubble up raw;
catch parsing/validation errors inside readPredecessorEndContract and rethrow
them using the same contract-validation envelope (e.g., call errorUnexpected or
the project's contract/error wrapper used elsewhere) so the error includes the
snapshot path and consistent exit handling; specifically wrap the JSON.parse and
validateContract call in a try/catch and on error throw the envelope with the
path, a helpful why/fix message, and the original error attached, referencing
readPredecessorEndContract and validateContract to locate where to add the catch
and rethrow.
packages/2-sql/1-core/contract/src/ir/sql-storage.ts (1)

127-153: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Tighten the public types input surface to match this strict branch.

normaliseTypeEntry() now rejects raw codec triples, but SqlStorageTypeEntry / SqlStorageInput.types still advertise StorageTypeInstanceInput as valid. That leaves callers with compile-time success for { codecId, nativeType, typeParams } entries that now always fail at runtime here.

🩹 Suggested follow-up
-export type SqlStorageTypeEntry =
-  | StorageTypeInstance
-  | PostgresEnumStorageEntry
-  | StorageTypeInstanceInput;
+export type SqlStorageTypeEntry =
+  | StorageTypeInstance
+  | PostgresEnumStorageEntry;

Also update the nearby docblocks so they stop promising that SqlStorage stamps kind: 'codec-instance' during construction.

Based on learnings: Contract builder and PSL interpreter must author contracts in the canonical shape, where every storage.types[*] entry carries its kind discriminator at authoring time.

🤖 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/contract/src/ir/sql-storage.ts` around lines 127 - 153,
normaliseTypeEntry now rejects raw codec-triples at runtime, but the public
input types still allow them, so update the public type surface and docs to
require the discriminator at compile time: change SqlStorageTypeEntry and the
SqlStorageInput.types declaration to disallow StorageTypeInstanceInput/raw codec
triples and instead only accept the canonical shapes (PostgresEnumStorageEntry
or StorageTypeInstance with kind present), update docblocks near SqlStorage to
stop promising automatic stamping of kind:'codec-instance', and add guidance to
callers to use toStorageTypeInstance(...) before constructing any storage.types
entries; touch the definitions and nearby comments so TypeScript will reject the
old {codecId, nativeType, typeParams} shape and normaliseTypeEntry is consistent
with the types and docs.
🤖 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.

Inline comments:
In `@examples/prisma-next-demo/scripts/check-migration-plan.ts`:
- Around line 38-43: The script calls execFileSync in check-migration-plan.ts to
run the CLI (cliEntry, 'migration', 'plan') and then JSON.parse(stdout) without
guaranteeing JSON output; modify the argument list passed to execFileSync to
include the explicit '--json' flag (i.e., invoke cliEntry with 'migration',
'plan', '--json') so the command emits deterministic JSON, then keep the
JSON.parse(stdout) behavior unchanged; update the args array in the execFileSync
call in this file accordingly.

In `@packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts`:
- Around line 106-122: The path filtering uses node:path's relative which yields
backslashes on Windows and breaks the string includes/startsWith checks; replace
the node:path import with pathe and call pathe.relative(...) (keep REPO_ROOT and
the rel variable) so rel is normalized to forward slashes and the existing
checks (includes/startsWith for the migration and fixture paths) work
cross-platform; update the import at the top of snapshot-read-shapes.test.ts to
import relative from 'pathe' and leave the rest of the filter logic unchanged.

---

Outside diff comments:
In `@packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts`:
- Around line 80-97: readPredecessorEndContract currently parses and validates
end-contract.json but lets JSON.parse or validateContract errors bubble up raw;
catch parsing/validation errors inside readPredecessorEndContract and rethrow
them using the same contract-validation envelope (e.g., call errorUnexpected or
the project's contract/error wrapper used elsewhere) so the error includes the
snapshot path and consistent exit handling; specifically wrap the JSON.parse and
validateContract call in a try/catch and on error throw the envelope with the
path, a helpful why/fix message, and the original error attached, referencing
readPredecessorEndContract and validateContract to locate where to add the catch
and rethrow.

In `@packages/2-sql/1-core/contract/src/ir/sql-storage.ts`:
- Around line 127-153: normaliseTypeEntry now rejects raw codec-triples at
runtime, but the public input types still allow them, so update the public type
surface and docs to require the discriminator at compile time: change
SqlStorageTypeEntry and the SqlStorageInput.types declaration to disallow
StorageTypeInstanceInput/raw codec triples and instead only accept the canonical
shapes (PostgresEnumStorageEntry or StorageTypeInstance with kind present),
update docblocks near SqlStorage to stop promising automatic stamping of
kind:'codec-instance', and add guidance to callers to use
toStorageTypeInstance(...) before constructing any storage.types entries; touch
the definitions and nearby comments so TypeScript will reject the old {codecId,
nativeType, typeParams} shape and normaliseTypeEntry is consistent with the
types and docs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 655e93fc-7f2d-4eb5-a296-386ff03210b4

📥 Commits

Reviewing files that changed from the base of the PR and between ce0916e and 230d8a0.

⛔ Files ignored due to path filters (2)
  • projects/tml-2536-contract-deserializer-seam/plans/plan.md is excluded by !projects/**
  • projects/tml-2536-contract-deserializer-seam/spec.md is excluded by !projects/**
📒 Files selected for processing (59)
  • .agents/skills/drive-code-review/SKILL.md
  • .agents/skills/drive-pr-local-review/SKILL.md
  • .cursor/rules/as-contract-cast-smell.mdc
  • .cursor/rules/contract-normalization-responsibilities.mdc
  • .cursor/rules/validate-contract-usage.mdc
  • .github/workflows/ci.yml
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.ts
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.json
  • examples/prisma-next-demo/migrations/pgvector/contract.d.ts
  • examples/prisma-next-demo/migrations/pgvector/contract.json
  • examples/prisma-next-demo/migrations/pgvector/refs/head.json
  • examples/prisma-next-demo/package.json
  • examples/prisma-next-demo/scripts/check-migration-plan.ts
  • package.json
  • packages/1-framework/0-foundation/contract/src/hashing.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-apply.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-new.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts
  • packages/1-framework/3-tooling/cli/src/commands/migration-show.ts
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.ts
  • packages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
  • packages/2-sql/1-core/contract/src/ir/sql-storage.ts
  • packages/2-sql/1-core/contract/test/sql-storage.test.ts
  • packages/2-sql/4-lanes/query-builder/src/root.ts
  • packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts
  • packages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.ts
  • packages/3-mongo-target/1-mongo-target/src/core/control-target.ts
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.json
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.json
  • packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/control-target.ts
  • scripts/lint-no-contract-cast.mjs
💤 Files with no reviewable changes (15)
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
✅ Files skipped from review due to trivial changes (17)
  • examples/prisma-next-demo/migrations/pgvector/refs/head.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.json
  • examples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.json
  • packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.json
  • examples/prisma-next-demo/package.json
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
  • examples/prisma-next-demo/migrations/pgvector/contract.d.ts
  • packages/2-sql/5-runtime/test/sql-context.codec-context.test.ts
  • packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
  • examples/prisma-next-demo/migrations/pgvector/contract.json
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.json
  • packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
  • .cursor/rules/as-contract-cast-smell.mdc
  • packages/3-targets/3-targets/postgres/src/exports/control.ts
  • .agents/skills/drive-pr-local-review/SKILL.md
  • examples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • .agents/skills/drive-code-review/SKILL.md
  • .cursor/rules/validate-contract-usage.mdc
  • .cursor/rules/contract-normalization-responsibilities.mdc
  • .github/workflows/ci.yml

@wmadden

wmadden commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

Addressing the four CodeRabbit outside-diff findings:

  • docs/architecture docs/subsystems/7. Migration System.md (27-31) — fixed in 992464b; the directory example now uses start-contract.* / end-contract.* consistently with the rest of the page.
  • .cursor/rules/as-contract-cast-smell.mdc (34-46) — fixed in aab2fdd; the maintenance protocol now explicitly requires updating the rule doc, the lint script (scripts/lint-no-contract-cast.mjs), and the call-site comment together when extending the allowlist.
  • packages/1-framework/3-tooling/cli/src/commands/migration-plan.ts (80-97) — fixed in 3465fea; readPredecessorEndContract now wraps JSON.parse + validateContract failures in errorContractValidationFailed({ where: { path } }), matching the envelope the destination contract uses a few lines above.
  • packages/2-sql/1-core/contract/src/ir/sql-storage.ts (127-153) — not addressed in this PR. The finding is valid — the public SqlStorageTypeEntry / SqlStorageInput.types still admit untagged StorageTypeInstanceInput codec triples that normaliseTypeEntry() now throws on at runtime — but tightening that type ripples into every call-site that constructs SqlStorage (in-package tests, contract builder, PSL interpreter) and is a coordinated in-memory-authoring change separable from the on-disk-read seam scoped to TML-2536. Captured as TML-2545 with the full fix shape; the runtime guard in normaliseTypeEntry() stays in place as defence in depth in the meantime.

wmadden added 15 commits May 18, 2026 16:51
Route every on-disk contract read in the CLI through familyInstance.validateContract,
strip the SQL family's silent shape-coercion in normaliseTypeEntry so the deserializer
is strict, and close the test gap that let the demo's migration history rot without
any CI alarm. Single milestone; single PR; no backwards compatibility for old on-disk
contract shapes (per 0.x semver stance + .cursor/rules/no-backward-compatibility.md).

Linked: TML-2536, TML-2512 (consolidated snapshot reads — already merged),
TML-2537 (family-core layering cleanup — out of scope here; notes added there).

Signed-off-by: Will Madden <[email protected]>
…(m1 T1.1-T1.7)

Every CLI command that loads a contract.json from disk now hydrates
it through `familyInstance.validateContract` rather than a
`JSON.parse(...) as Contract` cast. That guarantees the polymorphic
`storage.types` slot crosses the family `ContractSerializer` — and
its discriminator dispatch — at every on-disk boundary, fixing the
class of bugs where untagged entries silently slipped past the
serializer (TML-2536) and crashed downstream IR consumers.

Affects `migration apply`, `migration new`, `migration plan`,
`migration show`, and `db-verify`. The redundant downstream
`validateContract` call in `migration plan` (phase 2) is collapsed
into the single up-front seam.

Test mocks updated where the loader returned a bare `{}` family
instance: a pass-through `validateContract` stub keeps the
non-validation-focused tamper / invariant tests exercising the
behaviour they target.

Signed-off-by: Will Madden <[email protected]>
… T1.8-T1.9)

Untagged inputs to the polymorphic `SqlStorage.types` slot used to
fall through to `toStorageTypeInstance`, silently stamping
`kind: "codec-instance"` on whatever the caller passed. That hid the
TML-2536 class of bugs: snapshot-read paths that bypass the
serializer dispatch on `entry.kind`, see `undefined`, and crash.

`normaliseTypeEntry` now throws when an entry matches neither
`isPostgresEnumStorageEntry` nor `isStorageTypeInstance`. The
diagnostic names the slot key and either reports the missing `kind`
or echoes the unrecognised value, so the failure points the author
at the fix (wrap untagged codec triples with
`toStorageTypeInstance(...)` before construction).

In-tree authoring paths already produce tagged entries; two test
fixtures (pgvector planner, sql-runtime codec-context) authored
untagged codec triples and now declare the discriminator
explicitly.

Signed-off-by: Will Madden <[email protected]>
… (m1 T1.10)

The on-disk `end-contract.json` snapshots under
`examples/prisma-next-demo/migrations/app/` carried untagged
polymorphic `storage.types` entries (`Embedding1536`, `user_type`),
the shape that pre-dated the family `ContractSerializer` enforcing
`kind` discriminators. With the strict `normaliseTypeEntry` landed
in the previous commit and every CLI on-disk read now routed through
`familyInstance.validateContract`, the old shape no longer
round-trips — re-running `migration plan` on the demo crashed with
PN-CLI-4999 (the TML-2536 bug).

Replaced the divergent three-migration chain (its tail `to` hash had
drifted from the live `src/prisma/contract.json`) with one
freshly-emitted initial migration whose `end-contract.json` matches
the current emitted contract exactly. `migration plan` against the
demo is now a no-op (`AC-4`); the pgvector extension space and its
materialised install-vector migration are committed alongside.

Signed-off-by: Will Madden <[email protected]>
…ontract scan (m1 T1.11-T1.12)

Closes the test gap that hid TML-2536. Two complementary nets:

- Per-polymorphic-`storage.types`-kind fixtures
  (`codec-instance.json`, `postgres-enum.json`) round-trip through
  the family `ContractSerializer` and pin the IR-class output shape
  for each kind. Adding a third fixture is the canonical way to
  extend coverage when a new entity-type discriminator enters the
  family registry.

- A repo-wide snapshot scan loads every checked-in `contract.json` /
  `*-contract.json` under `examples/` (filtered to Postgres-shaped
  envelopes) and asserts each one deserializes without throwing.
  Two pre-existing TML-2536-class shape drifts surfaced and are
  excluded with explicit comments + tracked as follow-ups:
  `examples/prisma-next-postgis-demo/migrations/` (regeneration
  needs a DATABASE_URL) and `examples/prisma-next-demo/test/
  fixtures/basic-contract.json` (unrelated stale fixture).

Signed-off-by: Will Madden <[email protected]>
… smell rule (m1 T1.13-T1.15)

Three coordinated doc moves:

- Rewrote .cursor/rules/contract-normalization-responsibilities.mdc.
  The earlier text asserted "the validator does NOT normalize" — a
  stance that pre-dated the family ContractSerializer landing.
  Today the validator and the IR-class hydrator live behind the
  single named familyInstance.validateContract seam, and every
  on-disk read is required to cross it. The rule now describes the
  actual seam: structural validation + IR-class hydration happen
  together, the contract builder and PSL interpreter author the
  canonical shape directly, and the CLI may not bypass the seam.

- Added .cursor/rules/as-contract-cast-smell.mdc. Declares
  JSON.parse(...) as Contract in packages/**/src/** (outside an
  allowlist of test files + serializer implementation files) a
  serializer-bypass smell, with the explicit replacement idiom
  validateContract<Contract>(JSON.parse(raw) as unknown). Cross-
  linked from validate-contract-usage.mdc. Distinct from the
  as unknown as X policy in type-predicates.mdc (the single-step
  as Contract is the failure mode TML-2536 cost us).

- Wired the smell into drive-code-review and drive-pr-local-review
  via a new "Smells to surface" subsection in the
  principal-engineer-pass boundary, so reviewers flag the smell with
  the rule cross-reference during local PR review.

Signed-off-by: Will Madden <[email protected]>
…m1 T1.16)

New `scripts/lint-no-contract-cast.mjs` walks `packages/**` `src/`
trees and fails on `as Contract` casts that bypass the family
ContractSerializer seam. Strips comments + string literals before
matching (so JSDoc and prose mentions of the smell pattern do not
register), and explicitly allows the documented
`as unknown as Contract` blind-cast escape hatch from
`.cursor/rules/type-predicates.mdc`. The serializer implementation
files themselves are allowlisted by path fragment — those files are
the seam.

Wired into the existing `lint:deps` script (which the CI lint job
already runs) and exposed as `pnpm lint:no-contract-cast` for local
ad-hoc invocation.

The lint surfaced ten pre-existing `as Contract` casts in production
code. None matched the original TML-2536 bypass pattern
(`JSON.parse(...) as Contract`) — they were all type-widening or
generic-narrowing on already-validated Contract values. Refactored
each to the documented `as unknown as Contract` form so the lint is
clean from day one:

- packages/1-framework/0-foundation/contract/src/hashing.ts
- packages/1-framework/3-tooling/cli/src/control-api/client.ts
- packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
- packages/1-framework/3-tooling/cli/src/load-ts-contract.ts
- packages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.ts
- packages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.ts
- packages/2-sql/4-lanes/query-builder/src/root.ts
- packages/3-mongo-target/1-mongo-target/src/core/control-target.ts
- packages/3-targets/3-targets/postgres/src/exports/control.ts
- packages/3-targets/3-targets/sqlite/src/core/control-target.ts

Signed-off-by: Will Madden <[email protected]>
TML-2536 crashed `prisma-next migration plan` against
`examples/prisma-next-demo` and went undetected end-to-end because
the demo workflow was not in CI. This commit adds that gate:

- `examples/prisma-next-demo/scripts/check-migration-plan.ts` runs
  the CLI against the demo, asserts the plan JSON has `ok: true`,
  `noOp: true`, and an empty `operations` array, and performs a
  semantic JSON-equality diff against every checked-in
  `migrations/**/*.json` file to flag drift. Semantic compare (not
  byte-for-byte) intentionally absorbs whitespace-only deltas in
  `refs/head.json` (lint-staged reformats the initial pretty-printed
  generation; the CLI re-emits in compact form on each run). Wired
  into the demo as `pnpm migration:plan:check`.

- New `demo-migration-plan` GitHub Actions job in `ci.yml` builds
  the CLI binary, links workspace bins, and invokes the new script.
  Depends on `build`. The job comment names TML-2536 so future
  readers see why the gate exists.

Signed-off-by: Will Madden <[email protected]>
Sweep across the m1 diff for any other `T1.\d+` strings in test or
source files was clean — only this one site.

Signed-off-by: Will Madden <[email protected]>
Eight of the ten as-unknown-as-Contract sites landed in f147bbfb6
now carry a site-specific rationale comment explaining why the
blind cast is safe — the policy in AGENTS.md (and the spirit of
type-predicates.mdc) is that the escape hatch is acceptable only
when the rationale is greppable. Each rationale points at either
the framework SPI signature that forces the wider type, the
upstream validation seam that has already proved the structural
shape, or the public overload set that statically constrains the
caller (in the case of the query-builder `createRoot` impl-body
cast). The hashing helper synthesises a hash-only stand-in that
never escapes the function and is documented as such.

The remaining two of the ten (graph-walk.ts and synth.ts in
migration-tools) turned out not to need any cast at all once
re-inspected — `ContractSpaceMember.contract` is already typed as
`Contract`, so I dropped the cast (and the now-unused `Contract`
type imports) in those two files. The original `as Contract` was a
relic from when the field was typed more loosely; tsc agrees the
direct assignment is sound.

Signed-off-by: Will Madden <[email protected]>
… gate

The check-migration-plan.ts CI gate parses CLI stdout as JSON but did not pass `--json`. It only worked because `parseGlobalFlags` auto-enables JSON output when stdout is not a TTY. Making the flag explicit removes the hidden coupling and brings the invocation in line with every other CI script in tree.

Signed-off-by: Will Madden <[email protected]>
…test

The TML-2536 snapshot-read scan filters by repository-relative path (e.g. `rel.includes("/migrations/cipherstash/")`). On Windows, `relative()` from `node:path` returns backslash-separated paths and the filters silently fail. Swapping to `pathe` normalises to forward slashes on every platform; this matches the workspace `use-pathe-for-paths` cursor rule.

Signed-off-by: Will Madden <[email protected]>
The "Migration System" subsystem doc still showed `contract.json` / `contract.d.ts` in its overview directory snippet while the rest of the page already describes the start-/end-contract snapshot model that TML-2536 makes canonical. Bring the example in line so the page is internally consistent.

Signed-off-by: Will Madden <[email protected]>
The allowlist of `as Contract` cast call-sites is duplicated in two places (`scripts/lint-no-contract-cast.mjs` and this rule). Anyone extending the lint can plausibly update one and forget the other. Reword the maintenance protocol so the requirement to update both — plus the call-site comment — is explicit, not implied.

Signed-off-by: Will Madden <[email protected]>
…tion envelope

Until now, a malformed or schema-rejected predecessor `end-contract.json` would bubble a raw `JSON.parse`/arktype error out of `readPredecessorEndContract`. The call-site catch maps it through `errorUnexpected(...)`, which loses both the contract-validation exit class and the offending snapshot path.

Wrap the parse + validate pair in a try/catch that re-throws `errorContractValidationFailed({ where: { path } })`, matching the envelope the destination contract uses a few lines above. After this change every on-disk contract read in this command surfaces failures through the same structured path.

Signed-off-by: Will Madden <[email protected]>
@wmadden
wmadden force-pushed the tml-2536-bug-snapshot-contracts-on-disk-are-read-without branch from 3465fea to 92b3c64 Compare May 18, 2026 14:51
@wmadden

wmadden commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #533 — re-cut as a smaller, dispatch-decomposed PR against current origin/main (the original branch became unrebaseable due to overlapping CLI refactors). Same scope (CLI seam closure + strict deserializer + lint guard + demo CI gate + upgrade entries for both end-users and extension authors + manual QA), cleaner history. Branch tml-2536-contract-deserializer-seam is preserved for reference but not for merge.

@wmadden wmadden closed this May 18, 2026
wmadden added a commit that referenced this pull request May 19, 2026
Re-apply the drive-qa-plan skill against the shipped state of PR #533
(branch `tml-2536-contract-deserializer-seam-v2`) — the previous draft
was written in D4 against the now-superseded PR #520 and predated D5
(demo CI gate, lint guard, namespaces-bookend migration) and D6
(rationale comments).

What changed:

- Header now points at PR #533 and frames both audiences (CLI users +
  extension authors) up-front; the implementation-history bullet list
  in "What this script is testing" mentions the shipped guardrails by
  their concrete names (`lint:no-contract-cast`, the
  `Demo `migration plan` (no-op)` CI job, `stamp-storage-types-kind.ts`).
- Added an Isolation column to the TOC and an explicit `Isolation` line
  to every scenario (and the exploratory charter), tagging each with the
  strictest tag it actually needs: `workspace` for DB / tree mutators,
  `read-only` for the rule-coherence pass, `external` for the
  `gh pr checks` scenario.
- Added "Preconditions: no prerequisite scenarios" / "Scenario N
  completed" lines so the runner has explicit DAG edges (Scenario 2
  depends on 1; Scenario 8 depends on 1 or 3; everything else is
  independent).
- Stripped every severity pre-classification (🛑 Blocker / ⚠️ High /
  📝 Follow-up) from failure-mode lists in Scenarios 9, 10, 11. The
  script now enumerates failure-mode categories only; severity belongs
  in the runner report.
- Updated Scenario 4 (negative control for the strict deserializer) to
  target `migrations/app/20260518T1701_namespaces_bookend/end-contract.json`
  — the head migration that the planner now reads as the predecessor
  snapshot after D5's bookend addition. The old target
  (`20260422T0720_initial`) no longer exercises the predecessor-read
  path on its own.
- Updated Scenario 3 to apply the *full* checked-in history (initial
  plus bookend) and `migration show` both, so the re-enactment touches
  the literal pre-bug artefact and the new head.
- Updated Scenario 7 to reference PR #533 instead of #520 and to name
  the actual CI job display name (`Demo `migration plan` (no-op)`).
- Updated Scenario 10's oracle and step 8 expectations: the demo
  `migration plan` is now a *clean* no-op end-to-end (D5's namespaces
  bookend closed the residual TML-2521 drift), so the prior "you may
  still see PN-CLI-4020" carve-out is gone — any non-zero / non-no-op
  envelope is now a finding.
- Pre-flight now uses the workspace-canonical CLI invocation
  (`node ../../packages/.../cli.js`) the rest of the script already
  uses, so the demo-rooted scenarios all read the same way.
- "Scenarios deliberately not in this script" now explicitly excludes
  the static-pass half of AC-2 / AC-8 (re-running the lint over a clean
  tree) and AC-11; the sign-off coverage map maps AC-2 to Scenario 5
  (the gate-of-gate negative control) and points the AC-11 row at the
  exclusion table.

No scenarios were deleted under the litmus test — every existing
scenario already fell into one of the six legitimate buckets. Each
scenario now names which bucket it falls under so the runner can
quickly verify the script's honesty.

Scope is script-revision only: no spec / plan / source / CI / skill
changes. The runner skill (`drive-qa-run`) drives the script and owns
the report.
wmadden added a commit that referenced this pull request May 19, 2026
Re-apply the drive-qa-plan skill against the shipped state of PR #533
(branch `tml-2536-contract-deserializer-seam-v2`) — the previous draft
was written in D4 against the now-superseded PR #520 and predated D5
(demo CI gate, lint guard, namespaces-bookend migration) and D6
(rationale comments).

What changed:

- Header now points at PR #533 and frames both audiences (CLI users +
  extension authors) up-front; the implementation-history bullet list
  in "What this script is testing" mentions the shipped guardrails by
  their concrete names (`lint:no-contract-cast`, the
  `Demo `migration plan` (no-op)` CI job, `stamp-storage-types-kind.ts`).
- Added an Isolation column to the TOC and an explicit `Isolation` line
  to every scenario (and the exploratory charter), tagging each with the
  strictest tag it actually needs: `workspace` for DB / tree mutators,
  `read-only` for the rule-coherence pass, `external` for the
  `gh pr checks` scenario.
- Added "Preconditions: no prerequisite scenarios" / "Scenario N
  completed" lines so the runner has explicit DAG edges (Scenario 2
  depends on 1; Scenario 8 depends on 1 or 3; everything else is
  independent).
- Stripped every severity pre-classification (🛑 Blocker / ⚠️ High /
  📝 Follow-up) from failure-mode lists in Scenarios 9, 10, 11. The
  script now enumerates failure-mode categories only; severity belongs
  in the runner report.
- Updated Scenario 4 (negative control for the strict deserializer) to
  target `migrations/app/20260518T1701_namespaces_bookend/end-contract.json`
  — the head migration that the planner now reads as the predecessor
  snapshot after D5's bookend addition. The old target
  (`20260422T0720_initial`) no longer exercises the predecessor-read
  path on its own.
- Updated Scenario 3 to apply the *full* checked-in history (initial
  plus bookend) and `migration show` both, so the re-enactment touches
  the literal pre-bug artefact and the new head.
- Updated Scenario 7 to reference PR #533 instead of #520 and to name
  the actual CI job display name (`Demo `migration plan` (no-op)`).
- Updated Scenario 10's oracle and step 8 expectations: the demo
  `migration plan` is now a *clean* no-op end-to-end (D5's namespaces
  bookend closed the residual TML-2521 drift), so the prior "you may
  still see PN-CLI-4020" carve-out is gone — any non-zero / non-no-op
  envelope is now a finding.
- Pre-flight now uses the workspace-canonical CLI invocation
  (`node ../../packages/.../cli.js`) the rest of the script already
  uses, so the demo-rooted scenarios all read the same way.
- "Scenarios deliberately not in this script" now explicitly excludes
  the static-pass half of AC-2 / AC-8 (re-running the lint over a clean
  tree) and AC-11; the sign-off coverage map maps AC-2 to Scenario 5
  (the gate-of-gate negative control) and points the AC-11 row at the
  exclusion table.

No scenarios were deleted under the litmus test — every existing
scenario already fell into one of the six legitimate buckets. Each
scenario now names which bucket it falls under so the runner can
quickly verify the script's honesty.

Scope is script-revision only: no spec / plan / source / CI / skill
changes. The runner skill (`drive-qa-run`) drives the script and owns
the report.

Signed-off-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 19, 2026
…rios

Forks the manual-QA script from the predecessor branch onto v2 and
extends it for the re-cut + the new upgrade-instructions scope:

- Migration directory references updated for the v2 demo layout
  (`20260422T0720_initial` ×3 packages, not the old predecessor
  branch's `20260516T1816_initial`).
- Branch / PR pre-flight updated to point at the re-cut branch and
  flag PR #520's closure.
- "What this script is testing" block now covers four changes (not
  three), naming the upgrade-instructions skill entries as fix #4.
- "Why manual QA matters here" extended to add the
  upgrade-instructions intent as a sixth gap the scripted gates
  don't close.

Adds two new upgrade-journey scenarios per the slice plan's D4 +
calibration § 9.1 ("the script must name both prisma-next QA
audiences when shipping a breaking change"):

- Scenario 10 — End-user upgrade journey via the `prisma-next-upgrade`
  0.9→0.10 entry. Steps: stash the codemod-applied state to reproduce
  the pre-codemod TML-2536 deserializer crash; read the user-skill
  prose cold; run the codemod in `--check` mode; apply; confirm
  substrate equals PR-branch state (validation-by-execution proof);
  idempotency re-run; confirm the deserializer crash is gone. Failure
  modes severity-classified per scenario step.
- Scenario 11 — Extension-author upgrade journey via the
  `prisma-next-extension-upgrade` 0.9→0.10 entry. Uses pgvector as the
  representative third-party extension substrate. Steps: enumerate
  the extension's `SqlStorage`-touching source; read the extension-
  skill prose cold; confirm baseline tests pass; codemod against
  any seed snapshots; optional structural-falsifier plant to verify
  the `SqlStorage` constructor diagnostic fires cleanly.

Sign-off coverage map appended with two non-numbered rows for the
upgrade-instructions intent (one per audience), with a note that the
calibration document explicitly requires naming both audiences for a
breaking change.

The script is the planner artefact for `drive-qa-run`; the runner
produces the report with severity-classified findings. This commit
ships the plan; running it + producing the report is the slice DoD's
manual-QA bullet, satisfied at D7.

Signed-off-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 19, 2026
Re-apply the drive-qa-plan skill against the shipped state of PR #533
(branch `tml-2536-contract-deserializer-seam-v2`) — the previous draft
was written in D4 against the now-superseded PR #520 and predated D5
(demo CI gate, lint guard, namespaces-bookend migration) and D6
(rationale comments).

What changed:

- Header now points at PR #533 and frames both audiences (CLI users +
  extension authors) up-front; the implementation-history bullet list
  in "What this script is testing" mentions the shipped guardrails by
  their concrete names (`lint:no-contract-cast`, the
  `Demo `migration plan` (no-op)` CI job, `stamp-storage-types-kind.ts`).
- Added an Isolation column to the TOC and an explicit `Isolation` line
  to every scenario (and the exploratory charter), tagging each with the
  strictest tag it actually needs: `workspace` for DB / tree mutators,
  `read-only` for the rule-coherence pass, `external` for the
  `gh pr checks` scenario.
- Added "Preconditions: no prerequisite scenarios" / "Scenario N
  completed" lines so the runner has explicit DAG edges (Scenario 2
  depends on 1; Scenario 8 depends on 1 or 3; everything else is
  independent).
- Stripped every severity pre-classification (🛑 Blocker / ⚠️ High /
  📝 Follow-up) from failure-mode lists in Scenarios 9, 10, 11. The
  script now enumerates failure-mode categories only; severity belongs
  in the runner report.
- Updated Scenario 4 (negative control for the strict deserializer) to
  target `migrations/app/20260518T1701_namespaces_bookend/end-contract.json`
  — the head migration that the planner now reads as the predecessor
  snapshot after D5's bookend addition. The old target
  (`20260422T0720_initial`) no longer exercises the predecessor-read
  path on its own.
- Updated Scenario 3 to apply the *full* checked-in history (initial
  plus bookend) and `migration show` both, so the re-enactment touches
  the literal pre-bug artefact and the new head.
- Updated Scenario 7 to reference PR #533 instead of #520 and to name
  the actual CI job display name (`Demo `migration plan` (no-op)`).
- Updated Scenario 10's oracle and step 8 expectations: the demo
  `migration plan` is now a *clean* no-op end-to-end (D5's namespaces
  bookend closed the residual TML-2521 drift), so the prior "you may
  still see PN-CLI-4020" carve-out is gone — any non-zero / non-no-op
  envelope is now a finding.
- Pre-flight now uses the workspace-canonical CLI invocation
  (`node ../../packages/.../cli.js`) the rest of the script already
  uses, so the demo-rooted scenarios all read the same way.
- "Scenarios deliberately not in this script" now explicitly excludes
  the static-pass half of AC-2 / AC-8 (re-running the lint over a clean
  tree) and AC-11; the sign-off coverage map maps AC-2 to Scenario 5
  (the gate-of-gate negative control) and points the AC-11 row at the
  exclusion table.

No scenarios were deleted under the litmus test — every existing
scenario already fell into one of the six legitimate buckets. Each
scenario now names which bucket it falls under so the runner can
quickly verify the script's honesty.

Scope is script-revision only: no spec / plan / source / CI / skill
changes. The runner skill (`drive-qa-run`) drives the script and owns
the report.

Signed-off-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 19, 2026
…rios

Forks the manual-QA script from the predecessor branch onto v2 and
extends it for the re-cut + the new upgrade-instructions scope:

- Migration directory references updated for the v2 demo layout
  (`20260422T0720_initial` ×3 packages, not the old predecessor
  branch's `20260516T1816_initial`).
- Branch / PR pre-flight updated to point at the re-cut branch and
  flag PR #520's closure.
- "What this script is testing" block now covers four changes (not
  three), naming the upgrade-instructions skill entries as fix #4.
- "Why manual QA matters here" extended to add the
  upgrade-instructions intent as a sixth gap the scripted gates
  don't close.

Adds two new upgrade-journey scenarios per the slice plan's D4 +
calibration § 9.1 ("the script must name both prisma-next QA
audiences when shipping a breaking change"):

- Scenario 10 — End-user upgrade journey via the `prisma-next-upgrade`
  0.9→0.10 entry. Steps: stash the codemod-applied state to reproduce
  the pre-codemod TML-2536 deserializer crash; read the user-skill
  prose cold; run the codemod in `--check` mode; apply; confirm
  substrate equals PR-branch state (validation-by-execution proof);
  idempotency re-run; confirm the deserializer crash is gone. Failure
  modes severity-classified per scenario step.
- Scenario 11 — Extension-author upgrade journey via the
  `prisma-next-extension-upgrade` 0.9→0.10 entry. Uses pgvector as the
  representative third-party extension substrate. Steps: enumerate
  the extension's `SqlStorage`-touching source; read the extension-
  skill prose cold; confirm baseline tests pass; codemod against
  any seed snapshots; optional structural-falsifier plant to verify
  the `SqlStorage` constructor diagnostic fires cleanly.

Sign-off coverage map appended with two non-numbered rows for the
upgrade-instructions intent (one per audience), with a note that the
calibration document explicitly requires naming both audiences for a
breaking change.

The script is the planner artefact for `drive-qa-run`; the runner
produces the report with severity-classified findings. This commit
ships the plan; running it + producing the report is the slice DoD's
manual-QA bullet, satisfied at D7.

Signed-off-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 19, 2026
Re-apply the drive-qa-plan skill against the shipped state of PR #533
(branch `tml-2536-contract-deserializer-seam-v2`) — the previous draft
was written in D4 against the now-superseded PR #520 and predated D5
(demo CI gate, lint guard, namespaces-bookend migration) and D6
(rationale comments).

What changed:

- Header now points at PR #533 and frames both audiences (CLI users +
  extension authors) up-front; the implementation-history bullet list
  in "What this script is testing" mentions the shipped guardrails by
  their concrete names (`lint:no-contract-cast`, the
  `Demo `migration plan` (no-op)` CI job, `stamp-storage-types-kind.ts`).
- Added an Isolation column to the TOC and an explicit `Isolation` line
  to every scenario (and the exploratory charter), tagging each with the
  strictest tag it actually needs: `workspace` for DB / tree mutators,
  `read-only` for the rule-coherence pass, `external` for the
  `gh pr checks` scenario.
- Added "Preconditions: no prerequisite scenarios" / "Scenario N
  completed" lines so the runner has explicit DAG edges (Scenario 2
  depends on 1; Scenario 8 depends on 1 or 3; everything else is
  independent).
- Stripped every severity pre-classification (🛑 Blocker / ⚠️ High /
  📝 Follow-up) from failure-mode lists in Scenarios 9, 10, 11. The
  script now enumerates failure-mode categories only; severity belongs
  in the runner report.
- Updated Scenario 4 (negative control for the strict deserializer) to
  target `migrations/app/20260518T1701_namespaces_bookend/end-contract.json`
  — the head migration that the planner now reads as the predecessor
  snapshot after D5's bookend addition. The old target
  (`20260422T0720_initial`) no longer exercises the predecessor-read
  path on its own.
- Updated Scenario 3 to apply the *full* checked-in history (initial
  plus bookend) and `migration show` both, so the re-enactment touches
  the literal pre-bug artefact and the new head.
- Updated Scenario 7 to reference PR #533 instead of #520 and to name
  the actual CI job display name (`Demo `migration plan` (no-op)`).
- Updated Scenario 10's oracle and step 8 expectations: the demo
  `migration plan` is now a *clean* no-op end-to-end (D5's namespaces
  bookend closed the residual TML-2521 drift), so the prior "you may
  still see PN-CLI-4020" carve-out is gone — any non-zero / non-no-op
  envelope is now a finding.
- Pre-flight now uses the workspace-canonical CLI invocation
  (`node ../../packages/.../cli.js`) the rest of the script already
  uses, so the demo-rooted scenarios all read the same way.
- "Scenarios deliberately not in this script" now explicitly excludes
  the static-pass half of AC-2 / AC-8 (re-running the lint over a clean
  tree) and AC-11; the sign-off coverage map maps AC-2 to Scenario 5
  (the gate-of-gate negative control) and points the AC-11 row at the
  exclusion table.

No scenarios were deleted under the litmus test — every existing
scenario already fell into one of the six legitimate buckets. Each
scenario now names which bucket it falls under so the runner can
quickly verify the script's honesty.

Scope is script-revision only: no spec / plan / source / CI / skill
changes. The runner skill (`drive-qa-run`) drives the script and owns
the report.

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.

1 participant