Skip to content

fix(data): fromData resets nonPersistent space to defaults#142

Merged
krisnye merged 2 commits into
mainfrom
knye/fromdata-clears-nonpersistent
Jul 14, 2026
Merged

fix(data): fromData resets nonPersistent space to defaults#142
krisnye merged 2 commits into
mainfrom
knye/fromdata-clears-nonpersistent

Conversation

@krisnye

@krisnye krisnye commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Description

db.fromData() restored only the persistent side of the store and left the negative-ID nonPersistent space (nonPersistent resources + entities) holding the loading store's pre-load live values. This is inconsistent with db.reset(), which reverts nonPersistent state to its schema defaults.

Because nonPersistent data is never captured by toData() (only its archetype componentNames, never data), the only correct value after a load is the default. Leaving the stale live value leaks it across a same-instance load — e.g. a Save-As → Load in the same session keeping every pre-load blob: URL forever (the downstream FFP "video clips not visible after reopen" thumbnail bug).

Fix

core.fromData now resets the nonPersistent location table and zeroes nonPersistent archetype rows before restoring the persistent side (which is fully overwritten anyway). The store layer then re-seeds nonPersistent resource defaults via its existing rowCount === 0 re-init guard. This mirrors reset() exactly.

Why existing tests missed it

Every fromData test loaded a snapshot into a freshly-constructed store, whose nonPersistent resources were already at their defaults — so the assertions passed vacuously, not because fromData reset anything. Added red-green coverage that loads into a populated (non-fresh) store:

  • a nonPersistent resource holding a non-default value reverts to default after load
  • a nonPersistent entity present before the load is cleared

Version bumped to 0.9.78.

Testing

  • vitest run --project node — 1343 tests pass; new populated-store cases are red without the fix, green with it.

krisnye and others added 2 commits July 13, 2026 16:53
…0.9.78)

`db.fromData()` restored only the persistent side and left the
negative-ID nonPersistent space (nonPersistent resources + entities)
holding the loading store's pre-load live values — inconsistent with
`db.reset()`, which reverts them to defaults. Because nonPersistent data
is never captured by `toData()`, the only correct value after a load is
the default; leaving the stale value leaks it across a same-instance
load (e.g. Save-As -> Load keeping dead blob URLs forever).

Existing tests missed this because every fromData test loaded into a
freshly-constructed store, whose nonPersistent resources were already at
their defaults. Add red-green coverage that loads into a populated
(non-fresh) store.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Run `pnpm run bump` so the root and every workspace package move to
0.9.78 in lockstep, rather than hand-editing @adobe/data alone.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krisnye krisnye merged commit d1c6a31 into main Jul 14, 2026
4 checks passed
@krisnye krisnye deleted the knye/fromdata-clears-nonpersistent branch July 14, 2026 02:44
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