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

TML-1808 3: Emission plumbing for parameterized types - #97

Merged
jkomyno merged 12 commits into
mainfrom
tml-1808-phase-3-emission-plumbing
Jan 8, 2026
Merged

jkomyno merged 12 commits into
mainfrom
tml-1808-phase-3-emission-plumbing

Conversation

@wmadden

@wmadden wmadden commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

Part 3 of 6 in the parameterized column types stack.

Extends emission plumbing to pass parameterized codec descriptors and adds integration tests for parameterized type rendering.

Summary by CodeRabbit

  • New Features

    • Contract generation now supports parameterized type imports, enabling custom rendering for parameterized codecs.
  • Improvements

    • Type-import aggregation and deduplication added to emitted contract types; codec metadata extended to optionally include parameterized imports.
  • Tests

    • New unit and integration tests covering parameterized codec rendering, import emission, and deduplication behavior.
  • Revert

    • Removed multiple planning documents related to descriptor/manifest and contract authoring designs.

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

@coderabbitai

coderabbitai Bot commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Removed four planning documents and added end-to-end support for parameterized codec type imports: descriptors now declare parameterized imports, the SQL family extracts and forwards them through emission, and emitter/generator deduplicate and emit those imports into contract.d.ts.

Changes

Cohort / File(s) Summary
Planning documents removed
agent-os/specs/2025-12-05-db-init-command/planning/descriptor-manifest-serialized-view.plan.md, agent-os/specs/2025-12-05-db-init-command/planning/extend-planner.md, agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-and-descriptor-manifest-serialized-view.plan.md, agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-contract-authoring.plan.md
Deleted four design/planning markdowns; no runtime code changes implied.
Emission option surface
packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts, packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
Added optional parameterizedTypeImports to EmitOptions; unified conditional generation options via generateOptions and pass through to contract type generation.
Contract framework types
packages/1-framework/1-core/shared/contract/src/framework-components.ts, packages/1-framework/1-core/shared/contract/src/types.ts
Made codec type imports optional and added parameterizedImports; extended ValidationContext with parameterizedCodecs and GenerateContractTypesOptions with parameterizedTypeImports.
Emitter test updates
packages/1-framework/3-tooling/emitter/test/emitter.test.ts
Adjusted mock hook signatures (removed ctx from validateTypes; added options param to generateContractTypes); added tests asserting propagation of parameterizedRenderers and options capture.
SQL emitter import handling
packages/2-sql/3-tooling/emitter/src/index.ts
Aggregate three import sources (codec, operation, parameterized) and deduplicate by package+name, preserving first alias and order; render unified import statements for contract.d.ts.
SQL emitter rendering tests
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
Added tests for parameterized-type rendering: uses parameterized renderers when present, falls back to codec types when absent. (Duplicate blocks present.)
Family assembly + wiring
packages/2-sql/3-tooling/family/src/core/assembly.ts, packages/2-sql/3-tooling/family/src/core/instance.ts
Added extractParameterizedTypeImports() and wired extraction of parameterizedTypeImports from descriptors through family instance creation to the emission call.
SQL family integration tests
packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
New integration tests exercising end-to-end emission of parameterized codec type imports, deduplication, and correct contract.d.ts output across multiple codecs/packages.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Descriptor as Descriptor (Target/Adapter/Extension)
participant Assembly as Family Assembly
participant Instance as SQL Family Instance
participant Emitter as Emit/Control Plane
participant Generator as generateContractTypes
participant File as contract.d.ts

Descriptor->>Assembly: provide descriptors (including types.codecTypes.parameterizedImports)
Assembly->>Instance: assemble descriptors, extract parameterizedTypeImports
Instance->>Emitter: emit(contractIR, options including parameterizedTypeImports)
Emitter->>Generator: generateContractTypes(ir, codecImports, opImports, { parameterizedTypeImports })
Generator->>Generator: aggregate & dedupe imports (codec, operation, parameterized)
Generator->>File: write import lines and types into contract.d.ts


📜 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 812283f and f5ca962.

📒 Files selected for processing (1)
  • packages/2-sql/3-tooling/emitter/src/index.ts
🧰 Additional context used
📓 Path-based instructions (25)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

**/*.{ts,tsx}: Use local pnpm typecheck scripts instead of writing tsc commands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript

**/*.{ts,tsx}: Core contract types (ContractBase, Source) and document family types (DocumentContract) should be imported from @prisma-next/contract/types
SQL emitter hook should be imported from @prisma-next/sql-contract-emitter (canonical source)
Target-neutral operations should be imported from @prisma-next/operations (canonical source)

**/*.{ts,tsx}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with .d.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g., includeMany, returning())
Expo...

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in the exports/ folders

Import from shared plane packages using package name and export identifier (e.g., @prisma-next/sql-contract/types), not /exports/ paths

**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in .cursor/rules/import-validation.mdc and .cursor/architecture.config.json
Follow includeMany type inference patterns (as per .cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in .cursor/rules/arktype-usage.mdc
Use Object.hasOwn() instead of hasOwnProperty() (as per .cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{ts,tsx}

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

packages/**/*.{ts,tsx}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.create(), even for commands that don't use it (e.g., contract emit)
Do not use legacy descriptor types (FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor, ControlPlaneDriver). Use Control*Descriptor and Control*Instance types instead

packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g., emitContract, verify, schemaVerify, introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g., canonicalizeContract, `computeCoreHas...

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,sql}/**/*.ts

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

packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<ChildShape> from the Includes map using pattern: P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime: if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**

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

Structure multi-plane packages with split sources by plane: src/core/** for shared, src/exports/control.ts for migration, src/exports/runtime.ts for runtime

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**

📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)

Do not add backward-compatibility shims or migration scaffolding in the codebase

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)

Do not add deprecation warnings or migration helpers

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/index.ts

📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)

packages/**/src/index.ts: Never create index.ts files that only contain export * from './other-module' or export { something } from './other-module' - prefer explicit, direct imports instead
Only create index.ts files when they contain actual implementation code; use exports/index.ts pattern only for explicit, intentional API surfaces

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages,examples,test}/**/*.{ts,tsx}

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

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details

No generic defaults unless meaningful: defaults are semantics, not flexibility. See .cursor/rules/generic-parameters.mdc for details.

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}

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

packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as {alias}_lateral, column alias as {alias}, and select using table_alias.column_alias (e.g., posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then use json_agg(row_to_json(sub.*)) on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**/*.ts

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

Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**/*.{ts,tsx}

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

Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)

{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract, SqlStorage, SqlMappings, ModelDefinition, StorageTable, StorageColumn, etc.) from @prisma-next/sql-contract/types (shared plane package), not from @prisma-next/contract/types
SQL contract validators should be imported from @prisma-next/sql-contract/validators (shared plane)
SQL contract IR factories should be imported from @prisma-next/sql-contract/factories (shared plane)
SQL-specific operations should be imported from @prisma-next/sql-operations (canonical source, shared plane)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
**/*.{ts,tsx,test-d.ts}

📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)

When using validateContract<TContract>(), always use a fully-typed contract type (not a generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types throughout the code.

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
**/!(*.test|*.test-d|*.spec).ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)

For production code using validateContract<TContract>(), always import the contract type from contract.d.ts (generated by the emitter) rather than defining types inline.

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages,test,examples}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)

{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)

Never branch on target in core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages,test,examples}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)

{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g., columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without ?. operators

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)

packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts

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

{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for readability

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
{packages,examples}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)

Avoid blind casts like as unknown as X in production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.

{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See .cursor/rules/type-predicates.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for details.

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{ts,tsx,js,jsx}

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

For packages that span multiple planes, follow patterns in .cursor/rules/multi-plane-packages.mdc and .cursor/rules/multi-plane-entrypoints.mdc

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
**/*.{sql,ts,tsx}

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

Use LATERAL and json_agg patterns as defined in .cursor/rules/postgres-lateral-patterns.mdc

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
**/index.{ts,tsx,js,jsx}

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

Avoid barrel files (as per .cursor/rules/no-barrel-files.mdc)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**

📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)

Place all SQL target-family packages (all layers and planes) under packages/2-sql/**; place concrete dialects, adapters, and drivers under packages/3-targets/**

Files:

  • packages/2-sql/3-tooling/emitter/src/index.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/emitter/src/index.ts
🧬 Code graph analysis (1)
packages/2-sql/3-tooling/emitter/src/index.ts (1)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • TypesImportSpec (169-173)
🔇 Additional comments (3)
packages/2-sql/3-tooling/emitter/src/index.ts (3)

206-215: LGTM: Import collection is clear and correct.

The three-source import collection strategy is well-structured. Parameterized type imports are added last, which aligns with the "first occurrence wins" deduplication strategy implemented below.


235-241: LGTM: Import statement generation optimizes for readability.

The logic correctly omits redundant alias clauses when named === alias, improving the quality of generated import statements.


217-233: The deduplication logic and comments are correct. Parameterized renderers generate type references dynamically using ctx.codecTypesName and the codecId, not import aliases. The RenderTypeContext contains only the codec types name, so alias conflicts cannot affect renderer output. Deduplicating by package::named is safe and the explanatory comments are appropriate.


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

@wmadden
wmadden force-pushed the tml-1808-phase-2-codec-descriptors branch 3 times, most recently from ea950a9 to e3adb15 Compare January 7, 2026 20:56
Update emission API surfaces to include parameterized codec info:

- Add parameterizedCodecs to EmitOptions (Map<codecId, descriptor>)
- Add parameterizedCodecs to ValidationContext
- Add GenerateContractTypesOptions interface for structured options
- Update TargetFamilyHook.generateContractTypes signature with optional options
- Update emit() to pass parameterizedCodecs to both validateTypes and generateContractTypes

Update SQL family hook to accept the new options parameter.

Update SQL family instance to extract and pass parameterized codecs:
- Call extractParameterizedCodecs during instance creation
- Pass parameterizedCodecs to emit() calls

Add tests proving:
- parameterizedCodecs are passed to generateContractTypes options
- parameterizedCodecs are passed to ValidationContext

Part of TML-1808: Parameterized column types
- Add emit-parameterized.test.ts with integration tests covering:
  - typesImport from parameterizedCodecs appears in contract.d.ts
  - Multiple parameterized codecs from different packages
  - Multiple named exports from the same package

- Update SQL emitter generateContractTypes to:
  - Extract typesImport from parameterizedCodecs in options
  - Add them to the import list with deduplication
  - Omit redundant "as Alias" when named === alias

This completes the Phase 3 plumbing by ensuring parameterized type
imports flow from family instance through to emitted contract.d.ts.
Replace verbose ternary conditional spread patterns with ifDefined()
utility for cleaner, more readable code.

Also removes duplicate GenerateContractTypesOptions interface that was
causing type conflicts. The correct interface has only parameterizedRenderers,
since codecTypeImports and operationTypeImports are passed as separate args.
Replace two low-signal tests checking parameterizedCodecs (which did not
match the implementation) with a single focused test that verifies
parameterizedRenderers propagation to generateContractTypes.

The test now correctly matches the actual data flow:
- EmitOptions receives parameterizedRenderers (Map<string, TypeRenderEntry>)
- These are passed through to generateContractTypes options
- The renderer function is callable with params and context
…ring

Add two high-signal tests that prove parameterized renderers affect
actual contract.d.ts output:

1. When a column has typeParams and a matching renderer exists, the
   renderer produces the parameterized type (e.g., Vector<1536>)

2. When no renderer exists for a codec, falls back to CodecTypes lookup

These tests verify the end-to-end behavior rather than just plumbing.
@wmadden
wmadden force-pushed the tml-1808-phase-3-emission-plumbing branch from 43d7c06 to 781f051 Compare January 8, 2026 00:02
…structure

Add parameterizedImports field to ComponentMetadata.types.codecTypes for
extensions to declare type imports needed by their parameterized renderers.
This separates import concerns from renderer concerns in the new consolidated
codecTypes surface.

- Make codecTypes.import optional (adapters provide it, extensions usually do not)
- Add parameterizedTypeImports to GenerateContractTypesOptions
- Add parameterizedTypeImports to EmitOptions

This enables the emission pipeline to collect and deduplicate type imports
from parameterized codec descriptors across all loaded components.
Extract parameterized type imports from control descriptors during family
instance creation. These imports are collected from codecTypes.parameterizedImports
on adapters and extensions, then passed through the emission pipeline.

Follows the same pattern as extractCodecTypeImports and extractOperationTypeImports.
…line

Pass parameterized type imports from family instance through emit() to
generateContractTypes(). The SQL family instance now extracts these imports
during creation and includes them in the EmitOptions.

This completes the plumbing for parameterized type imports from component
descriptors to the emitter hook.
…edCodecs

Update generateContractTypes to consume the new parameterizedTypeImports
array instead of the non-existent parameterizedCodecs map. The new approach
is simpler: imports are already extracted and flattened by assembly, so the
emitter just merges them with other type imports.

This fixes the typecheck error from the incomplete API refactoring.
Migrate tests from the old ParameterizedCodecDescriptor array API to the
consolidated codecTypes surface:
- Use codecTypes.parameterized record for renderers (keyed by codecId)
- Use codecTypes.parameterizedImports array for type imports

Also fix createMockTarget to include required create method.
@wmadden wmadden changed the title Phase 3: Emission plumbing for parameterized types TML-1808 3: Emission plumbing for parameterized types Jan 8, 2026
@wmadden

wmadden commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @packages/2-sql/3-tooling/emitter/src/index.ts:
- Around line 206-232: The comment above the deduplication loop is misleading:
update the comment near the dedupe logic that references
allImports/seenImports/uniqueImports to state that imports are deduplicated by
package+named and that when duplicates occur the first occurrence (and its
alias) is kept; specifically clarify that different aliases for the same
package+named are not preserved but silently ignored because the key is
constructed as `${imp.package}::${imp.named}` and the loop pushes only the first
matching imp into uniqueImports.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 9ec5c7d and 812283f.

📒 Files selected for processing (14)
  • agent-os/specs/2025-12-05-db-init-command/planning/descriptor-manifest-serialized-view.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/extend-planner.md
  • agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-and-descriptor-manifest-serialized-view.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-contract-authoring.plan.md
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/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/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
💤 Files with no reviewable changes (4)
  • agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-and-descriptor-manifest-serialized-view.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/extend-planner.md
  • agent-os/specs/2025-12-05-db-init-command/planning/descriptor-manifest-serialized-view.plan.md
  • agent-os/specs/2025-12-05-db-init-command/planning/pack-refs-contract-authoring.plan.md
🧰 Additional context used
📓 Path-based instructions (41)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

**/*.{ts,tsx}: Use local pnpm typecheck scripts instead of writing tsc commands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript

**/*.{ts,tsx}: Core contract types (ContractBase, Source) and document family types (DocumentContract) should be imported from @prisma-next/contract/types
SQL emitter hook should be imported from @prisma-next/sql-contract-emitter (canonical source)
Target-neutral operations should be imported from @prisma-next/operations (canonical source)

**/*.{ts,tsx}: Extract CodecTypes from contract using ExtractCodecTypes<Contract> helper type with fallback to Record<string, never>
Extract OperationTypes from contract using ExtractOperationTypes<Contract> helper type with fallback to Record<string, never>
Never pass CodecTypes or OperationTypes as separate type parameters to schema(), sql(), or orm() functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing to createRuntimeContext() using validateContract<Contract>()

**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoc tsc, jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with .d.ts for precise types instead of inferring types from JSON imports
Always use validateContract<Contract>(json) with fully-typed Contract type parameter, not generic SqlContract<SqlStorage>
Access table columns using table.columns.fieldName to avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g., includeMany, returning())
Expo...

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in the exports/ folders

Import from shared plane packages using package name and export identifier (e.g., @prisma-next/sql-contract/types), not /exports/ paths

**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in .cursor/rules/import-validation.mdc and .cursor/architecture.config.json
Follow includeMany type inference patterns (as per .cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in .cursor/rules/arktype-usage.mdc
Use Object.hasOwn() instead of hasOwnProperty() (as per .cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per .cursor/rules/prefer-assertions-over-defensive-checks.mdc)

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.{ts,tsx}

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

packages/**/*.{ts,tsx}: Use ControlFamilyDescriptor<TFamilyId, TFamilyInstance> type for family descriptors in control plane implementations
Use ControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance> type for target descriptors in control plane implementations
Use ControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance> type for adapter descriptors in control plane implementations
Use ControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance> type for driver descriptors in control plane implementations
Use ControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance> type for extension descriptors in control plane implementations
All control plane descriptors must include kind property as a discriminator with value 'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must include id property as a string identifier
All control plane descriptors must include familyId property as a literal type (e.g., 'sql')
Target, adapter, driver, and extension descriptors must include targetId property as a literal type (e.g., 'postgres')
All control plane descriptors must include manifest property of type ExtensionPackManifest
All control plane descriptors must include create() factory method that returns an instance
Always pass driver parameter to ControlFamilyDescriptor.create(), even for commands that don't use it (e.g., contract emit)
Do not use legacy descriptor types (FamilyDescriptor, TargetDescriptor, AdapterDescriptor, DriverDescriptor, ExtensionDescriptor, ControlPlaneDriver). Use Control*Descriptor and Control*Instance types instead

packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g., emitContract, verify, schemaVerify, introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g., canonicalizeContract, `computeCoreHas...

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/src/**

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

Structure multi-plane packages with split sources by plane: src/core/** for shared, src/exports/control.ts for migration, src/exports/runtime.ts for runtime

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
packages/**

📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)

Do not add backward-compatibility shims or migration scaffolding in the codebase

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)

Do not add deprecation warnings or migration helpers

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages,examples,test}/**/*.{ts,tsx}

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

Always use Object.hasOwn() instead of hasOwnProperty() to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rule noPrototypeBuiltins.

Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details

No generic defaults unless meaningful: defaults are semantics, not flexibility. See .cursor/rules/generic-parameters.mdc for details.

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/src/**/*.ts

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

Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/**/*.{ts,tsx}

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

Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/*.{ts,tsx,test-d.ts}

📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)

When using validateContract<TContract>(), always use a fully-typed contract type (not a generic SqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting in unknown types throughout the code.

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/!(*.test|*.test-d|*.spec).ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)

For production code using validateContract<TContract>(), always import the contract type from contract.d.ts (generated by the emitter) rather than defining types inline.

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
{packages,test,examples}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)

{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)

Never branch on target in core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages,test,examples}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)

{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g., columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without ?. operators

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)

packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages,examples}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)

Avoid blind casts like as unknown as X in production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.

{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See .cursor/rules/type-predicates.mdc for details.
Use interface-based design with factory functions for object construction. See .cursor/rules/interface-factory-pattern.mdc for details.

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.{ts,tsx,js,jsx}

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

For packages that span multiple planes, follow patterns in .cursor/rules/multi-plane-packages.mdc and .cursor/rules/multi-plane-entrypoints.mdc

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{sql,ts,tsx}

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

Use LATERAL and json_agg patterns as defined in .cursor/rules/postgres-lateral-patterns.mdc

Files:

  • packages/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/{2-sql,sql}/**/*.ts

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

packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multiple includeMany() calls with an Includes map: Includes extends Record<string, any> = Record<string, never>
Use a helper type ExtractIncludeType<K extends string, Includes extends Record<string, any>> for safe type-safe lookup of include types from accumulated map with fallback to unknown
Handle boolean true in type inference to allow select({ posts: true }) to infer Array<ChildShape> from the Includes map using pattern: P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features like includeMany() and returning(), throwing planInvalid() errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g., includeMany requires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime: if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/src/index.ts

📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)

packages/**/src/index.ts: Never create index.ts files that only contain export * from './other-module' or export { something } from './other-module' - prefer explicit, direct imports instead
Only create index.ts files when they contain actual implementation code; use exports/index.ts pattern only for explicit, intentional API surfaces

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}

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

packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as {alias}_lateral, column alias as {alias}, and select using table_alias.column_alias (e.g., posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then use json_agg(row_to_json(sub.*)) on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)

{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract, SqlStorage, SqlMappings, ModelDefinition, StorageTable, StorageColumn, etc.) from @prisma-next/sql-contract/types (shared plane package), not from @prisma-next/contract/types
SQL contract validators should be imported from @prisma-next/sql-contract/validators (shared plane)
SQL contract IR factories should be imported from @prisma-next/sql-contract/factories (shared plane)
SQL-specific operations should be imported from @prisma-next/sql-operations (canonical source, shared plane)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts

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

{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns via tables.user.columns.email pattern instead of conflicting with table properties
Extract local variables when a file uses tables frequently - use const user = tables.user and const cols = user.columns for readability

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/index.{ts,tsx,js,jsx}

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

Avoid barrel files (as per .cursor/rules/no-barrel-files.mdc)

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**

📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)

Place all SQL target-family packages (all layers and planes) under packages/2-sql/**; place concrete dialects, adapters, and drivers under packages/3-targets/**

Files:

  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/src/core/**

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

packages/**/src/core/**: Keep src/core/** free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports inside src/core/**

Files:

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

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

Multi-plane packages must use a structured directory layout with src/core/ for shared plane code and src/exports/ for entry points (control.ts, runtime.ts)

Files:

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

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

Core plane code in src/core/** must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages

Files:

  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
**/*.{test,spec}.{ts,js}

📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)

Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)

Use local pnpm test scripts for testing; use pnpm test:coverage for all packages or pnpm coverage:packages for packages only

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)

When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)

Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.test.ts

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

Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests

**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-level describe blocks that can be split by functionality.
Use descriptive file names with the pattern {base}.{category}.test.ts, such as .basic.test.ts, .errors.test.ts, .structure.test.ts, or feature-area prefixes like runtime.joins.test.ts, runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined by describe blocks.
Prefer object comparison using toEqual or toMatchObject for assertions on objects, rather than property-by-property checks with toHaveProperty or individual property assertions. Use expect.any() for type-only checks and expect.not.objectContaining() for absence checks.
Compare entire plan structures using single toEqual assertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.

**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.{ts,js}

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

Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.{ts,tsx}

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

packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)

Integration tests that depend on multiple packages should be placed in @prisma-next/integration-tests to avoid cyclic dependencies.

Use factory functions like createContractIR() instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**

📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)

Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test,test-d,spec}.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)

For tests using validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never use validateContract<SqlContract<SqlStorage>>().

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}

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

Within-package tests: Import from source (../src/...), not from package exports

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.{test.ts,test-d.ts}

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

**/*.{test.ts,test-d.ts}: Use @ts-expect-error with a short reason in tests instead of blanket @ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Prefer unknown over any in tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. Use Object.create() and Object.assign() instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
**/*.test.{ts,tsx,js,jsx}

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

**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per .cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per .cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per .cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individual expect().toBe() calls in tests (as per .cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per .cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per .cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per .cursor/rules/test-mocking-patterns.mdc)

Files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.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/1-framework/1-core/shared/contract/src/framework-components.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/types.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/3-tooling/family/src/core/assembly.ts
  • packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts
  • packages/1-framework/1-core/shared/contract/src/types.ts
  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/2-sql/3-tooling/family/src/core/instance.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.

Applied to files:

  • packages/2-sql/3-tooling/family/test/emit-parameterized.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
🧬 Code graph analysis (5)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (2)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • TypesImportSpec (169-173)
packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)
  • TypesImportSpec (29-29)
packages/1-framework/1-core/migration/control-plane/src/emission/types.ts (2)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • TypesImportSpec (169-173)
packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)
  • TypesImportSpec (29-29)
packages/2-sql/3-tooling/emitter/src/index.ts (1)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • TypesImportSpec (169-173)
packages/1-framework/1-core/migration/control-plane/src/emission/emit.ts (2)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
  • ValidationContext (179-189)
packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)
  • ValidationContext (30-30)
packages/1-framework/3-tooling/emitter/test/emitter.test.ts (3)
packages/1-framework/1-core/shared/contract/src/ir.ts (1)
  • ContractIR (11-26)
packages/1-framework/3-tooling/emitter/test/utils.ts (1)
  • createContractIR (11-166)
packages/1-framework/1-core/shared/contract/src/types.ts (3)
  • GenerateContractTypesOptions (211-223)
  • TargetFamilyHook (229-259)
  • TypeRenderEntry (203-206)
🔇 Additional comments (20)
packages/1-framework/3-tooling/emitter/test/emitter.test.ts (3)

3-7: LGTM - Import changes align with new test requirements.

The additions of GenerateContractTypesOptions and TypeRenderEntry support the new parameterized renderers test, and removing ValidationContext is correct since the mock no longer uses it.


17-17: LGTM - Mock signatures correctly updated.

The mock hook signatures now match the updated TargetFamilyHook interface, with validateTypes no longer requiring ValidationContext and generateContractTypes accepting the new options parameter.

Also applies to: 49-59


652-702: LGTM - Comprehensive test for parameterized renderers propagation.

The test validates the complete flow of parameterized renderers through the emission pipeline, from EmitOptions to generateContractTypes. The assertions confirm both the propagation and the renderer's ability to produce parameterized type expressions.

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

225-229: LGTM - Appropriate change to support extension pack flexibility.

Making import optional is correct—extensions that only provide parameterized codecs don't need to declare a base codec types import. The updated comment clearly documents this behavior.


238-243: LGTM - Well-designed addition for parameterized type imports.

The new parameterizedImports field provides a clean way for components to declare type imports needed for parameterized codecs. The documentation is clear and the field is appropriately optional.

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

15-19: LGTM - Clean addition to emission options.

The new parameterizedTypeImports field follows the established pattern of codecTypeImports and operationTypeImports, providing a consistent way to pass parameterized type imports through the emission pipeline. The documentation clearly explains its purpose.

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

37-37: LGTM - Consistent implementation following established patterns.

The extraction and propagation of parameterizedTypeImports follows the exact same pattern as the existing metadata fields (codecTypeImports, operationTypeImports, parameterizedRenderers). The implementation is clean and consistent with the surrounding code.

Also applies to: 415-415, 896-896

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

184-188: LGTM!

The parameterizedCodecs field is well-designed for quick lookup during type generation, using a Map<string, ParameterizedCodecDescriptor> structure. The JSDoc clearly explains the purpose.


218-222: LGTM!

The parameterizedTypeImports option correctly mirrors the structure used elsewhere (ReadonlyArray<TypesImportSpec>) and integrates cleanly with the existing codec and operation type imports in the generation options.

packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts (3)

2-2: LGTM!

Import of TypeRenderEntry from the correct package path supports the new parameterized rendering tests.


582-631: LGTM!

The test correctly verifies that when a column has typeParams and a matching renderer exists in parameterizedRenderers, the emitter uses the renderer to produce the type expression (Vector<1536>). The assertions also properly verify that scalar codecs without parameterized renderers continue using the CodecTypes lookup pattern.


633-669: LGTM!

Good coverage of the fallback behavior—when no renderer exists for a codec with typeParams, the emitter correctly falls back to the standard CodecTypes['codecId']['output'] pattern.

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

166-190: LGTM!

The extractParameterizedTypeImports function follows the established pattern of its sibling extraction functions. The JSDoc appropriately notes that duplicates may be present, pushing deduplication responsibility to the caller (which aligns with how the emitter handles import deduplication).

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

58-63: LGTM!

The use of ifDefined for conditional spreading is clean and prevents adding undefined properties to the ValidationContext. This pattern is consistent throughout the function.


108-120: LGTM!

Good approach to conditionally construct generateOptions only when either parameterizedRenderers or parameterizedTypeImports is present, avoiding unnecessary object allocation when both are absent.

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

1-8: LGTM!

Imports are correctly sourced: types from @prisma-next/contract/types, control plane types from @prisma-next/core-control-plane/types, and the family instance factory from the local source path per coding guidelines.


17-74: LGTM!

The mock creator functions are well-structured with all required descriptor fields. The createMockExtensionWithParameterizedCodec function cleanly accepts configuration and conditionally includes parameterizedImports when a typesImport is provided.


76-149: LGTM!

Good integration test that exercises the full flow: creating a family instance with a parameterized codec extension, emitting a contract with a vector column, and verifying the type import appears in the generated contract.d.ts.


151-253: LGTM!

This test effectively validates that parameterized type imports are collected from multiple sources (both adapter and extension) and both appear in the emitted output.


255-353: LGTM!

Good test for verifying that different named exports from the same package are NOT incorrectly deduplicated. The comment on line 346 helpfully explains the expected behavior when alias === named.

@jkomyno jkomyno 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.

Base automatically changed from tml-1808-phase-2-codec-descriptors to main January 8, 2026 13:21
@jkomyno
jkomyno merged commit 1c2b83b into main Jan 8, 2026
@jkomyno
jkomyno deleted the tml-1808-phase-3-emission-plumbing branch January 8, 2026 13:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants