Skip to content

How the queue decides when a job runs

Agents put one command in front of their heavy commands. From then on every test run, build and end-to-end run follows the same four steps: line, gate, limit, journal.

The path of a job through dotime-queueA job started with dotime-queue run first passes two checks: a check that failed twice on unchanged code is refused with exit 3, and a test or lint check that already passed on this commit is skipped with exit 0. Otherwise it waits in line for one of 2 slots, leaving with exit 75 after 60 minutes. The health gate holds it while CPU, memory, disk or battery are short. It then runs under a limit learned from earlier passed runs and is stopped with exit 124 at that limit. Its wait, run time and result go into the journal, which the checks and the limits of later jobs read.$ dotime-queue run … -- npm testChecksfailed twice? refusepassed already? skipexit 3 refusedexit 0 skippedLinefirst come, first served2 slots by defaultexit 75 after60 min in lineGateCPU, memory, diskand batterywaits whileshort of roomRununder a limit learnedfrom passed runsexit 124 atthe limitJournalwait, run time,result, commitLater jobs read the journal: stamps, failures, run times.
Every job started with dotime-queue run takes this path. A command run directly is not queued.
On this page

The path of a job

Only a command started through the queue is queued. A npm test that an agent runs directly is not held, not limited and not recorded. A single test file, a lint or a typecheck of a few files finishes quickly and does not need the queue.

Shell
dotime-queue run --label "shop-api: unit tests" -- npm test

The text before the colon in the label is the project. Run limits and history are kept per project. The text after it names the task, and from it the queue guesses the kind of job: test, build, lint, deploy, debug or other.

Before the line: refuse or skip

Two checks run before a job joins the line. Both look at the journal and at the code the job runs on.

  • Refuse. When the same check failed twice in a row within 6 hours and neither the commit nor the uncommitted and untracked files changed since, a third run is refused with exit 3. Change the code, or pass --after-fix "<note>".
  • Skip. A test or lint job that already passed on the same clean commit, in the same folder, with the same label, command and code, is not run again. It prints one skipped: line, exits 0, takes no slot and starts nothing. --no-skip runs it anyway.
dotime-queue: skipped: "shop-api: unit tests" already passed on commit 0a1b2c3d (12 min ago); --no-skip runs it anyway

A build, deploy, debug or other job always runs, because its output may be needed.

1. The line

Jobs queue up first come, first served. Only a set number hold a slot at the same time: 2 by default, set with slots in ~/.dotime/config.json. While it waits, run prints its position and what holds it, at each change and again every minute.

dotime-queue: in line: position 2, 3 min waited, wait limit 60 min; no free slot: 2 of 2 taken, by "shop-api: e2e" and "docs-site: build"

A job waits at most 60 minutes, then exits 75. That is not a test failure. --priority puts a person's urgent job at the front; slots and the gate still apply. Keep it out of agent instructions, or every agent puts itself first.

2. The health gate

The first job in line starts only when a slot is free and the computer has room. The gate is checked only before a job starts: a running job is never stopped because the computer got busy.

What the health gate reads
ReadingHolds a job when (default)
LoadThe 1-minute load per core is above 1.0 while the CPU is at least 90% busy now
Free memoryBelow 20%
Free diskBelow 10 GB
BatteryAt or below 15% while on battery

The load average lags: it stays high for up to a minute after heavy work ends. So a high load holds a job only while the CPU is busy right now, measured from two readings of the CPU times. A value that cannot be read, such as the battery of a desktop, never holds a job.

dotime-queue: in line: position 1, 0 min waited, wait limit 60 min; disk too low: 7.4 GB free, 10 GB needed

3. The run limit

Every job runs under a time limit. Without --max-run, the journal decides it, from passed runs of the same project in the last 14 days:

  • with at least 5 passed runs of the same command: 1.5 times their 90th percentile;
  • otherwise, with 5 passed runs of the same kind: the same formula over those;
  • otherwise: 30 minutes. A measured limit is never below 10 minutes, and a debug job gets 15.

At the limit the job's whole process group gets TERM and, 10 seconds later, KILL, and run exits 124. A job that runs much longer than usual gets one notice first and keeps running.

A long first run. A new command gets the limit its kind has learned in that project, which can be as short as 10 minutes, or 30 minutes until the kind has five passed runs. A command that takes longer is stopped every time, so it never builds a history. Give it --max-run <min>, or raise limits.defaultMin.

4. The journal

Each run leaves one line in ~/.dotime/journal.jsonl: its wait, run time, result, commit and a short hash of the code. Later runs read it for their limits, their pass stamps and the repeated-failure stop, and dotime-queue history sums it up per project.

The journal also flags flaky checks: a check that both passed and failed on the same clean commit gets an advisory flaky: line after a failed run. It changes no exit code. On main, next release

Nested runs

A job may run the queue itself, for example an npm test script that calls dotime-queue run. Such an inner run would wait for a slot its own outer job holds. So run hands each job the variables DOTIME_JOB and DOTIME_PARENT, and a run that finds them is nested: it takes no slot, joins no line and skips the gate.

One job runs at most 2 nested runs at once (nestedPerJob); a further one waits for a place under that job, never for a slot. The variables are trusted only while the job they name is running and is an ancestor of the new run, so they cannot be used to skip the line from outside a job.

What the queue never does

  • It never edits your repository: it runs read-only git commands and reads files to tell whether the code changed.
  • It opens no network connection. Only a DOTIME_NOTIFY_CMD you set can send notices elsewhere.
  • It never stops a running job because the computer got busy, and never queues a command you did not start through it.

Every flag, exit code and setting is in the commands reference and the settings.