Skip to content

fix(coding-agent): accept sparse leap-day schedules - #912

Open
chai1any wants to merge 3 commits into
PrimeIntellect-ai:mainfrom
chai1any:fix/cron-leap-day-schedules
Open

fix(coding-agent): accept sparse leap-day schedules#912
chai1any wants to merge 3 commits into
PrimeIntellect-ai:mainfrom
chai1any:fix/cron-leap-day-schedules

Conversation

@chai1any

@chai1any chai1any commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • search a complete Gregorian calendar cycle when resolving the next five-field cron run
  • skip non-matching calendar days so sparse schedules remain fast without a minute-by-minute multi-year scan
  • add a timezone-independent regression for a leap-day schedule created in 2025

Problem

nextCronRunAfter() currently stops after 366 days. A valid schedule such as 0 0 29 2 * is therefore rejected during creation in most years because its next occurrence can be several years away:

Cron schedule did not match within one year: 0 0 29 2 *

Gregorian calendar dates repeat every 400 years, which provides a finite correctness bound. Skipping calendar days that cannot match keeps that bound practical and also rejects impossible dates deterministically.

Verification

  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/cron-jobs.test.ts (54 tests passed)
  • npm run check
  • cron suite also passed under UTC, America/New_York, Europe/Berlin, Pacific/Apia, and Australia/Lord_Howe
  • manual reproduction now resolves 0 0 29 2 * from March 2025 to February 29, 2028

Note

Fix nextCronRunAfter to accept leap-day cron schedules beyond one year

  • Replaces the one-year minute-by-minute scan in nextCronRunAfter with a 400-year Gregorian window, allowing sparse schedules like 0 0 29 2 * (leap day) to resolve correctly.
  • Adds a calendar-day prefilter via a new matchesCronCalendarDay helper that skips non-matching days in whole-day increments instead of iterating minute-by-minute.
  • Impossible dates (e.g. 0 0 31 2 *) now throw 'Cron schedule has no matching date: ...' instead of 'Cron schedule did not match within one year: ...'.
  • Behavioral Change: the scan window is now 400 years instead of 1; schedules that previously errored after one year may now resolve.

Macroscope summarized d53b62e.

Search a full Gregorian calendar cycle for the next cron date and skip non-matching calendar days efficiently, instead of rejecting valid schedules whose next run is more than one year away.
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.

1 participant