feat(hygiene): anti-redundancy enforcement — spec rules + weekly audit
Root cause analysis of the 2026-07-20 redundancy incident: 1. No single-source-of-truth rule -> same file legitimately lived in 4+ locations, diverging silently 2. Relative path resolution (Path(__file__).parent/'data') -> each hardlinked copy of mofin_db.py pointed to a DIFFERENT database 3. 'Backup habit' left .bak/legacy files in production dirs, which monitoring then scanned and reported as false alarms 4. Half-done migrations: DB tables created but old JSON writers/readers stayed (price_events), old files stayed 5. Dead modules never got buried: xiaoguo 'dead' but bot ran 8 days as root eating 2.5GB 6. Monitoring checked 'does it exist' not 'is it alive' -> stale file mtime reported as 'pipeline stalled 14 days' (false alarm) 7. No 'system hygiene' as a check category at all Prevention implemented: - dev-spec.md v2.0: 五条红线 -> 十条红线 #6 single source of truth (hardlink only, no independent copies) #7 absolute data paths only (no __file__-relative data resolution) #8 no backups/legacy in production data dirs (archive immediately) #9 dead module burial checklist (6 mandatory steps) #10 monitor liveness (DB table freshness) not existence - File Location Constitution: canonical location per content type - NEW system_hygiene_audit.py: weekly Monday 07:30 cron checking diverged copies / broken hardlinks / zombie processes / orphan data files / dead cron scripts / DB freshness -> hygiene_report.json + XMPP - specs/hygiene.json: module spec per red line #1 - Verified: audit found 5 real issues on first run, all fixed, re-run clean
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import json, urllib.request
|
||||
|
||||
msg = """[笑笑] 系统冗余全面审计完成 — 报告已生成
|
||||
|
||||
按你的要求只审计不动手。报告位置:
|
||||
📄 本地 vault: daily/调研笔记/系统冗余审计-20260720.md
|
||||
📄 246 Obsidian: daily/系统冗余审计-20260720.md
|
||||
|
||||
核心发现(9 类问题):
|
||||
|
||||
🔴 高危×3:
|
||||
1. 31 个同名 .py 文件内容分叉(deploy vs MoFin/scripts vs MoFin根 vs .hermes/scripts)——今天"修了还报错"的病根就是这个
|
||||
2. 数据库碎片化:除主库外还有一个"第三库"(含 17340 行 sector 数据需合并)+ 3 个废弃小库
|
||||
3. 僵尸进程:xmpp_xiaoguo_bot 以 root 跑了 8 天吃 2.5GB 内存;xiaoguo-tunnel 对着不可达的 Mac Mini 循环重连
|
||||
|
||||
🟡 中危×4:
|
||||
4. 三套 dashboard(8899/5803/9090)+ 两套 health check + 两套 auto_heal
|
||||
5. 小果生态残留:2 进程 + 4 脚本 + 2 服务 + 2 cron(扫描死了但其余还活着)
|
||||
6. 26 个 >14 天的遗留 JSON 文件
|
||||
7. projects/ 与根目录两对重复目录(1.4G + 2.2M)
|
||||
|
||||
🟢 低危×2:
|
||||
8. 10 个被禁用的 cron 任务
|
||||
9. 18 个旧日志 + 旧 .bak 文件
|
||||
|
||||
报告末尾有 7 个需要你拍板的问题(Q1-Q7),最关键的两个:
|
||||
- Q1: xiaoguo gateway (8645) 的"压缩策略"还在用吗?
|
||||
- Q2: xiaoguo-quick-scan(今天还在跑)和 market_scanner 什么关系?
|
||||
|
||||
你看完报告定方向,我再按决定执行。"""
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user