Sign in Start free
Contents Change windows

Change windows

A change window opens on a cron, in your time zone, and a workflow or step that names it starts only while it is open. A blackout holds every step that needs a window, whatever the windows say. Admins define both, in shiftlabs.config.ts or the dashboard, and an admin can let one held step through a blackout with a note the audit log keeps.

Windows and blackouts

A window is a cron, a time zone, a first opening and a duration: each cron time from startsAt on opens it for duration. A blackout is a stretch of time, from from up to to.

shiftlabs.config.ts
import { blackout, project, window } from "shiftlabs";

export default project({
  workflows: { "deploy-core": "./workflows/deploy-core.ts" },
  windows: {
    "sat-maint": window({
      cron: "0 22 * * SAT",
      timezone: "America/Detroit",
      startsAt: "2026-11-14T22:00:00-05:00",
      duration: "4 hours",
    }),
    lab: window({
      cron: "0 20 * * SAT",
      timezone: "America/Detroit",
      startsAt: "2026-11-14T20:00:00-05:00",
      duration: "8 hours",
    }),
    "q4-close": blackout({ from: "2026-12-28T00:00:00Z", to: "2027-01-04T00:00:00Z" }),
  },
});
  • cron is a schedule's five fields, read in timezone, an IANA name such as America/Detroit. Clock changes go as a schedule's do: a time skipped when clocks go forward opens an hour later that day, and a time that happens twice opens once, the first time, unless the hour field is *.
  • startsAt and a blackout's from and to are instants with their offset, such as 2026-11-14T22:00:00-05:00, kept as written. The first opening is the first cron time at or after startsAt.
  • duration is from 1 minute to 7 days, such as "4 hours"; digits alone are milliseconds. An opening lasts that long in elapsed time, a clock change included. Openings that overlap join into one.
  • A window is open from an opening's start up to its end: open at 22:00 and closed again at 02:00, not open at 02:00. A blackout holds from from up to to.
  • Names use lowercase letters, digits and hyphens. Windows and blackouts share one set of names.

Set in code

shiftlabs deploy makes the project's windows current in the same release as its workflows, agents and schedules. They replace the windows set in code: windows: {} removes them all, and a project without windows leaves them as they are. Rolling back a release puts its windows back, and promoting it carries them to the linked workspace.

  • Changing the windows set in code needs window.manage, which admins hold, and an API key without an agent or workflow scope. A release that leaves them as they are needs nothing more than a deploy does.
  • A name the dashboard set can't be set in code, and the dashboard can't change or remove one set in code: 409.
  • A version that names a window the workspace won't have once the release is in is refused with 409, naming the window. A code check says so too, with ?windows= naming the windows your project sets.

Set in the dashboard

Admins add, change and remove windows and blackouts on the Windows screen (under Automate in the sidebar, or g o), with shiftlabs windows set and shiftlabs windows remove, or with PUT /v1/windows/:name and DELETE /v1/windows/:name. Everyone can read them: the screen, shiftlabs windows list and GET /v1/windows list code's and the dashboard's together, with whether each is open or in effect now and its next opening or end.

shellterminal
npx shiftlabs windows set patch-tuesday --cron "0 18 * * TUE" --timezone Europe/Berlin --duration "3 hours"
npx shiftlabs windows set freeze-nov --from 2026-11-24T00:00:00Z --to 2026-11-30T00:00:00Z
npx shiftlabs windows list
  • A change goes at the version you read, so one made meanwhile is refused with 409 and the version it is at. shiftlabs windows set reads it first, and --if-match names it.
  • A window that the current version of a workflow names can't be removed, or made a blackout: 409 names those workflows. Deploy them without it first.
  • shiftlabs windows set without --starts-at keeps a window's first opening, and starts a new window's openings now.
  • Each change is in the audit log, window_set or window_delete, with what it was before.

Gate a workflow or a step

A workflow's window holds its run before any of its code runs, and holds each of its step.run, step.exec and step.activity calls. A step's own window adds to its workflow's: the step starts only while every window it needs is open and no blackout holds it. step.waitForWindow waits until one window is open, and holds nothing after it.

deploy-core
import { workflow } from "shiftlabs";

export default workflow({ window: "sat-maint" }, async ({ step }) => {
  await step.exec("drain", { run: "./drain.sh" });
  await step.run("smoke test", { window: { name: "lab", onClose: "continue" } }, async () => {
    const health = await fetch("https://lab.example.com/health");
    return health.status;
  });
});
  • A window is named by its name, or by { name, onClose } ({"name", "on_close"} in Python). A workflow or step names at most 20, its workflow's and its own together. Named twice, a window pauses if either says so.
  • A step names windows, never blackouts: every blackout holds each gated step already. A version that names one is refused with 409: freeze is a blackout; blackouts hold every gated step, so a step names windows only.
  • "Starts" means the platform lets the step begin: a held step.run doesn't call its function, and a held step.exec or step.activity job isn't given to a runner. A step already running when a window closes or a blackout begins is never stopped. How soon a runner's process starts after that is the runner's.
  • In a keyed workflow, time spent waiting for a window counts toward runLifetimeHours, and no continueWith carries it on: make sure the window opens well within it.
  • Undo steps and a cancel's cleanup always run, so a rollback is never held by a window.
  • A step needs no window unless its workflow or the step names one. A workflow with none runs as before.

When a window closes

Each window a run needs says what happens once it closes. onClose: "pause", the default, holds the run's next gated step until the window opens again. "continue" lets a run the window let in go on: its later steps that need the window start after the close too, on the opening that let it in. A blackout holds the run either way.

The run's timeline says which happened, at the step it happened. A run let in at 06:59 UTC on 2026-11-15, whose drain reaches its gate at 07:01, after sat-maint closed at 07:00, reads pausing for sat-maint (pause) at step.exec "drain": closed after the run went through it, until 2026-11-22 03:00 UTC. Had its workflow named { name: "sat-maint", onClose: "continue" }, it would read continuing at step.exec "drain": sat-maint (continue) closed at 2026-11-15 07:00 UTC, in its 2026-11-15 03:00 UTC opening.

A waiting run

A run held at a gate is waiting, and its page shows Waiting for window, the window, the blackouts holding it and when it next opens. At the opening the platform wakes the run, and the held step starts.

  • waiting_for in GET /v1/runs/:id is { kind: "window", name, since, until, reason, blackouts, gate, revision }. name lists the windows the step needs, and until is when the step can start, by the rule below, as its gate last worked it out: null while no such time is found yet. reason is closed, blackout, no-opening or unreadable.
  • A read of one run, GET /v1/runs/:id and its status, also gives each window wait blocking, closed and opens, worked out at the read: the blackouts holding the step now, one that began since the step last checked included, then the windows an override of them would leave it waiting for, and when they next open (null while no opening is found). closed is null when the platform can't tell, and blocking is then empty: for a window that's gone, or while a definition the step needs can't be read, such as after a rollback, which unreadable names. Such a definition holds the step, and no override starts it. Once it can be read, the gate checks again within 15 minutes and applies it as usual. You can cancel the run.
  • GET /v1/runs/:id/status lists the run's waits, so two steps held at once show as two waits, each with its own gate.
  • The timeline shows each wait as it begins and as it ends. A run started at 00:55 UTC on 2026-11-15, before sat-maint opens, reads waiting for sat-maint (pause) at workflow entry: closed, until 2026-11-15 03:00 UTC, then waited 2 h 5 min for sat-maint at workflow entry: the window opened. A step's wait names the step instead, such as at step.exec "drain".
  • A held step starts when its gate passes: every blackout holding it has ended or been overridden, and each of its windows is open, except a window whose continue opening already let the run in, which no longer holds it. until is the first such moment.
  • So a blackout that ends inside the window's opening lets the step start then, and one that ends after the window closed holds it to the window's next opening. Had a blackout freeze held from 03:30 to 05:00 UTC on 2026-11-15, inside sat-maint's opening, a run started at 04:00 would read waiting for sat-maint (pause) at workflow entry: blackout freeze holds it, until 2026-11-15 05:00 UTC, then at 05:00 waited 1 h 0 min for sat-maint at workflow entry: the blackout ended. A run started at 04:00 UTC on 2027-01-03, in sat-maint's opening but inside q4-close, reads waiting for sat-maint (pause) at workflow entry: blackout q4-close holds it, until 2027-01-10 03:00 UTC, as sat-maint is closed when q4-close ends on 2027-01-04.
  • Under continue, a blackout that ends after the window closed lets the step start then. Had a blackout late held from 06:30 to 08:00 UTC on 2026-11-15, a run let in at 06:00 whose drain reaches its gate at 06:45 reads waiting for sat-maint (pause) at step.exec "drain": blackout late holds it, until 2026-11-22 03:00 UTC. Had its workflow named { name: "sat-maint", onClose: "continue" }, it would read waiting for sat-maint (continue) at step.exec "drain": blackout late holds it, until 2026-11-15 08:00 UTC, then at 08:00 waited 1 h 15 min for sat-maint at step.exec "drain": the blackout ended and continuing at step.exec "drain": sat-maint (continue) closed at 2026-11-15 07:00 UTC, in its 2026-11-15 03:00 UTC opening.
  • A run that ends while it waits ends its wait then: the run ended (cancelled).

Blackouts

A blackout wins over every window: while it is in effect, no step that needs a window starts, whether its windows are open or say continue. Steps that need no window aren't held. An admin can let one held step through with an override.

Override a blackout

An admin can let a held step past the blackouts holding it, with a note that says why: it starts inside them once its windows are open. The dashboard's Override blackout, on the run's page, and shiftlabs runs override override every blackout holding each of the run's steps, one request a blackout and step under the one note.

shellterminal
npx shiftlabs runs override <runId> --note "INC-4211: the payment fix can't wait for the freeze to end"
shellcurl
# Admin key. The gate and revision come from the run's status waits, the blackouts from their blocking.
curl -X POST https://api.shiftlabs.org/v1/runs/<runId>/windows/override \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"requestId": "chg-4211", "gate": "<gate>", "revision": 7, "blackouts": ["q4-close"], "note": "INC-4211: the fix cannot wait"}'
  • An override lets that step start once. A later step that needs a window waits again while a blackout holds it.
  • An override never opens a closed window, and lets a step past only the blackouts it names: a step whose window is closed too waits for it, and a blackout that begins later holds it again. The dashboard and shiftlabs runs override say, for each step, whether it starts now or what it still waits for, and when that opens.
  • The step starts once the audit log has the override, with the note, who asked and when. Secrets in the note are redacted first. A blackout changed before then voids it.
  • The note is 1 to 500 characters, and required.
  • Overriding needs window.override, which admins hold. A key with an agent or workflow scope can't override.
  • A request names the gate, the windows' revision and the blackouts holding the step now, as the run's status waits give them in gate, revision and blocking. 409 says why one is refused: stale (the windows changed since: read the waits again), not holding, gate not waiting, run ended, request reused, or definition unreadable with the definitions that can't be read, which hold the step meanwhile. The dashboard and the CLI say which blackout and step was refused and leave the others overridden.
  • requestId makes a request safe to send again: the same id with the same gate and blackouts answers the same override, with created: false, and the same id for another gate is request reused.

Audit log and timeline

  • window_set · window_delete

    A window or blackout of the dashboard's added, changed or removed, with its definition before and after. A release that changes the windows set in code records its changes too.

  • window_wait · window_pause · window_continue · window_wait_end

    A gated step's wait, as the timeline shows it: when it began and why, a pause or continue at a close, and how it ended.

  • window_override

    An override, with who asked, when, the blackouts and the note.

Limits

  • A workspace has at most 200 windows and blackouts, code's and the dashboard's together.
  • A definition is at most 1 KB as JSON.
  • A workflow or step names at most 20 windows.
  • A window's duration is from 1 minute to 7 days.
  • An override's note is 1 to 500 characters.

API

Routes
RouteMethodMinimum role
/v1/windows ?after= and ?limit= (100 a page, up to 200): {revision, windows, nextAfter}, each window with its source, version, definition, active, blackouts, nextStart, nextEnd and searchedUntilGETviewer
/v1/windows/:name the definition, with "version" once it exists; 201 created or 200 changed; 409 for a name set in code or a stale versionPUTadmin
/v1/windows/:name ?version=; {deleted}; 409 while a current workflow version names itDELETEadmin
/v1/runs/:id/windows/override {"requestId", "gate", "revision", "blackouts", "note"}; {override, created}POSTadmin