Repository navigation
feat!: before 8.0.0, compute each contract hash from its own section with every value the author wrote, then freeze the rules (changes every existing hash) - #31203
Conversation
|
Review skipped: 1076 files exceed the limit of 300 WalkthroughWarning Review details and warnings were omitted to fit the comment limit. |
@prisma/orm-better-auth
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mariadb
@prisma/orm-mongo
@prisma/orm-mysql
@prisma/orm-postgres
@prisma/orm-postgres-contrib
@prisma/orm-sqlite
@prisma/orm-target-mariadb
@prisma/orm-target-mongo
@prisma/orm-target-mysql
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
…L holds them The subsystem docs, the capabilities reference and the capability-gating pattern now say that on PostgreSQL the target and driver declare capabilities and the client checks its connection, while on MySQL, MariaDB and SQLite the adapter's fixed list goes into every contract and no client check runs. They also say the SQL profile hash covers no capabilities today, until #31203. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Public API changesThis pull request changes the ## API changes
- `@prisma/orm-extension-supabase`:
- `@prisma/orm-extension-supabase (not exported): ProfileHash`:
- `@prisma/orm-extension-supabase (not exported): StorageHash`:
- `@prisma/orm-family-mongo`:
- `@prisma/orm-family-mongo/contract/canonicalization-hooks: mongoContractCanonicalizationHooks`:
- `@prisma/orm-family-mongo/contract/normal-form: normalizeMongoDomain`:
- `@prisma/orm-family-mongo/contract/normal-form: normalizeMongoStorage`:
- `@prisma/orm-family-mongo/family/ir: MongoContractSerializerBase`:
- `@prisma/orm-family-mongo/family: MongoContractSerializerBase`:
- `@prisma/orm-family-sql`:
- `@prisma/orm-family-sql/contract/canonicalization-hooks: sqlContractCanonicalizationHooks`:
- `@prisma/orm-family-sql/contract/normal-form: normalizeSqlDomain`:
- `@prisma/orm-family-sql/contract/normal-form: normalizeSqlStorage`:
- `@prisma/orm-family-sql/contract: normalizeSqlDomain`:
- `@prisma/orm-family-sql/contract: normalizeSqlStorage`:
- `@prisma/orm-family-sql/contract: sqlContractCanonicalizationHooks`:
- `@prisma/orm-family-sql/family/ir: SqlContractSerializerBase`:
- `@prisma/orm-family-sql/family: SqlContractSerializerBase`:
- `@prisma/orm-framework`:
- `@prisma/orm-framework (not exported): ComputeStorageHashArgs`:
- `@prisma/orm-framework/components/control: ContractSerializer`:
- `@prisma/orm-framework/components: ContractSerializer`:
- `@prisma/orm-framework/contract/hashing-utils: PathPattern`:
- `@prisma/orm-framework/contract/hashing-utils: PreserveEmptyPathSegment`:
- `@prisma/orm-framework/contract/hashing-utils: createPreserveEmptyPredicate`:
- `@prisma/orm-framework/contract/hashing-utils: createStorageSort`:
- `@prisma/orm-framework/contract/hashing-utils: matchesPathPattern`:
- `@prisma/orm-framework/contract/hashing: AssertContractHashesOptions`:
- `@prisma/orm-framework/contract/hashing: CanonicalizeContractOptions`:
- `@prisma/orm-framework/contract/hashing: HashedContractSections`:
- `@prisma/orm-framework/contract/hashing: NormalizeStorage`:
- `@prisma/orm-framework/contract/hashing: PreserveEmptyPredicate`:
- `@prisma/orm-framework/contract/hashing: SavedContractHashes`:
- `@prisma/orm-framework/contract/hashing: StorageSort`:
- `@prisma/orm-framework/contract/hashing: assertContractHashes`:
- `@prisma/orm-framework/contract/hashing: buildExecutionSection`:
- `@prisma/orm-framework/contract/hashing: computeExecutionHash`:
- `@prisma/orm-framework/contract/hashing: computeProfileHash`:
- `@prisma/orm-framework/contract: AssertContractHashesOptions`:
- `@prisma/orm-framework/contract: CanonicalizeContractOptions`:
- `@prisma/orm-framework/contract: HashedContractSections`:
- `@prisma/orm-framework/contract: NormalizeStorage`:
- `@prisma/orm-framework/contract: PathPattern`:
- `@prisma/orm-framework/contract: PreserveEmptyPathSegment`:
- `@prisma/orm-framework/contract: PreserveEmptyPredicate`:
- `@prisma/orm-framework/contract: SavedContractHashes`:
- `@prisma/orm-framework/contract: StorageSort`:
- `@prisma/orm-framework/contract: assertContractHashes`:
- `@prisma/orm-framework/contract: buildExecutionSection`:
- `@prisma/orm-framework/contract: computeExecutionHash`:
- `@prisma/orm-framework/contract: computeProfileHash`:
- `@prisma/orm-framework/contract: createPreserveEmptyPredicate`:
- `@prisma/orm-framework/contract: createStorageSort`:
- `@prisma/orm-framework/contract: matchesPathPattern`:
- `@prisma/orm-mariadb`:
- `@prisma/orm-mariadb/family-contract/canonicalization-hooks: everything from @prisma/orm-family-sql/contract/canonicalization-hooks`:
- `@prisma/orm-mariadb/family-contract/normal-form: everything from @prisma/orm-family-sql/contract/normal-form`:
- `@prisma/orm-mongo`:
- `@prisma/orm-mongo/family-contract/canonicalization-hooks: everything from @prisma/orm-family-mongo/contract/canonicalization-hooks`:
- `@prisma/orm-mongo/family-contract/normal-form: everything from @prisma/orm-family-mongo/contract/normal-form`:
- `@prisma/orm-mysql`:
- `@prisma/orm-mysql/family-contract/canonicalization-hooks: everything from @prisma/orm-family-sql/contract/canonicalization-hooks`:
- `@prisma/orm-mysql/family-contract/normal-form: everything from @prisma/orm-family-sql/contract/normal-form`:
- `@prisma/orm-postgres`:
- `@prisma/orm-postgres/family-contract/canonicalization-hooks: everything from @prisma/orm-family-sql/contract/canonicalization-hooks`:
- `@prisma/orm-postgres/family-contract/normal-form: everything from @prisma/orm-family-sql/contract/normal-form`:
- `@prisma/orm-sqlite`:
- `@prisma/orm-sqlite/family-contract/canonicalization-hooks: everything from @prisma/orm-family-sql/contract/canonicalization-hooks`:
- `@prisma/orm-sqlite/family-contract/normal-form: everything from @prisma/orm-family-sql/contract/normal-form`:
- `@prisma/orm-target-mongo`:
- `@prisma/orm-target-mysql`:
- `@prisma/orm-target-postgres`:
- `@prisma/orm-target-postgres/target/runtime: PostgresContractSerializer`:
- `@prisma/orm-target-postgres/target: PostgresContractSerializer`:
- `@prisma/orm-target-sqlite`:
- `@prisma/orm-toolchain`:
- `@prisma/orm-toolchain (not exported): ExecuteDbSignSuccess`:
- `@prisma/orm-toolchain/cli/control-api: DbSignOptions`:
- `@prisma/orm-toolchain/cli/control-api: ExecuteDbSignOptions`:
- `@prisma/orm-toolchain/cli/control-api: RenderContractDtsFailure`:
- `@prisma/orm-toolchain/emitter: EmitOptions`:
- `@prisma/orm-toolchain/migration-tools/contract-snapshot-store: SnapshotCanonicalizationHooks`:
- `@prisma/orm-toolchain/migration-tools/contract-snapshot-store: createSnapshotContentVerifier`:
- `@prisma/orm-toolchain/migration-tools/contract-snapshot-store: writeContractSnapshot`:
- `@prisma/orm-toolchain/migration-tools/spaces: DescriptorSelfConsistencyInputs`:
- `@prisma/orm-toolchain/migration-tools: DescriptorSelfConsistencyInputs`:
- `@prisma/orm-toolchain/migration-tools: SnapshotCanonicalizationHooks`:
- `@prisma/orm-toolchain/migration-tools: createSnapshotContentVerifier`:
- `@prisma/orm-toolchain/migration-tools: writeContractSnapshot`:
|
…er its own section and no author value dropped Each hash covers targetFamily, target and its own section of the contract. The framework canonicalizer drops no value; each family names the defaults it leaves out in normalizeStorage. The SQL profile hash covers the contract's capabilities, flags that are off left out. Foreign keys and MongoDB indexes are sorted before hashing. assertContractHashes lets a family or target hold its hashes fixed; prisma db sign gains --force. The upgrade instructions and script move a release-candidate project to the new hashes. ADR 332 records the decision and ADR 010 the computation. Squashed from 312 commits so the sign-off check can read the pull request; the earlier history is kept on ga-compat-hashes-backup-pre-squash. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
4ed566f to
5d97d2e
Compare
…ding example, and drop the one-time move from the pre-releases 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]>
…hey do not know (prisma#31200) ## At a glance **The decision: every file Prisma stores in a project states the version of its format, a reader refuses a version or a field it does not know, and until `8.0.0` it still reads the files a release candidate wrote.** `8.0.0` is the first stable release of Prisma 8, which has not shipped; release candidates (`8.0.0-rc.N`) continue until then. **Two things need the reviewer's decision:** 1. **This adds one concept to the framework domain,** which the repository's rules reserve: the shared reader of a stored file's format version, with its converters. It is there because some paths read a contract before any family sees it. I recommend accepting it. Details are under "API changes". 2. **Whether the framework should read a migration's operations strictly when it loads them.** Today only the commands that act on a database do, so `migration check` can pass a migration that `db migrate` refuses. Fixing it adds a hook to the framework. I recommend adding it, in this pull request or the next. Details are under "Known limits". Suppose Prisma `8.3` changes how a migration is written, and a teammate on `8.0` pulls a migration that `8.3` wrote. Without this pull request, `8.0` could read it and apply only the part it understood. With it, `8.0` stops before it touches the database (an example of the output): ```text ✘ [MIGRATION.FORMAT_VERSION_NEWER] The migration file (migration.json) "migrations/app/20270301_add_tags/migration.json" was written by a newer release of Prisma It is in format version 2, and this release of Prisma reads format version 1 only. Upgrade Prisma to the release that wrote the file, or a later one, and run the command again. ``` To make that possible, every file Prisma writes into a project and reads back later starts with the version of its format: ```text contract.json before: { "schemaVersion": "1", "targetFamily": "sql", ... } after: { "formatVersion": 1, "targetFamily": "sql", ... } migration.json before: { "from": "6c26…", "to": "6b46…", ... } after: { "formatVersion": 1, "from": "6c26…", "to": "6b46…", ... } refs/production.json before: { "hash": "6b46…", "invariants": [] } after: { "formatVersion": 1, "hash": "6b46…", "invariants": [] } ``` What it costs and what it does not: - **A project a release candidate wrote keeps working with no step.** Its files have no `formatVersion`. This release reads them as "format version 0" and converts them in memory. Each file becomes version 1 the next time a command writes it. `8.0.0` stops reading version 0, and a script in the upgrade instructions rewrites the files before that upgrade. - **A file with a key Prisma does not define is now refused,** in a contract, a migration, a ref or an operation. A hand-edited file with a stray key stops reading. One exception until `8.0.0`: a ref file a release candidate wrote is read with a stray key dropped, as the release candidates did. - **A MongoDB migration that passes `sort` or `returnDocument` to `rawFindOneAndUpdate`, or `sort` to `rawFindOneAndDelete`, now sends them to the database.** Earlier releases dropped them when they read the migration back, so the command ran without them. Applying such a migration to another database now does what its author wrote. - **A SQL target built outside this repository must supply a new function, `readOperations`,** and a contract serializer overrides a different method. The full list is under "API changes". About 600 of the changed files are the repository's own contracts, snapshots, migrations and refs, rewritten by a script; each differs from `main` only in the version field. A **snapshot** is the copy of a contract that a migration keeps beside it. A **ref** is a file that gives a contract a name, such as `production`. `ops.json` holds the operations of a migration, beside its `migration.json`. ## The decisions All are recorded in a new decision record, [ADR 331](docs/architecture%20docs/adrs/ADR%20331%20-%20Stored%20files%20carry%20a%20format%20version%2C%20and%20a%20reader%20refuses%20one%20it%20does%20not%20know.md). 1. **`contract.json`, each snapshot, `migration.json` and each ref file carry `formatVersion`.** A migration's version also covers its `ops.json`. 2. **A reader looks at the version first.** A version it knows: it reads the file. A higher version: it stops and says a newer release wrote the file. No version: it stops and says how to get a file it can read, unless the file is one only a release candidate wrote (decision 5). 3. **A reader refuses a field it does not know.** So a release cannot add a field to a format without raising its version. 4. **A writer writes the oldest version that can hold the data,** so newer tooling does not force an upgrade on everyone who reads its files. With one version there is nothing to choose yet; the rule binds the first release that adds a second. 5. **Until `8.0.0`, files a release candidate wrote are read as version 0 and converted in memory.** Until `8.0.0` the content of format 1 is also not final: a release candidate may still change it, with upgrade instructions. 6. **Format 1 of `ops.json` reads every shape of an operation that a release candidate wrote, for the whole of Prisma 8.** ### Decisions 1 and 2: why the version and the refusal must be in `8.0.0` The Prisma 8 compatibility policy promises (its page is a draft, prisma#31193; the promise itself is agreed) that a later 8.x release reads every file an earlier one wrote, and the user regenerates nothing. An `8.0.0` reader stays in use for the whole major. So it must already know how to recognise a file it cannot read, and it must already refuse what it does not understand. A reader that ignores an unknown key in `8.0.0` will ignore, for the whole major, a field a later release adds. Neither can be added afterwards. A reader is strict because a migration is an instruction to change a database. Acting on one that is only partly understood is the failure the rule prevents. ### Decision 3: what "refuses a field it does not know" changed Before this pull request several readers ignored unknown keys: | Reader | Before | Now | | --- | --- | --- | | `migration.json` and ref files | A ref ignored unknown fields | Strict in format 1; a release-candidate ref still has unknown fields dropped | | Contract (SQL family, PostgreSQL entry kinds, MongoDB family) | About 25 kinds of object ignored an unknown key | Strict; the error names the key's full path | | MongoDB `ops.json` | Every object ignored an unknown key | Strict | | SQL `ops.json` | No reader: the runners treated the parsed file as operations | A strict reader in the SQL family, to which each SQL target supplies its own fields | | A type's parameters | Prisma's own types ignored an unknown parameter, and no command checked them | Each of Prisma's 16 parameter schemas is strict, and it is applied when a command reads a contract and when a client builds the type | | A contract snapshot | Read strictly only by `migration plan` | Read strictly by whatever interprets it: planning, signing, `db migrate --to` and `db update --to` for the snapshot a ref names, and `migration check` for every snapshot a ref names or a graph ends at. A snapshot a command only records or identifies by hash is not read | A **family** is the code shared by databases of one kind (SQL, MongoDB); a **target** is one database, such as PostgreSQL. The rule stops at content Prisma carries for someone else, where any key is accepted. These are the **open places**: `meta`, `capabilities`, an extension's own section, a generator's parameters, a literal default's value, an index's options, a SQL statement's parameters, and the MongoDB documents handed to the database as they are. ADR 331 lists them. SQL operations are read strictly by everything that acts on their statements: the runners, the statement preview, and the checks `db migrate` runs on a recorded path. A command reads strictly what it interprets in that run, and no more. `db migrate` records the snapshot of each migration it applies as it is stored, and `migration status`, `list`, `graph` and `ref set` use hashes only. This matters for old projects: one with a snapshot in a shape from before `8.0.0-rc.1`, which no reader of this release reads, still applies its migrations. The repository's telemetry app is such a project. A command that cannot read a stored file names it and says why, and never calls it unknown or missing. It refuses when it acts on the file; `migration list`, `graph`, `status` and `check` report it and go on with the rest. `db update` is the one command that goes on past a file it acts on: when the snapshot of the contract the database was last at cannot be read, it warns and continues as for a database with no recorded origin. Before this, several commands dropped such a file without a word: `migration list` and `graph` left out a migration, `migration new` started from the empty contract when its ref could not be read, and `migration check` reported the migrations after an unreadable one as unreachable, with advice to delete them. Every command and entry point that loads a stored file was listed and checked for this. The advice a refusal gives follows one rule: restore the file from version control first; name a command only where that command writes the file again, and say what else it does; never give a new hash to a migration a database has applied; never name a contract for the `db` ref by hand. For example, a lost `migration.json` is written again by running the migration's `migration.ts`, which gives it a new hash, so that advice is offered only when no database has applied the migration. The database commands warn about a migration whose snapshot they cannot record only when the run applies it. ### Decision 5: why release-candidate files are read, and only until `8.0.0` Release-candidate users have asked for fewer forced rewrites. Reading their files costs them nothing now. It also runs the "convert an earlier format" path on real files before the first format change after `8.0.0` depends on it. A release-candidate file is recognised without guessing: a contract has `"schemaVersion": "1"` and no `formatVersion`; a `migration.json` or ref has neither. Only a release candidate wrote those. A contract with neither field is refused, because no release wrote it. Version 0 has a converter and no printer, so no release writes it. A test fails if a release that is not a pre-release still reads version 0, so `8.0.0` cannot ship with it. prisma#31203, built on this pull request, changes how contract hashes are computed. The parts of release-candidate reading that depend on that are there. ### Decision 6: why older operation shapes are read for the whole major From `8.0.0` no release may change a migration's hash, and `ops.json` is covered by that hash. So from `8.0.0` an older shape of an operation can only be read, never rewritten, and format 1 has to read it for the whole major. Before `8.0.0` a script could still have rewritten those shapes, because the hash rules change once before `8.0.0` (prisma#31203). Reading them was chosen because it is small and costs users no step. The reader converts each to the current shape before it checks the operation, so nothing after it sees the older form: - **SQLite, up to `8.0.0-rc.19`:** every operation carried `"schema": "main"`. It is dropped. Any other value is refused. - **PostgreSQL and SQLite, `8.0.0-rc.21` and `rc.22`:** an entry in a step's `meta` tells the runner to count the rows that still hold a removed enum value. In those releases it had fewer fields. The reader fills them in from the same places those releases' runners read them. - **MongoDB:** a field the query builder writes into a query plan is declared, and two command options that earlier readers dropped, `sort` and `returnDocument` on `rawFindOneAndUpdate` and `sort` on `rawFindOneAndDelete`, are now passed to the command. That changes what such a migration does when it is applied again: it now does what its author wrote. These were found by going through the history of every planner, operation class and serializer across all 485 published `8.0.0-rc` tags (each release candidate and the development builds between them), because the repository holds no saved file of most of them. Contract shapes from earlier release candidates need no such acceptance: published upgrade instructions already rewrite them. ## Known limits Recorded in the project's follow-up list, `projects/ga-compat-stored-files/deferred.md`: - **`migration check`, `status`, `list` and `graph` do not read a target's own operation fields.** They load `ops.json` in the framework and use only the fields every target shares. So `migration check` can pass a migration that `db migrate` refuses. Fixing it means the framework asks the family to read each operation when it loads the file, which adds to the framework. It is listed in ADR 331 as an alternative not chosen here, and it is the second decision asked of the reviewer above. - **A migration written in code can write an operation that `db migrate` then refuses,** for the same reason. - **An index's `type` and `options` are not checked when a contract is read,** only by the TypeScript builder. - **SQLite creates an empty database file when `db migrate` refuses a migration,** because the refusal comes after the database is opened to read its marker. That was so before this change. - **Nothing tests that the open places stay open.** A reader that starts acting on a key inside one needs a new format version, and only the author of the change knows. ## For users of a release candidate Nothing to do for this change. [The upgrade instructions](upgrade-instructions/pending/stored-files-format-version/app/instructions.md), for applications and for extensions, still ship a script that rewrites every file to version 1. It is required before upgrading to `8.0.0`, and optional until then: ```bash node upgrade-instructions/pending/stored-files-format-version/app/scripts/stored-files-format-version/stored-files-format-version.ts ``` That is its path in this repository. A user gets it with the release's upgrade guide in the Prisma 8 skill and runs it from their project root. It renames `schemaVersion` in every contract and snapshot, adds `formatVersion` to every `migration.json` and ref file, changes no other byte and no hash, removes an unknown field from a ref file and lists it, and changes nothing when run again. ## API changes Application code changes nothing. The changes are for authors of a family, a target, an extension or a tool built on the toolchain. - `@prisma/orm-framework`: new entries `contract/format-version` (`convertContractDocument`, which reads a stored contract's version and converts an earlier one; `NEWEST_CONTRACT_FORMAT_VERSION`, which a family writes into the contracts it prints; `isFormatVersionError`; and their types), so a family built outside this repository reads and writes a contract the way Prisma does (the same names are also on the `contract` entry); `contract/internal/format-version`, the shared reader and its converters for every kind of file (`readStoredDocument`, `StoredFormat` and their types), which Prisma's own packages reach each other through and which is not for outside code; and `utils/upgrade-guides`, the addresses a refusal points to. `CanonicalizeContractOptions` loses `schemaVersion`, because `canonicalizeContract` no longer takes or writes it. `errorContractValidationFailed` accepts the file's path and what kind of file it is in its options, so a refused contract or snapshot names its file. - `@prisma/orm-postgres`, `@prisma/orm-mysql`, `@prisma/orm-mariadb`, `@prisma/orm-sqlite` and `@prisma/orm-mongo`: each re-exports the three new framework entries, because a database package re-exports every framework entry so that code built on it needs no direct dependency on the framework. That includes the `internal` entry, which Prisma's own packages use to reach each other and which is not for outside code. - `@prisma/orm-family-sql`: `SqlContractSerializerBase` gains protected `parseContractV1` and `printContractV1`, the parser and printer of contract format 1; the base class reads and writes the version around them. New: `createSqlOperationsReader`, `SqlOperationsReader`, `SqlTargetOperationsFormat` and `SqlOperationsLocation`, the strict reader of SQL operations and what a target supplies to it; and `probeUnknownKeys`, `SQL_OPERATIONS_OPEN_PLACES`, `DocumentPlace` and `UnknownKeyProbe`, a test helper with which a SQL target's author checks that its reader refuses an unknown key everywhere outside the open places. `SqlControlTargetDescriptor` gains a required `readOperations`, so **a SQL target built outside this repository must now supply it**. Its `api-breaks.json` records the breaks against `8.0.0-rc.25`. - `@prisma/orm-family-mongo`: `MongoContractSerializerBase` and `MongoContractSerializer` gain `parseContractV1` and `printContractV1`, for the same reason as the SQL base. - `@prisma/orm-target-postgres`: `PostgresContractSerializer` overrides `printContractV1` where it overrode `serializeContract`, because the base class now writes the version around it. - `@prisma/orm-target-mysql`: `MysqlContractSerializer` overrides `printContractV1` for the same reason, and the target supplies `readOperations`. Its `api-breaks.json` records the breaks. - `@prisma/orm-target-sqlite`: `SqliteContractSerializer` overrides `printContractV1` for the same reason. - `@prisma/orm-target-mongo`: `MongoTargetContractSerializer` overrides `printContractV1` for the same reason. `deserializeMongoOps` takes an optional `MongoOperationsLocation`, so a refusal names the migration and the operation. - `@prisma/orm-toolchain`: new `parseMigrationMetadataDocument`, `printMigrationMetadataDocument`, `parseRefDocument`, `printRefDocument` and their document types, the parser and printer of each version of `migration.json` and ref files. `computeMigrationHash` accepts `formatVersion` and leaves it out of the hash. `contractSpaceFromJson` requires `spaceId`, so an error in a file an extension ships names the extension. `assertDescriptorSelfConsistency` takes the whole `contractJson`, so it can read the version first. `buildReadAggregate` gains `onUnreadableFile`, which refuses an unreadable ref or migration by default and lets a listing command report it and keep going. `IntegrityViolation`'s `contractUnreadable` gains the snapshot's `hash`, so a refusal names the file; the functions that carry that type are recorded as breaks for it. `DbUpdateOptions` gains an optional `onUnreadableOrigin`. `enumerateCheckSpaces` takes one options object (`EnumerateCheckSpacesInputs`) with the family's contract reader, and `CheckSpace` carries that reader and the migrations that could not be read; `checkSingleTarget` and `runMigrationCheck` follow. Its `api-breaks.json` records these. The breaks recorded against `8.0.0-rc.25` are `contractSpaceFromJson`, `assertDescriptorSelfConsistency`, `buildReadAggregate`, `enumerateCheckSpaces`, `checkSingleTarget` and `runMigrationCheck`. The repository's rule is that the framework domain, `packages/1-framework`, gains no new concepts. This pull request adds one there (the first decision asked of the reviewer above): the shared reader of a stored file's format version, with its converters. It is in the framework because some paths read a contract before any family sees it (the CLI's contract reader, the snapshot store, an extension's bundled files). The strict readers added nothing to the framework. This addition needs the reviewer's agreement. ## Reviewing the diff <details> <summary>A suggested reading order</summary> 1. ADR 331. 2. `packages/1-framework/0-foundation/contract/src/format-version.ts`: the shared reader, the refusals and their advice, version 0. 3. `packages/1-framework/3-tooling/migration/src/formats/`: one unit per version of `migration.json` and ref files. 4. Each family's contract serializer base, and the strict contract validators (`packages/2-sql-family/1-core/contract/src/validators.ts`, `packages/2-mongo-family/1-foundation/mongo-contract/src/contract-schema.ts`). 5. The SQL operations reader, `packages/2-sql-family/9-family/src/core/migrations/operations-reader.ts`, and each SQL target's `read-operations.ts`. 6. The MongoDB operations reader, `packages/3-targets/mongo/1-target/src/core/migrations/mongo-ops-serializer.ts`. 7. The upgrade instructions and script, with tests in `test/integration/test/upgrade-instructions/stored-files-format-version/`. </details> ## How it was verified - **Each parser and printer:** print, parse, same data back. Each refusal and each reading path has a test. - **Strictness:** for each object made strict, a test adds one unknown key and expects a refusal that names its path. A one-off probe added an unknown key at every place in the 368 saved contracts that read: 403 distinct places accepted it before, and only the open places do now. A committed test does the same for every saved SQL `ops.json` of each target. - **Nothing saved stops reading:** tests read every saved `contract.json` and every saved SQL and MongoDB `ops.json`, and fail on an empty list. They exclude, by name, 46 contracts in shapes from before `8.0.0-rc.1`, which the published `rc.25` reader refuses too, and the fixtures of earlier upgrade scripts. Stored contracts under other file names (112, mostly expected-output files of tests) are not in that test; a one-off run read all but one deliberate "before" fixture. - **Older shapes:** each one reads and gives the current shape; a malformed one is refused. For the enum-value mark, the conversion was checked against the `rc.22` runner's code. - **Release-candidate files:** a PostgreSQL and a MongoDB project that `8.0.0-rc.25` wrote are read file by file. The three tests on `main` that give an `rc.25` contract to a client pass. - **The script:** `before` and `after` project trees, a second run, and files it must refuse. - **By hand, with the built CLI, on real `8.0.0-rc.25` PostgreSQL and MongoDB projects with no script run:** `contract emit`, `migration status`, `migration check`, `migration plan` of a change, `db migrate`, `db verify` and a query worked, and only the files the commands wrote moved to version 1. - **By hand, strictness:** an unknown key was planted in each kind of stored file and each kind of place, for both databases. Every strict place refused it, every open place accepted it, the refusal's advice worked when followed, and no file or database changed. A file at version 2 was refused by every command. The first run found two gaps (a snapshot and a column's type parameters were accepted) and three commands that hid or misreported an unreadable file. They are fixed and the fixes confirmed by hand. One fix first went too far, reading every recorded snapshot strictly, which stopped the telemetry app migrating an empty database; review caught it and it was narrowed. - **By hand, older shapes:** a migration with the older enum-value mark was applied to a real PostgreSQL database, with and without a row holding the value, with the same result and messages as the current shape. On SQLite, `"schema": "main"` applied and `"schema": "other"` was refused. On MongoDB, the `sort` of a raw command decided which document changed. - **By hand, repair advice:** every command a refusal advises was run on copies of PostgreSQL and MongoDB projects, in the application's space and an extension's, with and without `--db` and `--config`, and the project checked afterwards with `migration check` and `db migrate`. Four review rounds found advice that refused, had side effects it did not state, or changed a hash; the last round fixed six such findings, and a final check covered only those six. - **The merge queue's integration tests** found that the new read-time check of type parameters reported a refused `varchar(0)` as a generic "contract validation failed". It now reports the data type's own `CONTRACT.TYPE_PARAMS_INVALID`, as main did. The CLI passes that error through as itself, alongside the format version errors. That is a list of codes chosen by name, not a rule for every library error: these are the read errors whose own message tells the user what to change, where the generic wrapper's advice (emit again) would not help. The commands that only list migrations still report it and go on. - **Decision record:** reviewed by fresh agents under the repository's rule for documentation: a cold reader, three times, and a fact checker against the code, five times, with its last findings corrected. - **CI** runs on this branch. The whole package, integration and end-to-end suites were not run locally. - **Independent review,** design and code separately, on each part, in several rounds. ## Alternatives considered - **Refuse a release-candidate file and leave it to the upgrade script.** Rejected while release candidates continue: every user would rewrite every stored file for a change that adds one field, and the conversion path would first run on real files only after `8.0.0`. - **Read a file with no version as version 1, with no "version 0".** Rejected: a reader that assumes a version is what the opening example shows going wrong. Version 0 is recognised by what only a release candidate wrote, and it has an end date. - **Ignore fields a reader does not know,** as Protocol Buffers readers do. Rejected: Prisma would apply a migration while ignoring part of it. - **Let each new field say whether an older release may ignore it.** Rejected: someone would have to judge that correctly for every field ever added. Writing the oldest version that holds the data serves the same case. - **Rewrite an older operation shape with an upgrade script.** Possible before `8.0.0` and not chosen: reading the shapes is small and costs users no step. From `8.0.0` it is not possible, because a migration's hash may not change. - **Read operations strictly when the framework loads `ops.json`.** Not chosen here, because it adds to the framework. See "Known limits". - **Record which Prisma release wrote the file.** Rejected: most releases change no format, so a release number would refuse files an older release reads perfectly well. - **A version string such as `"1.2"`.** Rejected: a reader refuses any version it does not know, so there is no compatible minor step to express. - **A version only in `contract.json`, or one for the whole project.** Rejected: migrations and refs are read on their own, and the files change independently. - **A version inside `ops.json`, by wrapping the array in an object.** Rejected: it would change every migration's hash, and `ops.json` is never read without its `migration.json`. - **Include `formatVersion` in the migration hash.** Rejected: converting a migration to a later format would change its hash. - **Tell a stored file from a contract Prisma built in memory by which fields it has.** A command accepts either. Rejected: a file with no version field at all would be taken for a built contract and accepted. Agent: alexvanhalen-55 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-authored-by: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # packages/1-framework/0-foundation/contract/test/canonicalization.test.ts # packages/3-extensions/paradedb/migrations/20260601T0000_install_pg_search_extension/migration.json # packages/3-extensions/paradedb/migrations/20260601T0000_install_pg_search_extension/migration.ts # packages/3-extensions/paradedb/migrations/20261029T1342_create_pg_search_extension/migration.json # packages/3-extensions/paradedb/migrations/20261029T1342_create_pg_search_extension/migration.ts # packages/3-extensions/paradedb/migrations/20261029T1342_declare_pg_search_extension/migration.json # packages/3-extensions/paradedb/migrations/20261029T1342_declare_pg_search_extension/migration.ts # packages/3-extensions/paradedb/migrations/20261106T1036_find_pg_search_on_search_path/migration.json # packages/3-extensions/paradedb/migrations/20261106T1036_find_pg_search_on_search_path/migration.ts # packages/3-extensions/paradedb/migrations/20261106T1401_install_pg_search_on_search_path/migration.json # packages/3-extensions/paradedb/migrations/20261106T1401_install_pg_search_on_search_path/migration.ts # packages/3-extensions/paradedb/migrations/refs/head.json # packages/3-extensions/paradedb/migrations/snapshots/64d4b64f45a5eed5da75f456d92729b2412d5c23b7d6f01bafaa8bdb542016de/contract.d.ts # packages/3-extensions/paradedb/migrations/snapshots/64d4b64f45a5eed5da75f456d92729b2412d5c23b7d6f01bafaa8bdb542016de/contract.json # packages/3-extensions/paradedb/migrations/snapshots/6640f77ac5c9486512863eceb9d99d4f60f2d21ca29385c62c7744d901b0a3c7/contract.d.ts # packages/3-extensions/paradedb/migrations/snapshots/6640f77ac5c9486512863eceb9d99d4f60f2d21ca29385c62c7744d901b0a3c7/contract.json # packages/3-extensions/paradedb/migrations/snapshots/ed091e3f6c2113d8488b1eac15933b77684d2bec75b6522a15afd4cdc96c369e/contract.d.ts # packages/3-extensions/paradedb/migrations/snapshots/ed091e3f6c2113d8488b1eac15933b77684d2bec75b6522a15afd4cdc96c369e/contract.json # packages/3-extensions/paradedb/src/contract.d.ts # packages/3-extensions/paradedb/src/contract.json # packages/3-extensions/paradedb/test/descriptor.test.ts # test/integration/test/prisma7-source/fixture-extension-packs.ts
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # packages/9-public/@prisma/orm-family-mongo/api.txt # packages/9-public/@prisma/orm-family-sql/api-breaks.json # packages/9-public/@prisma/orm-target-mongo/api-breaks.json
…ive is refused as invalid Rendering the types of a contract read from a file ran the emitter, whose check that the storage hashes to its recorded storage hash throws an internal error, so a placeholder or edited hash reached the user as CONTRACT.TYPES_RENDER_FAILED, which says the types could not be rendered. The file itself is wrong, so renderContractDts now checks the hash first and reports CONTRACT.VALIDATION_FAILED, saying what the hash is, what the storage gives, and how to write the file again. The emitter keeps its internal error for a contract built from source, where a wrong hash is a bug. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…heir storage gives Four suites wrote contract.json files with made-up storage hashes. The MongoDB db sign suite failed, because rendering the types of its contract refuses a hash its storage does not give; the db verify suites and the pgvector db init suite passed only because those paths do not check. Each now derives the hash with computeStorageHash and the family normal form. The db sign test that changed only the hash to model a changed contract now changes the capabilities, and checks the marker records the new profile hash. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rage gets its own message The refusal said the contract failed to deserialize. renderContractDts now returns both hashes in storageHashMismatch, and the refusal says that the contract records one storage hash while its storage gives another, why that happens, and how to write the file again. The error reference names the cause and the commands that meet it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…e capabilities Both profile hashes come from computeProfileHash over the capabilities the contract lists. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ers, not escapes Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…sorted by name The MongoDB normal form orders a collection indexes by name, so the emitted contract lists User_email_idx before User_email_key. The db init case read the live index list, whose order is the server one, so it now compares it sorted by name. 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…hem, db or conn, and sign only what the database provides A contract stores what it requires as requiredCapabilities, each key prefixed db. (the database provides it) or conn. (the connection provides it). Signing succeeds only if the database version provides every db. key, and a key no version provides is refused. The client checks conn. keys against its adapter and driver and warns. Extensions no longer declare capabilities. A stored contract that still has capabilities is refused with a message naming the contract-hash-inputs upgrade script, which now also rewrites the field. Fixtures, fixed hash literals and API records are regenerated for the new field and the hash rules of #31203. The full history of this change is on the branch tml-capabilities-stored-rename-history. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
At a glance
The decision: before
8.0.0, Prisma changes how it computes a contract's hashes, in two ways, and from8.0.0those rules do not change again until Prisma 9. Every existing hash changes once, in this release.A contract has three hashes. The storage hash identifies the database the contract describes: its tables, columns and indexes. The profile hash identifies the database features the contract requires, such as
RETURNING. The execution hash identifies the defaults the client fills in when it writes a row. The storage hash matters most, because Prisma writes it into five places:The marker is a row Prisma keeps in the database to record which contract it matches. A ref names the contract an environment such as production should be at.
The two changes:
storage,capabilitiesorexecution.false,[]and{}, so an index option such as{ "fastupdate": false }was lost from the file, the hash and the database.The cost, once: a project from a release candidate runs a script that rewrites the hashes in its files, and signs each database again with
prisma db sign, which checks that the database matches the contract and records the new hashes in its marker.Why the rules change now, and only now
If a later release computed a different hash for the same contract, all five places above would stop agreeing at once. Migrations would no longer chain from one to the next, saved copies would look edited, and every database would report that it does not match its contract. So within Prisma 8 the rules cannot change. Both defects below would be frozen in with them, so they are repaired now.
Defect 1: the hash covered more than the section
Because the storage hash was computed from a blanked copy of the whole contract, the first change to the file's format version, or a new field in any blanked part, would have changed every hash.
The target and the family were in the input too. A family is a kind of database Prisma supports (SQL or MongoDB), and a target is one database in it (PostgreSQL, MySQL, MariaDB). A hash is only ever compared with hashes from the same project, or from an extension the project declares, and a project has one target. So the target in a hash changed no comparison. Its one effect showed after a project moved between two targets that write the same
storage. MySQL and MariaDB share their type names, so theirstoragecan be identical. After such a move, no migration ended at the new contract's hash, no saved copy was named by it, and the marker no longer matched, so the team had to start its migration history again. The family adds nothing a target does not already say.Defect 2: the rules dropped values the author wrote
The old rule left out every
falseand empty value except at a list of known places. That is right for a family's own defaults. For example, a column'smany: false(the column holds one value, not a list) means the same as nomanyat all. But a value that belongs to the database or to an extension is not a default the family can drop:{ "name": "posts_tags_idx", "type": "gin", "options": { "fastupdate": false } }was written and hashed as
"options": {}, so the migration created the index without the option, and an index with the option had the same hash as one without. A check of every place the old rule fired found these:{ fastupdate: false }{}; the index was created without the option{ isAdmin: false }{}, a filter that matches every documentclusteredIndex: {}backwards: false, where the locale's default istrue{ strict: false }{ upper: false }falseor empty value inside an entry an extension definesNow the framework leaves out nothing. Each family names the fields it defines as defaults, in one function,
normalizeStorage, which is applied both whenstorageis written and when it is hashed. The full list is in ADR 010.Two smaller repairs
Each of these also changes hashes, so this is their one chance:
falseor leaving it out gives the same hash.What follows from these changes
A contract for the wrong target is caught by checks that name it. Without the target in the hash, nothing about a hash says which target it was for. The hash caught a contract for the wrong target only by accident: a stale MySQL contract used against a database a MariaDB contract had signed did not match the marker, but the error said only that the database did not match, not that the target was wrong. And a stale contract used against a database it had signed itself matched. Explicit checks catch it in every case and say what is wrong:
RUNTIME.CONTRACT_TARGET_MISMATCH);MIGRATION.CONTRACT_SPACE_VIOLATION);db sign,db init,db update,db migrate,migration planandmigration status, refuses an app contract whose target is not the config's, withCONTRACT.TARGET_MISMATCH, the codedb verifyalready reports.contract emit, which is how a stale contract is fixed, is not refused. The commands that change a database had no such check before.Two targets may write the same
storageonly if a migration planned by either one runs on the other, because after a move the project keeps its migrations. MariaDB plans with MySQL's planner, so this holds. A target built outside this repository takes on the same rule. After such a move the storage hashes, migrations, saved copies and refs stay as they are. The profile hash changes where the two targets' capabilities differ, as MySQL's and MariaDB's do, so each database is signed again withprisma db sign.An extension's newest saved copy now follows the installed extension. An extension can ship its own tables and migrations, and Prisma keeps a saved copy of the extension's contract next to the app's, named by its storage hash. A copy already on disk was never rewritten. So an extension whose capabilities changed while its storage did not, or a project that moved from MySQL to MariaDB, kept a copy with the old profile hash or target.
prisma db signrecorded that stale profile hash in the database. Now the copy is replaced when the installed extension's contract differs. This fixed the stale saved copies in this repository's examples.The freeze is held by tests, not by care. Each family keeps saved contracts and their expected hashes as literals in a test. Changing one of those literals is changing the rules.
prisma contract emitrefuses to write astoragethat does not hash to its storage hash, and the commands that render a saved contract's types refuse a contract file whose recorded hash does not match, withCONTRACT.VALIDATION_FAILEDnaming both hashes. Families and targets built outside this repository getassertContractHashes, which recomputes the hashes of their saved contracts and throwsCONTRACT.HASH_MISMATCHnaming each one that differs, because the freeze binds their part of the rules too.Signing a database that only accepts migrations. A database can carry a change policy that allows changes only through migrations, and it refuses
db sign.prisma db sign --forceoverrides that one refusal for the upgrade. It still checks that the database matches the contract, changes no schema, and keeps the policy. No error message suggests it; only the upgrade instructions do.For users of a release candidate
A project that starts on the release this ships in is not affected. A project from an earlier release candidate keeps reading its files and running queries (#31200, merged, made later releases read those files). But the commands that compare the contract with a database refuse until it follows the upgrade instructions. Extensions have their own version of the instructions.
prisma contract emit, in either order. A run of the script that stops partway is finished by running it again.prisma db sign --no-advance-ref, then runprisma db migrate. The flag stopsdb signfrom writing a ref file into the deploy's checkout. Add--forcewhere the database allows only migrations.Two effects users will see:
prisma migration statusno longer shows the earlier migrations as applied. The database's list of applied migrations holds their old hashes. Nothing is applied again, becausedb migrateworks from the marker.The instructions also cover a value the release candidate dropped, such as the index option above.
contract emitwrites it back, so the contract now really differs from the database. The script lists each such contract, and the change ships as a migration; for an index option, whichprisma migration plancannot change in place, the instructions give a hand-written one. They also cover a database the deploy did not reach in time: it is signed at the last migration it applied, whichdb signtakes by that migration's directory name.Framework changes that need your agreement
The repository's rules say changes to
packages/1-frameworkneed the reviewer's explicit agreement. These change what a family, target or tool built on the framework must call or implement:ContractSerializergets one required member,normalizeStorage, in place of three optional hooks, so every family supplies its own normal form. If it stayed optional, a family that supplied none would write and hash its content with no normal form, and nothing would tell it.computeStorageHash,computeProfileHash,computeExecutionHashandbuildExecutionSectionno longer taketargetortargetFamily.assertContractHashesand its errorCONTRACT.HASH_MISMATCHare published.writeContractSnapshottakeswhenPresent: 'keep' | 'replace', so the step that writes an extension's newest saved copy can replace it. A replacement that fails and cannot put the old copy back throws a new error,MIGRATION.CONTRACT_SNAPSHOT_REPLACE_FAILED, which names where the old copy was left.The CLI's behaviour also changes, in the framework's CLI package:
db sign --force, the refusal incontract emit, and the target check in the commands that load the project's migrations and extensions. None of these changes adds family or target vocabulary to the framework.How it was verified
8.0.0-rc.25projects (one MongoDB, three PostgreSQL). Its output matched the package's for every contract, saved copy, migration and ref. Every contract, saved copy and migration this release writes was recomputed and agrees. The release-candidate fixtures keep their old hashes on purpose.db sign,db init,db migrate,migration plan,db verifyin both families, the extension loader, and a move from MySQL to MariaDB with an extension whose saved copy is stale.8.0.0-rc.25itself emitted, planned and migrated, in both orders, interrupted at every point, and run twice. By hand, on real8.0.0-rc.25PostgreSQL and MongoDB projects and databases: both orders; a project withfastupdate: false, ending with the option set on the index; a migrations-only database with--force, and--forcerefusing a database whose schema does not match; a database one migration behind.Known gaps
Recorded in the project's follow-up list:
oneOf. Sorting them could make the planner propose changing a validator that is already right in a live database, so they were left. After8.0.0that order is frozen until Prisma 9.API changes
No application source code changes. These are for authors of a family, a target, an extension or a tool built on the toolchain. Each package's
api-breaks.jsonrecords its breaks against8.0.0-rc.25.The changed exports
@prisma/orm-framework: newassertContractHashes,AssertContractHashesOptions,SavedContractHashesandHashedContractSections.ContractSerializerhas one requirednormalizeStorage(typeNormalizeStorage) in place of the optionalshouldPreserveEmpty,sortStorageand hash hooks.CanonicalizeContractOptionsand the storage hash's arguments follow, and the hash functions andbuildExecutionSectionno longer taketargetortargetFamily. Removed with the dropping rule:createPreserveEmptyPredicate,matchesPathPattern,PathPattern,PreserveEmptyPathSegment,PreserveEmptyPredicateandStorageSort;createStorageSortnow orders by name, then content.@prisma/orm-family-sql:sqlContractCanonicalizationHooksis replaced bynormalizeSqlStorageandnormalizeSqlDomain, on a new entrycontract/normal-form.SqlContractSerializerBasesuppliesnormalizeStorage.@prisma/orm-family-mongo:mongoContractCanonicalizationHooksis replaced bynormalizeMongoStorageandnormalizeMongoDomain, oncontract/normal-form;MongoContractSerializerBasesuppliesnormalizeStorage.@prisma/orm-postgres,@prisma/orm-mysql,@prisma/orm-mariadb,@prisma/orm-sqliteand@prisma/orm-mongo: each re-exports the changed entries:contract/hashingchanges, andfamily-contract/normal-formreplacesfamily-contract/canonicalization-hooks.@prisma/orm-target-postgres:PostgresContractSerializerno longer overrides which empty values are kept.@prisma/orm-target-mysql,@prisma/orm-target-sqliteand@prisma/orm-target-mongo: each contract serializer inheritsnormalizeStoragefrom its family's base.@prisma/orm-toolchain:prisma db signgains--force(DbSignOptions,ExecuteDbSignOptions,ExecuteDbSignSuccess).EmitOptionstakes the family'snormalizeStorage.createSnapshotContentVerifierandDescriptorSelfConsistencyInputstakenormalizeStorage, andSnapshotCanonicalizationHooksgoes, because MongoDB snapshots are now checked like SQL ones.writeContractSnapshottakeswhenPresent.renderContractDtsrefuses a contract file whose recorded storage hash does not match its storage, and its failure result carries the two hashes in an optionalstorageHashMismatch.@prisma/orm-extension-supabase: no export changes; its bundled contract has new hashes, so the hash literal types in itsapi.txtchanged.Reviewing the diff
A suggested reading order
About 1,400 of the changed files are the repository's own contracts, migrations, saved copies and refs, rewritten with new hashes. Read the rest in this order:
packages/1-framework/0-foundation/contract/src/hashing.tsandcanonicalization.ts: the new inputs, and a canonicalizer that only sorts.normal-form.ts, inpackages/2-sql-family/1-core/contractandpackages/2-mongo-family/1-foundation/mongo-contract, with their tests.hash-rules.fixed-answers.test.ts.enrichContractin the CLI and the SQL contract builder, where the profile hash gets the contract's capabilities.contract-space-aggregate-loader.ts, and the snapshot replacement incontract-snapshot-store.ts.db sign --forcein the CLI.test/integration/test/upgrade-instructions/contract-hash-inputs/.Two existing tests changed their expectations. The end-to-end test of a project exactly as the last release candidate left it keeps its assertions; its comment now says a database that release candidate signed needs the upgrade steps. Two examples expect foreign keys and MongoDB indexes in the sorted order.
The sign-off check cannot read a pull request of more than 250 commits, so the earlier history was squashed into one commit; it is kept on
ga-compat-hashes-backup-pre-squash.Alternatives considered
On the hash input:
storage. A contract for the wrong target is better caught by a check that names the mistake than by a hash that only says the database does not match.storagedifferently.On what goes into each section:
falseand empty always mean absent inside values a family does not own. Rejected: a convention nothing checks, put on outside authors, where a violation gives two different contracts one hash.8.0.0, so the rules would change twice and every project would be signed twice.On moving existing databases:
migration statuskeeps its history. Rejected: a write to every database's history table only for whatmigration statusdisplays; nothing reads that list to decide what to apply.db signfrom the change policy. Rejected: signing could then hide, on any database, that it left its migration history.--forcekeeps that a deliberate act, and the flag stays available for recovering a database the upgrade did not reach.Agent: alexvanhalen-55
🤖 Generated with Claude Code