The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): a transport-cancelled ladder re-run no longer spends a repeat slot
kshitijk4poor068d709c5571
diff --git a/cron/scheduler.py b/cron/scheduler.pyindex 413ea89a492..1b6a2163a9e 100644--- a/cron/scheduler.py+++ b/cron/scheduler.py@@ -2899,12 +2899,19 @@ def run_one_job(_OWNERSHIP_LOST_INTERRUPTED = "Interrupted by shutdown before terminal completion."-def _record_fire_ownership_lost(job_id: str, fire_owner: Optional[str], execution_id: str) -> None:+def _record_fire_ownership_lost(+ job_id: str, fire_owner: Optional[str], execution_id: str, *, ladder_rung: bool = False,+) -> None:"""Bookkeeping after fire-claim ownership loss. A transport-level cancel (dashboard drain) isnot a real loss — we still own the claim, so record the interruption via the owner-fenced- terminal write instead of leaving fire_claim/last_status stale; otherwise discard."""+ terminal write instead of leaving fire_claim/last_status stale; otherwise discard.+ ``ladder_rung``: the interrupted run re-ran an occurrence that already counted, so its+ terminal write must not spend another repeat slot (same as every other terminal path)."""if fire_owner is not None and heartbeat_fire_claim(job_id, expected_owner=fire_owner):- mark_job_run(job_id, False, _OWNERSHIP_LOST_INTERRUPTED, expected_fire_owner=fire_owner)+ mark_job_run(+ job_id, False, _OWNERSHIP_LOST_INTERRUPTED, expected_fire_owner=fire_owner,+ **({"ladder_rung": True} if ladder_rung else {}),+ )finish_execution(execution_id, success=False, error=_OWNERSHIP_LOST_INTERRUPTED)else:finish_execution(@@ -3300,6 +3307,7 @@ def _run_one_job_body(transport_cancel: Optional[_CancelEventLike] = None,execution_token: Optional[object] = None,) -> bool:+ from cron.unreachable_retry import is_retry_runfence = _FireOwnership(job, claim_lost, transport_cancel)fire_owner = fence.owner_side_effect_fence = fence.side_effect_fence@@ -3394,7 +3402,8 @@ def _run_one_job_body(if _fire_claim_ownership_lost():_teardown_deferred()- _record_fire_ownership_lost(job["id"], fire_owner, execution_id)+ _record_fire_ownership_lost(+ job["id"], fire_owner, execution_id, ladder_rung=is_retry_run(job))return True# An agent can finish its own turn after a delegated child has failed. Let it explicitly@@ -3422,7 +3431,8 @@ def _run_one_job_body(if d.side_effect_ownership_lost:# The claim died inside a side-effect fence: the side effect did NOT complete.- _record_fire_ownership_lost(job["id"], fire_owner, execution_id)+ _record_fire_ownership_lost(+ job["id"], fire_owner, execution_id, ladder_rung=is_retry_run(job))return True# Empty final_response is a soft failure so last_status is not "ok".@@ -3447,7 +3457,8 @@ def _run_one_job_body("Job '%s': transport cancellation arrived before terminal completion; ""recording the interrupted run",job["id"])- _record_fire_ownership_lost(job["id"], fire_owner, execution_id)+ _record_fire_ownership_lost(+ job["id"], fire_owner, execution_id, ladder_rung=is_retry_run(job))return Trueif _consume_interrupted_flag(job["id"], execution_token):