Repository navigation
TML-2956: migrate @default to declarative attribute specs (both paths) - #938
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds numeric and pinned function-call PSL combinators, introduces attribute-spec grammars for field and enum defaults, replaces manual default parsing with AST interpretation, and updates registry, resolution, and diagnostic tests. ChangesDefault parsing and resolution
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PSLParser
participant AttributeSpec
participant FieldResolution
participant DefaultRegistry
PSLParser->>AttributeSpec: parse default value
AttributeSpec-->>FieldResolution: interpreted scalar, array, or function call
FieldResolution->>DefaultRegistry: lower parsed function call
DefaultRegistry-->>FieldResolution: lowered default or diagnostic
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
||
| // A bare identifier (e.g. an enum member name) → its text. No validation; the | ||
| // caller decides what the identifier must resolve to. | ||
| export function bareIdentifier(): ArgType<string> { |
There was a problem hiding this comment.
Don't we already have identifier in the kit?
@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/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/extension-supabase
@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/config-loader
@prisma-next/emitter
@prisma-next/language-server
@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: |
| import { leafDiagnostic } from './diagnostic'; | ||
|
|
||
| // A string, number, or boolean literal reduced to its decoded value (never re-slicing text). | ||
| export function scalarLiteral(): ArgType<string | number | boolean> { |
There was a problem hiding this comment.
Can't we just combine existing parser via oneOf?
size-limit report 📦
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/1-framework/2-authoring/psl-parser/test/attribute-spec-combinators.test.ts (1)
577-655: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding a test for
funcCall()with multiple arguments.The current tests cover nullary, single-string, and single-numeric arguments. A test with multiple arguments (e.g.,
foo(1, "bar")) would exercise theArray.from(arg.args(), ...)mapping with more than one element and verify argument ordering.💡 Suggested additional test
it('preserves a numeric argument as source text', () => { const { expr, ctx } = argOf('uuid(7)'); const result = funcCall().parse(expr, ctx); expect(result.ok).toBe(true); if (result.ok) { expect(result.value.name).toBe('uuid'); expect(result.value.args).toHaveLength(1); expect(result.value.args[0]?.raw).toBe('7'); } }); + + it('captures multiple arguments in source order', () => { + const { expr, ctx } = argOf('foo(1, "bar", true)'); + + const result = funcCall().parse(expr, ctx); + + expect(result.ok).toBe(true); + if (result.ok) { + expect(result.value.name).toBe('foo'); + expect(result.value.args).toHaveLength(3); + expect(result.value.args[0]?.raw).toBe('1'); + expect(result.value.args[1]?.raw).toBe('"bar"'); + expect(result.value.args[2]?.raw).toBe('true'); + } + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/2-authoring/psl-parser/test/attribute-spec-combinators.test.ts` around lines 577 - 655, Add a `funcCall()` test that covers multiple arguments to exercise the `Array.from(arg.args(), ...)` path with more than one element. Extend the existing `funcCall` test block in `attribute-spec-combinators.test.ts` with a case like `foo(1, "bar")`, then assert the parsed callee name, that `args` has length 2, and that each argument’s `raw` value preserves both the ordering and original source text.
🤖 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/1-framework/2-authoring/psl-parser/test/attribute-spec-combinators.test.ts`:
- Around line 577-655: Add a `funcCall()` test that covers multiple arguments to
exercise the `Array.from(arg.args(), ...)` path with more than one element.
Extend the existing `funcCall` test block in
`attribute-spec-combinators.test.ts` with a case like `foo(1, "bar")`, then
assert the parsed callee name, that `args` has length 2, and that each
argument’s `raw` value preserves both the ordering and original source text.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: f7fb897e-7ebf-48cc-b5b5-4426419cc931
⛔ Files ignored due to path filters (6)
projects/typed-attribute-parsers/slices/sql-default/dispatches/01-kit-scalar-funccall.mdis excluded by!projects/**projects/typed-attribute-parsers/slices/sql-default/dispatches/02-migrate-nonenum.mdis excluded by!projects/**projects/typed-attribute-parsers/slices/sql-default/dispatches/03-migrate-enum.mdis excluded by!projects/**projects/typed-attribute-parsers/slices/sql-default/dispatches/04-delete-legacy-funccall-parser.mdis excluded by!projects/**projects/typed-attribute-parsers/slices/sql-default/plan.mdis excluded by!projects/**projects/typed-attribute-parsers/slices/sql-default/spec.mdis excluded by!projects/**
📒 Files selected for processing (12)
packages/1-framework/2-authoring/psl-parser/src/attribute-spec/combinators/bare-identifier.tspackages/1-framework/2-authoring/psl-parser/src/attribute-spec/combinators/func-call.tspackages/1-framework/2-authoring/psl-parser/src/attribute-spec/combinators/scalar-literal.tspackages/1-framework/2-authoring/psl-parser/src/exports/index.tspackages/1-framework/2-authoring/psl-parser/test/attribute-spec-combinators.test.tspackages/2-sql/2-authoring/contract-psl/src/default-function-registry.tspackages/2-sql/2-authoring/contract-psl/src/psl-column-resolution.tspackages/2-sql/2-authoring/contract-psl/src/psl-field-resolution.tspackages/2-sql/2-authoring/contract-psl/src/sql-attribute-specs.tspackages/2-sql/2-authoring/contract-psl/test/default-function-registry.test.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.defaults.test.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.enum.test.ts
💤 Files with no reviewable changes (1)
- packages/2-sql/2-authoring/contract-psl/src/default-function-registry.ts
57269ff to
6f8c80a
Compare
| const [first, ...rest] = memberNames.map((name) => identifier(name)); | ||
| // memberNames is non-empty for any real enum; guard defensively so typing stays total. | ||
| const arms: readonly [ArgType<string>, ...ArgType<string>[]] = | ||
| first === undefined ? [identifier('')] : [first, ...rest]; |
There was a problem hiding this comment.
Wtf is identifier('')? That does not make any semantical sense.
Signed-off-by: Serhii Tatarintsev <[email protected]>
Grow the attribute-spec kit with the two leaf combinators @default needs: - scalarLiteral(): ArgType<string | number | boolean> — a String/Number/ Boolean literal reduced to its decoded .value(). - funcCall(): ArgType<ParsedDefaultFunctionCall> — a FunctionCallAst parsed into the framework ParsedDefaultFunctionCall shape (name via the structural QualifiedName.identifier() getter, each argument captured as verbatim source text so the SQL default registry can re-parse it downstream). Registry- agnostic: no name validation, no SQL dependency. The parsed-call output type is imported from @prisma-next/framework-components/ control (framework to framework, layering-clean). Unit-tested in isolation. Signed-off-by: Serhii Tatarintsev <[email protected]>
Signed-off-by: Serhii Tatarintsev <[email protected]>
… (enum + non-enum) Signed-off-by: Serhii Tatarintsev <[email protected]>
…on-enum @default) Signed-off-by: Serhii Tatarintsev <[email protected]>
to the attribute-spec path Part A: funcCall() now rejects a namespaced (or absent) callee. QualifiedNameAst.identifier() returns the segment after a dot, so foo.now() wrongly yielded the bare registry name now. Guard on dot()/colon() before reading the identifier, and add a combinator test for the namespaced-callee reject. Also reword the combinator comment to keep the framework domain family-blind. Part B: add defaultSpec (oneOf(scalarLiteral, list(scalarLiteral), funcCall)) and rewrite lowerDefaultForField to locate the @default node via the field and interpret it through the spec, then runtime shape-switch on the value: array -> array/scalar-mismatch literal, object -> registry-lowered function default (applicability/codec checks preserved verbatim), primitive -> scalar literal / list-mismatch. The hand-rolled arity check is dropped in favour of the spec engine. Delete the now-dead string parsers (parseDefaultLiteralValue, parseListDefaultExpression, decodeLiteralElement, ListDefaultParse); retain the registry helpers. Update AC5g to expect PSL_INVALID_ATTRIBUTE_SYNTAX (the spec-level reject), leaving the registry/optional-field PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT tests untouched. Signed-off-by: Serhii Tatarintsev <[email protected]>
…(operator standing order, not a repo rule) Signed-off-by: Serhii Tatarintsev <[email protected]>
… enum @default) Signed-off-by: Serhii Tatarintsev <[email protected]>
Part A: add a bareIdentifier() combinator to psl-parser (modeled on entity-ref.ts), export it, and unit-test it (accepts a bare identifier; rejects a string literal, number, and function call). Part B: migrate the enum @default path. Add enumDefaultSpec using bareIdentifier(), and rewrite lowerEnumDefaultForField to interpret via interpretFieldAttribute and match the member against enumHandle.enumMembers, deleting the inline isQuotedString/isFunctionCall regex checks and the exactly-one-positional guard. Thread field/model/sourceFile from the call site. Arg-shape errors (quoted string, function call, missing/extra arg) now surface as PSL_INVALID_ATTRIBUTE_SYNTAX; a non-member identifier still emits PSL_ENUM_UNKNOWN_DEFAULT_MEMBER. Signed-off-by: Serhii Tatarintsev <[email protected]>
…rseDefaultFunctionCall) Signed-off-by: Serhii Tatarintsev <[email protected]>
The funcCall() kit combinator replaced parseDefaultFunctionCall on the production @default path, leaving the hand-written string parser dead in production with only its own unit test as a caller. Remove parseDefaultFunctionCall and its exclusive support chain (splitTopLevelArgs, createSpanFromBase, resolveSpanPositionFromBase, the DefaultFunctionArgument interface, and the now-unused PslSpan import) from default-function-registry.ts, keeping formatSupportedFunctionList and lowerDefaultFunctionWithRegistry. Refactor the test: drop the parsing-behaviour tests (now covered by funcCall in psl-parser) and rebuild the lowering-test inputs via a local call() helper that constructs ParsedDefaultFunctionCall literals directly. Signed-off-by: Serhii Tatarintsev <[email protected]>
… sql-default (D5-D7) Signed-off-by: Serhii Tatarintsev <[email protected]>
…nly) Signed-off-by: Serhii Tatarintsev <[email protected]>
…default) Signed-off-by: Serhii Tatarintsev <[email protected]>
…e) + num()
Make funcCall name-pinned (funcCall(name)) and add a general num() number
atom (any number literal; int() stays integer-only). Replace the static
defaultSpec with buildDefaultSpec({ isList, registry }) that composes the
value grammar per field: literals (str/num/bool), a list arm for list
fields only, and one funcCall(name) arm per registered mutation-default
function.
Rewire lowerDefaultForField to build the spec dynamically and drop the
two shape-mismatch branches (array-on-scalar PSL_INVALID_DEFAULT_VALUE and
scalar-on-list PSL_LIST_DEFAULT_NOT_ARRAY): shape now maps to field kind,
so both become PSL_INVALID_ATTRIBUTE_SYNTAX at the grammar. Likewise a
function name absent from the registry has no arm and fails as invalid
syntax. The registry keeps validating args for known-name calls.
The oneOf(...valueArms) spread is typed cleanly without a cast by
annotating valueArms as a non-empty readonly tuple of ArgType<DefaultArgValue>.
Signed-off-by: Serhii Tatarintsev <[email protected]>
…fault) Signed-off-by: Serhii Tatarintsev <[email protected]>
…(member)…) Replace the static enumDefaultSpec (bareIdentifier + post-validation) with buildEnumDefaultSpec(memberNames), which builds oneOf(...identifier(name)) from the enum members so member-validity is a grammar concern. Rewire lowerEnumDefaultForField to build the spec from enumHandle.enumMembers and drop the PSL_ENUM_UNKNOWN_DEFAULT_MEMBER branch (an unknown member now fails as PSL_INVALID_ATTRIBUTE_SYNTAX). Shift the @default(Critical) test accordingly. Signed-off-by: Serhii Tatarintsev <[email protected]>
…d combinators + vocab fix) Signed-off-by: Serhii Tatarintsev <[email protected]>
…binators D5/D6 made the @default specs dynamic, leaving scalarLiteral() and bareIdentifier() without callers. Delete both combinators, their exports, and their obsolete unit-test describe blocks. Reword num.ts doc comment to drop the framework-vocabulary-flagged word "constraint" (906 -> 905, lint now green) and reword stale bareIdentifier() comments in interpreter.enum.test.ts to describe the current oneOf(identifier(member)) shape. Signed-off-by: Serhii Tatarintsev <[email protected]>
…kit foundation) Signed-off-by: Serhii Tatarintsev <[email protected]>
…oundation
Framework-only foundation for ADR 231 typed funcCall(sig):
- Extract the positional/named argument-binding out of interpretAttribute
into an exported interpretArgs() helper. interpretAttribute now builds the
attribute span, delegates binding to interpretArgs, and applies refine on
the returned record via the same justified blindCast. Behaviour identical.
- Give funcCall an optional signature funcCall(name, sig?). With a sig, the
args are parsed via interpretArgs and bound into { fn, ...args }; without a
sig, todays raw ParsedDefaultFunctionCall capture is unchanged. Two
overloads keep the two return shapes distinct without a cast.
- Extend num() to a pinnable num(value) and int() to a bounded int({min,max}).
No changes to packages/2-sql or packages/3-targets.
Signed-off-by: Serhii Tatarintsev <[email protected]>
Each default function declares a FuncCallSig argument signature; buildDefaultSpec builds funcCall(name, signature); each registry lower consumes the typed { fn, span, args } call instead of re-parsing raw argument source text. Arg shape/arity/range errors become grammar failures (PSL_INVALID_ATTRIBUTE_SYNTAX, Option A); the only surviving semantic arg check is dbgenerated empty -> PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT.
framework-components: add TypedDefaultFunctionCall; ControlMutationDefaultEntry gains an opaque signature?: unknown and a typed lower. psl-parser: typedFuncCall returns nested { fn, span, args }. sql-contract-psl: buildDefaultSpec maps registry.entries() to funcCall(name, blindCast<FuncCallSig>(entry.signature)); lowerDefaultFunctionWithRegistry reads call.fn; stub registry + affected tests migrated. adapter-postgres/adapter-sqlite: signatures added, lower bodies read typed args cast-free, imperative arg parsers removed, and psl-parser promoted to a runtime dependency so the combinators are not bundled (fixes cross-copy instanceof during arg parsing). test/integration: migrate the slugid parity pack to the signature API and update the two invalid-@default diagnostics fixtures.
Signed-off-by: Serhii Tatarintsev <[email protected]>
…d-to-end) Signed-off-by: Serhii Tatarintsev <[email protected]>
… sql-default spec Signed-off-by: Serhii Tatarintsev <[email protected]>
After D9 every SQL @default funcCall is built with a signature, so the no-signature funcCall(name) path (rawFuncCall) has no production caller. Collapse funcCall to a single funcCall(name, sig): ArgType<TypedFuncCall>, migrate/prune its psl-parser tests, and delete the now-vestigial ParsedDefaultFunctionCall, DefaultFunctionArgument, DefaultFunctionLoweringHandler, DefaultFunctionRegistryEntry and DefaultFunctionRegistry types plus their re-exports. Align the sqlite adapter to import LoweredDefaultResult / DefaultFunctionLoweringContext directly from framework-components/control. Type/test-level only; no runtime behaviour change. Signed-off-by: Serhii Tatarintsev <[email protected]>
…l(name, sig)) Signed-off-by: Serhii Tatarintsev <[email protected]>
…neage) Signed-off-by: Serhii Tatarintsev <[email protected]>
Signed-off-by: Serhii Tatarintsev <[email protected]>
…ile-time guarantee
buildEnumDefaultSpec no longer fabricates an identifier('') arm for a
memberless enum. It now takes a non-empty tuple, so non-emptiness is
enforced by the type. The single caller handles the degenerate
memberless-enum case honestly by skipping lowering (a memberless enum is
already a contract error at its declaration and never produces a handle).
Signed-off-by: Serhii Tatarintsev <[email protected]>
a888df3 to
2af855d
Compare
Linked issue
Refs TML-2956 — "Language Tools Support Prisma Next PSL".
Follow-up to #932 (the 7 non-
@defaultSQL attributes). This PR finishes the SQL family:@defaultwas split out of that slice because of its size, and lands here. With it, every SQL attribute's argument parsing is declarative — and@default's spec is composed dynamically per field, so the grammar itself describes exactly which values are valid at each site.At a glance
The
@defaultspec is built per field from the field's resolved context (the composed default-function registry,isList, and — for enum fields — the enum's members), composed entirely from atomic combinators viaoneOf:Each default function now declares an argument signature built from combinators — so
uuid(4)/uuid(7), the requiredcuid(2),nanoid's2..255size, anddbgenerated's string are parsed and range/shape-checked by the grammar, and each registrylowerreceives a typed{ fn, span, args }call instead of re-parsing argument source text:Previously
@defaultwas parsed by three hand-written string scanners (parseDefaultLiteralValue,parseListDefaultExpression, a ~160-lineparseDefaultFunctionCall) and each registrylowerre-parsed raw argument strings (parseIntegerArgument,parseStringLiteral,expectNoArgs, manual count checks). All of it is gone; the specs interpret the real AST and thelowerbodies read typed args.Decision
This PR makes
@defaultspec-driven on both lowering paths and composes each spec dynamically per field:buildDefaultSpec({ isList, registry })composes literal/list/function arms; thelistarm exists only for list fields, and onefuncCall(name)arm is emitted per registered default function.buildEnumDefaultSpec(members)isoneOf(identifier(member)…), so a bare member name is validated against the actual enum by the grammar.funcCall(name, signature)(name-pinned, parallel toidentifier(name)) parses a call's arguments through a recursive positional/named signature into a typed{ fn, span, args }; a generalnum()number-literal atom (any number incl. floats;int({ min, max })stays integer-only, now bounded);str()/bool()/list()/oneOf()/identifier()/optional()reused as-is.FuncCallSig; the registrylowerreads the typed args cast-free (typeof/literal comparisons), and the imperative arg parsers are deleted. BecauseFuncCallSigis authoring-layer and the core registry entry can't name it,signatureis an opaqueunknownon the entry, narrowed with one justifiedblindCast<FuncCallSig>inbuildDefaultSpec.PSL_INVALID_ATTRIBUTE_SYNTAXgrammar failures; array-on-scalar / scalar-on-list are grammar misses. The single surviving semantic arg check isdbgeneratedempty →PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT. Each per-field spec becomes a precise description a future language server can read for autocomplete.funcCall's span-arithmetic chain, the monolithicscalarLiteral()/bareIdentifier()combinators, and the per-lowerimperative arg parsers (parseIntegerArgument/parseStringLiteral/expectNoArgs) — all deleted (net −589 lines in the final commit).Only argument syntax moved to specs; the genuinely semantic rules stay in the interpreter.
How it fits together
str()/num()/bool()are flexible literal leaves;funcCall(name)matches a call with an exact callee (raw args captured — the registry still validates them);identifier(name)matches an exact bare identifier. Array defaults reuselist().lowerDefaultForFieldcallsbuildDefaultSpec({ isList, registry });lowerEnumDefaultForFieldcallsbuildEnumDefaultSpec(enumHandle.enumMembers.map(m => m.name)). Because the registry and field facts are in hand there,oneOf(funcCall(name)…)enumerates the open contributed function set — no bespokefuncCallFromcombinator needed (composition over special-casing, per ADR 231 principle 4).lowerDefaultFunctionWithRegistry→entry.lower, which now reads typed args and keeps generator applicability + codec matching (PSL_INVALID_DEFAULT_APPLICABILITY) and thedbgenerated-empty check (PSL_INVALID_DEFAULT_FUNCTION_ARGUMENT). Literal↔codec type is still enforced downstream by the codec'sencodeJson. For enum, the interpreter maps the (grammar-validated) member name to its value.isList, onefuncCall(name, sig)/identifier(member)arm per known function/member, and each function's args range/shape-checked by its signature, an unknown function, unknown member, scalar-on-list, array-on-scalar, or malformed argument is just an unmatchedoneOf— one uniformPSL_INVALID_ATTRIBUTE_SYNTAX.Behavior changes & evidence
@defaultspecs are composed per field. The function set and enum-member set come from the field's context, so the spec describes exactly what's valid there. Seesql-attribute-specs.ts(buildDefaultSpec/buildEnumDefaultSpec); wired inpsl-column-resolution.ts+psl-field-resolution.ts.PSL_INVALID_ATTRIBUTE_SYNTAX,Expected one of: …), replacing the post-validationPSL_UNKNOWN_DEFAULT_FUNCTION/PSL_ENUM_UNKNOWN_DEFAULT_MEMBER. Evidence ininterpreter.defaults.test.ts+interpreter.enum.test.ts.funcCall(name, signature)parses typed args;num(value)/int({min,max})added.funcCall('now')matchesnow()but notfoo.now(); a signed call binds args into{ fn, span, args }. Seefunc-call.ts+num.ts; evidence inattribute-spec-combinators.test.ts.uuid(5),cuid(),nanoid(1),dbgenerated(123), and args-on-nullary shift fromPSL_INVALID_DEFAULT_FUNCTION_ARGUMENT/PSL_UNKNOWN_DEFAULT_FUNCTIONtoPSL_INVALID_ATTRIBUTE_SYNTAX(operator "Option A"). Registrylowerbodies read typed args and are cast-free. Seedefault-function-registry.ts,control-mutation-defaults.ts; evidence ininterpreter.defaults.test.ts+ the adaptercontrol-mutation-defaults.test.ts.Reviewer notes
funcCallFromwas never built.oneOf(...registry.keys().map(funcCall)), composed at interpretation time, is the open-set dispatch the ADR proposedfuncCallFromfor — with the matched arm as thefndiscriminant. Composition over a bespoke combinator (ADR 231 principle 4).matchingScalarLiteraldeferred; literals stay flexible. Codec value-validation remains the codec'sencodeJson(the single authority, shared with the TS builder); moving it into the grammar would need codec accept-schema metadata that doesn't exist yet. Recorded in the slice spec.oneOfvariadic typing.buildDefaultSpec/buildEnumDefaultSpecannotate the arms as a non-empty readonly tuple (readonly [ArgType<T>, ...ArgType<T>[]]) to satisfyoneOf's constraint — no casts.PSL_INVALID_ATTRIBUTE_SYNTAX; genuinely semantic codes (PSL_INVALID_DEFAULT_FUNCTION_ARGUMENTfordbgeneratedempty,PSL_INVALID_DEFAULT_APPLICABILITY) preserved. Coarse-diagnostic trade-off (accepted per ADR 231): a malformed argument on a callee-matched funcCall arm makes the outeroneOfbacktrack to a genericExpected one of: …message, so@default(uuid(5))no longer gets a uuid-specific hint.cuid()loses its former "usecuid(2)" guidance for the same reason.ControlMutationDefaultEntry.lowernow receives a typedTypedDefaultFunctionCall(wasParsedDefaultFunctionCall), and an arg-bearing contributed default function must declare asignature. Any extension contributing default functions must migrate (thedefault-pack-slugidparity fixture was migrated as the in-repo example). Downstream-upgrade need recorded in the slice spec.@prisma-next/psl-parserpromoted from a dev- to a runtime dependency ofadapter-postgresso tsdown externalises (not bundles) the combinators — a bundled copy gavenum()/str()private AST classes, failinginstanceofagainstsql-contract-psl-parsed nodes so every valid argumented@defaultsilently failed to parse. Invisible to source-resolved unit tests; caught only by the dist-consuming real-pack parity suite.funcCallFromdropped foroneOf(funcCall(name, sig));matchingScalarLiteraldeferred; typed-funcCall provenance) are recorded in the slice spec.projects/typed-attribute-parsers/slices/sql-default/are included for review provenance; migrated/removed at project close-out.Verification
Run on final HEAD:
pnpm --filter @prisma-next/framework-components build && typecheck && test— clean; 469 testspnpm --filter @prisma-next/psl-parser build && typecheck && test— clean; 623 testspnpm --filter @prisma-next/sql-contract-psl typecheck && test— clean; 333 testspnpm --filter @prisma-next/adapter-postgres typecheck && test(+ coverage ≥ thresholds) — 675 testspnpm --filter @prisma-next/adapter-sqlite typecheck && test— 220 testsinstanceofparity +@defaultdiagnostics fixtures) — 50 testspnpm build— 68/68 ·pnpm fixtures:check— clean, no drift ·pnpm lint:framework-vocabulary— 836/836 ·pnpm lint:deps— 0 violationsFollow-ups
@defaultmigration — the remaining slice of TML-2956.Alternatives considered
funcCallFrom(registry)as a dedicated combinator. Rejected: with dynamic per-field construction the registry is in hand, sooneOf(funcCall(name)…)composes the same open-set dispatch without a bespoke combinator or dragging registry concerns into the kit.matchingScalarLiteral()/ codec-typed literals now. Rejected for this PR: literal↔type validation already lives at the codec'sencodeJson; a spec-level matcher would duplicate it (drift risk) or need codec accept-schema metadata that doesn't exist. Deferred.PSL_UNKNOWN_DEFAULT_FUNCTION/PSL_ENUM_UNKNOWN_DEFAULT_MEMBERas semantic checks. Rejected: folding membership into the grammar is the point (less post-validation), andoneOf's "Expected one of: …" preserves the helpful supported-set message.signatureon the core entry asFuncCallSig(notunknown). Rejected:FuncCallSiglives in the authoring layer (@prisma-next/psl-parser); the coreframework-componentsentry type cannot name it without a layering violation (pnpm lint:deps). The opaque-unknown+ single narrowingblindCastin the SQL family is the layer-clean shape; the typed{fn,span,args}call passed toloweris plain-structural and needs no cast.lowerarg parsers. Rejected: that is exactly the raw-string re-parse ADR 231's typedfuncCallreplaces; the signatures make arg validation a grammar concern and delete the parsers.Checklist
git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.@defaultargument-syntax error codes consolidated (documented in the slice spec), no CLI/API/config surface change.