Skip to main content

scope_for_proto_id

Function scope_for_proto_id 

Source
pub fn scope_for_proto_id(proto_id: u32) -> Option<Scope>
Expand description

Futu API protocol id → 所需 scope 的通用映射

gRPC 和核心 WS 都用这个函数做 scope 检查。proto_id 常量定义在 futu-core (circular dep 顾虑下这里手动枚举);新增 proto 时必须同步更新这里的 match 分支,否则落到 catch-all TradeReal 被拒(fail-closed)。

v1.4.104 codex round 1 F4 (P2) fix: 显式 trade/acc protos 用 SCOPED_TRADE_REAL_PROTOS / SCOPED_TRADE_UNLOCK_PROTOS / SCOPED_ACC_READ_PROTOS 暴露给 invariant test, 让 body_aware::build_check_ctxs + response_filter::FilterRegistry 共同 覆盖. 加新 scoped proto 时:

  1. match 分支加 → 让 scope check 知道新 proto
  2. 把 proto_id 加到对应的 SCOPED_*_PROTOS const list (机械 enumeration)
  3. 其中 一处 (body_aware OR response_filter OR EXPLICIT_NO_ACC_ID_PROTOS) 必须 cover, 否则 cross_surface_invariants test 挂.
proto_id 范围所需 scope
1xxx 系统(InitConnect / GetGlobalState / KeepAlive / …)无(放行)
3xxx 行情(含 push updates)qot:read
2005 UnlockTradetrade:unlock(v1.4.104 codex F1 P1 fix)
2202 PlaceOrder / 2205 ModifyOrder / 2237 ReconfirmOrdertrade:real
2xxx 账户只读(AccList / Funds / Positions / Orders / Deals / 费率 / push)acc:read
其他catch-all trade:real(fail-closed)