The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(cron): cover future occurrence poisoning
fangliquanced1bf29a81a
diff --git a/tests/cron/test_claim_job_for_fire.py b/tests/cron/test_claim_job_for_fire.pyindex 890e257e1e3..7b21a0a9332 100644--- a/tests/cron/test_claim_job_for_fire.py+++ b/tests/cron/test_claim_job_for_fire.py@@ -284,6 +284,22 @@ def test_manual_claim_does_not_stamp_a_future_occurrence(temp_home):f"manual fire stamped the future occurrence {pending}")+def test_unclassified_off_tick_claim_does_not_stamp_a_future_occurrence(temp_home, monkeypatch):+ from datetime import datetime, timedelta++ import cron.jobs as jobs++ job = jobs.create_job(prompt="x", schedule="every 5m", name="off-tick")+ pending = jobs.get_job(job["id"])["next_run_at"]+ monkeypatch.setattr(+ jobs, "_hermes_now", lambda: datetime.fromisoformat(pending) - timedelta(minutes=1))++ claimed = jobs.claim_job_for_fire(job["id"], return_job=True)++ assert isinstance(claimed, dict)+ assert claimed["_scheduled_instant"] is None++def test_manual_claim_still_refuses_a_paused_job(temp_home):"""``manual=True`` suppresses only the occurrence stamp — unlike ``force=True`` itmust not resume a paused job, which the run-now tool relies on to refuse it."""diff --git a/tests/cron/test_scheduled_occurrence.py b/tests/cron/test_scheduled_occurrence.pyindex 4081e73bbbd..4ff40505c43 100644--- a/tests/cron/test_scheduled_occurrence.py+++ b/tests/cron/test_scheduled_occurrence.py@@ -157,3 +157,24 @@ def test_ledger_migration_and_completion_identity(tmp_path, monkeypatch):jobs.save_jobs(rows)due = next(item for item in jobs.get_due_jobs() if item['id'] == naive['id'])assert due['_scheduled_instant'] is None+++def test_completion_before_occurrence_does_not_prove_slot_completed(tmp_path, monkeypatch):+ from datetime import datetime, timezone++ from cron import executions+ from cron.occurrences import completed_occurrence++ monkeypatch.setattr(executions, 'EXECUTIONS_FILE', tmp_path / 'executions.db')+ slot = '2026-01-05T00:00:00+00:00'+ monkeypatch.setattr(executions, '_hermes_now', lambda: datetime(2026, 1, 1, tzinfo=timezone.utc))+ poisoned = executions.create_execution('job', source='control', scheduled_instant=slot)+ executions.finish_execution(poisoned['id'], success=True)++ assert not completed_occurrence({'id': 'job'}, slot)++ monkeypatch.setattr(executions, '_hermes_now', lambda: datetime(2026, 1, 5, tzinfo=timezone.utc))+ legitimate = executions.create_execution('job', source='builtin', scheduled_instant=slot)+ executions.finish_execution(legitimate['id'], success=True)++ assert completed_occurrence({'id': 'job'}, slot)