Skip to content

fix(extension-arktype-json, sql-runtime): correctness gaps from ADR 208 landing#418

Open
jkomyno wants to merge 17 commits intomainfrom
fix/arktype-json-runtime-correctness
Open

fix(extension-arktype-json, sql-runtime): correctness gaps from ADR 208 landing#418
jkomyno wants to merge 17 commits intomainfrom
fix/arktype-json-runtime-correctness

Conversation

@jkomyno
Copy link
Copy Markdown
Contributor

@jkomyno jkomyno commented May 4, 2026

Focused follow-up to #402. This PR fixes the arktype-json runtime path that ADR 208 exposed: Postgres writes need runtime cast metadata, Postgres reads need to tolerate driver-preparsed jsonb, codec errors need to preserve stable runtime envelopes, and the docs need to say what no-emit can actually type today.

Changes

  • Arktype-json wire behavior: Widened the codec wire type from string to string | JsonValue and normalized both raw JSON text and driver-preparsed JSONB values on decode. The previous JSON.parse(wire) assumption was wrong because pg returns jsonb as JavaScript values by default. Decode and decodeJson are now the schema-validation boundary; encode intentionally stays JSON.stringify only, because schema-validating on encode would make the codec parameter-dependent while params still carry only codecId.
  • Runtime codec metadata: Registered the arktype-json metadata shim on the runtime descriptor through types.codecTypes.codecInstances, and gave it meta.db.sql.postgres.nativeType = 'jsonb'. The old "emit-only" shape was incomplete: the Postgres renderer reads codec metadata at runtime to decide whether $N::jsonb casts are required, so the first arktype-json write or filter could fail before codec dispatch even ran.
  • Parameterized encode fallback: Added CodecDescriptor.encodeIsParamsIndependent and taught the runtime codec registry to keep rejecting ambiguous multi-instance forCodecId(codecId) lookups unless the descriptor declares that encode output is equivalent across all resolved parameter sets. The old ambiguity guard was right for parameter-dependent encoders, but too coarse for arktype-json and pgvector; both now declare the invariant explicitly, while decode still uses forColumn for per-column schemas.
  • Runtime error envelopes: Updated encode and decode runtime paths to pass through codec-thrown RUNTIME.JSON_SCHEMA_VALIDATION_FAILED and already-stamped RUNTIME.ENCODE_FAILED / RUNTIME.DECODE_FAILED envelopes. Wrapping every codec error was wrong because it hid stable schema-failure codes and double-wrapped errors whose details were already authored by the codec.
  • Arktype compatibility guard: Changed expression mismatch from a warning to RUNTIME.TYPE_PARAMS_INVALID and pinned arktype to ~2.1.29. A warning was too late: if ark.schema(jsonIr).expression diverges from serialized typeParams.expression, contract.d.ts may already be stale relative to the runtime schema. Failing at codec materialization is the more honest behavior.
  • Docs: Updated ADR 208, the no-emit subsystem doc, and the arktype-json README to mark parameterized no-emit output as partial. Today no-emit still resolves through the codec base output (vector(1536) becomes number[], arktypeJson(schema) becomes unknown); precise schema-shaped output comes from emitted contract.d.ts until TML-2357 lands.
  • Tests: Added coverage for runtime metadata lookup, jsonb cast metadata, pre-parsed JSONB objects and string primitives, expression mismatch hard-fail, params-independent encode fallback, runtime error pass-through, and the Embedding.profile ORM round trip through Postgres.

Why

The previous implementation mixed up control-plane and runtime responsibilities. It carried enough metadata for emission, but not enough metadata for Postgres lowering; it documented the intended no-emit resolver, but the resolver still uses codec base outputs; and it assumed the driver returned JSONB as strings, even though the default pg behavior is the opposite.

This version keeps those boundaries explicit. Encode stays parameter-independent until ParamRef.refs can identify the target column. Decode validates the schema because stored JSON can come from this writer, another service, manual SQL, or an older schema. Runtime metadata lives where the renderer actually reads it. The docs now distinguish shipped behavior from the remaining TML-2357 work.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

Preserve JSON-schema validation error codes on encode/decode paths; widen arktype-json codec to accept pre-parsed JsonValue, add a metadata-only emit codec instance to the runtime, enforce runtime type-params round-trip, mark some parameterized codecs as encode-params-independent, and document partial no-emit typing for parameterized columns.

Changes

Arktype JSON, runtime codec registry, and JSON-schema error pass-through

Layer / File(s) Summary
Data Shape
packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts, packages/3-extensions/arktype-json/test/arktype-json-codec.test-d.ts
Codec wire/input type widened from string → `string
Core Codec Implementation
packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts
Decode accepts pre-parsed JsonValue and normalizes with parseWireValue; schema validation moved to decode/decodeJson; serializeToJsonSafe no longer validates post-roundtrip; factory throws RUNTIME.TYPE_PARAMS_INVALID on expression mismatch; arktypeJsonEmitCodec annotated with Postgres jsonb meta; descriptor sets encodeIsParamsIndependent.
Runtime Wiring / Registry
packages/3-extensions/arktype-json/src/exports/runtime.ts, packages/1-framework/1-core/.../shared/codec-types.ts, packages/2-sql/5-runtime/src/sql-context.ts
Runtime descriptor exposes arktypeJsonEmitCodec in types.codecTypes.codecInstances; added encodeIsParamsIndependent?: boolean to CodecDescriptor; registry marks codec-id ambiguous only if descriptor lacks encodeIsParamsIndependent.
Encode/Decode Error Handling
packages/2-sql/5-runtime/src/codecs/encoding.ts, packages/2-sql/5-runtime/src/codecs/decoding.ts
encodeParamValue and decodeField detect runtime errors and rethrow unchanged when code is RUNTIME.JSON_SCHEMA_VALIDATION_FAILED (and preserve pre-wrapped RUNTIME.ENCODE_FAILED/RUNTIME.DECODE_FAILED), avoiding double-wrapping.
Tests / E2E
packages/2-sql/5-runtime/test/json-schema-validation.test.ts, packages/3-extensions/arktype-json/test/*, packages/2-sql/5-runtime/test/contract-codec-registry.test.ts, test/e2e/framework/test/arktype-json.test.ts
Added regression tests preserving JSON-schema validation error codes on encode/decode, updated arktype-json unit tests for pre-parsed jsonb handling and factory behavior, registry tests for encodeIsParamsIndependent, and an e2e codec round-trip test.
Packaging / Dependency
packages/3-extensions/arktype-json/package.json
arktype dependency specifier narrowed from ^2.1.29~2.1.29.
Documentation / ADRs
docs/architecture/.../ADR 208 - Higher-order codecs for parameterized types.md, docs/architecture/subsystems/9. No-Emit Workflow.md, packages/3-extensions/arktype-json/README.md
Documented partial no-emit behavior: parameterized columns fall back to codec base output types in no-emit mode (tracked TML-2357), clarified encode/decode validation timing for arktype-json, and updated ADR/resolution notes to denote emit-path-only progress.

Sequence Diagram

sequenceDiagram
  participant Client as Client
  participant Runtime as Runtime
  participant Codec as Codec
  participant DB as PostgresDB

  Client->>Runtime: encodeParam(value)
  Runtime->>Codec: codec.encode(wireValue)
  alt codec throws RUNTIME.JSON_SCHEMA_VALIDATION_FAILED
    Codec-->>Runtime: throw { code: RUNTIME.JSON_SCHEMA_VALIDATION_FAILED }
    Runtime-->>Client: rethrow unchanged
  else codec throws pre-wrapped RUNTIME.ENCODE_FAILED
    Codec-->>Runtime: throw { code: RUNTIME.ENCODE_FAILED, details }
    Runtime-->>Client: rethrow unchanged
  else success
    Codec-->>Runtime: encodedParam
    Runtime->>DB: send param
    DB-->>Runtime: stored
    Runtime-->>Client: success
  end

  Client->>Runtime: decodeRow(row)
  Runtime->>Codec: codec.decode(wire)
  alt codec throws RUNTIME.JSON_SCHEMA_VALIDATION_FAILED
    Codec-->>Runtime: throw { code: RUNTIME.JSON_SCHEMA_VALIDATION_FAILED }
    Runtime-->>Client: rethrow unchanged
  else codec throws pre-wrapped RUNTIME.DECODE_FAILED
    Codec-->>Runtime: throw { code: RUNTIME.DECODE_FAILED, details }
    Runtime-->>Client: rethrow unchanged
  else success
    Codec-->>Runtime: decodedValue
    Runtime-->>Client: return value
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I parse the strings and guard the gate,
Preserve the codes that validate,
A metadata seed where codecs meet,
Docs and tests make the path complete,
Hop on—emit to see the types elate.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.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
Title check ✅ Passed The title accurately summarizes the main focus: fixing correctness gaps from ADR 208 landing, specifically for arktype-json and sql-runtime. It clearly identifies the primary change.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/arktype-json-runtime-correctness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 4, 2026

Open in StackBlitz

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-arktype-json@418

@prisma-next/middleware-telemetry

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 89e3484

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/architecture docs/adrs/ADR 208 - Higher-order codecs for parameterized types.md (1)

116-120: ⚡ Quick win

Trim the resolver mechanics from the ADR.

This section is drifting into implementation flow (typeRef traversal, CodecInstanceContext application, Js extraction). The ADR reads cleaner if it stays at the architectural contract level and leaves the step-by-step resolver behavior to the subsystem docs.
As per coding guidelines: ADRs in prisma/prisma-next should document architectural design decisions and the key constraints/assumptions only; avoid implementation algorithms and 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 208 - Higher-order codecs for parameterized
types.md around lines 116 - 120, Remove the low-level resolver steps from the
ADR and keep it at the architectural-contract level: delete or reword the
paragraph that describes following typeRef through storage.types, synthetically
applying CodecInstanceContext, and extracting the Js parameter; instead state
that FieldOutputType<Definition, Model, Field> will be able to resolve
parameterized column types via the ColumnTypeDescriptor's authoring-only type
slot (type: (ctx: CodecInstanceContext) => Codec<…, Js>) and that for
non-parameterized columns it will fall back to CodecTypes[codecId]['output'],
while nullability is preserved—leave the step-by-step traversal and application
details to subsystem documentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/architecture` docs/adrs/ADR 208 - Higher-order codecs for parameterized
types.md:
- Around line 116-120: Remove the low-level resolver steps from the ADR and keep
it at the architectural-contract level: delete or reword the paragraph that
describes following typeRef through storage.types, synthetically applying
CodecInstanceContext, and extracting the Js parameter; instead state that
FieldOutputType<Definition, Model, Field> will be able to resolve parameterized
column types via the ColumnTypeDescriptor's authoring-only type slot (type:
(ctx: CodecInstanceContext) => Codec<…, Js>) and that for non-parameterized
columns it will fall back to CodecTypes[codecId]['output'], while nullability is
preserved—leave the step-by-step traversal and application details to subsystem
documentation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 98367176-41fe-4e0e-9a95-53b519c6db44

📥 Commits

Reviewing files that changed from the base of the PR and between 1d8b709 and eecca73.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • docs/architecture docs/adrs/ADR 208 - Higher-order codecs for parameterized types.md
  • docs/architecture docs/subsystems/9. No-Emit Workflow.md
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • packages/2-sql/5-runtime/test/json-schema-validation.test.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/arktype-json/package.json
  • packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts
  • packages/3-extensions/arktype-json/src/exports/runtime.ts
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test-d.ts
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test.ts
  • packages/3-extensions/arktype-json/test/extension-descriptors.test.ts

jkomyno added a commit that referenced this pull request May 4, 2026
…amily

The previous fix typed `arktypeJsonEmitCodec` against the SQL `Codec`
extension solely to gain the optional `meta` field. That coupled the
family-agnostic `codecInstances` slot to the SQL family — a future
non-SQL arktype variant (Mongo, etc.) would need a parallel stub or a
refactor of which interface owns `meta`.

Drop the SQL `Codec` import. Type the stub as the framework `Codec`
intersected with a co-located `SqlNativeTypeMeta` structural shape that
mirrors what the SQL renderer reads. The renderer's existing
`as SqlCodec | undefined` cast at the lookup boundary consumes `meta`
structurally regardless of the source declaration, so behavior is
unchanged.

Refs #418 self-review (subideal item #1).
jkomyno added a commit that referenced this pull request May 4, 2026
…ugh codec.encode

Symmetric to the decode-side guard added in 0574f04. Per-library JSON-
with-schema codecs validate inside `encode` (same shape as their
`decode` validation per ADR 208 § Case J) and throw the stable code
directly. Without this rethrow, `wrapEncodeFailure` re-wraps it as
`RUNTIME.ENCODE_FAILED` and the documented stable-code contract breaks
on the write side too.

Adds a regression test mirroring the decode-side one: a stub codec whose
`encode` throws `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`, asserted to
pass through `encodeParam` unchanged.

Refs #418 self-review (encode-side gap surfaced while writing the e2e
schema-rejection test).
jkomyno added a commit that referenced this pull request May 4, 2026
The `Embedding.profile` column has been in the e2e fixture since the
arktype-json landing but no test ever wrote or read it — which is why
the runtime cast lookup gap and the JSON.parse decode mismatch slipped
through. Add direct coverage:

1. Happy round-trip — `Embedding.create({ profile: { ... } })` followed
   by a where-eq read. Exercises the full encode path (schema validate
   → JSON.stringify → SQL renderer cast lookup → driver write) and the
   full decode path (driver read with pre-parsed jsonb → schema validate
   → ORM result).
2. Schema rejection on write — confirms `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`
   surfaces unchanged through the encode-side rethrow guard.

Decode-side rejection is already covered by the unit test in
sql-runtime/test/json-schema-validation.test.ts; not duplicated here.

Refs #418 self-review (subideal item #2).
jkomyno added a commit that referenced this pull request May 4, 2026
…k fires

The README's Compatibility section explained the round-trip invariant
and the version pin but didn't say when the runtime defense actually
runs. Add one sentence: the factory runs at execution-context
construction time (typically `runtime.connect()`), so a stale-but-shape-
valid contract.json fails fast at startup rather than on first query
or — worse — by silently returning wrong types.

Resolves the self-review concern about hard-fail timing: there is no
earlier hook to use without architectural changes (the round-trip
check requires materializing the schema, which neither paramsSchema
validation nor `prisma-next verify` does today).

Refs #418 self-review (subideal item #3).
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/2-sql/5-runtime/src/codecs/encoding.ts`:
- Around line 126-140: The catch block in codec.encode currently only preserves
RUNTIME.JSON_SCHEMA_VALIDATION_FAILED; update it to also pass-through existing
RUNTIME.ENCODE_FAILED envelopes so they are not re-wrapped. Concretely, in the
catch for codec.encode, check if isRuntimeError(error) and if error.code is
either 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED' or 'RUNTIME.ENCODE_FAILED' then
rethrow the error; otherwise call wrapEncodeFailure(error, metadata, paramIndex,
codec.id). This uses the existing symbols codec.encode, isRuntimeError, and
wrapEncodeFailure to locate and modify the logic.
🪄 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: 2514a56f-f827-4262-9205-60a0ad1599aa

📥 Commits

Reviewing files that changed from the base of the PR and between eecca73 and e551a6c.

📒 Files selected for processing (5)
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/test/json-schema-validation.test.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts
  • test/e2e/framework/test/arktype-json.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/3-extensions/arktype-json/README.md

Comment thread packages/2-sql/5-runtime/src/codecs/encoding.ts
jkomyno added a commit that referenced this pull request May 4, 2026
…r flag

The runtime registry rejects `forCodecId(codecId)` lookups when multiple
distinct resolved instances share a parameterized codec id (e.g. two
`vector(N)` columns of different lengths, or two `arktypeJson(...)`
columns with different schemas). Today's encode dispatch carries only
the codec id (no `(table, column)` ref — TML-2357 § AC-5), so without
the rejection a DSL-param could silently bind to the wrong instance.

But for codecs whose `encode` is structurally equivalent across all
resolved instances (pgvector, arktype-json with schema-independent
encode), the rejection is over-conservative: any registered instance
encodes correctly, so picking one is safe. Without an opt-out, contracts
with multiple parameterized columns of the same codec id break at
encode time before `ParamRef.refs` lands.

Add `encodeIsParamsIndependent?: boolean` to `CodecDescriptor`. The
runtime registry skips the ambiguity-marker for descriptors that opt
in. Decode dispatch still uses `forColumn(table, column)` to get the
instance-specific schema, so the per-column type check remains correct.
The flag becomes vestigial when AC-5 lands.

Adds two unit tests in `contract-codec-registry.test.ts`: the default
ambiguity rejection (proves the guard still fires) and the
`encodeIsParamsIndependent` opt-out path (proves multi-instance
contracts work end-to-end at the registry level).

Refs Codex review of #418 (F01 enabling change).
jkomyno added a commit that referenced this pull request May 4, 2026
…rate pre-parsed JSON primitives

Two correctness gaps Codex's review of #418 surfaced:

F01 — encode is now params-dependent. Pre-existing on origin/main
(`8edf6cde0`): `serializeToJsonSafe` validated against the per-instance
schema. With multiple `arktypeJson(...)` columns the resolved codecs
differ by reference, the registry's ambiguity guard fires under any
codec-id-only encode lookup, and ordinary creates/updates/filters throw
`RUNTIME.TYPE_PARAMS_INVALID` before encoding can run. Drop the
encode-side `validateSchema(json)` call. Validation runs on decode only,
matching the JSON-validator philosophy: payloads can come from any
source (this writer, a previous schema version, a manual SQL `INSERT`),
so validate when reading. Pair with the new `encodeIsParamsIndependent`
descriptor flag (previous commit) — `arktypeJsonCodec` opts in.

F02 — pre-parsed JSON string primitives fail decode. The `pg` driver
returns `jsonb` cells as already-parsed JS values by default, including
primitives. For an arktype `type('string')` schema, a stored `"alice"`
arrives as the bare JS string `alice` and `JSON.parse(wire)` throws
SyntaxError before the schema gets a chance. Replace the binary
`typeof === 'string' ? JSON.parse : passthrough` branch with a
`parseWireValue` helper that tries `JSON.parse` first and falls back
to the original wire on parse failure. Covers raw-JSON-text drivers,
pre-parsed objects/arrays/numbers/bools/null, and pre-parsed JSON
string primitives. Documented edge case: a stored JSON string `"123"`
arrives pre-parsed as `123`, parses to the number `123` — collision
matches what `pgJsonbCodec` does today and is intrinsic to the
driver-mode ambiguity.

Test changes:
- arktype-json-codec.test.ts: encode-validation expectations updated to
  the round-trip-only contract (existing tests where the runtime check
  was pinning encode-side schema rejection are reframed as encode
  normalization tests). Three new F02 tests: pre-parsed string
  primitive happy path, raw-JSON-text wire still parses, pre-parsed
  primitive fails schema validation.
- e2e arktype-json.test.ts: schema-rejection test rewritten — write
  with a schema-violating payload commits, the subsequent read throws
  `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`. Mirrors the new validate-on-
  read contract.

Refs Codex review of #418 (F01, F02).
jkomyno added a commit that referenced this pull request May 4, 2026
Three sections still reflected the pre-PR-418 state of the world:

- "Type fidelity end-to-end" claimed `vector(1536)` and
  `arktypeJson(schema)` resolve in the no-emit path. They don't —
  the resolver wiring is tracked under TML-2357 and the partial-
  status block earlier in the ADR already says so. Update the
  consequence to match.

- "Encode-side `forCodecId` legacy fallback" said arktype-json's
  encode is `JSON.stringify` (true) and that the fallback works
  because encode is per-instance-stateless w.r.t. params. The
  PR-418 review surfaced that this required keeping encode
  schema-independent, which is now an explicit design choice. Add
  the `encodeIsParamsIndependent` flag mechanism that lets multi-
  column contracts work pre-AC-5.

- "Per-library JSON extensions" section said the descriptor's factory
  "validates internally in `decode`". Make the asymmetry explicit:
  validation runs on decode only; encode is `JSON.stringify` with no
  schema check, matching the validate-on-read philosophy.

- "Resolves" bullet for TML-2229 claimed both no-emit AND emit paths
  resolve correctly. Only emit ships in #402; no-emit waits for
  TML-2357. Split the bullet to reflect the partial state.

These updates close Codex's F03. The previously-added partial-status
block at § "No-emit type resolution" stays — this commit just brings
the rest of the ADR into agreement with it.

Refs Codex review of #418 (F03).
jkomyno added a commit that referenced this pull request May 4, 2026
…r descriptor

Pgvector's wire format `[v1,v2,...]` is dimension-independent. Today
the parameterized factory dodges the registry's reference-based
ambiguity check by returning `sharedVectorCodec` for every params, so
two `vector(N)` columns of different lengths happen to share one codec
instance. That keeps multi-vector contracts working without the new
`encodeIsParamsIndependent` opt-out — but only by accident of the
factory being a constant.

The comment on `vectorFactory` already foreshadows a refactor that
would close over `params` (e.g. capping wire length to declared
dimension). Such a refactor would produce reference-distinct instances
and trip the registry's ambiguity guard, breaking multi-vector
contracts silently.

Declare `encodeIsParamsIndependent: true` on the parameterized vector
descriptor to pin the encode-equivalence guarantee at the descriptor
level. Future implementation changes either preserve the invariant or
remove the flag — the registry will tell you which.

Adds a regression test in `manifest.test.ts` asserting the flag is
declared.

Refs Codex review of #418 (encodeIsParamsIndependent applied beyond
arktype-json).
jkomyno added 14 commits May 4, 2026 14:18
Postgres `pg` returns `jsonb` cells as already-parsed JS values by default.
The arktype-json codec was hardcoded to `JSON.parse(wire)` and would
SyntaxError on every read where the driver pre-parsed. Mirror
`pgJsonbCodec`'s `string | JsonValue` tolerance so selects against
arktypeJson columns work end-to-end.

Widens `ArktypeJsonCodec`'s `TWire` from `string` to `string | JsonValue`
to match the runtime tolerance. Adds two test cases covering both wire
shapes for `decode`.

Refs #402 review (P1 #2).
… lookup

The arktype-json runtime descriptor did not expose
`types.codecTypes.codecInstances`, so the postgres adapter's
`extractCodecLookup` (called at execution time, not control time) had no
entry for `arktype/json@1`. The first query touching an arktypeJson column
failed in `renderTypedParam` with "assembled codec lookup has no entry"
before encode/decode dispatch ever ran. pgvector's runtime descriptor
already follows the correct pattern.

Two changes:

1. `arktypeJsonRuntimeDescriptor.types.codecTypes.codecInstances` surfaces
   `arktypeJsonEmitCodec` so the runtime cast lookup resolves.
2. `arktypeJsonEmitCodec` now carries `meta.db.sql.postgres.nativeType =
   'jsonb'`. The framework `Codec` type doesn't expose `meta`; switch
   the declaration to the SQL `Codec` extension which does. Without this,
   `renderTypedParam` would emit `$N` instead of `$N::jsonb` — and `jsonb`
   is deliberately excluded from `POSTGRES_INFERRABLE_NATIVE_TYPES`, so
   the cast is required for filter expressions.

Renames the codec from "emit-only shim" to "metadata-only stub" to
reflect that it now serves both emit-path renderOutputType lookup AND
runtime cast policy. Encode/decode are still sentinels that throw if
invoked — runtime materialization goes through the unified descriptor
map's `factory(params)(ctx)`.

Adds three regression assertions in `extension-descriptors.test.ts`
covering: presence in `codecInstances`, resolution through
`extractCodecLookup`, and the `jsonb` native-type metadata field.

Refs #402 review (P1 #1).
…ugh codec.decode

ADR 208 § Case J says per-library JSON-with-schema codecs (e.g.
`arktype/json@1`) validate inside `decode` and surface the stable
`RUNTIME.JSON_SCHEMA_VALIDATION_FAILED` code unchanged. The runtime did
not honor that contract: `decodeField` caught all `codec.decode` errors
and rewrapped them as `RUNTIME.DECODE_FAILED`. The rethrow guard for the
schema-validation code only existed for the legacy post-decode
`validateJsonValue` path.

Add the same guard to the codec-decode catch arm. Adds a regression test
in `json-schema-validation.test.ts` that registers a stub codec whose
`decode` throws `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED` and asserts the
code passes through `decodeRow` unchanged.

Refs #402 review (P2 #3).
…-implemented

ADR 208 § "No-emit type resolution" and the No-Emit Workflow subsystem
described `FieldOutputType` as following `typeRef` and applying the
column's authoring-time `type` slot to produce `Vector<1536>` and arktype-
schema-shaped types in no-emit mode. The resolver isn't wired up:
`@prisma-next/sql-contract-ts`'s `FieldOutputType` resolves through
`CodecTypesFromDefinition[codecId]['output']` only, and the arktype-json
codec-types map declares the `arktype/json@1` `output` as `unknown`. So
authors who skip `pnpm emit` get codec-base types, not the parameterized
refinements that emit produces.

Mark the resolver as not-yet-implemented in the ADR, the no-emit
subsystem, and the arktype-json README. Reference TML-2357 for tracked
follow-up. The eventual target shape stays in the docs as the design
intent — what changed is the status, not the design.

Refs #402 review (P2 #4).
…ent round-trip stability

The codec's emit-path output is derived from `schema.expression`. Runtime
rehydration via `ark.schema(typeParams.jsonIr)` reproduces that string
only as long as arktype's IR-to-expression rendering doesn't change. A
minor or major arktype bump can therefore stale-render existing
`contract.json` blobs without a corresponding re-emit.

Pin the dependency to `~2.1.29` (patch range only) and add a
"Compatibility" section to the README explaining the invariant and what
consumers should do when they bump arktype outside this range.

Refs #402 review (other concerns — arktype version pinning).
Previously, when the rehydrated schema's `expression` didn't match
`typeParams.expression`, the factory emitted a `console.warn` and kept
going. The branch was wrapped in `c8 ignore`, which made it untested.

Two problems with the warning approach. First, by the time the runtime
materializes the codec, the bad `contract.d.ts` has already been emitted
and shipped — a runtime warning fires after the wrong types are in
consumer code. Second, the expression-vs-rehydrated round-trip is
exactly the invariant the package's arktype version pin protects. A
silent warning is the wrong response when the invariant breaks.

Throw `RUNTIME.TYPE_PARAMS_INVALID` instead, with a message that points
the caller at re-running `pnpm emit`. Removes the `c8 ignore` so the
branch is testable; adds two tests (one for divergence, one for the
matching happy path).

Refs #402 review (other concerns — expression divergence handler).
…amily

The previous fix typed `arktypeJsonEmitCodec` against the SQL `Codec`
extension solely to gain the optional `meta` field. That coupled the
family-agnostic `codecInstances` slot to the SQL family — a future
non-SQL arktype variant (Mongo, etc.) would need a parallel stub or a
refactor of which interface owns `meta`.

Drop the SQL `Codec` import. Type the stub as the framework `Codec`
intersected with a co-located `SqlNativeTypeMeta` structural shape that
mirrors what the SQL renderer reads. The renderer's existing
`as SqlCodec | undefined` cast at the lookup boundary consumes `meta`
structurally regardless of the source declaration, so behavior is
unchanged.

Refs #418 self-review (subideal item #1).
…ugh codec.encode

Symmetric to the decode-side guard added in 0574f04. Per-library JSON-
with-schema codecs validate inside `encode` (same shape as their
`decode` validation per ADR 208 § Case J) and throw the stable code
directly. Without this rethrow, `wrapEncodeFailure` re-wraps it as
`RUNTIME.ENCODE_FAILED` and the documented stable-code contract breaks
on the write side too.

Adds a regression test mirroring the decode-side one: a stub codec whose
`encode` throws `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`, asserted to
pass through `encodeParam` unchanged.

Refs #418 self-review (encode-side gap surfaced while writing the e2e
schema-rejection test).
The `Embedding.profile` column has been in the e2e fixture since the
arktype-json landing but no test ever wrote or read it — which is why
the runtime cast lookup gap and the JSON.parse decode mismatch slipped
through. Add direct coverage:

1. Happy round-trip — `Embedding.create({ profile: { ... } })` followed
   by a where-eq read. Exercises the full encode path (schema validate
   → JSON.stringify → SQL renderer cast lookup → driver write) and the
   full decode path (driver read with pre-parsed jsonb → schema validate
   → ORM result).
2. Schema rejection on write — confirms `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`
   surfaces unchanged through the encode-side rethrow guard.

Decode-side rejection is already covered by the unit test in
sql-runtime/test/json-schema-validation.test.ts; not duplicated here.

Refs #418 self-review (subideal item #2).
…k fires

The README's Compatibility section explained the round-trip invariant
and the version pin but didn't say when the runtime defense actually
runs. Add one sentence: the factory runs at execution-context
construction time (typically `runtime.connect()`), so a stale-but-shape-
valid contract.json fails fast at startup rather than on first query
or — worse — by silently returning wrong types.

Resolves the self-review concern about hard-fail timing: there is no
earlier hook to use without architectural changes (the round-trip
check requires materializing the schema, which neither paramsSchema
validation nor `prisma-next verify` does today).

Refs #418 self-review (subideal item #3).
…r flag

The runtime registry rejects `forCodecId(codecId)` lookups when multiple
distinct resolved instances share a parameterized codec id (e.g. two
`vector(N)` columns of different lengths, or two `arktypeJson(...)`
columns with different schemas). Today's encode dispatch carries only
the codec id (no `(table, column)` ref — TML-2357 § AC-5), so without
the rejection a DSL-param could silently bind to the wrong instance.

But for codecs whose `encode` is structurally equivalent across all
resolved instances (pgvector, arktype-json with schema-independent
encode), the rejection is over-conservative: any registered instance
encodes correctly, so picking one is safe. Without an opt-out, contracts
with multiple parameterized columns of the same codec id break at
encode time before `ParamRef.refs` lands.

Add `encodeIsParamsIndependent?: boolean` to `CodecDescriptor`. The
runtime registry skips the ambiguity-marker for descriptors that opt
in. Decode dispatch still uses `forColumn(table, column)` to get the
instance-specific schema, so the per-column type check remains correct.
The flag becomes vestigial when AC-5 lands.

Adds two unit tests in `contract-codec-registry.test.ts`: the default
ambiguity rejection (proves the guard still fires) and the
`encodeIsParamsIndependent` opt-out path (proves multi-instance
contracts work end-to-end at the registry level).

Refs Codex review of #418 (F01 enabling change).
…rate pre-parsed JSON primitives

Two correctness gaps Codex's review of #418 surfaced:

F01 — encode is now params-dependent. Pre-existing on origin/main
(`8edf6cde0`): `serializeToJsonSafe` validated against the per-instance
schema. With multiple `arktypeJson(...)` columns the resolved codecs
differ by reference, the registry's ambiguity guard fires under any
codec-id-only encode lookup, and ordinary creates/updates/filters throw
`RUNTIME.TYPE_PARAMS_INVALID` before encoding can run. Drop the
encode-side `validateSchema(json)` call. Validation runs on decode only,
matching the JSON-validator philosophy: payloads can come from any
source (this writer, a previous schema version, a manual SQL `INSERT`),
so validate when reading. Pair with the new `encodeIsParamsIndependent`
descriptor flag (previous commit) — `arktypeJsonCodec` opts in.

F02 — pre-parsed JSON string primitives fail decode. The `pg` driver
returns `jsonb` cells as already-parsed JS values by default, including
primitives. For an arktype `type('string')` schema, a stored `"alice"`
arrives as the bare JS string `alice` and `JSON.parse(wire)` throws
SyntaxError before the schema gets a chance. Replace the binary
`typeof === 'string' ? JSON.parse : passthrough` branch with a
`parseWireValue` helper that tries `JSON.parse` first and falls back
to the original wire on parse failure. Covers raw-JSON-text drivers,
pre-parsed objects/arrays/numbers/bools/null, and pre-parsed JSON
string primitives. Documented edge case: a stored JSON string `"123"`
arrives pre-parsed as `123`, parses to the number `123` — collision
matches what `pgJsonbCodec` does today and is intrinsic to the
driver-mode ambiguity.

Test changes:
- arktype-json-codec.test.ts: encode-validation expectations updated to
  the round-trip-only contract (existing tests where the runtime check
  was pinning encode-side schema rejection are reframed as encode
  normalization tests). Three new F02 tests: pre-parsed string
  primitive happy path, raw-JSON-text wire still parses, pre-parsed
  primitive fails schema validation.
- e2e arktype-json.test.ts: schema-rejection test rewritten — write
  with a schema-violating payload commits, the subsequent read throws
  `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`. Mirrors the new validate-on-
  read contract.

Refs Codex review of #418 (F01, F02).
Three sections still reflected the pre-PR-418 state of the world:

- "Type fidelity end-to-end" claimed `vector(1536)` and
  `arktypeJson(schema)` resolve in the no-emit path. They don't —
  the resolver wiring is tracked under TML-2357 and the partial-
  status block earlier in the ADR already says so. Update the
  consequence to match.

- "Encode-side `forCodecId` legacy fallback" said arktype-json's
  encode is `JSON.stringify` (true) and that the fallback works
  because encode is per-instance-stateless w.r.t. params. The
  PR-418 review surfaced that this required keeping encode
  schema-independent, which is now an explicit design choice. Add
  the `encodeIsParamsIndependent` flag mechanism that lets multi-
  column contracts work pre-AC-5.

- "Per-library JSON extensions" section said the descriptor's factory
  "validates internally in `decode`". Make the asymmetry explicit:
  validation runs on decode only; encode is `JSON.stringify` with no
  schema check, matching the validate-on-read philosophy.

- "Resolves" bullet for TML-2229 claimed both no-emit AND emit paths
  resolve correctly. Only emit ships in #402; no-emit waits for
  TML-2357. Split the bullet to reflect the partial state.

These updates close Codex's F03. The previously-added partial-status
block at § "No-emit type resolution" stays — this commit just brings
the rest of the ADR into agreement with it.

Refs Codex review of #418 (F03).
…r descriptor

Pgvector's wire format `[v1,v2,...]` is dimension-independent. Today
the parameterized factory dodges the registry's reference-based
ambiguity check by returning `sharedVectorCodec` for every params, so
two `vector(N)` columns of different lengths happen to share one codec
instance. That keeps multi-vector contracts working without the new
`encodeIsParamsIndependent` opt-out — but only by accident of the
factory being a constant.

The comment on `vectorFactory` already foreshadows a refactor that
would close over `params` (e.g. capping wire length to declared
dimension). Such a refactor would produce reference-distinct instances
and trip the registry's ambiguity guard, breaking multi-vector
contracts silently.

Declare `encodeIsParamsIndependent: true` on the parameterized vector
descriptor to pin the encode-equivalence guarantee at the descriptor
level. Future implementation changes either preserve the invariant or
remove the flag — the registry will tell you which.

Adds a regression test in `manifest.test.ts` asserting the flag is
declared.

Refs Codex review of #418 (encodeIsParamsIndependent applied beyond
arktype-json).
@jkomyno jkomyno force-pushed the fix/arktype-json-runtime-correctness branch from e5ba9f5 to 192a4ed Compare May 4, 2026 12:19
jkomyno added 3 commits May 4, 2026 14:26
The "writes succeed, reads enforce" test failed in CI: I missed that
`db.orm.Embedding.create` returns a decoded row via `RETURNING`, so
schema enforcement happens during create itself rather than on a
subsequent read. There's no single ORM call that cleanly demonstrates
the validate-on-read contract end-to-end without raw-SQL bypass
infrastructure the fixture doesn't expose.

Drop the failing case. Decode-side schema rejection is already covered
at:
- arktype-json unit tests (decode rejects pre-parsed payloads that
  violate the schema, decode rejects pre-parsed primitives that
  violate the schema)
- sql-runtime json-schema-validation tests (runtime preserves
  RUNTIME.JSON_SCHEMA_VALIDATION_FAILED thrown from codec.decode
  without rewrapping)

The happy-path e2e round-trip stays as the single end-to-end smoke
test; it exercises the full encode → cast lookup → driver write →
driver read (pre-parsed jsonb) → decode pipeline that originally
shipped broken in #402.
…gh unchanged

`encodeParams` and `decodeRow` already documented "no double wrap"
behavior for codec-stamped runtime envelopes, but the catch blocks
inside `encodeParamValue` and `decodeField` only special-cased
`RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`. Anything else flowed through
`wrapEncodeFailure` / `wrapDecodeFailure`, including envelopes a codec
body had already stamped — dropping the author-supplied
`details`/`cause` contract and producing a misleading double-wrap.

Extend both guards to also pass `RUNTIME.ENCODE_FAILED` /
`RUNTIME.DECODE_FAILED` through unchanged. The code now matches the
existing doc.

Adds two regression tests pinning the pass-through: a codec whose
`encode` throws a stamped `RUNTIME.ENCODE_FAILED` (with custom
`details.codecAuthorContext`) reaches `encodeParam` unchanged, and the
symmetric case for `decodeRow`.

Refs PR #418 review (CodeRabbit r3181136080).
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/e2e/framework/test/arktype-json.test.ts (1)

2-2: ⚡ Quick win

Prefer pathe over node:path for path manipulation.

dirname and resolve should be imported from pathe (drop-in replacement with identical API) rather than node:path. Note: node:url on line 3 stays — fileURLToPath has no pathe equivalent.

♻️ Proposed change
 import { readFile } from 'node:fs/promises';
-import { dirname, resolve } from 'node:path';
+import { dirname, resolve } from 'pathe';
 import { fileURLToPath } from 'node:url';

As per coding guidelines: "**/*.{ts,tsx,mts,cts}: Use pathe instead of node:path for path manipulation in TypeScript files... especially when code reads files/fixtures from disk."

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

In `@test/e2e/framework/test/arktype-json.test.ts` at line 2, Replace imports of
dirname and resolve from 'node:path' with imports from 'pathe': update the
import statement that currently pulls dirname and resolve from 'node:path' so it
instead imports those symbols from 'pathe' (leave fileURLToPath from 'node:url'
unchanged); ensure any usages of dirname and resolve remain the same since pathe
is a drop-in replacement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/e2e/framework/test/arktype-json.test.ts`:
- Line 2: Replace imports of dirname and resolve from 'node:path' with imports
from 'pathe': update the import statement that currently pulls dirname and
resolve from 'node:path' so it instead imports those symbols from 'pathe' (leave
fileURLToPath from 'node:url' unchanged); ensure any usages of dirname and
resolve remain the same since pathe is a drop-in replacement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 6cbb9930-0b82-4bda-95c7-86a13d6d26fe

📥 Commits

Reviewing files that changed from the base of the PR and between e5ba9f5 and 6a2e33b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • docs/architecture docs/adrs/ADR 208 - Higher-order codecs for parameterized types.md
  • docs/architecture docs/subsystems/9. No-Emit Workflow.md
  • packages/1-framework/1-core/framework-components/src/shared/codec-types.ts
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/src/sql-context.ts
  • packages/2-sql/5-runtime/test/contract-codec-registry.test.ts
  • packages/2-sql/5-runtime/test/json-schema-validation.test.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/arktype-json/package.json
  • packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts
  • packages/3-extensions/arktype-json/src/exports/runtime.ts
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test-d.ts
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test.ts
  • packages/3-extensions/arktype-json/test/extension-descriptors.test.ts
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/3-extensions/pgvector/test/manifest.test.ts
  • test/e2e/framework/test/arktype-json.test.ts
✅ Files skipped from review due to trivial changes (7)
  • packages/3-extensions/pgvector/src/exports/runtime.ts
  • packages/3-extensions/pgvector/test/manifest.test.ts
  • packages/3-extensions/arktype-json/package.json
  • packages/1-framework/1-core/framework-components/src/shared/codec-types.ts
  • packages/3-extensions/arktype-json/README.md
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test.ts
  • docs/architecture docs/subsystems/9. No-Emit Workflow.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/2-sql/5-runtime/test/contract-codec-registry.test.ts
  • packages/3-extensions/arktype-json/test/arktype-json-codec.test-d.ts
  • packages/3-extensions/arktype-json/test/extension-descriptors.test.ts
  • packages/3-extensions/arktype-json/src/core/arktype-json-codec.ts
  • packages/2-sql/5-runtime/src/sql-context.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts

Copy link
Copy Markdown
Contributor

@wmadden wmadden left a comment

Choose a reason for hiding this comment

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

I want to hold off merging this until TML-2357 / PR #417 is merged. This PR adds an extra conditional flag to codec descriptors, encodeIsParamsIndependent, which is made redundant by #417

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants