Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (60)
💤 Files with no reviewable changes (15)
✅ Files skipped from review due to trivial changes (17)
🚧 Files skipped from review as they are similar to previous changes (19)
📝 WalkthroughWalkthroughThis PR establishes contract validation as a single serialization seam by (1) introducing a "cast bypass smell" rule and linting to prevent direct ChangesContract Validation Seam & Type Safety Enforcement
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
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 winAlign 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 onstart-contract.*andend-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 contractAs 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 winConsider 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.jsonor 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
⛔ Files ignored due to path filters (4)
projects/migration-manifest-drop-inline-contracts/plan.mdis excluded by!projects/**projects/migration-manifest-drop-inline-contracts/spec.mdis excluded by!projects/**projects/tml-2536-contract-deserializer-seam/plans/plan.mdis excluded by!projects/**projects/tml-2536-contract-deserializer-seam/spec.mdis 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.ymldocs/architecture docs/adrs/ADR 169 - On-disk migration persistence.mddocs/architecture docs/subsystems/7. Migration System.mdexamples/cipherstash-integration/migrations/app/20260512T1716_migration/migration.jsonexamples/cipherstash-integration/migrations/cipherstash/20260601T0000_install_eql_bundle/migration.jsonexamples/mongo-demo/migrations/app/20260409T1030_migration/migration.jsonexamples/mongo-demo/migrations/app/20260415_add-posts-author-index/migration.jsonexamples/multi-extension-monorepo/packages/audit/migrations/20260601T0000_create_audit_event/migration.jsonexamples/multi-extension-monorepo/packages/feature-flags/migrations/20260601T0000_create_feature_flag/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260302T1000_alice_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260302T1100_bob_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260302T1200_staging_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260303T1000_merge_alice/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260303T1100_merge_bob/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260304T1000_add_comments/migration.jsonexamples/prisma-next-demo/migration-fixtures/complex/app/20260305T1000_add_tags/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1100_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260302T1200_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1000_merge_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1100_merge_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/converging-branches/app/20260303T1200_merge_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1000_alice_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1100_bob_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260302T1200_bob_experiment/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1000_merge_alice/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1100_merge_bob/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond-sub-branch/app/20260303T1200_bob_experiment_2/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.jsonexamples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260302T1100_widen_email/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260303T1000_email_default/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260304T1000_change_default/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260305T1000_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260306T1000_add_comments/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260307T1000_kitchen_sink/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260308T1000_rollback/migration.jsonexamples/prisma-next-demo/migration-fixtures/kitchen-sink/app/20260326T1428_migration/migration.jsonexamples/prisma-next-demo/migration-fixtures/linear/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/linear/app/20260302T1000_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260304T1000_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260305T1000_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260306T1000_add_comments/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1000_add_tags/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260307T1100_late_branch/migration.jsonexamples/prisma-next-demo/migration-fixtures/long-spine/app/20260308T1000_add_everything/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1100_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260302T1200_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1430_migration/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_foobar/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1431_migration/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-branch/app/20260326T1432_foobar/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260302T1100_staging/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260304T1000_add_comments/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260305T1000_add_tags/migration.jsonexamples/prisma-next-demo/migration-fixtures/multi-rollback-branch/app/20260306T1000_rollback_to_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260304T1000_rollback_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260305T1000_rollback_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback-continue/app/20260306T1000_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback/app/20260304T1000_rollback_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/rollback/app/20260305T1000_rollback_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1000_alice_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260302T1100_bob_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1000_merge_1a/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260303T1100_merge_1b/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1000_add_comments/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260304T1100_add_posts_branch/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1000_merge_2a/migration.jsonexamples/prisma-next-demo/migration-fixtures/sequential-diamonds/app/20260305T1100_merge_2b/migration.jsonexamples/prisma-next-demo/migration-fixtures/single-branch/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/single-branch/app/20260302T1100_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/single-branch/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260304T1000_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260305T1000_rollback_to_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/skip-rollback/app/20260306T1000_rollback_to_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/sub-branches/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/sub-branches/app/20260302T1100_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1000_add_bio/migration.jsonexamples/prisma-next-demo/migration-fixtures/sub-branches/app/20260303T1100_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260301T1000_init/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1000_add_phone/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1100_add_posts/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1200_add_avatar/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1300_add_category/migration.jsonexamples/prisma-next-demo/migration-fixtures/wide-fan/app/20260302T1400_add_settings/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.tsexamples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.tsexamples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.jsonexamples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.jsonexamples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.jsonexamples/prisma-next-demo/migrations/pgvector/contract.d.tsexamples/prisma-next-demo/migrations/pgvector/contract.jsonexamples/prisma-next-demo/migrations/pgvector/refs/head.jsonexamples/prisma-next-demo/package.jsonexamples/prisma-next-demo/scripts/check-migration-plan.tsexamples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/migration.jsonexamples/prisma-next-postgis-demo/migrations/postgis/20260601T0000_install_postgis_extension/migration.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.jsonpackage.jsonpackages/0-shared/extension-upgrade-skill/upgrades/0.8-to-0.9/instructions.mdpackages/0-shared/extension-upgrade-skill/upgrades/0.8-to-0.9/strip-inline-contracts.tspackages/0-shared/upgrade-skill/upgrades/0.8-to-0.9/instructions.mdpackages/0-shared/upgrade-skill/upgrades/0.8-to-0.9/strip-inline-contracts.tspackages/1-framework/0-foundation/contract/src/hashing.tspackages/1-framework/1-core/framework-components/src/control/control-migration-types.tspackages/1-framework/1-core/framework-components/src/control/control-spaces.tspackages/1-framework/3-tooling/cli/src/commands/db-verify.tspackages/1-framework/3-tooling/cli/src/commands/migration-apply.tspackages/1-framework/3-tooling/cli/src/commands/migration-new.tspackages/1-framework/3-tooling/cli/src/commands/migration-plan.tspackages/1-framework/3-tooling/cli/src/commands/migration-show.tspackages/1-framework/3-tooling/cli/src/control-api/client.tspackages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.tspackages/1-framework/3-tooling/cli/src/control-api/types.tspackages/1-framework/3-tooling/cli/src/load-ts-contract.tspackages/1-framework/3-tooling/cli/test/commands/migration-apply.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-e2e.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-plan-command.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-plan.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-ref.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-show.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.tspackages/1-framework/3-tooling/cli/test/control-api/db-init.test.tspackages/1-framework/3-tooling/cli/test/control-api/db-update.test.tspackages/1-framework/3-tooling/cli/test/migration-cli.test.tspackages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.test.tspackages/1-framework/3-tooling/migration/README.mdpackages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.tspackages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.tspackages/1-framework/3-tooling/migration/src/errors.tspackages/1-framework/3-tooling/migration/src/hash.tspackages/1-framework/3-tooling/migration/src/io.tspackages/1-framework/3-tooling/migration/src/migration-base.tspackages/1-framework/3-tooling/migration/test/deletable-node-modules.test.tspackages/1-framework/3-tooling/migration/test/fixtures.tspackages/1-framework/3-tooling/migration/test/hash.test.tspackages/1-framework/3-tooling/migration/test/io.test.tspackages/1-framework/3-tooling/migration/test/materialise-extension-migration-package-if-missing.test.tspackages/1-framework/3-tooling/migration/test/materialise-migration-package.test.tspackages/1-framework/3-tooling/migration/test/migration-base.test.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/test/sql-storage.test.tspackages/2-sql/4-lanes/query-builder/src/root.tspackages/2-sql/5-runtime/test/sql-context.codec-context.test.tspackages/2-sql/9-family/src/core/migrations/types.tspackages/3-extensions/cipherstash/migrations/20260601T0000_install_eql_bundle/migration.jsonpackages/3-extensions/paradedb/migrations/20260601T0000_install_pg_search_extension/migration.jsonpackages/3-extensions/pgvector/migrations/20260601T0000_install_vector_extension/migration.jsonpackages/3-extensions/pgvector/migrations/20260601T0000_install_vector_extension/migration.tspackages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.tspackages/3-extensions/postgis/migrations/20260601T0000_install_postgis_extension/migration.jsonpackages/3-extensions/postgis/migrations/20260601T0000_install_postgis_extension/migration.tspackages/3-mongo-target/1-mongo-target/src/core/control-target.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.jsonpackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.jsonpackages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.tspackages/3-targets/3-targets/sqlite/src/core/control-target.tspackages/3-targets/6-adapters/postgres/test/migrations/db-init-update.cli.integration.test.tspackages/3-targets/6-adapters/sqlite/test/migrations/db-init-update.cli.test.tsscripts/lint-no-contract-cast.mjstest/integration/test/contract-space-fixture-mongo/migrations.tstest/integration/test/contract-space-fixture/migrations.tstest/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
ce0916e to
230d8a0
Compare
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
There was a problem hiding this comment.
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 winWrap malformed predecessor snapshots in the contract-validation envelope.
If
end-contract.jsonis syntactically invalid or failsvalidateContract, this helper throws a raw error and Lines 270-289 rewrap it aserrorUnexpected(...). 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 winTighten the public
typesinput surface to match this strict branch.
normaliseTypeEntry()now rejects raw codec triples, butSqlStorageTypeEntry/SqlStorageInput.typesstill advertiseStorageTypeInstanceInputas 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
SqlStoragestampskind: '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 itskinddiscriminator 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
⛔ Files ignored due to path filters (2)
projects/tml-2536-contract-deserializer-seam/plans/plan.mdis excluded by!projects/**projects/tml-2536-contract-deserializer-seam/spec.mdis 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.ymlexamples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/ops.jsonexamples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.tsexamples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.jsonexamples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.tsexamples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.d.tsexamples/prisma-next-demo/migrations/app/20260516T1816_initial/end-contract.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.jsonexamples/prisma-next-demo/migrations/app/20260516T1816_initial/migration.tsexamples/prisma-next-demo/migrations/app/20260516T1816_initial/ops.jsonexamples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/migration.jsonexamples/prisma-next-demo/migrations/pgvector/20260601T0000_install_vector_extension/ops.jsonexamples/prisma-next-demo/migrations/pgvector/contract.d.tsexamples/prisma-next-demo/migrations/pgvector/contract.jsonexamples/prisma-next-demo/migrations/pgvector/refs/head.jsonexamples/prisma-next-demo/package.jsonexamples/prisma-next-demo/scripts/check-migration-plan.tspackage.jsonpackages/1-framework/0-foundation/contract/src/hashing.tspackages/1-framework/3-tooling/cli/src/commands/db-verify.tspackages/1-framework/3-tooling/cli/src/commands/migration-apply.tspackages/1-framework/3-tooling/cli/src/commands/migration-new.tspackages/1-framework/3-tooling/cli/src/commands/migration-plan.tspackages/1-framework/3-tooling/cli/src/commands/migration-show.tspackages/1-framework/3-tooling/cli/src/control-api/client.tspackages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.tspackages/1-framework/3-tooling/cli/src/load-ts-contract.tspackages/1-framework/3-tooling/cli/test/commands/migration-invariants.test.tspackages/1-framework/3-tooling/cli/test/commands/migration-tamper.test.tspackages/1-framework/3-tooling/migration/src/aggregate/strategies/graph-walk.tspackages/1-framework/3-tooling/migration/src/aggregate/strategies/synth.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/test/sql-storage.test.tspackages/2-sql/4-lanes/query-builder/src/root.tspackages/2-sql/5-runtime/test/sql-context.codec-context.test.tspackages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.tspackages/3-mongo-target/1-mongo-target/src/core/control-target.tspackages/3-targets/3-targets/postgres/src/exports/control.tspackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/codec-instance.jsonpackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.jsonpackages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.tspackages/3-targets/3-targets/sqlite/src/core/control-target.tsscripts/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
|
Addressing the four CodeRabbit outside-diff findings:
|
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]>
3465fea to
92b3c64
Compare
|
Superseded by #533 — re-cut as a smaller, dispatch-decomposed PR against current |
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.
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]>
…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]>
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]>
…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]>
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]>
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
SqlStoragenow 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:Before this PR,
prisma-next migration planagainstexamples/prisma-next-democrashed withPN-CLI-4999deep 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'smigration planworkflow 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 underexamples/prisma-next-demo/migrations/app/with a single regenerated20260516T1816_initialwhosestart-/end-contract.jsonfiles 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-checkEmbedding1536anduser_typein the newend-contract.jsonto confirm both now carry theirkinddiscriminator.as Contractlint surfaced ten additional cast sites that weren't on the TML-2536 bypass list (none of them were theJSON.parse(...) as Contractpattern — they were generic narrowing). They're rewritten toas unknown as Contract(the documented escape hatch from.cursor/rules/type-predicates.mdc) in commitf147bbfb6, then commented per the rule's required-comment pattern inec2fa2576. Two of those ten turned out not to need a cast at all and were dropped —ContractSpaceMember.contractis already typedContract. Diff is inaggregate/strategies/{graph-walk,synth}.ts.migration planruns in CI now via a newdemo-migration-planjob (commite74dde07f) that callspnpm --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 — runningmigration planagainst the checked-in history must reportok: true / noOp: true / operations: [].prisma-next-postgis-democarries the same TML-2536-class bug (WgsGeometry/geometryare 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.@prisma-next/adapter-postgresintegration tests failed locally during the end-of-round gate run — verified non-regression by reproducing the identical failure set againstorigin/mainand confirming they all need a live local Postgres instance the CI provides. CI will exercise them on push.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'sdrive-close-projectskill. It is not referenced from any shipped artefact indocs/or READMEs.wip/unattended-decisions.mdrecords 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
ContractSerializerthe single seam every on-disk contract read crosses, and makes the seam strict so format drift is loud at every code path simultaneously. Concretely:familyInstance.validateContract. Five bypass sites that previously castJSON.parse(raw) as Contract(migration-plan,migration-new,migration-apply,migration-show,db-verify) now deserialize through the family seam.normaliseTypeEntry's permissive fallthrough insql-storage.tsso an untagged codec triple throws naming the offending entry instead of being silently stamped withkind: 'codec-instance'. The deserializer is now the canonical format-drift alarm.as Contract-cast CI lint (pnpm lint:no-contract-cast, wired intolint:deps) that fails on the bypass pattern outside the allowlist..cursor/rules/contract-normalization-responsibilities.mdcand add a newas-contract-cast-smell.mdcrule, cross-referenced from the review skills so reviewers flag the smell.kindfixture set + a checked-in*-contract.jsonsnapshot-validation test so any future on-disk shape drift breaks something concrete.migration planworkflow 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.mdwe'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.
The seam exists, but the type system doesn't enforce it. The framework ships a
ContractSerializerSPI atpackages/1-framework/1-core/framework-components/src/control/contract-serializer.tswhose explicit purpose is to translate between on-disk JSON and in-memory IR. The SQL family implementation atpackages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.tscomposes arktype structural validation withhydrateSqlStorage.familyInstance.validateContract(json)is the named entry point. ButContractinpackages/1-framework/0-foundation/contract/src/contract-types.tsis a structuralinterface, soJSON.parse(raw) as Contractcompiles cleanly. The fix: route every CLI read site through the family seam (commit9fae5f785/551bf2e6epre-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 (commitbbc2b0dfe).A silent normaliser in family core was absorbing the legacy shape.
SqlStorage's constructor atpackages/2-sql/1-core/contract/src/ir/sql-storage.tscallednormaliseTypeEntry(~line 100–130). Its fallthrough at line 129 silently stampedkind: 'codec-instance'on untagged codec triples viatoStorageTypeInstance(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 rawentry.kindon 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-unknownkind(commitef20acaf9). Unit tests pin the three shapes — taggedcodec-instance,postgres-enum, untagged triple — so future polymorphic-slot kinds can't quietly regress.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.tsbuilt a contract with a polymorphicstorage.typesentry; 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 frommigration.jsonand consolidated snapshot reads intoreadPredecessorEndContract) and TML-2536 surfacing it. The fix, two parts: regenerate the demo'sstart-/end-contract.jsonfiles under the strict deserializer (commit180c9e8ee); and add a CI job that runspnpm --filter prisma-next-demo migration:plan:checkagainst the checked-in history on every PR (commit9fa979af5). For belt-and-braces, add per-polymorphic-kindfixtures + a scan that round-trips every checked-in*-contract.jsonthrough the seam (commit4f51455ec).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" whilehydrateSqlStoragedemonstrably does), a newas-contract-cast-smell.mdcrule, and cross-references from the review skills so the smell catches a reviewer's eye on future PRs (commitad24df899).Behavior changes & evidence
Untagged polymorphic
storage.typesentries 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 planagainst the demo is a no-op. Implementation: the demo's regenerated history underexamples/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 newexamples/prisma-next-demo/scripts/check-migration-plan.tsassertsok: true / noOp: true / operations: []and does a semantic JSON-equality diff against the checked-inmigrations/**/*.json; wired into a CI job in.github/workflows/ci.ymlasdemo-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(readPredecessorEndContracttakes the validator as a parameter;executeMigrationPlanCommandresolvesfamilyInstanceonce and reuses it) — and parallel changes inmigration-new.ts,migration-apply.ts,migration-show.ts, anddb-verify.ts. Evidence:pnpm lint:no-contract-castreturns clean against the tree.A grep-based CI lint catches future
as Contractcasts. Implementation:scripts/lint-no-contract-cast.mjs(uses a negative-lookbehind regex that filters the documentedas unknown as Contractescape hatch but catches the bareas Contractpattern). Wired intopnpm lint:deps. Evidence: try plantingconst x = JSON.parse(s) as Contract;anywhere inpackages/**/src/**outside the allowlist and observepnpm lint:no-contract-castexit non-zero.Per-polymorphic-
kindfixtures 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.tsloads each fixture, runs it throughfamilyInstance.validateContract, asserts the hydrated shape matches the expected class hierarchy. A separate scan in the same file round-trips every checked-in*-contract.jsonunderexamples/**andpackages/**/test/**/fixtures/**through the seam (with honest exclusions for the postgis demo + the pre-existing stalebasic-contract.jsonfixture).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.mdccross-referenced fromvalidate-contract-usage.mdcand from the review skills.agents/skills/drive-code-review/and.agents/skills/drive-pr-local-review/.Compatibility / migration / risk
.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-demois broken by this PR until its migrations are regenerated. Known issue; not blocking; follow-up ticket recommended (see## Follow-ups).Verification
Ran on the final HEAD (
ce0916ed8):pnpm typecheck— PASS (134/134)pnpm lint:deps(including the newlint:no-contract-cast) — PASS, cleanpnpm lint:no-contract-caststandalone — PASS, 0 hitspnpm --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-postgresintegration 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 againstorigin/main; CI runs them against the project's Postgres service and will catch any real regression.Follow-ups
examples/prisma-next-postgis-demo/migrations/**under the strict deserializer. Needs Postgis Docker image. Will hitPN-CLI-4999immediately after this PR merges ifpnpm prisma-next migration planis run against that demo. Worth its own ticket — small but env-dependent.cli/test/commands/migration-tamper.test.tsand a handful of related files referenceT3.x/T6.5.2from a closed-out project — pre-existing pergit blame ^57c098183. Worth a small cleanup ticket (sweep**/{src,test}/**for\bT\d+\.\d+(\.\d+)?\b+ strip-or-rename describes; optionally add alint:no-transient-idsscript).normaliseTypeEntrycan sprout a real upcaster behind the seam without re-introducing the bypass class.PostgresEnumStorageEntry+PostgresEnumTypeSchemashouldn't live in SQL family core) already carries the architectural notes from this PR's design discussion; no action here.Alternatives considered
formatRevisionfield + an upcaster). TML-2536's original proposal. Rejected — adds a back-compat shape to maintain forever, against.cursor/rules/no-backward-compatibility.mdand 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.contract-to-schema-ir.tsandverify-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.Contracttype for compile-time enforcement of the seam. Considered during the design discussion. Rejected — the structuralinterface Contractis 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.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.PostgresEnumStorageEntryis hardcoded into SQL family core, target-specific enum dispatch lives invalidators.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
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.TML-NNNN: <sentence-case title>form.Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
Chores