Resolve the create payload into an ordered list of operations.
The create payload contains complete dependency information via _alias
and _ref markers. Walking the payload to collect alias -> owner and
owner -> {refs} gives the exact dependency graph. Kahn's topo sort over
that graph produces the up order; the reverse is the down order.
Summary
Functions
Order models for teardown.
With alias_dependencies available (newer refs tokens carry it),
we run the same Kahn's topo sort over models and return the reverse
topo so children are torn down before parents.
Without it (older refs tokens), fall back to reversing the insertion
order of refs keys.
Topo-sort a create payload into an ordered list of create ops.
create is the dashboard's nested map %{model => [entity, ...]}.
Each entity is a map; _alias (declared by dependency targets) and
_ref (declared by dependents, anywhere in the field tree) are the
only reserved keys.
Returns %{ops, aliases, alias_owner_model, alias_dependencies}.