spend

fun spend(r: ReplicaId, group: GroupId, amount: Long): Patch<EntitlementLedger>?

Charge amount of completed service by r at leaf group. requires group is a leaf; null if r's holdings there are insufficient. Charges leafSpent(inbound(group))[r] and rollupSpent(e)[r] for every strict-prefix edge e — one atomic patch keeping per-edge outstanding correct at every level (design fix 1). amount 0 is a no-op cancel.

The require does not protect conservation: holdings subtracts leafSpent and every child's net inflow unconditionally, so a charge at any group stays inside what it holds. It protects the policy. A group with an ACTIVE child holds entitlement for the allocator to divide among its children (§7.3), and spending it at the group would bypass that split. isLeaf says when no ACTIVE child exists; a group whose children are only prepared, closing or retired is a leaf and is charged here.