Core replaces a live description-registered Schema and migrates instances by field name (#77) #89
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/cinnabar!89
Loading…
Reference in a new issue
No description provided.
Delete branch "schema-migration-77"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #77.
What
engine_register_component_schemawith a name that a description-registered Schema already holds replaces that Schema and returns the sameComponent_Type. Live instances migrate by field name (ADR-0020): a kept field with the same Kind carries its value over, a kept field with a different Kind reads as zero, a removed field is dropped, an added field is zero. Component Handles, Object Ids, owners, and dense indices are untouched, so references into a migrated Component still resolve. Replacing an Odin-registered Schema fails with a logged error andDuplicate_Component_Name.How
core/schema_migration.odinbuilds a by-nameMigration_Plan, rewrites every live instance throughvalue_encode/value_decodeinto fresh storage, then re-keys the Reference Side Table across every loaded Scene. Every key leaves a table before any is put back, so two reference fields that swap indices keep their own targets.Schema_Storagerecords aSchema_Origin, which is what decides whether a name may be replaced.schema_desc_is_well_formedso the new and replace paths share it."Compatible Kind" is implemented as identical Kind; the three Kinds today admit no other compatibility. Migrated instances take the new description's Hooks.
Tests
tests/core/schema_migration_test.odincovers every acceptance criterion: same-type replacement, by-name matching, drop / add / retype, Handle and Object Id survival, Odin refusal, a failed replacement, migration with two Scenes loaded including External Reference re-resolution after the target Scene reloads, a retyped reference dropping its External Reference, and two External References swapping indices.Post-build failure paths (allocation failure mid-migration) are verified by inspection; the suite cannot inject allocator failure.
just checkandjust testpass (core: 334 tests).