diff --git a/cron/unreachable_retry.py b/cron/unreachable_retry.py index ab4e9381eb..20102853da 100644 --- a/cron/unreachable_retry.py +++ b/cron/unreachable_retry.py @@ -68,26 +68,9 @@ def _is_recurring(job: Dict[str, Any]) -> bool: def will_retry(job: Dict[str, Any]) -> bool: - """Predict whether ``plan_retry`` will schedule a re-run for this flagged failure — - used by the scheduler to suppress the interim failure notice. - - Must mirror ``plan_retry`` (and the ``mark_job_run`` guards around it) decision-for- - decision, so a notice is held exactly when a re-run really is coming: - - - exhausted ladder / disabled / paused / non-recurring → no re-run; - - the yield branch: when the schedule's own next occurrence lands at or before the - pending rung, ``plan_retry`` schedules nothing (the natural fire IS the retry). - Without this mirror, a job on a cadence at or under a rung held EVERY failure - notice for as long as the outage lasted: each failure yielded without consuming an - attempt, so the "once the ladder is exhausted, the next failure alerts normally" - escape in the suppression contract was unreachable and the operator saw silence. - (The final run of a finite repeat is a separate terminal-state edge handled by - #109991.) - - Called before ``mark_job_run`` records the run; the occurrence is recomputed exactly - as ``_advance_after_run`` will (delivery-time skew between here and the store write - can only err toward delivering the notice, never toward suppressing it unheard). - """ + """True iff ``plan_retry`` will park a re-run for this flagged failure, so the scheduler + may hold the interim notice: recurring, unpaused, ladder not exhausted, enabled, and the + rung strictly before the natural occurrence. Called before ``mark_job_run``.""" if not _is_recurring(job) or job.get("state") == "paused": return False state = job.get(STATE_KEY) or {} diff --git a/tests/cron/test_unreachable_retry.py b/tests/cron/test_unreachable_retry.py index 61244ec13d..caffb14a83 100644 --- a/tests/cron/test_unreachable_retry.py +++ b/tests/cron/test_unreachable_retry.py @@ -75,7 +75,7 @@ def test_unreachable_failure_pulls_next_run_earlier_then_ladder_exhausts( assert weekly["id"] not in {due["id"] for due in get_due_jobs()} -def test_will_retry_mirrors_plan_retry_yield_and_terminal_paths(tmp_cron_home): +def test_will_retry_mirrors_plan_retry_yield(tmp_cron_home): """The notice-suppression predictor must mirror what ``plan_retry`` will actually do for THIS failure: