Scheduled starts and step deadlines

Two platform features for weekly operations work:

  • Scheduled starts: a run starts itself at a set time (e.g. the Merkl subsidy runs every Monday).
  • Step deadlines: while a run waits at a step, an "overdue" notice is posted once a deadline passes.

Both run in the worker. Times are UTC everywhere.

Scheduled starts

A schedule is a document in the schedules collection, edited under /database like any other document (database:write). Changing it needs no release; the worker reads it every minute.

{
  "name": "Merkl subsidy",
  "templateKey": "merkl-subsidy",
  "enabled": true,
  "cadence": { "every": "week", "weekday": "monday", "time": "08:00" },
  "cutoff": { "weekday": "tuesday", "time": "16:00" },
  "runs": [
    { "key": "usds-flagship", "label": "USDS Flagship", "values": { "vault": "USDS Flagship" } },
    { "key": "usdt-savings", "label": "USDT Savings", "values": { "vault": "USDT Savings" } }
  ],
  "noticeChannel": "C0AKV749160",
  "owner": { "email": "erwe@soterlabs.com" },
  "sharing": { "defaultVisibility": "none", "editors": ["erwe@soterlabs.com", "adam@soterlabs.com"] }
}
FieldMeaning
templateKeyThe template to start.
enabledfalse keeps the schedule without running it.
cadence{"every":"week","weekday":…,"time":"HH:MM"} or {"every":"day","time":"HH:MM"}.
cutoffUntil when a missed occurrence is still started: the first weekday time after it, or {"afterHours":n}. Default: the next occurrence.
runsOne entry per run to start each time: a stable key, a label for notices, and values that fill in the template's start step (its startValuesStepKey, or its first step).
noticeChannelSlack channel id for "started / skipped / could not start". Without it, notices are only logged.
ownerThe person responsible for the schedule. Kept here; it is not stamped on the runs.
sharingAccess to the started runs: defaultVisibility (none, viewer, contributor) and editors by email (people without an account yet are left out and logged).
startFromOptional ISO time: occurrences before it are ignored. Occurrences before the document was created always are.

How it behaves

  • Never twice. Each run's process id is derived from the schedule, the period (ISO week such as 2026-W44, or the date for daily schedules) and the run's key. A second tick, a worker restart or a second worker reaches the same id, and the store refuses to create it again.
  • Missed times. After downtime, the latest occurrence still starts until its cutoff. Past the cutoff it is skipped and the skip is posted once. Older periods are never started.
  • Failures. A refused start (for example, the ProcessOS account lacks the permission) is posted once, retried every minute and recorded; past the cutoff it becomes a skip.
  • History. Every outcome is a document in schedule-runs (<schedule>--<period>--<run>: status started, skipped or failed, the process id, the occurrence and cutoff, the error). /database is the schedules page for now.
  • An invalid schedule document is skipped and the reason logged once; other schedules keep running.

Who starts the run: the ProcessOS account. Scheduled runs are started by the ordinary ProcessOS account (processos|platform, "ProcessOS"; see records), recorded and shown by its name like any account. Nobody signs in as it.

  • For a scheduled start it acts with one grant, processes:start-scheduled, and nothing else.
  • That grant starts a run only of a template that allows scheduled starts by naming it in its start permissions: startPermissions: ["processes:write", "processes:start-scheduled"] (people still start it with processes:write). A schedule for any other template is refused like any start without permission; the refusal is posted once and recorded in schedule-runs.

Step deadlines

A template can declare deadlines (deadlines in the template source; presentation only, so adding or moving one is not a version change and applies to running items):

deadlines: [
  { key: "a1-not-picked-up", title: "Run not picked up", due: { afterMinutes: 180 }, steps: ["choose_run"], channel: "C0AKV749160" },
  { key: "a8-not-signed", title: "Not signed 3 hours before the start", due: { weekday: "tuesday", time: "16:00", offsetMinutes: -180 },
    steps: ["queue_and_sign", "cosign_review"], channel: "C0AKV749160", description: "Finish both signatures before Tuesday 16:00 UTC." },
]
  • due: afterMinutes after the run entered the current step (after the run started when steps is omitted), or the first weekday time at or after the run started, moved by offsetMinutes.
  • steps: the deadline applies only while the run waits at one of them; omitted, until the run ends.
  • channel: where the notice goes; the deployment's attention channel when omitted.

The attention sweep (every 5 minutes) posts each deadline when due, then reminds at most every 30 minutes while it still applies. The marker is cleared when the run moves past the deadline or ends. A deadline already more than a day old when first seen (e.g. on the first deploy) is recorded silently and remains suppressed on later sweeps.

Currently overdue notices are combined when they share a channel, application, template, deadline, and notice heading/context. A declared groupPath identifies a campaign for relative deadlines; otherwise the exact due time remains part of the grouping key. Each channel waits 30 minutes from its latest successful send, then sends all unresolved members together. A newly overdue member joins that window. Staggered legacy timers converge on this shared window rather than sending separately. Each row retains its own process link; a resolved run drops out. Per-channel delivery receipts are saved after a successful send, so routing/send failures retry on the next sweep, including after a restart. This is best-effort delivery: a crash after Slack accepts a message but before its receipt is saved, or a partial failure while sending a long list, can repeat a delivered message on retry. Separate campaigns, channels and instructions remain separate. Long lists are split without losing rows.

A deadline can optionally declare notice presentation data: title, titleByStep, labelPath, groupPath, reference: { label, path }, context: { label, path }, and action. Paths select scalar values from process memory; only those explicitly selected values enter the notice. Missing values are omitted, with the process id as the row-label fallback. Treat these as channel-visible fields; do not select secrets. This presentation applies to running items after the normal template publication step.