RUNGS
RUNGS = ['observe', 'reindex', 'refetch', 'rebuild', 'quarantine', 'refuse']
The rungs, lowest first.
The escalation ladder, and the rule about which rungs a machine is allowed to take.
Rungs run lowest-first, cheapest and most reversible first. A repair only ever moves one rung at a time, in either direction, so a code that keeps failing climbs at a rate an operator can watch and a code that goes quiet walks back down on its own.
The line that matters sits between rebuild and quarantine. Everything at or below rebuild reconstructs derived state from data that still exists, so the worst case of running it wrongly is wasted work. Quarantine removes a restore target and refuse blocks a restore outright; both take away the thing a backup exists to provide, which is a decision a human makes, not cron.
initialRung(int $severity) : string
Where a finding of this severity starts.
Read with >= rather than ==, so an ordinal above CRITICAL - a caller inventing its own scale, or a value read back from a newer schema - lands on quarantine instead of falling through to observe. Being wrong upward costs a paused code; being wrong downward costs a restore.
| int | $severity | One of the Finding severity ordinals. |
A rung name from RUNGS.
escalate(string $rung) : string
One rung up, saturating at the top.
Saturation rather than an exception, because escalation runs on the failure path: a code that has already reached refuse and fails again should stay at refuse, not throw on top of the failure that got it there.
| string | $rung | Current rung. |
The next rung up, the same rung at the top, or the lowest rung when $rung is not on the ladder at all.
decay(string $rung) : string|null
One rung down, or NULL at the bottom.
NULL is the signal to stop tracking the code entirely rather than to park it at observe forever; a ledger that never forgets a resolved code grows without limit.
| string | $rung | Current rung. |
The rung below, or NULL when already at the bottom or not on the ladder.
isAutomatic(string $rung) : bool
Whether an unattended run may take this rung without asking.
Fails closed: a rung this class does not recognise is not automatic. The cost of refusing a repair is a finding that stays in the ledger until someone looks; the cost of running quarantine unattended is a restore target that is gone when it is needed.
| string | $rung | The rung being considered. |
TRUE for observe, reindex, refetch and rebuild. FALSE for quarantine, refuse, and anything not on the ladder.