fix(data): correct version-upgrader self-service guidance + reject corrupt stamps - #188
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.versionnow derives fromentries.length - 1. An agent/human obeying it would re-add adatabaseVersionresource, 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").data-lit-todo versioning template carried the same dead reference — it's the file every versioned app copies from, so the stale line propagates.
readSchemaVersionsaccepted a corrupt null/missing stamp as version 0 (create-database.ts).Number(value ?? 0)— andNumber(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 absentschemaVersionsblock 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).version-entryhandler doc overstated its guarantee. It claimed the handler "sees a known shape for every component" — false under a scoped/split load, wherecreate-version-upgraderstages 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.🤖 Generated with Claude Code