feat: stable EntityIdMapper — rebuild() no longer renumbers (2.4.0 #1, the foundation) #1
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: soulcraft/brainy#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/2.4.0-storage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
metadataIndex.rebuild()previously calledidMapper.clear()which resetnextIdto1and renumbered every UUID by re-insertion order — silently invalidating any consumer that had persisted int-keyed data against the old map. This is the foundation 2.4.0 #2 (vector mmap store), #3 (graph link compression), and #4 (column-store JS↔native interchange) all need.idMapper.clear()inrebuild(). The rebuild already re-iterates every entity viagetOrAssign(uuid), which returns the existing int unchanged for known UUIDs. Stale UUID→int entries for entities no longer in storage persist as harmless memory overhead.clearAllIndexData()— the explicit nuclear recovery path — keeps itsidMapper.clear()call (renumbering is intentional there) and now logs aprodLog.warnmaking it explicit that any persisted int-keyed data is invalidated.EntityIdMapperclass JSDoc with the stability contract: append-onlygetOrAssign, monotonicnextId,remove()leaves permanent holes,rebuild()never renumbers, onlyclear()does.Test plan
tests/regression/entity-id-mapper-stability.test.ts— 5 tests pinning down the contract:clearAllIndexData()is the explicit nuclear path that DOES renumber.Compat / risk
EntityIdMapper's API surface is unchanged; onlyrebuild()'s implementation behavior is.rebuild()and then relied on getting fresh int ids assigned for existing UUIDs are now broken — but no such consumer should exist (the renumber was a bug, not a feature).