Repository navigation
Keep rediscovered Lark private recovery work scheduled - #8427
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent, GPT-6, OpenAI (self_reported)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
受影响的是在飞书私聊里等候助手补完答复的用户。例如,助手先送出部分答复,之后系统发现同一条请求可以安全续办。旧调度器看到这条路径曾经处理过,就跳过这次新发现;修复后,原服务会在有空位时把它交回原处理器。基线复现了三种漏排场景。候选在相同场景中恢复了调度,且新消息扫描短暂失败时也能保住已经发现的恢复路径。
这次修改只解决飞书私聊恢复的调度。原消息是否可以续办,以及接收和回传的证据,仍由既有流程核验。生产采用和真实原会话的最终答复仍需独立读回。
改动思路 / Approach
本次只修改原私聊回复 worker 中从扫描结果到排队的一段流程。待调度集合放在原扫描器内,只携带路径。这样能保住重新发现的工作,并继续使用原处理器的权限和投递判断。 调度器把候选保留到同一组 worker 有空位为止,次数仍用于公平排序。若直接把次数清零,较早发现的路径会反复抢占顺序;若把完整恢复扫描搬回同步路径,当前回复又会等历史观察。现有调度器已经掌握候选路径和空位,在这里接住新发现即可。
具体改动 / Changes
按 原私聊恢复规范 核对三项。recovery-rediscovery 已实现,异步发现包含处理过的路径时仍可排队。existing-worker-fairness 已实现,新正文仍优先,等待期间保留路径,原工作池最多四个槽。original-recovery-authority 已实现,提交后仍调用原处理器,由它读回当前来源、绑定和 Core 的恢复资格。改动包含调度和对应测试两个文件。
关键代码讲解
_reconcile_private接收当前正文和异步恢复发现。先收下异步恢复扫描的结果,再运行独立的新消息扫描。路径按键去重,排除在途路径。提交后移除候选,再递增尝试次数。待处理和在途状态分开,尝试次数只影响排序。test_already_attempted_private_path_is_rediscovered用同一条持久路径驱动正文已发、恢复暂缓、以及正文扫描暂时失败三种情形。中间版本在扫描出错时要等完整退避,最终版本在下一次可用扫描即提交,原记录继续保持已送达状态。
对主干的风险 / Risks
并发风险集中在扫描结果返回时是否会重复提交、以及历史恢复是否挡住新正文。定向测试覆盖满池、下一空位优先、退避和服务停止。基线三条反例确实失败,安装包用相同夹具三条均通过。完整飞书私聊 427 项测试、标准 premerge、双语 RFC 检查及补丁一致性检查均通过。测试使用合成来源,未覆盖生产身份和真实消息送达。此 Goal 使用本地验证,远端 CI 依配置未读取。合并与部署资格另有仓库及运行时检查。
语义与 CI 对齐
复用既有投递记录、退避和恢复资格。调度提示的有无不改变 Core 的停止、撤权、来源复核和未知效果处理。
我的整体评价 / Verdict
当前 head 修复了可续办请求被静默漏排的具体问题。长期收益是后续符合资格的请求能继续排队,用户收益是无需为同一请求再发一次消息。额外状态只有进程内待处理路径,没有新配置或迁移。本次改动只触及飞书后台调度和测试,回复文案、卡片及页面没有差异。真实飞书终答和时延仍待采用后独立核验。 代码审查通过,生产采用与原会话读回继续跟踪。
English verdict: APPROVE. Reviewed 65067e410f6e0c834381a7a9e08da87f48e3703d. The installed candidate reschedules eligible paths and preserves the existing worker and recovery boundaries.
Goal And Delivered Outcome
A private reply can be delivered before the same request becomes eligible for recovery. The background scan found the delivered path, but the scheduler treated a previous attempt as a reason to drop the new discovery. The request could stay pending indefinitely.
Retain discovered paths until an existing worker slot opens. Use the attempt count to order eligible paths. A delivered reply can enter recovery, and an earlier recovery probe can return after its backoff. Fresh reply bodies still take priority. A temporary error in the fast body scan also preserves the already discovered recovery work.
Author Declaration
LarkGoalTopicRuntimeService._reconcile_privateScope And Continuation
This change is confined to scheduling the existing private reply worker. Recovery eligibility and delivery still run through the existing owners. Production adoption and readback of a real reply remain follow-up validation.
Validation
65067e410f6e0c834381a7a9e08da87f48e3703dregression_paritypassedintegrationpassedintegrationpassedintegrationpassedtests/test_lark_private_conversations.pyat the final revision.staticpassedFrontend / Visual Evidence
Type of Change
LoopX Area
Boundary Checklist