Struct EntityLifecycleRun
One spawn or destroy run in EntityLifecycle — the trace-side index behind the Workbench entity lens (#620,
design §4.4). Sorted by (TickNumber, FirstEntityKey) so a tick range resolves by binary search.
public struct EntityLifecycleRun
- Inherited Members
Remarks
A run, not a row per entity. Transaction.SpawnBatch reserves all its keys with one Interlocked.Add and stamps one routing id,
so a batch's ids are exactly (FirstEntityKey + n, RoutingId) for n in [0, Count). The range is therefore an *exact*
representation, not a summary, and a 200K bulk load costs one 24-byte row instead of 200K of them. Single spawns and destroys are runs of length 1.
Keys, not raw ids. A raw EntityId is (key << 16) | routingId, so consecutive entities are 65,536 apart in raw value but
adjacent in key. Storing the key is what makes the run contiguous.
Two archetype identifiers, deliberately. RoutingId is the durable per-database id embedded in every entity id; ArchetypeId is the per-process catalog id the trace's archetype table is keyed by. They are usually *different numbers for the same archetype* — design §5.3's landmine. Spawns know both. Destroys know only the routing id (the wire event carries just the entity id), and set ArchetypeId to UnknownArchetypeId rather than guessing: a fabricated catalog id would join to the wrong archetype and look plausible doing it.
Fields
ArchetypeId
Per-process catalog archetype id (matches ArchetypeRecord.ArchetypeId), or UnknownArchetypeId for destroys.
public ushort ArchetypeId
Field Value
Count
Number of consecutive keys in the run. Always >= 1.
public uint Count
Field Value
FirstEntityKey
First entity key in the run. The n-th entity's raw id is ((FirstEntityKey + n) << 16) | RoutingId.
public long FirstEntityKey
Field Value
Kind
Spawn or destroy — see EntityLifecycleKind.
public byte Kind
Field Value
RoutingId
Durable per-database routing id — the low 16 bits of every entity id in this run, and the one identifier safe to join on directly.
public ushort RoutingId
Field Value
TickNumber
Tick number the run was recorded in. Zero for pre-tick activity — bulk loads during setup land here, and are kept, not dropped.
public uint TickNumber
Field Value
UnknownArchetypeId
Sentinel for ArchetypeId when the source event did not carry a catalog id (every destroy).
public const ushort UnknownArchetypeId = 65535
Field Value
_reserved0
Reserved; zero on disk. Keeps the record at 24 B and 8-byte aligned.
public byte _reserved0
Field Value
_reserved1
Reserved; zero on disk.
public ushort _reserved1