Skip to content

The agent that grows with you

fix(cron): R2-2 explain when lateness warnings clear

yoniebans909c736cd432
diff --git a/hermes_cli/cron.py b/hermes_cli/cron.py
index ad3b5e084d5..3f6da2a9a46 100644
--- a/hermes_cli/cron.py
+++ b/hermes_cli/cron.py
@@ -550,7 +550,8 @@ def _cron_doctor_issues_for_job(job: Dict[str, Any]) -> List[str]:
labels = {"catch_up": "a catch-up after a missed schedule", "late": "late"}
if label := labels.get(dispatch.get("kind", "")):
issues.append(f"last fire was {label} (scheduled {dispatch.get('scheduled_at', '?')}, "
- f"{_format_lateness(dispatch.get('lateness_seconds', 0))} late)")
+ f"{_format_lateness(dispatch.get('lateness_seconds', 0))} late). "
+ "This warning clears at the next on-time fire.")
if isinstance(fire_err := job.get("last_fire_error"), dict) and fire_err.get("detail"):
# The handoff error survives next_run_at advancing beyond the failed dispatch.
issues.append(f"missed scheduled fire at {fire_err.get('at', '?')}: {_short_reason(fire_err['detail'])}")
@@ -588,7 +589,7 @@ def cron_doctor() -> int:
for issue in issues:
print(f" - {issue}")
print()
- print(color("Next: fix the listed job config, then run `hermes cron doctor` again.", Colors.DIM))
+ print(color("Review the findings above, then run `hermes cron doctor` again.", Colors.DIM))
return 1
diff --git a/tests/hermes_cli/test_cron_satellite_diagnostics.py b/tests/hermes_cli/test_cron_satellite_diagnostics.py
index 321d1a6f056..20b457436ef 100644
--- a/tests/hermes_cli/test_cron_satellite_diagnostics.py
+++ b/tests/hermes_cli/test_cron_satellite_diagnostics.py
@@ -130,6 +130,20 @@ def test_doctor_reports_persisted_dispatch_health(served_root, capsys, dispatch)
output = capsys.readouterr().out
expected = {"catch_up": "catch-up", "late": "last fire was late", "forward_error": "loopback unavailable"}
assert expected[dispatch] in output
+ assert "Review the findings above, then run `hermes cron doctor` again." in output
+ jobs.mark_job_run(job["id"], success=True)
if dispatch == "forward_error":
- jobs.mark_job_run(job["id"], success=True)
assert cron_doctor() == 0
+ else:
+ assert "This warning clears at the next on-time fire." in output
+ assert cron_doctor() == 1
+ capsys.readouterr()
+ records = jobs.load_jobs()
+ records[0]["next_run_at"] = datetime.now(timezone.utc).isoformat()
+ jobs.save_jobs(records)
+ assert len(jobs.get_due_jobs()) == 1
+ persisted = jobs.get_job(job["id"])
+ assert persisted is not None
+ assert persisted["last_dispatch"]["kind"] == "on_time"
+ assert cron_doctor() == 0
+ assert "This warning clears" not in capsys.readouterr().out