本文记录 Bot 渠道的端到端行为合同。Bot 用例独立于 conversation-session:它们复用 ZCode task stream,但入口、状态所有者和外部证据位于 BotsService 与 provider API。
| 边界 | 决策 | 理由 |
|---|---|---|
| 本轮主范围 | Feishu/Lark streaming_card 完整生命周期 |
这是分支中用户可见且跨层风险最高的行为 |
| Provider 环境 | CI 使用 mock Feishu HTTP API | 避免真实租户、凭据和网络造成不稳定 |
| Task 时序 | controlled-stream |
必须观察运行态展开与终态收起,fast-text 无法证明中间状态 |
| 客户端语义 | bot-channel-continuous |
Bot stream 不进入手机 web-remote-replayable 恢复语义 |
| 多 host runtime 锁 | 后续独立 process E2E | 当前已有 service integration 回归;多进程夹具不与卡片语义混跑 |
| Plan approval UI | 排除 | 与 Bot 渠道生命周期无直接状态交叉 |
file 和包含正文及顶层 files 数组的 post 消息经 provider callback 进入 Bot,下载附件并提交本轮输入。bots/delivery/bot-large-attachment.test.ts。2026-11-06 macOS WDIO 隔离回放 12/12 通过,运行证据见覆盖矩阵;未转正或新增 CI 准入。2026-11-03 macOS 修复开发构建实测:同一 GLM-5.3 Coding Plan 从 Max 调到 High,
未发送桌面消息,直接飞书续聊;真实请求 output_config.effort 由 max 变为 high,
两轮均返回 OK。Session 更新事件与消息快照一致;队列及运行中 usage E2E 2/2 通过。
Setup:飞书绑定已有 Session,模型为 Start;桌面打开同一会话。
Action:桌面选择 BigModel Provider,不点击模型、不发送桌面消息,直接飞书发送。
Assert:成功回执后的飞书实际请求为 BigModel;已有运行轮及已接纳队列保持原模型。
Assert:配置失败不显示已切换;同名模型仍按 Provider 身份区分;新建草稿不改其他会话。
Status:accepted;2026-11-03 macOS 真实飞书续聊通过。15:58:44 配置确认 BigModel,15:59:26 实际网络请求为 bigmodel-standard-api / GLM-5.3,15:59:32 完成。切换与飞书发送之间没有模型二次点击或桌面发送。
Regression:conversation-session-model-switch-queue.test.ts 两项通过(运行中 auto drain、held queue 立即发送),CLI 冻结 Submission 与旧读取依据回归通过。手机真机、Windows/Linux 原生客户端未实测。
2026-10-21:ReplyToChannel 默认注册和发送接线注释停用,MN-02/FN-01 组合 E2E 暂时跳过, 原用例及 fixture 完整保留,待插件接入后恢复。MN-01/MN-03 中直接调用 Bot service 的测试 继续保护原实现。下方默认工具发送记录仅作历史证据,不代表当前入口可用。
bots/channels/feishu-channel-mention.test.ts,用户于 2026-10-08 确认转正。真实租户权限与手机 UI 待验证,不把平台替身当生产证明。/model、/think,再发送首条普通消息;另以失效结果尝试修改档位和派发。/model 已裁决为立即修改/保存同一 Session,完整链路合同见 W99-E06。replyMode=streaming_card,中文 locale;mock provider 返回固定 token、message id 与 reaction id。E2E_BOT_STREAMING_CARD_LIFECYCLE 标记的普通消息;task 依次产生文本、工具开始/完成、文本、工具开始/完成、最终文本和 task_complete。message → tools → message → tools → message → terminal status;bot-channel-continuous,不请求 replayable snapshot/gap 恢复。packages/desktop/test/e2e/fixtures/bots/feishu-streaming-card-lifecycle.json。formal。| Case ID | 候选 | 状态 | 原因 |
|---|---|---|---|
| BOT-E2E-AQ-01 | AskUserQuestion 多选/自定义在同卡更新 | formal | controlled elicitation 与 callback fixture |
| BOT-E2E-IL-01 | 阻塞交互切断流式卡并保留最终交互卡 | formal | controlled stream + Feishu HTTP 请求序列 |
| BOT-E2E-RT-01 | 两个本地 host 争用相同 Feishu runtime lock | formal | 真实文件锁的 owner/contender/takeover 证据 |
| BOT-E2E-RT-02 | attached remote host 不启动 provider runtime | formal | 启动状态与零 provider 网络请求证据 |
| BOT-E2E-PV-01 | Feishu/Lark domain 隔离 | formal | 同一 HTTP mock 的完整 origin 断言 |
| BOT-E2E-RW-01 | 远程 workspace 断开时不重连、不本地 fallback | formal | remote service 调用计数与零 task 调用证据 |
| BOT-E2E-CR-01 | Bot 创建定时任务后执行结果回推原会话 | formal | Host 注入、持久化重开、先订阅后派发与 provider 出站证据 |
| BOT-E2E-CF-01 | 已绑定 Feishu 长连接失败时展示可诊断状态 | formal | Desktop 真实 UI、runtime 状态与绑定关系联合证据 |
| Decision | 组合 | 分类 | 依据 |
|---|---|---|---|
| BOT-PRUNE-01 | streaming card × Telegram/Weixin | pruned | streaming_card 是 Feishu/Lark provider 能力;其他 provider 保持原回复语义 |
| BOT-PRUNE-02 | streaming card × mobile replayable recovery | pruned | Bot task stream 固定为 bot-channel-continuous |
| BOT-PRUNE-03 | 单卡渲染 × 多 host runtime lock | pruned | 两者状态所有者和故障证据不同,合并会降低失败定位能力 |
| BOT-PRUNE-04 | Bot lifecycle × plan approval dialog rendering | ignored | 本分支中的相邻提交,不属于 Bot provider 交付合同 |
| BOT-PRUNE-05 | automation 回推 × 中间流式消息 | pruned | 定时任务仅回推 summary_changes 终态,避免群聊或私聊被工具过程刷屏 |
| BOT-PRUNE-06 | automation 回推 × mobile replayable recovery | pruned | 回推继续订阅 bot-channel-continuous,不进入手机 gap/snapshot 恢复链路 |
| BOT-PRUNE-07 | 连接失败 UI × 未绑定 Bot 的 Desktop 重复覆盖 | pruned | 未绑定分支已有组件合同;Desktop E2E 聚焦绑定关系与 runtime error 同时存在的冲突态 |
当前用例从 case-local bot-config.v3.json 加载;通过真实 UI 启用后核对 v3 写入及绑定保留。
旧文件一次性导入、旧 strict Reader 和回滚字节保持由 botsStorageV3.test.ts 验证。
providerUserId 的 Feishu Bot,但不提供其 credential,使 provider runtime 可确定地进入 error;不访问真实飞书网络。desktop-continuous 管理界面的 runtime 投影,不创建手机 web-remote-replayable session,不依赖真实 Feishu WebSocket。formal,已通过 Desktop 人工验收并转正。CronCreate 的消息;mock Feishu provider 记录所有出站请求。Weixin 复用相同的 delivery target / watcher 合同,由 provider service integration test 单独证明 /sendmessage 终态出站。task_complete 与 task_error。{ provider, botId, providerUserId, chatType },普通 UI prompt 不携带;CronCreate 参数不暴露 Bot 目标,automation protocol 只从 active turn 读取并持久化;automationId + workspaceKey 读取目标,脏 JSON 按无目标降级;sendPrompt 前完成 bot-channel-continuous 订阅;workspaceIdentity 贯穿远程 workspace,不能只按 workspacePath 匹配。/sendmessage 由 packages/services/test/botsService.messageFlow.test.ts 的 provider service integration test 证明。desktop-continuous,手机远控仍是 web-remote-replayable。formal。replyMode=streaming_card;task 先产生普通 Agent 正文,再产生 AskUserQuestion 或 Plan approval。card.raw,其中包含新题 token,不得再执行 card_update_token、message PATCH、POST 或 DELETE;完成、取消或任务终止后交互卡保留为无按钮只读卡;交互后的 Agent 内容创建新的流式卡;任何问题、答案或 Plan 正文都不回填旧/新流式卡。bot-channel-continuous;不扩展到 desktop desktop-continuous 或 mobile web-remote-replayable 的会话恢复语义。packages/desktop/test/e2e/bots/runtime/bot-deleted-task-recovery.test.ts。packages/desktop/test/e2e/bots/delivery/feishu-delivery-error.test.ts.DF-01 verification (2026-09-07): macOS Desktop WDIO passed (desktop-e2e-20260907040958265-p60496-c535b8967f7e59a1). HTTP 200/400 business failures, body/header log ID, update rejection, streaming circuit status, and localized error rendering are covered by 124 passing unit tests. Typecheck, Desktop E2E typecheck, and lint passed (43 warnings, 0 errors). Pending case is not promoted. Live Feishu, Windows/Linux, mobile devices, and delivery-failure DOM interaction remain unverified; existing connection-error DOM regression CF-01 passed in macOS Desktop WDIO.
GR-05 queue-card correction: persist the card's message ID and follow the input through running and terminal states on the same card, removing cancel controls after queue admission ends. Verify normal queue promotion to completion, delayed card creation after completion, duplicate/late events, persisted target reuse and revoked-group no-op. Live acceptance must let the second input execute normally; cancelling the second input alone does not cover this regression.
These cases implement the accepted bots-feishu-group-collaboration.md contract. Synthetic provider HTTP and controlled task events are permitted for deterministic service integration evidence. Real CLI admission and renderer DOM assertions must be reported separately; mock task methods are not evidence of CommandInbox behavior. Real Feishu tenant permissions, mentions, attachment references, removal, and message restrictions require a real test group.
Group member display revision: GR-02/04 also checks the queue sender's name and click-to-view full identifier. Provider tests cover paginated directories and Feishu/Lark domains; UI tests cover historical name overlays and group isolation. Live tenant permission and actual member-name rendering require separate evidence.
bots/delivery/bot-private-task-sync.test.ts。accepted,再次提交返回 duplicate,不开新一轮;任务快照状态由用例控制。飞书 reaction POST 按真实响应返回 reaction_id(共享替身先匹配消息接口,拿不到该字段)。completed;A 再次进入业务处理,模拟去重窗口过期后、或游标未提交时的重投;随后发新消息 B。running(会话里还有别的轮次在执行);A 再次进入业务处理;最后让正在执行的那一轮结束。sendPrompt 与首次使用同一个 traceId(即 v4 sendText 的 commandId),B 使用新 ID。duplicate 后:向桌面广播 completed;Telegram/微信超过一个续发周期(4 秒)不再发 Typing;飞书删除 Typing reaction;B 不被“任务运行中”拒绝。duplicate 后:不广播 completed,Typing 继续,飞书 reaction 不删除;那一轮结束后按原终态路径停止 Typing。duplicate(既有协议合同),不代表真实渠道重投。bots/delivery/bot-private-redelivery.test.ts,用户于 2026-11-10 确认转正。getupdates;Telegram runtime 的业务回调返回失败。两者都使用替身锁和替身 logger。bots/runtime/bot-polling-retry-backoff.test.ts,用户于 2026-11-10 确认转正。bots/channels/feishu-channel-mention.test.ts,用户于 2026-10-08 确认转正。BOT-UI-MN:真实正式气泡、准备气泡与队列组件在 390/1200px、深浅主题显示渠道 chip; 普通 @ 文本无渠道节点,无横向溢出、不显示平台 ID。组件浏览器测试不等于手机 replayable 真机验证。
范围:飞书群协作分支相对 staging 的群聊、话题、材料、回传、设置 UI 与渠道工具。 用户已确认实施整个分支的覆盖补齐;重复成功回执保持现状,不增加去重断言。 状态 owner:CLI CommandInbox 管 admission/执行,Bot Host 管绑定、材料及 delivery,UI 只投影;不另建队列。
| Case | Setup → Action → Assert | 证据与状态 |
|---|---|---|
| BOT-E2E-TP-04 | 真实 CLI 话题运行中 → Bot 接收新消息 → 自动停止旧 run,权威终态后续接,零排队,旧输出不冒充新轮 | Host/CLI/模型 HTTP,pending |
| BOT-E2E-TP-05 | 已接收历史文件索引 → 真实 ReadTopicResource → Host 验证并下载,CLI 收到正确文件;其他任务/失效授权不下载 | Host/CLI/模拟平台 HTTP,pending |
| BOT-E2E-FN-01 | 工具输出后终态含完整正文 → adapter 对账 → 完整结果仅回传一次;普通对话仍正常 | adapter/真实 stream/平台出站,pending |
| BOT-E2E-MN-02 | 真实 CLI 触发 ReplyToChannel → 原生提及成功 → 客户端续聊按名字查询新目标,无 botGroupSource,不弹默认审批 | Host/CLI/模拟平台 HTTP,pending |
| BOT-E2E-GR-02 | 运行中接收群输入 → 取消及正常晋升分别执行 → FIFO、原始来源、同卡终态与不重复输入 | 调整已有 runtime case |
| BOT-E2E-GR-UI-01 | 两机器人/两群 → 设置开关、失败及恢复 → 隔离、持久化、不补发 | 新增 UI 候选 |
| BOT-E2E-PS-01 | 私聊绑定 task → IM/desktop/mobile 连续轮次与重启 → 一轮一回传,失败显式重试 | 扩展已有候选,模拟 origin 不计手机 UI |
| BOT-E2E-MN-01/TP-03 | 群/话题与多个身份 → 回复和管理员操作 → quote、条件 @、管理员提醒及幂等 | 扩展现有服务候选 |
剪枝:Feishu/Lark 平台差异由服务候选双平台覆盖,真实 CLI 主链路优先 Feishu;不机械交叉所有平台与主题。 主题/宽度由组件浏览器验证;真实手机 replayable、SSH 身份、平台租户通知分别记录,不能以窄屏或 stub 代替。 初始验证阶段新增用例保持 manual-review/pending;2026-09-23 用户确认后,下列四份新增 spec 已转正,未进入 Docker/CI。 先完成 case-local fixture 与 canonical manifest,再跑受控回放;平台请求全部隔离,不使用用户 Bot。
本轮新增正式用例(2026-09-23 用户确认):
conversation-session/session-control/conversation-session-bot-channel-worker.test.ts:MN-02 + FN-01,真实 CLI 原生提及、无来源的客户端续聊、丢失 text delta 的终态补齐。conversation-session/session-control/conversation-session-bot-topic-worker.test.ts:TP-04 + TP-05,真实运行中自动停止续接、工具结果及受管理附件字节校验。conversation-session/session-control/conversation-session-bot-continuous-worker.test.ts:GR-02 正常晋升 + PS-01 IM/desktop 持续订阅。bots/channels/feishu-bound-groups-ui.test.ts:GR-UI-01 实际 Desktop RPC/持久化与群/机器人隔离。上述路径均相对 packages/desktop/test/e2e/。新 worker 正式用例使用真实 CLI/生产 Host 服务,Bot repo 与平台 HTTP 为隔离夹具,不能称为 Electron UI 或真实租户验证。
PS-01 的重启、失败重试及换绑继续由 botsService.privateSync.test.ts 覆盖;mobile 来源模拟不升级为实际手机证明。
GR-UI-01 的失败/并发/迟到回调、禁用机器人继续由 botBoundGroupsInteraction.test.ts 覆盖,本轮 Desktop 用例只证明实际成功保存路径。
MN-01 增加同任务桌面续聊和跨任务拒绝;TP-03 扩展飞书/Lark × 条件 @ 四场景,覆盖当前消息引用、审批提醒管理员与普通问答条件提醒;模型继承继续由 botsService.groups.test.ts 验证。
机器人接收事件回归:真实事件 sender_type=bot 映射为内部 app;已启用普通群原生 @ 可提交,未启用/无 @ 不提交;话题延续保持 active 校验、去重、自身回声与控制命令隔离。 TP-04 使用 bot 事件穿过 Provider → Host → CLI → 平台回复;历史接口仍使用 app。