Skip to content

feat(schedule): schedule update 支持切换静默执行 - #3859

Merged
deepcoldy merged 2 commits into
deepcoldy:masterfrom
gxy01:feat/schedule-update-silent
Nov 26, 2026
Merged

deepcoldy merged 2 commits into
deepcoldy:masterfrom
gxy01:feat/schedule-update-silent

Conversation

@gxy01

@gxy01 gxy01 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

改了什么

schedule add --silent 能创建静默任务,Dashboard 也能改,但 schedule update 不认这个开关:--silent 报「不认识的参数」,托管变更路由也只收 prompt/schedule/calendar。静默任务因此只能删了重建,执行记录和 task ID 一起丢。

本次复用已有复合编辑(它本就支持 silent 及回滚)把开关端到端接上:

  • src/cli/schedule-update.ts:新增 --silent / --no-silent,拒绝互斥、重复、带值写法
  • src/core/schedule-managed-update.ts:托管路由把 silent 校验为严格布尔,允许只带 silent 的请求体,回执回传实际值
  • src/cli.ts:改动涉及 silent 时打印静默状态
  • help 文本同步

影响面

只动 schedule update 的入参校验与回执;schedule add、Dashboard PATCH、调度执行路径未改。silent 与 new-topic 的标题约束沿用 updateTask 既有的 normalizeTopicTitle 校验。

验证

vitest run test/schedule-managed-update.test.ts   -> 18 passed
vitest run test/schedule-cli-update.test.ts       -> 74 passed
tsc --noEmit -p tsconfig.typecheck.json           -> 通过

未执行:bun run build(本机 electron postinstall 连不上外网)、Dashboard 与 Midscene E2E、飞书 live 验证。

`botmux schedule add --silent` could create a quiet task, but there was no
way to flip that flag afterwards: the Dashboard form already exposes it,
while `botmux schedule update` rejected `--silent` outright and the managed
daemon route refused any body without prompt/schedule/calendar.

Wire the flag end to end:

- CLI parser accepts `--silent` / `--no-silent`, rejects duplicates, the
  contradictory pair, and a `--silent=<value>` form that would otherwise be
  silently ignored.
- The managed route validates `silent` as a strict boolean (a string would
  otherwise flip quiet mode by accident) and carries it into the compound
  edit, which already supported the field and its rollback.
- The receipt echoes the effective value so the CLI can print it.
@gxy01 gxy01 changed the title test feat(schedule): let schedule update change a task's silent mode Nov 26, 2026
@gxy01 gxy01 changed the title feat(schedule): let schedule update change a task's silent mode feat(schedule): schedule update 支持切换静默执行 Nov 26, 2026
新 CLI 向旧 daemon 发送 --silent/--no-silent 时,旧 daemon 忽略该字段且
回执不含 silent,CLI 此前仍按 undefined 打印「静默执行: 已关闭」,会在
改动未落地时给出错误确认(任务可能仍处于静默态)。对齐同路径频率字段的
旧版守卫:回执缺少 silent 时告警并以非零码退出,组合编辑时注明其余字段
已更新。同步更新中英文档中「静默设置保留」的过时描述并补端到端测试。

Co-Authored-By: Claude Fable 5 <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

自动评审意见(首审 + 代修)

改动概述

为 botmux schedule update 接通静默开关:CLI 新增 --silent / --no-silent(拒绝互斥、重复、带值写法),daemon 托管路由把 silent 严格校验为布尔、允许仅带该字段的请求体,复用既有复合编辑(含前置条件回滚),回执回传实际状态。Dashboard PATCH 本就支持该字段,本次把 CLI 与托管路由补齐,执行链路在 fire 点读取 task.silent,下次执行即生效。

评审发现与处理

P2(已代修,00d48f2b):新 CLI 对旧版 daemon 使用 --silent 时,旧 daemon 忽略该字段且回执不含 silent,CLI 却按 undefined 打印「静默执行: 已关闭」,在改动未落地时给出错误确认(任务可能仍是静默态)。已对齐同路径频率字段的旧版守卫:回执缺少 silent 时告警并以非零码退出,组合编辑时注明其余字段已更新;并补端到端测试覆盖新/旧两种 daemon 回执形态。

P3:

  1. 中英文档 docs-site/docs/{zh,en}/schedule.md 原写「静默设置保留」,本 PR 后已过时,已在同一代修提交中同步更新。
  2. 结构化远端工具(remote runner protocol 的 schedule.update)与 riff host 参数白名单(riff-host-tools.ts)目前仍不支持 silent / --no-silent,沙盒会话内的 agent 无法经这两个面切换静默。属能力缺口而非回归(schedule.add 同样只有 --silent),建议后续单独补齐。

验证

  • 定向测试:test/schedule-cli-update.test.ts(76 例)、test/schedule-managed-update.test.ts(18 例),vitest unit 与 bun test 双引擎除一个与本 PR 无关的环境性用例外全绿(该用例在干净 master 同样失败:root 下 chmod 000 不生效)。
  • 8 项变异复验(非布尔守卫、false 归一化、带值拒绝、互斥校验、空 body 认可、回执字段、旧版守卫、状态打印)摘掉守卫后均按预期咬红,随后还原。
  • 真实组件对抗探针 32 项:运行中切换不影响计时与运行态、前置条件回滚连带回滚 silent、动态模板标题 + 静默拒绝、托管线协议边界,全部通过。
  • tsc --noEmit -p tsconfig.typecheck.json 与 bun run build 通过。

以上为自动评审的初步意见,最终以维护者审阅为准。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复核结论(head 00d48f2b59)

代码复核通过,未发现新的阻塞问题。 已修复的 P2 能够阻止旧 daemon 组合编辑场景下的错误成功确认。

P2 修复与旧版边界核验

  • src/cli.ts:10249 在成功提示之前检查 silent 回执;缺少该键时非零退出,src/cli.ts:10273 的状态打印因此不可达。组合编辑会明确提示其余字段已更新。
  • 从基线 a2f0731026 提取并执行真实 readManagedScheduleUpdate:仅 silent:true/false 的请求均返回 invalid_schedule_update;prompt + silent 则只保留 prompt、忽略 silent。也就是说,silent-only 在旧版上本就非零拒绝,不会误报;真正需要新守卫的是组合编辑,而当前修复覆盖了它。
  • 已检查的历史回执路径不存在“旧 daemon 返回带有旧 silent 值的完整 task”这一形态:受限回执自引入起不含 silent,更旧版本没有 task 回执。因此仅检查键存在不会在这些旧版路径上造成误报。
  • src/core/schedule-managed-update.ts:41-66 允许 silent-only、严格要求布尔;src/core/scheduler.ts:2030-2032 将 false 归一化为 undefined;src/core/schedule-precondition-config.ts:210 覆盖失败回滚;回执由实际持久状态生成。

非阻塞说明:旧 daemon 的 silent-only 路径目前显示 invalid_schedule_update 原始错误码,可选择后续映射成升级提示;新增 legacyReceipt 用例模拟的是“缺少 silent 的回执”,不是完整旧 daemon 响应。这两点都不造成错误确认或持久状态损坏。

实际验证

  • bun run build:通过。本地验证使用 rebase 等价提交 7442f92dba;已逐字比较,PR 的 8 个改动文件与远端 00d48f2b59 完全一致,差异仅为 master 的 #3779。
  • 双引擎定向全文件:vitest 与 bun test 均为 93 通过、1 失败。唯一失败是未改动的既有 chmod 000 用例;当前 UID 为 0,root 下该权限设置不能制造不可读文件,两种引擎表现一致。
  • 仅静默相关用例:vitest 7/7 通过,Bun 7/7 通过。
  • git diff --check:通过;编译后 dist/cli.js schedule update --help 的 fenced smoke 通过,实际包含两个静默开关。

持久状态对抗验证

在精确 head 的临时源码副本上,经 fenced-run.ts 使用真实 SQLite authority、JSON projection、precondition sidecar、scheduler 与可控定时器/故障注入,未发现问题:

  • 半步失败回滚:任务行更新后删除 sidecar 强制 rebind 失败;true → false 和 false → true 两个方向都返回 schedule_precondition_update_failed,authority 与 JSON 中 silent 均恢复为各自原值。探针只把任务行恢复记为成功,没有把外部删除的 sidecar 误记为已恢复。
  • tick × 人工编辑交叠:已认领且执行 Promise 未结算时,单独切换 silent 成功且当前运行保留旧快照、nextRunAt 不变;连续三次执行为 [true, false, true]。组合修改 silent + schedule 则整体以 schedule_run_in_flight 拒绝,两个字段均未改变。
  • 线协议边界:新 daemon 对 true/false 都显式回传布尔;旧 daemon 组合编辑缺键时新 CLI 退出 1,silent-only 在旧版校验阶段拒绝;非布尔 silent 在任何权限写入前拒绝。

CI 状态

network-boundary 与 bun-binary-darwin 已通过;其余 CI 任务在本复核记录时仍排队或运行,未将其计为通过。合并仍以最终 CI 结果为准。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并树复核确认

合并结构与代码内容确认可合;落地条件仍是当前 PR 的 CI 全部通过。

独立复算结果:

  • PR head 仍为 00d48f2b5998e5f2ae90f20c03f0572666697f45,master 为 37715affa3ff7eb5567a7c2f99b3f4934c9b34fd,GitHub 当前报告 MERGEABLE。
  • 两端三点 diff 的唯一文件交集为 src/cli.ts。
  • git merge-tree --write-tree 37715affa3 00d48f2b59 复算得到 ee098e420f9dd79b31d5b9d2b5f1fa50f2f670e7,退出 0。
  • 最新 master 到该 tree 只有 PR 的 8 个文件、138 行新增 / 8 行删除;git diff --check 通过。
  • PR 原 diff 与 master→合并 tree diff 的 stable patch-id 均为 229835e4bef5152ce5c6c653313bd720132de972,证明 PR 实际改动内容在合并树中未变。
  • src/cli.ts 中,master 侧仅贡献 cmdSetupScripted 的 hunk;PR 侧仍是 cmdSchedule schedule update 的两个 hunk,仅行号随前置内容下移。同文件非相邻、不同函数的判断成立。
  • 两端 delta 均未修改 package.json / bun.lock。

合并树上的 typecheck、build、schedule 双引擎定向测试及交集区域测试采用随确认请求提供的结果;本次新增验证是上述 tree、patch-id、文件交集和实际 diff 的独立复算,这些测试未在本次重复执行。

确认时 CI 已通过 build、network-boundary、bun-test 1/4、bun-binary、bun-binary-darwin;其余任务仍排队或运行,因此尚未把 CI 记为全绿。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新合并树确认

确认 70ca82f181efe3331a69a9d41948f754ede1471d 可合。 PR head 未变,CI 已全绿;落地时核实际 merge tree 与该预测一致即可。

独立复算结果:

  • 指定 master 精确为 402223f504b9e76129bcf3d8f8abee0ee0f12833,PR head 仍为 00d48f2b5998e5f2ae90f20c03f0572666697f45,GitHub 报告 MERGEABLE。
  • git merge-tree --write-tree 402223f504 00d48f2b59 复算得到 70ca82f181efe3331a69a9d41948f754ede1471d,退出 0。
  • 整段 master delta 与本轮增量 delta 各自和 PR 的文件交集都只有 src/cli.ts。
  • PR 原 diff 与新 master→新合并 tree diff 的 stable patch-id 均为 229835e4bef5152ce5c6c653313bd720132de972,合入内容逐字保持原 PR 语义与字节形态。
  • src/cli.ts 的 master 侧 hunk 位于 cmdSetupScripted、cmdCard、cmdAuth;PR 侧两个 hunk 仍位于 cmdSchedule,不同函数且不相邻。
  • 新 master→新 tree 仍只有 PR 的 8 个文件、138 行新增 / 8 行删除,git diff --check 通过;两端 delta 均未修改 package.json / bun.lock。
  • CI 的 13 个 job 均已成功;API 另有 test、bun-test 两个聚合条目也为 SUCCESS,当前 rollup 15/15 全部成功。

新合并树上的 typecheck、build 和定向测试采用随确认请求提供的结果;本次独立复算了 tree、文件交集、hunk、patch-id 和实际 diff,未重复执行这些测试。

@deepcoldy
deepcoldy merged commit 1d4dd5b into deepcoldy:master Nov 26, 2026
15 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

已合并,感谢贡献!

后续可改进项(不阻断,均非本 PR 引入的回归)

  1. 远端工具面暂不支持静默切换:remote runner protocol 的 schedule.update(src/adapters/backend/remote-runner-protocol.ts)与 riff host 参数白名单(src/services/riff-host-tools.ts)目前都不接受 silent / --no-silent,沙盒会话内的 agent 还无法经这两个面切换静默(schedule add 同样只有 --silent)。建议后续单独补一个 PR,把 update 的静默开关接到这两个入口。
  2. 旧版 daemon 收到仅含 silent 的更新请求时返回的是原始错误码 invalid_schedule_update;新版本 CLI 已能在回执缺字段时给出「daemon 版本过旧」的明确提示,后续可考虑把该原始码也映射成升级提示文案。

验证摘要

  • 评审在精确 head 上完成,CI 15 项首跑全部通过(无重跑)。
  • 合入为单个 squash 提交,任务 ID、执行记录等持久数据无迁移;新开关为纯增量参数,不使用时行为与旧版完全一致。

@github-actions

Copy link
Copy Markdown

@gxy01 @deepcoldy 合入 master 后的 Midscene E2E 失败:Dashboard Midscene 失败。

这次运行覆盖 402223f…32dd59c52(6 个提交),同批合入的还有 #3863 #3860 #3867 #3854 #3878,失败不一定由本 PR 引起。

用例 跑道 状态 失败信息
Navigate the core read-only Dashboard pages dashboard-smoke failed Node "aiAssert" failed: Assertion failed: The Dashboard workbench or navigation is missing

@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.35

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