Skip to content

PR 1/N: version the Deck schema + migrator at store boundary#5

Merged
karthikmudunuri merged 1 commit intokarthikmudunuri/slidewise-pptx-fidelityfrom
karthikmudunuri/deck-schema-versioning
May 4, 2026
Merged

PR 1/N: version the Deck schema + migrator at store boundary#5
karthikmudunuri merged 1 commit intokarthikmudunuri/slidewise-pptx-fidelityfrom
karthikmudunuri/deck-schema-versioning

Conversation

@karthikmudunuri
Copy link
Copy Markdown
Member

First PR in the integration plan (.context/integration-plan.md). Stacked on top of #4 — review/merge that first.

Summary

Adds a version: number field on Deck and a migrator chain that runs on every external Deck before it enters the editor store. Lets us evolve the persisted schema without breaking hosts that pin an older @textcortex/slidewise.

What changes

  • src/lib/schema/migrate.ts — exports CURRENT_DECK_VERSION = 1 and migrate(input). Walks the MIGRATIONS table forward from the deck's version to current. Throws on bogus input. Throws if the deck was written by a newer Slidewise (host should upgrade rather than silently render a degraded version).
  • Store boundarycreateEditorStore() and setDeck() run migrate() so PPTX import, JSON import, localStorage hydration, host props, and seed all pass through the same gate.
  • Internal constructors stamp versionparsePptx() and seedDeck now emit current-version decks so callers don't need to migrate after.
  • Roundtrip fixtures updated to include the version field.

How future schema changes work

  1. Bump CURRENT_DECK_VERSION.
  2. Register MIGRATIONS[oldVersion] = (deck) => … returning the new shape.
  3. Done — every host that calls setDeck or mounts the editor with a stale persisted deck migrates transparently.

Migrators are append-only and never deleted, since published decks may still be at any historical version.

Test plan

  • npx tsc -b clean
  • npx vitest run — 13/13 (6 roundtrip + 7 new migrator tests)
  • Manually load a PPTX, confirm seed/localStorage hydration unchanged

Adds a `version: number` field on Deck and a migrator chain that runs
on every external Deck before it enters the editor store. Lets us
evolve the persisted schema without breaking hosts that pin an older
@textcortex/slidewise.

  * src/lib/schema/migrate.ts — exports CURRENT_DECK_VERSION (= 1) and
    migrate(input). Walks the MIGRATIONS table forward from the
    deck's version to current, throws on bogus input, throws if the
    deck was written by a newer Slidewise (host should upgrade rather
    than silently render a degraded version).

  * createEditorStore() and setDeck() now run migrate() so PPTX import,
    JSON import, localStorage hydration, host props, and seed all
    pass through the same gate.

  * parsePptx() and seedDeck stamp the current version on output so
    callers don't need to migrate after.

  * Roundtrip test fixtures get the version field.

  * New unit tests for migrate(): v0 → v1 stamping, current-version
    pass-through, future-version rejection, bad input rejection,
    no-mutation guarantee.

Future schema changes register a migrator at MIGRATIONS[oldVersion]
and bump CURRENT_DECK_VERSION; migrators are append-only and never
deleted, since published decks may still be at any historical version.
@karthikmudunuri karthikmudunuri merged commit d9ff772 into karthikmudunuri/slidewise-pptx-fidelity May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant