From dba811dfb27c4f65bc41f7b6cfd50db387ae1cea Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 23 Sep 2026 02:56:27 +1000 Subject: [PATCH] docs(scheduling): pin the pocketbase AND of day-of-month and day-of-week tools/cron ANDs the two day fields where Vixie cron ORs them, so 0 0 1 * 1 means Monday the 1st, not the 1st or any Monday. State the deviation in the ScheduleCron comment and pin it with a test. --- internal/domain/scheduling/schedule.go | 8 +++++--- internal/domain/scheduling/schedule_test.go | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/domain/scheduling/schedule.go b/internal/domain/scheduling/schedule.go index 573e7ebb6..787f02245 100644 --- a/internal/domain/scheduling/schedule.go +++ b/internal/domain/scheduling/schedule.go @@ -89,10 +89,12 @@ const ( // (or after Start, if never run). The simplest recurring schedule. ScheduleInterval = "interval" - // ScheduleCron fires at the next moment matching a standard 5-field - // cron expression (or one of the @ macros) after the last successful + // ScheduleCron fires at the next moment matching a 5-field cron + // expression (or one of the @ macros) after the last successful // run, computed in the zone of that run time. Expressions are parsed - // with pocketbase tools/cron. + // with pocketbase tools/cron, which ANDs day-of-month with day-of-week + // instead of Vixie cron's OR: "0 0 1 * 1" means only Monday the 1st, + // not "the 1st or any Monday". ScheduleCron = "cron" // ScheduleOnce fires once at the configured At time. Subsequent diff --git a/internal/domain/scheduling/schedule_test.go b/internal/domain/scheduling/schedule_test.go index 3707024fc..44734b435 100644 --- a/internal/domain/scheduling/schedule_test.go +++ b/internal/domain/scheduling/schedule_test.go @@ -35,6 +35,14 @@ func TestScheduleCronNextRun(t *testing.T) { lastRun: zoned(2026, 8, 24, 12, 7, 0), want: zoned(2026, 8, 24, 12, 15, 0), }, + { + // pins the pocketbase AND semantics: Vixie cron would give the + // next Monday (2026-08-31); tools/cron gives Monday the 1st. + name: "dual-restricted day-of-month and day-of-week AND, not Vixie OR", + expr: "0 0 1 * 1", + lastRun: zoned(2026, 8, 24, 12, 15, 30), + want: zoned(2027, 2, 1, 0, 0, 0), + }, { name: "run exactly on a matching minute advances to the next one", expr: "0 * * * *",