Skip to content

[M1-ECS-02] Component registry + trait-based IDs - #17

Merged
offdev merged 2 commits into
masterfrom
m1-ecs-02-component-registry
Sep 13, 2026
Merged

offdev merged 2 commits into
masterfrom
m1-ecs-02-component-registry

Conversation

@offdev

@offdev offdev commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Implements M1-ECS-02 from roadmap/M1-heartbeat.md (exactly the Scope bullets, nothing else).

What landed

  • ComponentTypeId — stable per-world component type ids: 32-bit, dense in registration order from 1, 0 reserved (kInvalidComponentTypeId). Assignment is pure integer bookkeeping (ARCH-010): same registration order → bit-identical ids across worlds/runs/builds. Per-world ids (cross-world caveat, like Entity). operator< orders by registration order for M1-ECS-03/05.
  • LAIGE_COMPONENT(Type) — compile-time trait mark (data-only; replication/inspector traits land in M4). Built-in and user-defined components register through the same path — a user struct is legal (S-8 data-carrier case, PRD Appendix B shape).
  • World::registerComponent() — records sizeof(T)/alignof(T) for the M1-ECS-03 SoA layout. Duplicate registration is an error (InvalidArgument + rate-limited warn ecs/component_duplicate); engine-level budget kMaxComponentTypes = 256 (BudgetExhausted); setup-phase O(n), no allocation; moved-from world has no registry. Type identity without RTTI/unordered containers (per-type inline-static marker address; NFR-8.10, PERF-006). static_assert guards: LAIGE_COMPONENT mark + trivially-copyable (actionable compile errors).
  • componentCount() / componentInfo(id) accessors; registry moves with World; clear() leaves it untouched.

Files

  • New: src/laige-sim/include/laige/sim/component.h, tests/laige-sim/component_registry_tests.cpp, docs/api/component_registry.md
  • Modified: entity.h/.cpp (World registry), tests/laige-sim/CMakeLists.txt (component_registry CTest entry), docs cross-refs (docs/README.md, docs/api/entity.md, src/laige-sim/README.md), roadmap (box, board 2/25, change log), laige-api.json (regenerated: 421 symbols)

Verification (AGENTS §5)

  • ctest -R component_registry green — 12 cases (duplicate error + unchanged registry, id stability across two worlds with the same registration order, order-determines-ids, 256-type budget boundary, size/alignment incl. 8-byte alignment, componentInfo validation, move/clear, warn-once rate-limit summary via memory sink)
  • Full ctest 35/35 on canonical g++ Debug tree (zero warnings, -Werror), ASan+UBSan tree 35/35 (leak-free), Clang tree 35/35; shared-library tree builds clean
  • api-real-tree green after manifest regeneration; tools/laige-include-lint OK (1/10 deps)
  • No hot-path changes (registration is a setup-phase operation); zero-allocation property holds by construction (no new heap on any operation)

No ENGINE-RULE-EXCEPTION added.

- ComponentTypeId: stable per-world ids, dense in registration order
  from 1, 0 reserved (kInvalidComponentTypeId), per-world contract,
  operator< = registration order (ARCH-010: pure integer bookkeeping).
- LAIGE_COMPONENT(Type): compile-time trait mark (data-only; replication
  / inspector traits land in M4). User-defined structs register through
  the same path (S-8 data-carrier case).
- World::registerComponent<T>: records sizeof/alignof for the M1-ECS-03
  SoA layout; duplicate registration is an error (InvalidArgument +
  rate-limited warn ecs/component_duplicate); engine-level budget
  kMaxComponentTypes = 256 (BudgetExhausted); setup-phase O(n), no
  allocation; moved-from world has no registry.
- Type identity without RTTI/unordered: per-type inline-static marker
  address (NFR-8.10, PERF-006).
- Tests: 12 cases under the new component_registry CTest entry
  (duplicate error, id stability across two worlds with the same order,
  order-determines-ids, 256-type budget boundary, size/alignment,
  validation, move/clear, warn-once).
- Docs: docs/api/component_registry.md (+ cross-refs), laige-api.json
  regenerated (421 symbols).

Verify: ctest -R component_registry green; full ctest 35/35 on
canonical g++ Debug, ASan (35/35), and Clang (35/35) trees;
api-real-tree green; tools/laige-include-lint OK.
@offdev
offdev merged commit 452ab86 into master Sep 13, 2026
10 checks passed
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