Core registers a Component Schema from a description (#76) #88

Merged
crowmaki merged 2 commits from register-component-schema-from-description into main 2026-09-06 01:59:41 +00:00
Owner

Closes #76.

What

engine_register_component_schema registers a Component Schema from a Component_Schema_Desc: a name, Component_Field_Desc entries naming a Component_Field_Kind (F64, Bool, GameObject_Reference), and optional on_add / on_remove Hooks. Each Kind maps to the Odin type the serializer already covers, so the Schema is first-class for both Scene Encodings and Play Mode capture. The three types are declared in the ABI Surface and closed over Boundary Types.

Registration is legal after startup (ADR-0020). A name collision, a duplicate field name, or an unknown Kind fails the call with a logged error and leaves the running Scene untouched. Odin-derived Schemas keep their typeid inside Core and report no Kind (ADR-0022).

How

  • The Odin-type route and the description route share schema_commit (name ownership, Schema append, storage open) and schema_storage_alloc. Neither calls the other.
  • The debug-only "called after startup" panic stays on engine_register_component alone.
  • The Scene ABI test places the new proc and types in its tables, moves engine_register_component to the Odin-only table with the new proc as its boundary counterpart, and retires the "no boundary route" table.
  • ADR-0022 carries a dated amendment noting the gap is closed.

Tests

tests/core/component_schema_test.odin covers: registration at startup with layout, registration after startup, collision after startup, the .Reference flag with component_reference / component_set_reference, text and binary round-trips, Play Mode capture and restore, Hooks on a described Schema, and rejection of a duplicate field name and an unknown Kind. No Luau involved.

One criterion is verified by inspection rather than by test: "Odin-type registration after startup still panics under ODIN_DEBUG". An Odin test cannot survive log.panic; the panic block is unchanged and runs before the shared tail.

just check and just test pass (core: 325 tests).

Closes #76. ## What `engine_register_component_schema` registers a Component Schema from a `Component_Schema_Desc`: a name, `Component_Field_Desc` entries naming a `Component_Field_Kind` (`F64`, `Bool`, `GameObject_Reference`), and optional `on_add` / `on_remove` Hooks. Each Kind maps to the Odin type the serializer already covers, so the Schema is first-class for both Scene Encodings and Play Mode capture. The three types are declared in the ABI Surface and closed over Boundary Types. Registration is legal after startup (ADR-0020). A name collision, a duplicate field name, or an unknown Kind fails the call with a logged error and leaves the running Scene untouched. Odin-derived Schemas keep their `typeid` inside Core and report no Kind (ADR-0022). ## How - The Odin-type route and the description route share `schema_commit` (name ownership, Schema append, storage open) and `schema_storage_alloc`. Neither calls the other. - The debug-only "called after startup" panic stays on `engine_register_component` alone. - The Scene ABI test places the new proc and types in its tables, moves `engine_register_component` to the Odin-only table with the new proc as its boundary counterpart, and retires the "no boundary route" table. - ADR-0022 carries a dated amendment noting the gap is closed. ## Tests `tests/core/component_schema_test.odin` covers: registration at startup with layout, registration after startup, collision after startup, the `.Reference` flag with `component_reference` / `component_set_reference`, text and binary round-trips, Play Mode capture and restore, Hooks on a described Schema, and rejection of a duplicate field name and an unknown Kind. No Luau involved. One criterion is verified by inspection rather than by test: "Odin-type registration after startup still panics under `ODIN_DEBUG`". An Odin test cannot survive `log.panic`; the panic block is unchanged and runs before the shared tail. `just check` and `just test` pass (core: 325 tests).
`engine_register_component_schema` takes a `Component_Schema_Desc`: a name,
`Component_Field_Desc` entries naming a `Component_Field_Kind` (F64, Bool,
GameObject_Reference), and optional Hooks. Each Kind maps to the Odin type
the serializer already covers, so the Schema is first-class for both Scene
Encodings and Play Mode capture. It is legal after startup; a collision
then fails the call with a log and leaves the running Scene untouched.

The Odin-type route and the description route share `schema_commit`, and
the debug-only "called after startup" panic stays on the Odin-type route
alone. The Scene ABI test places the new proc and types in its tables and
retires the "no boundary route" entry for `engine_register_component`.
A Kind outside the enum arriving from a foreign caller previously fell
through to a nil typeid and crashed. It now fails the call with
Invalid_Component_Schema and a log, like a duplicate field name does.

Both Schema routes derive the Reference flag from the mapped typeid and
share one storage allocation, and schema_commit's failure paths collapse
into two defers. Comments trimmed to ownership and boundary contracts;
ADR-0022's amendment names the two routes as counterparts that share a
tail rather than one calling the other.
crowmaki deleted branch register-component-schema-from-description 2026-09-06 01:59:41 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar!88
No description provided.