feat: mofin_health cron输出缺失检测(hermes失败静默补偿)

This commit is contained in:
xxm
2026-08-10 18:39:33 +08:00
parent 55893bedd7
commit 4d8fde5856
+27
View File
@@ -945,6 +945,28 @@ def build_report():
last_run = str(j.get("last_run_at", ""))[:19]
schedule = j.get("schedule", {}).get("display", str(j.get("schedule","")))
no_agent = j.get("no_agent", False)
# 输出缺失检测(2026-08-10):hermes失败时last_status仍ok
# 检查"今天应按调度运行但输出目录无当日文件"的LLM cron
output_missing = False
output_missing_reason = ""
if not no_agent and j.get("id") and j.get("enabled", True):
try:
_job_id = j.get("id")
_out_dir = Path('/home/hmo/.hermes/profiles/position-analyst/cron/output') / _job_id
if _out_dir.exists():
_today = now.strftime("%Y-%m-%d")
_today_files = list(_out_dir.glob(f"*{_today}*"))
_last_run_str = str(j.get("last_run_at", ""))[:10]
_is_today_run = (_last_run_str == _today)
# LLM cron 今天应按调度跑(工作日)但没有今天输出
_sched = str(j.get("schedule", ""))
_weekday_only = ("1-5" in _sched or "mon" in _sched.lower())
_is_weekday = now.weekday() < 5
if _is_today_run and not _today_files and (_weekday_only and _is_weekday or not _weekday_only):
output_missing = True
output_missing_reason = f"last_status={status}但今天无输出文件"
except Exception:
pass
pipelines.append({
"name": name,
"type": "no_agent" if no_agent else "LLM",
@@ -953,7 +975,12 @@ def build_report():
"status": status,
"last_run": last_run,
"profile": j.get("profile", "?"),
"output_missing": output_missing,
"output_missing_reason": output_missing_reason,
})
if output_missing:
feature_tree["status"] = "fail"
feature_tree.setdefault("warn_detail", {})[name] = output_missing_reason
# ── 自检体系状态(L1功能健康/L3修复记录/L4元监控/L2卫生)──
self_check = {}