detach
The steps that detach the child name from the declared group at group: detach of the one-level path GroupPath.Attached(group, name).
Throws
The steps that detach the child at path, and every child attached beneath it: [Close, Retire] for an attached leaf, [Retire] when it is already closing, and [] when there is nothing left to do. Beneath an attached group the whole subtree goes, closes top-down and retires bottom-up, so nothing is retired while a child beneath it still has a live edge. A retire is refused while work beneath it is outstanding or an open lease crosses it, even one reserving nothing, and so is every retire above it; detach again, or diff, once it has drained. Attaching the group again brings none of its children back.
A prepared edge a child has — a re-attach or a reweight still waiting for a drain — is retired too, straight from PREPARED, and first: [Retire p, Close a, Retire a]. Otherwise it would record that the child is wanted, and a reload would bring the child back. It is never closed, so no prefix gives the child two live inbound edges, and it runs before the child's close, so no prefix leaves a closed child that still reads as attached. Nothing has crossed it, and it runs top-down with the closes, before anything below the child is stopped, so it is not what waits on a drain beneath: the child's live retire is, with work outstanding, and its close stands.
Throws
if path is a GroupPath.Declared, if no template reaches it, or if ledger belongs to another root.
Samples
val ci = draft("ci") {
// Each repository weighs 2 beside the nightly lane, and each author caps at one job.
group("repos") { template(Weight.of(2), template = Topology.ChildTemplate(Weight.ONE, maxConcurrent = 1L)) }
lane("nightly")
}
val (heddle, booted) = LocalHeddle.fromTopology(ci, LocalPolicy(defaultReservation = 1L), epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 4L)
// Attaching an author attaches its repository too, in the same unit.
val kuilt = GroupPath.Attached(listOf("repos"), "kuilt")
val alice = GroupPath.Nested(kuilt, "alice")
check(heddle.attach(alice, generation = 1L).refusals.isEmpty())
val aliceId = checkNotNull(ci.findGroupId(alice))
check(aliceId == GroupId("ci/repos/!kuilt/!alice") && ci.findPath(aliceId) == alice)
// Work is charged to the author; the repository itself is never leased.
val kuiltId = checkNotNull(ci.findGroupId(kuilt))
check(heddle.admit(kuiltId, waiting = setOf(kuiltId), startedAt = 0L) == AcquireOutcome.NoLiveLineage(kuiltId))
val lease = (heddle.acquire(setOf(aliceId), setOf(aliceId), startedAt = 0L) as AcquireOutcome.Acquired).lease
check(lease.leaf == aliceId)
// Detaching the repository closes alice too, and waits for her running job.
val detached = heddle.detach(kuilt)
check(detached.refusals.isNotEmpty() && detached.refusals.all { it is StepRefusal.Draining })
check(heddle.complete(lease.id, actualCost = 1L, waiting = emptySet()) is LeaseOutcome.Done)
check(heddle.detach(kuilt).refusals.isEmpty())