← Back to Pull requests

A contract with a bm25 index must build type declarations, now that the ORM development build 8.0.1-dev.18 fixes it #6

Closed
unknown closed this pull request without merging on Nov 30, 2026 19:15 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 12:44 UTC
Author

An application that uses this extension's bm25 index type can now build type declarations, and this repository's checks require it. For example, with "declaration": true in the application's tsconfig.json:

// prisma/contract.ts
import { defineContract, postgres18, postgresDriver } from '@prisma/orm-postgres/contract-builder';
import paradedb from '@prisma/orm-extension-paradedb/pack';

export const contract = defineContract(
  { requiredCapabilities: [...postgres18, ...postgresDriver], extensions: { paradedb } },
  // … a model with an index of type 'bm25'
);

Until now, under pnpm, tsc stopped on that file:

prisma/contract.ts: error TS2742: The inferred type of 'contract' cannot be named without a reference to
'.pnpm/@prisma+orm-family-sql@…/node_modules/@prisma/orm-family-sql/contract/index-types'. This is likely not portable.

The defect was in Prisma ORM, not in this package, and prisma/orm#31283 fixed it. The fix reaches this repository by moving it to the ORM build that contains it, which is what this pull request does.

The decision

This repository is separate from the ORM repository, and builds the extension from the ORM packages published on npm. Until Prisma ORM 8.0 is released it names one exact development build of them (a build the ORM publishes from every push to its main). This pull request moves that build from 8.0.1-dev.15 to 8.0.1-dev.18, the newest, and makes two decisions along the way:

1. The check for the error above now requires a pass. It used to expect exactly that error.
2. A test that used ORM functions which are no longer published now asks the function prisma db migrate itself uses, in place of keeping a private copy of the removed ones.

Nothing is published by this pull request, and this package's own behaviour does not change. A user gets the declaration fix by upgrading Prisma ORM.

Why now

A nightly run builds this repository against the ORM's newest development build, to find out early when the ORM changes something the extension relies on. It fails since last night (issue 4). Since 8.0.1-dev.15 the ORM renamed one import path the extension uses and stopped publishing two others (prisma/orm#31276). The ORM removed paths it found no use of outside its own packages; this repository's tests used two of them.

1. Declaration emit must pass

scripts/check-application.mjs packs the extension, installs it into a new application the way a user would, and builds type declarations for two contracts: one with a bm25 index and one without the extension, so that a failure can be told apart from one the ORM causes on its own. DEVELOPING.md recorded the TS2742 error as a known gap, and the check expected exactly that error for the bm25 contract. It was written to fail once the ORM fixed the gap, so that the record could not outlive the defect.

8.0.1-dev.18 contains the fix, so:

  • the check requires both contracts to build declarations;

  • the code that recognised the known error, its test, and the gap's entry in DEVELOPING.md are removed;

  • the unit test of the same thing, test/declaration-emit.test.ts, loses a compiler option (preserveSymlinks) that made TypeScript find the ORM packages in a way that hid the error. It passes without it, and now fails if the error comes back.
  • 2. What the ORM's path changes required

  • A renamed error class. InternalError from @prisma/orm-framework/utils/internal-error is now InvariantError from utils/invariant-error. The shipped code throws it in one place, src/core/proximity-chain.ts, for a state only a bug in this package could cause. The ORM's upgrade script for this change (platform-paths-an-extension-uses) rewrote the import. The lint rule that forbids throw new Error names the allowed class in its message (biome-plugins/no-bare-throw.grit); that file is not TypeScript, so the script skips it, and it is renamed by hand.

  • Two removed paths, used by one test. test/descriptor.test.ts checks which of the package's migrations run from an empty database, and from the first contract the package ever shipped. It built the migration graph with reconstructGraph and searched it with findPathWithDecision, from @prisma/orm-toolchain/migration-tools/migration-graph, starting from EMPTY_CONTRACT_HASH from migration-tools/constants. Neither path is published any more. The test now describes the package's migrations with createAggregateContractSpace and asks resolveRecordedPath, both from @prisma/orm-toolchain/migration-tools/aggregate, which is still published. "An empty database" is now "no recorded contract" (null). The test asserts the same migration names as before.
  • DEVELOPING.md lists every ORM import path the repository uses, and pnpm lint:entrypoints keeps the list equal to the imports. It gains the two new paths and loses the three old ones.

    The rest of the move

  • Every @prisma/orm-* version in the two package.json files, and the build named in DEVELOPING.md and CONTRIBUTING.md, is 8.0.1-dev.18.

  • The prisma command-line tool depends on its own copy of @prisma/orm-toolchain and @prisma/orm-framework, and no release of it uses this build. Two overrides in pnpm-workspace.yaml make it use the same copy as the extension; without them it writes contract files in an older format. They stay, and now name 8.0.1-dev.18.

  • No contract or migration hash changes.

  • CONTRIBUTING.md and three CI step names now say that the application check builds type declarations.
  • Checked

  • Locally, passing: build, type check, lint, the repository's checks of its manifests, docs and workflows, the check that committed contracts and migrations match their sources, and the application check described above.

  • Unit tests: the files this change touches pass locally (descriptor, declaration-emit, operations, structured-errors). The rest of the unit suite runs in this pull request's CI.

  • The tests against a real ParadeDB database run only in CI; the machine this was built on has no Docker.
  • What the upgrade found wrong in the ORM's upgrade guidance is recorded in the ORM team's tracker (TML-4016), not here.

    Alternatives considered

  • Stay on 8.0.1-dev.15 until the next release candidate. The nightly run would stay red, so a second breaking change in the ORM would go unnoticed, and every change would arrive at once on release day.

  • Copy the removed graph functions into this repository's test helpers. The test would check the package's migrations against a private copy of the route-finding logic, which can drift from what prisma db migrate does.

  • Keep expecting the TS2742 error, or keep preserveSymlinks. Both exist only to live with the defect. With the fix installed, requiring a pass is what catches the defect if it returns.

  • Two pull requests, one per decision. The check that expected the error fails as soon as the new build is installed, so the build cannot move without it.
  • Agent: romeo-32

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: wmadden Review duration: 391m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%