Repository navigation
fix(schedule): 定时任务续跑与 relay 的身份只从宿主 authority 库取 - #2541
Merged
Merged
Conversation
schedules.json 是 authority 库的投影,沙盒内 CLI 可写。续跑轮次的 trustedCaller、scheduledTurnCallers 比对、v3 session relay 的定时轮次鉴权、 任务位首次触发取已有 root、Dashboard 编辑时校验建任务人的 chatId 原先都读它。 现在这几处都改读宿主 schedule-authority.sqlite,不回落投影;CLI 侧 current-turn-provenance 仍读投影,只作预检。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 29, 2026 18:48
This was referenced Oct 30, 2026
deepcoldy
pushed a commit
to uestcwangci/botmux
that referenced
this pull request
Oct 30, 2026
…ity-recovery-2473-final 四次同步 master(0345cc5f1..eb43116,14 提交,含 deepcoldy#2514/deepcoldy#2534/deepcoldy#2535/deepcoldy#2541/ deepcoldy#2467/deepcoldy#2550/deepcoldy#2553/deepcoldy#2554/deepcoldy#2557/deepcoldy#2561/deepcoldy#2562 等)。与本 PR 仅 worker-pool.ts / worker.ts 文件交集,git 自动合并干净、无冲突标记;PR 关键接线(codexApp TurnFailureCode 四处、!turn.error 守卫、pool 恢复落账、worker 签名 final 失败字段、Pi boot 20s 预算)逐处 grep 仍在原位。合并树 build 过、 codex 集成/容量/engine/deployment/schedule 共 276 项 vitest 绿、 容量+Pi argv 46 项 bun 绿。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 Released in v3.56.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.
改了什么
定时任务有两份数据:宿主侧的
schedule-authority.sqlite(只有 daemon 能写)和<BOT_HOME>/schedules.json(daemon 从 authority 库同步出来的投影,给botmux schedule list展示用)。沙盒会话里 BOT_HOME 是可写的,所以沙盒内的 agent 能改写这份投影。首次触发的身份判断本来就读 authority 库,但下面几处 daemon 侧的判断还在读投影,本 PR 全部改为只读 authority 库、不回落投影:
worker-pool.tsscheduledContinuationTrustedCaller(定时轮次失败后的自动续跑)ownerOpenId/ownerUnionId,续跑轮次就以别人的身份执行worker-pool.tsrememberScheduledTurnCaller(记入scheduledTurnCallers,Gateway / current-actor 证明用它)session-relay.ts(沙盒内botmux workflow start/cancel/retry/grant的 relay 鉴权)session-manager.ts任务位(executionPosition: task)首次触发时取已有 rootrootMessageId,这一轮就续进 agent 指定的话题,不再开新话题dashboard-ipc-server.tsDashboard 编辑任务时校验建任务人用的 chatIdcanOperate判断做法:
scheduled-turn-provenance.ts新增readScheduledTaskFromAuthority:库不可用、读取出错、任务已撤销都返回 undefined(等同任务不存在,拒绝)。authorizeScheduledTurn改成由调用方注入「取任务」函数:daemon 注入 authority 版本;CLI 侧current-turn-provenance(跑在 CLI 进程里,读不到宿主库)继续读投影,只作预检,真正放行在 daemon 侧。loadScheduledTaskForIdentity取任务,daemon 注入 authority 版本;relay 改为注入loadScheduledTask,未注入时拒绝。getRuntimeTask(已有的runtimeTask包一层),给 session-manager 和 Dashboard 路由用。为什么不改沙盒挂载
先核实了 schedules.json 现在的地位:它仍由宿主写入,但只是投影,daemon 启动时用 authority 库整份重写它,之后每次变更也同步写。沙盒里的
botmux schedule add/enable/remove都走 daemon 路由,不直接写它。daemon 不再从它取身份后,沙盒改它只影响自己看到的列表,所以没有改成只读挂载;那样要动 fs-policy(Linux bwrap 组也在改),收益不大。影响面
测试
新增回归(都用真实
ScheduleAuthorityStore+ 篡改投影):test/session-lifecycle-start.test.ts:投影改了 owner 后续跑仍按原创建人;只在投影里存在的任务续跑不带身份;只和被改投影一致的伪造 caller 不会被记进scheduledTurnCallers。test/v3-session-relay.test.ts:relay 用例改用真 authority 库;投影改 owner/chatId 后仍按原 owner 判定;authority 撤销后拒绝;只在投影里的伪造任务拒绝;未注入 loader 时拒绝。test/scheduled-turn-provenance.test.ts:readScheduledTaskFromAuthority的撤销、无库、库抛错。test/scheduler-silent-execute.test.ts:投影里伪造 root 时首次触发仍开新话题,root 写回 authority。test/dashboard-schedule-creator.test.ts:Dashboard 编辑时建任务人校验用 authority 里的 chatId。变异(每条摘掉守卫后对应用例必须变红):
rememberScheduledTurnCaller改回读 schedules.jsonauthorizeScheduledTurn忽略注入的 loader、读投影运行结果:
提交前独立复核
由未参与实现的独立上下文只看 diff 做了一轮对抗复核,攻击面:
发现 1 处 P2:任务位首次触发的话题落点读投影(master 上原有问题,不是这次引入的)。用真实
executeScheduledTask复现:伪造 root 后continuation: true,没有发种子消息。已在本 PR 修复并补回归,就是上表「任务位首次触发」那一行。其余场景没有发现问题。来源:维护者在决策看板批次 #21(看板 #88)定的方案,问题来自用户反馈。
🤖 Generated with Claude Code