Repository navigation
fix(schedule): 宿主终端创建的定时任务可由自身执行回合收尾 - #2747
Merged
Merged
Conversation
在宿主终端用 botmux schedule add 建的任务不记录真人控制者。执行回合调用 schedule done/pause/remove self 时,direct 分支照常复核控制者,必然失败, until-done 任务因此只能空跑到截止。没有记录任何控制者字段的 direct 任务 现在跳过这项真人复核;状态检查和路由层的「只能停当前精确任务」限制不变, 记录了任一控制者字段(含空字符串)的任务照常复核。
baicaicc
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 3, 2026 12:56
- runtime/route 两层补「无控制者 + completed + once_completed 经真实 authorizer 放行 remove self」一格;删豁免行、关闭 completedRunStillLive 两种变异均咬红 - ADR、docs-site 中英文档与 schedule skill 提示把豁免主体写成结构条件(两个控制者字段均未记录),宿主终端由穷举入口改为举例,避免被读成只限宿主终端 Co-Authored-By: Claude Code <[email protected]>
Owner
|
复审认可后,我们把评审中提到的两条非阻断建议作为一个追加 commit 直接补在了作者分支上(fast-forward,未改动原提交 d018b55): 47caea3
本地验证:vitest 定向 94/94、bun test 同两文件 94/94、 这是自动评审的初步意见,最终以维护者审阅为准。 |
Owner
|
已合并,感谢修复和详细的复现记录(含 live 实测)! 后续跟进(不阻塞本 PR):
|
This was referenced Nov 4, 2026
|
🚀 Released in v3.57.0 |
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.
改了什么
在宿主终端用
botmux schedule add建的定时任务,执行回合现在可以schedule done self/pause self/remove self收尾。authorizeScheduleSelfManage的 direct 分支:控制者两个字段都没有记录(controlOpenId、controlUnionId均为undefined)时,跳过真人控制者复核;其余一律照旧:为什么
宿主终端经 daemon HMAC 创建的任务走
if (!ds)分支,存成kind='direct'、控制者为空(创建者就是宿主管理员)。self-manage 的 direct 分支假设 direct 任务「天然携带同 Bot、同群的控制者记录」(见 ADR),对这类任务revalidateController必然抛schedule controller is no longer an allowed bot operator,路由返回schedule_self_manage_denied。实际后果:
--until-done任务做完了也关不掉,只能按--retry-every空跑到截止;叠加--new-topic时每次重跑还会新开一个话题。11-03 在两台会话里独立复现:一个任务连续空跑 3 轮、一个测试任务跑了 5 轮留下 5 个话题,done self/done <id>全部被拒。停掉自己是低风险动作,最坏是该跑的没跑;真人控制者复核要防的是「授权已失效的人借任务继续行事」,而这类任务没有会失效的真人授权。
影响面
src/core/schedule-delegated-runtime.ts一处判断(+ 文档、skill 提示文字),不涉及 CLI 适配器、后端、IM 层;schedule add、Dashboard 在无登录身份时创建的任务——调用方本来就是宿主管理员;会话内 direct 创建路由要求两个控制者字段都在,产生不了这类记录;store.updateTask不会把控制者改成空;self按「当前活跃 turn」解析,不受沙箱的宿主调用方若在别的 turn 迟到调用会作用在当时活跃的任务上——这是既有行为,有控制者的任务同样存在,建议另起修复(把body.originTurnId与活跃 turn 绑定)。测试验证
新增用例:无控制者 direct 任务可自停且不查身份、暂停/已删除仍拒绝;半条/空字符串控制者照常复核并拒绝;路由层用真实授权函数跑 done/pause/remove self 通过、管别的任务或 run/update self 仍 403;记录了控制者但已失去管理员身份的仍拒绝。去掉修复后新增的 4 个用例失败。
全量
vitest run --project unit:18 个文件失败;其中 17 个在未改动的 master 上单独跑同样失败(worker-/session-env- 等 integration,本机环境相关),另 1 个(cli-send-custom-final)是全量并发下 30s 超时,单独跑两次均 29/29 通过。Live 实测(
bun run switch:here && bun run daemon:restart后):宿主终端botmux schedule add "<2 分钟后>" "<只运行 schedule done self>" --new-topic --silent --until-done --retry-every 10m --deadline <45 分钟后>建的任务(authority
kind=direct、control_open_id为空),第 1 次执行里botmux schedule done self --note ...返回「✅ 已标记完成当前定时任务,之后不再执行。」exit 0;schedule list显示「直到完成 · 已完成 · 已执行 1 次」、结果说明已记录,authority 状态completed,没有再重跑。修复前同样的任务会被拒(schedule_self_manage_denied)并重跑到截止。