Repository navigation
TML-3228: register the SQL built-in attribute specs and source every interpreter call site from the namespace - #30159
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (17)
🚧 Files skipped from review as they are similar to previous changes (16)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe SQL authoring package now exposes centralized model and field attribute specifications. Default and relation parsing use symbol-aware factories. SQL family descriptors publish the namespace, and tests cover registration, interpretation, diagnostics, and language-server consumability. ChangesSQL attribute specification surface
Priority: ➖ Normal — Schedule the SQL attribute namespace change because it centralizes built-in model and field specs across interpreters, language-server integration, and the public SQL family package. Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This centralizes SQL attribute specifications and exposes them to SQL authoring consumers without an identified behavior regression or production-impacting risk. Sequence Diagram(s)sequenceDiagram
participant PSLInterpreter
participant sqlAttributeSpecs
participant sqlFamilyPack
participant LSPConsumabilityTest
PSLInterpreter->>sqlAttributeSpecs: resolve model and field attribute factories
sqlFamilyPack->>sqlAttributeSpecs: publish authoring.attributeSpecs
LSPConsumabilityTest->>sqlFamilyPack: enumerate SQL attributes
LSPConsumabilityTest->>sqlAttributeSpecs: invoke relation and contributed field factories
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 6.90% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 14 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
…lan, trace) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…mespace Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…pace Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…e it reaches the LSP Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…L namespace Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…ackage Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…roject trace Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
…cceptance test Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <[email protected]>
6fe720b to
87938cd
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…ssons, workspace removal) (prisma#30237) Closes out the `attribute-registry` project ([TML-3226](https://linear.app/prisma-company/issue/TML-3226)). All four slices merged; this PR records the durable decision as an ADR, lands the retro lessons, and removes the transient project workspace. ## Project DoD verification | Condition | Evidence | | --- | --- | | LSP-side test enumerates a family built-in and a target-contributed attribute | `packages/1-framework/3-tooling/language-server/test/attribute-spec-consumability.test.ts` and `test/integration/test/authoring/attribute-specs.lsp-consumability.test.ts` | | Interpreters source every spec from a registered namespace (grep gate) | `BUILTIN_FIELD_ATTRIBUTE_NAMES` and unregistered spec-constant imports return zero hits | | Mongo `@id`/`@unique` specs registered; Mongo surface enumerable | prisma#30160 | | Unknown attribute names diagnose in both families at field and model level | `PSL_UNSUPPORTED_FIELD_ATTRIBUTE` / `PSL_UNSUPPORTED_MODEL_ATTRIBUTE` in both interpreters | | `@@type` and extension-block `@@map` declared on descriptors; no `blockAttributes.find` outside the generic machinery (grep gate) | prisma#30162; grep returns zero hits | | ADR 236 amended to the factory descriptor shape | prisma#30154 | | Registry ADR authored at close-out | ADR 249, this PR | | Mandatory final retro (invariant I10) | run 2026-09-09 | Slices: `registry-core` (prisma#30154), `sql-attributes-registered` (prisma#30159), `mongo-attributes-registered` (prisma#30160), `block-attributes-on-kit` (prisma#30162). No slice deferred or cancelled. ## Changes **ADR 249 — Central attribute-spec registry.** Records the shipped design: registry entries are uniformly spec factories over a framework-owned construction-time context; parse-time contexts are separate types (`AttributeCtx` / `ModelAttributeCtx` / `FieldAttributeCtx`) with no level discriminant; contributions transit core erased with one documented narrow per erased channel; registry keys drive unknown-attribute diagnostics. It carries the rationale for why the factory types erase to `AttributeSpec<never>` rather than `AttributeSpec<unknown>` — `Out` is contravariant through `refine`, so `unknown` would reject every spec that declares one. That reasoning survived nowhere else in the repo. **Project workspace deleted.** All 18 files under `projects/attribute-registry/` classified transient by the default rules — spec, plan, slice specs and plans, dispatch briefs, design-decisions, manual-QA script and report, retro log, trace. No long-lived methodology files were present, so the ADR is the only migration. Reference scan before and after returns empty: nothing outside the directory pointed at it. ## Scope Documentation and project-workspace only. No source file changes, no test changes, no behaviour change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Added an architectural decision record describing the centralized registry for model-level and field-level attributes. - Clarified that registry entries use a shared namespace and support consistent attribute validation and diagnostics. - Updated the architecture index to specify the registry’s coverage of model-level and field-level attributes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Steven McClankerton <[email protected]> Co-authored-by: Steven McClankerton <[email protected]>
Slice 2 of the attribute-registry project (parent TML-3226; builds on TML-3227, #30154). The SQL family now registers its whole built-in attribute surface once, and every consumer — the four interpreter files, the two unknown-attribute checks, and the language server — reads that one registration.
What changed
One namespace, one export.
@internal/sql-contract-pslgainssqlAttributeSpecs(as const satisfies AttributeSpecNamespace): eight model factories (map id unique index check control discriminator base) and six field factories (map id unique noCheck relation default), exposed through a new@internal/sql-contract-psl/attribute-specsentry. The@relationspec moved frompsl-relation-resolution.tsinto the namespace's module so the namespace never imports from a consumer. The individual spec constants and the two@defaultbuilders are no longer exported — a spec is reachable only through the namespace.@defaultis one factory over the uniform ctx. It reads the field's list-ness and the default-function registry from the ctx, and resolves an enum-typed field's member names from the symbol table (topLevel.blocksor the field's namespace scope), replacing the interpreter-sidebuildDefaultSpec/buildEnumDefaultSpecsplit. Both grammars key their positional asvalue, so the factory has a single return type; the enum lowering narrows ontypeof value === 'string'. A memberless enum yields a grammar that rejects every argument.Call sites source from the namespace.
interpreter.ts,psl-field-resolution.ts,psl-column-resolution.ts,psl-relation-resolution.tsreadsqlAttributeSpecs.<level>.<name>(…);symbolTableis threaded to the two@defaultlowering sites (the only factory that consumes ctx).InferAttrtyping at every call site is unchanged and no cast was added or removed.The family registers it.
@internal/family-sqldepends on@internal/sql-contract-psl(moved from dev to prod — family is the last layer in the SQL layer order) and declaresauthoring.attributeSpecson both its pack ref and its control descriptor. The public@prisma/orm-family-sqlexport map gained the matching entry from the build's public-surface sync.Unknown-attribute diagnostics derive from the registry. The hand-maintained
BUILTIN_FIELD_ATTRIBUTE_NAMESset is gone; the field-level check isObject.hasOwn(sqlAttributeSpecs.field, name). The model-attribute loop checksObject.hasOwn(sqlAttributeSpecs.model, name)(or an ADR 236 contribution) before dispatching; the former fall-through diagnostic became anInternalError, since a registered name without an interpreter branch is a programming error. Messages and codes are untouched.LSP proof in final form. The in-package language-server test enumerates a synthetic family field factory through
resolveConfigInputs; the integration test enumerates the real postgres project's full model/field key sets and@relation's named arguments. Both go red if the family stops registering.Why
The project's premise is that the editor can never fall out of step with what the interpreters accept. That only holds when the interpreter and the LSP read the same object — so the namespace is a module constant the interpreter consumes directly (total,
InferAttr-typed access) and the LSP reads throughassembleAttributeSpecs. Deriving the unknown-name checks from the same keys closes the last place a second list could drift.Scope
In: the SQL family only (
sql-contract-psl,family-sql, tests inlanguage-serverandtest/integration). Out: Mongo (TML-3229), block-level attributes (TML-3230), any LSP production change, the registry ADR (project close-out).Decisions taken on the registry-core open items:
resolveConfigInputsstays a deep import (no new import site appeared); the?? new Map()mutation-default fallback stays (the factory receives exactly the registry the old builder did); wrong-level registration is guarded by a test that invokes every factory and assertsspec.level/spec.namematch its subkey.Verification
pnpm --filter @internal/sql-contract-psl test(451),pnpm --filter @internal/language-server test(295), the integration test file (4),pnpm typecheck,pnpm lint:deps,pnpm fixtures:check(byte-clean),pnpm build,pnpm test:packages. Grep gate:rg "ModelSpec\b|FieldSpec\b|buildDefaultSpec|buildEnumDefaultSpec" packages/2-sql/2-authoring/contract-psl/src --glob '!sql-attribute-specs.ts'→ empty. No comment lines added to.tsfiles.Refs: TML-3228
🤖 Generated with Claude Code
https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA
Summary by CodeRabbit
New Features
@relationarguments.Tests