The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
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.pyindex 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.pyindex 71c77030ec6..f560f381c56 100644--- a/cron/jobs.py+++ b/cron/jobs.py@@ -28,7 +28,7 @@ except ImportError: # pragma: no cover - non-Windowsfrom datetime import datetime, timedelta, timezonefrom pathlib import Pathfrom 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_SECONDSfrom cron.env_settings import cron_env_settingfrom 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.pyindex 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 anotherprocess is honoured while that owner may still be alive within the fire-claim lease — asecond live gateway on the same store is mid-dispatch, not dead."""+ from cron.constants import FIRE_CLAIM_TTL_SECONDSfrom 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")