Skip to content

fix(cron): match restricted day fields with OR - #612

Merged
Kaguya-19 merged 2 commits into
OpenBMB:mainfrom
blueberrycongee:fix/cron-day-matching
Sep 24, 2026
Merged

Kaguya-19 merged 2 commits into
OpenBMB:mainfrom
blueberrycongee:fix/cron-day-matching

Conversation

@blueberrycongee

Copy link
Copy Markdown
Contributor

Summary

Fix the Cron day-of-month/day-of-week matching rule. When both fields are restricted, Unix cron runs when either matches; PilotDeck previously required both.

For 0 9 1 * 1, starting at 2026-06-02T00:00:00Z:

  • Before: 2027-02-01T09:00:00Z (the next Monday that is also the first).
  • After: 2026-06-08T09:00:00Z (the next Monday).

Changes

  • Preserve the original day-field syntax and use OR only when neither field starts with *. Keep AND for wildcard fields, including */n, following Cronie's matching rule.
  • Keep month/hour/minute constraints and timezone handling. Do not mistake explicit full ranges such as 0-6 for wildcards.
  • Restrict the leap-day fast path to genuinely leap-day-only schedules; 29 2 0-6 must also run on other February dates under OR semantics.
  • Advance the schedule computation version to 3 so startup repairs cached future execution dates. Preserve already-due version-2 runs for catch-up, leave one-time schedules alone, and avoid recalculating migrated tasks on subsequent restarts.
  • Add 16 matcher cases plus a persisted-task migration/restart regression test. No UI or dependency changes.

Validation

Using Node 22.23.3:

  • npm run build — passed.
  • node --import tsx --test tests/cron/cron-schedule.test.ts tests/cron/cron-editing.spec.ts — 27 passed.
  • Before the fix, 10 of the 16 matcher cases failed. The migration regression also failed independently before the cache-version change.
  • Full compiled suite: 642 passed, 0 failed, 9 cancelled, 2 skipped (653 total; nonzero exit due to cancellations).
  • Repeated the same full build and suite in a separate clean worktree at upstream f0ca40f4: 625 passed, 0 failed, the same 9 cancelled, 2 skipped (636 total). All 17 added tests pass.

The pre-existing cancellations are seven cases in tests/network/fetch.spec.ts and two in tests/task/background-task-runtime.spec.ts, all reporting Promise resolution is still pending but the event loop has already resolved. They are outside this PR's scope.

blueberrycongee and others added 2 commits September 24, 2026 14:05
Co-authored-by: WUU Agent <305930189+wuu-agent[bot]@users.noreply.github.com>
Co-authored-by: WUU Agent <305930189+wuu-agent[bot]@users.noreply.github.com>
@Kaguya-19
Kaguya-19 merged commit ee6a10e into OpenBMB:main Sep 24, 2026
5 checks passed
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