setMaxConcurrent

Sets the maxConcurrent ceiling of the child at path: a count, 0 to pause it, or null to clear the ceiling. Not checked here; Topology.from reports a negative one. A group's template ceiling is not this one: it is on TopologyDocument.ChildTemplate.

Always TopologyEdit.History.KEPT: a ceiling changes which leaf is picked, not anybody's share.

Refused with TopologyEdit.AtRoot for [], or TopologyEdit.NoSuchNode.

Samples

val running = draft("pool") {
    group("acme", Weight.of(3)) {
        lane("interactive")
        lane("batch")
    }
    group("hobby") { lane("batch") }
}
var document = running.toDocument()

// A path is child indices, as on a TopologyProblem: [0, 1] is acme's batch lane.
val reweighted = document.setWeight(listOf(0, 1), "2")
check(reweighted is TopologyEdit.Edited && reweighted.history == TopologyEdit.History.SHARE_RESTARTS)
document = reweighted.document

// history is what one edit does: a rename replaces hobby, and so does renaming it back.
val renamed = document.rename(listOf(1), "hobbyists")
check(renamed is TopologyEdit.Edited && renamed.history == TopologyEdit.History.REPLACED)
val back = renamed.document.rename(listOf(1), "hobby")
check(back is TopologyEdit.Edited && back.history == TopologyEdit.History.REPLACED)
document = back.document

// A template lets the app attach children to hobby while it runs, here two levels deep.
// Adding one costs nobody history; removing it later would drain the attached children.
val attaching = document.setTemplate(listOf(1), TopologyDocument.ChildTemplate("2", template = TopologyDocument.ChildTemplate()))
check(attaching is TopologyEdit.Edited && attaching.history == TopologyEdit.History.KEPT)
document = attaching.document

// An edit that would give two siblings one name is refused, naming the sibling that has it.
val refused = document.addChild(listOf(0), TopologyDocument.Lane("batch"))
check(refused == TopologyEdit.DuplicateName(listOf(0, 1), "batch"))

// The warning before saving compares with the tree the editor loaded: the round trip is gone.
val candidate = Topology.from(document)
check(candidate is TopologyParse.Valid)
val attached = Topology.ChildTemplate(Weight.of(2), template = Topology.ChildTemplate(Weight.ONE))
check(
    running.changesTo(candidate.topology) ==
        listOf(
            TopologyChange.WeightChanged(listOf(0, 1), listOf("pool", "acme", "batch"), Weight.ONE, Weight.of(2)),
            TopologyChange.TemplateAdded(listOf(1), listOf("pool", "hobby"), attached),
        ),
)