Repository navigation
TML-2623: hard-cut Postgres enum slot from framework-shared types to namespace-scoped enum - #595
Conversation
📝 WalkthroughWalkthroughThis PR renames the Postgres enum storage container in SQL namespaces from ChangesNamespace Enum Storage Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
3394cbf to
49b5ff1
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/cli-telemetry
@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: 1
🧹 Nitpick comments (2)
packages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.ts (1)
27-27: ⚡ Quick winUse
ifDefined()for conditional spread in the contract helper.Line 27 uses an inline conditional spread; please switch this to
ifDefined(...)for consistency with repo conventions.Suggested change
+import { ifDefined } from '`@prisma-next/utils/defined`'; ... const unboundNs: SqlNamespaceTablesInput = { id: UNBOUND_NAMESPACE_ID, tables: overrides.tables ?? {}, - ...(overrides.enum !== undefined ? { enum: overrides.enum } : {}), + ...ifDefined(overrides.enum, (value) => ({ enum: value })), };As per coding guidelines: "Use
ifDefined()from@prisma-next/utils/definedfor conditional object spreads instead of inline conditional spread patterns".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.ts` at line 27, Replace the inline conditional spread "(...(overrides.enum !== undefined ? { enum: overrides.enum } : {}))" in the contract helper with the repository-standard ifDefined(...) helper: import ifDefined from '`@prisma-next/utils/defined`' (or the named export used in the repo) and spread ...ifDefined({ enum: overrides.enum }) instead; this keeps behavior identical but follows the project's conditional-spread convention and uses the helper wherever the overrides.enum conditional currently appears.packages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.ts (1)
106-109: ⚡ Quick winPrefer
ifDefined()for the optionalenumspread.This block uses the inline ternary spread pattern the package guidelines ask us to avoid.
As per coding guidelines, "Always use
ifDefined()from@prisma-next/utils/definedfor conditional object spreads instead of inline conditional spread patterns."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.ts` around lines 106 - 109, The object construction returning new PostgresSchema uses an inline ternary spread for the optional enum field (hydratedNsEnums); replace that pattern with ifDefined(hydratedNsEnums) from `@prisma-next/utils/defined` so the spread becomes conditional via the utility. Update the return in the PostgresSchema creation (the block that currently spreads ...(hydratedNsEnums !== undefined ? { enum: hydratedNsEnums } : {})) to instead use ifDefined(hydratedNsEnums) so the enum property is only added when defined.
🤖 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 `@packages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.ts`:
- Around line 193-199: hydrateSqlNamespaceEntry currently reconstructs the
namespace return value using only id, tables and enum, dropping any other
hydrated slots stored in result; change the return to preserve all other keys
from result by extracting tables and enumSlot from result and spreading the
remaining entries (e.g. otherSlots) into the returned object alongside id,
tables and enum when present so arbitrary object-valued slots survive
deserialization and round-trips.
---
Nitpick comments:
In
`@packages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.ts`:
- Around line 106-109: The object construction returning new PostgresSchema uses
an inline ternary spread for the optional enum field (hydratedNsEnums); replace
that pattern with ifDefined(hydratedNsEnums) from `@prisma-next/utils/defined` so
the spread becomes conditional via the utility. Update the return in the
PostgresSchema creation (the block that currently spreads ...(hydratedNsEnums
!== undefined ? { enum: hydratedNsEnums } : {})) to instead use
ifDefined(hydratedNsEnums) so the enum property is only added when defined.
In `@packages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.ts`:
- Line 27: Replace the inline conditional spread "(...(overrides.enum !==
undefined ? { enum: overrides.enum } : {}))" in the contract helper with the
repository-standard ifDefined(...) helper: import ifDefined from
'`@prisma-next/utils/defined`' (or the named export used in the repo) and spread
...ifDefined({ enum: overrides.enum }) instead; this keeps behavior identical
but follows the project's conditional-spread convention and uses the helper
wherever the overrides.enum conditional currently appears.
🪄 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: 34cc5497-32ba-4f17-8591-61a3b35ac7c6
⛔ Files ignored due to path filters (5)
projects/contract-ir-planes/slices/enum-migration/dispatches/01-source-migration.mdis excluded by!projects/**projects/contract-ir-planes/slices/enum-migration/dispatches/02-fixture-regen.mdis excluded by!projects/**projects/contract-ir-planes/slices/enum-migration/dispatches/03-grep-and-pr.mdis excluded by!projects/**projects/contract-ir-planes/slices/enum-migration/plan.mdis excluded by!projects/**projects/contract-ir-planes/slices/enum-migration/spec.mdis excluded by!projects/**
📒 Files selected for processing (33)
drive/retro/findings.mdexamples/prisma-next-cloudflare-worker/src/prisma/contract.d.tsexamples/prisma-next-cloudflare-worker/src/prisma/contract.jsonexamples/prisma-next-demo/src/prisma/contract.d.tsexamples/prisma-next-demo/src/prisma/contract.jsonpackages/1-framework/1-core/framework-components/src/ir/ir-node.tspackages/1-framework/1-core/framework-components/src/ir/storage-type.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.test.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.types.test.tspackages/2-sql/2-authoring/contract-ts/src/build-contract.tspackages/2-sql/2-authoring/contract-ts/src/contract-definition.tspackages/2-sql/2-authoring/contract-ts/src/contract-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.contract-definition.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/4-lanes/relational-core/src/codec-ref-for-column.tspackages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.tspackages/2-sql/9-family/src/core/migrations/contract-to-schema-ir.tspackages/2-sql/9-family/src/core/schema-verify/verify-sql-schema.tspackages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner-strategies.tspackages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.tspackages/3-targets/3-targets/postgres/src/core/postgres-schema.tspackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.jsonpackages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.tspackages/3-targets/3-targets/postgres/test/postgres-contract-serializer.test.tspackages/3-targets/3-targets/postgres/test/postgres-schema.test.tspackages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.storage-types.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/schema-verify.after-runner.integration.test.tstest/integration/test/authoring/parity/core-surface/expected.contract.json
CodeRabbit (PR #595) caught: hydrateSqlNamespaceEntry's generic loop populates result with arbitrary contributed slots, but the return only forwarded id/tables/enum — any future pack-contributed slot would be silently dropped on hydration. Spread ...result so all hydrated slots survive, keeping explicit tables/enum overrides for the typed shape. Refs: #595 (comment) Signed-off-by: Will Madden <[email protected]>
…ared types slot Slice S1.B settles the hard-cut migration design that proves the S1.A substrate works: Postgres enum moves from storage.namespaces.<ns>.types (framework-shared) to storage.namespaces.<ns>.enum (pack-contributed via the descriptor mechanism). PDoD3 from the parent project spec gets satisfied at the end of this slice. A6 confirmed by operator 2026-05-22: no off-repo EA consumer pins contract.json shape or storageHash literals across the npm minor, so the slice ships as a single hard-cut PR (no deprecation-shim sub-slice composition required). Spec embeds the project-plan Risk #5 mitigation as a Per-dispatch DoR overlay: every brief assembled within the slice answers (a) the non-redundancy question for any new public-surface field and (b) the enforcement-beyond-hydration question for any new identity-encoding framework structure, before locking decisions. Spec-level answers for the six surfaces the slice already knows it touches are tabulated; briefs may refine but must not contradict. Fold/defer decisions on the five cleanup tickets surfaced during S1.A: - TML-2658 (NamespaceRawSchema +: ignore nit) folds into D1 family-sql touch — one-line change in the same file as enum slot hydration. - TML-2654 (executeContractEmit pipeline) stays standalone — different code path from S1.B emitter codegen, folding would expand scope. - TML-2634 (plural slot rename), TML-2636 (.entries redirect), TML-2648 (SQLite kind materialization) all defer — no overlap with enum slot migration, best landed after S1 closes. Next: drive-plan-slice decomposes the spec into dispatches. Refs TML-2623. Signed-off-by: Will Madden <[email protected]>
…e PR D1 (M, Composer-2.5) hard-cuts the source surface: IR typing, validator, serializer hydration + folded TML-2658, verifier, emitter codegen, authoring lowering, and Postgres target read/write paths — document- scoped storage.types preserved as out-of-scope guard. fixtures:check is explicitly a non-gate for D1; expected to fail until D2 runs. Re- decomposition trigger at >25 package files or >30-file typecheck cascade splits into D1a (contract IR + family) + D1b (authoring + postgres target). D2 (M, Composer-2.5) grep-audits enum-bearing committed contracts, runs pnpm fixtures:emit, gates on pnpm fixtures:check, and runs the A4 migration-replay probe on pre-#534 bookends. Bookend regen is conditional on replay falsification; if A4 needs >3 source files the dispatch halts (promote per spec edge #12). D3 (S, Composer-2.5) closes the slice: PDoD3 grep gate, SDoD2 edge-case disposition audit, SDoD7 TML-2658 verification, and the full slice validation gate (typecheck, test:packages, test:integration, fixtures:check, lint:deps). No implementation changes expected; >3 straggler files routes failure back to D1 or D2 rather than band-aiding in D3. Risk #5 (Per-dispatch DoR overlay) is wired per-dispatch with explicit brief-assembly discipline drawn from drive/retro/findings.md 2026-05-21: do not lift spec table rows into a "do not relitigate" block without the (a) non-redundancy justification per row; default stance for S1.B is retire framework-encoded Postgres identity, do not add parallel slot registries; if (b) answer is "hydration/validation already enforce this", the dispatch must not introduce that structure. Each dispatch carries refusal triggers naming F1 (no read-fallback shim), F5 (no destructive git), F6 (no redundant descriptor fields), F7 (no unbriefed-blocker workarounds) from drive/calibration/ failure-modes.md. Hard-cut path is preserved. Refs TML-2623. Signed-off-by: Will Madden <[email protected]>
D1 walks Risk #5 (a)+(b) per surface (all eight subtractive); enumerates the 4-package source migration; pins the descriptor surface as unchanged; makes pnpm fixtures:check an explicit non-gate for D1 (D2 regenerates). Composer-2.5; ~15-22 files; >25-file or >30-cascade trigger splits D1 → D1a+D1b. TML-2623 Signed-off-by: Will Madden <[email protected]>
Move Postgres enum entries to storage.namespaces[ns].enum across IR typing, validation, serializer hydration, emitter codegen, authoring lowering, and postgres target read paths. Delete the framework-shared namespace types slot with no read-fallback. Fold TML-2658 explicit '+': 'ignore' on NamespaceRawSchema. Pre-flight grep inventory (step 1): - packages/3-targets/3-targets/postgres/src/exports/types.ts - packages/2-sql/5-runtime/src/sql-context.ts (no edit — comment only) - packages/3-targets/3-targets/postgres/src/core/authoring.ts (no edit) - packages/3-targets/3-targets/postgres/src/core/postgres-enum-type.ts (no edit) - packages/3-targets/3-targets/postgres/src/core/postgres-schema.ts - packages/3-targets/3-targets/postgres/test/postgres-schema.test.ts - packages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.ts - packages/3-targets/3-targets/postgres/src/core/migrations/planner-ddl-builders.ts (no edit) - packages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.ts - packages/3-targets/3-targets/postgres/src/core/migrations/planner-sql-checks.ts (no edit) - packages/2-sql/1-core/contract/src/validators.ts - packages/2-sql/1-core/contract/src/types.ts (no edit) - packages/3-targets/3-targets/postgres/src/core/migrations/planner-strategies.ts - packages/3-targets/3-targets/postgres/src/core/migrations/planner-type-resolution.ts (no edit) - packages/2-sql/4-lanes/relational-core/src/codec-ref-for-column.ts - packages/2-sql/1-core/contract/src/exports/types.ts (no edit) - packages/2-sql/3-tooling/emitter/src/index.ts - packages/3-targets/3-targets/postgres/src/core/migrations/planner-recipes.ts (no edit) - packages/3-targets/3-targets/postgres/src/core/migrations/enum-planning.ts (no edit) - packages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.ts - packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts - packages/3-targets/3-targets/postgres/src/core/migrations/planner-identity-values.ts (no edit) - packages/2-sql/1-core/contract/src/ir/storage-type-instance.ts (no edit) - packages/2-sql/1-core/contract/test/sql-storage.test.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/build-contract.ts - packages/2-sql/1-core/contract/src/ir/sql-storage.ts - packages/2-sql/1-core/contract/vitest.config.ts (no edit) - packages/2-sql/1-core/contract/src/ir/postgres-enum-storage-entry.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/contract-lowering.ts (no edit) - packages/2-sql/1-core/contract/src/ir/sql-node.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/contract-warnings.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/contract-definition.ts - packages/2-sql/9-family/src/core/control-adapter.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (no edit) - packages/2-sql/2-authoring/contract-psl/src/interpreter.ts (no edit) - packages/2-sql/2-authoring/contract-ts/test/contract-builder.contract-definition.test.ts - packages/2-sql/9-family/src/core/schema-verify/verify-sql-schema.ts - packages/2-sql/2-authoring/contract-psl/test/interpreter.test.ts - packages/2-sql/2-authoring/contract-psl/test/interpreter.extensions.test.ts (no edit) - packages/2-sql/2-authoring/contract-psl/test/fixtures.ts (no edit) - packages/2-sql/2-authoring/contract-ts/src/contract-dsl.ts (no edit) - packages/2-sql/2-authoring/contract-psl/test/interpreter.types.test.ts - packages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.ts - packages/2-sql/2-authoring/contract-ts/src/contract-types.ts - packages/2-sql/9-family/src/core/migrations/contract-to-schema-ir.ts - packages/3-targets/6-adapters/postgres/test/migrations/*.integration.test.ts (typecheck cascade) Surprise files outside brief table (grep-bounded, reported): - codec-ref-for-column.ts, contract-to-schema-ir.ts, adapter-postgres integration tests Signed-off-by: Will Madden <[email protected]>
D1 post-flight surfaced that SDoD6 added PostgresEnumStorageEntry to a project-PDoD3 pattern that only audits literal 'postgres-enum' \ discriminator paths. The type-import bridging in family-sql is a separate descriptor-driven verifier scope (filed as TML-2667); D1 satisfies the corrected gate. Folds 2-line JSDoc cleanup into D2. TML-2623 TML-2667 Signed-off-by: Will Madden <[email protected]>
…st fold-ins Pure regen + verification dispatch. Reverts D1 test workaround (snapshot-read-shapes.test.ts skip-paths + inline JSON) once on-disk fixtures regen. Folds 2-line JSDoc cleanup per D1 reviewer signal. A4 replay probe documented as binary outcome (PASS or REGEN+rationale). Composer-2.5; no source changes beyond 2 JSDoc lines (F7 halt otherwise). TML-2623 Signed-off-by: Will Madden <[email protected]>
Pre-flight grep inventory (postgres-enum in contract.json / *.json): - examples/prisma-next-demo/src/prisma/contract.json - examples/prisma-next-cloudflare-worker/src/prisma/contract.json - packages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.json - test/integration/test/authoring/parity/core-surface/expected.contract.json - examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json - examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json - examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.json - examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/end-contract.json - examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json - examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json - examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/start-contract.json Regenerated enum-bearing fixtures via pnpm fixtures:emit (and parity UPDATE_AUTHORING_PARITY_EXPECTED=1). postgres-enum.json via serializer round-trip. Reverted snapshot-read-shapes.test.ts D1 workaround. A4 PASS: pre-#534 bookends retain document-scoped storage.types enums; strict deserialize of bookends fails identically pre-D1 (0339f34^) and post-D2 — no replay regression from namespace enum slot migration. Bookends not regenerated. JSDoc: ir-node.ts uses 'pack-contributed-kind'; storage-type.ts uses '<kind>'. Signed-off-by: Will Madden <[email protected]>
…-app importer D2 (9cebc27) accidentally committed an importer for a temp test-app directory that no longer exists on disk, plus its transitive @prisma-next/*@0.10.0 published-package resolutions. pnpm install reconciles the lockfile against on-disk package.json files; the importer and its closure drop out. Signed-off-by: Will Madden <[email protected]>
D3 closes the slice: PDoD3 grep + slice validation + PR open. Pure verification + PR assembly; zero source changes; halt-and-route on any gate failure. Operator preference encoded in PR-body outline (lead with decisions, end with alternatives). Retro (2nd instance of 2026-05-21 stale-dist hygiene): both D2-R2 implementer and D2 reviewer false-failed pnpm typecheck despite explicit brief guidance to run pnpm build first. Brief-text mitigation insufficient; proposed runner-script + brief-template fixes. TML-2623 Signed-off-by: Will Madden <[email protected]>
CodeRabbit (PR #595) caught: hydrateSqlNamespaceEntry's generic loop populates result with arbitrary contributed slots, but the return only forwarded id/tables/enum — any future pack-contributed slot would be silently dropped on hydration. Spread ...result so all hydrated slots survive, keeping explicit tables/enum overrides for the typed shape. Refs: #595 (comment) Signed-off-by: Will Madden <[email protected]>
…um slot D1's source hard-cut missed three PSL-interpreter test-fixture assertions that still expected the legacy storage.namespaces.<ns>.types shape for Postgres enums. Renamed the namespace-scoped 'types:' key to 'enum:' in each toMatchObject block. Top-level storage.types (document- scoped, holds Email / Embedding1536) is intentionally preserved per project scope. Signed-off-by: Will Madden <[email protected]>
6070467 to
7f07c53
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@packages/3-targets/3-targets/postgres/src/core/migrations/planner-strategies.ts`:
- Around line 136-138: The planner currently looks up enums by bare typeName
across all namespaces (see the enum access using ns.enum and typeName which
returns PostgresEnumStorageEntry), causing collisions; update the enum lookup,
collection and all enum-related planner functions (lookup, diff, and operation
construction) to accept and use namespaceId so you scope keys by namespace
(e.g., use a compound key or index by namespaceId then typeName) instead of
name-only, thread namespaceId through the functions that reference ns.enum /
PostgresEnumStorageEntry (the places around the current typeName lookup and the
corresponding collection sites referenced in the diff) and ensure enum diffing
and operation construction use the namespace-aware entry to avoid
cross-namespace overwrites.
🪄 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: 00a6b49a-6264-4b98-ab9c-5a9d42e40f7f
📒 Files selected for processing (31)
drive/retro/findings.mdexamples/prisma-next-cloudflare-worker/src/prisma/contract.d.tsexamples/prisma-next-cloudflare-worker/src/prisma/contract.jsonexamples/prisma-next-demo/src/prisma/contract.d.tsexamples/prisma-next-demo/src/prisma/contract.jsonpackages/1-framework/1-core/framework-components/src/ir/ir-node.tspackages/1-framework/1-core/framework-components/src/ir/storage-type.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.extensions.test.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.test.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.types.test.tspackages/2-sql/2-authoring/contract-ts/src/build-contract.tspackages/2-sql/2-authoring/contract-ts/src/contract-definition.tspackages/2-sql/2-authoring/contract-ts/src/contract-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.contract-definition.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/4-lanes/relational-core/src/codec-ref-for-column.tspackages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.tspackages/2-sql/9-family/src/core/migrations/contract-to-schema-ir.tspackages/2-sql/9-family/src/core/schema-verify/verify-sql-schema.tspackages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner-strategies.tspackages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.tspackages/3-targets/3-targets/postgres/src/core/postgres-schema.tspackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.jsonpackages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.tspackages/3-targets/3-targets/postgres/test/postgres-contract-serializer.test.tspackages/3-targets/3-targets/postgres/test/postgres-schema.test.tspackages/3-targets/3-targets/postgres/test/snapshot-read-shapes.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.integration.test.ts
✅ Files skipped from review due to trivial changes (7)
- packages/3-targets/3-targets/postgres/test/postgres-contract-serializer.test.ts
- packages/1-framework/1-core/framework-components/src/ir/storage-type.ts
- packages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.integration.test.ts
- examples/prisma-next-demo/src/prisma/contract.json
- packages/2-sql/2-authoring/contract-ts/src/contract-definition.ts
- packages/1-framework/1-core/framework-components/src/ir/ir-node.ts
- examples/prisma-next-cloudflare-worker/src/prisma/contract.json
Spec + plan for S1.E: namespace-aware enum planning (TML-2686). Follow-on correctness fix surfaced by CodeRabbit on PR #595 — the Postgres migration planner keys enum lookups by bare TypeScript name across namespaces, so two namespaces holding enum.<sameName> collide silently. Pre-existing bug, surfaced by S1.B's slot rename touching the line. Sized L per drive/calibration/sizing.md; decomposed into 5 dispatches (M/M/M/S/S). Sequenced after S1.D per operator decision (could parallelise with S1.C/D but reviewer attention stays on the critical path until the structural slices close). Project plan adjustments: - At-a-glance: four → five slices - New S1.E section under Stack with Purpose/Dispatches/Scope/Linear - Parallel groups: extended stack thread + sequencing rationale - Sequencing visualisation: S1.E node added - Realistic budget: × 4 structural + ~0.5 day S1.E = ~10.5-12.5 days - PDoD1 row: 4 → 5 slices (no new PDoD added; S1.E satisfies none) - Risk #6: SchemaIssue shape blast radius (goldens regen at D4) No commits to follow on this branch — slice execution starts after S1.D closes. Documenting here so the deferred follow-up is discoverable. Linear: TML-2686 (relatedTo TML-2584 parent project; relatedTo TML-2623 S1.B PR that surfaced this). Signed-off-by: Will Madden <[email protected]>
CodeRabbit (PR #595) caught: hydrateSqlNamespaceEntry's generic loop populates result with arbitrary contributed slots, but the return only forwarded id/tables/enum — any future pack-contributed slot would be silently dropped on hydration. Spread ...result so all hydrated slots survive, keeping explicit tables/enum overrides for the typed shape. Refs: #595 (comment) Signed-off-by: Will Madden <[email protected]>
At a glance
This slice retires the legacy Postgres-enum slot from the framework-shared
storage.namespaces.<ns>.types.*location and lands it under the namespace-scopedstorage.namespaces.<ns>.enum.*slot, owned by the Postgres pack via the descriptor mechanism introduced in S1.A.The framework no longer carries a slot dedicated to Postgres-pack content. The
enumslot only exists for namespaces whosekindbelongs to a pack that contributes it.The decision
Hard-cut, not deprecation shim.
storage.<ns>.typeshad been doing double duty: a generic catch-all for type-shaped storage entries and the load-bearing home of Postgres enums. S1.A's descriptor mechanism made the second role unnecessary — packs can now contribute namespace-scoped entity-kind slots throughAuthoringContributions.entityTypes, and the framework no longer needs to know what's living undertypes. This slice cashes in that capability for the Postgres enum case.A6 ("no off-repo
@prisma-next/*consumer pins oncontract.jsonshape orstorageHashvalues") was confirmed by the operator pre-slice. With no external pin to honour, a shim phase would only add a temporary discriminator-aware reader and a removal commit later; the hard-cut compresses that into the byte-stability hash bump this slice already needs.Narrative
D1 — source hard-cut + TML-2658 fold-in (
0339f348e, 24 files)D1 retired every framework- and family-side use of
typesfor enum content. The Postgres pack'sAuthoringContributions.entityTypesgained anenumentry; the descriptor mechanism routed serialization/hydration/validation through it. Folded in TML-2658 (NamespaceRawSchema'+': 'ignore'directive parity withvalidators.ts) as a one-line touch on a file D1 already had open.Spec patch
5f22452b8corrected the slice's SDoD6 grep gate from the over-strict originalPostgresEnumStorageEntry|'postgres-enum'pattern to the project-PDoD3 verbatim'postgres-enum'literal. ThePostgresEnumStorageEntrysymbol stays as a legitimate bridging-adapter type signature in family-sql; retiring it is the scope of follow-up TML-2667, not S1.B.D2 — fixture regen + A4 probe + JSDoc fold-in + snapshot revert (
9cebc27dc)Regenerated four contracts (two
examples/demos, one integration fixture, one snapshot-read fixture) plus pairedcontract.d.tsfiles. NewstorageHashvalues land alongside the new slot. Two framework JSDoc lines that named'postgres-enum'as the example discriminator were generalized to'pack-contributed-kind'and'<kind>', removing the substrate's pre-existing soft-coupling to one pack's vocabulary.snapshot-read-shapes.test.tsreverted to loading from regenerated on-disk fixtures (D1 had inlined JSON as a workaround pending D2's regen).A4 (pre-#534 bookend replay):
PASS. Pre-S1.B bookend contracts retain their original document-scopedstorage.typesenum shape; strict deserialize of those bookends behaves identically pre-D1 (0339f348e^) and post-D2 — the namespace-slot migration introduces no replay regression. Bookends not regenerated.D2-R2 — lockfile reconcile (
3829f634a)D2's
pnpm fixtures:emitinvocation left a transient test-app importer (test-1779440829345-2mmflhsudq4) and ~20@prisma-next/*@0.10.0published-package resolutions inpnpm-lock.yaml. R2 ranpnpm install, removing the 133-line cruft.Test plan
rg "'postgres-enum'" packages/1-framework/ packages/2-sql/9-family/returns one hit (framework-components/test/control-stack.test.ts:235, allowed by SDoD6 carve-out)rg "'postgres-enum'" packages/ --glob '!**/node_modules/**' --glob '!**/dist/**'returns hits only underpackages/3-targets/3-targets/postgres/**,packages/3-targets/6-adapters/postgres/**,packages/3-targets/6-adapters/sqlite/**, and test fixturesrg 'storageSlotKey|reservedStorageSlotKeys|namespaceSlotHydrationRegistry' packages/ --glob '!**/node_modules/**' --glob '!**/dist/**'returns zero (no S1.A regression)storageHashvalues inexamples/prisma-next-demo/,examples/prisma-next-cloudflare-worker/,test/integration/test/authoring/parity/core-surface/, andpackages/3-targets/3-targets/postgres/test/fixtures/snapshot-read-shapes/postgres-enum.jsonWhat this slice deliberately does not do
PostgresEnumStorageEntrysymbol retirement in family-sql. Bridging adapters keep the type-import; follow-up TML-2667 introduces a descriptor-driven verifier that lets family-sql drop the import.Plural slot naming refactor (
enum→enumsor similar). ADR Decision 5 picked "essence + singular"; mass rename across existing pack slots is deferred to TML-2634.Namespace shape refactor (
entries-redirected vs flat map). A02(b) deferred to TML-2636.SQLite analogue of the Mongo builder lift from S1.A D6. TML-2648 tracks
new SqliteStorage()parity.TML-2654 emit-pipeline plain-literal namespace fix. Separate scope; tracked at TML-2654.
Bookend contract regeneration. A4 PASS rationale — replay-clean pre/post, no regen needed.
S1.C / S1.D scope. Domain-plane population (S1.C) and project-level cleanup (S1.D) remain follow-on slices on
contract-ir-planes.Namespace-aware Postgres enum planning. The Postgres migration planner keys enum lookups by bare TypeScript name across namespaces (
locateNamespaceType,collectPostgresEnumTypes,locateNamespaceTypeInStorage), so two namespaces holdingenum.<sameName>collide silently. Pre-existing bug onorigin/main; S1.B D1 only renamed.types.→.enum.inside the existing loops. Sized L perdrive/calibration/sizing.md— deferred to its own slice S1.E (TML-2686), full spec + plan inprojects/contract-ir-planes/slices/namespace-aware-enum-planning/. Decomposed into 5 dispatches (M/M/M/S/S); sequenced after S1.D.Alternatives considered
typesreading enums for one minor with a deprecation log line, hard-cut next minor. Rejected: A6 confirmed no off-repo pin needs the grace period; the byte-stability hash bump lands either way; a shim phase only adds a deletion commit.PostgresEnumStorageEntryretirement in this slice — extend the descriptor mechanism to expose verifier-side type-narrowing so family-sql doesn't need the import. Rejected for scope: descriptor-driven verifier work is one slice on its own (TML-2667); pulling it into S1.B blows the M-cap.fixtures:checkred onmain.typesslot to migrate from; the analogue is a future-pack contribution.References
projects/contract-ir-planes/slices/enum-migration/spec.mdprojects/contract-ir-planes/slices/enum-migration/plan.mdprojects/contract-ir-planes/spec.mdprojects/contract-ir-planes/adrs/0001-contract-planes.mddrive/retro/findings.md(2026-05-22 SDoD6 over-strictness; 2026-05-22 stale-dist hygiene)Summary by CodeRabbit
Documentation
Refactor