Files
MoFin/docs
hmo 4f83ee8a01 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
2026-07-20 19:04:05 +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 查看完整变更