Skip to content

feat(schedules): register workflows in five named slots - #6

Merged
jshvn merged 1 commit into
mainfrom
josh/slots
Sep 9, 2026
Merged

jshvn merged 1 commit into
mainfrom
josh/slots

Conversation

@jshvn

@jshvn jshvn commented Sep 9, 2026

Copy link
Copy Markdown
Owner

What

Replaces per-workflow cron strings with a SLOTS table of five named expressions in schedules/index.ts. A leaf declares slots: [...] and ends in as const, so a misspelt slot, a leaf without as const, or an empty slot list fails to compile on the registry line. Target keeps its cron, so src/index.ts is untouched.

slot UTC Pacific, winter
hourly :42 :42
overnight 11:17 03:17
morning 17:17 09:17
afternoon 23:17 15:17
evening 05:17 21:17

One expression per slot rather than one four-hour daily: Cloudflare hands the Worker the same string for every hour a list expression matches, so a target could not pick one, and a dropped trigger takes one slot down rather than every daily. Only slots with a target become triggers; wrangler.jsonc carries three until morning or afternoon is claimed. Registering a workflow in a slot already in use no longer touches wrangler.jsonc, so it needs no task crons and has no propagation window.

Fire times move

  • ctan stays hourly at :42.
  • dropbox: 20 11 to 17 11, three minutes earlier.
  • terraform: 15 4 to 17 5, about an hour later.
  • tlnet: 30 3 to 17 5, about two hours later. It now shares a firing with terraform.

The three daily expressions are new strings, so each pays the 15-minute propagation delay once and may miss its first slot after deploy.

Test plan

  • task check passes: typecheck, format, 45 tests, dry-run deploy
  • A misspelt slot, a leaf without as const, and slots: [] each fail tsc on the REPOS line
  • task crons run; wrangler.jsonc carries 17 11, 17 5, 42 *
  • task targets prints the slot column
  • After deploy, task instances shows the 17 5 * * * firing with two steps

Replace per-workflow cron strings with a SLOTS table in schedules/index.ts:
hourly at :42, and overnight, morning, afternoon and evening dailies at :17
UTC (11, 17, 23 and 5). A leaf declares slot names and ends in `as const`,
so a misspelt slot, a missing `as const` or an empty list fails to compile on
the registry line. Target keeps its cron, so the Worker is unchanged.

One expression per slot rather than one four-hour daily: Cloudflare hands
the Worker the same string for every hour a list expression matches, and a
dropped trigger takes one slot down rather than every daily. Only slots with
a target become triggers, so wrangler.jsonc carries three until morning or
afternoon is claimed.

Reassignment: ctan stays hourly; dropbox moves to overnight, three minutes
earlier; terraform and tlnet move to evening, about one and two hours later,
and now dispatch in the same firing. The three daily expressions are new and
pay the propagation delay once.
@jshvn
jshvn merged commit 1b33908 into main Sep 9, 2026
1 check passed
@jshvn
jshvn deleted the josh/slots branch September 9, 2026 22:01
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