Skip to content

SchemaKit: snapshot format v2 and CodoMetis: annotation keys ship in 11.0.0; the 5.x format is read forever (D11) #9

Open
1 of 1 issue completed

Description

@CaffeinatedCoder

2026-11-12: #50 and #51 are merged. A format version that is not a whole number, or is lower, is refused for what it is, and a kind holds no white space and no control character. Also merged (#56, closed #52): a property stored twice ("nullsDistinct":false,"nullsDistinct":true) is refused before anything is read, with its own message; until then two equal values were read, and two different ones were refused with the message for a Read that changed the declaration. Still open here: the 5.x readers and the round trip of a real 5.x snapshot (#18, #28), and the migration guide's statement on the empty migration.


From #45, 2026-11-11: the v2 format is written and read. One annotation per declaration, CodoMetis:{Owner}:{hash}; the value is {"$kind":…,"v":2,"r":…,"name":…,…} in a fixed order, written by hand. The key is over the kind (the case of the union) and the explicit name for a named declaration, and over the kind and every non-operational property for an unnamed one; the kernel computes it from what the declaration writes. Nothing is omitted but a null and the reader has no default; an unknown v, a property nothing read and a reader that builds anything but the declaration that was stored are refused (the last since the analysis of #46: what was read is written again and its JSON must equal what was stored). The round trip through a real generated snapshot compiled with Roslyn holds on Npgsql, SQL Server and SQLite. The stamp is not the version marker: CodoMetis:SchemaKit = 1 stays a mark of presence, and the format version is v on each declaration, so one snapshot can hold two formats while it is rewritten. That reverses what I recommended before writing the store; it is cheap to change until preview.1. From #49, 2026-11-11: strings are written by one fixed rule. ", \, everything below U+0020, and U+0085, U+2028 and U+2029 are escaped; everything else is written as itself, so a key is the same on every runtime. A string that is not well-formed UTF-16 is refused, and a property name is ASCII letters, digits and _. Still open here: a kind is not checked like an owner (#51); the wording of the format-version refusal (#50); the 5.x readers and the round trip of a real 5.x snapshot (#18, #28), and the migration guide's statement on the empty migration.


From #40, 2026-11-11: one annotation is already fixed. The wiring stamp is a model annotation, CodoMetis:SchemaKit with the value 1, and EF writes it into every snapshot beside Relational:MaxIdentifierLength. Its name and value are therefore part of the snapshot format this issue freezes at 11.0.0, and the value must never follow the package version, or every upgrade would rewrite every snapshot. If the format wants a version marker, this annotation's value is the place to decide it, before 11.0.0.


Decided 2026-11-11 (plan, sections 3.4 and 3.5). The key stays CodoMetis:{Owner}:{hash}, but the hash is over (kind, explicit name) for a named declaration and over the full canonical content for an unnamed one, and Declare never replaces: the draft's identity (Method|Targets|Where) let pg.Unique(x => x.Code) followed by pg.BTree(x => x.Code) overwrite the unique index without an error. Redeclare is the only replacing path and is atomic. Expressions are stored as provider-specific templates written at declaration; the resolution layer carries a per-declaration epoch r, and a golden corpus fails the build when a renderer changes without a new one. A snapshot lock stays possible for an 11.x minor.


Problem

Annotation keys and the snapshot format end up permanently in consumers' model snapshots and migrations. ROADMAP.md 5.5 (D11) plans one annotation per declaration, under the CodoMetis: prefix (owner-branded, so it survives any product name).

Changing the format in an 11.x minor would give every consumer an empty migration on a minor upgrade, which a CI gate on has-pending-model-changes reports as a failure. So the change belongs in 11.0.0.

Change

Done when

  • Round-trip tests pass for v2 and for a real 5.x snapshot (compiled with Roslyn, as SnapshotRoundTripTests does).
  • The migration guide states up front the one empty migration the format change produces, if it produces one.
  • It ships in 11.0.0.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added this to the 11.0.0 milestone on Oct 19, 2026
  2. added
    enhancement
    package/core
    area/migrations
    on Oct 19, 2026
  3. CaffeinatedCoder commented on Nov 14, 2026

    @CaffeinatedCoder
    OwnerAuthor

    From the architecture debate of 2026-11-14 (#111, #114): a policy for a preview's snapshots is owed before preview.1.

    DeclarationCodec refuses every v but its own. If the stored form of a template changes in preview.2 (#114), a preview.1 snapshot is then either read by a reader for the old v, with the old resolution epoch, or declared unreadable. Two things a reader cannot give back: a converter's effect and a raw dependency, since neither was stored. And an unreadable snapshot blocks migrations add and migrations remove until it is scaffolded again, while the database built from it keeps the old SQL: that takes a corrective migration, not only a new snapshot.

    To decide, and to say in preview.1's notes: previews promise nothing about their snapshots and their databases are disposable, or each preview reads the one before. The permanent promise (the stamp, the keys, the 5.x format read forever) starts at 11.0.0 either way.

  4. CaffeinatedCoder commented on Nov 16, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Decided 2026-11-16 by the maintainer: previews promise nothing about their snapshots. A later preview may refuse a preview's snapshot, or read it differently, and ask for the migrations to be scaffolded again. A database built from a preview is one to throw away: a new snapshot does not change the SQL a database was built with, so no preview owes a reader for an earlier preview's v or a corrective migration. The permanent promise (the stamp, the CodoMetis: keys, the 5.x format read forever) starts at 11.0.0, as this issue says. preview.1's notes and the READMEs say it (the issue linked below). This issue stays open for what ships in 11.0.0.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationsenhancementpackage/core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions