Skip to content

Record each release's built-in shape and classify every change by what it requires of existing databases #4222

Closed

Description

@malibio

Overview

Nothing records what changed in NodeSpace's built-in shape from one release to the next. A database from an earlier build is either refused (a core type or table differs), reconciled silently (seeded content), or opened with the old behaviour (an index, trigger, relationship or structural rule changed, which the shape check does not read). No record says which changes fall in which group, or what carrying a database forward would require. This issue adds that record: a generated snapshot of the built-in shape, a hand-classified change log that a gate keeps complete, and a release check that keeps the costly entries decided.

It does not move or rewrite any data and does not change what opening a database does. It is the input a later decision on backward compatibility needs. Decision and design: ADR-104 and Built-In Shape Record.

Problem Statement

What exists today:

  • check_shape (core/src/db/schema.rs) refuses a database whose table columns differ from this build's; an existing table is never altered. A changed index or trigger body is not detected, because IF NOT EXISTS leaves the old object in place.
  • core_type_shape.rs refuses a database whose core-type fields differ from the ones this build declares. It reads fields only (not relationships or structural rules), from the schema nodes themselves, because "nothing on disk records" a version. A user may add namespaced fields, extend extensible enums, change user-protected fields and change context paths without tripping it.
  • Core type schemas are written when a database is created and never rewritten. Seeded skills, Plays, queries, guidance, links and context paths are reconciled by fixed id on every open, per aspect: an unedited aspect is replaced, an edited one is kept and a shipped change to it is recorded as pending for the user to keep or take (ADR-072, ADR-094 §8). A deleted seed comes back on the next open.
  • schema_version on schema nodes is 1 everywhere and is read only by the Play validator.
  • types:check, node-types:check and the prompt snapshots compare Rust, TypeScript, docs and prompts within one build. Nothing compares one release with the next.
  • A migration runner once existed (SQLite DDL migration runner (pre-launch requirement) #1320) and was collapsed into a single bootstrap (Collapse the five-step migration ladder into a single current-shape schema bootstrap #2688). No issue tracks a record of shape changes across releases.

Without a record, a change that needs user data to move looks the same as one that is purely additive until a user's database is refused, and a change the shape check cannot see is never noticed.

Proposed Solution

1. A shape snapshot, generated

JSON produced from the type registry, core_schemas.rs and the table DDL. It holds everything the build ships and has no exclusions: the full DDL (tables, columns, indexes, triggers); each core type's fields, field types, enum values, protection, extends, relationships, structural rules and context paths; and, for seeded content, the shipped fingerprint of each aspect of each seed id, computed by the function seed reconciliation already uses (no second fingerprint). A canonical hash covers the whole.

  • Two copies. A working snapshot is one file, updated by every change that alters the shape and checked by the gate. A release copy is made from it at release time, committed and never changed.
  • A database fingerprint is a separate function: one shared normaliser applied to a database's contents, leaving out what a user may legitimately change (the exclusions core_type_shape.rs makes). For a database this build created, it equals the fingerprint of the working snapshot.
  • Embedded in the binary only if the prototype in §4 passes. Nothing reads it at runtime otherwise.

2. A change log, classified by hand

One entry per changed key. Each entry records:

  • key: a stable path into the snapshot (type and field, table and column, index, trigger, seed id and aspect)
  • area: table shape, core schema, seeded content, user-data bucket, derived data, wire/tooling, local app state, settings
  • class: additive (nothing needed), reconcile (the seed system covers it), rebuild (regenerated by the system), stale (an older database opens and keeps the old behaviour), migrate (existing rows must change), refuse (an older database cannot be opened)
  • for seeded content: which aspect changed (config, guidance, context paths, links), whether users who kept an edit are affected, and whether the change must not wait for a user's keep-or-take decision
  • whether a user could have produced the same state themselves
  • for migrate: what data is affected and what would have to change
  • for migrate, refuse, stale, at release time: a decision, adr: ADR-<number> or accepted_reset_required

The format is machine-readable (structured fields and one line of free text).

3. A gate

Regenerates the snapshot, computes the changed keys against the committed one, and fails on a changed key with no entry and on an entry for a key that did not change. The generator prints the key-level difference as a log skeleton with the class unset, so the hand work is classification only. It runs where types:check and node-types:check run (test:changed and the merge gate), with scripts/gate-scope.ts aware of the paths, and reads no other repository.

3b. A release check

bun run release regenerates the working snapshot, writes it as the release's copy, compares it with the previous release's copy, prints the entries between them grouped by class (and into the release notes), and refuses while any migrate, refuse or stale entry has no decision. The decision's form is validated; the record is not looked up, so the check needs no other repository. It runs before the version bump, so a refusal leaves nothing to undo. Until a database has users, the answer to all three classes is a database reset, and accepted_reset_required says so.

4. Settle the open points first

Recorded answers (ADR-104 and the architecture page carry the evidence):

  • A seed that stops shipping: neither removed nor recorded as pending today; classified migrate (remove if unedited, keep and record as pending if edited, if a mechanism is ever chosen).
  • Switching a Play off: counts as an edit to its configuration. The implementation confirms with a test that the switch stamps the modified mark.
  • Identifying a database: the fingerprint identifies the shape, not the release; no stored version. A fingerprint matching no committed snapshot is an unknown shape, which is not refuse. Prototype behind a test.
  • Earlier snapshots: history starts at the current shape. No backfill from tags unless a classification needs it.

Documentation

Written in nodespace-docs:

Still to do with the implementation: the decision tree and the migration-ban paragraph in AGENTS.md (recording and classifying a change is not migrating it); a pointer in creating-node-types.md; a scope note at the top of architecture/schema-migration-strategy.md (it covers cloud tenant schemas, not the local store). Related: ADR-072, ADR-094 §8, ADR-086, ADR-078.

Architecture Impact

AGENTS.md bans migration strategies and any code that carries existing rows from an old shape to a new one, and core_type_shape.rs states that NodeSpace does not migrate databases. This issue respects both: it records and classifies changes and moves no data. The migrate class exists so that a later decision on backward compatibility has an accurate list of what would have to move. Lifting or narrowing the ban, and choosing a migration mechanism, is a separate decision and needs its own decision record first.

Acceptance Criteria

  • ADR-104's four open points are confirmed with evidence from the implementation (the Play switch test, the identification prototype), and any answer that changes is amended in the ADR and the architecture page.
  • The snapshot generator produces the same bytes on two runs, and a test covers that.
  • The fingerprint of a freshly created database equals the fingerprint of the working snapshot. A test mutates a table, a core field and a seed in both directions: a shape change moves the fingerprint, and a namespaced field or an added enum value does not.
  • An index change, a trigger change and a relationship change each alter the snapshot and each require an entry (the stale case is covered by a test).
  • A snapshot of the current shape is committed. It is embedded in the binary and readable from the daemon crate only if the identification prototype passes.
  • A change-log format exists with the fields above, including a stable key, and a test validates every entry against it.
  • The gate fails on a changed key with no entry and on an entry whose key did not change, and passes when entries match. Both directions are tested.
  • The generator prints the changed keys as a log skeleton with the class unset.
  • The gate runs in test:changed and the merge gate, and reads no other repository.
  • bun run release writes the release copy, prints the entries since the previous release grouped by class, includes them in the release notes, and refuses on an undecided migrate, refuse or stale entry. Tests cover the refusal, the adr path and the accepted_reset_required path, and that it runs before the version bump.
  • The node type sequence names the change-log step, and the AGENTS.md decision tree and migration-ban paragraph carry the pointer.
  • No existing behavior of opening a database changes; the existing shape-check tests pass unchanged.
  • Code passes bun run quality:fix; bun run test:changed passes.

Technical Specifications

Reference Files

  • packages/core/src/db/schema.rs - create_schema, check_shape, expected_shape, and the DDL source (indexes and triggers included in the hash)
  • packages/core/src/db/core_type_shape.rs - the shape comparison and what a user may change
  • packages/core/src/models/core_schemas.rs - the seeded core schemas
  • packages/core/src/models/seed_update.rs - SeedAspect, the pending record and the aspect fingerprint
  • packages/core/src/markdown/mod.rs - SeedTier, seeded-node reconciliation
  • scripts/gate-scope.ts, scripts/check-node-types-doc.ts - how an existing generated-artifact check is wired into the gates
  • scripts/release.ts, scripts/release.test.ts - where the release check runs

Implementation Details

Keep the snapshot and change log in this repository, not in nodespace-docs; the gate reads them and the docs repository is being frozen. Follow the existing pattern for generated artifacts: generated by a script, committed, compared by a check. The gate and the release check do not read the docs repository.

Non-Goals

Related Issues

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. mstomar125 commented on Nov 3, 2026

    @mstomar125
    Contributor

    Picking this up (sweep drain).

  3. mstomar125 commented on Nov 6, 2026

    @mstomar125
    Contributor

    Status check against main: the snapshot generator, current snapshot, 0.3.11 snapshot, change log, identification prototype and the gate are merged (the shape record change and the 0.3.11 snapshot). The one acceptance item still open is the first: ADR-104's four open points are still marked Proposed in the ADR, so they are not yet confirmed with evidence and amended. That needs an architect answer on the four points (seed that stops shipping, switching a Play off, identifying the release from the database, earlier snapshots from tags). Keeping this open until then.

  4. mstomar125 commented on Nov 6, 2026

    @mstomar125
    Contributor

    Done. The shape record is on main (generator, current snapshot, 0.3.11 snapshot, change log, identification prototype, and the shape:check gate that the merge gate runs), and the last open acceptance item is now met: ADR-104's four open points are confirmed with evidence and amended in the ADR and the architecture page (docs, merged 4e026d6).

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions