///|
pub(all) struct RepairVerification {
valid : Bool
diagnostics : Array[Diagnostic]
outcome : Truth
computed_cost : Int
} derive(Debug, Eq)
///|
/// Verify a repair received from storage or another process before applying it.
pub fn Policy::verify_repair(
self : Policy,
repair : Repair,
) -> RepairVerification {
let errors : Array[Diagnostic] = []
let span = Span::{ offset: 0, line: 1, column: 1 }
let mut computed_cost = 0
let mut environment = self.environment()
for index, change in repair.changes {
let item = match self.find_feature(change.feature) {
None => {
errors.push({
code: "E_REPAIR_UNKNOWN_FEATURE",
message: "repair references unknown feature '\{change.feature}'",
span,
})
continue
}
Some(value) => value
}
if item.locked {
errors.push({
code: "E_REPAIR_LOCKED",
message: "repair changes locked feature '\{change.feature}'",
span,
})
}
if change.from != item.current {
errors.push({
code: "E_REPAIR_STALE",
message: "repair expects stale source value for '\{change.feature}'",
span,
})
}
if !item.domain.contains(change.to) {
errors.push({
code: "E_REPAIR_OUTSIDE_DOMAIN",
message: "repair value for '\{change.feature}' is outside its domain",
span,
})
}
if change.cost != item.cost {
errors.push({
code: "E_REPAIR_CHANGE_COST",
message: "repair records the wrong cost for '\{change.feature}'",
span,
})
}
for previous in 0..