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

feat(adapter-postgres): move SQL cast policy onto adapter - #397

Merged
wmadden merged 14 commits into
mainfrom
tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill
Apr 29, 2026
Merged

wmadden merged 14 commits into
mainfrom
tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill

Conversation

@wmadden

@wmadden wmadden commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace the hardcoded codec-ID switch in the Postgres SQL renderer (getCodecParamCast) with adapter-level cast policy driven by each codec's existing meta.db.sql.postgres.nativeType. Architectural rationale lives in docs/architecture docs/adrs/ADR 205 - SQL cast emission is adapter policy.md.

What changed

  • Codec metadata stays descriptive. Each codec already declares meta.db.sql.postgres.nativeType for DDL emission and introspection. The renderer now reads that field; no new codec field.
  • Cast emission is adapter policy. The Postgres adapter holds a POSTGRES_INFERRABLE_NATIVE_TYPES set (numeric, boolean, string, temporal, bit-string Postgres builtins). The renderer emits $N if the codec's nativeType is in the set, $N::<nativeType> otherwise. json / jsonb are intentionally outside the set (operator-overload ambiguity); vector and other extension types fall through automatically.
  • Codec lookup reaches the renderer through the stack. Both SqlControlAdapterDescriptor.create(stack) and SqlRuntimeAdapterDescriptor.create(stack) thread the assembled codec lookup into the renderer. The bare createPostgresAdapter() factory defaults to a postgres-builtins-only lookup (extensions only flow through stack composition, by design).
  • Throw on lookup miss. A ParamRef carrying a codecId whose codec is absent from the assembled lookup throws at lower-time with a message naming the offending codecId and pointing at extension-pack registration. Strengthens the ADR's invariant: extension-codec misconfiguration surfaces immediately rather than as an opaque Postgres parser error later.
  • pgvector runtime wiring. pgvectorRuntimeDescriptor now exposes types.codecTypes.codecInstances (mirroring pgvectorPackMeta on the control side) so the runtime-plane lookup picks up pg/vector@1.
  • Tests migrated to stack composition. Three test files that previously used the bare factory with extension-codec-bearing contracts (operation-lowering.test.ts, rich-adapter.test.ts, control-adapter-lower-parity.test.ts) now compose stacks via a new test/helpers/composed-adapter.ts. Lowered SQL assertions stay byte-identical.

Layering

  • @prisma-next/adapter-postgres does not import any extension package by name. Vector/extension codec metadata reaches the renderer only through stack.codecLookup.
  • pnpm lint:deps clean; no new framework→target imports.

Validation gates

  • pnpm --filter @prisma-next/adapter-postgres test — 644/644
  • pnpm --filter @prisma-next/adapter-postgres typecheck — clean
  • pnpm --filter @prisma-next/adapter-postgres lint — clean
  • pnpm --filter @prisma-next/extension-pgvector test — 31/31
  • pnpm --filter @prisma-next/extension-pgvector typecheck — clean
  • pnpm --filter @prisma-next/extension-pgvector lint — clean
  • pnpm test:integration — 524/524 (pgvector / JSON / JSONB e2e SQL byte-identity preserved)
  • pnpm lint:deps — no dependency violations
  • rg "VECTOR_CODEC_ID|getCodecParamCast" packages/3-targets/6-adapters/postgres/src/ — zero matches

Commit graph

chore(projects/sql-cast-policy): close out project — ADR 205 landed in docs/
test(adapter-postgres): rename misleading postgresControlAdapterDescriptor alias  (+ ADR 205 migration via lint-staged restage)
test(adapter-postgres): migrate bare-factory + pgvector tests to stack-composed adapter
refactor(adapter-postgres): throw on codec-lookup miss in Postgres renderer (M2 R2)
feat(adapter-postgres): drive Postgres cast emission from codec metadata (M2)
fix(extension-pgvector): expose codec instances via runtime descriptor types
docs(projects/sql-cast-policy): amend M2 plan with codec-lookup wiring fix
feat(adapter-postgres): thread codecLookup into Postgres adapters and renderer (M1)
docs(projects/sql-cast-policy): shape TML-2310 — Postgres cast policy moves to the adapter
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Extension-contributed codecs (e.g., vector) are now included in composed adapter stacks and considered during SQL rendering.
  • Bug Fixes

    • Parameter cast emission is adapter-driven: renderer consults adapter-provided codec lookup, emits casts only when appropriate, and errors if required codec metadata is missing.
  • Documentation

    • Added ADR documenting the Postgres cast-emission policy and lookup behavior.
  • Tests

    • Added and updated tests/helpers covering cast policy, stack-derived codec resolution, and runtime/control parity.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Renderer cast emission is now driven by an assembled CodecLookup supplied by adapter/stack wiring. At lower time the renderer consults each codec’s Postgres nativeType and emits $N::<nativeType> only for non-inferrable natives; missing codec lookups cause a render-time error.

Changes

Cohort / File(s) Summary
ADR Documentation
docs/architecture/adrs/ADR 205 - SQL cast emission is adapter policy.md
New ADR formalizing that cast emission is adapter policy, how codec lookup is passed to the renderer, v1 inferrable native types (excludes json/jsonb), and lowering behaviors on missing metadata.
Renderer & Cast Policy
packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
renderLoweredSql signature gains codecLookup; parameter rendering queries codec metadata to decide $N vs $N::<nativeType> and throws if a referenced codecId is missing.
Adapter APIs & Wiring
packages/3-targets/6-adapters/postgres/src/core/adapter.ts, packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts, packages/3-targets/6-adapters/postgres/src/exports/control.ts, packages/3-targets/6-adapters/postgres/src/exports/runtime.ts, packages/3-targets/6-adapters/postgres/src/core/types.ts
Adapters accept/retain an optional CodecLookup (PostgresAdapterOptions.codecLookup); control/runtime factories and descriptors pass stack-derived lookup into adapter instances.
Builtin Codec Lookup Helper
packages/3-targets/6-adapters/postgres/src/core/codec-lookup.ts
Added createPostgresBuiltinCodecLookup() producing a built-ins-only CodecLookup populated from built-in codec definitions (excludes extension codecs).
Extension Runtime Descriptor
packages/3-extensions/pgvector/src/exports/runtime.ts
Runtime descriptor now exposes types.codecTypes.codecInstances so extension codec instances appear in assembled runtime codec lookup.
Tests — helpers & composition
packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts, packages/3-targets/6-adapters/postgres/test/descriptor-parity.test.ts
New composed adapter test helpers and adjusted descriptor-parity stub to provide stack metadata and include extension packs so a stack-derived codecLookup is produced.
Tests — adapter/runtime parity & usage
packages/3-targets/6-adapters/postgres/test/control-adapter-lower-parity.test.ts, packages/3-targets/6-adapters/postgres/test/operation-lowering.test.ts, packages/3-targets/6-adapters/postgres/test/rich-adapter.test.ts
Tests updated to instantiate adapters via composed factories (including pgvector) so runtime/control lowering share aligned codec lookups.
Cast Policy Tests
packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts
New tests validating cast emission rules, inferrable native types behavior, error on missing codec lookup entries, and integration with stack-derived/extension codecs (including pgvector).
Integration helper update
packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
Runtime helper now composes the stack-derived adapter (from stackInstance.adapter), guards runtime init/cleanup, and ensures lowering uses the stack-composed adapter with extension codecs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Stack as Execution Stack
  participant Ext as Extension Pack(s)
  participant Adapter as Postgres Adapter
  participant Renderer as SQL Renderer
  participant Lookup as CodecLookup

  Stack->>Ext: collect extension descriptors & codecInstances
  Stack->>Adapter: create adapter with assembled CodecLookup
  Adapter->>Renderer: renderLoweredSql(ast, contract, codecLookup)
  Renderer->>Lookup: lookup(codecId) for each ParamRef
  alt codec found and nativeType not inferrable
    Renderer->>Renderer: emit `$N::<nativeType>`
  else codec found and nativeType inferrable or absent
    Renderer->>Renderer: emit `$N`
  else codec missing
    Renderer->>Adapter: throw error (missing codecId)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I dug through codecs, tidy and neat,
Stack-built lookups make casts discreet.
Native types whisper when to append,
Extensions hop in—no surprises to mend.
A nibble, a hop—lowering sings complete.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(adapter-postgres): move SQL cast policy onto adapter' directly and accurately summarizes the main change: moving cast emission logic from hardcoded renderer IDs to adapter-driven policy based on codec metadata.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill

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

@pkg-pr-new

pkg-pr-new Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@397

@prisma-next/family-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-mongo@397

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@397

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@397

@prisma-next/middleware-telemetry

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/middleware-telemetry@397

@prisma-next/mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo@397

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@397

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@397

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@397

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@397

@prisma-next/sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sqlite@397

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@397

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@397

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@397

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@397

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@397

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@397

@prisma-next/errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/errors@397

@prisma-next/framework-components

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/framework-components@397

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@397

@prisma-next/ts-render

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ts-render@397

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@397

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@397

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@397

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@397

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@397

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@397

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@397

prisma-next

npm i https://pkg.pr.new/prisma/prisma-next@397

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@397

@prisma-next/mongo-codec

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-codec@397

@prisma-next/mongo-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract@397

@prisma-next/mongo-value

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-value@397

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-psl@397

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-ts@397

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-emitter@397

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-schema-ir@397

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-ast@397

@prisma-next/mongo-orm

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-orm@397

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-builder@397

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-lowering@397

@prisma-next/mongo-wire

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-wire@397

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@397

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@397

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@397

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@397

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@397

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@397

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@397

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@397

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@397

@prisma-next/sql-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder@397

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@397

@prisma-next/target-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-sqlite@397

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@397

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-sqlite@397

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@397

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-sqlite@397

commit: c95038c

@cursor
cursor Bot marked this pull request as ready for review April 29, 2026 15:29

@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

🧹 Nitpick comments (2)
packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts (1)

59-59: Prefer descriptor factory over direct class construction for control helper parity.

Using postgresAdapterControlDescriptor.create(stack) keeps this test helper resilient if descriptor construction logic evolves.

Suggested refactor
-  return new PostgresControlAdapter(stack.codecLookup);
+  return postgresAdapterControlDescriptor.create(stack);

As per coding guidelines, “Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts` at
line 59, Replace the direct construction of PostgresControlAdapter with the
descriptor factory to follow the public API pattern: instead of returning new
PostgresControlAdapter(stack.codecLookup) use
postgresAdapterControlDescriptor.create(stack) so the helper uses the descriptor
factory; update references in this helper to rely on
postgresAdapterControlDescriptor.create(stack) and remove direct usage of the
PostgresControlAdapter constructor.
packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts (1)

163-195: Consider reusing the composed-adapter test helper to reduce setup duplication.

Both stack-derived tests inline near-identical runtime target/adapter composition. Reusing test/helpers/composed-adapter.ts would keep wiring updates in one place.

Also applies to: 211-227

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts`
around lines 163 - 195, Replace the inline runtime/extension composition (the
local target, geographyExtension, and the call to
postgresRuntimeAdapterDescriptor.create({...}) that returns adapter) with the
shared composed-adapter test helper: import and call the helper to produce the
composed adapter (and any target/extension pack) instead of manually
constructing target and geographyExtension; remove the duplicated definitions
around the call sites (the block creating target, geographyExtension, and the
call to postgresRuntimeAdapterDescriptor.create) and reuse the helper in both
places referenced (lines near the current adapter creation and the other similar
block around 211-227) so wiring is centralized via the composed-adapter helper
API.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/architecture` docs/adrs/ADR 205 - SQL cast emission is adapter
policy.md:
- Around line 17-20: The fenced code block containing the error message "ERROR:
operator does not exist: vector <-> text" should include a language tag to
satisfy markdown lint (MD040); update the fence that surrounds that exact
error-output block to use ```text instead of just ``` so the block becomes a
labeled text code block. Ensure you modify the fenced block that contains the
string "ERROR: operator does not exist: vector <-> text" (the error-output
block) to include the language tag.

---

Nitpick comments:
In `@packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts`:
- Line 59: Replace the direct construction of PostgresControlAdapter with the
descriptor factory to follow the public API pattern: instead of returning new
PostgresControlAdapter(stack.codecLookup) use
postgresAdapterControlDescriptor.create(stack) so the helper uses the descriptor
factory; update references in this helper to rely on
postgresAdapterControlDescriptor.create(stack) and remove direct usage of the
PostgresControlAdapter constructor.

In
`@packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts`:
- Around line 163-195: Replace the inline runtime/extension composition (the
local target, geographyExtension, and the call to
postgresRuntimeAdapterDescriptor.create({...}) that returns adapter) with the
shared composed-adapter test helper: import and call the helper to produce the
composed adapter (and any target/extension pack) instead of manually
constructing target and geographyExtension; remove the duplicated definitions
around the call sites (the block creating target, geographyExtension, and the
call to postgresRuntimeAdapterDescriptor.create) and reuse the helper in both
places referenced (lines near the current adapter creation and the other similar
block around 211-227) so wiring is centralized via the composed-adapter helper
API.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 66d44003-569f-42df-8d66-39b8529eca38

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca1642 and 92a8e43.

📒 Files selected for processing (15)
  • docs/architecture docs/adrs/ADR 205 - SQL cast emission is adapter policy.md
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/src/core/adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/codec-lookup.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
  • packages/3-targets/6-adapters/postgres/src/core/types.ts
  • packages/3-targets/6-adapters/postgres/src/exports/control.ts
  • packages/3-targets/6-adapters/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter-lower-parity.test.ts
  • packages/3-targets/6-adapters/postgres/test/descriptor-parity.test.ts
  • packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/operation-lowering.test.ts
  • packages/3-targets/6-adapters/postgres/test/rich-adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts`:
- Around line 77-79: The error path currently throws when adapter is missing but
leaves the created pg Pool open; before throwing in the branch that checks `if
(!adapter)` ensure the pool is cleanly closed (call and await `pool.end()` or
`pgPool.end()` as appropriate) and handle the case where `pool` may be
undefined; alternatively wrap the setup in try/finally and call `await
pool.end()` in the finally block so the `pool` created/pinged earlier is always
ended before the function (or the `if (!adapter)` branch) throws.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 52e5c77b-6a75-4738-a907-5772b58bb309

📥 Commits

Reviewing files that changed from the base of the PR and between 92a8e43 and 1c5d9c1.

📒 Files selected for processing (1)
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts

@wmadden
wmadden force-pushed the tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill branch from 1c5d9c1 to 8035b0e Compare April 29, 2026 16:17

@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 (1)
packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts (1)

71-83: ⚠️ Potential issue | 🟡 Minor

Close the pool on setup failures.

At this point the Pool has already been created and pinged, so these new early throws can leak the connection if stack assembly is incomplete. Wrapping the whole post-new Pool(...) setup in try/catch and await pool.end() before rethrowing would fix the adapter/driver branches and the rest of the init path in one place.

Suggested fix
 export async function createPgIntegrationRuntime(
   connectionString: string,
 ): Promise<PgIntegrationRuntime> {
   const pool = new Pool({ connectionString });
-  await pool.query('select 1');
-
-  const contract = getTestContract();
-
-  const stack = createSqlExecutionStack({
-    target: postgresTarget,
-    adapter: postgresAdapter,
-    driver: postgresDriver,
-    extensionPacks: [pgvectorRuntime],
-  });
-
-  const context = createExecutionContext<TestContract>({ contract, stack });
-  const stackInstance = instantiateExecutionStack(stack);
+  try {
+    await pool.query('select 1');
+
+    const contract = getTestContract();
+
+    const stack = createSqlExecutionStack({
+      target: postgresTarget,
+      adapter: postgresAdapter,
+      driver: postgresDriver,
+      extensionPacks: [pgvectorRuntime],
+    });
+
+    const context = createExecutionContext<TestContract>({ contract, stack });
+    const stackInstance = instantiateExecutionStack(stack);
   // ...
-  return runtime;
+    return runtime;
+  } catch (error) {
+    await pool.end();
+    throw error;
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts`
around lines 71 - 83, The setup currently constructs a new Pool and then throws
early if stackInstance.adapter or stackInstance.driver are missing, which can
leak connections; wrap the code that runs after new Pool(...) (including
accesses to stackInstance.adapter and stackInstance.driver and any subsequent
init steps) in a try/catch, and in the catch call await pool.end() before
rethrowing the original error so the pool is always closed on setup failure;
reference the Pool construction, stackInstance.adapter and stackInstance.driver
checks, and pool.end() when making this change.
🧹 Nitpick comments (1)
docs/architecture docs/adrs/ADR 205 - SQL cast emission is adapter policy.md (1)

62-110: Trim the implementation mechanics out of the ADR.

The exact allow-list and pseudo-code are likely to drift faster than the architectural decision itself. I’d keep this document at the policy/constraint level and move the concrete mechanics to subsystem docs or inline code comments.

Based on learnings, "ADRs in prisma/prisma-next should document architectural design decisions and the key constraints/assumptions only. Do not include implementation algorithms, emitter derivation logic, or step-by-step derivation/migration rules."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/architecture` docs/adrs/ADR 205 - SQL cast emission is adapter policy.md
around lines 62 - 110, The ADR includes detailed implementation mechanics
(POSTGRES_INFERRABLE_NATIVE_TYPES set, renderTypedParam pseudo-code, and the
pgVectorCodec example) that should be removed from the decision record; instead,
trim the ADR to state the policy ("SQL cast emission is an adapter policy"), key
constraints (which kinds of types are inferrable vs. must be cast, rationale
about operator overloads like json/jsonb), and assumptions, and move the
concrete allow-list, exact spellings, and the renderTypedParam algorithm into a
subsystem implementation doc or inline code comments where
POSTGRES_INFERRABLE_NATIVE_TYPES and renderTypedParam live; keep the
pgVectorCodec example minimal or remove it from the ADR and place a fuller
example in the implementation docs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/3-extensions/pgvector/src/exports/runtime.ts`:
- Around line 47-52: The comment describing why we mirror
pgvectorPackMeta.types.codecTypes.codecInstances is outdated: a missing runtime
lookup now causes renderTypedParam() to throw rather than silently drop
::vector. Update the comment to state that we mirror
pgvectorPackMeta.types.codecTypes.codecInstances so that extractCodecLookup
(which reads descriptor.types?.codecTypes?.codecInstances) exposes the
pg/vector@1 codec to runtime-plane assemblers and prevents renderTypedParam()
from throwing on a lookup miss, rather than saying the cast would “silently
disappear.”

---

Duplicate comments:
In `@packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts`:
- Around line 71-83: The setup currently constructs a new Pool and then throws
early if stackInstance.adapter or stackInstance.driver are missing, which can
leak connections; wrap the code that runs after new Pool(...) (including
accesses to stackInstance.adapter and stackInstance.driver and any subsequent
init steps) in a try/catch, and in the catch call await pool.end() before
rethrowing the original error so the pool is always closed on setup failure;
reference the Pool construction, stackInstance.adapter and stackInstance.driver
checks, and pool.end() when making this change.

---

Nitpick comments:
In `@docs/architecture` docs/adrs/ADR 205 - SQL cast emission is adapter
policy.md:
- Around line 62-110: The ADR includes detailed implementation mechanics
(POSTGRES_INFERRABLE_NATIVE_TYPES set, renderTypedParam pseudo-code, and the
pgVectorCodec example) that should be removed from the decision record; instead,
trim the ADR to state the policy ("SQL cast emission is an adapter policy"), key
constraints (which kinds of types are inferrable vs. must be cast, rationale
about operator overloads like json/jsonb), and assumptions, and move the
concrete allow-list, exact spellings, and the renderTypedParam algorithm into a
subsystem implementation doc or inline code comments where
POSTGRES_INFERRABLE_NATIVE_TYPES and renderTypedParam live; keep the
pgVectorCodec example minimal or remove it from the ADR and place a fuller
example in the implementation docs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 36bf3ea3-d95f-4284-9223-192216652d01

📥 Commits

Reviewing files that changed from the base of the PR and between 1c5d9c1 and 8035b0e.

📒 Files selected for processing (16)
  • docs/architecture docs/adrs/ADR 205 - SQL cast emission is adapter policy.md
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/3-extensions/sql-orm-client/test/integration/runtime-helpers.ts
  • packages/3-targets/6-adapters/postgres/src/core/adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/codec-lookup.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
  • packages/3-targets/6-adapters/postgres/src/core/types.ts
  • packages/3-targets/6-adapters/postgres/src/exports/control.ts
  • packages/3-targets/6-adapters/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/test/control-adapter-lower-parity.test.ts
  • packages/3-targets/6-adapters/postgres/test/descriptor-parity.test.ts
  • packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/operation-lowering.test.ts
  • packages/3-targets/6-adapters/postgres/test/rich-adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/3-targets/6-adapters/postgres/src/core/types.ts
  • packages/3-targets/6-adapters/postgres/src/core/codec-lookup.ts
  • packages/3-targets/6-adapters/postgres/src/exports/runtime.ts
  • packages/3-targets/6-adapters/postgres/test/operation-lowering.test.ts
  • packages/3-targets/6-adapters/postgres/test/helpers/composed-adapter.ts
  • packages/3-targets/6-adapters/postgres/test/rich-adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/sql-renderer.cast-policy.test.ts
  • packages/3-targets/6-adapters/postgres/src/core/adapter.ts

cursor Bot pushed a commit that referenced this pull request Apr 29, 2026
…hrows

Wrap stack/runtime construction in `createPgIntegrationRuntime` in a
try/catch that ends the pool on any error between pool creation and a
working runtime. Without this, an early throw (missing adapter/driver
descriptor, failed `pool.query("select 1")`, failed `driver.connect`,
etc.) leaves the pool open until the test process exits, leaking
connections to PG. CodeRabbit flagged this on PR #397.

Co-authored-by: Will Madden <[email protected]>
cursor Bot pushed a commit that referenced this pull request Apr 29, 2026
… in cast-policy tests

Two CodeRabbit follow-ups on PR #397:

- `test/helpers/composed-adapter.ts`: route the control-side composition
  through `postgresAdapterControlDescriptor.create(stack)` instead of
  `new PostgresControlAdapter(stack.codecLookup)`. Matches the codebase's
  "factories not classes" coding convention and uses the same factory
  `exports/control.ts` runs in production. Drops the now-unused import of
  `PostgresControlAdapter`.

- `test/sql-renderer.cast-policy.test.ts`: factor the inline runtime stack
  composition in the geography-extension test and the pgvector smoke test
  through the existing `createComposedPostgresAdapter` helper. Drops the
  duplicated stub `RuntimeTargetDescriptor` declaration and the inline
  `postgresRuntimeAdapterDescriptor.create({...})` blocks. Drops the
  now-unused imports.

Co-authored-by: Will Madden <[email protected]>
wmadden and others added 14 commits April 29, 2026 18:46
… moves to the adapter

Spec, plan, and ADR 205 (draft) for replacing the hardcoded codec-ID
switch in `sql-renderer.ts` with adapter-level cast policy driven by
each codec's existing `nativeType` metadata. ADR 205 records the
descriptive-vs-policy seam: codecs declare what they are, the adapter
decides when to emit a `::T` cast via an inferrable-types vocabulary.
Closes the layering inversion where the core adapter named the
pgvector extension's codec ID.
… renderer (M1)

No behaviour change: getCodecParamCast still drives cast emission. The
renderer now receives a CodecLookup from each adapter so a follow-up can
read codec metadata at lower-time without further plumbing.

- PostgresAdapterOptions gains an optional readonly codecLookup; the impl
  defaults to a postgres-builtins-only lookup via createPostgresBuiltinCodecLookup.
- PostgresControlAdapter takes an optional codecLookup ctor arg with the
  same default.
- renderLoweredSql now requires a CodecLookup; threaded through the
  ParamIndexMap carrier so helper signatures stay stable.
- Control descriptor passes stack.codecLookup; runtime descriptor derives
  an equivalent lookup via extractCodecLookup over stack components, since
  the runtime ExecutionStack does not (yet) carry codecLookup directly.

M1 of TML-2310 / projects/sql-cast-policy.

Co-authored-by: Will Madden <[email protected]>
…g fix

Surfaced during M1 R1 review: pgvectorRuntimeDescriptor does not contribute types.codecTypes.codecInstances, so the runtime-plane lookup derived via extractCodecLookup is missing pg/vector@1. M1 stays behaviour-preserving (getCodecParamCast still drives emission), but M2 must address this before flipping the renderer to the lookup or vector casts will silently disappear at runtime.

Also pin the inferrable-set spelling to actual on-disk meta.db.sql.postgres.nativeType values (format_type-style: integer, boolean, timestamp with time zone, etc.), not the ADRs udt_name shorthand.

Co-authored-by: Will Madden <[email protected]>
…r types

M2 pre-flip wiring fix for projects/sql-cast-policy. The Postgres adapter
runtime-plane derives its codec lookup from `extractCodecLookup` over the
target / adapter / extension descriptors, which inspects
`types.codecTypes.codecInstances`. The pgvector control-side meta
(`pgvectorPackMeta`) already exposes that list; the runtime descriptor was
missing it, so the runtime lookup silently lacked `pg/vector@1`. Once M2
flips the renderer to lookup-driven cast policy, this would have caused
`$N::vector` to disappear at runtime even though the test contracts still
declare `nativeType: vector` on vector columns. Add the same field to the
runtime descriptor so both planes see the same codec set.

Co-authored-by: Will Madden <[email protected]>
…ata (M2)

Replaces the hardcoded `getCodecParamCast` switch (`pg/vector@1` /
`pg/json@1` / `pg/jsonb@1`) with a lookup-driven cast policy keyed off
each codec's `meta.db.sql.postgres.nativeType`. The renderer now consults
the assembled-stack `CodecLookup` first and emits `$N::<nativeType>` only
for codecs whose `nativeType` is outside `POSTGRES_INFERRABLE_NATIVE_TYPES`
(numeric / boolean / string / temporal / bit-string scalars). `json`,
`jsonb`, `vector`, and any extension-supplied or unknown type fall outside
the set and continue to emit a cast.

When the codec lookup misses entirely (e.g. `createPostgresAdapter()`
without an extension pack composing a stack), the renderer falls back to
a `codecId → nativeType` map derived from the contract's
`storage.tables[*].columns`. Contracts are themselves stack-derived
artifacts emitted by the contract emitter, so this remains consistent
with adapter-policy-driven-by-stack-metadata while keeping byte-identical
SQL for legacy bare-factory call sites that exercise extension codecs
through their contract column metadata (the existing test suites in
`adapter.test.ts`, `operation-lowering.test.ts`, `rich-adapter.test.ts`,
`control-adapter-lower-parity.test.ts` continue to assert `::jsonb` /
`::json` / `::vector` byte-for-byte).

Deletes `VECTOR_CODEC_ID`, `getCodecParamCast`, and the now-unused
`PG_JSON_CODEC_ID` / `PG_JSONB_CODEC_ID` imports from the renderer.

Adds `test/sql-renderer.cast-policy.test.ts` covering: codec with non-
inferrable `nativeType` → cast; codec with inferrable `nativeType` → no
cast; codec with no `meta` → no cast; codec lookup miss with contract
fallback; param ref without `codecId` → no cast; extension codec
contributed via `stack.extensionPacks` → cast (covers AC5); pgvector
installed via `stack.extensionPacks` → `$1::vector` (probe for the
M2 wiring fix in `pgvectorRuntimeDescriptor`).

Closes M2 of TML-2310 / projects/sql-cast-policy.

Co-authored-by: Will Madden <[email protected]>
…nderer (M2 R2)

Removes the contract-storage fallback added in M2 R1. A `ParamRef`
that carries a `codecId` not present in the assembled `codecLookup` is
a stack-configuration failure (almost always a missing extension pack
in the runtime stack), not a fallback opportunity. The renderer now
throws a clear error at lower-time naming the offending codecId so
callers fix the configuration rather than silently emitting an uncast
`$N` or guessing native types from contract storage.

The `codecId === undefined` and "lookup hit but no `meta`" branches are
unchanged: they still emit plain `$N` (the LiteralExpr-shaped param
ref and pg/enum@1-style codec cases respectively, per ADR 205).

Drops `buildContractNativeTypeMap`, `contractNativeTypes` from the
`ParamIndexMap` carrier, and the corresponding parameter from
`renderTypedParam`. Updates the cast-policy tests: the two former
"lookup miss → fallback" assertions are replaced with explicit throw
assertions naming the codecId.

Co-authored-by: Will Madden <[email protected]>
…k-composed adapter

Three test files exercised `pg/vector@1` ParamRefs through bare
`createPostgresAdapter()` / `new PostgresControlAdapter()`. Under M2's
new lookup-miss-throws contract, these would now throw because bare
factories cannot see extension codecs (ADR 205 § "Adapters built
without a stack"). Migrate each to compose a stack with the pgvector
runtime / control descriptor:

- test/operation-lowering.test.ts
- test/rich-adapter.test.ts
- test/control-adapter-lower-parity.test.ts

Existing assertions on the lowered SQL are unchanged — still byte-
identical `$N::vector` etc.

Adds `test/helpers/composed-adapter.ts` with two small factories
(`createComposedPostgresAdapter` / `createComposedPostgresControlAdapter`)
to keep the runtime / control stack composition local to the test
suite without growing a generic harness. The control variant uses
the real `sql` family / postgres target / postgres adapter control
descriptors so the assembled `codecLookup` matches what
`exports/control.ts` produces in production.

Co-authored-by: Will Madden <[email protected]>
…iptor alias

The control-side test helper imported `@prisma-next/target-postgres/control` under the name postgresControlAdapterDescriptor, but that descriptor is the postgres *target* control descriptor, not the postgres *adapter* control descriptor (which is the next import). Rename to postgresTargetControlDescriptor to match its actual role and avoid the two-line collision with postgresAdapterControlDescriptor.

Co-authored-by: Will Madden <[email protected]>
…n docs/

TML-2310 done: spec / plan / ADR draft migrated to docs/architecture docs/adrs/ADR 205 - SQL cast emission is adapter policy.md. The transient projects/ folder is no longer needed.

Co-authored-by: Will Madden <[email protected]>
…ntime helper

The pg integration helper composed pgvectorRuntime into the execution stack but used a separate bare createPostgresAdapter() to lower plans for assertion-side SQL capture. With the renderer now throwing on codec-lookup miss (per ADR 205), any vector ParamRef going through the bare adapter fails immediately at lower-time — exactly what failed in CI on extension-operations and codec-async integration tests.

Use the adapter from the assembled execution stack (which carries pg/vector@1 via the pgvector pack) for both lowering and execution. Removes the now-unused createPostgresAdapter import.

Co-authored-by: Will Madden <[email protected]>
…hrows

Wrap stack/runtime construction in `createPgIntegrationRuntime` in a
try/catch that ends the pool on any error between pool creation and a
working runtime. Without this, an early throw (missing adapter/driver
descriptor, failed `pool.query("select 1")`, failed `driver.connect`,
etc.) leaves the pool open until the test process exits, leaking
connections to PG. CodeRabbit flagged this on PR #397.

Co-authored-by: Will Madden <[email protected]>
… in cast-policy tests

Two CodeRabbit follow-ups on PR #397:

- `test/helpers/composed-adapter.ts`: route the control-side composition
  through `postgresAdapterControlDescriptor.create(stack)` instead of
  `new PostgresControlAdapter(stack.codecLookup)`. Matches the codebase's
  "factories not classes" coding convention and uses the same factory
  `exports/control.ts` runs in production. Drops the now-unused import of
  `PostgresControlAdapter`.

- `test/sql-renderer.cast-policy.test.ts`: factor the inline runtime stack
  composition in the geography-extension test and the pgvector smoke test
  through the existing `createComposedPostgresAdapter` helper. Drops the
  duplicated stub `RuntimeTargetDescriptor` declaration and the inline
  `postgresRuntimeAdapterDescriptor.create({...})` blocks. Drops the
  now-unused imports.

Co-authored-by: Will Madden <[email protected]>
…n type

After replacing `new PostgresControlAdapter(stack.codecLookup)` with `postgresAdapterControlDescriptor.create(stack)` (CodeRabbit factory-not-class nit), the helpers return type narrowed to the framework-level `ControlAdapterInstance<"sql","postgres">`, which does not expose `.lower`. Annotate the helper as `SqlControlAdapter<"postgres">` (which does) so call sites like `control-adapter-lower-parity.test.ts` continue to type-check.

Co-authored-by: Will Madden <[email protected]>
@wmadden
wmadden force-pushed the tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill branch from 9de8894 to c95038c Compare April 29, 2026 16:46
@wmadden
wmadden merged commit 75879e5 into main Apr 29, 2026
15 checks passed
wmadden added a commit that referenced this pull request Apr 29, 2026
…hrows

Wrap stack/runtime construction in `createPgIntegrationRuntime` in a
try/catch that ends the pool on any error between pool creation and a
working runtime. Without this, an early throw (missing adapter/driver
descriptor, failed `pool.query("select 1")`, failed `driver.connect`,
etc.) leaves the pool open until the test process exits, leaking
connections to PG. CodeRabbit flagged this on PR #397.

Co-authored-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request Apr 29, 2026
… in cast-policy tests

Two CodeRabbit follow-ups on PR #397:

- `test/helpers/composed-adapter.ts`: route the control-side composition
  through `postgresAdapterControlDescriptor.create(stack)` instead of
  `new PostgresControlAdapter(stack.codecLookup)`. Matches the codebase's
  "factories not classes" coding convention and uses the same factory
  `exports/control.ts` runs in production. Drops the now-unused import of
  `PostgresControlAdapter`.

- `test/sql-renderer.cast-policy.test.ts`: factor the inline runtime stack
  composition in the geography-extension test and the pgvector smoke test
  through the existing `createComposedPostgresAdapter` helper. Drops the
  duplicated stub `RuntimeTargetDescriptor` declaration and the inline
  `postgresRuntimeAdapterDescriptor.create({...})` blocks. Drops the
  now-unused imports.

Co-authored-by: Will Madden <[email protected]>
@wmadden
wmadden deleted the tml-2310-move-sql-param-cast-metadata-onto-codec-descriptors-kill branch April 29, 2026 17:03
wmadden added a commit that referenced this pull request May 4, 2026
…hrows

Wrap stack/runtime construction in `createPgIntegrationRuntime` in a
try/catch that ends the pool on any error between pool creation and a
working runtime. Without this, an early throw (missing adapter/driver
descriptor, failed `pool.query("select 1")`, failed `driver.connect`,
etc.) leaves the pool open until the test process exits, leaking
connections to PG. CodeRabbit flagged this on PR #397.

Co-authored-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 4, 2026
… in cast-policy tests

Two CodeRabbit follow-ups on PR #397:

- `test/helpers/composed-adapter.ts`: route the control-side composition
  through `postgresAdapterControlDescriptor.create(stack)` instead of
  `new PostgresControlAdapter(stack.codecLookup)`. Matches the codebase's
  "factories not classes" coding convention and uses the same factory
  `exports/control.ts` runs in production. Drops the now-unused import of
  `PostgresControlAdapter`.

- `test/sql-renderer.cast-policy.test.ts`: factor the inline runtime stack
  composition in the geography-extension test and the pgvector smoke test
  through the existing `createComposedPostgresAdapter` helper. Drops the
  duplicated stub `RuntimeTargetDescriptor` declaration and the inline
  `postgresRuntimeAdapterDescriptor.create({...})` blocks. Drops the
  now-unused imports.

Co-authored-by: Will Madden <[email protected]>
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.

3 participants