Repository navigation
fix(owner-group-follow): 防止瞬态漏群误拉历史旧群 - #3901
Merged
Merged
Conversation
Co-Authored-By: Kimi <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 27, 2026 03:22
deepcoldy
commented
Nov 27, 2026
deepcoldy
left a comment
Owner
Author
There was a problem hiding this comment.
复审结论:三项边界均已闭环,未发现新增阻断问题
核心改动位于 src/services/owner-group-follow-store.ts:105-167:owner 与 bot 两份完整成功列表都采用连续缺失确认,正向 bot 成员证据先于 owner 条目循环消费;src/services/owner-group-follow-store.ts:133-146 将扫描推断移出与永久墓碑分开处理。src/services/owner-group-follow-store.ts:173-181 的永久失败认领边界未放开。
发现、探针与处理
- 中:真实退群/再进群与永久失败的文档语义不一致。 真实 follower + journal + 可控 60 秒时钟复现:永久失败后为
failed(attempts:1),连续两次缺席虽移出基线,再次返回仍不会邀请。处理为保留既有“永久失败停止”行为,收窄文档并加入test/owner-group-follow.test.ts:100-110,防止退群/再进群意外重置邀请预算。 - 低:bot 列表单轮漏群制造不可恢复的 removed。 真实组件复现
joined → 单轮缺席 → removed → 成员恢复仍 removed。处理为增加missingBotChatScans和removalSource:'snapshot':连续两次缺席才生成可纠正的扫描移出,真实成员恢复可回joined;显式事件及无来源旧removed继续永久。回归见test/owner-group-follow.test.ts:271-290,旧 journal 对照见test/owner-group-follow.test.ts:111-130。 - 低:owner 缺席轮次忽略 bot 正向在场证据。 探针复现“bot 缺席一次 → owner 缺席/bot 在场 → owner 恢复/bot 再缺席”时,计数未中断,第三轮过早生成扫描移出;另一序列证明 owner 缺席时扫描移出也无法恢复。现由
src/services/owner-group-follow-store.ts:110-119统一消费正向证据,回归见test/owner-group-follow.test.ts:291-307。
最终针对性探针输出 FINAL_OVERLAP_PROBES_OK:上述两条交叠序列均只重新计第一次缺席;扫描移出能在 owner 缺席时按 bot 正向证据恢复;显式事件墓碑在 owner 缺席或在场时均不被覆盖。
其余攻击面
已验证首次基线、真正新群、关闭/重开与 owner 变更、缺失计数跨重启、claim 已写入但 finish 未完成、晚到 finish、配置 epoch 失效、多 daemon presence/absence 交叠、分页失败不推进或清零计数,以及显式 removed 与晚到响应竞争,未发现其它确认问题。
实际验证
bun run build:通过,含 TypeScript 编译、类型检查和构建审计。- 四个
owner-group-follow定向套件:4 个文件、193/193 通过。 - 修复前复现与变异复验均实际咬红:owner 瞬态漏群产生误邀请 POST;bot 单轮漏群产生不可恢复 removed;移除缺失确认、反转移出来源、移除 owner 缺席时的 bot 正向处理、放开 failed 扫描与认领,对应测试均失败。变异后已恢复并重新全绿。
- 围栏探针使用真实组件、真实 journal 与可控时钟,未触碰线上配置或 daemon。
未部署、未重启、未发版,也不声称已完成飞书线上验证;合入仍需等待 PR 完整 CI 闭环。
|
🚀 Released in v3.59.36 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
飞书
im/v1/chats即使成功返回,也可能某一轮瞬态漏掉主人已经在里面的历史群。原实现每轮直接以当前列表覆盖knownChatIds:旧群缺席一轮就被移出已见基线,下一轮恢复时命中“未知群且无条目”,被误标为pending并邀请机器人。修复
version: 1journal 中增加可选missingChatScans/missingBotChatScans,分别记录主人列表和机器人成员列表的连续缺席次数。joined;连续两次完整扫描均缺席才确认退出或扫描推断移出。中途重新出现会清零计数,不再误拉或错记永久移出;bot 正向在场证据即使碰上 owner 列表当轮缺席,也会清零计数并纠正扫描推断移出。failed不因退群/再进群重置邀请预算。removed带有可选removalSource: 'snapshot',后续真实成员关系恢复可纠正为joined。显式移出事件及旧日志中无来源的removed继续作为永久墓碑。影响面
仅修改 owner-group-follow 的持久基线、机器人成员关系核对及其设计文档、定向测试。群列表分页仍在完整成功后才进入
observe();失败页、循环游标、异常格式不会更新基线或缺失计数。不涉及其它平台、CLI 适配器、PTY/Tmux 后端、话题/群会话、消息路由或 Dashboard。未开启该功能的 Bot 不经过此状态路径。
实际验证
bun run build:通过,包含 TypeScript 编译、类型检查和构建审计。bun run test -- test/owner-group-follow.test.ts test/owner-group-follow-runtime.test.ts test/owner-group-follow-api.test.ts test/owner-group-follow-platform-auth.test.ts:4 个文件、193 条测试全部通过。joined → removed且恢复后无法回到joined。对抗复核发现与处理
{status:'failed',attempts:1};连续两次缺席虽移出基线,返回时仍不会再次邀请。处理为保留“永久失败停止”的既有行为,收窄设计文档并新增跨退群/再进群不重置预算的回归,避免擅自放大邀请副作用。joined → 单轮 bot 列表缺席 → removed → 下一轮成员恢复仍 removed。处理为增加独立连续缺失计数,并用removalSource区分可纠正的扫描推断与永久事件墓碑;新增单轮漏群、非连续恢复、扫描移出恢复、显式事件及旧日志墓碑回归。removed(snapshot);另一序列证明 owner 缺席时扫描移出也不能按 bot 恢复纠正。处理为在 owner 条目循环之前统一消费 bot 正向证据,清零缺席计数并只恢复removed(snapshot);两条完整交叠序列均已加入回归,显式事件墓碑复验不被覆盖。另外攻过首次基线、真正新群、关闭/重开与 owner 变更、缺失计数写入后重启、claim 已持久化但 finish 未完成、晚到 finish、双 daemon presence/absence 交叠、后续分页失败及显式 removed 晚到响应,未发现其它异常。
最终针对性复验通过:
FINAL_OVERLAP_PROBES_OK。两条 owner 缺席/bot 在场序列均保持连续计数语义,扫描移出能按正向证据恢复,显式事件墓碑在 owner 缺席或在场时都不被覆盖;未再发现新的确认问题。未部署、未重启 daemon、未发版;本 PR 的验证均为本地定向测试与构建,不声称已完成飞书线上验证。
🤖 Generated with Claude Code