Expand description
Engine::retype_entity — change an entity’s type in place.
The identity triple (mem / id / type) is reserved on update
by decision: type set refuses READ_ONLY_FIELD. A type change is
its own verb because it is its own validation regime — the existing
sections and metadata have to satisfy the TARGET type, and every edge
touching the entity, incoming and outgoing, same-mem and cross-mem,
has to fit the target type’s relationship pins — and its own
provenance kind. The id, the file path, and every incoming edge stay:
nothing is deleted and re-created, so history and provenance survive.
Report-all refusal: every unknown section, missing required section,
unknown or invalid metadata value, unsatisfied block-tier constraint,
and shape-violating edge is collected and returned in ONE envelope
(RetypeRefused), with the target’s declared sections, its catch-all,
and a proposed section_map in the recovery payload, so a second
attempt can be the right one. Nothing is written before the set is
empty.
The edge re-check on both directions is mandatory, not thoroughness:
the loader drops a shape-invalid edge at the next boot with only a
PARSED_RELATION_INVALID warning, so a retype that skipped it would
amputate the graph on restart. Referrers that live in a lazy (deferred,
unloaded) mem are not in the store; they are probed through storage —
the same backend the relate path probes deferred targets through — and
when a deferred mem cannot be enumerated the retype refuses naming it,
never proceeding on the assumption that its edges are fine.