{
  "schema_version": 1,
  "diagram_type": "architecture",
  "meta": {
    "title": "Ailoha iOS 5e6 历史运行架构",
    "subtitle": "并行控制面：组合根、导航、特性状态、跨进程与两条传输通道",
    "output": "current-architecture.html",
    "animation": "trace",
    "visual_preset": "editorial",
    "quality_profile": "showcase",
    "repository": {
      "url": "https://github.com/Ailoha-ai/ailoha-agent-iOS",
      "revision": "5e6ac6e41c53780c85808c92290d2bd38f809123"
    },
    "views": [
      {
        "id": "primary-use",
        "label": "用户主路径",
        "focus": ["user", "app-root", "features", "state-owners", "rest-api", "backend"],
        "note": "从 App 入口追踪特性界面、并行状态所有者与 REST 请求。"
      },
      {
        "id": "navigation-path",
        "label": "导航控制面",
        "focus": ["system-events", "app-root", "navigation", "features", "state-owners"],
        "note": "通知、深链和可见任务状态共同驱动页面栈。"
      },
      {
        "id": "cross-process",
        "label": "跨进程路径",
        "focus": ["system-events", "extensions", "shared-state", "app-root", "backend"],
        "note": "Widget、通知内容和 App 通过 App Group、系统事件及后端协作。"
      },
      {
        "id": "realtime-path",
        "label": "实时与观测",
        "focus": ["features", "arpc", "backend", "observability"],
        "note": "ARPC 与日志/遥测是独立于 REST 的第二条运行通道。"
      }
    ]
  },
  "components": [
    {
      "id": "user",
      "type": "external",
      "label": "用户",
      "sublabel": "触控 / 语音 / 截图",
      "pos": [40, 300],
      "size": [140, 66]
    },
    {
      "id": "system-events",
      "type": "external",
      "label": "iOS 系统事件",
      "sublabel": "Deep Link / APNs / App Intent",
      "pos": [40, 520],
      "size": [160, 70]
    },
    {
      "id": "app-root",
      "type": "frontend",
      "label": "App 组合根",
      "sublabel": "AilohaApp + ServiceLocator",
      "tag": "Any 注册 + 多个 .shared",
      "pos": [260, 300],
      "size": [180, 76],
      "sources": [
        {"path": "Ailoha/AilohaApp.swift", "label": "启动与注销编排"},
        {"path": "Ailoha/GlobalService/ServiceLocator.swift", "label": "运行时服务表"}
      ]
    },
    {
      "id": "navigation",
      "type": "frontend",
      "label": "导航控制面",
      "sublabel": "AppRoute + MainTabPage",
      "tag": "通知 + 栈补偿",
      "pos": [500, 100],
      "size": [200, 74],
      "sources": [
        {"path": "Ailoha/Pages/Root/MainTabPage.swift", "label": "深链与通知入口"},
        {"path": "Ailoha/GlobalService/Router/Router.swift", "label": "类型化路由"}
      ]
    },
    {
      "id": "features",
      "type": "frontend",
      "label": "产品特性界面",
      "sublabel": "Home / Chat / Contact / Calendar",
      "tag": "Onboarding 并列",
      "pos": [500, 300],
      "size": [200, 76],
      "sources": [
        {"path": "Ailoha/Pages/Root/RootPage.swift", "label": "主 App 入口页面"},
        {"path": "Packages/OnboardingKit/Sources/OnboardingCore/OnboardingFlow.swift", "label": "独立引导流程"}
      ]
    },
    {
      "id": "extensions",
      "type": "frontend",
      "label": "系统扩展",
      "sublabel": "Widget / Live Activity / Notification",
      "pos": [500, 520],
      "size": [200, 74],
      "sources": [
        {"path": "AilohaWidget/ScreenshotTaskLiveActivity.swift", "label": "Widget 与 Live Activity"},
        {"path": "AilohaNotificationContent/NotificationViewController.swift", "label": "通知内容扩展"}
      ]
    },
    {
      "id": "state-owners",
      "type": "backend",
      "label": "并行状态所有者",
      "sublabel": "TaskState / HomeVM / Contact / Calendar",
      "tag": "账户作用域不一致",
      "pos": [770, 300],
      "size": [215, 76],
      "sources": [
        {"path": "Ailoha/GlobalService/Task/TaskStateManager.swift", "label": "任务详情状态"},
        {"path": "Ailoha/Pages/Home/HomeViewModel.swift", "label": "任务列表状态"},
        {"path": "Ailoha/GlobalService/Contact/ContactManager.swift", "label": "联系人缓存"}
      ]
    },
    {
      "id": "shared-state",
      "type": "database",
      "label": "本地与共享状态",
      "sublabel": "UserDefaults / Keychain / App Group",
      "tag": "多命名空间",
      "pos": [770, 520],
      "size": [205, 76],
      "sources": [
        {"path": "AilohaShared/SharedConstants.swift", "label": "跨进程键与令牌"}
      ]
    },
    {
      "id": "rest-api",
      "type": "cloud",
      "label": "REST 客户端",
      "sublabel": "AilohaAPIClient + 手写服务",
      "pos": [1040, 240],
      "size": [190, 74],
      "sources": [
        {"path": "Packages/AilohaAPIClient/Package.swift", "label": "生成与封装 API"},
        {"path": "Ailoha/GlobalService/APIService/APIService.swift", "label": "App 内服务"}
      ]
    },
    {
      "id": "arpc",
      "type": "messagebus",
      "label": "ARPC 实时通道",
      "sublabel": "Protocol + Transport",
      "pos": [1040, 390],
      "size": [190, 72],
      "sources": [
        {"path": "Packages/AilohaARPCKit/Package.swift", "label": "实时协议与传输"}
      ]
    },
    {
      "id": "observability",
      "type": "security",
      "label": "日志与遥测",
      "sublabel": "ALHLogger / Sentry / 周期上传",
      "tag": "需先收敛敏感边界",
      "pos": [770, 100],
      "size": [200, 74],
      "sources": [
        {"path": "Ailoha/Utils/ALHLogger.swift", "label": "日志管线"},
        {"path": "Ailoha/Utils/ClientPeriodicLogService.swift", "label": "客户端日志上报"}
      ]
    },
    {
      "id": "backend",
      "type": "external",
      "label": "Ailoha 后端",
      "sublabel": "HTTP / Realtime / Push",
      "pos": [1300, 300],
      "size": [170, 76]
    }
  ],
  "connections": [
    {"id": "user-entry", "from": "user", "to": "app-root", "label": "交互", "variant": "emphasis"},
    {"id": "root-features", "from": "app-root", "to": "features", "route": "straight"},
    {"id": "root-navigation", "from": "app-root", "to": "navigation"},
    {"id": "navigation-features", "from": "navigation", "to": "features", "label": "路由", "fromSide": "bottom", "toSide": "top", "route": "straight", "labelAt": [600, 235]},
    {"id": "features-state", "from": "features", "to": "state-owners", "label": "读写", "route": "straight"},
    {"id": "state-rest", "from": "state-owners", "to": "rest-api", "label": "请求"},
    {"id": "features-arpc", "from": "features", "to": "arpc", "label": "实时事件", "variant": "dashed"},
    {"id": "rest-backend", "from": "rest-api", "to": "backend", "variant": "emphasis"},
    {"id": "arpc-backend", "from": "arpc", "to": "backend", "label": "ARPC", "variant": "dashed"},
    {"id": "system-root", "from": "system-events", "to": "app-root", "label": "唤醒 / 深链"},
    {"id": "system-extensions", "from": "system-events", "to": "extensions"},
    {"id": "extensions-shared", "from": "extensions", "to": "shared-state"},
    {"id": "root-shared", "from": "app-root", "to": "shared-state", "fromSide": "right", "toSide": "left", "via": [[470, 338], [470, 470], [740, 470], [740, 558]]},
    {"id": "navigation-observability", "from": "navigation", "to": "observability", "label": "页面事件", "route": "straight"},
    {"id": "observability-backend", "from": "observability", "to": "backend", "variant": "security", "fromSide": "right", "toSide": "left", "via": [[1000, 137], [1260, 137], [1260, 338]]}
  ],
  "cards": [
    {
      "dot": "rose",
      "title": "当前最高风险",
      "items": ["普通注销未清空联系人与日历的内存状态", "令牌/API Key 前缀可绕过现有日志脱敏"]
    },
    {
      "dot": "amber",
      "title": "结构性张力",
      "items": ["Task 详情与 Home 列表各自持有状态", "通知、延迟和可见页面补偿共同驱动导航"]
    },
    {
      "dot": "emerald",
      "title": "可复用基础",
      "items": ["AppRoute 已类型化", "Chat V2、OnboardingKit 与本地 Swift Package 可作为迁移支点"]
    }
  ]
}
