Skip to content

fix(scheduler): skip the model when a check has no change signal - #8285

Open
elfcv wants to merge 6 commits into
makecindy:mainfrom
elfcv:fix/check-skip-model-without-change
Open

elfcv wants to merge 6 commits into
makecindy:mainfrom
elfcv:fix/check-skip-model-without-change

Conversation

@elfcv

@elfcv elfcv commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

Agent 新建的检查任务,没变化就不要再启动模型。以前 silentWhenIdle=true 只是不播报,模型仍会每次被叫醒去判断有没有变化。现在这类新建检查默认带程序变化门:没有脚本 exit 0 或插件放行,就不建会话、不启动模型,run 记 skipped。上网检索这类必须由模型发现变化的检查,创建时显式设 modelDetectsChange=true,仍走原来的「启动模型、无变化不播报」。

变更类型

  • fix 缺陷修复

范围

UI 变化

不涉及。

  • 引用的设计规范:不涉及

怎么验证的

自动验证

cd apps/desktop && pnpm exec vitest run src/main/scheduler-host/__tests__/runnerPreRunHookCwd.test.ts src/main/scheduler-host/__tests__/storage.test.ts --maxWorkers=2
结果:48 passed(runner 22 + storage 26)。runner 文件约 13s,其中测试体 16ms;耗时在 Electron 收集,不是用例本身。

cd packages/lizi-mcps && pnpm exec vitest run src/__tests__/cindy_schedulerMcpServer.test.ts --maxWorkers=2
结果:75 passed,218ms。

node apps/desktop/scripts/validate-migrations.mjs
结果:0000..0141 通过,无 schema drift。

pnpm --filter @cindy/maker-scheduler exec tsc --noEmit
结果:通过。

测试价值:最小失败输入是 { silentWhenIdle: true } 的 schedule_create,读回 programChangeGate=true;以及 runner 对带门、无 hook、无插件的检查直接 skipped,createSession 未被调用。对照锁住 modelDetectsChange=true、提醒、有 hook、有插件、把检查改回提醒这几条不误伤。

手工验证

不涉及。没有启动 Desktop,也没有改真实定时任务。

未执行的验证

  • Desktop 全量 tsc --noEmit 在本机 8GB 堆上 OOM。失败点是堆上限,不是类型报错。定向 vitest 已编译并跑过改动文件。
  • 没有在真机上观察一条新建检查的 skipped 记录。

风险

风险分类

  • SQLite / migration
  • 其他:改了模型可见的 schedule_create / schedule_update 说明。

影响与回滚

  • 影响范围:只影响本机、经 schedule_create 新建、且 silentWhenIdle=true、未设 modelDetectsChange=true 的 agent 检查。已有任务列默认 false。提醒、脚本任务、桌面表单不受影响。跨电脑 schedule_update 不接受 modelDetectsChange。
  • 回滚 / 降级方式:revert 本提交。新列默认 false,旧客户端忽略未知列;已建的带门任务可在本机用 modelDetectsChange=true 关掉。
  • 存量插件影响:无。没选插件的任务由脚本或这道门决定;选了插件的检查仍先问插件,插件放行才会进入模型路径。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名
  • 未提交凭证、令牌或授权文件
  • 已核对受影响的文档并同步
  • 已确认测试结果或说明未执行原因

@elfcv
elfcv requested a review from a team as a code owner October 31, 2026 22:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T17:02:08.488171Z 0dced01 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects how selected scheduled checks start across agent-created routines.

Fix Continue for interrupted gated checks before merging.

Findings

  1. P1 Continue skips interrupted checks ▶
Fix with agent prompt
### Issue 1
apps/desktop/src/main/scheduler-host/runner.ts:883-887
A check created with `silentWhenIdle=true` and a passing `preRunHook` cannot continue after an app restart. When the user clicks Continue, `fire()` clears `preRunHook` but keeps `programChangeGate=true`. This condition then skips the run instead of continuing its existing task.

The engine also marks the original run as `skipped`, clears its `sessionId`, and sets its cost to zero even though it already started. Exempt `ctx.resumeSessionId` from this gate and add a regression test for continuing a gated check.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds programChangeGate so new agent checks created through schedule_create skip the model when no script or plugin check is configured.

  • New agent checks skip the model unless a program signal or model-led check is chosen.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[User clicks Continue] --> B[Load interrupted run]
  B --> C[Keep programChangeGate; remove preRunHook]
  C --> D{No plugin configured?}
  D -->|Yes| E[New gate returns skipped]
  E --> F[Original run loses task link and is marked zero cost]
Loading

Reviews (1) · Last reviewed commit: "fix(scheduler): skip the model when a ch..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1b2b40c1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MagicLizi

Copy link
Copy Markdown
Contributor

维护者确认请求(自动审查流程)

本 PR 命中维护者确认门,需要维护者确认后才能继续自动审查与合并:

  • rules:改动了规则文档 docs/product-rules/bot-routines.md,且为实质规则含义变更(新建检查默认带程序变化门、没变化不再启动模型等新规定),审查判据自身发生变化;
  • arch:调度核心路径改动 160 行(≥150 阈值),总 diff 7696 行(≥800 阈值),并改变新建检查的默认行为。

改动摘要:Agent 新建的检查(silentWhenIdle=true)默认带程序变化门,没有脚本 exit 0 或插件放行就不启动模型、run 记 skipped、零 token;变化必须由模型发现时显式设 modelDetectsChange=true;提醒、定时发送、桌面表单和已有任务不迁移。附带数据库 migration(schedules 新增 program_change_gate 列)。

请维护者直接在本 PR 上 Approve 确认(Approve 即视为确认通过,流程会继续自动审查与合并);如需修改,请 Request Changes 并说明,作者改完后重新审查。

详细说明见关联讨论 issue。

讨论 issue:#8286

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:redline 改动碰到红线路径(updater / DB schema 等,review-pr 自动维护,仅展示) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) labels Oct 31, 2026
@elfcv

elfcv commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on b4e5ca5, after merging current main (conflict was only schedule_create; remote create of a silent check still gets programChangeGate).

Review fixes:

  • Continue after exit no longer hits the no-signal gate just because resume clears the hook.
  • A gated check bound to a deleted or service-owned archived target pauses before the empty skip, so it does not stay active.

Local checks, not GitHub CI:

  • pnpm --dir apps/desktop exec vitest run src/main/scheduler-host/__tests__/runnerPreRunHookCwd.test.ts --maxWorkers=2: 28 passed, 13.4s
  • pnpm --dir packages/lizi-mcps exec vitest run src/__tests__/cindy_schedulerMcpServer.test.ts src/__tests__/schedulerDevices.test.ts --maxWorkers=2: 91 passed, 1.1s
  • apps/desktop tsc --noEmit exit 0
  • eslint on the touched desktop runner files exit 0

CI on this head has not finished. Product gate #8286 is unchanged and still needs a maintainer Approve.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4e5ca5272

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

elfcv added 2 commits November 1, 2026 22:39
Agent-created checks no longer start a model just to decide that nothing
changed. A pre-run hook exit 0 or a plugin allow is the signal to run;
modelDetectsChange keeps the old poll-with-model path for research checks.
Existing schedules, reminders, and the desktop form are unchanged.

Signed-off-by: elfcv <cnxpfcv@gmail.com>
Resume clears the pre-run hook but must not reapply the no-signal gate,
otherwise Continue skips a check that already started. A gated check bound
to a deleted or service-owned archived target now pauses before the skip,
instead of staying active and accumulating empty runs.

Signed-off-by: elfcv <cnxpfcv@gmail.com>
@elfcv
elfcv force-pushed the fix/check-skip-model-without-change branch from b4e5ca5 to 0fa2d40 Compare November 1, 2026 14:39
@elfcv

elfcv commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. The program-change-gate migration is now 0144_brief_elektra (main already owns 0141-0143). Head 0fa2d40543.

Local checks before push, not GitHub CI:

  • pnpm --dir apps/desktop db:validate: passed, 0000..0144, drizzle-kit check ok, 1.3s
  • runnerPreRunHookCwd 29 passed, 13.3s
  • scheduler MCP tests 91 passed, 1.1s

CI is rerunning on this head. Still needs a maintainer Approve on the PR; the author cannot self-approve.

elfcv added 2 commits November 3, 2026 01:35
A peer that supports remote create but predates the program change gate
drops `programChangeGate`, so a check promised to skip the model without
a program signal would start the model (and spend tokens) on every run.

The host now declares `supportsScheduleProgramChangeGate` in
maker:get-capabilities, and the scheduler transport refuses a create
with `programChangeGate: true` with REMOTE_UNSUPPORTED before the write
when the peer lacks it. `programChangeGate: false` (the model detects
change) behaves the same on old and new peers and needs no capability;
cross-device schedule_update already refuses modelDetectsChange.

Also bring the DB-tier storage test (manual tier, not run by unit CI) up
to the new column: its hand-written schedules table and round-trip
fixture lacked program_change_gate, so every insert failed.

Signed-off-by: elfcv <cnxpfcv@gmail.com>
Main now owns migration 0144 (preserve_existing_pr_associations), so the
program-change-gate column is regenerated with drizzle-kit as
0145_round_baron_zemo against main's migration chain. The SQL is
unchanged.

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: elfcv <cnxpfcv@gmail.com>
@elfcv

elfcv commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged current main again (a65d671fe5). Main now owns 0144 and 0145, so the program-change-gate migration was regenerated with drizzle-kit as 0146_handy_quentin_quire. The SQL is unchanged (ALTER TABLE schedules ADD program_change_gate ...).

Local: db:validate passes (0000..0146). test:migration-replay was not run: it only executes on macOS/Windows, and it is a manual tier that CI does not run either.

The review finding about promotion to a project automation is fixed in 0dced01893 (see the thread).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2e3cc2ace

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-scheduler/src/types.ts Resolved
elfcv added 2 commits November 5, 2026 00:51
Main now owns migration 0145, so the program-change-gate column is
regenerated with drizzle-kit as 0146_handy_quentin_quire. The SQL is
unchanged.

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: elfcv <cnxpfcv@gmail.com>
Promoting a gated check to a project automation rebuilt it from the
project file, which had no programChangeGate field, so the check was
stored with the gate off and started the model on every run. The
project file now carries the gate (written only when on), the loader
reads it, compares it and validates it, and editing a project
automation in the form keeps the saved value. Files without the field
still default to off.

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: elfcv <cnxpfcv@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0dced01893

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* 见 Schedule.programChangeGate。仅 Agent 检查创建入口在未显式 modelDetectsChange 时设 true。
* 桌面表单、提醒和已有任务不设。
*/
programChangeGate?: boolean;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 在复制或降级项目检查时保留程序变化门

把 silentWhenIdle=true、programChangeGate=true 且无 hook/插件的项目检查复制或降级为个人自动任务时,SchedulerPage.tsx:489–492,515–516 都会调用 scheduleToUserCreateInput(),但该转换(scheduleFormLogic.ts:675–698)没有携带这两个字段。定向运行生产转换确认,重建输入确实缺少两项;此路径直接走 IPC schedule.create,不会经过 MCP 新增的默认门控逻辑,因此落库后门变为 false,原本无信号时零 token 的检查会重新每轮启动模型,降级路径还会删除原调度。请同步这个反向转换,保留已有门控和静默状态。

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:redline 改动碰到红线路径(updater / DB schema 等,review-pr 自动维护,仅展示) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants