Make schedule store recurrence-aware (cron + RRULE)#5516
Conversation
Upgrade schedule store to support both cron and RRULE syntax via the recurrence engine. Adds syntax/expression fields to ScheduleJob, persists schedule_syntax in DB, and uses recurrence engine for validation and next-run computation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee6f9d0fd8
ℹ️ 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".
| newNextRunAt = computeNextRunAtEngine({ | ||
| syntax, | ||
| expression: row.cronExpression, | ||
| timezone: row.timezone, | ||
| }); |
There was a problem hiding this comment.
Handle exhausted RRULEs after claiming the due run
For finite RRULE schedules (for example COUNT=1 or an UNTIL boundary), computeNextRunAtEngine can throw once the currently due occurrence is the last one; in claimDueSchedules, that exception path skips the job entirely, so the due run is never claimed/executed and the row remains perpetually due on every tick. This regression is introduced by adding RRULE support here, because cron expressions were effectively unbounded before. The claim path needs to execute the current due run even when no subsequent occurrence exists (e.g., by claiming and disabling/removing the schedule).
Useful? React with 👍 / 👎.
|
Addressed in #5634 |
Summary
syntaxandexpressionfields to theScheduleJobinterface while preservingcronExpressionfor backward compatibilitycreateScheduleandupdateSchedulenow accept optionalsyntax/expressionparams; when omitted, defaults to cron behaviorclaimDueSchedulesreadsschedule_syntaxfrom DB rows and delegates tocomputeNextRunAtEnginefor syntax-aware next-run computationschedule_syntaxin the DB (cron_jobs.schedule_syntaxcolumn added in PR 03)Test plan
schedule-store.test.tswith 14 tests covering:schedule_syntaxcolumnupdateSchedulewith syntax/expression switchingclaimDueSchedulesadvancing both cron and RRULE schedulestask-scheduler.test.tspasses (6/6)tsc --noEmitpasses🤖 Generated with Claude Code