Skip to content

The agent that grows with you

fix(cron): move FIRE_CLAIM_TTL_SECONDS to the same leaf as the skew bound

Konstantin Khlopkove4e63e325ac6
diff --git a/cron/constants.py b/cron/constants.py
index 6c2896399e1..33cd96e5260 100644
--- a/cron/constants.py
+++ b/cron/constants.py
@@ -1,5 +1,12 @@
-"""Stable cron constants safe for lazy imports after an on-disk upgrade."""
+"""Fire-claim timing bounds shared by the job store and its siblings.
+Import-free on purpose: a sibling loaded fresh from a newer on-disk tree must resolve
+these without going through the ``cron.jobs`` object a long-lived process cached at boot.
+"""
+
+# A fire_claim younger than this is a live run (heartbeat cadence is 60 s). One value
+# for claiming, one-shot re-arm, and stale-error recovery so they cannot disagree.
+FIRE_CLAIM_TTL_SECONDS = 300
# A hosted/webhook fire for the armed slot can arrive a few seconds before the stored
# ``next_run_at`` (the fire scheduler's clock runs ahead of ours). Claims that early still own
# the slot; only claims further ahead are off-tick manual/dashboard fires.
diff --git a/cron/jobs.py b/cron/jobs.py
index 71c77030ec6..f560f381c56 100644
--- a/cron/jobs.py
+++ b/cron/jobs.py
@@ -28,7 +28,7 @@ except ImportError: # pragma: no cover - non-Windows
from datetime import datetime, timedelta, timezone
from pathlib import Path
from hermes_constants import get_hermes_home
-from cron.constants import FIRE_CLAIM_SKEW_SECONDS
+from cron.constants import FIRE_CLAIM_SKEW_SECONDS, FIRE_CLAIM_TTL_SECONDS
from cron.env_settings import cron_env_setting
from typing import Optional, Dict, List, Any, Callable, Set, Tuple, Union, Collection
@@ -926,9 +926,6 @@ def _classify_dispatch_lateness(lateness_seconds: float, grace_seconds: int) ->
_persisted_error_recoveries: int = 0
# Bounded in-memory history kept by every probe-visible fire-path counter.
_TELEMETRY_RECENT_HISTORY = 20
-# A fire_claim younger than this is a live run (heartbeat cadence is 60 s). One value
-# for claiming, one-shot re-arm, and stale-error recovery so they cannot disagree.
-FIRE_CLAIM_TTL_SECONDS = 300
_persisted_error_recoveries_recent: list = []
diff --git a/cron/occurrences.py b/cron/occurrences.py
index bd0fd3464ef..5db596415fe 100644
--- a/cron/occurrences.py
+++ b/cron/occurrences.py
@@ -82,8 +82,9 @@ def unclaimed_pending_slot(job, now):
THIS process on a job not running here is orphaned (dispatch refused). A stamp by another
process is honoured while that owner may still be alive within the fire-claim lease — a
second live gateway on the same store is mid-dispatch, not dead."""
+ from cron.constants import FIRE_CLAIM_TTL_SECONDS
from cron.jobs import (
- FIRE_CLAIM_TTL_SECONDS, _claim_is_live, _job_running_in_this_process, _machine_id,
+ _claim_is_live, _job_running_in_this_process, _machine_id,
)
pending = job.get("pending_slot")