Skip to content

Schema Versioning & Evolution #99

Closed

Description

@nockawa

Goal

Enable safe, incremental schema changes across database lifetimes without data loss or silent corruption. When a component's struct definition changes (fields added, removed, reordered, types widened, or types changed), Typhon should detect the mismatch, auto-resolve compatible changes, and support user-defined migration functions for breaking changes.

Current State (Unsafe)

Today, RegisterComponentFromAccessor<T>() blindly trusts the runtime struct — no validation against persisted metadata. If the struct layout changes between sessions, the result is silent data corruption or crashes. FieldIds are assigned by declaration order, so inserting a field shifts all subsequent IDs and breaks B+Tree index associations.

Design Reference

  • Schema Versioning Design Series (5-part design)
  • Decision log: D1-D8 (FieldId hybrid assignment, PreviousName, eager migration, chunkId preservation, safe type widenings)

Architecture

Layer 4: Operational Tooling  — Schema history, dry-run, tsh commands
Layer 3: Migration Functions  — User-defined transforms, migration registry
Layer 2: Compatible Evolution — Add/remove/reorder/widen fields, add/remove indexes
Layer 1: Schema Validation    — SchemaDiff engine, reopen-time checks, error reporting
Layer 0: FieldId Stability    — Persistent name-based assignment, PreviousName, dense array

Sub-Issues (5 Phases)

Phase 1 — FieldId Stability (Foundation)

Phase 2 — Schema Validation (Safety Net)

Phase 3 — Compatible Evolution (Automatic Changes)

Phase 4 — Migration Functions (User Transforms)

Phase 5 — Operational Tooling (Production Support)

Activity

  1. moved this to Ready in Typhon devon Feb 26, 2026
  2. moved this from Ready to In Progress in Typhon devon Feb 26, 2026
  3. moved this from In Progress to Review in Typhon devon Feb 26, 2026
  4. added a commit that references this issue on Feb 26, 2026
  5. moved this from Review to Done in Typhon devon Feb 26, 2026
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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions