Repository navigation
ci(api): fail on any unrecorded break against the last release, and require each pull request to name its public API changes - #31217
Merged
Conversation
…cord Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… CodeRabbit Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…generated type tests Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…re the description to name each changed export Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… package's breaks since it The last release is the registry's latest of @prisma/orm-postgres, with its git tag. Its packages go into .api-compat/ with a workspace of their own, their third-party dependencies pinned to the versions the current build resolves. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ot failed Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ail the check, and the diff reads the merge commit A package name in backticks with a reason covers every change in that package, so a change too large to list in a description can pass. The comment's template and the failure message offer that form for packages with more than 50 names. Errors from the comment API are logged as warnings and the description is still checked. Code fences are skipped when finding the section, only the bot's own marked comment is edited, and the job summary stays under 1,000,000 bytes with the failure included. The check now compares the merge commit with its first parent (fetch depth 2), groups runs by pull request number, and has a 10-minute timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…pps against the current build Each app under examples/ is replaced, apart from node_modules, with its files at the last release's tag, checked with the tag's own typecheck script, and put back, also on failure or after a killed run. Errors are grouped by app and file. An error the policy allows is recorded in examples/last-release-errors.json by app, file, line and code; before GA errors are reported and do not fail. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…inst this build Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…y checks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…hout context Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e, and check forwarded names exist - Tests after the first TS2589 are compiled again in a new program, until no new TS2589, because TypeScript keeps an error type for the instantiation that passes every later test. - A comparison is undecided only when TS2589 is its only error. - Each forwarded name gets an existence test; a class made abstract is a break. - Unresolved imports and copies of our packages read as one are problems. - A test whose release side is never or any is listed as not compared. - A removed import path can be recorded with export "*"; a record for an earlier release is listed as removable instead of failing; a path the current build exports but lacks fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… and fails clearly on lookups A package at the tag that the repository or the registry lacks is a problem, an --only name that matches nothing fails, registry requests are retried and end in one message, the install folder gets fetchRetries, and a version stamp is never written outside the install folder. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… not the type check job A failed release lookup or a registry outage then never blocks the type check job. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ds match one error exactly - Each app is extracted from the tag into .api-examples/<run>/examples/<app>, beside the tag's root tsconfig files, with node_modules linked to the real app's. The developer's app folders are never written, and runs at once use separate folders. - A record names the app, file, line, code and message, and must match exactly one error; line 0 is an error with no location. Its release must be a version, and one later than the last release fails. - --only scopes records to the apps it checks and fails on a name that is no app. - The typecheck script must end in a tsc run, which gets --pretty false; pretty output is read too. A non-zero exit without a type error, a signal and a timeout are problems, and a timeout kills the whole process group. - The release lookup is retried over about a minute and then fails with one line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…b, and records match one error Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e budget per package A test compared after a type too deep to compare is suspect, because TypeScript keeps an error type that passes it. Suspects are compiled again 32 at a time; what is left when the budget (two minutes by default) runs out is reported as undecided, never as passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…unresolved imports only in our packages pnpm does not install optional peers, so the release's orm-toolchain lost vite's types and compared them as any. Unresolved optional imports inside third-party declarations, such as vite's less, are the same on both sides and are no longer problems. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e packages Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…rong Private members that changed, a narrowed constructor parameter, two unique symbols with one name in two modules, a generic signature TypeScript cannot relate between two copies, a type too deep to instantiate, and one third-party version installed twice with different peers. The count of tests for the unchanged build now includes the constructor test for its class. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ach third-party version A compiler host that turns our packages' methods into function-typed properties, drops private and protected members (in third-party declarations too), names each unique symbol constant after its module and itself, and resolves every import of a third-party name and version to the first copy read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…of the release Each export is compared with TypeScript's own assignability on the rewritten declarations, with a constructor-parameters test for each class. A failure is a break when the same test passes between the release and a second copy of it; otherwise it is compared with generic signatures erased one level deep, then with the structural mapping, and is undecided if that is too deep. A stack overflow is split down to the one test, which is undecided. One time budget covers the whole package. Records now match the final verdict instead of a @ts-expect-error line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…isses A generic signature whose change only the comparison with the twin, or only a member-by-member comparison, can see; a changed generic signature TypeScript cannot relate between two copies, which must stay undecided; a failure with no time left to confirm it; a narrowed protected method and a widened abstract one; a unique symbol that moved to another file; two classes whose members are all private; a type that overflows the checker's stack; and a record for one test of an export beside a break of another. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
An API inside a GA package can be a Release Candidate, written rc_foo, and may still change before it is GA. So a break to an rc_ name is reported only, as for preview_ and ea_, unless the last release also exports the same thing under a name without a prefix. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e, and forwarded names A promoted name is held to GA when the unprefixed name is the one typed as the prefixed one, when the two meet through a declaration the package does not export, and when both are forwarded from another package, as the facade packages do. Each test fails when its part of the rule is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 26, 2026 11:05
wmadden
approved these changes
Nov 26, 2026
wmadden-electric
marked this pull request as draft
November 26, 2026 23:28
wmadden
requested changes
Nov 26, 2026
wmadden
left a comment
Contributor
There was a problem hiding this comment.
rewrite all documentation on this pr from scratch
Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ructions Each document now opens with an example and the decision, defines its words before using them, shows each rule with code or real job output, and leaves out tickets, dates and counts that will go out of date. Wrong statements are corrected: which test reports a change that is safe for users, what the example apps report, how the second copy of the release is made, what a printed record needs before it is accepted, and the capitalised level prefix on a type or class. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The decision record gains an example for the example apps, a real import path in its list example, a definition of the last release, and a table of the four steps that turn a failed test into a break or an undecided result. It says why a generic type can be "not compared" and what `allowed` covers. The guide shows the job's output whole, lists the seven tests and every entry the report prints, and says what a fork sees. The review instructions no longer describe levels per package, which do not exist. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 27, 2026 00:17
wmadden
approved these changes
Nov 27, 2026
wmadden-electric
marked this pull request as draft
November 27, 2026 03:54
…eases included Both checks now fail on any break or example-app error that no record accepts, whatever the last release's version. The --ga flag and the "reported only" rule for pre-releases are gone. A break in an export whose name starts with a maturity level still does not fail; the report marks it "maturity level, does not fail". Records the 35 breaks already on main against 8.0.0-rc.25: 29 from the SQL builder's join scopes (#31150) and 6 from MongoDB contracts refusing __proto__ names (#31185). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Each part of the compatibility policy is in force from the first release candidate after it merges, and a break before 8.0.0 is a deliberate decision, written down as a record. The documents no longer describe a rule that waits for a full release, and the promise is stated once, in the decision record, which the guide and the review instructions point to. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
# Conflicts: # package.json
The promise is stated once, with its scope, and nothing in the decision record goes stale at 8.0.0. The documents agree that the release notes name a recorded break, and the step table says when a member-by-member pass is undecided. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
marked this pull request as ready for review
November 27, 2026 04:26
# Conflicts: # package.json
… page The versioning page now states both, so the decision record and the guide link to it, and the record no longer says the policy keeps every package at one version. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pull request can break our users in two ways without anyone noticing: it breaks an API users already have, or it exports something by accident, which from
8.0.0we must keep until Prisma 9. This pull request adds two CI jobs, one for each, and they apply from now, on release candidates, so they are proven long before8.0.0.A break. Suppose a pull request makes the
optionsparameter ofcreateCacheMiddlewarerequired. Every application that callscreateCacheMiddleware()would stop compiling. The newAPI compatibilityjob compares the build with the last release and fails:If the break is deliberate, the author records it, with a reason, and the job passes (see "Accepting a break you mean").
An accidental export. Each published package commits an
api.txt, a generated list of everything users can import from it, one line per export. Suppose a pull request exports an internal helper from@prisma/orm-family-sql/relational-core/ast. Nothing breaks, but the package's list gains a line, which starts with the import path:The new
API changes namedjob posts a comment listing that line. The author either removes an export that was an accident, or names it in the description with a reason. The job fails until the description has that entry:The decision
API compatibilityAPI changes namedapi.txtlists and break records before and after this pull requestBoth apply from now, against any last release. Each part of the compatibility policy is in force from the first release candidate after its pull request merges. Until
8.0.0, a break is still possible, but only as a deliberate decision with release notes, and a record is how that decision is written down. Failing from now on also proves the checks on real breaks before anyone relies on them. A job that could not compare at all, for example because the registry was unreachable, fails too.Neither job blocks a merge yet. That needs a repository admin to make it a required check in the branch rules, which live outside this repository. The recommendation: require both now.
One piece of work remains before
8.0.0. The compatibility job assumes every package is published at one version, as every release candidate is. #31212, merged today, gives each package its own version from release 8.0, such as8.3.1for a generally available (GA) package and8.3.0-ea.1for an Early Access one. The job looks up one version for every package and applies one rule to all of them. So it would not find packages published at their own versions, and it could not treat an Early Access package differently from a GA one. Ticket TML-3977 makes it read each package's own version and level; release 8.0 waits for it.The design and its reasons are in the new decision record,
docs/architecture docs/adrs/ADR 336 - CI finds breaking and accidental API changes against the last release.md. The contributor guide isdocs/Public API Compatibility.md.What it finds today
Over the 21 published packages that were in the last release, the type tests make 10,050 comparisons. (The 22nd,
@prisma/orm-better-auth, has never been released, so there is nothing to compare it with.)8.0.0-rc.25: one requires a column name shared by several joined tables to name its table (fix(sql-builder)!: a column name that several joined tables share must name its table #31150), and one refuses MongoDB names such as__proto__(fix: a MongoDB contract refuses a field, relation or PSL enum named __proto__, and the upgrade instructions for such names are corrected #31185). Both were deliberate breaking changes, so this pull request records all 35, with those two reasons. The records stop applying when the next release candidate is published, because it becomes the last release.ormandCollection, and the Mongo query builder, which is too deep for the compiler (the job carries on). For those, the example apps' type tests are the check, as far as the apps use them. Nine of the 123 are in@prisma/orm-family-sqlonly because it declares two different symbols with the same name,aggregateOperationsUnavailable; TML-3973 renames one.neverwhen the check fills their type parameters, so a test of them would pass whatever they are. The check lists them and does not compare them.createCacheMiddleware's options required fails the job against8.0.0-rc.25(exit 1,breaks 1 … — FAILS), and the same package without the change passes. Earlier rounds showed that adding an optional parameter is not a break, and that changing a result type an example app asserts fails with the app, file and error.Accepting a break you mean
Under each break, the job prints a record. The author pastes it into the package's
api-breaks.jsonand replaces the…inreason:{"path":".","export":"createCacheMiddleware","test":"value","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"b0e322358c4a297e","reason":"A store must always be given."}testis which of the export's comparisons failed, such asvaluefor the function or constant itself andtypefor its type; the guide has a table of all seven.kindisbreakfor a deliberate break, which the release's release notes must name, orallowedfor a change the policy permits that is reported anyway (next section). The fingerprint covers the export's lines inapi.txt, so a later change to the export makes the record stop applying. An example app's error has its own record inexamples/last-release-errors.json, and a deleted package one inpackages/9-public/removed-packages.json. Adding or removing a record is itself an API change, named in the description by the package (orexamples/<app>), and the failure message says exactly what to write.How the type tests decide
The method adapts the one used by Microsoft's Fluid Framework: one compile-time test per export of the previous release. The last release is installed from the registry beside the current build, and for each export a generated line asks TypeScript whether the current type can be assigned to the release's.
Only that one direction is tested, and it tests each type in both of its roles. A type's own test treats it as something users receive and use. The test of each exported function that accepts the type treats it as something users supply. Suppose
CacheStore, an interface users implement, gains a requiredclear().CacheStore's own test passes, because a type with more members fits where the old one did. ButcreateCacheMiddlewareaccepts aCacheStore, and no longer accepts an old store withoutclear(), so the function's test fails. So nobody keeps a list of which interfaces users implement. The price is that the check cannot know which role a type really has. A change that is safe in its real role can fail the test for the other role: a wider return type on a method of an interface that users only implement fails the interface's own test. Someone records such a report with kindallowed. None of today's 35 breaks is of that kind.The declarations are rewritten as TypeScript reads them, so that private members and unique symbols, which TypeScript ties to one copy, compare across copies. A failure only counts once the release, compared with a second copy of itself, passes; otherwise TypeScript cannot relate the type across copies.
Names that carry a level. An API that may still change has its maturity level at the start of its name:
ea_,preview_orrc_(Early Access, Preview, Release Candidate), capitalised on a type or class, as inEa_Search. A break in it is only reported. One exception: when an API is promoted, the release keeps the old name for the same thing, deprecated, until the next major version. So if release8.2exportsea_fooand release8.3addsfoowithexport { foo as ea_foo }, from8.3onea_foois held likefoo, and removing it fails. A similar name alone does not count: anea_createClientwith its own declaration besidecreateClientstays Early Access.What the checks do not see
Behaviour (runtime results, errors, command output), third-party types, the 123 undecided comparisons, the 171 exports that are not compared, result types the example apps do not use, and a few kinds of type change listed in the decision record, such as a property made
readonly.Five further checks are their own tickets: TML-3965 (a GA package depends only on GA packages), TML-3966 (each package's committed
exportsfield matches its build), TML-3967 (release notes name each recorded break), TML-3968 (dependency upgrades are named in the description), TML-3969 (a scheduled run comparing each package with itself, so false breaks stay visible).What is in the diff
scripts/public-api/: the test generator, the release lookup, the records, the example-app check, with tests and fixtures..github/workflows/: theAPI compatibilityjob inci.yml, and the newapi-changes.ymlwith its script. The description check writes to the job summary instead of commenting for a pull request from a fork, and passes in the merge queue. Only its job haspull-requests: write; there is nopull_request_target.api.txtand the records, inpackages/9-public/AGENTS.mdand.coderabbit.yml; the decision record; the contributor guide. The project's planning folder,projects/public-api-check/, is deleted, since its lasting content is now in the decision record and the guide.API changes
This pull request records the 35 breaks already on
main, so these packages'api-breaks.jsonfiles are new. Noapi.txtchanges.@prisma/orm-family-sql,@prisma/orm-postgres,@prisma/orm-mysql,@prisma/orm-mariadb,@prisma/orm-sqlite,@prisma/orm-extension-supabase: records of the deliberate break in fix(sql-builder)!: a column name that several joined tables share must name its table #31150, where a column name that several joined tables share must name its table.@prisma/orm-family-mongo: records of the deliberate break in fix: a MongoDB contract refuses a field, relation or PSL enum named __proto__, and the upgrade instructions for such names are corrected #31185, where a MongoDB contract refuses a field, relation or PSL enum named__proto__.Alternatives considered
api.txt, and they too are compared as text.api.txtchange in place of the description check. It depends on one person noticing, and leaves no reason in the history.Fixes TML-3933
Agent: hallandoates-87
🤖 Generated with Claude Code