TopologyStep
One step of moving a ledger to a new Topology. Topology.diff lists them in the order they must run, and an interpreter applies them one at a time.
Every step names the child group it belongs to, so an interpreter can refuse one child's change and carry on with every other child. LocalHeddle.apply does it by leaving the child out: when one of a child's steps is refused, it drops every step of that child, earlier ones included, and applies the rest of the list again from the same ledger, so the child is left exactly as it was. The one exception is a removal whose Retire waits for work outstanding on its edge: its Close stands, since that is what stops new work going there. Either way, the retire of every group above a child whose change did not land waits too. Asking Topology.diff again later lists what is left.
What an interpreter must hold to. Four contracts the list cannot enforce on its own:
Apply the whole list as one unit, on a working ledger swapped in once, and serve nothing from a state part-way through it. A prefix is a state to recover from, never one to schedule against: a replaced edge retires before its successor activates, so a prefix between the two leaves the child with no live inbound edge, and an internal group's holdings read negative until its Reconcile, which comes last. No step of the list gives a child a second live inbound edge: an abandoned prepared edge is retired without a close, ahead of its child's (#3198). A refused child does not break the unit: it is left out as above, and the rest of the list still applies. Re-entrance is what makes a prefix recoverable, since asking again lists exactly the steps that did not land.
The steps are valid only against the ledger they were computed from. Work charged between the diff and the apply can make a Reconcile necessary that the list does not hold: diff an internal group's reweight, serve seven units beneath it, apply the stale list, and the group's holdings read
-7with a LedgerConflict.PersistentNegativeHoldings. So diff and apply under one lock, or diff again after any traffic.Keep the list's order across children. Re-entrance holds for a prefix of the list with some children's steps left out. Running one child's steps ahead of another's is not that, and a later diff numbers the prepares still to come at a higher generation.
Reconcile is licensed by a single writer, and by one precondition: no open reservation's captured path runs through an edge of the retired strand. The move drains those edges, and a straggling charge against one afterwards leaves a conflict nothing repairs. An interpreter moves open reservations off the old path before it retires the edge.
Inheritors
Types
Stop new work crossing edge; what it already carries can still be spent or returned.
Record a new edge as Lifecycle.PREPARED: it exists, and nothing crosses it until Activate. Its record id carries the child, its weight and a generation no edge in the ledger has used.
Move what child's retired edges still account for onto its new inbound edge. An internal group's children were charged through its old edge, and without this its new edge starts owing them: its holdings read negative and the ledger reports a conflict.
Retire the closed edge for good, or a prepared one nothing has crossed. Refused while anything is outstanding on it: the interpreter waits for that work to finish, and a later Topology.diff lists the retire again.