Skip to content

refactor: harden trading paths and consolidate IPC architecture#15

Open
Rogers-F wants to merge 1 commit into
qtcls:version/v4.0.xfrom
Rogers-F:refactor/ipc-trading-hardening
Open

refactor: harden trading paths and consolidate IPC architecture#15
Rogers-F wants to merge 1 commit into
qtcls:version/v4.0.xfrom
Rogers-F:refactor/ipc-trading-hardening

Conversation

@Rogers-F

Copy link
Copy Markdown

概要

对 v4.0.x 客户端做的一轮系统性审计与加固,为便于审阅已汇总为单个提交(原始开发历史共 63 个提交)。净改动 175 文件、+2820 / -8139(净减约 5300 行)。

主要内容

实盘控制路径加固(资金安全)

  • 新增 src/shared/lib/trading-guard.ts:开启实盘的前置校验单源化(权重结构化校验、QMT 配置校验、固定顺序)
  • setAutoTrading 改为 async 权威 ack:main 侧自校验,enable 失败/调度失败/disable 统一走 enforceTradingOff(置 OFF + 落盘 + 强杀 rocket + 有界确认),renderer 端 fail-closed
  • wakeUpRocket 四道前置门控;account_id === '0' 手动下单哨兵并入守卫

IPC 架构整理

  • 处理器从 preload 回迁至 src/main/ipc(修复进程层级倒置)
  • 频道常量单源化 + 快照测试基线;监听器生命周期治理(移除共享 removeAllListeners 误伤)

启动与系统层

  • 单一 app-ready 序列;tray/powerMonitor 一次注册;窗口显式 contextIsolation: true
  • Hono 回调服务仅绑定 127.0.0.1,真实 listening 后才上报端口
  • powerMonitor 在 Windows 启用:睡眠时 main 权威 fail-closed 关停实盘,唤醒不自动恢复

卫生

  • 删除 13 个死 hook 与 send-python-output 死特性;换仓时间展示 formatter 单源化;typecheck 清零
  • CI actions 升主版本(checkout/setup-node/gh-release v4+)

验证

  • pnpm typecheck(node + web)= 0 错误
  • 频道快照脚本与交易守卫纯函数用例(32/32)通过
  • biome lint 触碰文件零诊断

说明

本分支基于 8ff648c,晚于其后的 3 个最新提交(加速数据源 / min-data / client.env),与之存在 6 个文件的冲突(主要因 IPC 处理器回迁 main)。如方向认可,我可以跟进 rebase,把这 3 个提交的改动迁入回迁后的结构。

Squashed from 63 commits of audit and hardening work on top of 8ff648c:

- Trading guard: single-source preconditions (shared/lib/trading-guard),
  authoritative setAutoTrading ack from main, fail-closed enable path,
  enforceTradingOff with bounded rocket kill confirmation
- IPC: handlers moved from preload to src/main/ipc, channel constants
  single-sourced, listener lifecycle fixes, snapshot-tested channel set
- Hono callback server bound to 127.0.0.1, resolves only when listening
- Windows: explicit contextIsolation, single app-ready sequence, tray and
  powerMonitor registered once; powerMonitor enabled on Windows with
  fail-closed suspend handling
- Dead code removal (13 unused hooks, send-python-output feature),
  formatter single-sourcing, typecheck baseline cleaned to zero
- CI: bump checkout/setup-node/gh-release actions to current majors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant