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

Keep @prisma-next/config path-agnostic for contract sources - #356

Merged
jkomyno merged 46 commits into
mainfrom
tml-2276-authoritative-watch-inputs
Apr 21, 2026
Merged

jkomyno merged 46 commits into
mainfrom
tml-2276-authoritative-watch-inputs

Conversation

@jkomyno

@jkomyno jkomyno commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR keeps @prisma-next/config path-agnostic again.

contract.source.inputs stays as the declarative source list, but path resolution and cross-field path validation now happen in the CLI loader, which already owns the authoritative config-file directory. Providers consume absolute paths through ContractSourceContext.resolvedInputs, and emitted artifact path mapping lives in @prisma-next/emitter.

Why

The first version of this work introduced the right contract-source shape (inputs + load) but still left path semantics split across layers:

  • @prisma-next/config imported path utilities and compared paths
  • providers received configDir through ContractSourceEnvironment
  • emitted artifact path derivation was duplicated across config, CLI, and Vite

That made the framework-core config package responsible for I/O-adjacent concerns it should not own.

Main Changes

  • remove path handling from @prisma-next/config; validation there is shape-only again
  • remove ContractSourceEnvironment and createPathBackedSource
  • keep ContractSourceProvider.load(context) as a one-argument API and add resolvedInputs to ContractSourceContext
  • make loadConfig() resolve contract.source.inputs and contract.output to absolute paths once, relative to the config file
  • move the output ∉ inputs check into the CLI loader
  • centralize contract.json / contract.d.ts path derivation in getEmittedArtifactPaths() inside @prisma-next/emitter
  • update PSL providers and TypeScript contract facades to read context.resolvedInputs
  • make the Vite plugin consume finalized absolute inputs directly instead of re-resolving them
  • pass the output path into emit() so the emitter-owned artifact-path helper is exercised from the emit path as well

Behavior

  • no end-user config syntax change
  • loadConfig() now returns absolute contract.source.inputs and absolute contract.output
  • declaring an emitted artifact as an input still fails before emit, but the error now comes from loadConfig() rather than defineConfig()
  • Vite still watches provider-declared inputs, but now consumes the loader-finalized paths directly

Test-only Cleanup

  • raise timeout budgets for DB-backed CLI and integration tests that were flaky under full-repo load
  • make the Vite HMR e2e test wait until rewritten contract.json is readable before parsing it

Validation

  • pnpm test
  • pnpm typecheck
  • pnpm lint:deps

Related

  • TML-2276

@coderabbitai

coderabbitai Bot commented Apr 19, 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

The PR refactors the contract source provider API from a directly-callable async function to a structured object with load and optional inputs properties. This enables declaring authoritative input files for build/tooling integrations and provides configuration directory context during contract loading. The change cascades across configuration types, validation logic, CLI/Vite tooling, and test fixtures.

Changes

Cohort / File(s) Summary
Core Contract Source Types
packages/1-framework/1-core/config/src/contract-source-types.ts, packages/1-framework/1-core/config/src/exports/config-types.ts
Updated ContractSourceProvider from callable function type to interface with optional inputs?: readonly string[] and required load(context, environment) method. Added new exported ContractSourceEnvironment interface.
Config Type System & Validation
packages/1-framework/1-core/config/src/config-types.ts, packages/1-framework/1-core/config/src/config-validation.ts, packages/1-framework/1-core/config/README.md
Updated ContractConfigSchema to validate against structured schema instead of 'unknown'. Extended validateConfig with new validateContractConfig helper that validates provider object shape, optional inputs array, required load function, and cross-field validation preventing artifact paths in inputs.
Config Type Tests
packages/1-framework/1-core/config/test/config-types.test-d.ts, packages/1-framework/1-core/config/test/config-validation.test.ts
Added type-level tests for provider object structure and input metadata. Updated validation tests to use createSourceProvider() helper and verify nested field errors (contract.source.inputs[], contract.source.load).
CLI Config Loading & Tooling
packages/1-framework/3-tooling/cli/src/config-loader.ts, packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
Refactored loadConfig to delegate validation to new internal loadValidatedConfig() helper. Updated contract emit request to use contractConfig.source (instead of sourceProvider) and added contractConfig.configDir.
CLI Control API
packages/1-framework/3-tooling/cli/src/control-api/types.ts, packages/1-framework/3-tooling/cli/src/control-api/client.ts, packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts, packages/1-framework/3-tooling/cli/src/exports/config-types.ts
Renamed EmitContractConfig.sourceProvider to source and added configDir field. Updated contract source invocations to call source.load(context, { configDir }) instead of source(context). Re-exported ContractSourceEnvironment type.
SQL Contract Providers
packages/2-sql/2-authoring/contract-psl/src/provider.ts, packages/2-sql/2-authoring/contract-ts/src/config-types.ts, packages/2-sql/2-authoring/contract-ts/package.json
Updated prismaContract to use provider object with inputs: [schemaPath] and load method. Added new factory typescriptContractFromPath(contractPath, output?) with dynamic imports and path resolution via environment.configDir. Added pathe dependency.
Mongo Contract Providers
packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts, packages/2-mongo-family/2-authoring/contract-ts/src/config-types.ts, packages/2-mongo-family/2-authoring/contract-ts/package.json
Updated mongoContract to use provider object with inputs and load. Added typescriptContractFromPath factory with pathe dependency.
Extension Implementations
packages/3-extensions/postgres/src/config/define-config.ts, packages/3-extensions/mongo/src/config/define-config.ts
Simplified .ts contract handling by delegating to new typescriptContractFromPath() helper instead of inline dynamic import logic. Removed pathToFileURL and related imports.
CLI Testing Infrastructure
packages/1-framework/3-tooling/cli/test/.../*, packages/1-framework/3-tooling/cli/README.md, packages/1-framework/3-tooling/cli/recordings/fixtures/prisma-next.config.ts
Updated test helpers (createSourceProvider, createSource) to return provider objects. Updated config fixture and tests to use source: { load: async () => ... } shape. Updated README to document .load(context, environment) invocation.
Vite Plugin Watch Resolution
packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts, packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md, packages/1-framework/3-tooling/vite-plugin-contract-emit/package.json
Major refactor: new resolveWatchedFiles() builds watch set from config file + contract.source.inputs + module graph roots, filtering out output artifacts. New handleTrackedFileChange() manages debounced emits. Watcher events now registered on configureServer. Added pathe dependency. Updated README to document authoritative inputs behavior.
Vite Plugin Testing
packages/1-framework/3-tooling/vite-plugin-contract-emit/test/plugin.test.ts
Mocked @prisma-next/cli/config-loader.loadConfig alongside executeContractEmit. Expanded test coverage for watch file scenarios: omitted inputs, merged inputs with module graph, artifact filtering. Added watcher event handler setup via beforeEach.
SQL Module Test Fixtures
packages/2-sql/2-authoring/contract-psl/test/fixtures.ts, packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
Added createPostgresTestEnvironment() helper returning ContractSourceEnvironment with configDir: process.cwd(). Added provider test validating inputs and load behavior with relative path resolution.
Integration Tests - Config & Emission
test/integration/test/cli.emit-contract.test.ts, test/integration/test/cli.emit-command.test.ts, test/integration/test/authoring/cli.emit-parity-fixtures.test.ts, test/integration/test/authoring/psl.pgvector-dbinit.test.ts
Updated all contract source invocations to call source.load(context, environment) instead of source(context). Added sourceEnvironmentFromCwd() / buildSourceEnvironment() helpers. Updated config resolution to pass configDir based on loaded config path.
Integration Tests - Provider Behavior
test/integration/test/authoring/side-by-side-contracts.test.ts, test/integration/test/sql-builder/fixtures/prisma-next.config.ts
Updated provider calls to use new load signature with environment. Updated test config fixtures to provider object shape.
Integration Tests - PSL Vite Plugin
test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/vite-plugin-psl/*, test/integration/test/vite-plugin.hmr.e2e.test.ts
Added new PSL fixture variant with contract.prisma, contract-alt.prisma, prisma-next.config.ts, and vite.config.ts. Added e2e HMR tests validating schema changes and authoritative input switching with watch file updates.
Config Fixtures (Multiple Directories)
test/integration/test/fixtures/.../prisma-next.config.*.ts, packages/1-framework/3-tooling/cli/recordings/fixtures/prisma-next.config.ts, packages/3-extensions/sql-orm-client/test/fixtures/prisma-next.config.ts
Updated all config fixtures across CLI and extension test suites from source: async () => ... to source: { load: async () => ... } shape (30+ files).
ADR & Documentation
docs/architecture docs/adrs/ADR 163 - Provider-invoked source interpretation packages.md
Updated ADR description to call config.contract.source.load() instead of config.contract.source().
Contract Test Fixtures
test/integration/test/authoring/parity/callback-mode-scalars/contract.ts, test/integration/test/fixtures/prisma-next.config.ts, test/integration/test/mongo/fixtures/prisma-next.config.ts
Updated contract field definitions to use explicit Postgres column-type bindings. Updated config to provider object shape.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI/Vite Plugin
    participant ConfigLoader as Config Loader
    participant Validator as Validator
    participant Provider as Contract Source Provider
    participant FS as File System

    CLI->>ConfigLoader: loadConfig(configPath)
    ConfigLoader->>ConfigLoader: resolve config path + load via c12
    ConfigLoader->>Validator: validateConfig(config)
    Validator->>Validator: validate contract.source.load (function)
    Validator->>Validator: validate contract.source.inputs (array)
    Validator->>Validator: validate no inputs match output artifacts
    Validator-->>ConfigLoader: validated config
    ConfigLoader-->>CLI: PrismaNextConfig

    CLI->>CLI: resolveWatchedFiles()
    CLI->>CLI: collect config path + contract.source.inputs
    CLI->>CLI: build module graph from config + input paths
    CLI->>CLI: filter out contract output artifacts
    CLI-->>CLI: watched file set

    CLI->>Provider: source.load(context, { configDir })
    FS->>Provider: resolve contractPath relative to configDir
    Provider->>FS: read/parse schema or import module
    Provider-->>CLI: Result<Contract, Diagnostics>

    CLI->>CLI: emit contract + update watched files
    FS-->>CLI: file system watches for changes
    CLI->>CLI: handleTrackedFileChange(file)
    alt file in ignoredOutputFiles
        CLI-->>CLI: ignore (self-triggered)
    else file in watchedFiles
        CLI->>Provider: source.load(...) again
        Provider-->>CLI: Result<Contract>
        CLI->>CLI: emit contract
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • TML-1817: Vite plugin #109: Introduced the original prismaVitePlugin implementation; this PR's Vite plugin refactor for watch file resolution and the new loadConfig integration directly extend that work.

Suggested reviewers

  • wmadden
  • igalklebanov
  • saevarb

Poem

🐰 Hops with glee,
Structured sources now decree,
Inputs watched with care,
configDir is shared,
Load methods guide the spree! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Keep @prisma-next/config path-agnostic for contract sources' directly summarizes the main change: the PR refactors contract sources to separate path/environment concerns (configDir moves to ContractSourceEnvironment), enabling @prisma-next/config to remain path-agnostic while tooling (Vite plugin) handles watch-path logic.

✏️ 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-2276-authoritative-watch-inputs

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

pkg-pr-new Bot commented Apr 19, 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@356

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/middleware-telemetry

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/runtime-executor

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/runtime-executor@356

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: b41ccba

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

🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/test/config-loader.test.ts (1)

68-167: Good coverage of the new metadata paths.

The four new cases exercise the authoritative-inputs, moduleGraph, default-artifact filtering, and fallback-warning branches. Use of toEqual on the full contractWatch object is aligned with the "prefer object matchers" guideline.

One small suggestion: the last case uses result.metadata.contractWatch?.inputs with optional chaining; since contract is present in the config, contractWatch is guaranteed non-null — prefer a non-null assertion or assert on the full object via toEqual/toMatchObject to keep style consistent with the other three cases.

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

In `@packages/1-framework/3-tooling/cli/test/config-loader.test.ts` around lines
68 - 167, The test uses optional chaining when asserting contract watch metadata
(result.metadata.contractWatch?.inputs) but contract is always present here;
replace the optional assertion with a non-null assertion or assert the entire
object like the other tests (e.g.,
expect(result.metadata.contractWatch).toEqual(...) or toMatchObject(...)) so the
style is consistent with the other cases and avoids the unnecessary optional
chaining (refer to result.metadata.contractWatch and the surrounding it block).
packages/1-framework/3-tooling/cli/src/config-loader.ts (1)

47-50: Unnecessary optional chaining on outputJsonPath.

resolve(...) always returns a non-nullable string, so outputJsonPath?.endsWith('.json') can be simplified to outputJsonPath.endsWith('.json').

Proposed nit
-  const outputDtsPath = outputJsonPath?.endsWith('.json')
+  const outputDtsPath = outputJsonPath.endsWith('.json')
     ? `${outputJsonPath.slice(0, -5)}.d.ts`
     : undefined;

Also worth noting: when contract.output uses a non-.json extension, the colocated .d.ts artifact won't be filtered out of watchInputs. That's probably fine given the canonical output is .json, but worth a comment if that's intentional.

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

In `@packages/1-framework/3-tooling/cli/src/config-loader.ts` around lines 47 -
50, The optional chaining on outputJsonPath is unnecessary because resolve(...)
always returns a string; update the conditional that sets outputDtsPath to use
outputJsonPath.endsWith('.json') instead of outputJsonPath?.endsWith('.json')
and remove the redundant null-safety. Locate the code that computes
outputJsonPath (uses resolve(configDir, contract.output ??
DEFAULT_CONTRACT_OUTPUT)) and outputDtsPath and make the change; optionally add
a brief comment near outputDtsPath noting that non-".json" contract.output
values will not produce a colocated ".d.ts" (so watchInputs may include it) if
you want to document that behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/1-framework/3-tooling/cli/src/config-loader.ts`:
- Around line 47-50: The optional chaining on outputJsonPath is unnecessary
because resolve(...) always returns a string; update the conditional that sets
outputDtsPath to use outputJsonPath.endsWith('.json') instead of
outputJsonPath?.endsWith('.json') and remove the redundant null-safety. Locate
the code that computes outputJsonPath (uses resolve(configDir, contract.output
?? DEFAULT_CONTRACT_OUTPUT)) and outputDtsPath and make the change; optionally
add a brief comment near outputDtsPath noting that non-".json" contract.output
values will not produce a colocated ".d.ts" (so watchInputs may include it) if
you want to document that behavior.

In `@packages/1-framework/3-tooling/cli/test/config-loader.test.ts`:
- Around line 68-167: The test uses optional chaining when asserting contract
watch metadata (result.metadata.contractWatch?.inputs) but contract is always
present here; replace the optional assertion with a non-null assertion or assert
the entire object like the other tests (e.g.,
expect(result.metadata.contractWatch).toEqual(...) or toMatchObject(...)) so the
style is consistent with the other cases and avoids the unnecessary optional
chaining (refer to result.metadata.contractWatch and the surrounding it block).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 75bf42d9-cb80-4ee9-b957-e1dbac73ee33

📥 Commits

Reviewing files that changed from the base of the PR and between 21a24dd and ba2cc16.

📒 Files selected for processing (20)
  • packages/1-framework/1-core/config/README.md
  • packages/1-framework/1-core/config/src/config-types.ts
  • packages/1-framework/1-core/config/src/config-validation.ts
  • packages/1-framework/1-core/config/test/config-types.test-d.ts
  • packages/1-framework/1-core/config/test/config-validation.test.ts
  • packages/1-framework/3-tooling/cli/src/config-loader.ts
  • packages/1-framework/3-tooling/cli/test/config-loader.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts
  • packages/2-mongo-family/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-mongo-family/2-authoring/contract-ts/src/config-types.ts
  • packages/2-mongo-family/2-authoring/contract-ts/test/config-types.test.ts
  • packages/2-sql/2-authoring/contract-psl/src/provider.ts
  • packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/config-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/3-extensions/mongo/src/config/define-config.ts
  • packages/3-extensions/mongo/test/config/define-config.test.ts
  • packages/3-extensions/postgres/src/config/define-config.ts
  • packages/3-extensions/postgres/test/config/define-config.test.ts

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

I like the direction to make a ContractSourceProvider explicitly return its sources. I don't think the framework should be aware of dev watcher integrations though. Also watchStrategy appears to have no consumer and it's unclear from its doc comment what its future purpose will be. In any case, this doesn't belong in Prisma Next config, it belongs in the watcher integration's config

So I recommend:

  • rename the watcher-coupled properties of the contractProvider to be consumer agnostic, eg watcherInputs could as easily be sources or sourceFiles etc
  • move watcher-specific config (watcherStrategy) to the watcher integration (ie the vite or NextJS integratio)

@jkomyno

jkomyno commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor Author

I agree with this review.

The current change solves the Vite invalidation problem, but it does it at the wrong boundary: it teaches ContractConfig about dev watcher behavior, and then adds a parallel loadConfigWithMetadata() API to recover that information later.

I think the cleaner model is:

  • keep contract focused on emission concerns (source, output)
  • move authoritative source declaration to the source-provider side
  • make that declaration tool-agnostic, not watcher-specific

So instead of contract.watchInputs / contract.watchStrategy, I’d rather have providers declare something like:

  • moduleGraph
  • paths
  • configPathOnly

That also addresses the “why is this optional?” point. Every provider should declare its authoritative source model explicitly. For built-ins, that means:

  • PSL providers declare paths
  • direct TS helpers declare moduleGraph
  • extension facades that dynamically import contract.ts declare paths, because the config module graph is not authoritative in that flow

Then the Vite plugin can resolve that provider metadata into watched files, filter out emitted artifacts, and handle the partial-coverage warning there. That keeps the fallback behavior we want for custom providers, but avoids encoding it as implicit back-compat logic in the generic config loader.

I'll get rid of the retro-compatibility that snuck in.

Separately, if any validation remains for this shape, it should live in the Arktype schema rather than in ad hoc manual checks.

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

Caution

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

⚠️ Outside diff range comments (2)
test/integration/test/cli.emit-command.test.ts (1)

568-570: ⚠️ Potential issue | 🟡 Minor

Stale type annotation for sourceResult.

typeof providerConfig.contract['source'] is now an object (with authoritativeInputs + load), not a callable, so ReturnType<...> on it is invalid. The annotation happens to still resolve (likely to never/broken inference) but no longer describes the load result. Use ReturnType<NonNullable<typeof providerConfig.contract>['source']['load']> instead.

Proposed fix
-        let sourceResult: Awaited<
-          ReturnType<NonNullable<typeof providerConfig.contract>['source']>
-        >;
+        let sourceResult: Awaited<
+          ReturnType<NonNullable<typeof providerConfig.contract>['source']['load']>
+        >;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/test/cli.emit-command.test.ts` around lines 568 - 570, The
type annotation for sourceResult is stale because
providerConfig.contract['source'] is now an object with a load method; update
the declaration to use the load method's return type by replacing
ReturnType<NonNullable<typeof providerConfig.contract>['source']> with
ReturnType<NonNullable<typeof providerConfig.contract>['source']['load']> (keep
the NonNullable wrapper) so sourceResult correctly reflects the load result from
providerConfig.contract.source.load.
test/integration/test/authoring/cli.emit-parity-fixtures.test.ts (1)

95-98: ⚠️ Potential issue | 🟡 Minor

Update ReturnType<typeof …source> annotations to target .source.load.

Same issue as in cli.emit-command.test.ts: contract.source is now an object, not a function, so ReturnType<typeof tsConfig.contract.source> (and the matching psl/diagnostics ones) no longer reflects the load() result type. Point these at .source.load instead.

Proposed fix
-          let tsProviderResultFirst: Awaited<ReturnType<typeof tsConfig.contract.source>>;
-          let tsProviderResultSecond: Awaited<ReturnType<typeof tsConfig.contract.source>>;
-          let pslProviderResultFirst: Awaited<ReturnType<typeof pslConfig.contract.source>>;
-          let pslProviderResultSecond: Awaited<ReturnType<typeof pslConfig.contract.source>>;
+          let tsProviderResultFirst: Awaited<ReturnType<typeof tsConfig.contract.source.load>>;
+          let tsProviderResultSecond: Awaited<ReturnType<typeof tsConfig.contract.source.load>>;
+          let pslProviderResultFirst: Awaited<ReturnType<typeof pslConfig.contract.source.load>>;
+          let pslProviderResultSecond: Awaited<ReturnType<typeof pslConfig.contract.source.load>>;
...
-          let sourceResult: Awaited<ReturnType<typeof pslConfig.contract.source>>;
+          let sourceResult: Awaited<ReturnType<typeof pslConfig.contract.source.load>>;

Also applies to: 241-241

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

In `@test/integration/test/authoring/cli.emit-parity-fixtures.test.ts` around
lines 95 - 98, The type aliases for provider result variables use
ReturnType<typeof ...contract.source> but contract.source is now an object;
change the annotations to target the load method return type instead (e.g., use
Awaited<ReturnType<typeof tsConfig.contract.source.load>> for
tsProviderResultFirst/Second and similarly use Awaited<ReturnType<typeof
pslConfig.contract.source.load>> for pslProviderResultFirst/Second and update
any diagnostics-related ReturnType references to point at .source.load as well)
so the types reflect the result of calling source.load().
🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts (1)

81-86: Redundant manual validation — already enforced by ContractSourceProviderSchema.

loadConfig() runs ContractConfigSchema via validateContractConfig, which requires contract.source to be an object with authoritativeInputs and load: Function. By the time this code runs, contractConfig.source.load is guaranteed to be a function. Per the PR direction to move provider-shape validation into the Arktype schema, and per guideline to prefer assertions over defensive checks once validated, this block can be dropped.

♻️ Proposed cleanup
-  // Validate source exists and is callable
-  if (typeof contractConfig.source?.load !== 'function') {
-    throw errorContractConfigMissing({
-      why: 'Contract config must include a valid source provider object',
-    });
-  }
-

As per coding guidelines: "Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties."

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

In
`@packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts`
around lines 81 - 86, Remove the redundant runtime check for
contractConfig.source.load in loadConfig(): since validateContractConfig runs
ContractConfigSchema/ContractSourceProviderSchema and guarantees
contractConfig.source.load is a Function, delete the if (typeof
contractConfig.source?.load !== 'function') { throw ... } block; rely on
validateContractConfig/ContractConfigSchema for enforcement and keep the rest of
loadConfig() logic intact (referencing symbols: loadConfig,
validateContractConfig, ContractConfigSchema, ContractSourceProviderSchema,
contractConfig).
packages/1-framework/3-tooling/vite-plugin-contract-emit/test/plugin.test.ts (1)

152-179: Assert the watcher registration in the moduleGraph case.

This test says it registers watchers, but it only verifies ssrLoadModule(). A regression that loads the module graph but never calls watcher.add() would still pass.

🧪 Proposed test assertion
       await configureServer(mockServer);
 
       expect(mockServer.ssrLoadModule).toHaveBeenCalled();
+      expect(mockServer.watcher.add).toHaveBeenCalledWith('/project/prisma-next.config.ts');
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/vite-plugin-contract-emit/test/plugin.test.ts`
around lines 152 - 179, The test currently only asserts ssrLoadModule was called
but must also assert the plugin registered file watchers from the module graph;
after calling configureServer(mockServer) add an assertion that
mockServer.watcher.add was invoked for the module file returned by
mockServer.moduleGraph.getModuleById (e.g. '/project/prisma-next.config.ts') —
use prismaVitePlugin, configureServer, and the mocked moduleGraph.getModuleById
to locate where watcher.add should be called and assert it was called (and
optionally called once).
🤖 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/1-framework/3-tooling/cli/test/config-types.test.ts`:
- Around line 9-12: The default parameter of createSourceProvider is too
narrowly inferred; update its signature to type the authoritativeInputs
parameter as ContractAuthoritativeInputs (imported from
`@prisma-next/config/config-types`) so it accepts all three kinds (e.g.,
'moduleGraph' and 'paths'); change the parameter annotation on
createSourceProvider to use ContractAuthoritativeInputs and add the
corresponding import statement so callers like the one at the failing call
accept the wider union type.

In `@packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts`:
- Around line 1-2: The file imports dirname and resolve from 'node:path' —
replace that import to use 'pathe' instead to ensure
cross-platform/cross-runtime compatibility; update the import that currently
reads the symbols dirname and resolve so they are imported from 'pathe' and
leave all usages of dirname and resolve in this module (plugin.ts) unchanged.

In `@packages/2-sql/2-authoring/contract-psl/src/provider.ts`:
- Around line 35-58: The loader's load function resolves the schemaPath with
resolve(schemaPath) (in load) which is cwd-relative and can differ from the
watcher that resolved authoritativeInputs.paths against the config directory;
change the resolution in load to use the same base (e.g.,
resolve(context.configDir, schemaPath) or equivalent from ContractSourceContext)
before calling readFile so the watcher and loader target the same file, and
propagate the adjusted absolute path into the notOk payload fields
(sourceId/meta.absoluteSchemaPath) so diagnostics and metadata remain
consistent; update references around load, resolve(schemaPath), readFile, and
the notOk return accordingly.

---

Outside diff comments:
In `@test/integration/test/authoring/cli.emit-parity-fixtures.test.ts`:
- Around line 95-98: The type aliases for provider result variables use
ReturnType<typeof ...contract.source> but contract.source is now an object;
change the annotations to target the load method return type instead (e.g., use
Awaited<ReturnType<typeof tsConfig.contract.source.load>> for
tsProviderResultFirst/Second and similarly use Awaited<ReturnType<typeof
pslConfig.contract.source.load>> for pslProviderResultFirst/Second and update
any diagnostics-related ReturnType references to point at .source.load as well)
so the types reflect the result of calling source.load().

In `@test/integration/test/cli.emit-command.test.ts`:
- Around line 568-570: The type annotation for sourceResult is stale because
providerConfig.contract['source'] is now an object with a load method; update
the declaration to use the load method's return type by replacing
ReturnType<NonNullable<typeof providerConfig.contract>['source']> with
ReturnType<NonNullable<typeof providerConfig.contract>['source']['load']> (keep
the NonNullable wrapper) so sourceResult correctly reflects the load result from
providerConfig.contract.source.load.

---

Nitpick comments:
In
`@packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts`:
- Around line 81-86: Remove the redundant runtime check for
contractConfig.source.load in loadConfig(): since validateContractConfig runs
ContractConfigSchema/ContractSourceProviderSchema and guarantees
contractConfig.source.load is a Function, delete the if (typeof
contractConfig.source?.load !== 'function') { throw ... } block; rely on
validateContractConfig/ContractConfigSchema for enforcement and keep the rest of
loadConfig() logic intact (referencing symbols: loadConfig,
validateContractConfig, ContractConfigSchema, ContractSourceProviderSchema,
contractConfig).

In
`@packages/1-framework/3-tooling/vite-plugin-contract-emit/test/plugin.test.ts`:
- Around line 152-179: The test currently only asserts ssrLoadModule was called
but must also assert the plugin registered file watchers from the module graph;
after calling configureServer(mockServer) add an assertion that
mockServer.watcher.add was invoked for the module file returned by
mockServer.moduleGraph.getModuleById (e.g. '/project/prisma-next.config.ts') —
use prismaVitePlugin, configureServer, and the mocked moduleGraph.getModuleById
to locate where watcher.add should be called and assert it was called (and
optionally called once).
🪄 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: bcabb0ac-ebd7-4a51-ba2a-0bf1b27bfc21

📥 Commits

Reviewing files that changed from the base of the PR and between ba2cc16 and 9adefba.

📒 Files selected for processing (57)
  • docs/architecture docs/adrs/ADR 163 - Provider-invoked source interpretation packages.md
  • packages/1-framework/1-core/config/README.md
  • packages/1-framework/1-core/config/src/config-types.ts
  • packages/1-framework/1-core/config/src/config-validation.ts
  • packages/1-framework/1-core/config/src/contract-source-types.ts
  • packages/1-framework/1-core/config/src/exports/config-types.ts
  • packages/1-framework/1-core/config/test/config-types.test-d.ts
  • packages/1-framework/1-core/config/test/config-validation.test.ts
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/3-tooling/cli/recordings/fixtures/prisma-next.config.ts
  • packages/1-framework/3-tooling/cli/src/config-loader.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/1-framework/3-tooling/cli/test/config-loader.test.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/test/control-api/contract-emit.test.ts
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/test/plugin.test.ts
  • packages/2-mongo-family/2-authoring/contract-psl/src/provider.ts
  • packages/2-mongo-family/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-mongo-family/2-authoring/contract-ts/src/config-types.ts
  • packages/2-mongo-family/2-authoring/contract-ts/test/config-types.test.ts
  • packages/2-sql/2-authoring/contract-psl/src/provider.ts
  • packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-sql/2-authoring/contract-ts/src/config-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/3-extensions/mongo/src/config/define-config.ts
  • packages/3-extensions/mongo/test/config/define-config.test.ts
  • packages/3-extensions/postgres/src/config/define-config.ts
  • packages/3-extensions/postgres/test/config/define-config.test.ts
  • packages/3-extensions/sql-orm-client/test/fixtures/prisma-next.config.ts
  • test/integration/test/authoring/cli.emit-parity-fixtures.test.ts
  • test/integration/test/authoring/psl.pgvector-dbinit.test.ts
  • test/integration/test/authoring/side-by-side-contracts.test.ts
  • test/integration/test/cli.emit-command.test.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/cli-journeys/prisma-next.config.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/cli-journeys/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-init/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-driver.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-sign/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-update-scenarios/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-driver.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.emit.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/migration-apply/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/migration-plan/prisma-next.config.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/mongo-db-commands/prisma-next.config.with-db.ts
  • test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/vite-plugin/prisma-next.config.ts
  • test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.async-source.ts
  • test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.mongo-contract-ts.ts
  • test/integration/test/fixtures/prisma-next.config.ts
  • test/integration/test/mongo/fixtures/prisma-next.config.ts
  • test/integration/test/sql-builder/fixtures/prisma-next.config.ts
✅ Files skipped from review due to trivial changes (8)
  • docs/architecture docs/adrs/ADR 163 - Provider-invoked source interpretation packages.md
  • packages/1-framework/3-tooling/cli/README.md
  • packages/1-framework/1-core/config/src/exports/config-types.ts
  • packages/3-extensions/postgres/test/config/define-config.test.ts
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/README.md
  • packages/1-framework/3-tooling/cli/src/config-loader.ts
  • packages/3-extensions/mongo/test/config/define-config.test.ts
  • packages/1-framework/3-tooling/cli/test/config-loader.test.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-mongo-family/2-authoring/contract-ts/test/config-types.test.ts
  • packages/3-extensions/mongo/src/config/define-config.ts
  • packages/1-framework/1-core/config/src/config-validation.ts
  • packages/2-mongo-family/2-authoring/contract-psl/test/provider.test.ts
  • packages/1-framework/1-core/config/test/config-types.test-d.ts
  • packages/1-framework/1-core/config/test/config-validation.test.ts
  • packages/2-mongo-family/2-authoring/contract-ts/src/config-types.ts
  • packages/1-framework/1-core/config/README.md
  • packages/2-sql/2-authoring/contract-ts/src/config-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/3-extensions/postgres/src/config/define-config.ts
  • packages/2-mongo-family/2-authoring/contract-psl/src/provider.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

Caution

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

⚠️ Outside diff range comments (1)
packages/1-framework/3-tooling/cli/test/control-api/client.test.ts (1)

467-499: ⚠️ Potential issue | 🟡 Minor

Duplicate of earlier test.

This test is effectively identical to the 'emits resolveSource and emit spans' case at lines 421-465 — both use createSourceProvider() with default load (returning ok(...)) and assert the same resolveSource span outcome. Since the provider-object shape is already the only supported shape (callable sources were removed), the "when source is a provider object" wording is redundant. Consider removing this test or, if the intent was to exercise a distinct scenario (e.g., different authoritativeInputs kind), adjust it to cover something not already covered by the first case.

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

In `@packages/1-framework/3-tooling/cli/test/control-api/client.test.ts` around
lines 467 - 499, The test "emits resolveSource and emit spans when source is a
provider object" duplicates the earlier "emits resolveSource and emit spans"
case; remove this redundant test block (the it(...) that uses
createSourceProvider() and asserts resolveSource spans) to avoid duplicate
coverage, or if you prefer retaining a distinct case replace it with a test that
exercises a different provider behavior (e.g., pass a createSourceProvider()
that returns authoritativeInputs or a failing load) and assert the corresponding
span outcome; locate the duplicate by the test name and the use of
createSourceProvider(), client.emit(), and the resolveSource span assertions.
🧹 Nitpick comments (3)
packages/1-framework/1-core/config/src/config-types.ts (1)

89-114: Doc comment placement is now misleading.

The JSDoc block at lines 89-92 describes ContractConfigSchema, but two additional schemas (ContractAuthoritativeInputsSchema, ContractSourceProviderSchema) now sit between the comment and ContractConfigSchema. Either move the comment down to ContractConfigSchema (line 111) or add a short JSDoc per schema so the mapping is unambiguous.

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

In `@packages/1-framework/1-core/config/src/config-types.ts` around lines 89 -
114, The JSDoc currently placed above ContractAuthoritativeInputsSchema is meant
for ContractConfigSchema; either move that comment so it immediately precedes
ContractConfigSchema or add short JSDoc comments above each schema to clarify
intent — specifically update the block so ContractAuthoritativeInputsSchema,
ContractSourceProviderSchema and ContractConfigSchema each have unambiguous
documentation (or relocate the existing JSDoc directly above the
ContractConfigSchema declaration) to resolve the misleading placement.
packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts (1)

152-165: Redundant inner Set in filterOutputArtifacts.

new Set([...new Set(values)].filter(...)) wraps values in a Set, spreads to an array for filtering, then re-wraps. The outer Set already dedupes, so the inner one is pointless.

-    return new Set(
-      [...new Set(values)].filter((value) => value !== outputJsonPath && value !== outputDtsPath),
-    );
+    return new Set(
+      values.filter((value) => value !== outputJsonPath && value !== outputDtsPath),
+    );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts`
around lines 152 - 165, filterOutputArtifacts currently wraps values in an
unnecessary inner Set before filtering; replace the inner dedupe with a direct
array filter and then dedupe once when constructing the returned Set.
Specifically, inside filterOutputArtifacts (which uses values, contractOutput,
DEFAULT_CONTRACT_OUTPUT, absoluteConfigPath, outputJsonPath, outputDtsPath)
remove new Set([...new Set(values)].filter(...)) and instead filter values
directly (values.filter(...)) and then wrap that filtered array in a single new
Set to deduplicate the results.
packages/1-framework/1-core/config/test/config-types.test-d.ts (1)

102-123: Type assertions largely restate the interface.

Because result.contract!.source is already typed as ContractSourceProvider, expectTypeOf(...source.load).toEqualTypeOf<ContractSourceProvider['load']>() and the kind union assertion are close to tautological: they check each field's declared type against itself rather than behavior of defineConfig. Consider instead asserting that the literal narrowing is preserved (e.g., constructing config with as const and asserting result.contract!.source.authoritativeInputs narrows to { kind: 'paths'; paths: ... }), or else asserting the input-shape is assignable to ContractSourceProvider via toExtend — those catch regressions the current assertions cannot.

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

In `@packages/1-framework/1-core/config/test/config-types.test-d.ts` around lines
102 - 123, The test's current type assertions merely restate the declared
ContractSourceProvider shape and don't verify that defineConfig preserves
literal narrowing; update the test to assert narrowing or assignability instead:
construct the config.authoritativeInputs with an explicit const assertion (e.g.,
use `as const` on the authoritativeInputs object) or build the entire config as
const, then assert that result.contract!.source.authoritativeInputs has the
narrowed literal type (exact `{ kind: 'paths'; paths: string[] }`) or use
expectTypeOf(result.contract!.source).toExtend<ContractSourceProvider>() to
confirm assignability; modify the assertions around defineConfig and result to
use these stricter checks so regressions in defineConfig's type inference are
caught.
🤖 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/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts`:
- Around line 217-265: resolveWatchedFiles currently omits the config file when
authoritativeInputs.kind === 'paths' and also swallows the fact that loadConfig
failed in the catch; update the 'paths' branch so the returned files Set
includes both the resolved authoritativeInputs.paths (via filterOutputArtifacts)
AND absoluteConfigPath (so edits to the config trigger a re-emit), and change
the catch block to return the PARTIAL_COVERAGE_WARNING (or otherwise a non-null
warning) instead of null while still calling logError; refer to
resolveWatchedFiles, authoritativeInputs.kind === 'paths', absoluteConfigPath,
filterOutputArtifacts, loadConfig, logError, and PARTIAL_COVERAGE_WARNING to
locate where to apply these fixes.

---

Outside diff comments:
In `@packages/1-framework/3-tooling/cli/test/control-api/client.test.ts`:
- Around line 467-499: The test "emits resolveSource and emit spans when source
is a provider object" duplicates the earlier "emits resolveSource and emit
spans" case; remove this redundant test block (the it(...) that uses
createSourceProvider() and asserts resolveSource spans) to avoid duplicate
coverage, or if you prefer retaining a distinct case replace it with a test that
exercises a different provider behavior (e.g., pass a createSourceProvider()
that returns authoritativeInputs or a failing load) and assert the corresponding
span outcome; locate the duplicate by the test name and the use of
createSourceProvider(), client.emit(), and the resolveSource span assertions.

---

Nitpick comments:
In `@packages/1-framework/1-core/config/src/config-types.ts`:
- Around line 89-114: The JSDoc currently placed above
ContractAuthoritativeInputsSchema is meant for ContractConfigSchema; either move
that comment so it immediately precedes ContractConfigSchema or add short JSDoc
comments above each schema to clarify intent — specifically update the block so
ContractAuthoritativeInputsSchema, ContractSourceProviderSchema and
ContractConfigSchema each have unambiguous documentation (or relocate the
existing JSDoc directly above the ContractConfigSchema declaration) to resolve
the misleading placement.

In `@packages/1-framework/1-core/config/test/config-types.test-d.ts`:
- Around line 102-123: The test's current type assertions merely restate the
declared ContractSourceProvider shape and don't verify that defineConfig
preserves literal narrowing; update the test to assert narrowing or
assignability instead: construct the config.authoritativeInputs with an explicit
const assertion (e.g., use `as const` on the authoritativeInputs object) or
build the entire config as const, then assert that
result.contract!.source.authoritativeInputs has the narrowed literal type (exact
`{ kind: 'paths'; paths: string[] }`) or use
expectTypeOf(result.contract!.source).toExtend<ContractSourceProvider>() to
confirm assignability; modify the assertions around defineConfig and result to
use these stricter checks so regressions in defineConfig's type inference are
caught.

In `@packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts`:
- Around line 152-165: filterOutputArtifacts currently wraps values in an
unnecessary inner Set before filtering; replace the inner dedupe with a direct
array filter and then dedupe once when constructing the returned Set.
Specifically, inside filterOutputArtifacts (which uses values, contractOutput,
DEFAULT_CONTRACT_OUTPUT, absoluteConfigPath, outputJsonPath, outputDtsPath)
remove new Set([...new Set(values)].filter(...)) and instead filter values
directly (values.filter(...)) and then wrap that filtered array in a single new
Set to deduplicate the results.
🪄 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: eccac6d8-050c-4bc2-8ab7-d7837ce7b8ea

📥 Commits

Reviewing files that changed from the base of the PR and between 9adefba and aa556f7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (22)
  • packages/1-framework/1-core/config/src/config-types.ts
  • packages/1-framework/1-core/config/src/contract-source-types.ts
  • packages/1-framework/1-core/config/test/config-types.test-d.ts
  • packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/control-api/client.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
  • packages/1-framework/3-tooling/cli/src/control-api/types.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • packages/1-framework/3-tooling/cli/test/control-api/client.test.ts
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/package.json
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/src/plugin.ts
  • packages/2-mongo-family/2-authoring/contract-ts/test/config-types.test.ts
  • packages/2-sql/2-authoring/contract-psl/src/provider.ts
  • packages/2-sql/2-authoring/contract-psl/test/fixtures.ts
  • packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/3-extensions/postgres/test/config/define-config.test.ts
  • test/integration/test/authoring/cli.emit-parity-fixtures.test.ts
  • test/integration/test/authoring/psl.pgvector-dbinit.test.ts
  • test/integration/test/authoring/side-by-side-contracts.test.ts
  • test/integration/test/cli.emit-command.test.ts
  • test/integration/test/cli.emit-contract.test.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/1-framework/3-tooling/vite-plugin-contract-emit/package.json
  • packages/2-sql/2-authoring/contract-psl/test/provider.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • test/integration/test/authoring/side-by-side-contracts.test.ts
  • test/integration/test/authoring/psl.pgvector-dbinit.test.ts
  • test/integration/test/authoring/cli.emit-parity-fixtures.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/2-sql/2-authoring/contract-psl/src/provider.ts
  • packages/1-framework/3-tooling/cli/test/config-types.test.ts
  • test/integration/test/cli.emit-command.test.ts

jkomyno added 3 commits April 20, 2026 13:03
The SQL provider was updated to use context.configDir but the mongo
provider was missed, causing watcher/loader path divergence when cwd
differs from the config directory.
…onfigDir

- Switch config-loader from node:path to pathe for consistency with
  the rest of the tooling layer.
- Resolve .ts contract paths inside load() via context.configDir instead
  of capturing process.cwd() at config-definition time, so the watcher
  and loader always reference the same file.
The paths branch omitted the config file from the watch set, so edits
to prisma-next.config.ts (e.g. changing paths or swapping provider)
would not trigger re-emit. Also surface a partial-coverage warning when
loadConfig fails instead of silently falling back.
jkomyno added 3 commits April 21, 2026 15:32
The PSL and TS-from-path providers used `= schemaPath` / `= contractPath`
defaults when destructuring context.resolvedInputs. That silently fell
back to the user's relative path when a test harness handed in an empty
context, masking the invariant that the CLI loader guarantees
resolvedInputs is positional-matched with source.inputs.

Drop the fallback in all four providers and throw a clear error naming
the provider and the loader contract. Unreachable in production;
surfaces test-harness bugs immediately.
Pulls in 72 commits from main, including the new mongo-migration.e2e
test file and its fixture (which uses the pre-rework bare-callable
source shape and needs updating in a follow-up commit on this branch).
The fixture landed on main after this branch forked and still used the
pre-rework bare-callable source:

    contract: {
      source: async () => ({ ok: true as const, value: contract }),
      output: 'output/contract.json',
      types: 'output/contract.d.ts',
    }

The new validator requires an object with load, so the 3 mongo
migration e2e tests failed under CI with "contract.source.load must be
a function (was missing)". Update the fixture to match the current
protocol and drop the now-unsupported top-level 'types' field (the
emitter colocates the .d.ts next to the .json automatically).

Verified: all 507 tests across 96 files in the integration suite pass
locally after the merge.
@jkomyno

jkomyno commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Re-review please, @wmadden — round 3 addresses layering in full

Main branch merged in + 4 follow-up commits addressing your round-2 observations and self-review findings from my own pass. headRefOid is now b2f135c8d; nothing was force-pushed.

What moved since your round-2 comment

  • R03 (path utility inconsistency) — fixed. createPathBackedSource's node:path import is gone entirely because the helper itself is gone: path handling moved out of @prisma-next/config into the CLI loader (finalizeConfig + validateContractPathDisjointness). rg "from 'node:path'" packages/1-framework/1-core/config/src/ returns zero.
  • R04 (typescriptContractFromPath should use the helper) — obviated. No helper to share anymore. Both PSL providers and both TS-from-path facades now read context.resolvedInputs[0] inline in 4–6 lines each, with no path imports.
  • F04 (ContractSourceContext field-by-field construction) — unchanged; structurally better. Context is still hand-built in contract-emit.ts + client.ts, but resolvedInputs is a plain readonly string[] populated from the finalized config, so there's no configDir-resolve step to duplicate. If you still want a factory this is cheap as a follow-up, not load-bearing.

Other structural shifts you haven't seen yet

  • @prisma-next/emitter now owns getEmittedArtifactPaths(outputJsonPath). emit() consumes it internally; the CLI emit path, the loader's cross-field check, and the Vite plugin all import it. rg "slice\(0, -5\)" packages/ --type ts is zero outside the emitter.
  • The CLI loader now pre-resolves both contract.source.inputs and contract.output to absolute paths. The output ∉ inputs check moved from defineConfig()/@prisma-next/config to loadConfig()/@prisma-next/cli, throwing ConfigValidationError('contract.source.inputs[]', …) that surfaces as errorConfigValidation — same shape as before, timing shifted.
  • The Vite plugin dropped its own resolve(configDir, input) pass and reconstructs nothing. It reads loader-finalized absolute paths verbatim and calls getEmittedArtifactPaths for the ignore set.

Design call I should flag explicitly (OQ1)

Your rework spec's "assumption unless told otherwise" was option (a) — resolvedInputs as a second positional arg to load. I landed option (b) — field on ContractSourceContext — for ergonomics (one param, one type to test-construct). FR3 ("no provider resolves paths") holds either way. Happy to revisit if the control-stack-projection identity of ContractSourceContext matters more than I judged.

Follow-ups from my own re-read (all fixed in this round)

  • b8c41b3e0 — two READMEs documented load(context, resolvedInputs) from an abandoned draft; now show the real arity-1 signature.
  • 842ef1c4f — ADR 163 Context section still showed the bare-callable shape; updated. Also clarified that interpreters remain pure while providers' load may read from context.resolvedInputs.
  • 242e16baa — providers used a silent = schemaPath / = contractPath fallback when resolvedInputs was empty. Now they throw with a clear message naming the provider and the loader invariant. Unreachable in production; surfaces test-harness bugs loudly.
  • b2f135c8d — merged main; the new test/integration/test/cli-journeys/mongo-migration.e2e.test.ts fixture on main still used the pre-rework bare-callable source, which made the 3 mongo migration e2e tests fail on CI. Fixture migrated to { source: { load: … } }. Local run: all 96 test files / 507 tests green.

Mechanical acceptance-criteria checks

Check Result
rg "from 'node:path'" packages/1-framework/1-core/config/src/ 0
rg "from 'pathe'" packages/1-framework/1-core/config/src/ 0
rg "ContractSourceEnvironment" packages/ 0
rg "createPathBackedSource" packages/ 0
rg "slice\(0, -5\)" packages/ --type ts 0 outside @prisma-next/emitter
pnpm lint:deps green (587 modules)
pnpm typecheck on affected packages green
Integration suite locally 507/507

Ready for a round-3 look whenever works.

@jkomyno
jkomyno force-pushed the tml-2276-authoritative-watch-inputs branch from b2f135c to 6b128c6 Compare April 21, 2026 14:02
jkomyno added 7 commits April 21, 2026 16:04
…rces

Validation becomes shape-only; path resolution and cross-field path checks
move to the CLI loader (see follow-up commit). `ContractSourceProvider.load`
stays a one-argument API; `ContractSourceContext` gains `resolvedInputs` so
providers consume absolute paths supplied by the loader. Drops the separate
`ContractSourceEnvironment` and `createPathBackedSource` helpers.
`loadConfig()` now owns config-file-relative path resolution for
`contract.source.inputs` and `contract.output`, and enforces that no
declared input equals an emitted artifact path. Extension facades
(postgres, mongo `define-config`) propagate the new context shape to
providers; control-api call sites thread resolved inputs through.
Introduces `getEmittedArtifactPaths()` so `contract.json` / `contract.d.ts`
paths are derived from `contract.output` in one place. `emit()` takes the
output path and uses the helper, replacing the duplicated derivation that
had grown across config, CLI, and Vite.
SQL and Mongo PSL providers read absolute paths from `context.resolvedInputs`
instead of resolving schema paths themselves; they fail loudly when the list
is empty rather than silently defaulting. TypeScript contract facades gain a
`typescriptContractFromPath` helper so both families share path handling.
Plugin reads absolute inputs from the loader-finalized config instead of
re-resolving them; the config file itself is watched in paths mode and a
warning fires on load failure. Hot-update paths are normalized via `pathe`
so the plugin stops fabricating default outputs for unrelated files.
…rdening

Updates all `prisma-next.config.ts` fixtures under test/integration to the
new `contract.source.inputs` shape. Adds the vite-plugin PSL fixture used by
the HMR e2e test and makes that test wait until the rewritten
`contract.json` is readable before parsing. Raises timeout budgets on
DB-backed CLI and sql-builder integration tests that were flaky under full-
repo load.
Updates ADR 163 to describe provider-invoked source interpretation with the
resolvedInputs I/O boundary, and aligns the config / cli / vite-plugin
READMEs with the current `load()` signature and the one-call-site path
derivation.
@jkomyno
jkomyno force-pushed the tml-2276-authoritative-watch-inputs branch from 6b128c6 to 9edc5ed Compare April 21, 2026 14:05

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

A couple of small comments but this looks good, well done 👏🏻

@jkomyno
jkomyno merged commit b1ffdba into main Apr 21, 2026
15 checks passed
@jkomyno
jkomyno deleted the tml-2276-authoritative-watch-inputs branch April 21, 2026 15:57
wmadden added a commit that referenced this pull request Apr 22, 2026
- ImportRequirement extension stays as two optional fields (kind + attributes).
- Replace the over-specialized copyContractToMigrationDir with a generic
  copyFilesWithRename helper; callers invoke it once per contract, driven by
  the emitter files list landing in #356.
- Combined named+default import lines deferred to whatever falls out of the
  renderer implementation.
- F02 (e2e un-skip) stays in PR 2, consistent with the PR-2 merge gate.
- Follow-up Linear ticket TML-2291 filed for type-level contract-hash
  enforcement (SqlQueryPlan<C, _Row>).
wmadden added a commit that referenced this pull request Apr 22, 2026
`migration new` and `migration plan` now copy the destination contract
as `contract.{json,d.ts}` and the source contract (when present) as
`from-contract.{json,d.ts}`, using the prior migration's already-copied
contract files as the source. TODOs flag #356 where the emitter will
own the artifact list.
wmadden added a commit that referenced this pull request Apr 22, 2026
…ract copies

Replace the sibling-.d.ts string-slice expedient in `migration plan` and
`migration new` with the emitter-owned `getEmittedArtifactPaths()` API
(landed in #356). The destination and prior-migration source contracts
are now derived symmetrically through the same helper, centralising the
`.json` / `.d.ts` pairing in `@prisma-next/emitter` and removing the
TODO(#356) markers.
wmadden added a commit that referenced this pull request Apr 22, 2026
- ImportRequirement extension stays as two optional fields (kind + attributes).
- Replace the over-specialized copyContractToMigrationDir with a generic
  copyFilesWithRename helper; callers invoke it once per contract, driven by
  the emitter files list landing in #356.
- Combined named+default import lines deferred to whatever falls out of the
  renderer implementation.
- F02 (e2e un-skip) stays in PR 2, consistent with the PR-2 merge gate.
- Follow-up Linear ticket TML-2291 filed for type-level contract-hash
  enforcement (SqlQueryPlan<C, _Row>).
wmadden added a commit that referenced this pull request Apr 22, 2026
`migration new` and `migration plan` now copy the destination contract
as `contract.{json,d.ts}` and the source contract (when present) as
`from-contract.{json,d.ts}`, using the prior migration's already-copied
contract files as the source. TODOs flag #356 where the emitter will
own the artifact list.
wmadden added a commit that referenced this pull request Apr 22, 2026
…ract copies

Replace the sibling-.d.ts string-slice expedient in `migration plan` and
`migration new` with the emitter-owned `getEmittedArtifactPaths()` API
(landed in #356). The destination and prior-migration source contracts
are now derived symmetrically through the same helper, centralising the
`.json` / `.d.ts` pairing in `@prisma-next/emitter` and removing the
TODO(#356) markers.
wmadden added a commit that referenced this pull request Apr 22, 2026
- ImportRequirement extension stays as two optional fields (kind + attributes).
- Replace the over-specialized copyContractToMigrationDir with a generic
  copyFilesWithRename helper; callers invoke it once per contract, driven by
  the emitter files list landing in #356.
- Combined named+default import lines deferred to whatever falls out of the
  renderer implementation.
- F02 (e2e un-skip) stays in PR 2, consistent with the PR-2 merge gate.
- Follow-up Linear ticket TML-2291 filed for type-level contract-hash
  enforcement (SqlQueryPlan<C, _Row>).
wmadden added a commit that referenced this pull request Apr 22, 2026
`migration new` and `migration plan` now copy the destination contract
as `contract.{json,d.ts}` and the source contract (when present) as
`from-contract.{json,d.ts}`, using the prior migration's already-copied
contract files as the source. TODOs flag #356 where the emitter will
own the artifact list.
wmadden added a commit that referenced this pull request Apr 22, 2026
…ract copies

Replace the sibling-.d.ts string-slice expedient in `migration plan` and
`migration new` with the emitter-owned `getEmittedArtifactPaths()` API
(landed in #356). The destination and prior-migration source contracts
are now derived symmetrically through the same helper, centralising the
`.json` / `.d.ts` pairing in `@prisma-next/emitter` and removing the
TODO(#356) markers.
jkomyno added a commit that referenced this pull request Apr 22, 2026
## Summary
- finalize `contract.output` in the CLI loader for plain-object configs
so the Vite plugin always receives resolved absolute paths
- make the Vite plugin consume loader-resolved inputs and emitted
artifact paths, update watched files as config/module-graph inputs
change, and warn once when it must fall back to config-only watching
- refresh plugin docs and align integration coverage with the default
output behavior

## Testing
- pnpm test -- test/plugin.test.ts
- pnpm test -- test/config-loader.test.ts
- pnpm test -- test/cli.emit-command.test.ts
test/vite-plugin.hmr.e2e.test.ts
- rg "resolve\(configDir"
packages/1-framework/3-tooling/vite-plugin-contract-emit/src/
- rg "slice\(0, -5\)"
packages/1-framework/3-tooling/vite-plugin-contract-emit/src/

## Notes
- Stacked on #356
- Replaces the older attempt in #357
- Refs TML-2277

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Contract configs now get a consistent default output path when
omitted.

* **Bug Fixes**
* More precise validation for optional contract fields; clearer errors
when modules lack expected exports.

* **Improvements**
* CLI always finalizes contract output and resolves input paths; Vite
plugin watch/emission behavior improved with fallback warnings and fewer
redundant emits.

* **Tests**
* Expanded and reorganized unit and integration tests to cover provider
shapes, path resolution, watch fallback, and emit flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: jkomyno <[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.

2 participants