Repository navigation
[M1-ECS-01] Entity handle - #16
Merged
Merged
Conversation
First module beyond laige-core (M1 milestone rules): the laige-sim module with the ECS foundation per roadmap/M1-heartbeat.md M1-ECS-01. - laige::Entity: 32-bit handle (16-bit id + 16-bit generation; generation 0 reserved; 65536 slots; documented 2^16 wrap limit) - laige::World: pool-backed entity storage (create/destroy/check/isValid/clear/stats; setup-only allocation; O(1) no-allocation ops; LIFO deterministic slot assignment) - Stale-handle contract: debug assert / release Status(InvalidArgument) + warn-once via the logging facade (ecs/stale_entity_access, ecs/stale_entity_destroy) — never silent (FR-12.3, CORE-008) - Capacity = declared scene budget (G-R3): BudgetExhausted on overflow; InvalidArgument for a >65536 budget at construction (API-008) - entity CTest entry (19 cases incl. the forked-SIGABRT stale destroy and the pinned 2^16 generation wrap); docs/api/entity.md; laige-api.json regenerated Verify: ctest -R entity + full suite green on fresh g++ Debug, ASan, TSan, shared, and Release trees, zero warnings; tools/laige-include-lint OK; api-real-tree green.
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.
Implements M1-ECS-01 · Entity handle (roadmap/M1-heartbeat.md) — the first step of M1, and the first module beyond
laige-core(laige-sim), per the milestone rules.What lands
laige::Entity— the 32-bit handle (FR-1.2, CPP-007): 16-bit slot id + 16-bit generation,static_asserted to exactly 4 bytes. Generation 0 is reserved (the defaultEntity{}is never valid); the 16-bit generation wrap (one slot freed 2^16 times) is documented in the header and pinned by a test (WorldStale.GenerationWrapDocumentedCollision) rather than assumed — the same documented-limit pattern as the M0-CORE-05Pool<T>2^32 case.laige::World— the pool-backed entity storage (create/destroy, no per-op heap):uint16generation +uint8alive flag + pre-allocated LIFO free stack (5 B/slot); the factory is the only allocation; every op is O(1)create()beyond it →BudgetExhausted; a>65536budget is rejected at construction withInvalidArgument(API-008 — the invalid state is unrepresentable)isValid→ false,check()→Status(InvalidArgument)+ warn-once); uses of a stale handle (destroy) assert in debug and returnStatus(InvalidArgument)+ warn-once in release — never silent. Warns go through the logging facade (stable eventsecs/stale_entity_access/ecs/stale_entity_destroy; the facade's rate limit implements the warn-once semantics, LOG-004)EntityStatsaccounting (G-R3 / M1-PROF-01 feed)check()is the access-validation primitive M1-ECS-03's component access builds on — the stale-handle contract stated in this step's Scope is documented here so the next step inherits it.Files
src/laige-sim/CMakeLists.txt,entity.cpp,include/laige/sim/entity.h(new module; static/shared, engine + SimMath policy, single PUBLIC link to laige-core)tests/laige-sim/—entityCTest entry, 19 cases (the three the step names — generation bump on reuse, stale detection, capacity limit — plus LIFO ordering, clear/move, the 65536 boundary, the forked-SIGABRT stale destroy, stats, and the warn-once rate-limit summary via a memory sink)docs/api/entity.md(API contract incl. Performance section, misuse warnings, roadmap context);docs/README.mdlinkedCMakeLists.txt+tests/CMakeLists.txtwiring;laige-api.jsonregenerated (32 new symbols); roadmap box + Progress Board (M1 1/25) + change logVerify (all local, this branch)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debugctest34/34… -B build-asan -DLAIGE_ASAN=ONctest -R entitygreen;ctest34/34 (the step's Verify clause)… -B build-tsan -DLAIGE_TSAN=ONctest -R entitygreen… -B build-shared -DLAIGE_BUILD_SHARED=ONctest34/34… -B build-release -DCMAKE_BUILD_TYPE=Releasectest -R entitygreen — exercises the#ifdef NDEBUGrelease path of the staledestroy(Status + warn-once, verified in output)ctest -R entity: 19 cases — 18 passed, 1 skipped in debug (DestroyStaleReturnsInvalidArgumentInRelease, release-only by design; runs on the Release row above)tools/laige-include-lint: OK (1/10 deps; laige-sim → laige-core is the only new internal edge, R2-compliant)api-real-tree: green after manifest regeneration (407 symbols, 11 headers)No
ENGINE-RULE-EXCEPTIONadded. No new dependencies. No public API changes to existing modules (additive only: new module + new header).Untested / carried to CI
pools_tests)