{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "设备上行 · FA/04 领域处理与推送",
    "locale": "zh-CN",
    "quality_profile": "showcase",
    "column_fit": "spread",
    "viewBox": [
      1380,
      620
    ]
  },
  "participants": [
    {
      "id": "device",
      "type": "backend",
      "label": "device"
    },
    {
      "id": "redis",
      "type": "database",
      "label": "Redis"
    },
    {
      "id": "insight",
      "type": "backend",
      "label": "insight"
    },
    {
      "id": "realtime",
      "type": "backend",
      "label": "realtime"
    },
    {
      "id": "app",
      "type": "frontend",
      "label": "App / 小程序"
    },
    {
      "id": "mysql",
      "type": "database",
      "label": "MySQL"
    }
  ],
  "messages": [
    {
      "id": "m1",
      "from": "device",
      "to": "redis",
      "y": 160,
      "label": "过滤旧功能水位",
      "variant": "default",
      "note": "先解析协议；过滤旧功能点，记忆模式补齐后再过滤。全部过期直接正常返回。"
    },
    {
      "id": "m2",
      "from": "device",
      "to": "redis",
      "y": 189,
      "label": "条件累计与状态缓存",
      "variant": "emphasis",
      "note": "非BLE端口0：fn3累计使用分钟，fn5写提醒缓存，fn18写在线状态；久坐提醒同步system落库、fn20型号更新等条件动作详见文档。"
    },
    {
      "id": "m3",
      "from": "device",
      "to": "redis",
      "y": 218,
      "label": "读取旧习惯快照",
      "variant": "default",
      "note": "必须发生在本帧组件快照覆盖之前；采集时间取本次处理时间，重放会重新构造。"
    },
    {
      "id": "m4",
      "from": "device",
      "to": "insight",
      "y": 247,
      "label": "同步习惯采集",
      "variant": "emphasis",
      "note": "InsightEventBridge.collect传入协议、旧值与观察时间；关闭采集或测试黑名单时跳过。"
    },
    {
      "id": "m5",
      "from": "insight",
      "to": "redis",
      "y": 276,
      "label": "起点与事件日志",
      "variant": "default",
      "note": "ON先SET onset再append ON事件；OFF先读取并删除onset，再append OFF事件；起点变更与事件追加非事务，没有源记录去重键。"
    },
    {
      "id": "m6",
      "from": "insight",
      "to": "device",
      "y": 305,
      "label": "返回；采集可吞错",
      "variant": "return",
      "note": "桥接与采集器均可吞错，正常RPC返回也不保证每个习惯事件都已append。"
    },
    {
      "id": "m7",
      "from": "device",
      "to": "redis",
      "y": 334,
      "label": "更新组件快照",
      "variant": "emphasis",
      "note": "协议投影到组件Hash，写异常告警后吞掉；多Hash更新没有共同事务。"
    },
    {
      "id": "m8",
      "from": "device",
      "to": "realtime",
      "y": 363,
      "label": "同步提交 type7/10",
      "variant": "emphasis",
      "note": "type7过滤固定功能；坐垫11/12/13拆type10，有健康页观众才发送，观众查询异常默认放行。"
    },
    {
      "id": "m9",
      "from": "realtime",
      "to": "device",
      "y": 392,
      "label": "返回：仅提交分发",
      "variant": "return",
      "note": "TOPIC消息提交本机队列，返回不代表查询到订阅、成功发送或客户端收到。"
    },
    {
      "id": "m10",
      "from": "realtime",
      "to": "app",
      "y": 421,
      "label": "异步实时推送",
      "variant": "dashed",
      "note": "分发线程查Redis绑定；本地发送池或远端节点Pub/Sub；队满可丢消息，无离线重放与业务送达ACK。"
    },
    {
      "id": "m11",
      "from": "device",
      "to": "insight",
      "y": 450,
      "label": "同步坐姿结算",
      "variant": "emphasis",
      "note": "processPosture异常向上抛；仅普通上行坐垫11温度/12重心/13坐姿参与实际结算。"
    },
    {
      "id": "m12",
      "from": "insight",
      "to": "redis",
      "y": 479,
      "label": "坐姿状态与累计",
      "variant": "default",
      "note": "更新latest/session/today/active，TTL25小时；闭合会话通常先入内存队列，队满同步尝试写库。"
    },
    {
      "id": "m13",
      "from": "insight",
      "to": "mysql",
      "y": 508,
      "label": "独立异步落库",
      "variant": "dashed",
      "note": "习惯定时消费者与坐姿session worker独立运行；总调度与坐姿worker默认关闭，坐姿submit仍入队。"
    },
    {
      "id": "m14",
      "from": "device",
      "to": "redis",
      "y": 537,
      "label": "尝试水位；随后 ACK",
      "variant": "emphasis",
      "note": "坐姿RPC返回后尝试markApplied；其Redis错误仅warn；handler正常返回后由分区入口ACK，异步落库不构成ACK屏障。"
    }
  ],
  "cards": [
    {
      "dot": "violet",
      "title": "条件参与的服务",
      "items": [
        "久坐提醒同步调用system存站内消息；异常才走notification，identity/media非逐帧必经。"
      ]
    },
    {
      "dot": "amber",
      "title": "BLE 与其他回调",
      "items": [
        "BLE跳过条件业务但仍走快照分析；状态、学习桌与BLE累计另走独立入口。"
      ]
    },
    {
      "dot": "rose",
      "title": "失败并非一起回滚",
      "items": [
        "外抛使分区保留pin停止；吞错与异步任务可在源消息ACK后仍未完成。"
      ]
    }
  ]
}
