Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

TML-1808 6: pgvector Vector<N> typing - #100

Merged
jkomyno merged 10 commits into
mainfrom
tml-1808-phase-6-pgvector-types
Jan 12, 2026
Merged

jkomyno merged 10 commits into
mainfrom
tml-1808-phase-6-pgvector-types

Conversation

@wmadden

@wmadden wmadden commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Parameterized vector support: new Vector type, vector(length) factory, and exposed parameterized codec descriptors; result types now infer dimensioned vectors (e.g., Vector<1536>).
    • Column typeParams are captured and propagated into built contracts.
    • Public descriptor field renamed from parameterizedImports to typeImports (type-only imports).
  • Documentation

    • README updated with Vector usage and examples.
  • Tests

    • Added/updated tests for type-only imports, typeParams, contract emission, and parameterized vector behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds parameterized pgvector support (Vector), introduces typeImports for type-only import emission, propagates typeParams through builders and contract emission, and updates type-resolution to prefer model-derived types and compute parameterized codec outputs.

Changes

Cohort / File(s) Summary
Framework contract shape
packages/1-framework/1-core/shared/contract/src/framework-components.ts
Renamed types.codecTypes.parameterizedImports → typeImports and expanded docs clarifying these are type-only imports separate from CodecTypes.
Tooling — emitter & assembly
packages/2-sql/3-tooling/emitter/src/index.ts, packages/2-sql/3-tooling/family/src/core/assembly.ts
Adjusted import intersection to restrict CodecTypes/OperationTypes intersections to named exports CodecTypes/OperationTypes; non-Codec/Operation type-only imports remain as per-import importLines. extractCodecTypeImports now aggregates codecTypes.import and codecTypes.typeImports.
Family tests / emit fixtures
packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
Updated mocks and expectations to use typeImports (Vector) and ensure type-only imports are emitted but not intersected into CodecTypes.
Type system — relational core
packages/2-sql/4-lanes/relational-core/src/types.ts
Added helpers (ExtractTableToModel, ExtractColumnToField, ExtractFieldValue, ExtractColumnJsTypeFromModels, ResolveColumnTypeParams, ExtractParameterizedCodecOutputType) and refactored ComputeColumnJsType to prefer model-derived types, honor typeParams, and support parameterized codec outputs with nullability preservation.
Authoring / column descriptors
packages/1-framework/2-authoring/contract/src/builder-state.ts, packages/1-framework/2-authoring/contract/src/table-builder.ts, packages/1-framework/2-authoring/contract/test/table-builder.test.ts
Added optional typeParams to ColumnTypeDescriptor/ColumnBuilderState and TableBuilder.column options; tests added to verify propagation, overrides, and omission behavior.
Contract builder emission
packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts, packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
Propagate typeParams into stored BuildStorageColumn entries; tests added to assert preserved/omitted and precedence behavior.
pgvector runtime & types
packages/3-extensions/pgvector/src/types/codec-types.ts, packages/3-extensions/pgvector/src/exports/codec-types.ts, packages/3-extensions/pgvector/src/exports/runtime.ts
Introduced exported branded Vector<N> type and defined CodecTypes['pg/vector@1'] with a parameterizedOutput signature; runtime exposes parameterizedCodecs() with validation and pre-allocated descriptor(s).
pgvector descriptors & column helpers
packages/3-extensions/pgvector/src/core/descriptor-meta.ts, packages/3-extensions/pgvector/src/exports/column-types.ts
Added typeImports for Vector to pack metadata; switched to VECTOR_CODEC_ID constant and added vector(length) factory producing typeParams.length with validation against VECTOR_MAX_DIM.
pgvector docs & tests
packages/3-extensions/pgvector/README.md, packages/3-extensions/pgvector/test/*, test/integration/test/pgvector.test.ts, packages/3-extensions/pgvector/test/result-type.types.test-d.ts
README and tests updated to import/use Vector; result-type and integration tests revised to expect Vector<N> semantics, parameterized column typeParams, and an extra type-only import in emitted contracts.
Emitter tests / serialization
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
Added tests for operation-type import filtering, empty typeParams serialization, bigint literal serialization, and unknown/symbol handling (note: duplicate test blocks appended).
pgvector constants
packages/3-extensions/pgvector/src/core/constants.ts
Added exported VECTOR_CODEC_ID and VECTOR_MAX_DIM = 16000 constants used by validation and column factory.

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
Loading

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

@wmadden wmadden changed the title Phase 6: pgvector Vector<N> typing TML-1808 6: pgvector Vector<N> typing Jan 8, 2026
@wmadden
wmadden force-pushed the tml-1808-phase-5-runtime-schema branch from ff4ee58 to 853c6c8 Compare January 8, 2026 12:08
@wmadden
wmadden force-pushed the tml-1808-phase-6-pgvector-types branch from 248db9f to 3837a2e Compare January 8, 2026 12:09
Base automatically changed from tml-1808-phase-5-runtime-schema to main January 8, 2026 16:51
jkomyno and others added 2 commits January 8, 2026 17:53
…d typedParams in SQL contract builder, added "nativeType: 'vector(N)'" support; improved tests

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 reference Vector<1536> but the available import name is PgVector, 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}}>' to renderer: '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

📥 Commits

Reviewing files that changed from the base of the PR and between 40e3cb4 and 95cbed1.

📒 Files selected for processing (11)
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/1-framework/2-authoring/contract/src/table-builder.ts
  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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 local pnpm typecheck scripts instead of writing tsc commands 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}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, 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.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to 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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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 the exports/ folders

Import 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.mdc and .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
Use Object.hasOwn() instead of hasOwnProperty() (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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.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). Use Control*Descriptor and Control*Instance types 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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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 of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

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.mdc for details.

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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-level describe blocks 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 like runtime.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 by describe blocks.
Prefer object comparison using toEqual or toMatchObject for assertions on objects, rather than property-by-property checks with toHaveProperty or individual property assertions. Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks.
Compare entire plan structures using single toEqual assertions 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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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-tests to 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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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 generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types throughout the code.

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 use validateContract<SqlContract<SqlStorage>>().

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 target in 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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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-error with 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
Prefer unknown over any in tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. Use Object.create() and Object.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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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 X in 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.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for details.

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 individual expect().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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • 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.mdc and .cursor/rules/multi-plane-entrypoints.mdc

Files:

  • packages/1-framework/2-authoring/contract/test/table-builder.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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/types and @prisma-next/sql-contract/factories for test fixtures

Update 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 changes

Remove 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-error and 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 via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for readability

Files:

  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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 (not any) 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 multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<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 like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires 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.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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.ts for migration, src/exports/runtime.ts for runtime

Files:

  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 using table_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 use json_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.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 from contract.d.ts (generated by the emitter) rather than defining types inline.

Files:

  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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 under packages/3-targets/**

Files:

  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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 and src/exports/ for entry points (control.ts, runtime.ts)

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

packages/**/src/core/**: Keep src/core/** free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/1-framework/2-authoring/contract/src/builder-state.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • test/integration/test/pgvector.test.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/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 ModelField objects (with column property) to fall through to codec-based resolution.


261-280: LGTM - Type parameter resolution.

Correctly handles both sources of type parameters:

  1. Inline columnMeta.typeParams
  2. Referenced via columnMeta.typeRef → contract.storage.types[typeRef].typeParams

The Params extends object check ensures only valid objects are propagated.


289-299: LGTM - Parameterized codec output extraction.

The function type inference pattern Fn extends (params: Params) => infer Out is 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:

  1. Model-derived types (highest priority)
  2. Parameterized codec output (when typeParams present)
  3. Plain codec output
  4. unknown fallback

Nullability 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 typeParams for both TypeScript type generation and native DDL output. Using Record<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:

  1. Includes typeParams only when defined in columnState
  2. 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:

  1. The primary codec import (codecTypes.import)
  2. Additional type-only imports for parameterized renderers (codecTypes.typeImports)

The spread into the array handles the case where typeImports may contain multiple entries.


185-188: LGTM - Updated to use typeImports.

The rename from parameterizedImports to typeImports aligns with the broader PR changes standardizing on the typeImports field 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 typeParams is defined on the column descriptor, it flows through to the storage column definition. The use of toMatchObject is appropriate for partial matching.


302-311: LGTM - Test for typeParams omission.

Correctly verifies that typeParams is not present on the column when not provided, using not.toHaveProperty().

packages/1-framework/2-authoring/contract/src/table-builder.ts (2)

89-89: LGTM - typeParams option added.

Extends column options to accept typeParams for cases where the type parameters should differ from the descriptor defaults.


101-109: LGTM - typeParams merging and propagation.

The implementation correctly:

  1. Extracts descriptorTypeParams from the type descriptor
  2. Uses nullish coalescing to prefer options.typeParams over descriptorTypeParams
  3. 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, and typeParams for testing parameterized type support.


118-133: LGTM - Test typeParams from descriptor.

Correctly verifies that typeParams defined on the descriptor flows through to the built column state.


135-158: LGTM - Test typeParams from options.

Good test design using a bareVectorColumn without typeParams to verify that options-provided typeParams are correctly stored.


160-173: LGTM - Test options override behavior.

Verifies the precedence rule: options.typeParams takes priority over descriptor.typeParams.


175-183: LGTM - Test omission behavior.

Correctly verifies that typeParams property is absent when not provided from either source.

packages/3-extensions/pgvector/src/exports/column-types.ts (1)

10-18: vectorColumn descriptor looks correct and minimal.

Nice use of as const satisfies ColumnTypeDescriptor to keep the public shape tight.

packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts (1)

60-79: typeImports plumbing + “don’t intersect into CodecTypes” assertion looks right.

The move to types.codecTypes.typeImports is reflected cleanly in the mock descriptor shape, and the added assertion that export type CodecTypes = ... is not intersected with extra imports is a good regression catch.

Also applies to: 82-114, 190-200

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95cbed1 and 04b52d1.

📒 Files selected for processing (6)
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 local pnpm typecheck scripts instead of writing tsc commands 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}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, 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.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to 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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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 the exports/ folders

Import 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.mdc and .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
Use Object.hasOwn() instead of hasOwnProperty() (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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)

packages/**/*.{ts,tsx}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.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). Use Control*Descriptor and Control*Instance types 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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts for migration, src/exports/runtime.ts for runtime

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 and src/exports/ for entry points (control.ts, runtime.ts)

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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 of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

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.mdc for details.

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types throughout the code.

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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 from contract.d.ts (generated by the emitter) rather than defining types inline.

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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 target in 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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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 X in 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.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for details.

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.mdc and .cursor/rules/multi-plane-entrypoints.mdc

Files:

  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<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 like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires 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/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 using table_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 use json_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
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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-level describe blocks 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 like runtime.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 by describe blocks.
Prefer object comparison using toEqual or toMatchObject for assertions on objects, rather than property-by-property checks with toHaveProperty or individual property assertions. Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks.
Compare entire plan structures using single toEqual assertions 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/3-extensions/pgvector/test/column-types.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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-tests to 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/3-extensions/pgvector/test/column-types.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 use validateContract<SqlContract<SqlStorage>>().

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for readability

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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-error with 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
Prefer unknown over any in tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. Use Object.create() and Object.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/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 individual expect().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/3-extensions/pgvector/test/column-types.test.ts
  • packages/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 under packages/3-targets/**

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts

Runtime 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.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/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:

  1. Empty operation type imports default to Record<string, never>
  2. Operation type imports are filtered to only include named: 'OperationTypes' entries

The 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 for typeParams propagation entrypoint (descriptor → storage column).
The suite setup is minimal and readable, and keeps all pgvector-specific setup local.


304-313: Nice: explicit assertion that typeParams is omitted when absent.
This guards against accidental normalization adding empty typeParams.


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 to contract.parameterized-types.test.ts using validateContract<>(), 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 for vectorColumn look solid and minimal.

Good use of toMatchObject + checking absence of typeParams.

packages/3-extensions/pgvector/src/exports/column-types.ts (1)

14-17: vectorColumn descriptor is clean and correctly constrained with satisfies 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 rejects NaN and Infinity, so an explicit Number.isFinite() check is redundant. The authoring-time validation in column-types.ts uses 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 the FromModels branch is not applicable in the current architecture. ModelField is strictly defined as { readonly column: string } with no support for type annotations. The ExtractColumnJsTypeFromModels type explicitly filters out all model field mappings (checking FieldValue extends { readonly column: string } and returning never), so the FromModels branch at line 524 will always resolve to never in 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between feb5b13 and 617a539.

📒 Files selected for processing (6)
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 local pnpm typecheck scripts instead of writing tsc commands 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}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, 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.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to 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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 the exports/ folders

Import 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.mdc and .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
Use Object.hasOwn() instead of hasOwnProperty() (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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)

packages/**/*.{ts,tsx}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.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). Use Control*Descriptor and Control*Instance types 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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
packages/**/src/core/**

📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)

packages/**/src/core/**: Keep src/core/** free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/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.ts for migration, src/exports/runtime.ts for runtime

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 and src/exports/ for entry points (control.ts, runtime.ts)

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

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.mdc for details.

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types throughout the code.

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 from contract.d.ts (generated by the emitter) rather than defining types inline.

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 target in 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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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 X in 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.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for details.

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.mdc and .cursor/rules/multi-plane-entrypoints.mdc

Files:

  • packages/3-extensions/pgvector/src/core/constants.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • 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 test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • packages/3-extensions/pgvector/test/column-types.test.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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-level describe blocks 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 like runtime.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 by describe blocks.
Prefer object comparison using toEqual or toMatchObject for assertions on objects, rather than property-by-property checks with toHaveProperty or individual property assertions. Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks.
Compare entire plan structures using single toEqual assertions 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.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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-tests to 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.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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 use validateContract<SqlContract<SqlStorage>>().

Files:

  • packages/3-extensions/pgvector/test/column-types.test.ts
  • 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/3-extensions/pgvector/test/column-types.test.ts
  • 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-error with 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
Prefer unknown over any in tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. Use Object.create() and Object.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.ts
  • 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 individual expect().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.ts
  • 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 multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<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 like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires 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/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 using table_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 use json_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
  • packages/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.ts
  • packages/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 via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for readability

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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 under packages/3-targets/**

Files:

  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/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.ts

Runtime 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.ts
  • packages/3-extensions/pgvector/src/exports/column-types.ts
  • packages/3-extensions/pgvector/test/column-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.methods.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/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.ts
  • packages/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_ID uses as const for literal type inference, and VECTOR_MAX_DIM correctly 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 vectorColumn descriptor properties
  • vector() factory with various dimensions including OpenAI embedding sizes
  • Error handling for invalid dimensions (boundary cases and non-integers)

Good use of toMatchObject for 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 in column-types.ts, and both share VECTOR_MAX_DIM from constants ensuring consistency.


27-37: LGTM!

Pre-allocating the descriptors array avoids per-call allocations. The as const satisfies pattern 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_ID constant instead of a hardcoded string.


33-46: LGTM!

Well-designed factory function:

  • Generic N extends number preserves literal type for compile-time type safety
  • Explicit return type ensures typeParams.length is typed as N
  • 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 using Exclude<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:

  1. Direct columnMeta.typeParams
  2. Indirect via columnMeta.typeRef → storage.types[typeRef].typeParams

This 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 Out enables 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:

  1. Model-derived types (highest priority)
  2. Parameterized codec outputs
  3. Standard codec outputs (fallback)

The [FromModels] extends [never] pattern correctly prevents union distribution, and nullability is consistently applied across all resolution paths.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 617a539 and 3d056e6.

📒 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 local pnpm typecheck scripts instead of writing tsc commands 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}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, 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.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to 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 test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for 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 the exports/ folders

Import 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.mdc and .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
Use Object.hasOwn() instead of hasOwnProperty() (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}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.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). Use Control*Descriptor and Control*Instance types 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 multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<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 like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires 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 of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

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.mdc for 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 using table_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 use json_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-level describe blocks 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 like runtime.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 by describe blocks.
Prefer object comparison using toEqual or toMatchObject for assertions on objects, rather than property-by-property checks with toHaveProperty or individual property assertions. Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks.
Compare entire plan structures using single toEqual assertions 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-tests to 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 generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types 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 use validateContract<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 target in 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 via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for 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-error with 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
Prefer unknown over any in tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. Use Object.create() and Object.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 X in 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.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for 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 individual expect().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.mdc and .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 under packages/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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants