From d6d3b2469f46e424e9ed908e25eab5079b83d5f8 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Fri, 6 Nov 2026 17:16:07 -0800 Subject: [PATCH] fix(core): allow `changes: false` beside another shell check predicate A shell check's wording counts is, matches and changes as alternatives, but validation counted an explicit `changes: false` as one of them while the run path treats it as unset. A check that opted out of change detection beside another predicate was rejected as choosing two, with no way to say no. Accept it and count only `changes: true`. --- packages/core/src/schedule/check.ts | 3 ++- packages/core/test/schedule.test.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/core/src/schedule/check.ts b/packages/core/src/schedule/check.ts index 816422d13de..18c2a0c31bf 100644 --- a/packages/core/src/schedule/check.ts +++ b/packages/core/src/schedule/check.ts @@ -71,10 +71,11 @@ export function validate(condition: ScheduleSchema.Condition): Result.Result 1) return Result.fail("Choose at most one of is, matches or changes") if (condition.matches === undefined) return Result.succeed(undefined) diff --git a/packages/core/test/schedule.test.ts b/packages/core/test/schedule.test.ts index 391e92dab92..39802f04043 100644 --- a/packages/core/test/schedule.test.ts +++ b/packages/core/test/schedule.test.ts @@ -1229,6 +1229,26 @@ describe("Schedule", () => { ).toMatchObject({ _tag: "Schedule.InvalidError" }) }), ) + + it.effect("counts only a changes predicate that is turned on", () => + Effect.gen(function* () { + const schedules = yield* setup() + const create = (check: NonNullable[0]["if"]>) => + schedules.create({ + sessionID, + when: { type: "every", every: "15 seconds" }, + if: check, + action: { type: "prompt", prompt: "x" }, + }) + // `changes: false` opts out, so it does not compete with another predicate. + expect(yield* create({ type: "shell", run: "echo hi", is: "hi", changes: false })).toMatchObject({ + if: { type: "shell", run: "echo hi", is: "hi", changes: false }, + }) + expect( + yield* Effect.flip(create({ type: "shell", run: "echo hi", is: "hi", changes: true })), + ).toMatchObject({ reason: "Choose at most one of is, matches or changes" }) + }), + ) }) describe("code checks", () => {