Repository navigation
TML-1808 6: pgvector Vector<N> typing - #100
Conversation
WalkthroughAdds parameterized pgvector support (Vector), introduces Changes
Sequence Diagram(s)sequenceDiagram
participant Builder as Schema/Builder
participant Emitter as Contract Emitter
participant TypeResolver as Relational Type Resolver
participant CodecPack as pgvector Codec Definitions
Builder->>Emitter: emit contract (column with codecId 'pg/vector@1' and typeParams)
Emitter->>CodecPack: include `typeImports` (e.g., Vector) in emitted d.ts
Emitter->>TypeResolver: request ComputeColumnJsType for column
TypeResolver->>TypeResolver: check table->model mappings
alt model-derived type exists
TypeResolver-->>Emitter: return model-derived JS type (may be Vector<N>)
else
TypeResolver->>CodecPack: query parameterizedOutput support with Params
CodecPack-->>TypeResolver: parameterizedOutput available? (Vector<N>)
alt parameterized
TypeResolver-->>Emitter: return parameterized output type (Vector<N>, apply nullability)
else
TypeResolver-->>Emitter: return codec standard output (e.g., number[])
end
end
Comment |
ff4ee58 to
853c6c8
Compare
248db9f to
3837a2e
Compare
…d typedParams in SQL contract builder, added "nativeType: 'vector(N)'" support; improved tests
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts (1)
203-267: Renderer templates must use the configured alias to match the imported type name.The renderer templates use unaliased identifiers (e.g.,
'Vector<{{length}}>') while the corresponding type imports use aliases (e.g.,alias: 'PgVector'). This creates a mismatch: rendered types referenceVector<1536>but the available import name isPgVector, resulting in invalid TypeScript.Update the renderer strings to use the alias, and add assertions to verify the rendered field types appear in contract.d.ts:
- Line 207: Change
renderer: 'Vector<{{length}}>'torenderer: 'PgVector<{{length}}>'- Line 262-267: Add assertion
expect(result.contractDts).toContain('readonly vector: PgVector<1536>');- Line 390-391: Change
'pg/decimal@1': 'Decimal<{{precision}}, {{scale}}>'to'pg/decimal@1': 'PgDecimal<{{precision}}, {{scale}}>'- Add similar rendered type assertions for the decimal test
🤖 Fix all issues with AI agents
In @packages/3-extensions/pgvector/src/exports/column-types.ts:
- Around line 31-39: The vector factory currently accepts any number; enforce
pgvector constraints by validating the length in the vector function (in
column-types.ts) to ensure it is an integer between 1 and 16000: if not, throw a
clear TypeError/RangeError. Also update vectorParamsSchema in runtime.ts to use
arktype number validations (integer + min(1) + max(16000)) so runtime
parsing/enforcement matches the factory; keep the returned descriptor shape the
same and only add the validation checks before building the descriptor.
In @packages/3-extensions/pgvector/test/column-types.test.ts:
- Around line 4-53: Update the tests to use object matchers for related fields
and add invalid-length cases: replace exact comparisons of related properties
(e.g., separate expect(descriptor.nativeType).toBe(...) and
expect(descriptor.typeParams).toEqual(...)) with a single
expect(descriptor).toMatchObject({ codecId: 'pg/vector@1', nativeType:
'vector(1536)', typeParams: { length: 1536 }}) for the factory-created
descriptors (use appropriate lengths for other cases like 768/384/3072), and if
you implement a runtime guard in the vector() factory, add a small table-driven
test that calls vector() with invalid inputs (0, -1, 1.5) and asserts it throws
(using expect(() => vector(x)).toThrow()) to cover validation.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (11)
packages/1-framework/2-authoring/contract/src/builder-state.tspackages/1-framework/2-authoring/contract/src/table-builder.tspackages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.ts
🧰 Additional context used
📓 Path-based instructions (47)
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
test/integration/test/pgvector.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
test/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
test/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
Test files should use
@prisma-next/sql-contract/typesand@prisma-next/sql-contract/factoriesfor test fixturesUpdate relative paths in test files to reference other packages and extension pack manifests after moving packages, using the correct number of
../segments based on the new location's directory depth
Files:
test/integration/test/pgvector.test.ts
test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
test/integration/test/pgvector.test.ts
test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/use-contract-ir-factories.mdc)
Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changesRemove tests that use type assertions to bypass type checking and test impossible states (e.g., tests that use
as SqlContract<SqlStorage>to test missing required properties)
Files:
test/integration/test/pgvector.test.ts
{test/e2e/**,test/integration/**,packages/1-framework/3-tooling/cli/**}
📄 CodeRabbit inference engine (.cursor/rules/cli-e2e-test-patterns.mdc)
{test/e2e/**,test/integration/**,packages/1-framework/3-tooling/cli/**}: Prefer the shared fixture app directory for reliable workspace resolution in CLI e2e tests
Tests must clean up their own ephemeral directories
Files:
test/integration/test/pgvector.test.ts
test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/generic-parameters.mdc)
Don't add generic defaults unless the type is meaningfully usable with the default. Avoid defaults that create a false "optional" API where the type is pointless without concrete generics.
Test-only escapes permitted:
@ts-expect-errorand double casts are acceptable only in test files, with a short explanation.
Files:
test/integration/test/pgvector.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
test/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
{test/**,examples/**/test/**}/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Cross-package and integration tests: Import from package exports (
@prisma-next/...) to verify the public API
Files:
test/integration/test/pgvector.test.ts
test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
In test files (*.test.ts and *.test-d.ts), double casts with
unknown(notany) are acceptable for mocks and dynamic proxies, but must be kept local, explained, and never copied into production code.
Files:
test/integration/test/pgvector.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/src/core/**: Keepsrc/core/**free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Core plane code in
src/core/**must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/1-framework/2-authoring/contract/src/builder-state.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/2-authoring/contract/src/table-builder.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.
Applied to files:
packages/1-framework/2-authoring/contract/test/table-builder.test.tspackages/3-extensions/pgvector/test/column-types.test.tstest/integration/test/pgvector.test.tspackages/2-sql/3-tooling/family/test/emit-parameterized.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
🧬 Code graph analysis (4)
packages/3-extensions/pgvector/test/column-types.test.ts (1)
packages/3-extensions/pgvector/src/exports/column-types.ts (2)
vectorColumn(14-17)vector(31-39)
packages/1-framework/2-authoring/contract/src/builder-state.ts (1)
packages/1-framework/2-authoring/contract/src/index.ts (1)
ColumnTypeDescriptor(4-4)
packages/3-extensions/pgvector/src/exports/column-types.ts (1)
packages/1-framework/2-authoring/contract/src/builder-state.ts (1)
ColumnTypeDescriptor(9-13)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (3)
packages/3-extensions/pgvector/src/exports/column-types.ts (1)
vectorColumn(14-17)packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (1)
defineContract(583-587)packages/2-sql/4-lanes/relational-core/src/types.ts (1)
CodecTypes(343-343)
🔇 Additional comments (22)
test/integration/test/pgvector.test.ts (2)
25-25: LGTM: Correct update for new Vector import.The expectation correctly reflects the addition of a third codec type import for the Vector type introduced in this PR.
38-43: LGTM: Vector type import validation is well-structured.The new assertion correctly validates the Vector type-only import with proper structure and helpful clarifying comment about import ordering. The use of
toEqual()for object comparison follows the coding guidelines.packages/2-sql/4-lanes/relational-core/src/types.ts (4)
217-254: LGTM - Model-derived type extraction.The deeply nested conditional type correctly navigates the contract structure to extract field types from models. The check at lines 239-241 properly filters out
ModelFieldobjects (withcolumnproperty) to fall through to codec-based resolution.
261-280: LGTM - Type parameter resolution.Correctly handles both sources of type parameters:
- Inline
columnMeta.typeParams- Referenced via
columnMeta.typeRef→contract.storage.types[typeRef].typeParamsThe
Params extends objectcheck ensures only valid objects are propagated.
289-299: LGTM - Parameterized codec output extraction.The function type inference pattern
Fn extends (params: Params) => infer Outis the correct approach for extracting type-level computed outputs from codec definitions.
441-483: LGTM - Updated ComputeColumnJsType with proper fallback chain.The type computation follows a sensible precedence:
- Model-derived types (highest priority)
- Parameterized codec output (when typeParams present)
- Plain codec output
unknownfallbackNullability is correctly applied at each codec output branch (lines 463-465, 467-469, 474-476).
packages/1-framework/2-authoring/contract/src/builder-state.ts (2)
4-12: LGTM - typeParams addition to ColumnTypeDescriptor.The documentation clearly explains the dual purpose of
typeParamsfor both TypeScript type generation and native DDL output. UsingRecord<string, unknown>provides appropriate flexibility for codec-specific parameters.
24-24: LGTM - typeParams propagation in ColumnBuilderState.Aligns with the descriptor type and enables the parameter flow through the builder chain.
packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (1)
219-228: LGTM - Conditional typeParams propagation.The conditional spread pattern correctly:
- Includes
typeParamsonly when defined incolumnState- Omits the property entirely when undefined (matching the "omits typeParams when not provided" test case)
This is consistent with how other optional fields (e.g., constraint names) are handled in this file.
packages/2-sql/3-tooling/family/src/core/assembly.ts (2)
57-62: LGTM - Extended codec type imports extraction.Now correctly collects both:
- The primary codec import (
codecTypes.import)- Additional type-only imports for parameterized renderers (
codecTypes.typeImports)The spread into the array handles the case where
typeImportsmay contain multiple entries.
185-188: LGTM - Updated to use typeImports.The rename from
parameterizedImportstotypeImportsaligns with the broader PR changes standardizing on thetypeImportsfield name across descriptor shapes.packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (2)
252-277: LGTM - Test for typeParams from descriptor.Correctly verifies that when
typeParamsis defined on the column descriptor, it flows through to the storage column definition. The use oftoMatchObjectis appropriate for partial matching.
302-311: LGTM - Test for typeParams omission.Correctly verifies that
typeParamsis not present on the column when not provided, usingnot.toHaveProperty().packages/1-framework/2-authoring/contract/src/table-builder.ts (2)
89-89: LGTM - typeParams option added.Extends column options to accept
typeParamsfor cases where the type parameters should differ from the descriptor defaults.
101-109: LGTM - typeParams merging and propagation.The implementation correctly:
- Extracts
descriptorTypeParamsfrom the type descriptor- Uses nullish coalescing to prefer
options.typeParamsoverdescriptorTypeParams- Conditionally spreads to omit the property when undefined
This matches the test cases for descriptor-sourced, option-sourced, and override scenarios.
packages/1-framework/2-authoring/contract/test/table-builder.test.ts (5)
7-11: LGTM - Vector column fixture.Defines a complete test fixture with
codecId,nativeType, andtypeParamsfor testing parameterized type support.
118-133: LGTM - Test typeParams from descriptor.Correctly verifies that
typeParamsdefined on the descriptor flows through to the built column state.
135-158: LGTM - Test typeParams from options.Good test design using a
bareVectorColumnwithouttypeParamsto verify that options-providedtypeParamsare correctly stored.
160-173: LGTM - Test options override behavior.Verifies the precedence rule:
options.typeParamstakes priority overdescriptor.typeParams.
175-183: LGTM - Test omission behavior.Correctly verifies that
typeParamsproperty is absent when not provided from either source.packages/3-extensions/pgvector/src/exports/column-types.ts (1)
10-18:vectorColumndescriptor looks correct and minimal.Nice use of
as const satisfies ColumnTypeDescriptorto keep the public shape tight.packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts (1)
60-79:typeImportsplumbing + “don’t intersect into CodecTypes” assertion looks right.The move to
types.codecTypes.typeImportsis reflected cleanly in the mock descriptor shape, and the added assertion thatexport type CodecTypes = ...is not intersected with extra imports is a good regression catch.Also applies to: 82-114, 190-200
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts (1)
1-742: Consider splitting this test file to meet the 500-line guideline.The file is 742 lines, exceeding the 500-line limit by 48%. Per coding guidelines, test files should be kept under 500 lines for maintainability and navigability.
Suggested split:
emitter-hook.generation.basic.test.ts- basic generation tests (lines 37-321)emitter-hook.generation.parameterized.test.ts- parameterized type tests (lines 582-669)emitter-hook.generation.operations.test.ts- operation type import tests (lines 671-721)emitter-hook.serialization.test.ts- serialization tests (lines 723-741)Each split file would include the necessary imports and helper functions.
🤖 Fix all issues with AI agents
In
@packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts:
- Around line 279-302: Replace the inline explanatory comment with
self-documenting variable names: rename baseVectorColumn to something like
vectorDescriptorWithoutParams and rename the options object passed to
.column(...) (the one containing typeParams: { length: 768 }) to a descriptive
variable such as columnOptionsWithParams, then use those variables in the call
to column(...) and remove the comment; update references in this test
(function/variable names: columnDescriptor, baseVectorColumn, typeParams) so the
intent is clear from names rather than a comment.
In @packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts:
- Around line 723-741: The tests are directly calling internal methods on
sqlTargetFamilyHook (serializeTypeParamsLiteral and serializeValue); decide and
implement one of: 1) promote these methods to the public API of
sqlTargetFamilyHook so tests can remain as-is, 2) stop calling them directly and
instead exercise the same behavior via the hook's higher-level public methods
(replace direct serializeTypeParamsLiteral/serializeValue calls with calls to
the public export that uses them), or 3) extract serializeTypeParamsLiteral and
serializeValue into standalone utility functions and move their tests into a new
unit test file for those utilities; update imports/exports accordingly and
remove direct testing of internal-only methods.
In @packages/2-sql/4-lanes/relational-core/src/types.ts:
- Around line 217-322: ExtractColumnJsTypeFromModels is misclassifying types
that merely contain a `column` property; tighten the relation detection by
checking that FieldValue is exactly the ModelField shape (only a readonly
`column` key) rather than just having a `column` property. Update the
conditional in ExtractColumnJsTypeFromModels so that when FieldValue extends {
readonly column: string } you also verify that keyof FieldValue is exactly
"column" (i.e. no extra keys) before treating it as a relation (and returning
never); otherwise treat FieldValue as the JS type. Keep ResolveColumnTypeParams
as-is.
In @packages/3-extensions/pgvector/src/exports/column-types.ts:
- Around line 32-43: The same magic values (codec id 'pg/vector@1' and max
dimension 16000) are duplicated between vector(...) in column-types.ts and the
runtime validation in runtime.ts; extract them into shared constants (e.g.,
export const PG_VECTOR_CODEC = 'pg/vector@1' and export const PG_VECTOR_MAX_DIM
= 16000) in a common module (suggest ../core/constants or similar) and import
and use those constants in both the vector function (replace the literal codecId
and upper bound check) and the runtime validator (replace its literal codec id
and max-dimension check) so the values stay in one place and avoid drift.
In @packages/3-extensions/pgvector/src/exports/runtime.ts:
- Around line 13-25: The runtime hardcodes vectorTypeId and the min/max dims
inside vectorParamsSchema, which can drift from authoring-time; create canonical
constants (e.g., VECTOR_CODEC_ID, MIN_VECTOR_DIM, MAX_VECTOR_DIM) in a small
shared module and import them into both the runtime and column-types modules,
then replace the hardcoded 'pg/vector@1' with VECTOR_CODEC_ID and replace the
numeric bounds in vectorParamsSchema's validation with MIN_VECTOR_DIM and
MAX_VECTOR_DIM so both authoring-time and runtime validations stay in sync.
- Around line 48-57: parameterizedCodecs currently allocates a new
RuntimeParameterizedCodecDescriptor array on every call; hoist the single
descriptor object/array to a module-level const (e.g., const
vectorParameterizedCodecs = [ { codecId: vectorTypeId, paramsSchema:
vectorParamsSchema } ] as const) and make parameterizedCodecs() simply return
that constant to avoid per-call allocations while preserving the types and
readonly semantics.
In @packages/3-extensions/pgvector/test/column-types.test.ts:
- Around line 62-70: The test currently uses expect(() =>
vector(value)).toThrow(new RangeError(...)), which only matches the message;
update the assertion to use toThrowError to assert both type and message: call
expect(() => vector(value as number)).toThrowError(RangeError, `pgvector:
dimension must be an integer in [1, 16000], got ${value}`) for each invalid
value in the invalidInputs loop so the test verifies the thrown error is
specifically a RangeError with the expected message (refer to the vector(...)
call and the invalidInputs array in the same test).
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (6)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/3-extensions/pgvector/test/column-types.test.ts
🧰 Additional context used
📓 Path-based instructions (38)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/exports/runtime.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Import runtime/driver only from
src/exports/runtime.tsRuntime plane entry point (
src/exports/runtime.ts) must export runtime factories (e.g.,createPostgresAdapter) and can only import from runtime plane packages and core
Files:
packages/3-extensions/pgvector/src/exports/runtime.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/3-extensions/pgvector/src/exports/column-types.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
🧬 Code graph analysis (4)
packages/3-extensions/pgvector/src/exports/column-types.ts (1)
packages/1-framework/2-authoring/contract/src/builder-state.ts (1)
ColumnTypeDescriptor(9-13)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (3)
packages/3-extensions/pgvector/src/exports/column-types.ts (1)
vectorColumn(14-17)packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (1)
defineContract(583-587)packages/2-sql/4-lanes/relational-core/src/types.ts (1)
CodecTypes(385-385)
packages/3-extensions/pgvector/test/column-types.test.ts (1)
packages/3-extensions/pgvector/src/exports/column-types.ts (2)
vectorColumn(14-17)vector(32-43)
packages/2-sql/4-lanes/relational-core/src/types.ts (1)
packages/2-sql/4-lanes/relational-core/src/ast/codec-types.ts (2)
CodecId(179-184)CodecOutput(186-186)
🔇 Additional comments (9)
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts (2)
671-741: Note: AI summary mentions duplicate tests, but none are visible in the provided code.The AI summary states: "A duplicate copy of the above test blocks was appended later in the file, resulting in two identical groups of tests." However, the code shows these five new tests appear only once (lines 671-741) and the file ends at line 742. If duplicates existed, they may have already been removed.
671-721: Good coverage of operation type import edge cases.These tests appropriately verify:
- Empty operation type imports default to
Record<string, never>- Operation type imports are filtered to only include
named: 'OperationTypes'entriesThe tests align well with the PR's typeImports functionality and use appropriate matchers.
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (3)
252-254: Good coverage fortypeParamspropagation entrypoint (descriptor → storage column).
The suite setup is minimal and readable, and keeps all pgvector-specific setup local.
304-313: Nice: explicit assertion thattypeParamsis omitted when absent.
This guards against accidental normalization adding emptytypeParams.
255-277: Validation tests belong in contract validation tests, not builder tests. The builder doesn't validate; it constructs the contract object. Validation tests should be added tocontract.parameterized-types.test.tsusingvalidateContract<>(), which is where structural validation is tested.Note: The test comment at line 280 states typeParams from descriptor and options are "independent", so conflict validation may not apply. Additionally, no vector length value validation (e.g., checking if length > 0) appears to be implemented in contract.ts. Clarify whether length-value validation is part of this PR before adding these tests.
packages/3-extensions/pgvector/test/column-types.test.ts (1)
4-16: Tests forvectorColumnlook solid and minimal.Good use of
toMatchObject+ checking absence oftypeParams.packages/3-extensions/pgvector/src/exports/column-types.ts (1)
14-17:vectorColumndescriptor is clean and correctly constrained withsatisfies ColumnTypeDescriptor.packages/3-extensions/pgvector/src/exports/runtime.ts (1)
14-25: The current code is correct and consistent with existing patterns in the codebase.
Number.isInteger()already rejectsNaNandInfinity, so an explicitNumber.isFinite()check is redundant. The authoring-time validation incolumn-types.tsuses the same approach without the extra guard. Per the coding guidelines, avoid redundant manual checks when structural validation is sufficient—the current single error message for non-integers is clearer than splitting into separate "finite" and "integer" checks that reject the same invalid inputs.packages/2-sql/4-lanes/relational-core/src/types.ts (1)
483-525: The concern about nullability semantics in theFromModelsbranch is not applicable in the current architecture.ModelFieldis strictly defined as{ readonly column: string }with no support for type annotations. TheExtractColumnJsTypeFromModelstype explicitly filters out all model field mappings (checkingFieldValue extends { readonly column: string }and returningnever), so theFromModelsbranch at line 524 will always resolve toneverin practice. There is no scenario where a non-never type flows through this branch, and therefore no nullability normalization is needed.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
@packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts:
- Line 253: The local variable vectorColumn created via
columnDescriptor('pg/vector@1', 'vector(1536)') should be renamed to a more
descriptive identifier (e.g., testVectorColumn or vectorColumnWithLength) to
avoid confusion with the exported pgvector symbol; update the declaration of
vectorColumn and every reference to it within contract-builder.methods.test.ts
so all usages (tests, assertions, helper calls) point to the new name while
leaving columnDescriptor unchanged.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (6)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.tspackages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/3-extensions/pgvector/test/column-types.test.ts
🧰 Additional context used
📓 Path-based instructions (40)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/core/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/src/core/**: Keepsrc/core/**free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**
Files:
packages/3-extensions/pgvector/src/core/constants.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.ts
packages/**/src/core/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Core plane code in
src/core/**must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages
Files:
packages/3-extensions/pgvector/src/core/constants.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/exports/runtime.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Import runtime/driver only from
src/exports/runtime.tsRuntime plane entry point (
src/exports/runtime.ts) must export runtime factories (e.g.,createPostgresAdapter) and can only import from runtime plane packages and core
Files:
packages/3-extensions/pgvector/src/exports/runtime.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/3-extensions/pgvector/src/core/constants.tspackages/3-extensions/pgvector/src/exports/column-types.tspackages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.tspackages/3-extensions/pgvector/src/exports/runtime.tspackages/2-sql/4-lanes/relational-core/src/types.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.
Applied to files:
packages/3-extensions/pgvector/test/column-types.test.tspackages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
🧬 Code graph analysis (4)
packages/3-extensions/pgvector/test/column-types.test.ts (2)
packages/3-extensions/pgvector/src/exports/column-types.ts (2)
vectorColumn(15-18)vector(33-46)packages/3-extensions/pgvector/src/core/constants.ts (1)
VECTOR_MAX_DIM(9-9)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (3)
packages/3-extensions/pgvector/src/exports/column-types.ts (1)
vectorColumn(15-18)packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (1)
defineContract(583-587)packages/2-sql/4-lanes/relational-core/src/types.ts (1)
CodecTypes(436-436)
packages/3-extensions/pgvector/src/exports/runtime.ts (2)
packages/3-extensions/pgvector/src/core/constants.ts (2)
VECTOR_MAX_DIM(9-9)VECTOR_CODEC_ID(4-4)packages/2-sql/5-runtime/src/sql-context.ts (1)
RuntimeParameterizedCodecDescriptor(34-53)
packages/2-sql/4-lanes/relational-core/src/types.ts (2)
packages/2-sql/4-lanes/sql-lane/test/fixtures/contract.d.ts (2)
Contract(17-85)CodecTypes(9-13)packages/2-sql/4-lanes/relational-core/src/ast/codec-types.ts (2)
CodecId(179-184)CodecOutput(186-186)
🔇 Additional comments (13)
packages/3-extensions/pgvector/src/core/constants.ts (1)
1-9: LGTM!Clean constant definitions with appropriate typing.
VECTOR_CODEC_IDusesas constfor literal type inference, andVECTOR_MAX_DIMcorrectly matches pgvector's documented maximum dimension limit.packages/3-extensions/pgvector/test/column-types.test.ts (1)
1-74: LGTM!Comprehensive test coverage for the pgvector column-types. Tests validate:
- Static
vectorColumndescriptor propertiesvector()factory with various dimensions including OpenAI embedding sizes- Error handling for invalid dimensions (boundary cases and non-integers)
Good use of
toMatchObjectfor object comparisons per coding guidelines.packages/3-extensions/pgvector/src/exports/runtime.ts (3)
14-25: LGTM!The arktype schema with
narrow()provides proper runtime validation for vector parameters. The validation logic (integer check, range validation) aligns with the authoring-time validation incolumn-types.ts, and both shareVECTOR_MAX_DIMfrom constants ensuring consistency.
27-37: LGTM!Pre-allocating the descriptors array avoids per-call allocations. The
as const satisfiespattern ensures type safety while preserving the readonly nature of the array.
59-64: LGTM!Clean implementation returning the pre-allocated descriptors.
packages/3-extensions/pgvector/src/exports/column-types.ts (2)
14-18: LGTM!Good refactoring to use the centralized
VECTOR_CODEC_IDconstant instead of a hardcoded string.
33-46: LGTM!Well-designed factory function:
- Generic
N extends numberpreserves literal type for compile-time type safety- Explicit return type ensures
typeParams.lengthis typed asN- Validation matches the runtime schema in
runtime.ts- Clear error message includes the valid range and actual value
packages/2-sql/4-lanes/relational-core/src/types.ts (6)
264-278: LGTM!Clean helper type for extracting model names from table-to-model mappings using the standard conditional inference pattern.
280-297: LGTM!Properly navigates nested column-to-field mappings with appropriate conditional checks at each level.
320-347: LGTM!Smart handling of the
{ column: string }marker objects usingExclude<keyof FieldValue, 'column'> extends never. This correctly distinguishes between:
- Pure column markers that should fall through to codec-based resolution
- Richer field types that should be used directly
349-373: LGTM!Good two-stage resolution for type params:
- Direct
columnMeta.typeParams- Indirect via
columnMeta.typeRef→storage.types[typeRef].typeParamsThis enables both inline and shared type definitions.
375-392: LGTM!Elegant use of function type inference to extract parameterized output types. The pattern
Fn extends (params: Params) => infer Outenables codec definitions to expose type-level parameterization without branching on codec IDs in core code.
534-576: LGTM!Well-structured type resolution with clear precedence:
- Model-derived types (highest priority)
- Parameterized codec outputs
- Standard codec outputs (fallback)
The
[FromModels] extends [never]pattern correctly prevents union distribution, and nullability is consistently applied across all resolution paths.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
@packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts:
- Line 253: The variable testVectorColumn is declared via
columnDescriptor('pg/vector@1', 'vector(1536)') but never used; remove the
unused declaration (the const testVectorColumn = ... line) from the test file,
or if intended to be reused, replace inline columnDescriptor(...) usages in the
tests with testVectorColumn; locate the symbol testVectorColumn in
contract-builder.methods.test.ts and either delete its declaration or rewire
tests to reference it consistently.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
🧰 Additional context used
📓 Path-based instructions (32)
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
🧬 Code graph analysis (1)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (3)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
contract(11-41)packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts (1)
defineContract(583-587)packages/2-sql/4-lanes/relational-core/src/types.ts (1)
CodecTypes(436-436)
🔇 Additional comments (1)
packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts (1)
255-341: LGTM! Comprehensive typeParams test coverage.The test suite thoroughly validates the typeParams handling:
- Preservation from descriptor
- Preservation from options
- Omission when not provided
- Correct precedence (options override descriptor)
The tests follow all guidelines: concise descriptions, object matchers, and factory functions.
Part 6 of 6 in the parameterized column types stack.
Adds Vector typing to pgvector extension, validates length params, derives column JS types from model mappings, and supports extra type-only imports for parameterized renderers.
Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.