{
  "repo": "tidbcloud/escalation-base",
  "binary": "feishu-messager-server",
  "binary_path": "feishu_messager_v2/cmd/feishu-messager-server/main.go",
  "notes": [
    "Fresh codex rescan rebuilt feishu-messager around the v2 module and its real runtime shape: API server plus background read-receipt callback worker.",
    "The old v1 feishu_messager tree remains in the repo, but this binary now follows feishu_messager_v2/cmd/feishu-messager-server, which is the only module wired into the current Makefile and internal module path."
  ],
  "dependencies": {
    "FeishuMessagerLifecycle.LoadConfig": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "READ CONFIG",
              "paths": [
                "--config supplied root config path"
              ],
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(flagConfig)"
            }
          ]
        }
      },
      "services": []
    },
    "FeishuMessagerLifecycle.SetupDeps": {
      "infrastructure": {},
      "services": [
        {
          "name": "olympus-db",
          "target_interface": "Gorm MySQL connection",
          "operation_type": "mysql",
          "conditions": [
            "Always"
          ],
          "implementation": "deps.Init -> newGormDB/newDBProvider"
        },
        {
          "name": "lark",
          "target_interface": "Instantiate configured Lark clients",
          "operation_type": "client_init",
          "conditions": [
            "Always"
          ],
          "implementation": "deps.Init -> newLarkClientSet"
        },
        {
          "name": "alicloud",
          "target_interface": "Instantiate voice call client",
          "operation_type": "client_init",
          "conditions": [
            "Always"
          ],
          "implementation": "deps.Init -> newAliClient"
        },
        {
          "name": "twilio",
          "target_interface": "Instantiate Twilio call client",
          "operation_type": "client_init",
          "conditions": [
            "Always"
          ],
          "implementation": "deps.Init -> newTwilioClient"
        },
        {
          "name": "olympus",
          "target_interface": "Instantiate Olympus client for user phone lookups",
          "operation_type": "client_init",
          "conditions": [
            "Always"
          ],
          "implementation": "deps.Init -> newOlympusClient"
        }
      ]
    },
    "FeishuMessagerLifecycle.RunBackgroundServices": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:FeishuMessageBackCallService",
          "target_interface": "FeishuMessageBackCallService.Run",
          "operation_type": "local_call",
          "conditions": [
            "Always"
          ],
          "implementation": "service.Manager.RunServices"
        }
      ]
    },
    "FeishuMessagerLifecycle.RunAPIServer": {
      "infrastructure": {
        "network": {
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "address": "Conf.APIServer.ListenAddr",
              "conditions": [
                "Always"
              ],
              "implementation": "controller.APIServer.Run -> http.Server.ListenAndServe"
            }
          ]
        }
      },
      "services": []
    },
    "FeishuMessagerLifecycle.ShutdownAPIServer": {
      "infrastructure": {},
      "services": []
    },
    "FeishuMessagerLifecycle.ShutdownServices": {
      "infrastructure": {},
      "services": []
    },
    "FeishuMessagerHTTP.MessageForward": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:FeishuMessageService",
          "target_interface": "FeishuMessageService.SendUrgentMessageCard",
          "operation_type": "local_call",
          "conditions": [
            "Request JSON binds successfully",
            "req.is_urgent == true"
          ],
          "implementation": "pkg/controller/message.go MessageForward"
        },
        {
          "name": "local:FeishuMessageService",
          "target_interface": "FeishuMessageService.SendMessageCard",
          "operation_type": "local_call",
          "conditions": [
            "Request JSON binds successfully",
            "req.is_urgent == false"
          ],
          "implementation": "pkg/controller/message.go MessageForward"
        }
      ]
    },
    "FeishuMessageService.SendMessageCard": {
      "infrastructure": {},
      "services": [
        {
          "name": "lark",
          "target_interface": "SendMessageViaWebhook",
          "operation_type": "http_post",
          "conditions": [
            "Resolved receiver type == webhook"
          ],
          "implementation": "pkg/service/message.sendMessageCard"
        },
        {
          "name": "lark",
          "target_interface": "SendMessage",
          "operation_type": "http_post",
          "conditions": [
            "Resolved receiver type != webhook"
          ],
          "implementation": "pkg/service/message.sendMessageCard"
        }
      ]
    },
    "FeishuMessageService.SendUrgentMessageCard": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:FeishuMessageService",
          "target_interface": "FeishuMessageService.SendMessageCard",
          "operation_type": "local_call",
          "conditions": [
            "Always after raw_mode=true and receiver type is user_id"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "olympus",
          "target_interface": "GetPhoneNoByUserId",
          "operation_type": "http_get",
          "conditions": [
            "Always after the message card is sent"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "lark",
          "target_interface": "Contact.GetUser",
          "operation_type": "http_get",
          "conditions": [
            "Olympus phone lookup returned not-found"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "alicloud",
          "target_interface": "Call.SingleCall",
          "operation_type": "sdk_call",
          "conditions": [
            "Resolved phone number is domestic"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "twilio",
          "target_interface": "Call.SingleCall",
          "operation_type": "sdk_call",
          "conditions": [
            "Resolved phone number is not domestic",
            "enableTwilio == true"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "lark",
          "target_interface": "Message.MakeUrgent",
          "operation_type": "http_post",
          "conditions": [
            "Always after the message card is sent",
            "urgentType becomes phone when the number is overseas and Twilio is disabled"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "local:FeishuNotifyService",
          "target_interface": "FeishuNotifyService.Notify",
          "operation_type": "local_call",
          "conditions": [
            "Phone call step failed"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "local:FeishuNotifyService",
          "target_interface": "FeishuNotifyService.Notify",
          "operation_type": "local_call",
          "conditions": [
            "MakeUrgent failed"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        },
        {
          "name": "local:FeishuMessageBackCallService",
          "target_interface": "FeishuMessageBackCallService.AddWatchMessage",
          "operation_type": "local_call",
          "conditions": [
            "Always after the urgent flow reaches the callback-watch step"
          ],
          "implementation": "pkg/service/message.SendUrgentMessageCard"
        }
      ]
    },
    "FeishuMessageBackCallService.Run": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:FeishuMessageBackCallService",
          "target_interface": "FeishuMessageBackCallService.PollMessages",
          "operation_type": "local_call",
          "conditions": [
            "Every PollMessageReadInterval tick"
          ],
          "implementation": "pkg/service/message_backcall.periodically"
        },
        {
          "name": "local:FeishuMessageBackCallService",
          "target_interface": "FeishuMessageBackCallService.CallbackReadMessages",
          "operation_type": "local_call",
          "conditions": [
            "Every PollMessageReadInterval tick after pollMessages"
          ],
          "implementation": "pkg/service/message_backcall.periodically"
        },
        {
          "name": "local:FeishuMessageBackCallService",
          "target_interface": "FeishuMessageBackCallService.GarbageCollect",
          "operation_type": "local_call",
          "conditions": [
            "Every PollMessageReadInterval tick after callback"
          ],
          "implementation": "pkg/service/message_backcall.periodically"
        }
      ]
    },
    "FeishuMessageBackCallService.AddWatchMessage": {
      "infrastructure": {},
      "services": [
        {
          "name": "local:FeishuNotifyService",
          "target_interface": "FeishuNotifyService.Notify",
          "operation_type": "local_call",
          "conditions": [
            "Tracked watch-message map grows beyond 100 entries"
          ],
          "implementation": "pkg/service/message_backcall.addWatchMessage"
        }
      ]
    },
    "FeishuMessageBackCallService.PollMessages": {
      "infrastructure": {},
      "services": [
        {
          "name": "lark",
          "target_interface": "Message.ReadUsers",
          "operation_type": "http_get",
          "conditions": [
            "For each tracked message whose status is unread"
          ],
          "implementation": "pkg/service/message_backcall.pollMessages"
        }
      ]
    },
    "FeishuMessageBackCallService.CallbackReadMessages": {
      "infrastructure": {},
      "services": [
        {
          "name": "configured-backcall-endpoint",
          "target_interface": "POST backCallUrl with message_id JSON payload",
          "operation_type": "http_post",
          "conditions": [
            "For each tracked message whose status is read"
          ],
          "implementation": "pkg/service/message_backcall.callback"
        }
      ]
    },
    "FeishuMessageBackCallService.GarbageCollect": {
      "infrastructure": {},
      "services": []
    },
    "FeishuNotifyService.Notify": {
      "infrastructure": {},
      "services": [
        {
          "name": "lark",
          "target_interface": "Message.SendMessage",
          "operation_type": "http_post",
          "conditions": [
            "Best effort async notification"
          ],
          "implementation": "pkg/service/notify.notify"
        }
      ]
    }
  }
}
