Skip to content

fix(ecs): retire deleted persistent entity ids instead of reusing them; bump 0.10.37 - #285

Closed
krisnye wants to merge 1 commit into
mainfrom
krisnye/entity-id-generations
Closed

krisnye wants to merge 1 commit into
mainfrom
krisnye/entity-id-generations

Conversation

@krisnye

@krisnye krisnye commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Retires deleted entity ids in persistent quadrants (0 document, 2 settings) instead of immediately reusing them through the LIFO free list, so stale entity references fail locate/read instead of silently aliasing a newly created entity.

Design

  • Persistent quadrants (0, 2): Allocate monotonically from nextIndex++ and retire deleted slots (-1), never reusing them on normal create/insert. Fits the existing 32-bit I32.schema Entity representation, archetype id columns, and @adobe/data-persistence on-disk layout without changing wire or storage widths.
  • Non-persistent quadrants (1, 3): Keep immediate LIFO free-list reuse so transient/ephemeral entities remain memory-bounded.
  • Undo/redo & speculative rollback: TransactionInsertOperation records optional entity?: Entity so undo-of-delete and redo-of-insert restore the original entity id via an internal RESTORE_ENTITY path; speculative rollback paths (create-rebase-replay-applier, roll-forward-concurrency, immediate-concurrency, and transaction error rollback) unwind the latest allocation via internal REWIND_DELETE to preserve cross-peer id determinism.
  • Snapshot compatibility: Backward compatible with no ECS_SNAPSHOT_VERSION bump. Loading legacy snapshots that carry a non-empty freeListHead into a persistent quadrant resets freeListHead = -1 so previously freed slots stay retired and post-load allocations advance monotonically past nextIndex.

Verification

  • pnpm run lint — passed
  • pnpm run typecheck (all 34 workspace projects) — passed
  • pnpm --filter @adobe/data run test — 303/303 files, 3679/3679 tests passed
  • pnpm --filter @adobe/data-persistence run test — 37/37 files, 240/240 tests passed (node + chromium)

…m; bump 0.10.37

Co-Authored-By: OpenCode <noreply@opencode.ai>
@krisnye

krisnye commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

This is not the right direction. We will have to look at generation counters on entities instead.

@krisnye krisnye closed this Nov 23, 2026
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