Skip to content

fix(oncall): 外部 bot 首条 @ 前也先完成 defaultOncall 自动绑定 - #1765

Merged
deepcoldy merged 1 commit into
deepcoldy:masterfrom
xu4wang:fix/bot-first-msg-oncall-autobind
Oct 9, 2026
Merged

deepcoldy merged 1 commit into
deepcoldy:masterfrom
xu4wang:fix/bot-first-msg-oncall-autobind

Conversation

@xu4wang

@xu4wang xu4wang commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

问题

开了 defaultOncall(Oncall 模式)的 bot,群的 oncall 绑定是在首条被观察到的消息时懒写入的(ensureDefaultOncallBound)。

人路径在 canTalk 前会先调用它(注释里写明是为了防“oncall 群首条消息误弹授权卡”),但外部 bot 路径没有:

  • 被 @ 的主路径:直接 evaluateBotTalk
  • 免 @ 新话题自动开工(autoStartOnNewTopic):直接 evaluateBotTalk

所以新拉的群里,如果第一个开口的是外部 bot(典型场景:告警机器人 @ 运维 bot),oncallChats 里还没有该 chat → 判无权限 → 误弹授权申请卡。等真人说了话、触发绑定之后才恢复正常。

线上实例(daemon 日志):

09:13:36 bot added to chat=oc_067a69fc5
09:16:30 Foreign bot @mention not a known sibling (no_sibling_with_name); sending grant request card
09:19:25 [oncall:…] auto-bind (default) chat=oc_067a69fc… ← 真人首条消息才绑上

改法

  • 把人路径那段调用抽成 bindDefaultOncallBeforeTalk
  • 人、bot 三处 talk 判定之前统一调用

绑定是 chat 维度的策略,与 sender 无关;不新增任何放行来源,evaluateTalk / evaluateBotTalk 不变。

验证

  • 新增回归用例:未绑定的 defaultOncall 群里,外部 bot 首次 @ → 先完成绑定 → 正常路由到 handleThreadReply,不发授权卡
  • 红绿对照:去掉修复,这条用例失败;加上修复,通过
  • test/event-dispatcher.test.ts、test/oncall-store.test.ts、test/bot-talk-parity.test.ts:514/514 通过
  • tsc --noEmit(主工程 + test-mocks):通过
  • 全量 unit:失败的文件集合与不含本改动的基线一致(都是需要真实环境的 CLI/dist/integration 用例)。另有一处差异 update-check.test.ts,单独连跑 3 次 40/40 全过,判定为 flaky、与本改动无关
  • 未做 live 端到端验证

🤖 Generated with Claude Code

开了 defaultOncall 的 bot,群绑定是「首条被观察到的消息」时懒写入的。
原先只有人路径在 canTalk 前调用 ensureDefaultOncallBound;外部 bot 路径
(被 @ 的主路径 + 免 @ 新话题自动开工)直接 evaluateBotTalk,于是新拉的
告警群里若第一个开口的是外部告警 bot,oncallChats 里还没有该 chat →
判无权限 → 误弹授权申请卡(oncall 群对 bot 本应直接放行)。直到有真人
说话触发绑定后才恢复。

抽出 bindDefaultOncallBeforeTalk,人/bot 三处 talk 判定前统一调用。
绑定是 chat 维度策略、与 sender 无关,不新增任何放行来源。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

你好 @xu4wang,这个 PR 的评审群已经建好。由于你是飞书外部协作成员,系统无法直接把你拉进内部群,请通过下面的一年有效链接申请加入:
https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=837l8b8c-1307-44d8-a7c2-3d986397fb7c

也可以在自动拉群名单文档里补录/更新你的飞书信息:
https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe

这是自动评审流程发出的消息,如有不便敬请谅解。

@deepcoldy
deepcoldy merged commit 1563292 into deepcoldy:master Oct 9, 2026
7 of 10 checks passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🚀 Released in v3.39.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants