Skip to content

fix(data): correct version-upgrader self-service guidance + reject corrupt stamps - #188

Merged
krisnye merged 1 commit into
mainfrom
krisnye/version-upgrader-followup
Aug 26, 2026
Merged

fix(data): correct version-upgrader self-service guidance + reject corrupt stamps#188
krisnye merged 1 commit into
mainfrom
krisnye/version-upgrader-followup

Conversation

@krisnye

@krisnye krisnye commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Small follow-up to the version-upgrader work (#184). Four issues surfaced in a post-merge re-review — three documentation/guidance fixes and one correctness hardening.

Fixes

  1. Drift recipe misdirected toward the removed version resource (assert-versions-match-schema.ts). The self-service recipe printed on schema drift still said "then set the version resource default to N" — but feat(data): ordered version-upgrade system for persisted schemas #184 removed that resource; db.version now derives from entries.length - 1. An agent/human obeying it would re-add a databaseVersion resource, which then registers as an untracked component and re-drifts the guard with no exclusion param left to escape. Dropped the clause (the doc rule already said "there is no resource default to update").

  2. data-lit-todo versioning template carried the same dead reference — it's the file every versioned app copies from, so the stale line propagates.

  3. readSchemaVersions accepted a corrupt null/missing stamp as version 0 (create-database.ts). Number(value ?? 0) — and Number(null) === 0 — meant a present-but-null (or absent) quadrant stamp read as version 0 and silently triggered a full replay from 0 instead of rejecting. Now only a wholly absent schemaVersions block is legacy (0/0); once the block is present, each quadrant stamp must be a finite number or the load rejects non-destructively (live db untouched). Matches the existing non-numeric→reject contract. +2 tests (null stamp, missing quadrant stamp).

  4. version-entry handler doc overstated its guarantee. It claimed the handler "sees a known shape for every component" — false under a scoped/split load, where create-version-upgrader stages only the handler's own quadrant (pickQuadrant). Documented the single-quadrant contract: a handler must read/write only its own quadrant; reading another returns stale/default data under a scoped load and decides the migration wrong. (A runtime read-guard would need store instrumentation on the live path, which we avoid — deferred as a separate option if split-persistence adoption grows.)

Verification

  • pnpm -r run typecheck, pnpm run lint, @adobe/data build — all clean.
  • Versioning suite green (94 tests), including the two new corrupt-stamp cases.

🤖 Generated with Claude Code

…rrupt stamps

Follow-up to the version-upgrader PR (#184). Four small fixes flagged in review:

- The drift recipe (assert-versions-match-schema) still told users to "set the
  version resource default to N" — the resource #184 removed. An agent obeying it
  would re-add a databaseVersion resource, which then becomes an untracked
  component and re-drifts the guard with no exclusion param left. Drop that clause;
  db.version follows the history automatically.
- The data-lit-todo versioning template carried the same dead databaseVersion
  reference; it's the file every versioned app copies from.
- readSchemaVersions treated a present-but-null/missing quadrant stamp as version 0
  (Number(null) === 0) and silently replayed from 0. Only a WHOLLY absent
  schemaVersions block is legacy now; a present block requires a finite number per
  quadrant or the load rejects (live db untouched). +2 tests.
- version-entry's handler doc claimed the handler "sees a known shape for every
  component" — false under a scoped/split load, where only the handler's own
  quadrant is staged. Document the single-quadrant contract: read/write only your
  own quadrant; reading another is a silent stale-data bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krisnye
krisnye merged commit ea29122 into main Aug 26, 2026
3 checks passed
@krisnye
krisnye deleted the krisnye/version-upgrader-followup branch August 26, 2026 06:15
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