Concepts

Concepts

Jobs and states

A job is one row in SQLite. It moves through these states.

State Meaning
queued Waiting for a free slot
running Claimed by the daemon and holding a lease
waiting Parked until an event is released. It holds no process and no slot
done Finished with exit code 0
failed Finished with a non-zero exit code, or cancelled
dead Ran out of attempts after its lease expired each time
timed_out Passed its --max-runtime deadline

Caps

A daemon never runs more than COORDINATE_CAP jobs at once, or more than COORDINATE_REPO_CAP jobs with the same repo key. Other jobs wait in the queue. Among queued jobs, a higher --priority goes first, then the older job.

Change the caps while the daemon is running with coordinate cap set --machine-cap N --repo-cap N. The queue database stores both values, and the daemon reads them each time it claims a job. Raising a cap starts queued jobs without a restart. Lowering one lets running jobs finish, and the daemon claims no more until the count drops below the new cap.

Ordering

The daemon claims jobs in priority DESC, run_at, id order. Jobs with the same priority and start time run in submission order. --run-at holds a job until its start time and doesn't raise its priority.

By default, a new priority-9 job runs before a priority-0 job that has waited for hours, so a busy queue can starve low-priority work. To prevent this, set [scheduler] aging = "linear" in config.toml. Aging is off by default. It raises a waiting job's priority by one step per aging_period, up to aging_ceiling.

When a job's repo key or tool slot is full, the daemon skips it and takes the next eligible job in priority order.

Park and wake

--wait-on <event> parks a job, and release <event> puts it back in the queue. A parked job holds no process, so it costs only its row in the database.

A job parked with --wait-on always needs an explicit release. When a job finishes, it wakes only the jobs waiting for its tool: slot keys.

coordinate enqueue --wait-on deploy-ready -- ./smoke-test.sh
coordinate release deploy-ready

Crashes and retries

Queued and parked jobs stay in the database through a crash or reboot.

A running job keeps a lease alive while it works. If the daemon crashes or the machine reboots, that lease expires. The next daemon stops anything left of the old attempt and runs the job again, up to --max-attempts starts. A job with no attempts left becomes dead. A job past its --max-runtime deadline becomes timed_out.

A retry can repeat work from the interrupted attempt. See Handle retries.

A job that exits with a non-zero code becomes failed and isn't retried automatically. dead retry can requeue both failed and dead jobs.

Events

Every state change is added to an event log. events --follow streams it, events --since <id> replays it, and forward --exec <command> runs a command for each event with the event as JSON on stdin.