relocationPatch

The §4 generation-move: drain each fenced retired edge in finals and re-home everything it carried — net inflow and already-charged service — onto the child's live inbound liveEdge (relocation design §4, issue #1665 slice 3 / #1693). This is the conserving recovery for the advisory-retire race, and it is pure: acked finals in, patch out.

Why the child needs its FULL net inflow re-homed

When a gossip-lagged peer retires an edge whose delegate it had not yet merged, the edge is RETIRED with outstanding != 0 and its budget is stranded on a generation no longer on the live lineage (GovernedHeddleNode.retire). Once the child is legally reparented onto a fresh inbound edge with issued = 0, holdings at the child derive permanently negative — a persistent LedgerConflict.PersistentNegativeHoldings / LedgerConflict.PerEdgeSafety with zero real overspend. release refuses a retired edge, so the data plane cannot recover it.

The child's holdings under the old edge s were credited by its full net inflow n = effIssued(s)[r] − returned(s)[r] — not its outstanding (which nets out spent(s)). So making the child whole means re-homing n, and relocating the sp = effLeafSpent + effRollupSpent that rode with it so s stays per-edge-safe.

The patch, per fenced edge s and replica r

returned(s)[r]        → iss           # drain: netInflow(s)[r] → 0, outstanding(s) → 0
issued/leafSpent/rollupSpent(s)[r] → the acked finals # republished (observer completeness, §6.4)
leafRelocOut(s)[r] += lsp leafRelocIn(t)[r] += lsp
rollupRelocOut(s)[r] += rsp rollupRelocIn(t)[r] += rsp
issuedRelocIn(t)[r] += n # NEVER the live edge's base `issued` slot (#1691)
transferRelocOut(key(s))[r][to] += x transferRelocIn(key(t))[r][to] += x # the hand-offs

Every move sends equal and opposite relocation credits, so Σ effLeafSpent — the conservation term — is invariant; the net-inflow half telescopes (the parent's subtraction of netInflow(s) drops by n exactly as the child's creditIn rises by n). mintedTotal is untouched.

The two inputs, and why neither is read from a gossip view

  • finals — per fenced edge, each replica's log-recorded SlotFinals from its ControlCommand.QuiesceAck. Base slots are single-writer, and the acking replica has marked the edge locally unwritable, so these values are final and consensus-recorded.

  • this — the control plane's own accumulated relocation state (FenceState.relocations). The relocation families and a fenced edge's base slots are control-plane-owned exclusively (§6.3), so this holds their true values with no data-plane read at all.

Both are functions of the committed log prefix, so every peer derives the identical patch (Raft §5.4.3). That is what closes the Wall-A magnitude residual #1669 documented and what removes §12.3's magnitude-freshness residual: a second move onto one live edge accumulates on this rather than max-colliding with the first.

The two callers that are not the control plane

Neither derives a patch another peer must match, which is why neither needs a log.

  • A single writer (LocalHeddle's Reconcile step, reconcileLocally) reads finals and this off the ledger it alone writes, so they are final by construction.

  • A static peer repairing its own row (HeddleNode.reconcileOwn in :kuilt-heddle) passes finals holding only itself, and this is its own converged ledger. Every slot the patch reads or writes is then keyed by that replica — its base slots on each fenced edge, and its relocation slots there and on liveEdge — and on a static node that replica is their only writer, having marked the edge locally unwritable. So each peer's move touches a row no other peer's move touches, and the moves join cleanly in any order.

…and why the hand-offs are part of it (#2366 / #2377)

transfers is keyed by PathKey.of(edge) — the generation's id, not the child group — so a move that carried only the counter families left the rows on the dead key where holdings no longer reads them, silently reassigning a recipient's entitlement to the donor with conservation intact and validate otherwise empty. The three terms of a pocket travel together or the pocket is wrong.

The magnitudes arrive the same way the counters' do — through finals, in SlotFinals.transfers, never off a gossip view. transfers[key(s)][donor] is single-writer at donor and a retired s is no longer any group's live inbound, so transfer can never write that key again: the row is frozen at barrier time at its own writer, which is exactly what makes it declarable. That is also what puts the carry on the H5 control-plane path, whose receiver (FenceState.relocations) is log-pure and holds no data-plane row at all.

The carry is not a key move into transfers[key(t)] — that slot belongs to the donor and ordinary transfer writes it concurrently, so two writers on one max-joined slot would erase a side (#1691). It lands in the control-plane-owned transferRelocIn and is cancelled on the dead key by transferRelocOut, the same equal-and-opposite pair the spend families use. The Out half is what makes a second Reconcile carry nothing: a double-move is exactly as sum-preserving as an abandonment, so conservation can never be what rejects one.

Preconditions, checked per replica against the acked finals

  • n ≥ 0 — a replica that has returned more than it was issued on s cannot be drained, because the drain writes returned(s)[r] := effIssued(s)[r] and that slot is grow-only. Out of scope ⇒ Relocation.Refused (PR #1669 break4).

  • cover ≥ charge, where cover = Σ (n + tn) and charge = Σ sp over this replica's fenced edges — tn being its still-uncarried net transfer there. Cover counts the whole inbound half deliberately: a recipient that spent transferred credit has issuance nowhere, so a cover of n alone refused it for a shortfall that was never real.

  • lsp ≥ 0, rsp ≥ 0 — an acked base below what has already been relocated out is protocol-impossible, so it fails closed rather than moving a negative quantity.

  • every donor of a still-uncancelled carried row acked. A row an earlier move carried onto this key lives in transferRelocIn — control-plane state on this, on no ack — so a donor whose only mark here is such a row is invisible to the enumeration above. Moving the rest of the key while it stays behind reassigns its recipients' credit to the donor upstream of it, which is #2366 one hop up, and it survives a departure because the fence quantifies over the enrolled roster.

    Carrying it instead is not open, and not because "a peer that never acked has promised nothing" — that is true of a base row and false of this one, which is control-plane-authored and already committed to the log. It is this PR's own thesis one hop over: a pocket is netInflow + transferNet − effLeafSpent, and the covering netInflow/spend terms of this donor arrive only in this donor's ack, which is absent. Carrying the transfer term alone would move the hand-off onto the live key while the funding that makes it legitimate stays on the dead one — one pocket split across two generations, which is exactly the failure the whole carry exists to prevent. Three terms together or none; the transfer term is not exempt from the rule it motivated. ⇒ Relocation.Refused, on a state validate now also reports as LedgerConflict.OrphanedTransferPath. Scoped to the carried residual (transferRelocIn − transferRelocOut > 0) so a drained carried row does not re-refuse — see unackedCarriedDonors for why §5.4 (iii) does not actually rest on that scoping.

The live edge needs no data-plane read: the move adds sp to t's effective spend and n ≥ sp to its effective issuance, so per-edge safety on t survives by increment.

Relocation.Nothing when every fenced edge is already drained — n = 0, sp = 0 and no row left to carry. The deterministic idempotence guard of §5.4 (iii): a second Reconcile for one child moves nothing. All three halves matter; a strand whose counters closed at zero can still owe a hand-off, and that is precisely the state #2366 abandoned.

A replica that authored slots on s but is absent from finals (never acked) is left untouched: its strand stays stranded on the same terms as a crashed peer's holdings (heddle-design.md §8.1). Draining a slot whose owner never promised is precisely the fabricate-beyond-owner violation the fence exists to prevent.

HeddleInternalApi — the governed caller is HeddleControlPlane's apply loop, which alone holds log-pure inputs; the single-writer and own-row callers above hold inputs no other writer moves.