Hourly jobs
One Cron Trigger fires every hour (UTC). It runs a small dispatcher that looks at the household's local time and starts whichever jobs are due. That is one of the five free-plan triggers, and clock changes are handled in one place, with tests.
Built and tested, never seen firing on a real account
The dispatcher and its record are built and tested. The backup body is real (it writes an encrypted copy of the database to R2: see the runbook). The bank pull and the health check are still stubs that only write down what they would do: no bank calls, no network. The Cron Trigger, one hourly cron 0 * * * * (UTC), is in the generated config for both the demo and production, so a deploy starts it; it is not in the local wrangler.jsonc (wrangler dev --test-scheduled fires it by hand). It has not been seen firing on a real account.
The jobs
| Job | When (household local time) | What it will do |
|---|---|---|
pull | 1 to 4 hours a day, from Settings (default 03, 09, 15, 21) | Pull the bank, then reconcile |
job-health | once a day (default 06) | Check the job-health line |
backup | once a day (default 04) | Write the nightly backup (real) |
The defaults put the backup after the first pull (so it holds the newest data) and the health check after both.
Settings
All three are optional: a key with no value in force uses its default. Like every Setting they are effective-dated.
| Key | Value | Default |
|---|---|---|
job_pull_hours | JSON list of 1 to 4 different hours 0–23 | [3, 9, 15, 21] |
job_health_hour | one hour, 0–23 | 6 |
backup_hour | one hour, 0–23 | 4 |
The household time zone is time_zone. reconcile_mode gates the pulls: off runs none, dry-run runs them and records them as dry runs, live runs them. The health check and the backup run in every mode. Switching off to live (or dry-run) within six hours after a pull slot fires one catch-up pull at the next hourly tick.
A bad value never stops the other jobs. Each key is read on its own: a bad reconcile_mode (missing, or not one of the three) means off (no pulls), and a bad hour or hour list uses that key's default. A config-error line in the audit log names the key (never the value), once a day per key. Only a missing or unknown time zone stops the tick, since nothing can be scheduled without one.
How "due" is decided
A slot is one scheduled hour on one local day, written 2026-03-08T09 (the scheduled hour, not the hour it ran in). Each job's slot to run is its most recent slot at or before the household's local date and hour (before its first hour of the day, yesterday's last). It runs when it is later than the job's last run and no more than six local hours old. Older missed slots are never replayed: a pull is repeatable, so the newest slot is all a catch-up needs.
- Spring forward: a job scheduled in the hour that doesn't exist (02:00 on the change day) runs once, at 03:00. If 03:00 is also a slot, that one runs and the 02:00 one is dropped, so a day never holds more runs than its slots.
- Fall back: the repeated hour has the same date and hour both times, so it is the same slot: it runs once.
- A missed hour: the next tick finds the slot still due and runs it, marked as caught up (inside the six hours).
- Two ticks in one hour: the second finds the slot already run.
- A slot recorded in the future (a dev tick at a far-away moment, or a time zone change) is ignored: only slots up to the household's current local slot count as "last run".
- Half-hour zones: the tick's local hour decides, so a tick at :30 local works the same way.
- At most four pulls a day: the schedule is refused with more than four pull hours or a repeated hour.
Where it lives
packages/core/src/job-dispatch.ts:dueJobs, the schedule checks and the Settings readers. Pure, with golden tests across New York, Los Angeles, Sydney, Kolkata and Lord Howe clock changes.apps/worker/src/jobs/:scheduled(the Cron entry point, on the Worker's default export),runDueJobs(reads Settings, runs what is due, records it) andbodies.ts(the stubs, andliveBodies: the real backup).apps/worker/src/backup/: the backup itself (names and retention, encryption, the dump, the job).- The record is the audit log, no new table: one system line per run, table
scheduled_job, record id<job>@<slot>, details in the line. The newest line per job is what it last ran for. A slot is claimed with a conditional insert before its body runs, so two triggers at once run it once. A body that throws is recorded as afailed@<job>@<slot>line (append-only; the claim line stays) and the rest of the tick still runs. The real backup is the exception: it is claimed after it succeeds (see below). A stub's claim line has actionwould-run(dry-runfor a dry-run pull) andstub: true; a real body's has actionrunandstub: false. - A failure is also reported. After the whole tick has run,
scheduledthrows one error naming the failed jobs and their codes (never a value), so the invocation counts as failed in Cloudflare's error monitoring and an alert can fire.
Trying it locally
With the local server running, an Admin can run one tick at any moment. The Worker's notes show how to print a ready curl with npm run dev:token -- gomez --curl /api/dev/run-jobs; send it as a POST with an X-Now header such as 2026-03-08T14:00:00Z.
POST /api/dev/run-jobs runs one tick of the stubs at the X-Now moment and answers with what ran. It never runs the real backup (it never touches the bucket); the scheduled entry point does, as the Cron Trigger would. It exists only where NOW_OVERRIDE=allowed (the local config and the tests); anywhere else it is a 404 for everyone, signed in or not (the check comes before the login on purpose, so a deployed-site check can see it; it shows only that the dev prefix is special, and every other path still fails closed with a 401). The X-Now moment must be within six hours of the real time (else 400), so a far-future slot can't be planted.
Known limits
- A failed backup is tried again. It runs first and claims its slot only on success (it is safe to run twice: one
headsays "done" and its write never replaces an object), so a failure leaves the slot free and each later hourly tick in the catch-up window (6 hours after the slot's hour) tries again. Each failed try leaves its ownfailed@backup@<slot>@<time>line and fails its invocation, so one bad night can raise up to seven alerts. Two ticks at once may both run it; one claim line lands. Past the window the night is lost. The stubs, and the real pull when it lands, still claim first and are not retried (a bank pull is not something to repeat blindly: that rule is settled with it). - The health body is a stub. Nothing alerts when the backup silently doesn't run (the trigger removed, the Worker deleted): the job-health check that would notice is not built.
- The catch-up window counts wall-clock hours, so across a clock change it can be an hour off in either direction.
- The Settings page doesn't list the three new keys until it reads them; until then they are set as plain Settings rows.