Skip to content

Store: fix the unresolved review comments from #6053 - #6060

Merged
William Wong (compulim) merged 9 commits into
feat-new-storefrom
copilot/6053-write-failing-test-cases
Nov 20, 2026
Merged

William Wong (compulim) merged 9 commits into
feat-new-storefrom
copilot/6053-write-failing-test-cases

Conversation

Copilot AI commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This PR fixes the unresolved review comments from #6053 (new graph store) in packages/store. Each comment first got a failing test, then the source fix. Where there is a reference behaviour, the test shows it next to ours: JSON.parse(JSON.stringify(value)) for JSON values, and native Set for set operations.

JSON values, createNode, deepFreeze

  • JSONValue.ts: unbox now detects boxed primitives by checking for their internal slot (valueOf.call inside try/catch), not with instanceof. Spoofed prototypes and boxes from other realms are now handled correctly.
  • createNode.ts: properties are read from own data descriptors, so user getters are never called. toFrozenNodeSet now takes the original value.
  • deepFreeze.ts: objects with a null prototype are copied into plain objects instead of being reused. This matches the JSON round-trip.

SetView / FrozenSet / FrozenNodeSet

  • Set-likes with a negative size now throw RangeError, as native Set does.
  • Equality is now based on a key function passed into the constructor. FrozenNodeSet keys by @id.
  • union, symmetricDifference and intersection de-duplicate values from the other set by that key.
  • isSupersetOf no longer returns early based on size. That shortcut was wrong when the other set held duplicates under key equality.

VersionedStorage

  • An Overlay now iterates live through entries/keys/values. If the overlay is committed mid-iteration, iteration continues on the committed version.
  • The writable overlays of FrozenMap/FrozenSet use this instead of copying everything through toMap().

dateCreated precision

  • Sorting uses milliseconds only. Sub-millisecond digits are truncated, as Date does, and children in the same millisecond are sorted by @id.
  • The original dateCreated string is stored unchanged.
upsertDatedMessage(tx, '_:m-a', ['_:c-1'], '2026-01-01T00:00:00.0009Z');
upsertDatedMessage(tx, '_:m-b', ['_:c-1'], '2026-01-01T00:00:00.0001Z');

getSortedPartIdsOf(store, '_:c-1'); // ['_:m-a', '_:m-b'] — same millisecond, sorted by @id

…ed properties in createNode

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@compulim
William Wong (compulim) marked this pull request as ready for review November 20, 2026 00:57
@compulim
William Wong (compulim) merged commit 6598cf5 into feat-new-store Nov 20, 2026
1 check passed
@compulim
William Wong (compulim) deleted the copilot/6053-write-failing-test-cases branch November 20, 2026 00:57
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