Closes the monitoring part of C7's remaining gap, and finishes W2.
Two decisions lived inside the alerting path, where neither could be tested: whether a domain is due for a background check, and how its interval moves afterwards. Both failure modes are silent — an interval that grows without bound stops monitoring and reports nothing, and one that never backs off hammers every tracked domain on every wake.
isDue(trackedDomain:settings:now:)takes an injected clock rather than callingDate()inline.adapted(_:changeHash:settings:now:)returns the next state and whether this is a change not seen before, leaving the alerting to its caller.
adapted preserves a behaviour that was previously an implicit gap between two
if statements: an alert whose hash is unchanged moves neither the interval
nor the stable counter, so a persistent condition does not keep resetting the
backoff. It is an explicit guard with a comment now, rather than something the
next reader would mistake for an oversight and "fix".
nextScheduleInterval, monitoredDomains and sanitizeSettings needed nothing
but visibility and a caller — they were already pure and static, just never
tested.
18 tests, including the two silent failure modes (capped at maxInterval,
floored at the base), the unchanged-alert case, a zero interval falling back to
the base rather than reading as due-never or due-always, the soonest-due domain
setting the next wake, and a selection outliving the domain it named.
One of them corrected my own assumption rather than the code: the clamp is
max(base, min(max, current * multiplier)), so the interval multiplies upward
from the base and a value below it is raised rather than multiplied. The backoff
can never schedule a domain more often than its configured base interval.
185 tests, 0 failures on iOS 18.6 and iOS 27.0.