Files
MoFin/archive/hermes-dead-tools-20260820/notify_user7.py
T
xxm c68f987653 chore(cleansweep): 代码大扫除——归档hermes 111个死工具+4个废弃scanner,收敛MoFin/scripts重复副本,删除根旧版mo_models
- archive/hermes-dead-tools-20260820/: hermes独有不在cron不被import的111个一次性排查/测试工具
- archive/hermes-dead-tools-20260820/: 4个废弃scanner(btd1_v3/market_scanner/market_thermometer已废弃/s2v2)
- archive/legacy-cleanup-20260820/: MoFin根2旧版(mo_models/technical_analysis)+/home/hmo/scripts无引用旧项目+MoFin/scripts重复prepare_report_data
- 删除MoFin根mo_models.py(根旧版,deploy/profile-scripts权威保留)
- 保留: mofin_db.py/mo_data.py硬链接(server.py多层sys.path需各目录访问同一inode,非冗余)
- fix_gateway.py保留(Gateway看门狗fix_gateway_port.py的活跃依赖,勿误删)
- 验证: cron所有脚本引用无缺失, key模块import正常
- hermes独有从116收敛到5核心(alert_logger/market_screener/prepare_report_data/self_todo_executor_v2/xmpp_zhiwei_bot)
2026-08-20 10:36:25 +08:00

69 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json, urllib.request
msg = """[笑笑] 自检体系 L0-L4 分层架构 — 建成并验证
按你的四点要求重构完成:
■ 责任矩阵(每层职责单一,不重叠不疏漏)
L0 执行心跳 — agents_health_check.py5min
职责:端口/HTTP/DB 存活 + auto_heal 执行(gateway重启/key切换/bot重启)
L1 功能健康 — functional_health_check.py(交易时段15min
职责:判据是"功能是否达成"不是"进程活着"。9个核心模块各有注册判据:
· price_monitor → live_prices 最新记录 <6min
· market_watch → market_snapshots <40min
· mtf_cache → <75min
· macro_context → <45min
· 健康采集 → mofin_health.json <20min
· 盘前重评 → summary <26h
· LLM → agent.log 有成功调用
· bot → systemctl active + 无断线循环
· cron引擎 → 最近12min有job运行
L2 系统卫生 — system_hygiene_audit.py(每日08:20,已从每周改每日)
职责:分叉副本/断裂硬链接/僵尸进程/孤儿文件/死cron/DB新鲜度
L3 LLM修复循环 — self_repair.py30min
职责:读 L1/L2 失败项 → LLM 诊断 → 直接修复(报备制)
L4 元监控 — meta_watchdog.py(每小时)
职责:自检系统的自检——L0-L3 输出物新鲜度 + L3注册状态 + XMPP桥。
任何一层死亡直接 XMPP 点名(最后兜底)
已退休重叠组件:Cron监护-高频(并入L3)、全局cron健康监控(并入L1)
■ 报备制(不是报告了事)
L3 的纪律:发现问题 → 直接修 → 记录 repair_log.jsonl → XMPP 报备。
LLM 只许选白名单动作(rerun_script/restart_service/sync_links/switch_llm_key/none),
不许任意执行代码;每模块每天≤2次防修复循环;白名单兜不住会明说"需要人工"。
■ 端到端验证(真实测试)
1. 我手动 stop xmpp bot → L1 立即报 failbot 服务非 active
2. systemd Restart=always 自动拉起 → L3 LLM 诊断后正确判定"无需动作"并记录日志
3. rerun_script 白名单路径实测:真实重跑 mofin_health.py 成功
4. meta_watchdog 复检:L0-L4 全绿
5. 第一版 bot 判据被我自己抓出 bug(信30分钟前日志不看当前状态),已修正为"先看 is-active"
■ F健康整合
mofin_health.html 新增 🩺自检体系 Tab(在 功能树/全部Cron/数据实体/数据流 之后):
· L4 元监控各层状态表
· L1 九项功能判据逐项状态
· L2 卫生问题清单
· L3 最近修复动作时间线(报备记录)
你打开 Dashboard → 健康 → 🩺自检体系 就能看到系统各方各面的健康状态,
以及自检系统自身的运转情况。责任矩阵已写入 dev-spec.md 第三章。
代码已提交合并(246: e69109fd)。"""
payload = json.dumps({"to": "hmo@yoin.fun", "body": msg, "type": "chat"}).encode()
req = urllib.request.Request("http://127.0.0.1:5805/", data=payload,
headers={"Content-Type": "application/json"})
try:
print("XMPP:", urllib.request.urlopen(req, timeout=10).read().decode()[:80])
except Exception as e:
print("XMPP fail:", e)