The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: keep ambiguous cron occurrence snapshots nullable
Teknium96a903c9d20f
diff --git a/cron/jobs.py b/cron/jobs.pyindex 50faa4a05dc..a128ea0fe0c 100644--- a/cron/jobs.py+++ b/cron/jobs.py@@ -2939,7 +2939,7 @@ def _evaluate_due_job(job: Dict[str, Any], scan: _DueScan, run_claim_ttl: float)return False# Only the dispatch snapshot carries this field; never infer it from a later stamp.- job["_scheduled_instant"] = None if manual_run else scheduled_instant(d.next_run_dt.isoformat())+ job["_scheduled_instant"] = None if manual_run else scheduled_instant(job.get("next_run_at"))if not manual_run and kind == "cron" and _reanchor_stale_cron(d):return Falsediff --git a/tests/cron/test_scheduled_occurrence.py b/tests/cron/test_scheduled_occurrence.pyindex 9134465e75f..4081e73bbbd 100644--- a/tests/cron/test_scheduled_occurrence.py+++ b/tests/cron/test_scheduled_occurrence.py@@ -145,3 +145,15 @@ def test_ledger_migration_and_completion_identity(tmp_path, monkeypatch):adopted = executions.adopt_claimed_execution(claim['execution_id'])assert adopted is not Noneassert adopted['scheduled_instant'] == slot++ # A runnable legacy wall-clock value cannot establish an exact UTC identity.+ from datetime import timedelta+ from hermes_time import now+ naive = jobs.create_job(prompt='legacy', schedule='every 4h')+ rows = jobs.load_jobs()+ for item in rows:+ if item['id'] == naive['id']:+ item['next_run_at'] = (now() - timedelta(minutes=10)).replace(tzinfo=None).isoformat()+ jobs.save_jobs(rows)+ due = next(item for item in jobs.get_due_jobs() if item['id'] == naive['id'])+ assert due['_scheduled_instant'] is Nonediff --git a/tests/cron/test_scheduler_provider.py b/tests/cron/test_scheduler_provider.pyindex 6bf710e4ed3..81e208c0643 100644--- a/tests/cron/test_scheduler_provider.py+++ b/tests/cron/test_scheduler_provider.py@@ -404,7 +404,8 @@ def test_claim_fire_persists_attempt_before_fire_claimed(monkeypatch):monkeypatch.setattr(executions,"create_execution",- lambda jid, source: events.append("ledger") or {"id": "exec-1"},+ lambda jid, source, _create=executions.create_execution:+ events.append("ledger") or _create(jid, source=source),)monkeypatch.setattr(sched,@@ -417,9 +418,9 @@ def test_claim_fire_persists_attempt_before_fire_claimed(monkeypatch):assert events == ["ledger", "claim"]assert claimed is not None- assert claimed["execution_id"] == "exec-1"+ assert executions.get_execution(claimed["execution_id"])["status"] == "claimed"assert provider.fire_claimed(claimed) is True- assert events == ["ledger", "claim", ("run", "exec-1")]+ assert events == ["ledger", "claim", ("run", claimed["execution_id"])]def test_fire_due_forwards_manual_force_to_store_claim(monkeypatch):