Files
MoFin/docs
hmo 08eef1e181 feat(self-check): L0-L4 layered self-check architecture with LLM auto-repair
User directive: daily not weekly; clear responsibilities per layer with no
overlap; functional criteria (does the function WORK) not process liveness;
problems get FIXED via LLM with file-and-report discipline (act first,
report after); plus a meta-layer watching the watchers; deeply integrated
into F健康.

Architecture (responsibility matrix in dev-spec.md):
- L0 agents_health_check (5min): port/HTTP/DB liveness + auto_heal executor
- L1 functional_health_check (15min trading): per-module FUNCTIONAL
  criteria — output freshness/validity per REGISTRY (live_prices/market_
  snapshots/mtf_cache/macro_context/bot/LLM/cron engine), not process alive
- L2 system_hygiene_audit (daily 08:20, was weekly): divergence/hardlink/
  zombie/orphan/dead-cron/db-freshness
- L3 self_repair (30min): reads L1/L2 failures -> LLM diagnoses -> executes
  WHITELISTED repair actions directly (rerun_script/restart_service/
  sync_links/switch_llm_key/none) -> repair_log.jsonl + XMPP report.
  Max 2 repairs/module/day anti-loop. LLM unavailable -> rule fallback.
- L4 meta_watchdog (hourly): checks L0-L3 output freshness + L3 cron
  registration + XMPP bridge; direct XMPP alert as last resort

Retired (overlap): Cron监护-高频 (cron_watchdog -> L3), 全局cron健康监控
(cron_health_monitor -> L1).

Dashboard: mofin_health.py now emits self_check section (functional/meta/
hygiene/recent_repairs); mofin_health.html new '🩺 自检体系' tab rendering
L4 layers, L1 module checks, L2 issues, L3 repair history.

E2E verified: stopped xmpp bot -> L1 flagged fail -> systemd recovered ->
L3 LLM correctly diagnosed 'none needed' and logged; rerun_script whitelist
path executes real scripts successfully; meta_watchdog all-green after fix.
2026-07-20 19:39:58 +08:00
..

MoFin 文档中心

文档驱动开发。每次代码变更必须同步更新对应文档。


阅读指引

🚀 新手入门(按顺序读)

# 文档 内容 时间
1 SYSTEM_ARCHITECTURE.md 系统总览:架构图、数据流、模块职责 10 min
2 portfolio-data-model.md 核心数据模型:表结构、币种规则、常见错误 10 min
3 DEVELOPMENT_STANDARDS.md 开发规范:代码结构、DB 规范、Prompt 规范、开发流程 15 min
4 CHANGELOG.md 变更日志:所有改动的完整记录 5 min

🔧 日常开发

文档 何时查阅
DEVELOPMENT_STANDARDS.md 每次写代码前
TEST_PLAN.md 每次改完代码后跑测试
CHANGELOG.md 改完后追加变更记录

📊 运维参考

文档 内容
cron-catalog.md Cron 任务清单(知微维护)
decisions-db-migration.md JSON→DB 迁移记录( 已完成)

📦 历史文档(archive/

旧的设计文档、需求文档、分析报告。仅供参考,不代表当前系统状态。


文档规范

  • 每个 .md 文件顶部标注版本和日期
  • 过时内容追加 > **已废弃** — 见 XXX 替代
  • 不直接删除旧文档,移到 archive/ 保留
  • 交叉引用使用相对路径 [xxx](xxx.md)

当前系统状态

  • 数据:纯 SQLite/home/hmo/web-dashboard/data/mofin.db
  • 币种:港股存 HKD,A 股存 CNY,汇总时转换
  • JSON:已全部移除,无残留
  • 测试scripts/run_all_tests.py — 33/33 通过
  • 最新CHANGELOG.md 查看完整变更