Repository navigation
Conversation
Collaborator
Author
|
Thanks. I took the preferred option in 8b95069: generations exist in memory only, so neither format changes and no rollout is needed.
|
…ed slots Co-Authored-By: OpenCode <noreply@opencode.ai>
… memory and retire at the last generation Co-Authored-By: OpenCode <noreply@opencode.ai>
…m.exited; derived components removed - Query.create and Query.and make archetype queries (with, not, shared values) and row queries (any value, comparisons, partial structs); every matching site takes one: systems, lookups, render systems, indexes, tables, despawnWhere, entered and exited systems, ecs-persistence selections - Shared-value predicates are a system's filter - System.removed is System.exited; System.entered runs for entities that start matching - Component.derive and the derived trait are removed; within stays - The build follows queries through module-scope consts and imports - ecs-persistence 0.3.0, ecs-architecture 0.7.0 (query file kind) Co-Authored-By: OpenCode <noreply@opencode.ai>
krisnye
force-pushed
the
krisnye/entity-generations
branch
from
November 28, 2026 18:52
8b95069 to
b882e5e
Compare
…y-valued partitions are stored in the i32 form
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds generations to the
@adobe/dataECS entity ids, using the same layout as@adobe/ecs. A stale id that points at a deleted slot, or at a slot that has since been reused, now resolves tonullinstead of the new occupant. Generations exist in memory only: snapshots and the persistence cache keep exactly the 0.10.x format, so no reader or writer needs a rollout.Entity layout (in memory)
entity = slot + generation * 2^32entity & 3,entity >>> 2and theisPersistent/isSharedhelpers are unchanged.2^21 - 1), the slot is retired and never issued again, so an old id can never come back.Entity.nonecarries that last generation, so it can never be a live id.Entity.schemais nowintegerwith a range of 0 toNumber.MAX_SAFE_INTEGER, so live entity columns are stored in aFloat64Array.Entity.noneis nowNumber.MAX_SAFE_INTEGER, and it is still stored as-1.Entity.generationOf,Entity.toEntity(localIndex, quadrant, generation?),Entity.toStoredEntity/fromStoredEntity,Entity.hasEntity,Entity.toStoredSchema,Entity.toStoredValue/fromStoredValue.Stored format: unchanged
ECS_SNAPSHOT_VERSIONstays at 2.toDatawrites entity ids as i32 without their generation. This covers every place a stored entity id appears:idand entity columnsoneOf, objects, arrays)componentSchemas(i32 entity schemas)Columns are copied up to capacity, so the output is byte-for-byte what 0.10.36 wrote. A test checks this against a fixture serialized by 0.10.36.
fromDatawidens stored i32 entity ids to generation 0 and maps a stored-1toEntity.none. Every free slot below the high-water mark starts at generation 1, so a stored reference to an entity that was deleted before the save becomes stale once its slot is reused.Known gap: suppose an entity is deleted and a new one reuses its slot in the same session. A reference to the deleted entity that was already dangling at save time will then point at the new occupant after reload.
@adobe/data-persistencealso keeps its format:numberwith stride 4, orstruct, exactly as before.Undo, rollback and replay
Undo and rollback need ids to come back exactly, so the undo operations now say how to restore them:
Store.claim(entity)makes the next create in that entity's quadrant return exactlyentity.entityset, which brings back the same id.reclaim: true, which puts the slot back at its earlier generation.This keeps undo/redo and the reconciling and concurrency replays deterministic across peers.
Tests
stored-snapshot.test.ts:noneis stored as-1entity-reference-durability.test.ts: entity, nullable, struct and array references round-trip through a checkpoint and through journal replay, and the manifest records i32 storage.claim,reset, retirement at the last generation, generations surviving a snapshot round-trip, and loading a table stored without generations.build,lint,typecheckand their tests locally.@adobe/ecs0.8.0: queriesQuery
Query.create({ with?, not?, where? })andQuery.and(a, b)make queries. A query exposes itswith,notandwhere.Query):wheregives shared components whole values, so it matches whole archetypes.RowQuery):wherematches any component's value:== != < <= > >=comparisons, or partial structs and tuples.Sites
System.createcomponents.query; lookups; render systems;Index.create; readonlytables; ecs-persistence selections.commands.despawnWhere.components.filter.Entered and exited systems
System.removedis nowSystem.exited.System.enteredruns for each entity that starts matching its query, after the sync point applies, and for existing matches when the system is added. Its commands apply at the next sync point. It runs on the world's thread only.Removed
Component.deriveand thederivedtrait;withinstays.Other packages
@adobe/ecs-persistence0.3.0:Selectionis{ query?, resources? }.@adobe/ecs-architecture0.7.0: aqueryfile kind, and thequery-inferredrule.Not yet supported
These are listed in
followups.md:whereon indexes;whereon kernel lookups;Tests and performance
ecs/packages build and pass their tests, including the browser, threads and as-written projects.spawn entered 10Kandshow entered 10K.