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

TML-1757: Unify FamilyInstance type hierarchy - #56

Merged
wmadden merged 32 commits into
mainfrom
tml-1757-unify-familyinstance-type-hierarchy
Dec 31, 2025
Merged

wmadden merged 32 commits into
mainfrom
tml-1757-unify-familyinstance-type-hierarchy

Conversation

@wmadden

@wmadden wmadden commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor

    • Unified component descriptor/instance model into a shared framework surface; control and runtime descriptors now inherit from it.
    • Strengthened generic typings across driver/descriptors and control/runtime instances.
  • Chores

    • Added a new public export for framework component types.
    • Updated CLI/tooling to use the new control-oriented public surface.
  • Documentation

    • Expanded README and examples to cover the new component model and control-plane types.
  • Tests

    • Updated tests and mocks to match the revised public typings.

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

@coderabbitai

coderabbitai Bot commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Refactors descriptor and instance types to a shared framework-components model, parameterizes control/driver instance generics (familyId, targetId), tightens SQL/postgres driver typings, removes several per-plane duplicated fields, adds framework-components export, and eliminates local FamilyInstance casts in CLI/tests. Also removes one exported FamilyInstance from a control-plane export barrel.

Changes

Cohort / File(s) Summary
Shared framework-components new entrypoint & types
packages/1-framework/1-core/shared/contract/src/framework-components.ts, packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts, packages/1-framework/1-core/shared/contract/package.json, packages/1-framework/1-core/shared/contract/tsup.config.ts, packages/1-framework/1-core/shared/contract/README.md
Add a shared ComponentDescriptor/FamilyDescriptor/TargetDescriptor/AdapterDescriptor/DriverDescriptor/ExtensionDescriptor model and identity instance bases (FamilyInstance, TargetInstance, AdapterInstance, DriverInstance, ExtensionInstance); expose via ./framework-components export and build config; expand docs.
Control-plane surface refactor & generics
packages/1-framework/1-core/migration/control-plane/src/types.ts, packages/1-framework/1-core/migration/control-plane/src/config-types.ts, packages/1-framework/1-core/migration/control-plane/src/migrations.ts
Control descriptors/instances now extend shared bases; ControlFamilyInstance surface expanded with validate/verify/schemaVerify/sign/introspect/toSchemaView/emitContract methods and generic TSchemaIR; ControlDriverInstance and other control interfaces parameterized as <TFamilyId, TTargetId>; CliDriver and migration-runner driver typings updated to ControlDriverInstance<string,string>.
Removed export: FamilyInstance from control-plane barrel
packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
Deleted FamilyInstance from the export type { ... } block in the control-plane exports barrel.
Runtime-plane descriptor/inheritance updates
packages/1-framework/1-core/runtime/execution-plane/src/types.ts
Runtime descriptors/instances now extend shared framework-components types (removed per-plane manifest/kind/id/familyId/targetId duplicates); imports switched to framework-components and create signatures adjusted to composed descriptors.
SQL family: tighten driver generics & runtime types
packages/2-sql/3-tooling/family/src/core/control-adapter.ts, packages/2-sql/3-tooling/family/src/core/instance.ts, packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts, packages/2-sql/3-tooling/family/src/core/runtime-instance.ts, packages/2-sql/3-tooling/family/src/core/migrations/types.ts, packages/2-sql/3-tooling/family/src/core/verify.ts, packages/2-sql/3-tooling/family/src/core/descriptor.ts
Replace broad ControlDriverInstance usages with ControlDriverInstance<'sql', ...>; introduce SqlRuntimeDriverInstance and SqlRuntimeAdapterInstance types; propagate SQL-specific adapter/driver instance types through descriptors and runtime factory signatures; tighten validateContractIR return typing.
Postgres target/driver typing adjustments
packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts, packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts, packages/3-targets/7-drivers/postgres/src/exports/control.ts, packages/3-targets/7-drivers/postgres/src/exports/runtime.ts, test/integration/test/family.introspect.test.ts
Introspect and helper signatures updated to ControlDriverInstance<'sql','postgres'>; tests/mocks updated to include familyId: 'sql' and targetId: 'postgres'; PostgresControlDriver implements ControlDriverInstance<'sql','postgres'> and exposes readonly familyId = 'sql'.
CLI: remove local typed FamilyInstance casts
packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts, packages/1-framework/3-tooling/cli/src/commands/db-init.ts, packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts, packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts, packages/1-framework/3-tooling/cli/src/commands/db-sign.ts, packages/1-framework/3-tooling/cli/src/commands/db-verify.ts, packages/1-framework/3-tooling/cli/README.md
Remove FamilyInstance type imports and local typedFamilyInstance casts; code now uses inferred familyInstance directly; documentation updated to Control-prefixed surfaces.
Tests & mocks adjusted for new typings
packages/1-framework/3-tooling/cli/test/config-types.test.ts, test/integration/test/cli.emit-contract.test.ts, test/integration/test/family.schema-verify.helpers.ts, test/integration/test/family.introspect.test.ts, packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
Remove FamilyInstance casts in tests, add explicit return types where needed (e.g., SqlControlFamilyInstance), update mocks to include familyId/targetId aligned with parameterized driver types; expand mock schemaVerify/sign return shapes in test helper.
Migration & tooling driver typing updates
packages/1-framework/1-core/migration/control-plane/src/migrations.ts, packages/1-framework/1-core/migration/control-plane/src/config-types.ts, packages/2-sql/3-tooling/family/src/core/migrations/types.ts
Migration runner and tooling types updated to accept ControlDriverInstance<string,string> or ControlDriverInstance<'sql', string> as appropriate.
Planning/docs additions & removals
.cursor/plans/unify_descriptor_hierarchy_9f582aad.plan.md, agent-os/specs/2025-12-05-db-init-command/planning/*.plan.md
Add a plan describing descriptor unification; remove two obsolete planning/design markdown docs.

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between ff956e4 and 684e0c7.

📒 Files selected for processing (6)
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
🧰 Additional context used
📓 Path-based instructions (29)
**/*.{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
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.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
Use instanceof type.errors to 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

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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-lane can import from sql-relational-core if both are in the lanes layer)
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/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.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/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/src/core/**/*.{ts,tsx,js,jsx}

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

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/src/{core,exports}/**/*.ts

📄 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

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/src/core/**/*.ts

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

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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 the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If 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 comments

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/src/core/descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/*cli**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/cli-error-handling.mdc)

Use factory functions from utils/cli-errors.ts to create structured errors with consistent structure and metadata

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
{src,packages}/**/cli/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

{src,packages}/**/cli/**/*.{ts,tsx,js}: Follow CLI command description patterns as per .cursor/rules/cli-command-descriptions.mdc
CLI command error handling: throw errors, don't call process.exit as per .cursor/rules/cli-error-handling.mdc
Follow CLI package export structure and import patterns as per .cursor/rules/cli-package-exports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/commands/**/*.{ts,tsx}

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

FamilyInstance is retained for CLI command handlers that need the full method set (validateContractIR, verify, schemaVerify, introspect, emitContract, toSchemaView). It uses ControlDriverInstance internally.

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.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 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
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']
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: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
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.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().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 using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.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 correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects 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 deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*cli*/**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use setupTestDirectoryFromFixtures() helper to create ephemeral test directories from fixtures for CLI E2E tests, organized by command in subdirectories (e.g., fixtures/emit/, fixtures/db-verify/)

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
🧠 Learnings (1)
📚 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/3-tooling/family/src/core/descriptor.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
🧬 Code graph analysis (4)
packages/2-sql/3-tooling/family/src/core/descriptor.ts (1)
packages/2-sql/3-tooling/family/src/core/control-adapter.ts (1)
  • SqlControlAdapter (13-39)
packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (3)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • VerifyDatabaseSchemaResult (400-430)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/2-sql/3-tooling/family/src/core/instance.ts (2)
packages/1-framework/1-core/migration/control-plane/src/types.ts (2)
  • ControlDriverInstance (163-170)
  • ControlAdapterDescriptor (276-285)
packages/2-sql/3-tooling/family/src/core/control-adapter.ts (1)
  • SqlControlAdapter (13-39)
🔇 Additional comments (25)
packages/1-framework/3-tooling/cli/test/config-types.test.ts (5)

1-1: LGTM: ContractIR import added appropriately.

The type import is correctly added to support the cast on line 23 and follows the import guidelines for contract types.


23-23: LGTM: Type cast appropriate for test mock.

The as ContractIR cast is acceptable for this test mock according to the guideline that allows type casts in test files for mocking purposes.


36-51: LGTM: Schema structure enriched appropriately.

The expanded schema structure provides comprehensive mock data that better matches real schema verification results, with proper type annotations including as const for preserving literal types.


53-60: LGTM: Sign method follows consistent mock pattern.

The new sign method is properly structured and follows the same pattern as other mock methods in this test, with appropriate return fields including the marker property for tracking creation/update status.


93-93: LGTM: familyId addition supports type hierarchy unification.

The familyId: 'sql' addition aligns with the PR objective to parameterize driver instances with familyId and maintains consistency with the target and adapter mock patterns.

packages/2-sql/3-tooling/family/src/core/descriptor.ts (2)

9-9: LGTM! Type-only import for SQL-specific adapter typing.

The import correctly brings in SqlControlAdapter for use in parameterizing the adapter descriptor at line 36.


36-36: LGTM! Tightened adapter typing for SQL-specific operations.

Parameterizing the third generic of ControlAdapterDescriptor with SqlControlAdapter<TTargetId> ensures that adapter.create() returns the SQL-specific adapter type, improving type safety throughout the control plane operations. This aligns with the PR's goal to unify and tighten the FamilyInstance type hierarchy.

packages/2-sql/3-tooling/family/src/core/instance.ts (7)

235-240: LGTM! Driver type tightened for SQL family operations.

The parameter type refinement from ControlDriverInstance to ControlDriverInstance<'sql', string> improves type safety and aligns with the SQL-specific nature of these operations.


253-253: LGTM! Interface signatures improved for type safety.

The changes improve type safety across the board:

  • validateContractIR now returns ContractIR instead of unknown, enabling better downstream type inference
  • Driver parameters in verify, sign, and introspect are now typed as ControlDriverInstance<'sql', string>, providing SQL-specific type constraints

Also applies to: 260-260, 279-279, 302-302


331-331: LGTM! Adapter type parameterization enables cast removal.

Adding the SqlControlAdapter type parameter ensures adapter.create() returns the correct SQL-specific type, which allows the removal of redundant casts at lines 591 and 715 (as noted in past review comments).


428-435: LGTM! Return type improvement with appropriate type assertion.

The return type change from unknown to ContractIR improves type safety. The cast at line 434 is acceptable as it asserts the validated and stripped contract matches the ContractIR interface after runtime validation and mapping removal.


591-592: LGTM! Redundant casts successfully removed.

The removal of casts on both adapter.create() and the driver parameter addresses the previous review comments. The type parameterization at line 331 ensures adapter.create() returns SqlControlAdapter, and the driver is already correctly typed as ControlDriverInstance<'sql', string> from the function signature. The casts were indeed redundant.


715-716: LGTM! Redundant casts successfully removed.

Similar to the changes at lines 591-592, the removal of casts here addresses previous review comments. The type system now correctly infers the types without requiring explicit casts, thanks to the improved type parameterization.


854-854: LGTM! Consistent use of instance method.

Using this.validateContractIR ensures consistent validation behavior throughout the instance and aligns with the interface definition.

packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts (3)

84-84: LGTM: Clean JSON parsing without unnecessary cast.

The removal of type assertions aligns with the unification to framework-components. Since validateContractIR accepts unknown, no cast is needed here.


150-150: LGTM: Direct validateContractIR call.

The refactored call removes the typed alias and uses the public familyInstance method directly, aligning with the framework-components model.


158-161: LGTM: Direct method invocations on familyInstance.

The introspect and optional toSchemaView calls now use the public instance directly, consistent with the unified type hierarchy.

Also applies to: 176-178

packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (3)

149-149: LGTM: Cast removed as previously suggested.

The validateContractIR call no longer includes the as ContractIR cast. The method signature in types.ts (line 57) now properly returns ContractIR, eliminating the need for the cast.


155-162: LGTM: Direct schemaVerify invocation.

The refactored call uses familyInstance.schemaVerify directly, consistent with the unified framework-components surface.


184-190: LGTM: Direct sign invocation.

The refactored call uses familyInstance.sign directly, maintaining consistency with the new type hierarchy.

packages/1-framework/1-core/migration/control-plane/src/types.ts (5)

1-12: LGTM: Framework-components imports.

Imports correctly reference the unified framework-components from @prisma-next/contract/framework-components, aligning with the PR's goal to unify the type hierarchy.


49-57: LGTM: validateContractIR now returns ContractIR.

The return type has been updated from unknown to ContractIR, resolving the past review comment. The JSDoc correctly documents that additional fields (coreHash, profileHash) may be present in emitted contracts.


142-180: LGTM: Control*Instance interfaces.

The interfaces correctly extend base framework-components types and add control-plane specific behavior. ControlDriverInstance appropriately adds query() and close() methods for database operations.


231-321: LGTM: Control*Descriptor interfaces.

The descriptor interfaces follow the framework-components pattern consistently, providing create() factory methods for instantiation. The type parameters correctly flow through the hierarchy.


448-448: LGTM: IntrospectSchemaResult requires explicit type parameter.

Removing the default for TSchemaIR enforces explicit type specification by consumers, improving type safety. This aligns with the coding guidelines and addresses the generic defaults concern from past reviews.


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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (1)

154-167: Remove unnecessary type cast on verify result.

The verify() method should return a properly typed VerifyDatabaseResult based on the family instance's interface. The explicit cast on line 167 is unnecessary.

🔎 Proposed fix
-            )) as VerifyDatabaseResult;
+            ));
packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (1)

154-167: Remove unnecessary type cast on schemaVerify result.

The schemaVerify() method should return a properly typed VerifyDatabaseSchemaResult. The explicit cast on line 167 is unnecessary.

🔎 Proposed fix
-            )) as VerifyDatabaseSchemaResult;
+            ));
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 0be1d74 and dbbd470.

📒 Files selected for processing (20)
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/1-core/shared/contract/package.json
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.schema-verify.helpers.ts
💤 Files with no reviewable changes (1)
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
🧰 Additional context used
📓 Path-based instructions (41)
**/package.json

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

Export subpath entrypoints in package.json with correct types and import mappings for ./adapter, ./control, and ./runtime paths

When adding new exports to the CLI package, add the export path with types and import mappings to the exports field in package.json

Follow multi-plane entrypoints in single packages as per .cursor/rules/multi-plane-entrypoints.mdc

When moving packages, update all script paths in package.json (including biome.json config path, scripts/clean.mjs, and other root-level script references) by counting directory depth from the package to root

Files:

  • packages/1-framework/1-core/shared/contract/package.json
packages/**/package.json

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

packages/**/package.json: Shared plane packages must have sideEffects: false in package.json
Use explicit export paths in package.json following the pattern with separate export identifiers for types, validators, and factories
Shared plane packages should depend only on framework core packages and validation libraries (Arktype), not on migration-plane or runtime-plane packages

Files:

  • packages/1-framework/1-core/shared/contract/package.json
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/1-framework/1-core/shared/contract/package.json
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/shared/contract/README.md
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/*.{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
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.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
Use instanceof type.errors to 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

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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-lane can import from sql-relational-core if both are in the lanes layer)
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/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.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/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.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 the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If 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 comments

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
**/src/{core,exports}/**/*.ts

📄 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

Files:

  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
**/src/exports/**/*.ts

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

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)

Files:

  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
packages/**/src/exports/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages must export types, validators, and factories through separate export files in the src/exports/ directory

Files:

  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
**/exports/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

When a class with private properties is part of an exported type, the class must be explicitly exported from the exports file, not just from the source file

Files:

  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.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 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
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']
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: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
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.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.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:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().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 using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.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 correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects 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 deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.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:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*contract*.{ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Capability-gated features (e.g., includeMany, returning) must be enabled in contract capabilities

Files:

  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
**/*cli**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/cli-error-handling.mdc)

Use factory functions from utils/cli-errors.ts to create structured errors with consistent structure and metadata

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
{src,packages}/**/cli/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

{src,packages}/**/cli/**/*.{ts,tsx,js}: Follow CLI command description patterns as per .cursor/rules/cli-command-descriptions.mdc
CLI command error handling: throw errors, don't call process.exit as per .cursor/rules/cli-error-handling.mdc
Follow CLI package export structure and import patterns as per .cursor/rules/cli-package-exports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
**/commands/**/*.{ts,tsx}

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

FamilyInstance is retained for CLI command handlers that need the full method set (validateContractIR, verify, schemaVerify, introspect, emitContract, toSchemaView). It uses ControlDriverInstance internally.

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
**/*config.ts

📄 CodeRabbit inference engine (.cursor/rules/config-validation-and-normalization.mdc)

**/*config.ts: Use Arktype for validation in defineConfig() 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 in defineConfig() and return a fully normalized config object
Use join() and dirname() from node:path for 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/1-framework/1-core/shared/contract/tsup.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/1-framework/1-core/shared/contract/tsup.config.ts
**/tsup.config.ts

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

All entry points in multi-plane packages should be built in a single tsup configuration block with format ['esm'], sourcemap enabled, and output to dist/exports

When adding new exports to the CLI package, add the entry point to tsup.config.ts in the second config block under the entry field

Files:

  • packages/1-framework/1-core/shared/contract/tsup.config.ts
**/*.config.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Mark external dependencies in tsup.config.ts to prevent bundling: workspace packages (/^@prisma-next\//), CommonJS dependencies, and packages with native modules (e.g., @prisma/dev)

Files:

  • packages/1-framework/1-core/shared/contract/tsup.config.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/1-framework/3-tooling/cli/test/config-types.test.ts
**/*cli*/**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use setupTestDirectoryFromFixtures() helper to create ephemeral test directories from fixtures for CLI E2E tests, organized by command in subdirectories (e.g., fixtures/emit/, fixtures/db-verify/)

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/README.md

📄 CodeRabbit inference engine (.cursor/rules/doc-maintenance.mdc)

Keep READMEs up to date with package changes, including: package description, responsibilities, dependencies on other packages, architecture mermaid diagrams, links to relevant subsystem docs or ADRs, and developer context

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*.{md,mdc}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Keep docs, READMEs, and rules up-to-date as per .cursor/rules/doc-maintenance.mdc

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*.{md,markdown}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

After moving a package, update documentation including READMEs, AGENTS.md, and other documentation files to reflect the new package location

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/{README,*.md,.cursor/rules/**/*.mdc}

📄 CodeRabbit inference engine (AGENTS.md)

Keep docs current (READMEs, rules, links)

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*family*.ts

📄 CodeRabbit inference engine (.cursor/rules/family-instance-domain-actions.mdc)

**/*family*.ts: Family instances should implement domain actions (e.g., emitContract, verify, schemaVerify, introspect) as self-contained methods that own their implementation logic, rather than delegating to core domain action functions
Import pure helper functions from core control plane (such as canonicalizeContract, computeCoreHash, computeProfileHash) and use them within inline orchestration logic in domain action methods
Inline orchestration logic in domain action methods, including validation steps, building validation contexts, calling family hooks, assembling final results, and error handling specific to the domain action
Do not import and call domain action functions from core control plane in family instance methods; instead import pure helper functions and inline the orchestration logic

Files:

  • test/integration/test/family.schema-verify.helpers.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/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
📚 Learning: 2025-12-28T05:53:44.429Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 51
File: agent-os/specs/2025-12-05-db-init-command/verifications/branch-3-runner.md:20-20
Timestamp: 2025-12-28T05:53:44.429Z
Learning: In code reviews across the repository, preserve the domain-specific term "SQL family instance" when referring to an instantiated SqlControlFamilyInstance that provides control-plane operations. Do not replace it with generic terms like "database connection" or "configuration". Treat this phrase as an architectural concept consistently used throughout the codebase.

Applied to files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
🧬 Code graph analysis (6)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)
  • FamilyInstance (14-14)
packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-init.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
🔇 Additional comments (44)
packages/1-framework/1-core/shared/contract/README.md (4)

274-289: Clarify documentation dependency on SQL schema.

The documentation references the SQL schema from @prisma-next/sql-query (line 156), but this package is only listed under "Related Packages" (line 288) rather than "Dependencies." Verify whether:

  1. This is the intended documentation approach, or
  2. @prisma-next/sql-query should be listed as a runtime or documentation dependency
  3. The schema reference should be moved or adjusted if it's only provided for context

</shell_scripts>


1-289: Approve documentation structure and content.

The README has been comprehensively updated to reflect the new framework component descriptor architecture introduced in PR TML-1757. The documentation:

  • Clearly explains the foundational type system changes (FamilyInstance, ComponentDescriptor, plane-agnostic bases)
  • Provides practical TypeScript and JSON examples for both new and existing components
  • Documents the component hierarchy and plane-specific extensions effectively
  • Maintains consistency with established domain terminology

Pending verification of the specific import paths and external package references noted in separate comments, this documentation update appropriately supports the architectural changes.


156-180: Correct the schema path for SQL contracts.

The schema reference at line 157 is incorrect. The file data-contract-sql-v1.json is located in packages/2-sql/2-authoring/contract-ts/schemas/, not in @prisma-next/sql-query/schemas/. Update the example to use the correct package path for the SQL schema reference.

Likely an incorrect or invalid review comment.


76-123: No issues found. The import path @prisma-next/contract/framework-components is correctly configured in the package exports, all descriptor types (ComponentDescriptor, FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor) match their actual definitions, and the plane-specific descriptors (ControlFamilyDescriptor, RuntimeTargetDescriptor, etc.) exist and are correctly named in their respective plane packages. The README documentation accurately reflects the actual codebase.

packages/1-framework/1-core/shared/contract/src/types.ts (1)

4-16: LGTM! Clean base interface design.

The new FamilyInstance<TFamilyId> interface provides a minimal, well-documented foundation for plane-specific extensions. The generic parameter with default, readonly property, and clear documentation align with the framework's type hierarchy goals.

packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts (1)

115-120: LGTM! Type inference simplification.

Removing the explicit type assertion allows TypeScript's type inference to work naturally. The familyInstance is properly typed by the return type of config.family.create().

packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)

14-14: LGTM! Correct export addition.

The FamilyInstance type is properly added to the public exports, maintaining alphabetical order and consistency with existing patterns.

packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (3)

142-150: LGTM! Simplified instance usage with validated assertions.

The removal of the intermediate typedFamilyInstance variable simplifies the code. The type assertion on line 150 is appropriate since validateContractIR validates the input before returning.


155-169: LGTM! Type assertion after schema verification.

The type assertion to VerifyDatabaseSchemaResult is safe because schemaVerify validates the schema before returning. The error handling at line 170-175 ensures any validation failures are caught and wrapped.


185-198: LGTM! Type assertion after database signing.

The type assertion to SignDatabaseResult is appropriate since the sign method ensures a valid result structure. Error handling at line 199-204 catches any failures.

packages/1-framework/1-core/shared/contract/tsup.config.ts (1)

8-8: LGTM! Build configuration for framework-components.

The new entry correctly configures the build for the framework-components export, maintaining consistency with existing entry patterns and aligning with the package.json export definition.

packages/1-framework/3-tooling/cli/src/commands/db-init.ts (2)

168-176: LGTM! Consistent instance usage pattern.

The refactoring follows the same pattern as db-sign.ts - using familyInstance directly with appropriate type assertions after validation. The cast to ContractIR on line 176 is safe because validateContractIR validates the input.


183-186: LGTM! Introspection with validated family instance.

Using familyInstance.introspect() directly is clean and relies on proper typing from the method signature.

test/integration/test/cli.emit-contract.test.ts (7)

4-4: LGTM! Updated to control-plane type.

The import change from FamilyInstance to ControlFamilyInstance correctly reflects the type hierarchy where CLI command handlers use the control-plane specific instance type with the full method set (validateContractIR, emitContract, etc.).


54-59: LGTM! Consistent type assertion in tests.

The explicit type assertion to ControlFamilyInstance<string> is appropriate in test code and ensures the test has access to the full control-plane method set. This pattern is consistently applied across all test cases.


119-124: LGTM! Consistent type assertion pattern.

The type assertion maintains consistency with the first test case.


179-184: LGTM! Consistent type assertion pattern.

The type assertion maintains consistency across test cases.


231-236: LGTM! Consistent type assertion pattern.

The type assertion maintains consistency across test cases.


273-278: LGTM! Consistent type assertion pattern.

The type assertion maintains consistency across test cases.


315-320: LGTM! Consistent type assertion pattern.

The type assertion maintains consistency across all test cases in the file.

packages/1-framework/1-core/shared/contract/package.json (1)

44-47: Framework-components export is correctly configured.

The export entry properly points to the built file with correct type definitions. All required descriptor types (ComponentDescriptor, FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor) are exported from the source file and re-exported through the public exports file. The tsup configuration correctly builds this entry to the dist/exports directory with TypeScript declaration generation enabled.

packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts (1)

1-8: LGTM! Clean barrel export for framework components.

This export file correctly follows the established pattern for shared plane packages, providing a clean public API surface for the new framework component descriptor types.

test/integration/test/family.schema-verify.helpers.ts (1)

52-63: LGTM! Proper type alignment with Control naming.*

The explicit return type and updated JSDoc correctly reflect the migration to SqlControlFamilyInstance. The changes improve type clarity without altering behavior.

packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts (1)

141-190: LGTM! Clean implementation without unnecessary type casts.

This file correctly uses the family instance methods without defensive type casts. The optional chaining for toSchemaView is appropriate since it's a genuinely optional method.

packages/1-framework/3-tooling/cli/test/config-types.test.ts (1)

38-45: LGTM! Consistent mock structure for sign method.

The new sign method mock follows the established pattern of other command result mocks and correctly represents the SignDatabaseResult structure.

packages/1-framework/1-core/shared/contract/src/framework-components.ts (2)

1-58: Excellent documentation and base interface design.

The ComponentDescriptor base interface and its comprehensive documentation provide a solid foundation for the type hierarchy. The extensible Kind parameter design is particularly well thought out.


60-239: LGTM! Well-structured descriptor hierarchy with excellent documentation.

The complete descriptor hierarchy (Family, Target, Adapter, Driver, Extension) is clearly defined with:

  • Consistent readonly properties
  • Generic type parameters for type-safe composition
  • Comprehensive JSDoc with examples
  • Clear explanation of the component hierarchy and design decisions

The documentation quality is exemplary and will significantly help developers understand the framework's architecture.

packages/1-framework/3-tooling/cli/README.md (3)

224-245: LGTM! Documentation correctly updated for Control naming.*

The interface examples accurately reflect the new ControlFamilyDescriptor and ControlFamilyInstance types, with proper method signatures for the verify() operation.


381-396: LGTM! Introspection section updated consistently.

The documentation correctly shows the ControlFamilyInstance interface with the introspect() and optional toSchemaView() methods using proper Control* types.


587-608: LGTM! Sign section documentation updated correctly.

The interface examples accurately reflect the ControlFamilyInstance type with both schemaVerify() and sign() methods using ControlDriverInstance.

packages/1-framework/1-core/runtime/execution-plane/src/types.ts (7)

1-8: LGTM!

Imports are properly organized with type imports from the framework-components and types packages as per the coding guidelines.


20-23: LGTM!

RuntimeFamilyInstance correctly extends the base FamilyInstance<TFamilyId> from the shared contract types, aligning with the unified type hierarchy goal. The placeholder comment for future runtime-plane-specific methods is acceptable.


88-98: LGTM!

RuntimeFamilyDescriptor correctly extends FamilyDescriptor<TFamilyId> and maintains the expected create() factory method signature with typed component descriptors for target, adapter, driver, and extensions.


107-116: LGTM!

RuntimeTargetDescriptor properly extends TargetDescriptor<TFamilyId, TTargetId> with the create() factory method.


125-134: LGTM!

RuntimeAdapterDescriptor properly extends AdapterDescriptor<TFamilyId, TTargetId> with the create() factory method.


143-149: LGTM!

RuntimeDriverDescriptor properly extends DriverDescriptor<TFamilyId, TTargetId> with the create(options: unknown) factory method.


158-167: LGTM!

RuntimeExtensionDescriptor properly extends ExtensionDescriptor<TFamilyId, TTargetId> with the create() factory method.

packages/1-framework/1-core/migration/control-plane/src/types.ts (7)

1-11: LGTM!

Imports are properly organized with external type imports first, followed by internal type imports. The imports correctly reference the framework-components and contract types packages.


45-128: LGTM!

ControlFamilyInstance is well-designed with:

  • Proper extension of base FamilyInstance<TFamilyId>
  • Rich generic parameters for type-safe result types (TSchemaIR, TVerifyResult, TSchemaVerifyResult, TSignResult)
  • Comprehensive control-plane domain actions with clear documentation
  • Consistent use of ControlDriverInstance in method signatures

The interface provides a clean contract for control-plane operations.


237-248: LGTM!

ControlFamilyDescriptor correctly extends FamilyDescriptor<TFamilyId> and includes the driver parameter in the create() method options as required by the coding guidelines.


258-273: LGTM!

ControlTargetDescriptor properly extends TargetDescriptor<TFamilyId, TTargetId> and includes the optional migrations capability for targets that support migrations.


282-291: LGTM!

ControlAdapterDescriptor properly extends AdapterDescriptor<TFamilyId, TTargetId> with the create() factory method.


300-306: LGTM!

ControlDriverDescriptor properly extends DriverDescriptor<TFamilyId, TTargetId> with an async create(url: string) factory method appropriate for database driver initialization.


315-324: LGTM!

ControlExtensionDescriptor properly extends ExtensionDescriptor<TFamilyId, TTargetId> with the create() factory method.


// Validate contract using instance validator
const contractIR = typedFamilyInstance.validateContractIR(contractJson) as ContractIR;
const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;

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.

🧹 Nitpick | 🔵 Trivial

Remove unnecessary type cast.

The validateContractIR method should return a properly typed ContractIR based on the family instance's type definition. The explicit cast is unnecessary.

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
const contractIR = familyInstance.validateContractIR(contractJson);
🤖 Prompt for AI Agents
In packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts around
line 149, remove the unnecessary explicit cast "as ContractIR" from the call to
familyInstance.validateContractIR(contractJson); the method's signature already
returns the correct ContractIR type, so simply assign the result to a variable
typed by inference (or declare const contractIR: ContractIR =
familyInstance.validateContractIR(contractJson) if you prefer an explicit type
annotation) and update any usages accordingly.


// Validate contract using instance validator
const contractIR = typedFamilyInstance.validateContractIR(contractJson) as ContractIR;
const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;

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.

🧹 Nitpick | 🔵 Trivial

Remove unnecessary type cast.

The validateContractIR method should already return ContractIR based on the family instance's type definition. The explicit as ContractIR cast is unnecessary and may hide potential type issues.

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);
🤖 Prompt for AI Agents
In packages/1-framework/3-tooling/cli/src/commands/db-verify.ts around line 149,
remove the unnecessary "as ContractIR" type assertion on the result of
familyInstance.validateContractIR(contractJson); rely on the method's declared
return type (ContractIR) and let TypeScript infer the variable type — simply
assign the result to contractIR without the cast, and if necessary explicitly
type the variable declaration (e.g., const contractIR: ContractIR = ...) rather
than using an inline "as" assertion.

Extracts minimal FamilyInstance base interface with only familyId.
This enables plane-specific interfaces (ControlFamilyInstance, RuntimeFamilyInstance)
to extend a common base from the shared plane.
…milyInstance

- ControlFamilyInstance now extends FamilyInstance from contract package
- Added all control-plane domain methods (validateContractIR, verify,
  schemaVerify, sign, introspect, toSchemaView, emitContract)
- Removed old FamilyInstance interface (now in contract package)
- Updated exports to remove FamilyInstance (import from @prisma-next/contract/types)
…stance

RuntimeFamilyInstance now extends the base FamilyInstance from contract package,
establishing a proper shared base for both control-plane and runtime-plane instances.
ControlFamilyInstance now has all control-plane methods, so the casts
to FamilyInstance<string> are no longer needed. The family instance
returned by config.family.create() has all required methods.

- Removed FamilyInstance import from 6 CLI command files
- Removed cast to FamilyInstance<string> from all commands
- Updated config-types.test.ts mock to include sign() method
Add framework-components module with base descriptor interfaces:
- ComponentDescriptor<Kind> - base for all component descriptors
- FamilyDescriptor<TFamilyId> - base for family descriptors
- TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor

Exposed via new @prisma-next/contract/framework-components entrypoint.
Uses extensible Kind (string) rather than closed union.
Update control-plane descriptors to extend shared bases:
- ControlFamilyDescriptor extends FamilyDescriptor
- ControlTargetDescriptor extends TargetDescriptor
- ControlAdapterDescriptor extends AdapterDescriptor
- ControlDriverDescriptor extends DriverDescriptor
- ControlExtensionDescriptor extends ExtensionDescriptor

Removes duplicated kind/id/manifest/familyId/targetId properties.
Keeps control-plane-specific: hook, migrations, create() signatures.
Update runtime-plane descriptors to extend shared bases:
- RuntimeFamilyDescriptor extends FamilyDescriptor
- RuntimeTargetDescriptor extends TargetDescriptor
- RuntimeAdapterDescriptor extends AdapterDescriptor
- RuntimeDriverDescriptor extends DriverDescriptor
- RuntimeExtensionDescriptor extends ExtensionDescriptor

Removes duplicated kind/id/manifest/familyId/targetId properties.
Keeps runtime-plane-specific create() signatures.
The test uses control-plane methods like emitContract(), so it
needs the control-plane interface, not the base interface.
Add detailed documentation explaining:
- Component hierarchy overview (Family > Target > Adapter/Driver/Extension)
- What each component type represents and its responsibilities
- How descriptors relate to plane-specific extensions
- Usage examples for each descriptor type
- Update package description to include component descriptors
- Add Framework Component Descriptors section with usage examples
- Update Exports section to list all entrypoints
Update example comment to clarify that 'kind' is the Kind type parameter,
not a fixed union. The type accepts any string for ecosystem extensibility.
Replace 'target pack', 'adapter pack', etc. with 'component' in
plane-specific descriptor doc comments for consistent terminology.
…nstance

Clarify that the helper returns a control-plane family instance, not a
base FamilyInstance.
Replace outdated 'FamilyInstance' with 'ControlFamilyInstance' and
'FamilyDescriptor' with 'ControlFamilyDescriptor' to match the
actual type hierarchy.
Add FamilyInstance, TargetInstance, AdapterInstance, DriverInstance, and
ExtensionInstance interfaces to the shared framework-components module.
These are identity-only base types (familyId, targetId) that plane-specific
instances extend.

- Add 5 new instance interfaces with doc comments
- Export from framework-components entrypoint
- Add transitional re-export of FamilyInstance from types.ts
Update control-plane instance interfaces to extend the new shared bases
from framework-components:
- ControlTargetInstance extends TargetInstance
- ControlAdapterInstance extends AdapterInstance
- ControlDriverInstance extends DriverInstance (adds familyId parameter)
- ControlExtensionInstance extends ExtensionInstance

This establishes proper inheritance hierarchy and removes duplicated
identity properties.
Update runtime-plane instance interfaces to extend the new shared bases
from framework-components:
- RuntimeTargetInstance extends TargetInstance
- RuntimeAdapterInstance extends AdapterInstance
- RuntimeDriverInstance extends DriverInstance (adds familyId parameter)
- RuntimeExtensionInstance extends ExtensionInstance

This mirrors the control-plane hierarchy and removes duplicated
identity properties.
Update driver implementations to include familyId and use two-parameter
DriverInstance type:
- PostgresControlDriver: add familyId='sql', use ControlDriverInstance<'sql','postgres'>
- PostgresRuntimeDriver: use RuntimeDriverInstance<'sql','postgres'>
Update README to document that framework-components now includes both
descriptors and identity instance bases. Update usage examples and
exports section accordingly.
Update SqlControlAdapter interface and PostgresControlAdapter to use
ControlDriverInstance<'sql', TTarget> instead of single-parameter style.
…tance

Update SqlControlFamilyInstance and SqlRuntimeFamilyInstance to use
ControlDriverInstance<'sql', string> and SqlDriver casts.
Update test mocks to include familyId property and use two-parameter
ControlDriverInstance type as required by the new base interface.
…nstances

Define SqlRuntimeDriverInstance and SqlRuntimeAdapterInstance type aliases
that combine identity properties with SQL-specific behavior interfaces.
Update createSqlRuntimeFamilyInstance and SqlRuntimeFamilyDescriptor to
require these typed instances, eliminating the need for blind casts.

- Add SqlRuntimeDriverInstance = RuntimeDriverInstance & SqlDriver
- Add SqlRuntimeAdapterInstance = RuntimeAdapterInstance & Adapter
- Update function signatures to use typed instance parameters
- Remove 'as unknown as' casts from runtime-instance.ts
@wmadden
wmadden force-pushed the tml-1757-unify-familyinstance-type-hierarchy branch from dbbd470 to 8d432a5 Compare December 31, 2025 01:27

@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

♻️ Duplicate comments (2)
packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (1)

141-149: Remove unnecessary type cast.

The validateContractIR method already returns a properly typed ContractIR based on the family instance's type definition. The explicit as ContractIR cast is unnecessary and should be removed.

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (1)

149-149: Remove unnecessary type cast.

The validateContractIR method should already return ContractIR based on the family instance's type definition. The explicit as ContractIR cast is unnecessary and may hide potential type issues.

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between dbbd470 and 8d432a5.

📒 Files selected for processing (29)
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/1-core/shared/contract/package.json
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
  • test/integration/test/family.schema-verify.helpers.ts
💤 Files with no reviewable changes (1)
  • packages/1-framework/1-core/migration/control-plane/src/exports/types.ts
🧰 Additional context used
📓 Path-based instructions (48)
**/*.{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
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.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
Use instanceof type.errors to 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

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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-lane can import from sql-relational-core if both are in the lanes layer)
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/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.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/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/src/core/**/*.{ts,tsx,js,jsx}

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

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
**/src/{core,exports}/**/*.ts

📄 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

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/src/core/**/*.ts

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

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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 the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If 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 comments

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/1-framework/3-tooling/cli/README.md
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/package.json
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/*cli**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/cli-error-handling.mdc)

Use factory functions from utils/cli-errors.ts to create structured errors with consistent structure and metadata

Files:

  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
{src,packages}/**/cli/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

{src,packages}/**/cli/**/*.{ts,tsx,js}: Follow CLI command description patterns as per .cursor/rules/cli-command-descriptions.mdc
CLI command error handling: throw errors, don't call process.exit as per .cursor/rules/cli-error-handling.mdc
Follow CLI package export structure and import patterns as per .cursor/rules/cli-package-exports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
**/commands/**/*.{ts,tsx}

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

FamilyInstance is retained for CLI command handlers that need the full method set (validateContractIR, verify, schemaVerify, introspect, emitContract, toSchemaView). It uses ControlDriverInstance internally.

Files:

  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
**/*contract*.{ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Capability-gated features (e.g., includeMany, returning) must be enabled in contract capabilities

Files:

  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • test/integration/test/cli.emit-contract.test.ts
**/src/exports/runtime.ts

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

Runtime plane entrypoint must be located at src/exports/runtime.ts; import runtime/driver only from this file

Runtime plane entry point (src/exports/runtime.ts) must export runtime factories and can import from runtime plane packages and core (../core/...)

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
**/src/exports/**/*.ts

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

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)

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
packages/**/src/exports/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages must export types, validators, and factories through separate export files in the src/exports/ directory

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/exports/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

When a class with private properties is part of an exported type, the class must be explicitly exported from the exports file, not just from the source file

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
packages/3-targets/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

Don't branch on target; use adapters instead

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/README.md

📄 CodeRabbit inference engine (.cursor/rules/doc-maintenance.mdc)

Keep READMEs up to date with package changes, including: package description, responsibilities, dependencies on other packages, architecture mermaid diagrams, links to relevant subsystem docs or ADRs, and developer context

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*.{md,mdc}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Keep docs, READMEs, and rules up-to-date as per .cursor/rules/doc-maintenance.mdc

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*.{md,markdown}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

After moving a package, update documentation including READMEs, AGENTS.md, and other documentation files to reflect the new package location

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/{README,*.md,.cursor/rules/**/*.mdc}

📄 CodeRabbit inference engine (AGENTS.md)

Keep docs current (READMEs, rules, links)

Files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
**/*family*.ts

📄 CodeRabbit inference engine (.cursor/rules/family-instance-domain-actions.mdc)

**/*family*.ts: Family instances should implement domain actions (e.g., emitContract, verify, schemaVerify, introspect) as self-contained methods that own their implementation logic, rather than delegating to core domain action functions
Import pure helper functions from core control plane (such as canonicalizeContract, computeCoreHash, computeProfileHash) and use them within inline orchestration logic in domain action methods
Inline orchestration logic in domain action methods, including validation steps, building validation contexts, calling family hooks, assembling final results, and error handling specific to the domain action
Do not import and call domain action functions from core control plane in family instance methods; instead import pure helper functions and inline the orchestration logic

Files:

  • test/integration/test/family.schema-verify.helpers.ts
  • test/integration/test/family.introspect.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 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
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']
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: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
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.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.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/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().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 using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.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 correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects 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 deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.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/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.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-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-contract.test.ts
  • test/integration/test/family.introspect.test.ts
**/*cli*/**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use setupTestDirectoryFromFixtures() helper to create ephemeral test directories from fixtures for CLI E2E tests, organized by command in subdirectories (e.g., fixtures/emit/, fixtures/db-verify/)

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/package.json

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

Export subpath entrypoints in package.json with correct types and import mappings for ./adapter, ./control, and ./runtime paths

When adding new exports to the CLI package, add the export path with types and import mappings to the exports field in package.json

Follow multi-plane entrypoints in single packages as per .cursor/rules/multi-plane-entrypoints.mdc

When moving packages, update all script paths in package.json (including biome.json config path, scripts/clean.mjs, and other root-level script references) by counting directory depth from the package to root

Files:

  • packages/1-framework/1-core/shared/contract/package.json
packages/**/package.json

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

packages/**/package.json: Shared plane packages must have sideEffects: false in package.json
Use explicit export paths in package.json following the pattern with separate export identifiers for types, validators, and factories
Shared plane packages should depend only on framework core packages and validation libraries (Arktype), not on migration-plane or runtime-plane packages

Files:

  • packages/1-framework/1-core/shared/contract/package.json
**/src/exports/control.ts

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

Migration plane entrypoint must be named control.ts (not cli.ts) and located at src/exports/control.ts; import control plane/tooling only from this file

**/src/exports/control.ts: Migration plane entry point (src/exports/control.ts) must export control plane descriptors and use naming convention control.ts (not cli.ts)
Migration plane entry point (src/exports/control.ts) can import from migration plane packages and core (../core/...)

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/control.{ts,tsx}

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

Control plane entry points must export default descriptors with the appropriate types: @prisma-next/family-*/control exports ControlFamilyDescriptor, @prisma-next/target-*/control exports ControlTargetDescriptor, @prisma-next/adapter-*/control exports ControlAdapterDescriptor, @prisma-next/driver-*/control exports ControlDriverDescriptor, and @prisma-next/extensions-*/control exports ControlExtensionDescriptor.

Files:

  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
**/*config.ts

📄 CodeRabbit inference engine (.cursor/rules/config-validation-and-normalization.mdc)

**/*config.ts: Use Arktype for validation in defineConfig() 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 in defineConfig() and return a fully normalized config object
Use join() and dirname() from node:path for 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/1-framework/1-core/shared/contract/tsup.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/1-framework/1-core/shared/contract/tsup.config.ts
**/tsup.config.ts

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

All entry points in multi-plane packages should be built in a single tsup configuration block with format ['esm'], sourcemap enabled, and output to dist/exports

When adding new exports to the CLI package, add the entry point to tsup.config.ts in the second config block under the entry field

Files:

  • packages/1-framework/1-core/shared/contract/tsup.config.ts
**/*.config.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Mark external dependencies in tsup.config.ts to prevent bundling: workspace packages (/^@prisma-next\//), CommonJS dependencies, and packages with native modules (e.g., @prisma/dev)

Files:

  • packages/1-framework/1-core/shared/contract/tsup.config.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/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/2-sql/3-tooling/family/src/core/control-adapter.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • test/integration/test/family.schema-verify.helpers.ts
  • packages/1-framework/1-core/shared/contract/src/exports/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-init.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-instance.ts
  • test/integration/test/cli.emit-contract.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts
  • packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts
  • packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/3-targets/7-drivers/postgres/src/exports/control.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/1-core/shared/contract/tsup.config.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
📚 Learning: 2025-12-28T05:53:44.429Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 51
File: agent-os/specs/2025-12-05-db-init-command/verifications/branch-3-runner.md:20-20
Timestamp: 2025-12-28T05:53:44.429Z
Learning: In code reviews across the repository, preserve the domain-specific term "SQL family instance" when referring to an instantiated SqlControlFamilyInstance that provides control-plane operations. Do not replace it with generic terms like "database connection" or "configuration". Treat this phrase as an architectural concept consistently used throughout the codebase.

Applied to files:

  • packages/1-framework/1-core/shared/contract/README.md
  • packages/1-framework/3-tooling/cli/README.md
🧬 Code graph analysis (9)
packages/2-sql/3-tooling/family/src/core/instance.ts (2)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (167-176)
packages/1-framework/1-core/migration/control-plane/src/exports/types.ts (1)
  • ControlDriverInstance (6-6)
packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/3-targets/7-drivers/postgres/src/exports/runtime.ts (1)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (1)
  • RuntimeDriverInstance (61-64)
packages/1-framework/3-tooling/cli/src/commands/db-init.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/2-sql/3-tooling/family/src/core/runtime-instance.ts (1)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (4)
  • RuntimeDriverInstance (61-64)
  • RuntimeAdapterInstance (49-52)
  • RuntimeAdapterDescriptor (126-135)
  • RuntimeDriverDescriptor (144-153)
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-introspect.ts (1)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/2-sql/3-tooling/family/src/core/runtime-descriptor.ts (2)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (2)
  • RuntimeAdapterDescriptor (126-135)
  • RuntimeDriverDescriptor (144-153)
packages/2-sql/3-tooling/family/src/core/runtime-instance.ts (2)
  • SqlRuntimeAdapterInstance (35-39)
  • SqlRuntimeDriverInstance (25-29)
packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (2)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)

Comment on lines 21 to 22
// Note: Fields like targetFamily accept string to work with JSON imports,
// which don't preserve literal types. Runtime validation ensures correct values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Delete this comment - it's no longer relevant

readonly familyId: TFamilyId;
readonly manifest: ExtensionPackManifest;
> extends FamilyDescriptor<TFamilyId> {
readonly hook: TargetFamilyHook;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TargetFamilyHook deserves to be renamed. It's not a lifecycle hook, its an interface for contract validation and emission

import type { FamilyInstance } from '@prisma-next/contract/types';

// ============================================================================
// Runtime*Instance Base Interfaces (ADR 152)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't include ADR references in code

…ce types

Per TypeScript patterns rule: defaults should only be used when the type
makes sense with non-specific values. Identity parameters (TFamilyId,
TTargetId) must always be explicit to preserve type safety, while instance
type parameters (TFamilyInstance, TSchemaIR, etc.) expressing 'any compatible
type' are useful defaults.

Changes:
- Remove defaults from TFamilyId/TTargetId on all instance interfaces
- Keep defaults for TFamilyInstance, TSchemaIR, TVerifyResult, etc.
- Keep defaults for instance type params on descriptor interfaces
- Update SQL family to use explicit identity types ('sql', string)
- Fix integration test mock driver with explicit type annotation
… types

FamilyInstance is now canonically exported from @prisma-next/contract/framework-components.
Remove the transitional re-export from types.ts and exports/types.ts.

@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: 5

♻️ Duplicate comments (2)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (2)

69-71: Remove ADR reference from comment.

The comment at line 70 includes an ADR reference "(ADR 152)" which should be removed, consistent with the feedback at line 15.

🔎 Suggested fix
 // ============================================================================
-// Runtime*Descriptor Interfaces (ADR 152)
+// Runtime*Descriptor Interfaces
 // ============================================================================

14-16: Remove ADR reference from comment.

The comment at line 15 includes an ADR reference "(ADR 152)" which should be removed per the past review feedback and coding guidelines. The comment can simply read "Runtime*Instance Base Interfaces" without the reference.

🔎 Suggested fix
 // ============================================================================
-// Runtime*Instance Base Interfaces (ADR 152)
+// Runtime*Instance Base Interfaces
 // ============================================================================
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 8d432a5 and 674c79f.

📒 Files selected for processing (11)
  • .cursor/plans/unify_descriptor_hierarchy_9f582aad.plan.md
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
🧰 Additional context used
📓 Path-based instructions (25)
**/*.{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
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.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
Use instanceof type.errors to 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

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.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-lane can import from sql-relational-core if both are in the lanes layer)
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/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.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
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.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/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/src/core/**/*.{ts,tsx,js,jsx}

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

**/src/core/**/*.{ts,tsx,js,jsx}: Keep shared implementation in src/core/** directory with no migration/runtime plane imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/** directory

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/src/{core,exports}/**/*.ts

📄 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

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/src/core/**/*.ts

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

**/src/core/**/*.ts: Core implementation (src/core/**) must contain shared plane code with no CLI-specific or runtime-specific dependencies
Core code (src/core/**) can only import from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.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 the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If 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 comments

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • .cursor/plans/unify_descriptor_hierarchy_9f582aad.plan.md
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx,json,js}

📄 CodeRabbit inference engine (AGENTS.md)

SQL family internals live under packages/2-sql/; top-level packages/3-targets/ is reserved for target extension packs (dialect, adapter, driver)

Files:

  • packages/2-sql/3-tooling/family/src/core/migrations/types.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • packages/2-sql/3-tooling/family/src/core/instance.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 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
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']
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: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
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.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • test/integration/test/family.introspect.test.ts
**/*family*.ts

📄 CodeRabbit inference engine (.cursor/rules/family-instance-domain-actions.mdc)

**/*family*.ts: Family instances should implement domain actions (e.g., emitContract, verify, schemaVerify, introspect) as self-contained methods that own their implementation logic, rather than delegating to core domain action functions
Import pure helper functions from core control plane (such as canonicalizeContract, computeCoreHash, computeProfileHash) and use them within inline orchestration logic in domain action methods
Inline orchestration logic in domain action methods, including validation steps, building validation contexts, calling family hooks, assembling final results, and error handling specific to the domain action
Do not import and call domain action functions from core control plane in family instance methods; instead import pure helper functions and inline the orchestration logic

Files:

  • test/integration/test/family.introspect.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:

  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().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 using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.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 correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects 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 deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • test/integration/test/family.introspect.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:

  • test/integration/test/family.introspect.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • test/integration/test/family.introspect.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • test/integration/test/family.introspect.test.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • test/integration/test/family.introspect.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • test/integration/test/family.introspect.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/3-tooling/family/src/core/migrations/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/1-core/migration/control-plane/src/config-types.ts
  • packages/1-framework/1-core/migration/control-plane/src/migrations.ts
  • packages/2-sql/3-tooling/family/src/core/verify.ts
  • test/integration/test/family.introspect.test.ts
  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
📚 Learning: 2025-12-31T01:34:50.240Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 56
File: packages/1-framework/1-core/shared/contract/src/framework-components.ts:267-295
Timestamp: 2025-12-31T01:34:50.240Z
Learning: Do not recommend adding default generic parameters in this repository. Per .cursor/rules/typescript-patterns.mdc (“Generic Parameter Defaults”), defaults are only allowed when a type is still useful with non‑specific values. For framework component instance bases (TargetInstance, AdapterInstance, DriverInstance, ExtensionInstance in packages/1-framework/1-core/shared/contract/src/framework-components.ts), generics must remain explicit to prevent accidental widening.

Applied to files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
🧬 Code graph analysis (8)
packages/2-sql/3-tooling/family/src/core/migrations/types.ts (2)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
packages/1-framework/1-core/migration/control-plane/src/exports/types.ts (1)
  • ControlDriverInstance (6-6)
packages/1-framework/1-core/migration/control-plane/src/config-types.ts (1)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
packages/1-framework/1-core/migration/control-plane/src/migrations.ts (1)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
packages/2-sql/3-tooling/family/src/core/verify.ts (1)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
test/integration/test/family.introspect.test.ts (1)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (1)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • ExtensionPackManifest (252-272)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (1)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (10)
  • FamilyInstance (267-270)
  • TargetInstance (289-295)
  • AdapterInstance (314-320)
  • DriverInstance (339-345)
  • ExtensionInstance (364-370)
  • FamilyDescriptor (87-90)
  • TargetDescriptor (120-127)
  • AdapterDescriptor (157-164)
  • DriverDescriptor (196-203)
  • ExtensionDescriptor (232-239)
packages/2-sql/3-tooling/family/src/core/instance.ts (3)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • ControlDriverInstance (163-170)
packages/1-framework/1-core/migration/control-plane/src/exports/types.ts (1)
  • ControlDriverInstance (6-6)
packages/2-sql/3-tooling/family/src/core/control-adapter.ts (1)
  • SqlControlAdapter (13-39)
🔇 Additional comments (24)
packages/1-framework/1-core/migration/control-plane/src/migrations.ts (1)

155-155: LGTM! Explicit type parameters align with family-agnostic design.

The explicit <string, string> type parameters on ControlDriverInstance are appropriate here, as this interface is intentionally family-agnostic to serve as a stable vocabulary for CLI commands across different families.

packages/2-sql/3-tooling/family/src/core/instance.ts (3)

235-240: LGTM!

The type parameterization of ControlDriverInstance<'sql', string> correctly constrains the driver to the SQL family, aligning with the unified type hierarchy.


259-304: LGTM!

The verify, sign, and introspect method signatures are consistently updated with the parameterized ControlDriverInstance<'sql', string> type, maintaining type safety across the SQL control family instance interface.


436-442: LGTM!

The implementation signatures for verify, sign, and introspect correctly align with their interface definitions, maintaining consistent type parameterization throughout.

Also applies to: 605-610, 711-714

packages/1-framework/1-core/shared/contract/src/types.ts (1)

4-8: Header comment provides valuable context.

The header comment and the note about runtime validation at lines 7-8 are helpful for understanding the type design decisions. The note explains why targetFamily is typed as string rather than a literal union type (to support JSON imports which don't preserve literal types).

Contrary to the past review comment, this explanation is relevant and should be kept.

packages/1-framework/1-core/shared/contract/src/framework-components.ts (4)

1-2: LGTM - Import structure is correct.

The import of ExtensionPackManifest from the local ./types module follows the coding guidelines for within-package imports.


3-58: Excellent documentation and extensible design.

The header documentation clearly explains the component hierarchy and design decisions. The ComponentDescriptor<Kind extends string> base interface with an extensible Kind parameter is well-designed, allowing ecosystem authors to define custom component kinds beyond the built-in types.


60-239: Specialized descriptor hierarchy is well-structured.

The specialized descriptors (FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor) consistently extend ComponentDescriptor with appropriate discriminator literals and maintain proper type parameter constraints. The documentation includes helpful examples for each descriptor type.


241-370: Identity-only instance interfaces follow clean design principles.

The instance interfaces correctly provide minimal identity contracts (familyId/targetId) without behavior methods. The documentation clearly explains that plane-specific interfaces extend these bases to add domain actions. The intentional lack of default generic parameters (except for FamilyInstance) aligns with the repository's guidelines to prevent accidental type widening.

.cursor/plans/unify_descriptor_hierarchy_9f582aad.plan.md (1)

1-234: Plan document accurately reflects the implemented changes.

The plan provides clear context and rationale for the refactoring. All implementation steps are marked as completed and align with the actual code changes in the PR. The terminology decisions and design principles are well-documented.

packages/1-framework/1-core/runtime/execution-plane/src/types.ts (3)

1-12: LGTM - Imports correctly use the new framework-components entrypoint.

The imports properly reference the new @prisma-next/contract/framework-components public surface, bringing in all necessary base types for the runtime-plane descriptor hierarchy.


18-67: Runtime instance interfaces correctly extend framework bases.

All Runtime*Instance interfaces properly extend their corresponding base interfaces from framework-components, maintaining correct type parameter constraints and providing clear extension points for runtime-plane-specific behavior.


73-162: Runtime descriptor interfaces correctly extend framework bases.

All Runtime*Descriptor interfaces properly extend their corresponding base descriptors from framework-components, removing duplicate fields (kind, id, manifest, familyId, targetId) while retaining runtime-plane-specific create() factory methods. The type parameter constraints are correctly maintained throughout.

packages/1-framework/1-core/migration/control-plane/src/config-types.ts (1)

12-16: Explicit type parameterization improves clarity.

The change to explicitly parameterize CliDriver as ControlDriverInstance<string, string> makes the type more clear and aligns with the framework-wide shift to parameterized component types. The comment appropriately explains the use of string for maximum flexibility in CLI contexts.

packages/2-sql/3-tooling/family/src/core/verify.ts (1)

113-115: Appropriate type constraint for SQL-specific function.

The type refinement from generic ControlDriverInstance to ControlDriverInstance<'sql', string> appropriately constrains the driver parameter to SQL family drivers while maintaining flexibility for different SQL targets. This leverages the type system to prevent incorrect driver usage.

packages/2-sql/3-tooling/family/src/core/migrations/types.ts (1)

186-189: Type constraint ensures SQL drivers in migration execution.

The refinement to ControlDriverInstance<'sql', string> appropriately restricts the migration runner to SQL family drivers, consistent with the SQL-specific nature of the migration execution interface. This prevents type errors at compile time.

test/integration/test/family.introspect.test.ts (2)

1-7: Import addition is appropriate for test typing.

The addition of the ControlDriverInstance type import is necessary to properly type the mock driver in the test. The import follows the correct pattern for cross-package test imports.


215-220: Test mock correctly implements updated interface.

The mock driver now properly implements the ControlDriverInstance<'sql', 'postgres'> interface by including the required familyId and targetId identity fields. This aligns the test mock with the framework component model's requirements and ensures tests accurately reflect production usage.

packages/1-framework/1-core/migration/control-plane/src/types.ts (6)

1-16: LGTM!

The imports are properly structured, following the coding guidelines for explicit imports from specific package paths.


142-143: LGTM!

The empty interface extensions for ControlTargetInstance, ControlAdapterInstance, and ControlExtensionInstance provide extension points for future control-plane-specific behavior while maintaining type hierarchy consistency.

Also applies to: 153-154, 179-180


163-170: LGTM!

The ControlDriverInstance interface properly extends the base DriverInstance and adds essential control-plane methods (query and close) with appropriate type signatures.


231-242: LGTM!

The ControlFamilyDescriptor properly extends FamilyDescriptor and includes all required parameters in the create() method, including the driver parameter as mandated by coding guidelines.


252-267: LGTM!

The descriptor interfaces (ControlTargetDescriptor, ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor) properly extend their base types with appropriate generic constraints. The use of default generic types for instance parameters is appropriate here, as these provide reasonable fallbacks for descriptor type inference.

Also applies to: 276-285, 294-303, 312-321


448-463: LGTM!

Removing the default generic parameter from IntrospectSchemaResult enforces explicit type specification, improving type safety. This aligns with the coding guideline that generics should not have defaults unless they make sense with non-specific values.

Comment on lines +50 to +56
export interface ControlFamilyInstance<
TFamilyId extends string,
TSchemaIR = unknown,
TVerifyResult = unknown,
TSchemaVerifyResult = unknown,
TSignResult = unknown,
> extends FamilyInstance<TFamilyId> {

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.

⚠️ Potential issue | 🟠 Major

Remove generic defaults for domain-specific type parameters.

The generic parameters TSchemaIR, TVerifyResult, TSchemaVerifyResult, and TSignResult have unknown defaults, but these are family-specific domain types where unknown doesn't represent a meaningful default. Per the coding guidelines, generic defaults should only be provided when the type makes sense with non-specific values.

Removing these defaults will enforce explicit type specification by consumers, improving type safety across the control plane.

🔎 Proposed fix
-export interface ControlFamilyInstance<
-  TFamilyId extends string,
-  TSchemaIR = unknown,
-  TVerifyResult = unknown,
-  TSchemaVerifyResult = unknown,
-  TSignResult = unknown,
-> extends FamilyInstance<TFamilyId> {
+export interface ControlFamilyInstance<
+  TFamilyId extends string,
+  TSchemaIR,
+  TVerifyResult,
+  TSchemaVerifyResult,
+  TSignResult,
+> extends FamilyInstance<TFamilyId> {

As per coding guidelines, "Generic types or interfaces should not provide defaults unless the type actually makes sense with non-specific values in TypeScript."

🤖 Prompt for AI Agents
packages/1-framework/1-core/migration/control-plane/src/types.ts lines 50-56:
the interface ControlFamilyInstance currently provides defaults of `unknown` for
domain-specific generics TSchemaIR, TVerifyResult, TSchemaVerifyResult, and
TSignResult; remove those `= unknown` defaults so the declaration requires
explicit types, and then update any local usages or exports that relied on the
defaults to explicitly pass the appropriate family-specific types (or add type
aliases where appropriate) to restore type correctness.

Comment on lines +67 to +73
verify(options: {
readonly driver: ControlDriverInstance<TFamilyId, string>;
readonly contractIR: unknown;
readonly expectedTargetId: string;
readonly contractPath: string;
readonly configPath?: string;
}): Promise<TVerifyResult>;

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.

🧹 Nitpick | 🔵 Trivial

Consider more specific types for contractIR parameters.

Multiple methods use unknown for the contractIR parameter. Since this represents contract intermediate representation, consider using ContractIR or a more constrained type to improve type safety and enable better IDE support.

This pattern appears in:

  • verify() (line 69)
  • schemaVerify() (line 81)
  • sign() (line 94)
  • introspect() (line 117)

Also applies to: 79-85, 92-97, 115-118

…ntrolFamilyInstance

Remove TVerifyResult, TSchemaVerifyResult, TSignResult type parameters.
These were always the same core types (VerifyDatabaseResult, etc.) and
having one param per method doesn't scale.

Now ControlFamilyInstance<TFamilyId, TSchemaIR = unknown> uses concrete
core types directly:
- verify() -> Promise<VerifyDatabaseResult>
- schemaVerify() -> Promise<VerifyDatabaseSchemaResult>
- sign() -> Promise<SignDatabaseResult>

Only TSchemaIR remains generic (genuinely family-specific).

Benefits:
- Removes 3 useless type params
- Eliminates casts in CLI commands
- Uses core domain types directly (no leaking)

@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

♻️ Duplicate comments (5)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (1)

69-71: Remove ADR reference from code comment.

The section header references "ADR 152" which should be removed per previous feedback.

 // ============================================================================
-// Runtime*Descriptor Interfaces (ADR 152)
+// Runtime*Descriptor Interfaces
 // ============================================================================
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (1)

149-149: Remove unnecessary type cast.

The explicit as ContractIR cast is unnecessary. This was previously flagged and indicates that the validateContractIR method's return type should be fixed to return ContractIR instead of unknown (see comment on types.ts).

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);

Note: This fix requires updating the ControlFamilyInstance.validateContractIR return type in packages/1-framework/1-core/migration/control-plane/src/types.ts to return ContractIR instead of unknown.

packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (1)

149-149: Remove unnecessary type cast.

The explicit as ContractIR cast is unnecessary. This was previously flagged and indicates that the validateContractIR method's return type should be fixed to return ContractIR instead of unknown (see comment on types.ts).

🔎 Proposed fix
-          const contractIR = familyInstance.validateContractIR(contractJson) as ContractIR;
+          const contractIR = familyInstance.validateContractIR(contractJson);

Note: This fix requires updating the ControlFamilyInstance.validateContractIR return type in packages/1-framework/1-core/migration/control-plane/src/types.ts to return ContractIR instead of unknown.

packages/1-framework/1-core/migration/control-plane/src/types.ts (2)

49-53: Fix validateContractIR return type to match JSDoc.

The method returns unknown, but the JSDoc states it "returns a validated ContractIR". This mismatch forces all CLI callers to use type casts (as ContractIR), which violates the coding guideline against blind type casts in production code.

Update the return type to ContractIR to provide proper type safety and eliminate the need for casts in CLI files (db-verify.ts:149, db-sign.ts:150, db-schema-verify.ts:149).

🔎 Proposed fix
+import type { ContractIR } from '@prisma-next/contract/ir';
+
 /**
  * Validates a contract JSON and returns a validated ContractIR (without mappings).
  * Mappings are runtime-only and should not be part of ContractIR.
  */
-validateContractIR(contractJson: unknown): unknown;
+validateContractIR(contractJson: unknown): ContractIR;

Note: The ContractIR import is already present at line 13, so only the return type needs to be updated.

As per coding guidelines, "Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead."


59-110: Consider using ContractIR for contractIR parameters.

Multiple methods use unknown for the contractIR parameter (verify, schemaVerify, sign, introspect). Once validateContractIR is updated to return ContractIR, these parameters should also accept ContractIR instead of unknown for improved type safety and better IDE support.

🔎 Proposed changes
 verify(options: {
   readonly driver: ControlDriverInstance<TFamilyId, string>;
-  readonly contractIR: unknown;
+  readonly contractIR: ContractIR;
   readonly expectedTargetId: string;
   readonly contractPath: string;
   readonly configPath?: string;
 }): Promise<VerifyDatabaseResult>;

 schemaVerify(options: {
   readonly driver: ControlDriverInstance<TFamilyId, string>;
-  readonly contractIR: unknown;
+  readonly contractIR: ContractIR;
   readonly strict: boolean;
   readonly contractPath: string;
   readonly configPath?: string;
 }): Promise<VerifyDatabaseSchemaResult>;

 sign(options: {
   readonly driver: ControlDriverInstance<TFamilyId, string>;
-  readonly contractIR: unknown;
+  readonly contractIR: ContractIR;
   readonly contractPath: string;
   readonly configPath?: string;
 }): Promise<SignDatabaseResult>;

 introspect(options: {
   readonly driver: ControlDriverInstance<TFamilyId, string>;
-  readonly contractIR?: unknown;
+  readonly contractIR?: ContractIR;
 }): Promise<TSchemaIR>;
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 674c79f and ff956e4.

📒 Files selected for processing (9)
  • agent-os/specs/2025-12-05-db-init-command/planning/family-instance-type-hierarchy.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/migration-cli-base-types.plan.md
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
💤 Files with no reviewable changes (3)
  • agent-os/specs/2025-12-05-db-init-command/planning/migration-cli-base-types.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/family-instance-type-hierarchy.plan.md
  • packages/1-framework/1-core/shared/contract/src/types.ts
🧰 Additional context used
📓 Path-based instructions (25)
**/*.{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
Use type({ '[string]': Schema }) syntax to create Record<string, Schema> types in Arktype instead of using Record<string, Schema> string notation
Use the .array() method on Arktype schemas to create array types instead of wrapping schemas in type([Schema]) or using manual validation
Extract TypeScript types from Arktype schemas using the .infer property instead of manually duplicating type definitions
Use type.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
Use instanceof type.errors to 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

Prefer explicit, direct imports over barrel imports: import from specific module paths like @prisma/sql/builder instead of barrel re-exports like @prisma/sql

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties on objects

**/*.{ts,tsx}: Import core contract types (ContractBase, Source) and document family types (DocumentContract) from @prisma-next/contract/types
Import target-neutral operations (OperationRegistry, ArgSpec, ReturnSpec, createOperationRegistry) from @prisma-next/operations

**/*.{ts,tsx}: Extract CodecTypes from contract using the he...

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/*cli**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/cli-error-handling.mdc)

Use factory functions from utils/cli-errors.ts to create structured errors with consistent structure and metadata

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.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-lane can import from sql-relational-core if both are in the lanes layer)
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/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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
Replace any types with proper generic type parameters during function extraction, using existing type definitions like ModelColumnAccessor
Use the compact helper function to remove undefined values from objects when TypeScript's exactOptionalPropertyTypes is enabled
Organize imports in the following order: external type imports, external value imports, internal type imports, internal value imports

**/*.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/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
packages/**/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)

Shared plane packages should only contain side-effect-free code (types, validators, factories) with no migration-specific logic or IO operations

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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 the exports/ folders

**/*.{ts,tsx,js,jsx}: Import loadContractFromTs and createContractEmitCommand from the main package export @prisma-next/cli, not from subpaths
Import config utilities (defineConfig and config types) from the @prisma-next/cli/config-types subpath, not from the main package
Import loadExtensionPacks and loadExtensionPackManifest from the @prisma-next/cli/pack-loading subpath, not from the main package
Import command factory functions (e.g., createDbIntrospectCommand, createDbVerifyCommand) from their specific command subpaths (e.g., @prisma-next/cli/commands/db-introspect), not from the main package
Import the loadConfig function from the @prisma-next/cli/config-loader subpath, not from the main package

Update relative paths in source files (manifest paths, import paths, etc.) when moving packages by recalculating the path based on the new location's directory depth

If 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 comments

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
{src,packages}/**/cli/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

{src,packages}/**/cli/**/*.{ts,tsx,js}: Follow CLI command description patterns as per .cursor/rules/cli-command-descriptions.mdc
CLI command error handling: throw errors, don't call process.exit as per .cursor/rules/cli-error-handling.mdc
Follow CLI package export structure and import patterns as per .cursor/rules/cli-package-exports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
**/*.{test,spec,ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Use factory functions for creating AST nodes instead of manual object creation as per .cursor/rules/use-ast-factories.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{ts,tsx,js}: Use LATERAL/json_agg patterns for PostgreSQL queries as per .cursor/rules/postgres-lateral-patterns.mdc
Use Object.hasOwn() instead of hasOwnProperty() as per .cursor/rules/object-hasown.mdc
Prefer assertions over defensive checks; avoid schema validation redundancy as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc

**/*.{ts,tsx,js}: Prefer links to canonical docs over long comments
Package layering is enforced; fix violations rather than bypassing (see scripts/check-imports.mjs and .cursor/rules/import-validation.mdc)
Numbered prefixes in package directory structure indicate dependency direction: lower numbers can be imported by higher numbers, never the reverse

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
{src,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Prohibit inline type imports in source files as per .cursor/rules/no-inline-imports.mdc

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/commands/**/*.{ts,tsx}

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

FamilyInstance is retained for CLI command handlers that need the full method set (validateContractIR, verify, schemaVerify, introspect, emitContract, toSchemaView). It uses ControlDriverInstance internally.

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

!(**/*.test.{ts,tsx}|**/*.spec.{ts,tsx})**/*.{ts,tsx}: Blind type casts (as unknown as X) are forbidden in production code; use type predicates instead
Type safety is non-negotiable; never disable type checking with @ts-expect-error to work around broken types; fix the type definitions instead

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
**/+(src|lib)/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/+(src|lib)/**/*.{ts,tsx}: When extracting types from ColumnBuilder instances, use infer for all type parameters without constraints to allow correct type inference
Use RuntimeContext to decouple codec and operations registries from Runtime, allowing them to be passed to schema and query builders

Files:

  • packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.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 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
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']
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: Avoid using type assertions in tests to bypass type checking or test impossible states. Remove tests that use type assertions (e.g., 'as SqlContract') to test scenarios that contradict validated schemas.
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.

**/*.test.ts: Write test descriptions that omit 'should' - use direct, action-oriented language (e.g., it('returns correct value') not it('should return correct value'))
Prefer object comparison with toEqual or toMatchObject instead of piece-by-piece property checks with type casts
Keep test files under 500 lines maximum and split large files by functionality, feature area, or test type using descriptive file names
Extract helper functions when the same pattern appears 3+ times, ensuring...

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)

Prefer object matchers with .toMatchObject() over multiple individual expect().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 using toEqual or toMatchObject instead of piece-by-piece property checks with toHaveProperty or individual type assertions
Use expect.any() for type-only checks and expect.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 correct

Use factory functions (such as createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) for creating AST nodes in tests instead of manual object creation

Use factory functions (e.g., createContractIR()) instead of manual object creation when creating ContractIR objects 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 deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API; use toExtend() instead for verifying ...

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.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/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec,util,utils}.ts

📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)

For same-package tests needing private functions, create test utilities within the same package that use relative imports and can be exported if needed, rather than exporting the private functions directly

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

Omit 'should' from test descriptions as per .cursor/rules/omit-should-in-tests.mdc

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx,js}: Use correct test import patterns: import from source files with relative paths, don't export for tests as per .cursor/rules/test-import-patterns.mdc
Organize test files with max 500 lines, split by functionality as per .cursor/rules/test-file-organization.mdc
Prefer object matchers over multiple individual expect().toBe() calls as per .cursor/rules/prefer-object-matcher.mdc

Keep tests concise; omit 'should' from test descriptions

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{test,spec}.{ts,tsx}: Use Vitest expect().toEqual(expect.any(Type)) pattern for type testing as per .cursor/rules/vitest-expect-typeof.mdc
Use factory functions for ContractIR objects in tests as per .cursor/rules/use-contract-ir-factories.mdc

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/moving-packages.mdc)

When moving test files to new locations, update paths to other packages, fixtures, and manifests (e.g., extension pack manifests) by recalculating directory depth based on the new location

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*cli*/**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/testing-guide.mdc)

Use setupTestDirectoryFromFixtures() helper to create ephemeral test directories from fixtures for CLI E2E tests, organized by command in subdirectories (e.g., fixtures/emit/, fixtures/db-verify/)

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript-patterns.mdc)

**/*.test.{ts,tsx}: Always validate contracts in tests using validateContract function; contracts must have fully qualified type IDs, not bare scalars
Blind type casts (as unknown as X) are acceptable only in test files for mocking and error cases
Use @ts-expect-error comments with explanations in test files only when working with dynamic proxy objects or complex type scenarios
When mocking class instances in tests, use Object.create() and Object.assign() to preserve the prototype instead of the spread operator
Common patterns in test files should be extracted into helper functions from appropriate shared utility packages or created as package-specific helpers

Files:

  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
🧠 Learnings (1)
📚 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/3-tooling/cli/src/commands/db-schema-verify.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-sign.ts
  • packages/1-framework/3-tooling/cli/src/commands/db-verify.ts
  • packages/1-framework/1-core/migration/control-plane/src/types.ts
  • packages/1-framework/1-core/runtime/execution-plane/src/types.ts
🧬 Code graph analysis (4)
packages/1-framework/3-tooling/cli/src/commands/db-schema-verify.ts (3)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • VerifyDatabaseSchemaResult (392-422)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-sign.ts (3)
packages/3-targets/3-targets/postgres/test/migrations/fixtures/runner-fixtures.ts (1)
  • familyInstance (48-53)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • VerifyDatabaseSchemaResult (392-422)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/3-tooling/cli/src/commands/db-verify.ts (2)
packages/1-framework/1-core/migration/control-plane/src/types.ts (1)
  • VerifyDatabaseResult (318-343)
packages/1-framework/3-tooling/cli/src/utils/spinner.ts (1)
  • withSpinner (30-67)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (1)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (10)
  • FamilyInstance (267-270)
  • TargetInstance (289-295)
  • AdapterInstance (314-320)
  • DriverInstance (339-345)
  • ExtensionInstance (364-370)
  • FamilyDescriptor (87-90)
  • TargetDescriptor (120-127)
  • AdapterDescriptor (157-164)
  • DriverDescriptor (196-203)
  • ExtensionDescriptor (232-239)
🔇 Additional comments (6)
packages/1-framework/1-core/runtime/execution-plane/src/types.ts (3)

1-12: LGTM!

The imports are well-organized, using explicit type imports from the specific module path @prisma-next/contract/framework-components as per coding guidelines.


24-67: LGTM!

The runtime instance interfaces properly extend the base interfaces from framework-components. The empty extensions serve as appropriate extension points for runtime-plane specific behavior while inheriting familyId and targetId properties from their base types.


80-162: LGTM!

The descriptor interfaces properly extend their base types from framework-components and define appropriate create() factory methods. The generic type parameters with defaults follow the established pattern and maintain type safety throughout the hierarchy.

packages/1-framework/3-tooling/cli/test/config-types.test.ts (3)

35-50: LGTM: Enhanced schemaVerify mock structure.

The updated schemaVerify mock now includes a detailed schema structure with issues, root node hierarchy, and validation counts. The use of as const on line 38 correctly preserves the literal type for status: 'pass'.


52-59: LGTM: New sign method added to family mock.

The new sign method completes the family instance mock with contract signing/marking functionality. The return structure is consistent with other methods (verify, schemaVerify) and includes a marker field to track whether contracts were created or updated.


92-92: LGTM: Driver instance now includes familyId for consistency.

Adding familyId: 'sql' to the driver's create() return value aligns with the unified FamilyInstance type hierarchy. This makes the driver instance consistent with family, target, and adapter instances, all of which include familyId.

This addresses the PR objective of unifying the type hierarchy.

Type the adapter descriptor parameter with SqlControlAdapter instance type
so adapter.create() returns the correct type without a cast.

Changes:
- CreateSqlFamilyInstanceOptions: adapter uses SqlControlAdapter
- SqlFamilyDescriptor.create(): adapter uses SqlControlAdapter<TTargetId>
- Remove 'as SqlControlAdapter' cast in introspect()
…actIR

Replace 'unknown' return type with 'ContractIR' for validateContractIR()
method in ControlFamilyInstance. This provides better type safety for
callers while the method parameter types remain 'unknown' with runtime
validation (since verify/sign methods need coreHash/profileHash fields
that are not part of ContractIR).

Changes:
- ControlFamilyInstance.validateContractIR() returns ContractIR
- SqlControlFamilyInstance.validateContractIR() returns ContractIR
- Remove now-unnecessary 'as ContractIR' cast in emitContract()
- Update CLI test mocks to match new return type

Note: Method parameters still use 'unknown' because emitted contracts
have coreHash/profileHash which are not in ContractIR (IR is pre-emission).
@wmadden

wmadden commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Merging without review. All checks pass, CodeRabbit is satisfied. Changes shouldn't affect ongoing work in the rest of the repo.

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.

1 participant