Skip to content

Mongo PSL: bare-member enums fail interpretation unless enum inference codecs are wired explicitly#934

Open
ankur-arch wants to merge 6 commits into
mainfrom
fix/mongo-psl-enum-inference-defaults
Open

Mongo PSL: bare-member enums fail interpretation unless enum inference codecs are wired explicitly#934
ankur-arch wants to merge 6 commits into
mainfrom
fix/mongo-psl-enum-inference-defaults

Conversation

@ankur-arch

@ankur-arch ankur-arch commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What this fixes

Using an enum in a MongoDB PSL schema failed contract resolution:

■  ✖ Failed to resolve contract source (PN-RUN-3000)
│    Why: PSL to Mongo contract interpretation failed
│      - [PSL_UNSUPPORTED_FIELD_TYPE] Field "WhatsAppMessages.direction" type "WhatsAppMessageDirection"
│        is not supported in Mongo PSL interpreter

Reported on Discord ([NEXT], 2026-07-07). After this PR, a plain enum just works, on every config surface:

enum WhatsAppMessageDirection {
  INBOUND
  OUTBOUND
}

model WhatsAppMessages {
  id        ObjectId @id @map("_id")
  direction WhatsAppMessageDirection
}

What was broken

An enum without @@type(...) infers its codec from its members — but the codec ids to infer to were only wired in one place: @prisma-next/mongo's defineConfig. Any config that used the mongoContract() provider directly hit PSL_ENUM_CANNOT_INFER_TYPE, which then cascaded into the misleading PSL_UNSUPPORTED_FIELD_TYPE on every field typed by the enum — exactly the reported "2 of 2" diagnostics.

The fix

The Mongo PSL interpreter now derives the default inference codecs from the target's own scalar type descriptors (Stringmongo/string@1, Intmongo/int32@1) — the same values defineConfig passed by hand. defineConfig drops its now-redundant wiring, and the explicit enumInferenceCodecs option still overrides.

  • packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts — derive the default when the input omits enumInferenceCodecs
  • packages/3-extensions/mongo/src/config/define-config.ts — remove the duplicate wiring
  • skills/extension-author/.../0.14-to-0.15/instructions.md — no-action upgrade declaration (behaviour identical for extension authors)

Testing

Tests were written first and failed for the right reason, then went green:

  • Interpreter unit tests (new interpreter.enums.test.ts): a bare-member enum resolves with no explicit wiring (domain enum + typed field + storage value set); an explicit enumInferenceCodecs still overrides; the original diagnostic pair is still reported when no default can be derived.
  • End-to-end CLI tests: the reporter's schema shape emits successfully through contract emit with both config styles — raw mongoContract() (previously failing) and @prisma-next/mongo defineConfig (new fixture).
  • Regression: full pnpm test:packages sweep, the integration emit suite, pnpm lint:deps, and pnpm fixtures:check (no fixture drift) all pass.

The same Discord thread's second ask — an extendable Collection class for the Mongo ORM — is shipped separately in #936.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Mongo contracts now automatically infer enum codec ids from the target PSL String and Int scalar type descriptors.
    • Bare-member enums work without additional enum codec configuration.
    • Explicit enumInferenceCodecs remains supported as an override.
  • Bug Fixes

    • When enum codec inference can’t be derived from available scalar descriptors, interpretation now reports the relevant enum/type diagnostics.
  • Documentation

    • Expanded option documentation and updated upgrade guidance to reflect the new inference behavior.
  • Tests

    • Added interpreter enum field tests and a CLI integration test covering Mongo contract output for inferred enum value sets.

A bare-member enum (`enum Direction { INBOUND OUTBOUND }`) in a Mongo PSL
schema failed contract interpretation with PSL_ENUM_CANNOT_INFER_TYPE
cascading into PSL_UNSUPPORTED_FIELD_TYPE on every enum-typed field,
unless the config passed enumInferenceCodecs explicitly — only
@prisma-next/mongo's defineConfig did.

The interpreter now derives the default inference codecs from the
target-contributed PSL String/Int scalar type descriptors, so every
config surface resolves classic enums identically; the explicit option
still overrides. defineConfig drops its now-redundant wiring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
@ankur-arch
ankur-arch requested a review from a team as a code owner July 9, 2026 01:01
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: c641428a-1749-40ae-8b89-b1de3fa6a13d

📥 Commits

Reviewing files that changed from the base of the PR and between 7255cc3 and 0de334e.

📒 Files selected for processing (1)
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.15-to-0.16/instructions.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.15-to-0.16/instructions.md

📝 Walkthrough

Walkthrough

The Mongo PSL interpreter now derives enum inference codec ids from target scalar descriptors when explicit configuration is absent. Mongo extension wiring is simplified, documentation is updated, and unit and CLI integration tests cover inference, overrides, diagnostics, and emitted contracts.

Changes

Enum inference codec defaulting

Layer / File(s) Summary
Interpreter derivation and context wiring
packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts, packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts
Enum inference codec ids are derived from the target String and Int scalar descriptors when not explicitly provided, then passed into enum interpretation context.
Extension configuration and upgrade documentation
packages/3-extensions/mongo/src/config/define-config.ts, skills/extension-author/.../instructions.md
The non-TypeScript Mongo configuration path no longer supplies explicit codec ids, and upgrade instructions document the defaulting behavior and retained override option.
Interpreter enum coverage
packages/2-mongo-family/2-authoring/contract-psl/test/interpreter.enums.test.ts
Tests cover bare-member enum inference, explicit codec overrides, and diagnostics when scalar descriptors cannot provide inference codecs.
CLI emit coverage
test/integration/test/fixtures/.../prisma-next.config.mongo-define.ts, test/integration/test/cli.emit-command.additional.test.ts
Integration coverage validates bare-member enum output for both Mongo configuration variants, including domain and storage value sets.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PrismaSchema
  participant Interpreter as interpretPslDocumentToMongoContract
  participant ScalarDescriptors
  participant EnumEntity
  participant ContractJson

  PrismaSchema->>Interpreter: parse enum and model fields
  Interpreter->>ScalarDescriptors: derive enum inference codecs
  ScalarDescriptors-->>Interpreter: String and Int codec ids
  Interpreter->>EnumEntity: resolve enum type and value set
  EnumEntity-->>Interpreter: enum contract metadata
  Interpreter->>ContractJson: emit domain and storage enum structures
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and relevant to the Mongo enum inference fix, though it describes the prior failure mode rather than the new behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mongo-psl-enum-inference-defaults

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

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 160.62 KB (0%)
postgres / emit 144.06 KB (0%)
mongo / no-emit 99.3 KB (0%)
mongo / emit 89.43 KB (0%)
cf-worker / no-emit 186.8 KB (0%)
cf-worker / emit 168.17 KB (0%)

@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/extension-supabase

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/config-loader

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

@prisma-next/emitter

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

@prisma-next/language-server

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 0de334e

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/2-mongo-family/2-authoring/contract-psl/test/interpreter.enums.test.ts (1)

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

Optional: add coverage for the derived int codec path.

Current tests cover default text-codec inference, explicit override, and failure when Int is missing, but no test exercises an integer bare-member enum successfully resolving via the derived int codec end-to-end.

🤖 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-mongo-family/2-authoring/contract-psl/test/interpreter.enums.test.ts`
around lines 152 - 166, Add a test in interpreter.enums.test.ts to cover the
successful derived int codec path for bare-member enums. Extend the existing
enum inference coverage around interpretPslDocumentToMongoContract by creating
an int-valued enum case that resolves through the derived int codec end-to-end,
then assert the resulting namespace enum codecId matches the expected
mongo/int32@1 codec. Use the existing test helpers and symbols like
bareMemberEnumSchema, mongoScalarTypeDescriptors, mongoCodecLookup,
authoringContributions, and UNBOUND_NAMESPACE_ID to keep it aligned with the
current enum inference tests.
test/integration/test/cli.emit-command.additional.test.ts (1)

383-417: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Split the combined toMatchObject into targeted assertions.

This single toMatchObject bundles targetFamily, target, and deeply nested enum/model/field checks. Based on learnings, this repo's test convention is to prefer separate expect() assertions per field over toMatchObject() for multi-field validation, since it produces clearer, more actionable failure messages pinpointing exactly which field failed.

♻️ Example split
-        expect(contractJson).toMatchObject({
-          targetFamily: 'mongo',
-          target: 'mongo',
-          domain: {
-            namespaces: {
-              __unbound__: {
-                enum: {
-                  WhatsAppMessageDirection: {
-                    codecId: 'mongo/string@1',
-                    members: [
-                      { name: 'INBOUND', value: 'INBOUND' },
-                      { name: 'OUTBOUND', value: 'OUTBOUND' },
-                    ],
-                  },
-                },
-                models: {
-                  WhatsAppMessages: expect.objectContaining({
-                    fields: expect.objectContaining({
-                      direction: {
-                        type: { kind: 'scalar', codecId: 'mongo/string@1' },
-                        nullable: false,
-                        valueSet: {
-                          plane: 'domain',
-                          entityKind: 'enum',
-                          namespaceId: '__unbound__',
-                          entityName: 'WhatsAppMessageDirection',
-                        },
-                      },
-                    }),
-                  }),
-                },
-              },
-            },
-          },
-        });
+        expect(contractJson.targetFamily).toBe('mongo');
+        expect(contractJson.target).toBe('mongo');
+        const enumEntry =
+          contractJson.domain.namespaces.__unbound__.enum.WhatsAppMessageDirection;
+        expect(enumEntry.codecId).toBe('mongo/string@1');
+        expect(enumEntry.members).toEqual([
+          { name: 'INBOUND', value: 'INBOUND' },
+          { name: 'OUTBOUND', value: 'OUTBOUND' },
+        ]);
+        const field =
+          contractJson.domain.namespaces.__unbound__.models.WhatsAppMessages.fields.direction;
+        expect(field.type).toEqual({ kind: 'scalar', codecId: 'mongo/string@1' });
+        expect(field.nullable).toBe(false);
+        expect(field.valueSet).toEqual({
+          plane: 'domain',
+          entityKind: 'enum',
+          namespaceId: '__unbound__',
+          entityName: 'WhatsAppMessageDirection',
+        });
🤖 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 `@test/integration/test/cli.emit-command.additional.test.ts` around lines 383 -
417, The test in the contract JSON assertion is using one large toMatchObject
for multiple unrelated checks, which should be split into focused expect()
assertions. Update the assertions around contractJson to validate targetFamily,
target, and the nested domain/namespace/enum/model/field structure separately,
using the existing WhatsAppMessageDirection and WhatsAppMessages references to
keep each failure message precise.

Source: Learnings

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

Nitpick comments:
In
`@packages/2-mongo-family/2-authoring/contract-psl/test/interpreter.enums.test.ts`:
- Around line 152-166: Add a test in interpreter.enums.test.ts to cover the
successful derived int codec path for bare-member enums. Extend the existing
enum inference coverage around interpretPslDocumentToMongoContract by creating
an int-valued enum case that resolves through the derived int codec end-to-end,
then assert the resulting namespace enum codecId matches the expected
mongo/int32@1 codec. Use the existing test helpers and symbols like
bareMemberEnumSchema, mongoScalarTypeDescriptors, mongoCodecLookup,
authoringContributions, and UNBOUND_NAMESPACE_ID to keep it aligned with the
current enum inference tests.

In `@test/integration/test/cli.emit-command.additional.test.ts`:
- Around line 383-417: The test in the contract JSON assertion is using one
large toMatchObject for multiple unrelated checks, which should be split into
focused expect() assertions. Update the assertions around contractJson to
validate targetFamily, target, and the nested domain/namespace/enum/model/field
structure separately, using the existing WhatsAppMessageDirection and
WhatsAppMessages references to keep each failure message precise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: d517c9fa-2aeb-423c-b314-080ef7179670

📥 Commits

Reviewing files that changed from the base of the PR and between f44cbcb and ac20aec.

📒 Files selected for processing (6)
  • packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts
  • packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts
  • packages/2-mongo-family/2-authoring/contract-psl/test/interpreter.enums.test.ts
  • packages/3-extensions/mongo/src/config/define-config.ts
  • test/integration/test/cli.emit-command.additional.test.ts
  • test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.mongo-define.ts

@ankur-arch

Copy link
Copy Markdown
Contributor Author

Follow-up for the second issue in the same Discord thread (extendable Collection for the Mongo ORM, ADR 175): #936

ankur-arch and others added 2 commits July 9, 2026 16:24
…nce default wiring

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
@ankur-arch

Copy link
Copy Markdown
Contributor Author

Ponytail review (lazy-senior-dev ladder over the diff):

  • Root cause, not symptom — the fix targets the missing inference-codec default at the interpreter seam instead of patching each config surface; the misleading PSL_UNSUPPORTED_FIELD_TYPE cascade disappears because its trigger does.
  • Deletion over additiondefineConfig loses its hand-wired codec ids (and the import); the net production change is a 12-line derivation helper reusing the target's existing scalar descriptors.
  • Reuse — no new configuration surface: the default derives from scalarTypeDescriptors the target already contributes, and the existing enumInferenceCodecs option is untouched as the override.
  • No speculative abstraction — the SQL interpreter has the same seam but wasn't changed; it isn't part of the reported problem.

→ skipped: same defaulting for the SQL PSL interpreter — add if/when a SQL user hits the equivalent report (its defineConfig paths already wire the ids).

…ference-defaults

Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
@ankur-arch

Copy link
Copy Markdown
Contributor Author

Refresh pass — merged main, re-validated, scope decision recorded

What changed

Only a merge of origin/main (the branch was 67 commits behind). No source changes were needed: the defect is still live on mainresolveEnumCodecId (packages/1-framework/1-core/framework-components/src/shared/framework-authoring.ts:264) still hard-requires ctx.enumInferenceCodecs, and the recent native-enum work is postgres migration-plane and doesn't touch this path.

Checks run (local, on the merged tree)

Check Result
pnpm build ✅ 68/68
pnpm typecheck ✅ 143/143
pnpm lint ✅ 82/82
pnpm lint:deps ✅ no violations
@prisma-next/mongo-contract-psl tests ✅ 155/155
Integration suite ✅ except one pre-existing flake, below

The one integration failure is test/sql-orm-client/nested-includes-strategy.test.ts (portal "C_12" does not exist, a PGlite/pg-protocol flake) — unrelated to this diff, which touches no SQL code.

Verification of the core claim

The removed defineConfig wiring is behaviour-identical for Mongo, confirmed against the real adapter descriptors (packages/3-mongo-target/2-mongo-adapter/src/exports/control.ts:25):

  • Stringmongo/string@1 = MONGO_STRING_CODEC_ID
  • Intmongo/int32@1 = MONGO_INT32_CODEC_ID

So deriving from the scalar type descriptors reproduces exactly what defineConfig passed by hand, and it now also covers the mongoContract()-direct and LSP interpret paths.

Deliberate scope decision: SQL is not fixed here

A review pass flagged that prismaContract has the same missing default (packages/3-extensions/supabase/prisma-next.config.ts:12 is a live victim) and suggested lifting the derivation into framework-components/authoring for both families. I did not do that, because for SQL it is not behaviour-preserving:

  • postgres scalar descriptors map Intpg/int4@1 (packages/3-targets/6-adapters/postgres/src/core/control-mutation-defaults.ts:158)
  • postgres defineConfig wires enumInferenceCodecs.intPG_INT_CODEC_ID = pg/int@1 (packages/3-extensions/postgres/src/config/define-config.ts:51)

Applying the same derivation on the SQL side would silently shift int-backed enum inference from pg/int@1 to pg/int4@1. That discrepancy looks like a latent bug in its own right and deserves a separate, deliberately-scoped PR rather than a drive-by in a Mongo fix. (Stringpg/text@1 does match PG_TEXT_CODEC_ID; only the int leg diverges.)

Remaining risks / for human review

  1. The misleading cascade is narrowed, not removed. When no default can be derived, a field typed by the failed enum still reports PSL_UNSUPPORTED_FIELD_TYPE on top of PSL_ENUM_CANNOT_INFER_TYPE — pinned by the third test in interpreter.enums.test.ts. Suppressing the field-level diagnostic when the enum itself already failed would be the real fix; out of scope here.
  2. Derivation is all-or-nothing: a target declaring String but not Int infers neither, because the option type is a single { text, int } pair. No real target hits this.
  3. SQL follow-up above needs an owner and a decision on which int codec is correct.
  4. Test scaffolding in interpreter.enums.test.ts duplicates fixtures that three other test files in the package also hand-roll. The SQL sibling package has a shared test/fixtures.ts; Mongo doesn't. Extracting one is a worthwhile cleanup but was left out to keep this PR reviewable.

main has bumped to 0.15.0, so check:upgrade-coverage now requires per-PR
declarations in 0.15-to-0.16/instructions.md. The entry was recorded against
the already-shipped 0.14-to-0.15 cycle.

Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
…ference-defaults

Signed-off-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>

# Conflicts:
#	skills/extension-author/prisma-next-extension-upgrade/upgrades/0.15-to-0.16/instructions.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant