Commit Graph
496 Commits
Author SHA1 Message Date
知微 a0815bb39b Merge branch 'session-work' 2026-07-21 13:48:55 +08:00
hmo 3e5d841e58 chore: data/backups/ 移出跟踪 2026-07-21 13:48:53 +08:00
知微 a245c8b4dd fix: price_monitor crash when shares is string + type guard in write_holding_strategy
Root cause: holding_strategies.shares field got set to literal string
'write_holding_strategy' for 6 records, causing TypeError at
price_monitor.py line 611 ('>' not supported between str and int).

Fixes:
1. price_monitor.py: Replace set comprehension with safe loop that
   checks isinstance before comparison. Non-numeric shares treated
   as holdings for safety.
2. mofin_db.py write_holding_strategy: Add type guard that resets
   non-numeric shares to 0 with warning.
3. Data fix: Updated 5 corrupted holding_strategies records from
   holdings table (300035/300308/300750/518880/00700).
   Set 002594 (watchlist) shares=0.
2026-07-21 13:47:52 +08:00
知微 91885f7623 Merge branch 'session-work' 2026-07-21 13:47:31 +08:00
hmo 5422b0a11d feat(db): 每日DB在线备份(07:50,留14天) + 管道审计malformed重试一次再告警(瞬态WAL损坏防误报) 2026-07-21 13:47:10 +08:00
知微 34337fc5b7 clean: 移除早上健康检查/系统审计中的小果残留引用(二次提交—deploy guard恢复旧版后重新应用) 2026-07-21 12:05:43 +08:00
知微 9d3cab2306 clean: 移除盘中自检/早上健康检查/系统审计中的小果残留引用 2026-07-21 12:03:21 +08:00
知微 945941d3d0 fix: 同步scripts/intraday_health_check.py——移除小果残留(与deploy/profile-scripts一致,硬链共享inode)
84d72dfd 只修了 deploy/profile-scripts/ 版本,但 git 里 scripts/ 版本仍是
旧代码(含check_xiaoguo/8645端口/小果Bot/小果信号堆积)。两个文件硬链共享
inode,deploy_guard 检测到 scripts/ 版漂移就 git checkout -- 回滚旧版,
连带覆盖 deploy/profile-scripts/ 版的修复,导致盘中自检持续误报。

同步提交后 deploy_guard 不再回滚。
2026-07-21 11:58:34 +08:00
知微 a782a83953 sync: price_monitor SIGALRM fix to scripts/ (legacy location) 2026-07-21 11:31:44 +08:00
知微 c180129a1a fix: add SIGALRM 120s hard timeout to price_monitor lock
price_monitor.py 进程锁无硬超时,LLM策略重评耗时9-10分钟时
锁文件阻止后续*/2 cron执行,造成10分钟监控盲区。

新增:
- _handle_sigalrm: SIGALRM处理器,自动清理锁后退出
- signal.alarm(120): 获锁后设120s硬上限
- signal.alarm(0): 正常完成时取消定时器
2026-07-21 11:29:06 +08:00
知微 f6d10a41af Merge branch 'session-work'
# Conflicts:
#	deploy/profile-scripts/intraday_health_check.py
2026-07-21 10:43:41 +08:00
hmo 29e0e6c8b4 fix(688775事件): bot不再静默吞消息 + 价格推送分级 + 小果假警报清理
1. bot call_hermes 失败: 10s重试一次, 仍失败回兜底消息(网关暂时不可用)
   ——此前连接被拒时用户消息被静默吞掉(688775事件根因)
2. price_monitor 推送分级: 破止损/重评确认信号/持仓急跌=ACTION直通;
   未确认进区提示=聚合成一条摘要走INFO(30min限1条+8行截断)
   ——今早一秒一条十几连发+思特威英诺特双发
3. alert_helper ACTION 增加5min内容去重(防竞态双发)
4. intraday_health_check 删除小果全部残留检查(已退役, 假警报
   导致知微旧自愈执行器烧150k+token/session去调查并直接改代码)
2026-07-21 10:41:32 +08:00
知微 84d72dfd85 fix: intraday_health_check移除小果残留——check_xiaoguo/8645端口/小果bot/小果信号堆积
小果已全线归档(2026-07-20 Xiaoxiao重构)。盘中自检脚本仍残留:
- check_xiaoguo()函数
- 小果XMPP Bot离线检测
- 8645端口检测
- xiaoguo信号堆积检查(含import socket)
- main()中check_xiaoguo()调用

全部移除,匹配已修复的运行版本。
2026-07-21 09:46:43 +08:00
hmo e6e79ced0d docs: 红线#12 告警信噪比纪律(alert_helper两级通道) 2026-07-21 02:44:56 +08:00
hmo 1e71a2d852 feat(alerts): alert_helper 统一告警网关——信噪比控制
两级通道:
- ACTION(买入信号/重点推荐/部署验证失败): 直通不限速, 🚨醒目前缀
- INFO(部署/卫生/修复/螺旋报备): 同类30min限1条 + ≤8行截断 +
  24h内容去重(同一问题不重复轰炸) + 压制计数透明披露

6个调用点全部迁移: deploy_guard/hygiene/spiral/self_repair(INFO)
+ batch_reassess/per_stock_reassess 买入信号(ACTION)
解决: 真正有意义的信息(重点推荐操作)不被纯通知淹没
2026-07-21 02:43:57 +08:00
hmo 54652bff12 fix(verify): functional_health/mofin_health 新鲜度阈值 1h→16h(两者均交易时段运行,夜间必假警报) 2026-07-21 02:14:06 +08:00
hmo b1db424b8d chore: data/prompts/ 移出跟踪(提示词注册表为运行时产物) 2026-07-21 02:12:13 +08:00
hmo 1806b6a174 fix(SSOT): 4个库文件副本移出git跟踪(红线6:只允许硬链接,不允许独立副本)——硬链与git跟踪本质冲突:checkout重建文件断链→内容与提交版不同→guard判漂移回滚→sync重链→再dirty→merge被阻。移出跟踪后:根目录mofin_db.py/mo_data.py为唯一tracked canonical,副本由sync脚本以硬链重建 2026-07-21 02:09:25 +08:00
hmo 609ef06e6e fix(guard): CODE_PATHS补scripts/整目录+mofin_db/mo_data根文件——覆盖库文件硬链造成的合法dirty 2026-07-21 02:08:23 +08:00
hmo beee453bf3 fix: 同步4个库文件副本的提交内容与根canonical一致——消除deploy_guard回滚↔sync重链拉锯(guard实测抓到漂移并回滚,机制自证有效,但提交内容必须同源) 2026-07-21 02:06:55 +08:00
hmo 3e84cbc17e ux: 系统告警统一加'📟【MoFin系统·XX】(非知微本人)'前缀——告警与知微本人消息可一眼区分 2026-07-21 02:04:55 +08:00
hmo 6d1d4a5164 fix(SSOT): 库文件统一硬链到MoFin根目录canonical——今晚三处改造差点跑在陈旧副本上
- mo_data.py 提升为根目录canonical(含tag修复), deploy/profile-scripts/
  scripts/ profile脚本目录 全部硬链到根
- mofin_db.py 同理(含strategy_history/tag迁移), 四处硬链统一
- sync_profile_scripts.sh 增加库文件链接步骤, merge后自动恢复
- 根因: deploy/profile-scripts/mofin_db.py 是7-20陈旧副本(无snapshot),
  profile脚本目录mo_data.py无tag——hygiene分叉副本检查正确报警
2026-07-21 02:00:26 +08:00
hmo 2054c6e6f9 fix: state.db 时间戳单位自适应(秒/毫秒混存)+ default profile 无sessions表静默跳过 2026-07-21 01:54:59 +08:00
hmo 839c6fc2ff feat(self-heal): 三盲区系统性补丁——自愈体系覆盖今晚三类故障
1. agent_spiral_watchdog.py (新增,10min cron): state.db 检测运行>15min
   且消息>80条的 api session(螺旋特征), XMPP告警+去重。补 603288 事件
   '无watcher看agent会话本身'盲区
2. deploy_guard: 自动merge后自动跑 verify_deployment.py, 失败项立即
   XMPP告警。补'提交级回归无监控'盲区(知微stale提交事件)
3. system_hygiene_audit: 新增第7项检查'指令冻结session'——常驻session
   启动时间早于SOUL.md mtime且6h内仍活跃 → 告警需bump/重启。
   补'system_prompt冻结'盲区; 6h活跃度过滤防误报已遗弃session
2026-07-21 01:53:11 +08:00
hmo ab258c6264 chore(bot): xmpp session v3->v4 刷新知微冻结指令(部署纪律/识图知识更新),对话上下文重置 2026-07-21 01:42:14 +08:00
hmo ae0c7d1ca3 fix(L3): self_repair 迁移 llm_client(OCG直连无session) 废弃常驻'self-repair' session(指令冻结+上下文累积) 2026-07-21 01:39:54 +08:00
hmo 95d07f6a11 fix(guard): porcelain路径解析健壮化(line[2:].strip + rename格式处理) 2026-07-21 01:19:53 +08:00
hmo a69b246c57 feat(guard): 部署一致性守卫 deploy_guard.py + 知微运维纪律 + 健康JSON移出跟踪
- deploy_guard.py (15min cron): 代码漂移自动回滚(仅未提交改动)+
  session-work可快进时自动merge部署+幂等重链+cron引用完整性,
  状态落盘JSON, 有动作即XMPP报备
- docs/zhiwei-ops-discipline.md: 知微纪律——禁止直接编辑被跟踪代码/
  禁stale提交/禁直调gateway批量LLM; 自愈白名单(rerun/restart/
  sync/switch_key)本不改代码, 与纪律不矛盾; 紧急热修走git流程,
  提交到session-work后guard 15min自动部署
- dev-spec 红线#6 补充部署守卫机制
- static/mofin_health.json 移出git跟踪(运行时产物, 常驻dirty
  会废掉漂移检测)
2026-07-21 01:17:01 +08:00
hmo 574151aee9 docs: 红线#11 批量LLM调用禁走hermes gateway agent通道(603288事件) 2026-07-21 01:05:08 +08:00
hmo cd530c2463 fix(llm): 重评直连OCG上游绕过hermes agent运行时 + 全线切flash + prompt输出纪律
事故根因(2026-07-21): hermes gateway /v1/chat/completions 非透传,
每个请求创建带工具的agent会话。一次603288重评螺旋35分钟/44次
terminal调用/输入153k token, 客户端超时后服务端空转, 重试叠加
新会话自我DDoS。

- llm_client 重写: OCG直连为主(key运行时从hermes config.yaml
  ocg-key6读取, 不落盘), gateway兜底(agent模式仅应急)
- REASSESS_MODEL: pro -> flash (A/B实测新prompt下质量差距微弱,
  flash快40%)
- prompt输出纪律: 【建议仓位】不可省略(非买入写'不新建仓'),
  禁止structured_data/XML/JSON块, 禁止寒暄开场白
- batch main 双通道预检(全挂才退出)
2026-07-21 01:00:47 +08:00
hmo 5b44086c8a fix: reports匹配链修正(标题匹配不再是死代码) + strategy_history空历史时降级当前行 2026-07-20 23:58:45 +08:00
hmo 9a8e3344ac restore: candidate_filter busy_timeout + premarket Step1.5 摘要字段(知微17:31 stale提交回滚恢复至7b26c373已验证版本) 2026-07-20 23:53:03 +08:00
hmo de9927a627 重评核心重构:ds-v4-pro + 原策略全文 + strategy_history + 前端三改造
后端(重评管线):
- 新增 llm_client.py 共享客户端: REASSESS_MODEL=deepseek-v4-pro 单点,
  gateway预检(fail-fast), 150s超时+1次重试, 永不抛异常
- batch_reassess/per_stock_reassess: curl/urllib -> call_llm,
  prompt传入原策略全文+当前参数+最近3条变更, 输出 维持/修改判断+
  修改点理由+最终新策略, max_tokens 4096
- mofin_db: 新增 strategy_history 表 + snapshot_strategy_history(),
  write_holding_strategy 覆写前自动快照(保留20条/code)
- mofin_db: holding_strategies 补 tag 列迁移 + 写入保留
  (tag缺席=保留旧值, 显式传''=允许清除), 修复推荐标签被静默丢弃
- mo_data.read_decisions: SELECT 补 tag
- stale_detector/promote_candidates: 子进程超时 240/60 -> 480s

前端:
- 移除 报告Tab -> mofin_health 全部流程/Cron 表加 最后十次 列
  (modal列表->详情), /api/reports 支持 cron+script 多路匹配
  (jobs.json name->id 解析 + 文件名/标题子串兜底)
- 移除 决策库Tab
- 盯盘Tab 重构: 全部持仓+自选, sort_group 分组(推荐/持仓/自选),
  推荐行琥珀高亮+🔥badge+行内策略, 新增 操作策略 列查看
  最近3次完整策略(/api/strategy_history/<code>, 表缺失时降级当前行)
- 提示词Tab: registry.py 数据路径改回 /home/hmo/MoFin/data/prompts
  (红线: 数据只在规范数据根), 空态提示初始化命令
2026-07-20 23:51:24 +08:00
知微 0e13b3edda merge: reassess timeout + zone sanity gate 2026-07-20 22:05:05 +08:00
知微 90f07b4eba chore: sync 2026-07-20 22:05:03 +08:00
hmo 7b26c373d1 fix(reassess): stale_detector timeout 60->240s + batch cap 5/run + GATE_ZONE_SANITY
Three issues from zhiwei's strategy report:

1. '37 reassess all timed out (subprocess 60s)': real cause is per-call LLM
   latency exceeding the 60s per-subprocess limit during the key5-dead/
   gateway-unstable window. NOT 'no concurrency control' as reported (60s
   is per stock, not for the batch). Fixes: per-call timeout 60->240s
   (LLM cold-start is 20-100s), and cap AUTO_REASSESS batch to 5 stocks
   per run with remainder continuing next run (was unbounded serial calls
   that also blew the 120s cron script window).

2. '15 stocks entry-zone center wrongly 97.0': quality gates had no
   zone-sanity-vs-price check, so bad data (bad quote or LLM template
   output) could be written freely. New GATE_ZONE_SANITY (CRITICAL):
   zone center must be within 0.3x-3x of current price. Verified: rejects
   the exact 97-center-vs-5.69-price corruption, passes legit zones.

3. 'reassess overwrites manual SQL fixes': true by design; with
   GATE_ZONE_SANITY at write time, reassess can no longer overwrite good
   values with garbage - invalid writes get rejected + flagged instead.
2026-07-20 22:05:00 +08:00
知微 8d6082f0c2 merge: ocr pipeline fixes 2026-07-20 21:43:04 +08:00
知微 3eb214f3a6 chore: sync 2026-07-20 21:43:03 +08:00
hmo 299ddc1796 fix(ocr+bot): image download race, SenseNova context, log path, encoding
Root causes of the screenshot 404 incident:
1. RACE: client uploads image AND sends message concurrently; bot received
   the message before the upload finished writing, so its GET hit a 404
   error page (<100B treated as failure). FIX: _download_image now retries
   3x with 2s backoff.
2. Zhiwei mentioned tesseract/小果 because the failure text never told her
   the pipeline IS SenseNova. FIX: failure messages now name SenseNova
   explicitly and ask for resend.
3. log_xmpp never worked for the bot: sys.path used relative '../..' from
   a symlinked __file__ which resolved to '/' instead of MoFin root. This
   is why the '最近对话' panel never had bot chat data (only cron script
   entries). FIX: absolute path per red line #7. Verified: test message
   now lands in xmpp_messages.jsonl.
4. My PowerShell -replace corrupted the file encoding (UnicodeDecodeError
   crash loop on restart). Restored from git HEAD and re-applied edits with
   the edit tool. Lesson: never use PowerShell string replace on UTF-8
   source files with Chinese content.
5. functional_health: new sense_ocr module (OCR config presence +
   SenseNova API TCP reachability), no token cost.
2026-07-20 21:42:59 +08:00
知微 c01c6cd266 merge: dev-spec v2.1 numbering fix 2026-07-20 21:21:27 +08:00
知微 2b79c1dc44 chore: sync 2026-07-20 21:21:25 +08:00
hmo 60dbb64f92 docs(dev-spec): v2.1 — fix section numbering + outdated refs
Zhiwei flagged: '十条红线' but she counted 14. Real issues found:
- duplicate section numbers: two '三、' (验证闭环 + 自检体系矩阵),
  two '四、' (开发流程 + 部署环境) -> renumbered 一~七 sequentially
- doc index said '含五条红线' (stale from v1) -> '含十条红线'
- F 小节 still used old Tier1/Tier2 framing -> aligned to L0/L1-L2
  with pointer to the L0-L4 matrix section
- version bump v2.0 -> v2.1
Minimal edit: no content changes beyond numbering/consistency.
2026-07-20 21:21:21 +08:00
知微 5ab63b5c9d merge: zhiwei reply doc 2026-07-20 20:57:24 +08:00
hmo 94883539de docs: reply to zhiwei on cron error status accuracy 2026-07-20 20:57:20 +08:00
知微 ad6a416ef4 merge: watchdog agent.log check 2026-07-20 20:56:05 +08:00
知微 c971d6bced chore: watchdog fix 2026-07-20 20:55:34 +08:00
hmo 10a37f10f9 fix(watchdog): gateway session check now uses agent.log scan, not live LLM ping
Gateway看门狗-知微 was erroring (exit -15): its check_session_health did a
live LLM ping with 25s timeout. Cold-start LLM latency is 20-100s so the
ping always timed out -> false '不健康' verdict -> false gateway restart
-> and each 10-min run burned 22k tokens.

Now uses xmpp_logger._scan_agent_log (zero cost, reads real call results):
- ok if last real call succeeded
- unhealthy only if last call explicitly failed
- idle (no recent calls) counts as healthy
Verified: watchdog job now status=ok.

Also: triggered all 6 weekend 'Blocked' jobs via hermes cron run — all
now status=ok, proving the hardlink fix holds.
2026-07-20 20:55:30 +08:00
知微 e5b0335f93 merge: zhiwei briefing doc 2026-07-20 20:37:21 +08:00
知微 dae60bb92f chore: sync before briefing merge 2026-07-20 20:37:20 +08:00
hmo c42769f293 docs: zhiwei briefing on 2026-07-20 system changes 2026-07-20 20:36:50 +08:00