Skip to content

store: address review findings in SetView, VersionedStorage, createNode, FrozenNodeSet - #6059

Merged
William Wong (compulim) merged 4 commits into
feat-new-storefrom
copilot/add-test-cases-for-failing-scenarios
Nov 19, 2026
Merged

William Wong (compulim) merged 4 commits into
feat-new-storefrom
copilot/add-test-cases-for-failing-scenarios

Conversation

Copilot AI commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Fixes the outstanding review comments on packages/store. Each comment first got a failing test, then the code fix.

createNode

  • Reads each own data property descriptor once, so a getter can no longer return different values to validation and storage.
  • Compares node-reference sets with isSameIds, i.e. by ID.

SetView (base of FrozenSet and FrozenNodeSet)

  • difference, intersection, isDisjointFrom, isSubsetOf, isSupersetOf, symmetricDifference and union are hand-written using only size/has()/keys(). They no longer depend on native Set.prototype methods, which are missing in Chrome/Firefox 100 and Safari 15.
  • These methods use the receiver's own has(), so FrozenNodeSet matches node references by @id.
  • A code comment explains why core-js-pure is not used:
    • It returns its own Set class, so instanceof Set is false.
    • It copies the receiver into a plain Set, which drops FrozenNodeSet's ID matching, so union() duplicates references.

VersionedStorage: copy on move

  • A Map shared with older versions is never reordered.
    • A deleted key stays in place as a DELETED tombstone.
    • Re-adding a deleted key, moving a key, or piling up too many tombstones copies the head into a new Map.
  • An older version gets its key order by filtering its own map's keys through has(), and caches the result.
  • This fixes:
    • Older snapshots changing order after a delete.
    • Iterators exposing the head Map directly.
    • Delete-then-set not moving the key to the end.
  • Replaces an earlier position-tracking fix: about 270 lines of code instead of about 420, memory per node is the same as before, and benchmarks are roughly the same.
  • Drops the ordered: false option; FrozenSkipList now uses the default storage.

Tests

  • New regression tests for each review comment, in the tests for SetView, createNode, FrozenNodeSet, VersionedStorage, FrozenMap and FrozenSet.
  • One existing FrozenMap expectation is corrected to insertion order (['a', 'b', 'c']).
// Works in browsers without native Set methods, and matches node references by ID.
new FrozenNodeSet(['_:m-1', '_:m-2']).union(new Set([{ '@id': '_:m-2' }, { '@id': '_:m-3' }]));
// → _:m-1, _:m-2, _:m-3

…hods, VersionedStorage ordering and snapshot-safe iteration

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@compulim
William Wong (compulim) changed the base branch from main to feat-new-store November 19, 2026 20:10
@compulim
William Wong (compulim) marked this pull request as ready for review November 19, 2026 20:11
@compulim
William Wong (compulim) merged commit d929d9d into feat-new-store Nov 19, 2026
41 of 44 checks passed
@compulim
William Wong (compulim) deleted the copilot/add-test-cases-for-failing-scenarios branch November 19, 2026 20:27
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.

2 participants