Files
MoFin/docs/cleansweep-20260819.md
T

53 lines
3.1 KiB
Markdown
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.
# MoFin 系统大扫除记录(2026-08-19,顺瓜摸藤)
## 背景
系统经历无数次改版重构,存在:
- 多写入造成数据被篡改(同表被多模块反复覆写)
- 孤立死实体 / 幽灵数据流
- 违背"重评=12维LLM"原则的技术快算路径
- 误用废弃 decisions.json 的遗留模块
## 方法(老莫指引:顺瓜摸藤)
从每张表出发 → 检索使用它的代码 → 分析表/代码/数据流 → 梳理清楚 → 一次性标注清理。
## 已完成工作
### 1. 备份
- 246 本地 SQLite 完整备份: `mofin_backup_cleansweep_20260819.db`7.55GB61表,验证通过)
- (跨机到本机受网络限制,本地备份保留)
### 2. 数据流地图
- 生成 `docs/data-flow-map-20260819.md`:56 表的生产者/消费者/多写方风险
### 3. 精确数据流扫描器
- 解析 mofin_db 公共函数 → 表映射 + 脚本函数调用 → 准确识别每表读写方
- 修正了旧扫描(mofin_health.py 正则扫描)漏检问题
### 4. 核心修复:参数交叉覆写(根治!)
- **问题**holding_strategies 被 17 个模块写,辅助模块(clean_watchlist/branch_scanner/holdings_reconciliation 等)连带覆写策略参数(entry/stop/tp/rr)→ 参数被反复篡改
- **旧保护**依赖"有无 per_stock_12d 快照"判断,无快照的票(如00020)保护不触发
- **新方案(commit a5dcb913**:白名单机制——只有 per_stock_12d/batch_12d/promote 能写策略参数,其他一律保留DB当前参数。**已验证**:00020 辅助模块无法覆写(参数保持),600262 per_stock_12d 正常写。
- **效果**:同表被反复覆写问题根治!
### 5. 数据实体Tab增强
- mofin_health.py 加 writer_count/reader_count/multi_writer/risk 字段
- mofin_health.html 数据实体Tab加"多写方风险"徽标 + 红色篡改风险横幅
### 6. 死表清理(已删5个,均备份后)
- 4 个 `_bak_` 备份表(market_indicators_bak/market_regime_bak/regime_cycles_bak/strategy_regime_perf_bak
- `stock_announcements`40800行,代码零引用)
### 7. 重评路径纠正
- price_monitor 三处技术快算改为调用 per_stock_reassess(真12维LLM重评)+ 30分钟冷却
- 补充方法论文档 3.3b:4 类重评体系(选股/买触发/卖触发/盘前全量)
## 待办(用户不在,需后续确认)
- **isolated 表**state_meta/stock_capital_flow(924万行)/stock_sectors_em 等——虽代码有引用但写入方缺失,需确认是否该有写入方
- **xiaoguo(小果)系列**xiaoguo_scan_tracker + xiaoguo_scanner——小果可能已废弃,需确认后清理
- **辅助模块代码**holdings_reconciliation/clean_watchlist/prune_branches/branch_scanner 读废弃 decisions.json——已被权威保护拦截不影响参数,但代码冗余待清理
- **多写方收敛**candidates(16写/scanner各自写候选池合理)、todos(7写) 需评估
## 复核要点
- **教训**:不能盲信扫描/Tab(旧版把活跃表误标孤立);必须"顺瓜摸藤"逐表人工核实代码引用
- **教训**:权威保护不能依赖"有无快照",必须白名单(谁有资格写)