Repository navigation
correct dependencies, remove tsconfig paths, and break cycles - #31
Conversation
WalkthroughRepository-wide rework: added CLI subpath exports and build entries, introduced directional cross-domain rules with domain allow-lists, centralized/refactored test and CLI helpers (stub adapters, fixtures), set rootDir across many tsconfigs, updated package manifests and tests to use workspace package imports and a TS-based emit flow. Changes
Sequence DiagramsequenceDiagram
autonumber
participant Test as Integration Test
participant CLI as `@prisma-next/cli` (subpath)
participant Family as packages/sql/family
participant Contract as `@prisma-next/contract`
participant Runtime as SQL Runtime (createStubAdapter)
Note over Test,CLI: Integration tests use TS-based emit flow (no spawned CLI)
Test->>CLI: import or call emit API / config-loader
Test->>Contract: load/parse TS contract fixtures
Test->>Family: call assembly helpers (extract codec/operation imports, build registry)
Family->>Contract: resolve codec & operation types from packs
Test->>Runtime: createStubAdapter() to build runtime/context
Runtime-->>Test: runtime context for emit/plan
Test->>CLI: invoke emit(contract, options)
CLI->>Family: request emission (contract.json / contract.d.ts)
Family->>Contract: produce emitted artifacts
Contract-->>Test: emitted artifacts returned for assertions
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Lite 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (4)**/packages/**/package.json📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)
Files:
**/package.json📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Files:
packages/**/package.json📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Files:
{**/package.json,**/index.{ts,tsx}}📄 CodeRabbit inference engine (.cursor/rules/README.md)
Files:
🔇 Additional comments (3)
Comment |
… deps from sql-runtime
…test/integration/test/
wmadden
left a comment
There was a problem hiding this comment.
LGTM
enjoy your extra 1k LOC changed
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (8)
packages/sql/lanes/relational-core/src/ast/join.ts (1)
38-39: Replace blind type casts with type predicates to ensure type safety.Blind type casts (
as unknown as X) are forbidden in production code per coding guidelines. Instead, use a type predicate function to narrow types properly.The
isColumnBuilderfunction should be a type predicate (returningis AnyColumnBuilder) so that after the guard check at line 29, TypeScript narrowsleftandrightto the correct type without needing casts.Apply this pattern to fix the type safety issue:
- // TypeScript can't narrow ColumnBuilder properly, so we assert - const leftCol = left as unknown as { table: string; column: string }; - const rightCol = right as unknown as { table: string; column: string }; - if (leftCol.table === rightCol.table) { + if (left.table === right.table) { throw planInvalid('Self-joins are not supported in MVP'); } return { kind: 'join-on', - left: left as AnyColumnBuilder, - right: right as AnyColumnBuilder, + left, + right, };Ensure that
isColumnBuilderis implemented as a proper type predicate:function isColumnBuilder(value: unknown): value is AnyColumnBuilder { // validation logic }packages/targets/postgres-adapter/package.json (1)
15-28: Remove unused dependencies: @prisma-next/contract and @prisma-next/core-control-plane are not imported anywhere.The search reveals that @prisma-next/contract and @prisma-next/core-control-plane have no imports in the postgres-adapter source code and should be removed from dependencies. @prisma-next/contract-authoring is correctly listed and used for the
ColumnTypeDescriptortype insrc/exports/column-types.ts. Additionally, @prisma-next/cli is also unused and should be removed.packages/extensions/pgvector/package.json (1)
25-36: Addexternalconfiguration to tsup.config.ts to prevent bundling of workspace packages.The devDependencies are correctly scoped to testing and build (vitest.config.ts uses
@prisma-next/test-utilsfor timeouts; test files import adapter-postgres, sql-contract, sql-contract-ts). However,tsup.config.tsis missing theexternalarray configuration. Add the following to mark workspace packages as external:external: [ '@prisma-next/adapter-postgres', '@prisma-next/operations', '@prisma-next/sql-contract', '@prisma-next/sql-contract-ts', '@prisma-next/sql-lane', '@prisma-next/test-utils', ]This prevents accidental bundling of CommonJS dependencies into the ESM bundle and avoids vite parsing errors.
packages/sql/authoring/sql-contract-ts/test/contract.structure.test.ts (1)
28-136: Consider using a concrete contract type instead ofSqlContract<SqlStorage>in validateContract testsCurrent calls like
validateContract<SqlContract<SqlStorage>>(…)use the generic contract type; the sql guidelines recommend using a fully-typed contract (fromcontract.d.ts) withvalidateContract<T>()so type inference stays precise and mirrors real usage. If a concrete contract type is available, it would be better to use that here.examples/prisma-next-demo/src/queries/similarity-search.ts (1)
1-31: Type import path is correct; consider moving the type test out of example code
- Importing
ResultTypefrom@prisma-next/contract/typesmatches the contract-type import guidelines and keeps this example aligned with other callers.- The
// @ts-expect-errortype check onRow['distance']lives in a non-test source file, which conflicts with the rule to avoid disabling type checking outside tests. Consider moving this assertion into a dedicated*.test-d.ts/type test usingexpectTypeOfand removing the@ts-expect-errorfrom this example.tsconfig.base.json (1)
19-51: Enable declaration maps is fine; consider deduplicating project referenceAdding
"declarationMap": trueis a good tooling improvement and removing path mappings from this base config aligns with the goal of avoiding cross-package TS-only imports. However,./packages/framework/core-control-planeappears twice in thereferencesarray (Line 29 and Line 35); it’s harmless but redundant and could be cleaned up in this PR or a follow-up.examples/prisma-next-demo/src/queries/get-user-posts.ts (1)
23-25: Remove @ts-expect-error from example code and move type check into testsThis example file isn’t a test, so suppressing a type error with
@ts-expect-errorconflicts with the rule that production/example code must not disable type checking. The_Testalias is purely a type-level assertion and can live in a dedicated.test-d.tsinstead.Consider removing the in-file assertion:
const plan = sql @@ - type Row = ResultType<typeof plan>; - // @ts-expect-error - This is to test the type inference - type _Test = Row['embedding']; + type Row = ResultType<typeof plan>;and, if you still need to verify inference, reintroduce the
_Testcheck in a small type test that usesexpectTypeOfrather than@ts-expect-error.As per coding guidelines,
@ts-expect-erroris only acceptable in test files with explicit justification.packages/sql/lanes/sql-lane/test/plan-types.test-d.ts (1)
643-649: Replace deprecatedexpectTypeOf().toMatchTypeOfwithtoExtendIn the “result typing is derived solely from projection, unaffected by joins” test, this line:
expectTypeOf<Row>().not.toMatchTypeOf<{ email: unknown }>();uses the deprecated
toMatchTypeOfmatcher. To follow the current Vitest type-test guidelines, you can express the same intent with:expectTypeOf<Row>().not.toExtend<{ email: unknown }>();which still asserts that
Rowdoes not have an
♻️ Duplicate comments (2)
packages/sql/lanes/orm-lane/test/fixtures/contract.d.ts (1)
6-12: Duplicate: CodecTypes duplication already flagged.This is the same duplication issue identified in
contract-with-relations.d.ts. See the previous comment for the recommendation to extract to a shared test utility.packages/sql/lanes/sql-lane/test/fixtures/contract.d.ts (1)
7-13: Duplicate: CodecTypes duplication already flagged.This file has the same CodecTypes duplication. However, the comment here is more descriptive (mentioning
createStubAdapter) than in the other two fixture files. Consider using this comment style when extracting to a shared location.
| import { | ||
| assembleOperationRegistryFromPacks, | ||
| extractCodecTypeImportsFromPacks, | ||
| extractExtensionIdsFromPacks, | ||
| extractOperationTypeImportsFromPacks, | ||
| } from '../../../packages/sql/family/src/core/assembly'; |
There was a problem hiding this comment.
Import from package exports instead of source paths.
Line 16 imports from ../../../packages/sql/family/src/core/assembly, which bypasses the package's public API. According to the coding guidelines, test files should either:
- Import from package exports when available
- Use relative imports only within the same package
Since this is a test file in a different package (test/integration), check if these functions are exported from @prisma-next/family-sql package exports. If so, update the import:
-import {
- assembleOperationRegistryFromPacks,
- extractCodecTypeImportsFromPacks,
- extractExtensionIdsFromPacks,
- extractOperationTypeImportsFromPacks,
-} from '../../../packages/sql/family/src/core/assembly';
+import {
+ assembleOperationRegistryFromPacks,
+ extractCodecTypeImportsFromPacks,
+ extractExtensionIdsFromPacks,
+ extractOperationTypeImportsFromPacks,
+} from '@prisma-next/family-sql/assembly';If these functions are not yet exported, they should be added to the package's exports to support this programmatic usage pattern.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
test/integration/test/cli.emit.test.ts lines 11-16: the test imports internal
source paths from ../../../packages/sql/family/src/core/assembly which bypasses
the package public API; update the test to import these symbols from the package
export (e.g. @prisma-next/family-sql) if those functions are already exported,
otherwise add them to the package's exports (package.json "exports" or index
barrel) and then change the import to the package path so tests consume the
public API rather than internal source files.
There was a problem hiding this comment.
Our goal was to prevent packages having untracked interdependencies. This package is just integration tests and I don't think we care enough to address this right now.
There was a problem hiding this comment.
@wmadden, understood! Since the main goal of preventing untracked interdependencies between packages is already met, and this is specific to integration test code, it makes sense to defer this. Thanks for the clarification! 👍
| // Note: executeCommand and other test helpers are re-exported at the bottom of this file | ||
| // They come from the CLI package's test utilities but are not exported from the package | ||
| // We import them directly from the source file | ||
| import { executeCommand } from '../../../../packages/framework/tooling/cli/test/utils/test-helpers'; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Document or export test utilities from CLI package.
The imports from packages/framework/tooling/cli/test/utils/test-helpers.ts bypass the package's public API. While the comment acknowledges this (lines 14-16), it indicates a design gap.
Consider one of these approaches:
-
Export test utilities from CLI package (preferred):
Add topackages/framework/tooling/cli/package.json:"./test/utils": { "types": "./dist/test/utils.d.ts", "import": "./dist/test/utils.js" }
-
Move shared test utilities to @prisma-next/test-utils:
If these utilities don't depend on CLI-specific logic, they could be moved to the shared test-utils package per the learnings about avoiding circular dependencies. -
Accept the current pattern: If this is intentional for test-only utilities, update the comment to explain why these aren't exported and document this pattern for other test files.
Also applies to: 331-338
🤖 Prompt for AI Agents
In test/integration/test/utils/cli-test-helpers.ts around lines 14 to 17, the
test helper is importing directly from the CLI package source (bypassing the
package public API); fix by either 1) exporting the test utilities from
packages/framework/tooling/cli via its package.json exports map (add an export
entry for "./test/utils" pointing to the built JS and types and then update the
import to the package public path), or 2) move the shared helpers into the
shared @prisma-next/test-utils package (move the file, update its
imports/exports, and update all test imports), or 3) if intentional, expand the
comment to explain why these utilities are not exported and document the allowed
internal import pattern for tests; implement the chosen approach and update all
duplicate occurrences (notably lines 331-338) accordingly.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
**/*.{ts,tsx}: Use the'key?'syntax with the?suffix for optional keys in Arktype schemas instead of using'string | undefined'type unions
Reference schemas directly as object property values in Arktype schemas - this works seamlessly without special syntax
Usetype({ '[string]': Schema })syntax to createRecord<string, Schema>types in Arktype instead of usingRecord<string, Schema>string notation
Use the.array()method on Arktype schemas to create array types instead of wrapping schemas intype([Schema])or using manual validation
Extract TypeScript types from Arktype schemas using the.inferproperty instead of manually duplicating type definitions
Usetype.declare<>()to ensure Arktype schemas match pre-existing TypeScript types for compile-time type safety, especially when working with readonly properties
Use.array().readonly()method chaining to create readonly array types in Arktype instead of using string notation like'string[]'
Don't manually re-validate what Arktype has already checked - once validation passes, trust the structure matches the schema
Useinstanceof type.errorsto check for Arktype validation errors instead of other error checking patterns, for proper type narrowing
Return the original input value from validation functions instead of returning the Arktype validation result to preserve literal types
**/*.{ts,tsx}: Always useControl*Descriptortypes (ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor). Legacy descriptor types have been completely removed.
All descriptors must include required properties:kind(discriminator),id(string identifier),familyId(literal type),targetId(literal type for target/adapter/driver/extension),manifest(ExtensionPackManifest), andcreate()factory method
Use base instance interfaces:ControlFamilyInstance,ControlTargetInstance,ControlAdapterInstance, `ControlDriverIn...
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
**/*.test.ts: Contract builder tests must verify that normalization happens correctly with all required fields receiving their default values
Validator tests must verify that validation fails when required fields are missing, and must NOT test normalization behavior
Parser and emitter hook tests must test functionality with normalized contracts and must NOT test normalization behavior
**/*.test.ts: In tests usingwithDevDatabase()from@prisma-next/test-utils, avoid selecting or using extension-dependent columns (like pgvector, pg_trgm) when testing features unrelated to extension functionality, as pglite does not support PostgreSQL extensions
When tests must verify extension functionality end-to-end (e.g., pgvector queries), use a real PostgreSQL database instead ofwithDevDatabase()viawithClient()andprocess.env['DATABASE_URL']
When writing ORM tests with includes, relation filters, or other non-extension features, explicitly exclude extension-dependent columns from select statements to ensure compatibility with pglite-based test databases
**/*.test.ts: Within-package tests should import from source files directly (e.g., '../src/...') rather than from package exports (e.g., '@prisma-next/package-name/...')
Cross-package tests should import from package exports rather than relative source paths
Test files should never import from their own package using package aliases (e.g., '@prisma-next/package-name/...'); always use relative imports (e.g., '../src/...')
When importing from sibling packages within the same domain in test files, use relative paths instead of workspace package names
When extracting code between packages, move tests to the new package and update test imports to use relative source paths ('../src/...')
The 'exports/' folder contains the public API surface and should not be imported from in test files; import directly from source files instead
**/*.test.ts: Avoid using type assertions in tests to bypass type checking or test i...
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
packages/sql/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
packages/sql/**/*.{ts,tsx}: Place all SQL target-family packages (all layers and planes) underpackages/sql/**- family internals including contract types, operations, emitter hooks, and lanes must be target-agnostic and not contain concrete dialect code
Do not place concrete target code (dialects, adapters, drivers) underpackages/sql/**
packages/sql/**/*.{ts,tsx}: Use a generic type parameter that accumulates include definitions (with anIncludestype parameter) inincludeManybuilder implementations to track include definitions across multiple calls and infer correct array types in the final result
Use a helper type likeExtractIncludeType<K extends string, Includes>that safely extracts types from accumulated include maps with a fallback tounknownif the key doesn't exist
Handle booleantruein type inference to allowselect({ posts: true })syntax to inferArray<ChildShape>from the accumulated Includes map
Implement runtime capability checks in builder methods (likereturning()andincludeMany()) that verify required capabilities exist and are set totruebefore proceeding with implementation, throwing aplanInvaliderror if missing
For features requiring multiple capabilities (e.g.,includeManyrequiring both 'lateral' and 'jsonAgg'), check that all required capabilities are present and set totruein a single runtime validation
packages/sql/**/*.{ts,tsx}: Import and usetablesdirectly fromquery.tsinstead of accessing throughschema.tablesfor improved readability (e.g.,tables.userinstead ofschema.tables.user)
Extract table and column variables only when the same table/columns are used multiple times in a function or when it improves readability; use direct access for single-use queries
UseResultType<typeof plan>to extract row types from Prisma query plans instead of manually defining types
Use DML operations withreturning()clause for INSERT, UPDATE, and DELETE queries to retrieve affected rows (e...
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)
packages/**/*.{ts,tsx}: Same-layer imports are allowed: packages in the same layer can import from each other (e.g.,orm-lanecan import fromsql-relational-coreif both are in thelaneslayer)
Cross-layer imports must flow inward (toward core): packages can only import from inner layers (closer to core). Outer layers cannot import from inner layers (e.g., core layer cannot import from lanes layer)Import SQL emitter hook (
sqlTargetFamilyHook) from@prisma-next/sql-contract-emitter
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)
**/*.ts: Start refactoring by extracting pure, side-effect-free utility functions as thin wrappers around AST factories and error constructors
Extract state management into separate modules defining immutable state shapes and interfaces
Replaceanytypes with proper generic type parameters during function extraction, using existing type definitions likeModelColumnAccessor
Use thecompacthelper function to removeundefinedvalues from objects when TypeScript'sexactOptionalPropertyTypesis enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value importsDo not export functions, types, or utilities solely for test use; instead, tests should import from source using relative paths within the same package or refactor to use public APIs
**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid in TypeScript. Use non-null assertions (!) after validation checks instead of optional chaining or defensive conditionals.
Use assertions to access validated properties directly (e.g., columnMeta.codecId, columnMeta.nullable) instead of optional chaining (columnMeta?.codecId) after validation has already occurred.
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/packages/**/+(*.test|*.spec).{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)
In test files, update paths to other packages, extension pack manifests, fixtures, and import paths based on the new package location's directory depth from root
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.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/sql/lanes/relational-core/test/column-builder-operations.test.ts
packages/sql/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/sql/**/*.{ts,tsx,js}: 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 table and column: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))
Use column aliases in ORDER BY clauses when the column is in the SELECT list, mapping column references to their aliases before generating the ORDER BY clause
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers with
.toMatchObject()over multiple individualexpect().toBe()calls when checking 2+ related values in tests
**/*.{test,spec}.ts: Test files must not exceed 500 lines; split files that exceed this limit into multiple files organized by logical functionality
Split test files by logical groupings: by functionality (basic, errors, structure), by feature area (joins, projections, includes), or by test type (unit, integration, edge-cases)
Use descriptive test file names following the pattern{base}.{category}.test.ts, where base name indicates the subject being tested and category indicates the test type (e.g.,.basic.test.ts,.errors.test.ts,.joins.test.ts)
Ensure each split test file contains all necessary imports, setup/teardown code, and is independently runnable without dependencies on other test files
Prefer object comparison assertions usingtoEqualortoMatchObjectinstead of piece-by-piece property checks withtoHavePropertyor individual type assertions
Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks when performing partial object comparisons
Compare entire plan structures using object comparison assertions instead of checking individual AST fields piecemeal to ensure all fields are present and correctUse factory functions (such as
createColumnRef,createParamRef,createLiteralExpr,createTableRef,createBinaryExpr) for creating AST nodes in tests instead of manual object creationUse factory functions (e.g.,
createContractIR()) instead of manual object creation when creatingContractIRobjects in tests. Ensure all required fields (schemaVersion, targetFamily, target, models, relations, storage, extensions, capabilities, meta, sources) are present through the factory function rather than manual construction.
**/*.{test,spec}.ts: Do not use the deprecatedtoMatchTypeOf()matcher in Vitest'sexpectTypeOfAPI; usetoExtend()instead for verifying ...
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Import from shared plane packages using the package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/folders
**/*.{ts,tsx,js,jsx}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing via import validationIf you need to disable a Biome rule for more than a couple of lines in a file, use a file-level disable comment at the top instead of many inline disable comments.
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
packages/**/test/**/*.{ts,test.ts}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Shared plane packages should include unit tests for validators and factories, type tests for exported types, and no integration tests requiring migration or runtime plane packages
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.test.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)
**/*.test.{ts,tsx,js}: Test descriptions should omit 'should' - use direct action-oriented phrases like 'returns correct value' instead of 'should return correct value'
Test fixtures should not depend on specific adapters (e.g.,@prisma-next/adapter-postgres). DefineCodecTypesinline in test fixtures to remain adapter-agnostic and usecreateStubAdapter()from@prisma-next/runtime/test/utilsinstead of specific adapter factories.
Import test utilities from specific packages to avoid circular dependencies: Use@prisma-next/test-utilsfor generic database/async utilities,@prisma-next/runtime/test/utilsfor runtime-specific utilities, ande2e-tests/test/utils.tsfor contract-related E2E utilities.
UsewithDevDatabasefor automatic database cleanup and ensure only one connection at a time. Close thewithClientconnection before running CLI commands that need their own database connection.
UsecollectAsync()orexecutePlanAndCollect()to collect all results from async iterables, ordrainAsyncIterable()/drainPlanExecution()to drain without collecting.
Keep test files under 500 lines maximum. Split large files by functionality (basic, errors, structure, generation), feature area (joins, projections, includes), or test type (unit, integration, edge-cases). Use descriptive file names likecodecs.registry.test.ts,runtime.joins.test.ts,driver.errors.test.ts.
Prefer object comparison usingtoEqual()ortoMatchObject()instead of piece-by-piece property checks withtoHaveProperty()and type casts.
UsetoMatchObject()for JSON parsing assertions without type casts. Useexpect.anything()for nested objects when verifying existence.
Use the extension mechanism viacreateTestContextwith anextensionsparameter to register operations and codecs programmatically, rather than manually creating operation registries.
Let TypeScript automatically infer return types from plans usingResultType<typeof plan>rather than manual type param...
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)
Always quote table names in SQL statements to handle PostgreSQL reserved keywords (e.g., use
"user"instead ofuser).
**/*.{ts,tsx,js}: Follow layering rules and exceptions (see .cursor/rules/import-validation.mdc)
Resolve cyclic dependencies by checking for unused dependencies (see .cursor/rules/resolving-cyclic-dependencies.mdc)
Prefer declarative configuration over hardcoded logic (see .cursor/rules/declarative-config.mdc)
Prohibit inline type imports in source files (see .cursor/rules/no-inline-imports.mdc)
Use Object.hasOwn() instead of hasOwnProperty() (see .cursor/rules/object-hasown.mdc)
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages onlyKeep tests concise; omit 'should' from test names
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{test,spec}.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.{test,spec}.{ts,tsx,js}: Test descriptions omit 'should' (see .cursor/rules/omit-should-in-tests.mdc)
Follow testing guide pointers and patterns (see .cursor/rules/testing-guide.mdc)
Use test import patterns: source files, relative paths, don't export for tests (see .cursor/rules/test-import-patterns.mdc)
Organize test files with max 500 lines, split by functionality (see .cursor/rules/test-file-organization.mdc)
Follow test database limitations and patterns (see .cursor/rules/test-database-limitations.mdc)
Prefer object matchers over multiple individual expect().toBe() calls (see .cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (see .cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests (see .cursor/rules/use-contract-ir-factories.mdc)
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
**/*.{test,spec}.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use type test patterns with vitest.expectTypeOf (see .cursor/rules/vitest-expect-typeof.mdc)
**/*.{test,spec}.{ts,tsx}: Always validate contracts in tests usingvalidateContract()function. Contracts must have fully qualified type IDs (e.g., 'pg/text@1') not bare scalars (e.g., 'text'). Type canonicalization happens at authoring time, not during validation.
In test files only, use@ts-expect-errorcomments with explanations when working with dynamic proxy objects or complex type scenarios that require intentional type assertions.
When creating test mocks that don't perfectly match types, useas unknown as Type(double cast). Useunknowninstead ofanyto maintain type safety. This is only acceptable in test code.
When mocking class instances in tests, never use the spread operator (...) as it loses methods. UseObject.create()andObject.assign()to preserve the prototype chain.
Common patterns in test files should be extracted into helper functions with JSDoc comments. Check@prisma-next/test-utilsand@prisma-next/runtime/test/utilsfor shared helpers before creating new ones.
Files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-file-organization.mdc:0-0
Timestamp: 2025-12-04T12:15:57.358Z
Learning: Applies to **/*integration*.{test,spec}.ts : When splitting test files with multiple packages, place integration tests that depend on multiple packages in `prisma-next/integration-tests` to avoid cyclic dependencies
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/cli-e2e-test-patterns.mdc:0-0
Timestamp: 2025-12-05T14:23:28.220Z
Learning: Applies to packages/framework/tooling/cli/test/cli-e2e-test-app/package.json : Keep the root `package.json` in `packages/framework/tooling/cli/test/cli-e2e-test-app/` static with dependencies installed via `pnpm install` for workspace dependency resolution
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/resolving-cyclic-dependencies.mdc:0-0
Timestamp: 2025-12-04T12:15:08.433Z
Learning: Remove unused dependencies from package.json when they create cyclic dependencies, then run `pnpm install` and `pnpm typecheck` to verify no breaks occur
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test.{ts,tsx,js} : Import test utilities from specific packages to avoid circular dependencies: Use `prisma-next/test-utils` for generic database/async utilities, `prisma-next/runtime/test/utils` for runtime-specific utilities, and `e2e-tests/test/utils.ts` for contract-related E2E utilities.
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Test packages moved to `test/` directory must remain in `pnpm-workspace.yaml` for dependency resolution, be marked as `private: true` in `package.json`, use `workspace:*` protocol for dependencies, not be included in `architecture.config.json`, and be excluded from dependency cruiser checks
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Applies to **/packages/**/+(*.test|*.spec).{ts,tsx,js,jsx} : In test files, update paths to other packages, extension pack manifests, fixtures, and import paths based on the new package location's directory depth from root
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:05:24.382Z
Learning: When adding features that span multiple packages, build from root (`pnpm build`) to ensure correct dependency order
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{ts,tsx,js} : Resolve cyclic dependencies by checking for unused dependencies (see .cursor/rules/resolving-cyclic-dependencies.mdc)
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/*.test.ts : When importing from sibling packages within the same domain in test files, use relative paths instead of workspace package names
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to tsup.config.ts : Mark workspace packages and external dependencies as external in `tsup.config.ts` to prevent bundling CommonJS dependencies into ESM bundles and avoid vite parsing errors.
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js} : Use test import patterns: source files, relative paths, don't export for tests (see .cursor/rules/test-import-patterns.mdc)
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Applies to tsconfig.base.json : In `tsconfig.base.json`, update path mappings and project references to reflect new package locations after moves
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/*.test.ts : When extracting code between packages, move tests to the new package and update test imports to use relative source paths ('../src/...')
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/multi-plane-entrypoints.mdc:0-0
Timestamp: 2025-12-04T12:13:43.878Z
Learning: Applies to **/package.json : Export subpath entrypoints in `package.json` with correct types and import mappings for `./adapter`, `./control`, and `./runtime` paths
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Applies to dependency-cruiser.config.mjs : In `dependency-cruiser.config.mjs`, update exclude patterns to reflect new package locations after moves
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/test/fixtures/**/*.ts : Test fixtures should import from package exports using workspace package names, not relative source paths
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.e2e.{test,spec}.{ts,tsx,js} : Use CLI e2e test fixture patterns with shared fixture app (see .cursor/rules/cli-e2e-test-patterns.mdc)
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/multi-plane-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:53.734Z
Learning: Applies to **/src/exports/**/*.ts : Exports directory (`src/exports/`) should include re-export files (adapter.ts, codec-types.ts, types.ts) in addition to plane-specific entry points (control.ts, runtime.ts)
📚 Learning: 2025-12-04T12:15:37.900Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/sql-types-imports.mdc:0-0
Timestamp: 2025-12-04T12:15:37.900Z
Learning: Applies to packages/sql/**/*.{ts,tsx} : Import SQL-specific operations (`OperationSignature`, `LoweringSpec`, `assembleOperationRegistry`) from `prisma-next/sql-operations` (shared plane package)
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:15:37.900Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/sql-types-imports.mdc:0-0
Timestamp: 2025-12-04T12:15:37.900Z
Learning: Applies to **/*.{ts,tsx} : Import target-neutral operations (`OperationRegistry`, `ArgSpec`, `ReturnSpec`, `createOperationRegistry`) from `prisma-next/operations`
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:17:25.153Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/use-ast-factories.mdc:0-0
Timestamp: 2025-12-04T12:17:25.153Z
Learning: Applies to **/*.{test,spec}.ts : Use factory functions (such as `createColumnRef`, `createParamRef`, `createLiteralExpr`, `createTableRef`, `createBinaryExpr`) for creating AST nodes in tests instead of manual object creation
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-05T14:24:04.497Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/typescript-patterns.mdc:0-0
Timestamp: 2025-12-05T14:24:04.497Z
Learning: Applies to **/*.{ts,tsx} : When extracting types from `ColumnBuilder` instances, use `infer` for all type parameters to allow correct type inference. Avoid constraining type parameters too strictly with `infer T extends SomeType` when it prevents matching specific operation types.
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:15:46.557Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-database-limitations.mdc:0-0
Timestamp: 2025-12-04T12:15:46.557Z
Learning: Applies to **/*.test.ts : In tests using `withDevDatabase()` from `prisma-next/test-utils`, avoid selecting or using extension-dependent columns (like pgvector, pg_trgm) when testing features unrelated to extension functionality, as pglite does not support PostgreSQL extensions
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-05T14:24:04.497Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/typescript-patterns.mdc:0-0
Timestamp: 2025-12-05T14:24:04.497Z
Learning: Applies to **/*.{ts,tsx} : `AnyColumnBuilder` must use `any` for the `Operations` parameter due to TypeScript's variance limitations. This exception requires a documented explanation of why `any` is necessary.
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:16:59.752Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/type-extraction-from-contract.mdc:0-0
Timestamp: 2025-12-04T12:16:59.752Z
Learning: Applies to **/*.{ts,tsx} : Never pass `CodecTypes` or `OperationTypes` as separate type parameters to `schema()`, `sql()`, or `orm()` functions
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-05T14:23:37.092Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/prefer-assertions-over-defensive-checks.mdc:0-0
Timestamp: 2025-12-05T14:23:37.092Z
Learning: Applies to **/*.test.ts : Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract<SqlStorage>') to test scenarios that contradict validated schemas.
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-05T14:23:14.550Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{ts,tsx} : Import SQL types from prisma-next/sql-contract/types (see .cursor/rules/sql-types-imports.mdc)
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:15:46.557Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-database-limitations.mdc:0-0
Timestamp: 2025-12-04T12:15:46.557Z
Learning: Applies to **/*.test.ts : When writing ORM tests with includes, relation filters, or other non-extension features, explicitly exclude extension-dependent columns from select statements to ensure compatibility with pglite-based test databases
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test.{ts,tsx,js} : Test fixtures should not depend on specific adapters (e.g., `prisma-next/adapter-postgres`). Define `CodecTypes` inline in test fixtures to remain adapter-agnostic and use `createStubAdapter()` from `prisma-next/runtime/test/utils` instead of specific adapter factories.
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test-d.ts : Use `expectTypeOf` from Vitest for type testing in type test files (not runtime assertions)
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-11-25T12:27:11.738Z
Learnt from: CR
Repo: prisma/pdp-control-plane PR: 0
File: packages/interactors/AGENTS.md:0-0
Timestamp: 2025-11-25T12:27:11.738Z
Learning: Applies to packages/interactors/**/*.test.ts : Tests are written using Vitest
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test.{ts,tsx,js} : Import test utilities from specific packages to avoid circular dependencies: Use `prisma-next/test-utils` for generic database/async utilities, `prisma-next/runtime/test/utils` for runtime-specific utilities, and `e2e-tests/test/utils.ts` for contract-related E2E utilities.
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:15:46.557Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-database-limitations.mdc:0-0
Timestamp: 2025-12-04T12:15:46.557Z
Learning: Applies to **/*.test.ts : When tests must verify extension functionality end-to-end (e.g., pgvector queries), use a real PostgreSQL database instead of `withDevDatabase()` via `withClient()` and `process.env['DATABASE_URL']`
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:12:15.848Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/contract-normalization-responsibilities.mdc:0-0
Timestamp: 2025-12-04T12:12:15.848Z
Learning: Applies to prisma-next/sql-query/src/contract.ts : The `validateContract()` function must assume the contract passed to it is already normalized (all required fields present) and throw errors if required fields are missing or have incorrect types
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:12:15.848Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/contract-normalization-responsibilities.mdc:0-0
Timestamp: 2025-12-04T12:12:15.848Z
Learning: Applies to prisma-next/sql-query/src/contract.ts : The `validateContract()` function must validate contract structure and types only, using Arktype schemas for structural validation and checking logical consistency (e.g., FK references), but must NOT normalize the contract or set default values for missing fields
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:12:15.848Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/contract-normalization-responsibilities.mdc:0-0
Timestamp: 2025-12-04T12:12:15.848Z
Learning: Applies to prisma-next/sql-query/src/contract-builder.ts : The contract builder must always output a fully normalized contract with all required ContractIR fields present (non-optional), allowing empty objects/arrays but ensuring no fields are missing
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
📚 Learning: 2025-12-04T12:12:15.848Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/contract-normalization-responsibilities.mdc:0-0
Timestamp: 2025-12-04T12:12:15.848Z
Learning: Applies to prisma-next/cli/src/load-ts-contract.ts : The `loadContractFromTs()` function must assume contracts loaded from manually-written files should be normalized elsewhere (e.g., in the contract builder) and not perform normalization itself
Applied to files:
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts
🧬 Code graph analysis (1)
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts (1)
packages/sql/lanes/relational-core/src/ast/types.ts (1)
OperationExpr(31-39)
🔇 Additional comments (1)
packages/sql/lanes/relational-core/test/column-builder-operations.test.ts (1)
326-348: Good removal of inline type imports.Replacing the inline type imports with a top-level import reduces dependency on tsconfig path mappings and aligns with the PR objectives. The type references are now cleaner and easier to maintain.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
packages/framework/tooling/cli/vitest.config.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
**/*.{ts,tsx}: Use the'key?'syntax with the?suffix for optional keys in Arktype schemas instead of using'string | undefined'type unions
Reference schemas directly as object property values in Arktype schemas - this works seamlessly without special syntax
Usetype({ '[string]': Schema })syntax to createRecord<string, Schema>types in Arktype instead of usingRecord<string, Schema>string notation
Use the.array()method on Arktype schemas to create array types instead of wrapping schemas intype([Schema])or using manual validation
Extract TypeScript types from Arktype schemas using the.inferproperty instead of manually duplicating type definitions
Usetype.declare<>()to ensure Arktype schemas match pre-existing TypeScript types for compile-time type safety, especially when working with readonly properties
Use.array().readonly()method chaining to create readonly array types in Arktype instead of using string notation like'string[]'
Don't manually re-validate what Arktype has already checked - once validation passes, trust the structure matches the schema
Useinstanceof type.errorsto check for Arktype validation errors instead of other error checking patterns, for proper type narrowing
Return the original input value from validation functions instead of returning the Arktype validation result to preserve literal types
**/*.{ts,tsx}: Always useControl*Descriptortypes (ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor). Legacy descriptor types have been completely removed.
All descriptors must include required properties:kind(discriminator),id(string identifier),familyId(literal type),targetId(literal type for target/adapter/driver/extension),manifest(ExtensionPackManifest), andcreate()factory method
Use base instance interfaces:ControlFamilyInstance,ControlTargetInstance,ControlAdapterInstance, `ControlDriverIn...
Files:
packages/framework/tooling/cli/vitest.config.ts
**/*config.ts
📄 CodeRabbit inference engine (.cursor/rules/config-validation-and-normalization.mdc)
**/*config.ts: Use Arktype for validation indefineConfig()functions when implementing config files
Validate config structure using Arktype schemas and throw errors with clear messages when structure is invalid
Apply default values for optional config fields indefineConfig()and return a fully normalized config object
Usejoin()anddirname()fromnode:pathfor default path resolution in normalized config outputs
Validate and normalize nested config structures at each level using Arktype schemas
Join multiple Arktype validation error messages with semicolons for clear, actionable error reporting to users
Files:
packages/framework/tooling/cli/vitest.config.ts
**/cli/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
Always pass a
driverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit). This ensures consistent descriptor patterns across all commands.
Files:
packages/framework/tooling/cli/vitest.config.ts
**/*.config.*
📄 CodeRabbit inference engine (.cursor/rules/declarative-config.mdc)
Prefer declarative configuration over hardcoded logic in config generators - use declarative data structures (JSON config files) instead of hardcoded conditionals for validation rules, constraints, and configuration logic
Files:
packages/framework/tooling/cli/vitest.config.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/import-validation.mdc)
packages/**/*.{ts,tsx}: Same-layer imports are allowed: packages in the same layer can import from each other (e.g.,orm-lanecan import fromsql-relational-coreif both are in thelaneslayer)
Cross-layer imports must flow inward (toward core): packages can only import from inner layers (closer to core). Outer layers cannot import from inner layers (e.g., core layer cannot import from lanes layer)Import SQL emitter hook (
sqlTargetFamilyHook) from@prisma-next/sql-contract-emitter
Files:
packages/framework/tooling/cli/vitest.config.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/modular-refactoring-patterns.mdc)
**/*.ts: Start refactoring by extracting pure, side-effect-free utility functions as thin wrappers around AST factories and error constructors
Extract state management into separate modules defining immutable state shapes and interfaces
Replaceanytypes with proper generic type parameters during function extraction, using existing type definitions likeModelColumnAccessor
Use thecompacthelper function to removeundefinedvalues from objects when TypeScript'sexactOptionalPropertyTypesis enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value importsDo not export functions, types, or utilities solely for test use; instead, tests should import from source using relative paths within the same package or refactor to use public APIs
**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid in TypeScript. Use non-null assertions (!) after validation checks instead of optional chaining or defensive conditionals.
Use assertions to access validated properties directly (e.g., columnMeta.codecId, columnMeta.nullable) instead of optional chaining (columnMeta?.codecId) after validation has already occurred.
Files:
packages/framework/tooling/cli/vitest.config.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Import from shared plane packages using the package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/folders
**/*.{ts,tsx,js,jsx}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing via import validationIf you need to disable a Biome rule for more than a couple of lines in a file, use a file-level disable comment at the top instead of many inline disable comments.
Files:
packages/framework/tooling/cli/vitest.config.ts
**/vitest.config.ts
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
**/vitest.config.ts: Vitest configuration should use the 'vite-tsconfig-paths' plugin to automatically resolve workspace dependencies using tsconfig path mappings instead of manual aliases
In vitest.config.ts, external packages in imports should be sorted alphabetically and Biome will enforce this ordering
Files:
packages/framework/tooling/cli/vitest.config.ts
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)
Always quote table names in SQL statements to handle PostgreSQL reserved keywords (e.g., use
"user"instead ofuser).
**/*.{ts,tsx,js}: Follow layering rules and exceptions (see .cursor/rules/import-validation.mdc)
Resolve cyclic dependencies by checking for unused dependencies (see .cursor/rules/resolving-cyclic-dependencies.mdc)
Prefer declarative configuration over hardcoded logic (see .cursor/rules/declarative-config.mdc)
Prohibit inline type imports in source files (see .cursor/rules/no-inline-imports.mdc)
Use Object.hasOwn() instead of hasOwnProperty() (see .cursor/rules/object-hasown.mdc)
Files:
packages/framework/tooling/cli/vitest.config.ts
🧠 Learnings (18)
📓 Common learnings
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-file-organization.mdc:0-0
Timestamp: 2025-12-04T12:15:57.358Z
Learning: Applies to **/*integration*.{test,spec}.ts : When splitting test files with multiple packages, place integration tests that depend on multiple packages in `prisma-next/integration-tests` to avoid cyclic dependencies
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test.{ts,tsx,js} : Import test utilities from specific packages to avoid circular dependencies: Use `prisma-next/test-utils` for generic database/async utilities, `prisma-next/runtime/test/utils` for runtime-specific utilities, and `e2e-tests/test/utils.ts` for contract-related E2E utilities.
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/resolving-cyclic-dependencies.mdc:0-0
Timestamp: 2025-12-04T12:15:08.433Z
Learning: Remove unused dependencies from package.json when they create cyclic dependencies, then run `pnpm install` and `pnpm typecheck` to verify no breaks occur
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/cli-e2e-test-patterns.mdc:0-0
Timestamp: 2025-12-05T14:23:28.220Z
Learning: Applies to packages/framework/tooling/cli/test/cli-e2e-test-app/package.json : Keep the root `package.json` in `packages/framework/tooling/cli/test/cli-e2e-test-app/` static with dependencies installed via `pnpm install` for workspace dependency resolution
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Test packages moved to `test/` directory must remain in `pnpm-workspace.yaml` for dependency resolution, be marked as `private: true` in `package.json`, use `workspace:*` protocol for dependencies, not be included in `architecture.config.json`, and be excluded from dependency cruiser checks
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{ts,tsx,js} : Resolve cyclic dependencies by checking for unused dependencies (see .cursor/rules/resolving-cyclic-dependencies.mdc)
Learnt from: carlagn
Repo: prisma/website PR: 1272
File: app/mcp/HeroBg.tsx:236-245
Timestamp: 2025-10-09T18:46:35.603Z
Learning: In PR #1272 for the prisma/website repository, the user carlagn requested not to provide additional review comments on the file `app/mcp/HeroBg.tsx` after initial suggestions were made, to avoid piling up changes while they implement fixes.
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Applies to **/packages/**/+(*.test|*.spec).{ts,tsx,js,jsx} : In test files, update paths to other packages, extension pack manifests, fixtures, and import paths based on the new package location's directory depth from root
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/*.test.ts : When importing from sibling packages within the same domain in test files, use relative paths instead of workspace package names
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/*.test.ts : Cross-package tests should import from package exports rather than relative source paths
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/test/fixtures/**/*.ts : Test fixtures should import from package exports using workspace package names, not relative source paths
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js} : Use test import patterns: source files, relative paths, don't export for tests (see .cursor/rules/test-import-patterns.mdc)
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/*.test.ts : When extracting code between packages, move tests to the new package and update test imports to use relative source paths ('../src/...')
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.e2e.{test,spec}.{ts,tsx,js} : Use CLI e2e test fixture patterns with shared fixture app (see .cursor/rules/cli-e2e-test-patterns.mdc)
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-file-organization.mdc:0-0
Timestamp: 2025-12-04T12:15:57.358Z
Learning: Applies to **/*.{test,spec}.ts : Ensure each split test file contains all necessary imports, setup/teardown code, and is independently runnable without dependencies on other test files
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/moving-packages.mdc:0-0
Timestamp: 2025-12-04T12:13:35.471Z
Learning: Applies to dependency-cruiser.config.mjs : In `dependency-cruiser.config.mjs`, update exclude patterns to reflect new package locations after moves
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to vitest.config.{ts,js} : Configure coverage explicitly in vitest config with `include: ['src/**/*.ts']` to ensure source files are tracked. Import from source in tests (e.g., `../src/index`) not from package exports.
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-03T14:12:46.151Z
Learnt from: CR
Repo: prisma/ppg-canaries PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:12:46.151Z
Learning: Applies to tests/**/*.test.ts : All tests must pass with pnpm test and coverage must be maintained or improved
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:37.092Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/prefer-assertions-over-defensive-checks.mdc:0-0
Timestamp: 2025-12-05T14:23:37.092Z
Learning: Applies to **/*.test.ts : Remove tests that use type assertions to test impossible states or test code coverage without testing real scenarios. After refactoring to use assertions, clean up unrealistic test cases.
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-11-25T12:27:11.738Z
Learnt from: CR
Repo: prisma/pdp-control-plane PR: 0
File: packages/interactors/AGENTS.md:0-0
Timestamp: 2025-11-25T12:27:11.738Z
Learning: Applies to packages/interactors/**/*.test.ts : Tests are written using Vitest
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-11-25T09:20:46.384Z
Learnt from: CR
Repo: prisma/pdp-cloudflare PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-25T09:20:46.384Z
Learning: When modifying TypeScript files in the services directory (matching 'services/**/*.ts'), you must also add or modify at least one corresponding test file matching either '**/*.test.ts' or '**/*.spec.ts' to ensure proper test coverage
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-04T12:16:13.591Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-import-patterns.mdc:0-0
Timestamp: 2025-12-04T12:16:13.591Z
Learning: Applies to **/vitest.config.ts : Vitest configuration should use the 'vite-tsconfig-paths' plugin to automatically resolve workspace dependencies using tsconfig path mappings instead of manual aliases
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test-d.ts : Use `expectTypeOf` from Vitest for type testing in type test files (not runtime assertions)
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:28.220Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/cli-e2e-test-patterns.mdc:0-0
Timestamp: 2025-12-05T14:23:28.220Z
Learning: Applies to packages/framework/tooling/cli/test/**/*.test.{ts,tsx} : Do not pass `stdio` option with `execFile`; use `execFile` (not `spawn`) which captures stdout/stderr by default without needing the `stdio` option
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:28.220Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/cli-e2e-test-patterns.mdc:0-0
Timestamp: 2025-12-05T14:23:28.220Z
Learning: Applies to packages/framework/tooling/cli/test/**/*.test.{ts,tsx} : Use `setupTestDirectoryFromFixtures()` helper to create isolated ephemeral test directories from fixture subdirectories in CLI e2e tests
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:14.550Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.e2e.{test,spec}.{ts,tsx,js} : Use CLI e2e test fixture patterns with shared fixture app (see .cursor/rules/cli-e2e-test-patterns.mdc)
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-04T12:16:51.399Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/testing-guide.mdc:0-0
Timestamp: 2025-12-04T12:16:51.399Z
Learning: Applies to **/*.test.{ts,tsx,js} : Keep test files under 500 lines maximum. Split large files by functionality (basic, errors, structure, generation), feature area (joins, projections, includes), or test type (unit, integration, edge-cases). Use descriptive file names like `codecs.registry.test.ts`, `runtime.joins.test.ts`, `driver.errors.test.ts`.
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:14.550Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js} : Organize test files with max 500 lines, split by functionality (see .cursor/rules/test-file-organization.mdc)
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-04T12:15:57.358Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/test-file-organization.mdc:0-0
Timestamp: 2025-12-04T12:15:57.358Z
Learning: Applies to **/*.{test,spec}.ts : Test files must not exceed 500 lines; split files that exceed this limit into multiple files organized by logical functionality
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-04T12:15:30.047Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/shared-plane-packages.mdc:0-0
Timestamp: 2025-12-04T12:15:30.047Z
Learning: Applies to packages/**/test/**/*.{ts,test.ts} : Shared plane packages should include unit tests for validators and factories, type tests for exported types, and no integration tests requiring migration or runtime plane packages
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-03T09:31:15.792Z
Learnt from: CR
Repo: prisma/pdp-cloudflare PR: 0
File: services/tenant-manager/AGENTS.md:0-0
Timestamp: 2025-12-03T09:31:15.792Z
Learning: Applies to services/tenant-manager/tests/**/*.test.ts : Test suite must cover all critical paths including provisioning, cleanup, and error scenarios
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-08T11:20:55.987Z
Learnt from: CR
Repo: prisma/pdp-cloudflare PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T11:20:55.987Z
Learning: Applies to **/test/**/*.test.ts : Write unit tests for individual functions and classes
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
📚 Learning: 2025-12-05T14:23:14.550Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/README.md:0-0
Timestamp: 2025-12-05T14:23:14.550Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js} : Follow testing guide pointers and patterns (see .cursor/rules/testing-guide.mdc)
Applied to files:
packages/framework/tooling/cli/vitest.config.ts
This PR eliminates the ability to import from other packages in the monorepo without explicitly including the workspace dependency in the
package.jsonof the consumer.The
pathsoption of tsconfig enables these mistakes to be easily made, so we rely on pnpm workspace links instead. TurboRepo ensures we compile dependencies in the correct order as well.TODO
rootDiroption to package tsconfig to address ambiguous root directorySummary by CodeRabbit
New Features
Architecture & Configuration
Documentation
Chores / Tests
✏️ Tip: You can customize this high-level summary in your review settings.