saveEffect

What LocalHeddle.apply does to fairness history when it lands this change: SaveEffect.LOST for a change that costs a group its history, the one to warn about before saving; SaveEffect.KEPT for one that costs nobody any; and SaveEffect.NEW_TREE for the one apply throws on, which an editor refuses to save rather than warns about.

Read from the two trees alone, so it answers for what may be lost. A TemplateRemoved is SaveEffect.LOST whether or not the app has attached any children under that group yet, since a tree cannot say.

One change is one cause. A child whose weight and ceiling both changed is a WeightChanged, SaveEffect.LOST, beside a CeilingChanged, SaveEffect.KEPT: the child loses its history to the first, and the second costs it nothing more.

Samples

val running = draft("pool") {
    group("acme", Weight.of(3)) {
        lane("interactive")
        lane("batch")
    }
    group("tenants") { template(Weight.of(2)) }
}
val edited = draft("pool") {
    group("acme", Weight.of(3)) {
        lane("interactive", maxConcurrent = 2)
        lane("nightly")
    }
    // A new template ceiling keeps the attached children's history; a new weight would not.
    group("tenants") { template(Weight.of(2), maxConcurrent = 4) }
}
val changes = running.changesTo(edited)
check(changes.none { it.saveEffect == TopologyChange.SaveEffect.NEW_TREE })
// Of four changes, only the removal of batch costs anyone their history.
val warnings = changes.filter { it.saveEffect == TopologyChange.SaveEffect.LOST }
check(changes.size == 4 && warnings.map { it.names } == listOf(listOf("pool", "acme", "batch")))

// A renamed root is a new tree, which apply throws on, so the save is refused, not warned about.
val renamed = draft("farm") { lane("batch") }
check(running.changesTo(renamed).first().saveEffect == TopologyChange.SaveEffect.NEW_TREE)