deployontime 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +266 -2
- package/SECURITY.md +61 -0
- package/mcp/jobs.mjs +137 -0
- package/mcp/runner.mjs +64 -0
- package/mcp/server.mjs +209 -0
- package/mcp/tools.mjs +380 -0
- package/package.json +48 -4
- package/queue/README.md +885 -0
- package/queue/args.mjs +136 -0
- package/queue/cli.mjs +207 -0
- package/queue/clock.mjs +49 -0
- package/queue/commands.mjs +35 -0
- package/queue/failstop.mjs +45 -0
- package/queue/files.mjs +71 -0
- package/queue/fingerprint.mjs +63 -0
- package/queue/gate.mjs +37 -0
- package/queue/git.mjs +61 -0
- package/queue/health.mjs +154 -0
- package/queue/idle.mjs +63 -0
- package/queue/job-wrapper.mjs +116 -0
- package/queue/journal.mjs +216 -0
- package/queue/kinds.mjs +95 -0
- package/queue/limits.mjs +79 -0
- package/queue/linux.mjs +72 -0
- package/queue/nested.mjs +83 -0
- package/queue/notices.mjs +114 -0
- package/queue/notify.mjs +47 -0
- package/queue/probes.mjs +162 -0
- package/queue/proctree.mjs +124 -0
- package/queue/project.mjs +26 -0
- package/queue/ps.mjs +54 -0
- package/queue/reaper.mjs +278 -0
- package/queue/run.mjs +628 -0
- package/queue/schedule-check.mjs +177 -0
- package/queue/settings.mjs +145 -0
- package/queue/setup.mjs +270 -0
- package/queue/slots.mjs +144 -0
- package/queue/stats.mjs +8 -0
- package/queue/stray.mjs +38 -0
- package/queue/timer.mjs +47 -0
- package/queue/units.mjs +8 -0
package/queue/README.md
ADDED
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
# Machine queue
|
|
2
|
+
|
|
3
|
+
Machine queue is one waiting line for the heavy jobs on a computer that several coding agents use at the same time:
|
|
4
|
+
full test suites, builds, end-to-end runs. Its command is `dotime-queue`. The messages of `run` and its
|
|
5
|
+
warnings start with `dotime-queue:`, and the titles of its notices start with `dotime:`.
|
|
6
|
+
|
|
7
|
+
**Nothing is queued unless you ask.** Only a command started as `dotime-queue run ... -- <command>` (or
|
|
8
|
+
`node queue/cli.mjs run ... -- <command>`) waits in the line, is held by the gate and runs under a time limit. A
|
|
9
|
+
`npm test` that an agent runs directly is not held, not limited and not recorded. A single test file, a lint or a
|
|
10
|
+
typecheck of a few files finishes quickly and does not need the queue.
|
|
11
|
+
|
|
12
|
+
What the queue does for every job started through it:
|
|
13
|
+
|
|
14
|
+
1. **Line.** Jobs queue up first come, first served. Only a set number hold a slot at the same time (2 by
|
|
15
|
+
default).
|
|
16
|
+
2. **Gate.** The first in line starts only when a slot is free and the computer has room: load, free memory, free
|
|
17
|
+
disk, and the battery when the computer runs on it. See [Health gate](#health-gate).
|
|
18
|
+
3. **Limit.** The job runs under a time limit. At the limit, the job and everything it started are stopped.
|
|
19
|
+
4. **Journal.** Each run leaves a record of its wait, its run time and its result. Later runs use that record.
|
|
20
|
+
|
|
21
|
+
**State folder.** The queue keeps its state in one folder: `~/.dotime` by default, or the folder that the
|
|
22
|
+
`DOTIME_HOME` variable names. Callers share one queue only when they use the same folder. A state folder may only
|
|
23
|
+
be used by processes on one computer that see the same process list: the queue decides whether a job is still alive
|
|
24
|
+
by its process id. A container, a virtual machine or a second computer must therefore not point at the same folder;
|
|
25
|
+
it would take the host's jobs for finished, delete their slots and let too many jobs run. Each user account has its
|
|
26
|
+
own `~/.dotime`, and two computers must not share one.
|
|
27
|
+
|
|
28
|
+
**Your repository.** The queue never edits your repository. It runs read-only git commands and reads files to
|
|
29
|
+
tell whether the code changed between runs. The commands you run through it do what they always do. The queue
|
|
30
|
+
opens no network connection; only a `DOTIME_NOTIFY_CMD` that you set can send notices elsewhere.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Requirements: macOS or Linux (servers and desktops, x64 and arm64). Node 22 or newer. git 2.31 or newer. On Linux
|
|
35
|
+
the `ps` of procps, which almost every distribution installs, and a readable `/proc`.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
npm install -g deployontime
|
|
39
|
+
dotime-queue status
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This puts `dotime-queue` and `dotime-mcp` on your path. The package has no dependencies. The first line of
|
|
43
|
+
`dotime-queue status` should read `slots: 0 of 2 taken, 0 waiting`.
|
|
44
|
+
|
|
45
|
+
On Linux the steps are the same. When the install stops with a permission error, your Node was installed for all
|
|
46
|
+
users; run it with a Node from a version manager, or after `npm config set prefix ~/.local` with `~/.local/bin` on
|
|
47
|
+
your path.
|
|
48
|
+
|
|
49
|
+
To work from the source instead, clone `https://github.com/Moezat220/deployontime.git` and run `npm link` in its top
|
|
50
|
+
folder.
|
|
51
|
+
|
|
52
|
+
To tell the agents of a project to use the queue, run [`dotime-queue setup`](#setup) in that project's folder:
|
|
53
|
+
without `--write` it shows what it would add to `AGENTS.md` and `CLAUDE.md`, with `--write` it adds it.
|
|
54
|
+
|
|
55
|
+
From a clone that was not linked, call `node <path to the clone>/queue/cli.mjs` from any folder. The `queue/` folder
|
|
56
|
+
needs nothing outside itself. The examples below use `dotime-queue`.
|
|
57
|
+
|
|
58
|
+
To uninstall:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
npm uninstall -g deployontime
|
|
62
|
+
rm -rf ~/.dotime # or the folder DOTIME_HOME names
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If you scheduled the [reaper](#reaper), also remove it from your scheduler (for cron or a systemd timer, see
|
|
66
|
+
[the end of that section](#scheduling-the-reaper-with-cron)).
|
|
67
|
+
|
|
68
|
+
Agents that use MCP can reach the queue as tools instead of shell commands: `dotime-mcp`, set up as described in
|
|
69
|
+
[Use with an MCP client](../README.md#use-with-an-mcp-client). It runs the same `dotime-queue run` underneath, so
|
|
70
|
+
everything in this manual applies to its jobs too.
|
|
71
|
+
|
|
72
|
+
### What differs on Linux
|
|
73
|
+
|
|
74
|
+
The queue, `run`, `status`, `passed`, `history` and the reaper work the same on Linux. The readings come from
|
|
75
|
+
other places: free memory and swap from `/proc/meminfo`, the battery from `/sys/class/power_supply`, and desktop
|
|
76
|
+
notices go through `notify-send` (see [Health gate](#health-gate) and [Notices](#notices)). A server or desktop
|
|
77
|
+
without a battery has no battery limit. The [scheduled-job report](#scheduled-job-report) reads launchd jobs and
|
|
78
|
+
works on macOS only for now.
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
dotime-queue run --label "shop-api: unit tests" -- npm test
|
|
84
|
+
dotime-queue status
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Worth knowing before the first run:
|
|
88
|
+
|
|
89
|
+
- The text before the colon in the label is the project. Run limits and history are kept per project.
|
|
90
|
+
- A new command gets the limit its kind has learned in that project, which can be as short as 10 minutes, or 30
|
|
91
|
+
minutes until the kind has five passed runs. For a longer one, pass `--max-run <min>`. See [Run limits](#run-limits).
|
|
92
|
+
- A question mark in the task part of the label makes a debug job, stopped after 15 minutes:
|
|
93
|
+
`"shop-api: does login work?"` is one.
|
|
94
|
+
- A job waits in line at most 60 minutes, then exits 75. That is not a test failure.
|
|
95
|
+
- A test or lint check that already passed on the same clean commit, in the same folder, is skipped and exits 0 at
|
|
96
|
+
once. `--no-skip` runs it anyway.
|
|
97
|
+
- Times are printed in UTC unless `DOTIME_TZ` names another zone.
|
|
98
|
+
|
|
99
|
+
## Commands
|
|
100
|
+
|
|
101
|
+
`dotime-queue help` and `dotime-queue --help` print a short usage text and exit 0.
|
|
102
|
+
|
|
103
|
+
### `run`
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
dotime-queue run --label "<project>: <task>" [options] -- <command> [args]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Waits for a slot, runs the command, and exits with the command's exit code. Input and output pass through as
|
|
110
|
+
usual. Stopping a job stops every process it started, because `run` starts the job in a new session with a process group
|
|
111
|
+
of its own. The job therefore has no controlling terminal: a program that opens `/dev/tty`, for example to ask for a
|
|
112
|
+
password, cannot do so.
|
|
113
|
+
|
|
114
|
+
| Option | Effect |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `--label "<project>: <task>"` | Names the job. The text before the colon is its project. Default: `unnamed`. |
|
|
117
|
+
| `--max-wait <min>` | Leave the line after this many minutes, exit 75. `0`: no limit. Default: `maxWaitMin`. |
|
|
118
|
+
| `--max-run <min>` | Run limit for this job. Needed for a new command that runs longer than its kind's learned limit. |
|
|
119
|
+
| `--kind <name>` | Job kind, in place of the guessed one. See [Projects and kinds](#projects-and-kinds). |
|
|
120
|
+
| `--after-fix "<note>"` | Runs a check that would be refused with exit 3. The note is stored in the journal. |
|
|
121
|
+
| `--priority` | Joins the line at the front. Slots and the gate still apply. For a person's urgent run. |
|
|
122
|
+
| `--no-skip` | Runs a `test` or `lint` job that already passed on this commit. See **Checks that already passed** below. |
|
|
123
|
+
|
|
124
|
+
Options go in front of the `--`. Everything behind it is the job's command. Keep `--priority` out of agent
|
|
125
|
+
instructions: an agent that uses it every time puts itself in front of everyone else.
|
|
126
|
+
|
|
127
|
+
An option that is not in this table, an option without its value or with an empty value, an option given twice,
|
|
128
|
+
or any other word in front of the `--` is refused with exit 2, for example `dotime-queue: unknown option --max-runn`.
|
|
129
|
+
A word that starts with `--` is not taken as the value of the option in front of it: `--label --priority` is refused
|
|
130
|
+
because `--label` has no value. Give `--label` a value, or, when the value itself starts with `--`, join it to the
|
|
131
|
+
option with `=`: `--label=--priority`. The refusal message says both, with the value in single quotes when a shell
|
|
132
|
+
would split or change it. The job does not run. The same holds for `status`, `passed` and `history`: each accepts
|
|
133
|
+
only the options shown for it.
|
|
134
|
+
|
|
135
|
+
`run` started in a folder that was removed checks its options first, as above. When they are fine, it says
|
|
136
|
+
`dotime-queue: the current folder was removed; start the job from a folder that exists` and exits 2; nothing is
|
|
137
|
+
journalled.
|
|
138
|
+
|
|
139
|
+
While it waits, `run` prints its position and what holds it, at each change of position and again after each
|
|
140
|
+
minute of waiting.
|
|
141
|
+
|
|
142
|
+
**Ctrl-C.** While the job waits, Ctrl-C or TERM takes it out of the line and `run` exits 130. While the job runs,
|
|
143
|
+
INT, TERM and HUP are passed on to the whole job, and the run is journalled as `stopped`: neither a pass nor a
|
|
144
|
+
failure.
|
|
145
|
+
|
|
146
|
+
Details:
|
|
147
|
+
|
|
148
|
+
- A stop signal that the queue did not send (HUP, INT, KILL or TERM) also makes the run `stopped`, for example when
|
|
149
|
+
the system ends a job because memory ran out. So does exit status 128 plus a stop signal's number, because that
|
|
150
|
+
is how a shell script reports a child it lost to that signal. Stopped runs never count towards
|
|
151
|
+
[Repeated failures](#repeated-failures).
|
|
152
|
+
- Any other signal that ends a job counts as a failure.
|
|
153
|
+
- A job ended by a signal makes `run` exit 1, not 128 plus the signal's number as a shell would. The exceptions are
|
|
154
|
+
SIGUSR1 and signals Node does not die by, such as SIGPIPE: those give 128 plus the number. A script that looks
|
|
155
|
+
for 130 or 143 should look for the `stopped:` line that `run` prints instead.
|
|
156
|
+
- If the `run` process itself dies, the job notices within about 2 seconds (`limits.orphanCheckMs`) and stops.
|
|
157
|
+
- A command that cannot be started at all, for example a misspelled program name, makes `run` print a
|
|
158
|
+
`start failed:` line and exit 127. It is journalled as `could-not-start`, which counts neither as a failure nor
|
|
159
|
+
towards [Repeated failures](#repeated-failures). A command that starts and then exits 127 by itself, such as a
|
|
160
|
+
shell script that calls a missing program, is an ordinary failed run.
|
|
161
|
+
- `run` ends when the job's main process ends. A process the job started in the background and left running does
|
|
162
|
+
not keep `run` waiting.
|
|
163
|
+
|
|
164
|
+
**Checks that already passed.** A `test` or `lint` job that already passed on the same commit, in the same folder,
|
|
165
|
+
with the same files named in its command, is not run again. `run` prints one line, exits 0, takes no slot and starts
|
|
166
|
+
nothing:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
dotime-queue: skipped: "shop-api: unit tests" already passed on commit 0a1b2c3d (12 min ago); --no-skip runs it anyway
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
It skips a job only when all of these hold:
|
|
173
|
+
|
|
174
|
+
- The job's kind is `test` or `lint`, as guessed from the label and command or given with `--kind` (see
|
|
175
|
+
[Projects and kinds](#projects-and-kinds)). A `build`, `deploy`, `debug` or `other` job always runs, because its
|
|
176
|
+
output may be needed. The guess takes the first kind that matches, and `test` comes before `build`, so a job whose
|
|
177
|
+
label or command names both, such as `"shop-api: build and test"` or `sh -c "npm run build && vitest"`, is a `test`
|
|
178
|
+
job. Such a job is still never skipped: when the label's task part or the command also names a build or a deploy,
|
|
179
|
+
`run` runs it. For this, `build`, `bundle`, `compile`, `deploy`, `release` and `publish` count also inside other
|
|
180
|
+
words (`prebuild`, `esbuild`, `deploy_prod.sh`, `deployProd`), and so do `webpack`, `rollup`, `parcel`, `tsc`
|
|
181
|
+
without `--noEmit`, and `vercel` or `netlify` with `--prod`. This errs towards running: a test file named
|
|
182
|
+
`build.test.js` is run each time. Only `--kind test` or `--kind lint`, given on the command line, lets such a job
|
|
183
|
+
be skipped.
|
|
184
|
+
- The folder is a git checkout at a commit, with no uncommitted or untracked changes now.
|
|
185
|
+
- The journal holds a pass stamp for this check, found by the rules of [`passed`](#passed) but only among runs
|
|
186
|
+
started in the same folder, with the same label and the same command line: on this commit, begun with a clean tree,
|
|
187
|
+
and the newest of them exited 0. Stopped and timed-out runs are left out, as `passed` leaves them out. A pass in
|
|
188
|
+
another folder of the same repository, such as another package, never counts.
|
|
189
|
+
- That passing run has the same code fingerprint as the job now (see [Repeated failures](#repeated-failures)). With a
|
|
190
|
+
clean tree, the fingerprint covers the files the command names, so a script outside git that has changed since,
|
|
191
|
+
such as `node ../tools/check.js`, makes the job run. Only a file given as a word of its own counts: not a path
|
|
192
|
+
inside a `sh -c "..."` string or in `--config=../tools/check.ts`, not what is in a folder the command names, and
|
|
193
|
+
not a named file of 4 MB or more.
|
|
194
|
+
- No run of the same check in this folder on this commit failed, hit its run limit or could not start after that
|
|
195
|
+
pass, not even one that began with uncommitted changes.
|
|
196
|
+
|
|
197
|
+
The stamp has no age limit. Other things outside git are not part of the check: files the command reads without
|
|
198
|
+
naming them, installed packages in an ignored folder, tools and the environment. That includes a live target:
|
|
199
|
+
end-to-end or smoke tests against a deployed site are skipped on the same commit even after a redeploy, so give such
|
|
200
|
+
a job `--no-skip` or `--kind other`. After changing any of those, or to run a flaky test again, give `--no-skip`:
|
|
201
|
+
the job then runs, and its result counts like that of any run. A check that is refused because it failed twice is
|
|
202
|
+
refused before this is looked at.
|
|
203
|
+
|
|
204
|
+
A nested run follows the same rules. `--no-skip` on a job also reaches every run nested in it, at any depth: `run`
|
|
205
|
+
hands the job the variable `DOTIME_NO_SKIP=1`, and a nested run that finds it runs as with `--no-skip` and hands it on
|
|
206
|
+
in turn. A job that could not be skipped itself, such as a `build`, `deploy` or `other` job or a `test` job that
|
|
207
|
+
also names a build, gets the variable too, so no step inside it is skipped: a `tsc` or other check that such a job
|
|
208
|
+
runs through the queue may make output the job needs. Only a nested run heeds the variable, and a job gets it only
|
|
209
|
+
from its own `--no-skip`, from its own kind, or from the job it is nested in, never from the shell that started the
|
|
210
|
+
queue.
|
|
211
|
+
|
|
212
|
+
`run` prints nothing when it does not skip. To see why, look at the check's own lines in the journal: `cwd`, `cmd`,
|
|
213
|
+
`head`, `clean`, `fp` and `outcome` show which of the conditions above did not hold.
|
|
214
|
+
|
|
215
|
+
A skipped job is journalled with outcome `skipped`, exit 0, its commit, and the stamp it relied on in `stamp`
|
|
216
|
+
(`head`, `endedAt` and `runMin` of the passing run). A skipped line is never a stamp itself, never a sample for the
|
|
217
|
+
[run limits](#run-limits), and never a pass or an attempt for [Repeated failures](#repeated-failures). `history`
|
|
218
|
+
counts the skipped jobs and the run time they saved, and leaves them out of its wait median and p90.
|
|
219
|
+
|
|
220
|
+
**Nested runs.** A job may run the queue itself, for example an `npm test` script that calls `dotime-queue run`, or
|
|
221
|
+
an agent at work inside a queued job. Such an inner run would wait for a slot that its own outer job holds, and with
|
|
222
|
+
one slot it would never get one. So `run` hands every job it starts the variable `DOTIME_JOB`, which names the slot
|
|
223
|
+
of the outermost job, and the variable `DOTIME_PARENT`, which names the job's direct parent (see below). A `run`
|
|
224
|
+
that finds either is a nested run: it takes no slot, joins no line and does not wait for the
|
|
225
|
+
health gate, because the outer job was already let through. Everything else stays the same: the option checks, the
|
|
226
|
+
refusal of a check that failed twice, a run limit of its own, the handling of INT, TERM and HUP, and a journal line,
|
|
227
|
+
marked `nested: true`, so pass stamps and `history` see it as usual. A nested run says so on a `nested:` line when
|
|
228
|
+
it starts.
|
|
229
|
+
|
|
230
|
+
One job may run at most `nestedPerJob` nested runs at once (default 2). Each running nested run holds one of the
|
|
231
|
+
places of the job it was started in, its parent. A further nested run of the same parent waits for one of those
|
|
232
|
+
places, and only for them: never for a slot and never for the health gate, so it cannot wait for its own outer job.
|
|
233
|
+
Nested runs waiting under the same parent take the places in the order they started. While it waits, a nested run
|
|
234
|
+
prints an `in line for a nested place:` line that names its parent, gives up with exit 75 at the `--max-wait` limit,
|
|
235
|
+
leaves with exit 130 on INT or TERM, and books its waiting time in the journal under `nested`, as a run in line does.
|
|
236
|
+
A waiting nested run checks on every poll that its parent still runs. If the parent has ended, the run is no longer
|
|
237
|
+
inside a job: it prints a `parent gone:` line and joins the line as a normal run, waits for a slot and the health
|
|
238
|
+
gate, and is journalled without `nested`. Its `--max-wait` limit still counts from when it began to wait.
|
|
239
|
+
|
|
240
|
+
This limit is new: nested runs used to start at once, with no limit per job. Now no more than 2 run at once under one
|
|
241
|
+
job unless `nestedPerJob` says otherwise. A job that fans out to many long shards, each a nested run, now runs them 2 at
|
|
242
|
+
a time; the rest wait, and a shard whose wait passes its `--max-wait` limit (`maxWaitMin`, 60 min by default) gives up
|
|
243
|
+
with exit 75. The outer job's own run limit keeps counting while its shards wait, and that limit was learned from runs
|
|
244
|
+
made before this cap, when all shards ran at once. So a job that used to run 3 or more shards side by side now takes
|
|
245
|
+
longer: with 2 at a time, N equal shards take about N/2 times as long (6 shards about 3 times). It can then be stopped
|
|
246
|
+
at its limit (exit 124, its shards with it; twice the limit with `--priority`), which in a short job comes before any
|
|
247
|
+
shard reaches `--max-wait`. Give such a job `--max-run` on the outer run, or raise `nestedPerJob`.
|
|
248
|
+
|
|
249
|
+
Nested runs of one parent that only work when they run at the same time wait the same way: a pipeline such as
|
|
250
|
+
`dotime-queue run … | dotime-queue run …`, or a server and the tests that call it, both started through the queue.
|
|
251
|
+
With more of them than `nestedPerJob`, the ones beyond it wait for a place that none of the others give up, until
|
|
252
|
+
`--max-wait` ends them with 75. For such jobs, raise `nestedPerJob` in `config.json` to the number that must run at
|
|
253
|
+
once, for example `{ "nestedPerJob": 4 }`, or start only one side through the queue.
|
|
254
|
+
|
|
255
|
+
A nested run inside a nested run counts against its own parent, not against the outermost job: each nested run hands
|
|
256
|
+
its job a `DOTIME_PARENT` that names the nested run itself, while `DOTIME_JOB` keeps naming the outer slot at every
|
|
257
|
+
level. So with `nestedPerJob` at 1 several levels of nesting still run, each level in the one place of the level
|
|
258
|
+
above. A run looks at `DOTIME_PARENT` first, and at `DOTIME_JOB` when the first is missing or fails the check below;
|
|
259
|
+
`DOTIME_JOB` is only taken when it names a slot. An older copy of the queue that shares the state folder and reads
|
|
260
|
+
only `DOTIME_JOB` therefore still finds the outer slot at any depth, and runs nested as it did before.
|
|
261
|
+
|
|
262
|
+
Each of the two variables is trusted only while the slot or nested run it names belongs to a job that has started,
|
|
263
|
+
whose file names its start time and process group, and the process holding that slot or running that nested run is
|
|
264
|
+
an ancestor of the new run. A nested run that still waits for a place is not trusted as a parent yet. A copy of the
|
|
265
|
+
variables in another shell, or one left in a program that outlived its job, fails that check, and that run queues as
|
|
266
|
+
usual. The variables therefore cannot be used to skip the line from outside a job.
|
|
267
|
+
|
|
268
|
+
### `status`
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
dotime-queue status
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Prints the taken slots, each running job with its limit and time left, the waiting jobs in start order, and the
|
|
275
|
+
gate. `gate: open` means a job may start now; `gate: shut;` is followed by what holds new jobs back. `dotime-queue`
|
|
276
|
+
with nothing after it prints the same as `status`. A [nested run](#run) is shown indented under the job it runs in,
|
|
277
|
+
and a nested run inside a nested run one step further in; it holds no slot and is not counted as one. A nested run
|
|
278
|
+
that waits for a place under its parent says `waiting for a nested place` and names the parent. Its `min so far`
|
|
279
|
+
counts from when it began to wait, and once it runs, from when it started to run.
|
|
280
|
+
|
|
281
|
+
The gate is judged by the same rules as `run`, so a high load with an idle CPU shows as open. `run` judges on the
|
|
282
|
+
reading it shares with the other waiting jobs; `status` takes a reading of its own each time. When the load is above
|
|
283
|
+
its limit, memory, disk and battery do not already hold a job, and `health.json` holds no usable CPU times up to 5
|
|
284
|
+
seconds old, that reading takes about a second longer, while the CPU is measured. CPU times younger than half a
|
|
285
|
+
second make it wait only for the rest of the half second.
|
|
286
|
+
|
|
287
|
+
`status` only reads the state folder and never changes it. The file of a job that has ended is still left out of
|
|
288
|
+
what it prints, but the file itself stays until a waiting `run` or the reaper removes it.
|
|
289
|
+
|
|
290
|
+
### `passed`
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
dotime-queue passed [--match <text>] [--cwd <dir>]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Answers "did this check already pass on exactly this code?". `run` asks the same for every `test` or `lint` job
|
|
297
|
+
and skips one that already passed (see **Checks that already passed** under [`run`](#run)), so an agent does not need
|
|
298
|
+
to call `passed` first. It still may, for example for a build. `passed` asks a broader question than `run`: it looks
|
|
299
|
+
at every run in the repository, not only at those of one folder, label, command and fingerprint, so it can show a
|
|
300
|
+
stamp for a check that `run` rightly runs again.
|
|
301
|
+
|
|
302
|
+
It works only on a clean, committed tree: the folder must have no uncommitted or untracked changes now, and the run
|
|
303
|
+
it finds must have started with none. With local changes it always prints `no stamp:` and exits 1.
|
|
304
|
+
|
|
305
|
+
It looks at runs started in a repository of the same name, on the commit the folder is at now, that began with a
|
|
306
|
+
clean tree. Runs that were stopped or timed out are left out, since they say nothing about the code, and so are
|
|
307
|
+
jobs that `run` skipped. If the newest of what is left exited 0, it prints a `stamp:` line and exits 0. In every
|
|
308
|
+
other case it prints a `no stamp:` line that says why and exits 1. `--match` keeps only runs whose label or command
|
|
309
|
+
contains the text, in any letter case; without it, the newest run of any check counts. `--cwd` asks about another
|
|
310
|
+
folder. A folder outside git gives
|
|
311
|
+
`no stamp: this folder is not a git checkout`, and a repository whose current branch has no commits yet
|
|
312
|
+
(a new repository) gives `no stamp: the current branch has no commits yet`; both exit 1. Without `--cwd`, in a
|
|
313
|
+
folder that was removed, `passed` says so, points to `--cwd <dir>` and exits 2.
|
|
314
|
+
|
|
315
|
+
Note: an untracked entry named `node_modules` that is not a folder (in practice a link) does not count as a change.
|
|
316
|
+
Git's usual `node_modules/` ignore rule matches folders only, so git lists such a link.
|
|
317
|
+
|
|
318
|
+
### `history`
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
dotime-queue history [--days <n> | --day <YYYY-MM-DD>]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Sums up the journal: one row for all projects and one per project, with outcome counts, waiting time and the gates
|
|
325
|
+
that caused the waiting. Once a row has skipped jobs, its outcome counts end with `skipped N (saved M min)`, where
|
|
326
|
+
M is the run time of the passing runs those jobs relied on. The waiting columns answer three questions. `sum`: how
|
|
327
|
+
much waiting all jobs did together. `clock`: how long the line was not empty. `clock with no job running`: how much
|
|
328
|
+
of that time jobs were waiting while none of this row's jobs ran, for example because the health gate was shut.
|
|
329
|
+
`--days` covers the last n calendar days including today (default 7); `--day` covers one day. Days are counted in
|
|
330
|
+
the `DOTIME_TZ` zone, UTC by default. `--days` takes a whole number of 1 or more and `--day` a date as
|
|
331
|
+
`YYYY-MM-DD`; anything else exits 2. The median and p90 are nearest-rank percentiles, the same ones the run limits
|
|
332
|
+
use.
|
|
333
|
+
|
|
334
|
+
### `setup`
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
dotime-queue setup [--write] [--cwd <dir>] [--mcp]
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Puts the queue instruction into a project's agent instruction files, so the coding agents that work in it start
|
|
341
|
+
their heavy commands through the queue. The project folder is the one `--cwd` names; without it, the top folder of
|
|
342
|
+
the git repository the current folder is in, or the current folder outside git. The first line says which folder
|
|
343
|
+
was used. setup looks there for `AGENTS.md`, `CLAUDE.md` and `.claude/CLAUDE.md`. Each one it finds gets the
|
|
344
|
+
instruction block; when none exists, `AGENTS.md` is created with the block alone.
|
|
345
|
+
|
|
346
|
+
Claude Code does not read `AGENTS.md` when it finds a `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` in the
|
|
347
|
+
folder or above it. `CLAUDE.local.md` is one person's own file, usually kept out of git. When it is the only one of
|
|
348
|
+
those three in the project folder, it gets the block too, beside the `AGENTS.md` that other agents read, and setup
|
|
349
|
+
prints a note that says why; next to a `CLAUDE.md` or `.claude/CLAUDE.md` it is left alone, unless it holds the
|
|
350
|
+
block already. Adding the block there is safer than a warning alone: it is the file Claude Code reads, the change
|
|
351
|
+
sits between the markers, and a dry run shows it first. When no file in the project folder that Claude Code reads
|
|
352
|
+
gets the block and a folder above holds one, setup prints a note that names it and the `@` import line to add;
|
|
353
|
+
it never writes above the project folder.
|
|
354
|
+
|
|
355
|
+
A `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` without the block that imports `AGENTS.md` with an `@`
|
|
356
|
+
line (such as `@AGENTS.md`, or `@../AGENTS.md` in `.claude/CLAUDE.md`) is not given a copy of its own: Claude Code
|
|
357
|
+
reads the block through the import. setup prints `would skip` or `skipped` for it, with the reason. An `@` inside
|
|
358
|
+
a code span or a fenced code block is no import.
|
|
359
|
+
|
|
360
|
+
Without `--write`, setup is a dry run: it prints `would create`, `would add the block to` or `would update the block
|
|
361
|
+
in` for each file, then the block, and changes nothing. With `--write` it makes those changes and prints `created`,
|
|
362
|
+
`added the block to`, `updated the block in` or `unchanged:` for each file, then a `changed:` line that names every
|
|
363
|
+
file it wrote, or `changed: nothing`.
|
|
364
|
+
|
|
365
|
+
The block starts with the line `<!-- dotime-queue setup: begin; ... -->` and ends with
|
|
366
|
+
`<!-- dotime-queue setup: end -->`. A file without the block gets it at the end, after a blank line; a file with it
|
|
367
|
+
gets only the lines from the begin marker to the end marker replaced. Every other byte of the file stays as it was,
|
|
368
|
+
so running setup again changes nothing until the block's text changes in a newer version. A file whose lines end in
|
|
369
|
+
CRLF gets the block in CRLF too. Marker lines inside a fenced code block are an example and do not count; spaces
|
|
370
|
+
after a marker do not matter. A file with a begin marker and no end marker, with two blocks, or with the end
|
|
371
|
+
before the begin, is not changed: fix the markers by hand.
|
|
372
|
+
|
|
373
|
+
setup writes only inside the project folder, and only the files it names. A `CLAUDE.md` that is a link to
|
|
374
|
+
`AGENTS.md` is written once; an agent file that is a link to a file outside the project folder is refused, and so
|
|
375
|
+
is one with a second hard link, since that other name may be outside the project folder. A missing `AGENTS.md`
|
|
376
|
+
is created only when no file or link of that name exists, so a dangling link is never followed. Before
|
|
377
|
+
anything is written, every file to change is checked: when one cannot be read or written (a read-only file, for
|
|
378
|
+
example), setup names it, writes nothing and exits 1. It reads no settings and never touches the state folder.
|
|
379
|
+
|
|
380
|
+
`--mcp` also prints the settings for the [MCP server](../README.md#use-with-an-mcp-client): the generic
|
|
381
|
+
`mcpServers` entry with `"command": "dotime-mcp"`, the command that adds it to Claude Code, and the entry for a
|
|
382
|
+
clone that was not linked, with the full path of its `mcp/server.mjs`. It writes no MCP settings file.
|
|
383
|
+
|
|
384
|
+
setup exits 0 when it is done, also as a dry run, 1 when a file cannot be read or written, and 2 for an unknown
|
|
385
|
+
option, a `--cwd` that is not an existing folder, or, without `--cwd`, a current folder that was removed.
|
|
386
|
+
|
|
387
|
+
## Projects and kinds
|
|
388
|
+
|
|
389
|
+
The project of a job is the label text before the colon. That text may be at most 40 characters: a longer one is
|
|
390
|
+
not taken as a project name, so a sentence with a colon in it does not make a new project. Without a project in the
|
|
391
|
+
label, the project is the name of the git repository the job runs in (a linked worktree counts as its main
|
|
392
|
+
repository), and outside git the name of the folder.
|
|
393
|
+
|
|
394
|
+
The kind groups similar jobs for the run limit. It is read from the label's task part (the text after the project
|
|
395
|
+
prefix) and, only when that matches nothing, from the command. In each, it is the first match in this list, read
|
|
396
|
+
from the top: `deploy tests` is a `deploy` job, and `build tests` is a `test` job.
|
|
397
|
+
|
|
398
|
+
| Kind | Words |
|
|
399
|
+
| --- | --- |
|
|
400
|
+
| `debug` | `debug`, `repro`, `bisect`, `probe`, or a question mark in the label's task part. See below. |
|
|
401
|
+
| `deploy` | `deploy`, `release`, `publish` |
|
|
402
|
+
| `test` | `test`, `tests`, `check`, `suite`, `spec`, `e2e`, `vitest`, `jest`, `playwright`, `node --test` |
|
|
403
|
+
| `build` | `build`, `bundle`, `compile` |
|
|
404
|
+
| `lint` | `lint`, `typecheck`, `tsc`, `format` |
|
|
405
|
+
| `other` | anything else |
|
|
406
|
+
|
|
407
|
+
In the command, a `debug` word followed by `=` does not count, so `DEBUG=1` does not make a debug job.
|
|
408
|
+
|
|
409
|
+
## Run limits
|
|
410
|
+
|
|
411
|
+
Without `--max-run`, the journal decides the limit. Only passed runs count (exit 0), from the job's own project,
|
|
412
|
+
at most `limits.windowDays` (14) days old:
|
|
413
|
+
|
|
414
|
+
- With at least `limits.minSamples` (5) passed runs of the same command: `limits.p90Factor` (1.5) times their 90th
|
|
415
|
+
percentile.
|
|
416
|
+
- Otherwise, with that many passed runs of the same kind: the same formula over those runs.
|
|
417
|
+
- Otherwise: `limits.defaultMin`, 30 minutes.
|
|
418
|
+
|
|
419
|
+
A measured limit is never below `limits.floorMin` (10 minutes). A `debug` job gets `limits.debugMin` (15 minutes)
|
|
420
|
+
instead. Even before it has 5 passed runs, a command's own runs count: when 1.5 times its longest passed run is more
|
|
421
|
+
than the limit above, that becomes the limit. Passed runs under `--max-run` count as history too.
|
|
422
|
+
|
|
423
|
+
**The 30-minute trap.** Until a command, or its kind in that project, has enough passed runs, its limit is
|
|
424
|
+
`limits.defaultMin`, 30 minutes. A command that normally takes longer is stopped at 30 minutes every time. A stopped
|
|
425
|
+
run is not a pass, so it never builds a history and the limit never grows. Two such stops on unchanged code also
|
|
426
|
+
lead to a refusal (see [Repeated failures](#repeated-failures)). The fix: pass `--max-run <min>` to that command, or
|
|
427
|
+
raise `limits.defaultMin` in `config.json`.
|
|
428
|
+
|
|
429
|
+
Two commands count as the same when they have the same stem: the program and its task, without paths, flags and
|
|
430
|
+
variable assignments (`npm run build -- --watch` and `npm run build` share the stem `npm run build`). Labels and
|
|
431
|
+
`--kind` do not split a stem: `npm test -- a.test.js` and `npm test` are both `npm test`. Many quick partial runs
|
|
432
|
+
can pull the learned limit of the full suite down; if that happens, give the full suite `--max-run`.
|
|
433
|
+
|
|
434
|
+
A job that reaches its limit ends `run` with exit 124. Before that, its whole process group receives TERM and,
|
|
435
|
+
`limits.killGraceMs` (10 seconds) later, KILL. With `--priority` the stop moves out to `limits.priorityGrace` (2)
|
|
436
|
+
times the limit, and reaching the limit itself only prints a warning. When the last KILL is refused, for example
|
|
437
|
+
for a process that runs as another user, the job is still there: `run` then prints `timed out: exit 124, stop failed
|
|
438
|
+
after N min, KILL refused for group 48210 (EPERM), pid 48215 (EPERM)` instead of `stopped after N min`, naming the
|
|
439
|
+
group when the signal to the whole group was refused and each process that refused it, and the journal line gets
|
|
440
|
+
`stopFailed` with the same reason. The slot is freed either way, because `run` itself ends.
|
|
441
|
+
|
|
442
|
+
**Long-run notice.** A job that runs much longer than usual gets one notice and keeps running. `run` prints it,
|
|
443
|
+
and it goes out as a [notice](#notices): to `notify.log`, as a desktop notice, and into `notices/`. The mark
|
|
444
|
+
is `limits.longRunFactor` (2) times the 75th percentile of the same runs (at least `limits.floorMin`), or
|
|
445
|
+
`limits.longRunUnmeasuredMin` (20 minutes) when there are fewer than 5 of them. A command with a few passed runs of
|
|
446
|
+
its own raises the mark to 2 times their 75th percentile, when that is more. No notice is sent when the mark is not
|
|
447
|
+
earlier than the stop.
|
|
448
|
+
|
|
449
|
+
## Repeated failures
|
|
450
|
+
|
|
451
|
+
When the same check failed twice in a row within `limits.failWindowHours` (6), and neither the commit nor the
|
|
452
|
+
uncommitted and untracked files have changed since, a third run is refused: `run` prints a `refused:` line and
|
|
453
|
+
exits 3. The way out: change the code, or pass `--after-fix "<note>"` in front of the `--`. A failure is a non-zero
|
|
454
|
+
exit or a stop at the run limit. Runs that were stopped by a signal, and commands that could not be started, do
|
|
455
|
+
not count.
|
|
456
|
+
|
|
457
|
+
Renaming the label does not reset the count. Earlier runs belong to a check when they carry its label, and runs
|
|
458
|
+
under another label still belong when command, project and folder are all identical.
|
|
459
|
+
|
|
460
|
+
What is compared between the failures and the new run:
|
|
461
|
+
|
|
462
|
+
- the command line: a new run of the check with another command is let through, and two failures count as the same
|
|
463
|
+
failure twice only when they ran the same command;
|
|
464
|
+
- the commit;
|
|
465
|
+
- uncommitted changes to tracked files, wherever they are, and the list of changed and untracked paths as
|
|
466
|
+
`git status` prints it;
|
|
467
|
+
- the content of untracked files that git does not ignore, up to 2000 files. A file above 1 MB, or one that would
|
|
468
|
+
take the total past 32 MB, counts by its size and modification time;
|
|
469
|
+
- files the job's command mentions by path: their content, when they are smaller than 4 MB.
|
|
470
|
+
|
|
471
|
+
All of this is hashed on the computer; the journal keeps only a short hash, in the field `fp`.
|
|
472
|
+
|
|
473
|
+
Two groups of untracked files are skipped, because a check rewrites them itself: files inside a folder named in
|
|
474
|
+
`outputDirs`, at any depth, and files ending in `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.avif`, `.ico`, `.bmp`,
|
|
475
|
+
`.mp4`, `.webm`, `.mov`, `.pdf`, `.zip`, `.gz`, `.tgz` or `.log`. Tracked files are never skipped. If your fix
|
|
476
|
+
changes only such untracked files, the code counts as unchanged: pass `--after-fix "<note>"`.
|
|
477
|
+
|
|
478
|
+
## Exit codes
|
|
479
|
+
|
|
480
|
+
| Code | Meaning |
|
|
481
|
+
| --- | --- |
|
|
482
|
+
| the job's own | The job ran and ended by itself. A job ended by a signal gives 1; see [`run`](#run). |
|
|
483
|
+
| 0 | Also a `test` or `lint` job that was skipped because it already passed on this commit; see [`run`](#run). |
|
|
484
|
+
| 2 | The command line was not understood, for example an unknown option or a value that is not a number. Also `run`, and `passed` and `setup` without `--cwd`, from a folder that was removed. |
|
|
485
|
+
| 3 | Refused: the same check failed twice on unchanged code. Change the code or pass `--after-fix "<note>"`. |
|
|
486
|
+
| 75 | Gave up waiting after `--max-wait`. Not a test failure. |
|
|
487
|
+
| 124 | Stopped at the run limit. |
|
|
488
|
+
| 127 | The job's command could not be started. Journalled as `could-not-start`, not as a failure. |
|
|
489
|
+
| 130 | Left the line because of a signal. |
|
|
490
|
+
|
|
491
|
+
`passed` exits 0 with a stamp and 1 without. `setup` exits 1 when an agent file cannot be read or written; see
|
|
492
|
+
[`setup`](#setup).
|
|
493
|
+
|
|
494
|
+
## Message format
|
|
495
|
+
|
|
496
|
+
Every message has the same shape: clauses separated by `; `, each clause a topic, a colon, and facts separated by
|
|
497
|
+
commas. Durations are written as `12 min`, percentages as `20%`, sizes as `40 GB`, clock times on a 24-hour clock
|
|
498
|
+
with the zone name.
|
|
499
|
+
|
|
500
|
+
Sample lines. Each is one line on screen; long lines are wrapped here, and `<date and time>` stands for a value.
|
|
501
|
+
|
|
502
|
+
```
|
|
503
|
+
dotime-queue: in line: position 2, 3 min waited, wait limit 60 min; no free slot: 2 of 2 taken, by "shop-api: e2e"
|
|
504
|
+
and "docs-site: build"
|
|
505
|
+
dotime-queue: in line: position 1, 0 min waited, wait limit 60 min; disk too low: 7.4 GB free, 10 GB needed; hint:
|
|
506
|
+
the job starts once there is more free disk; to start with less, lower health.minFreeDiskGB in
|
|
507
|
+
/home/you/.dotime/config.json
|
|
508
|
+
dotime-queue: gave up: exit 75, position 1, 60 min waited; memory too low: 9% free, 20% needed; hint: --max-wait 0
|
|
509
|
+
waits without limit
|
|
510
|
+
dotime-queue: skipped: "shop-api: unit tests" already passed on commit 0a1b2c3d (12 min ago); --no-skip runs it anyway
|
|
511
|
+
stamp: commit 0a1b2c3d, passed 4 min ago by "shop-api: unit tests", command npm test, run time 2.5 min, tree clean
|
|
512
|
+
at start, finished <date and time> UTC
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Health gate
|
|
516
|
+
|
|
517
|
+
The gate is checked only before a job starts. A running job is never stopped because the computer got busy.
|
|
518
|
+
|
|
519
|
+
| Reading | Taken from | Holds a job when |
|
|
520
|
+
| --- | --- | --- |
|
|
521
|
+
| Load | 1-minute load average per core, and the share of CPU time in use since the last shared reading, when that was half a second to 5 seconds ago, or else over one second. While jobs wait, a new shared reading is taken about every `pollMs`, so the span is about `pollMs` when that is between half a second and about 5 seconds. With a shorter `pollMs` a reading waits until half a second has passed; from about 5 seconds up, the saved CPU times are always too old, and every reading that measures the CPU waits one second. | above `health.loadPerCore` while the CPU is at least `health.busyCpuPct` percent busy |
|
|
522
|
+
| Free memory | on macOS the free percentage that `memory_pressure` reports; on Linux `MemAvailable` as a share of `MemTotal` in `/proc/meminfo` | below `health.minFreeMemPct` |
|
|
523
|
+
| Free disk | the space free for users on the disk that holds `/`, as `df` counts it, read through Node's `statfs` | below `health.minFreeDiskGB` |
|
|
524
|
+
| Battery | `pmset -g batt` on macOS; on Linux the batteries and chargers in `/sys/class/power_supply` (batteries of a mouse, keyboard or phone do not count) | at or below `health.minBatteryPct` while on battery |
|
|
525
|
+
|
|
526
|
+
If the charger cannot keep up and the charge keeps falling, the battery limit applies as if unplugged.
|
|
527
|
+
A computer without a battery of its own, such as a server or a desktop, has no battery limit, and neither has one
|
|
528
|
+
whose battery state cannot be read. On Linux, several batteries count as one, with their mean charge.
|
|
529
|
+
|
|
530
|
+
The 1-minute load average lags: after heavy work ends it stays high for up to a minute while the CPU is already
|
|
531
|
+
idle. So when the load is above its limit, the gate also measures how busy the CPU is right now, from two readings
|
|
532
|
+
of the CPU times, and holds the job only when that share is at or above `health.busyCpuPct`. Each shared reading
|
|
533
|
+
of a waiting job keeps the CPU times it ended on in `health.json`; a `status` reading only reads them. When those
|
|
534
|
+
are between half a second and 5 seconds old, the next reading measures the CPU since then and does not wait; when
|
|
535
|
+
they are younger, it waits for the rest of the half second and then measures since then; when there are none, they
|
|
536
|
+
are older or they make no sense, it takes two readings one second apart. The message then names both numbers, for
|
|
537
|
+
example `load too high: 12.4 now, 8.0 allowed; CPU 96% busy now`. When the load is inside its limit, the CPU is not
|
|
538
|
+
measured and the load never holds a job. The CPU is measured after memory, disk and battery, and not at all when one
|
|
539
|
+
of those already holds the job. When the CPU is not measured or cannot be measured, a load above its limit holds the
|
|
540
|
+
job as the load alone would.
|
|
541
|
+
|
|
542
|
+
When a value cannot be read, such as on a computer with no battery or when a tool does not answer, that check is
|
|
543
|
+
left out and never holds a job, so it protects nothing until it can be read again. A reading of 0, such as a full
|
|
544
|
+
disk, is a real value and does shut the gate.
|
|
545
|
+
|
|
546
|
+
## Reaper
|
|
547
|
+
|
|
548
|
+
```
|
|
549
|
+
node queue/reaper.mjs # one run; schedule it to run every few minutes
|
|
550
|
+
node queue/reaper.mjs --dry # print what a run would do, change nothing
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
The reaper is optional. It runs only if you schedule it, and the queue works without it. It exits 0 after a run,
|
|
554
|
+
also a dry one, and 1 when the run fails. An option other than `--dry`, or `--dry` given twice, is refused with
|
|
555
|
+
exit 2, and then nothing runs, as for an option given twice to `run`.
|
|
556
|
+
|
|
557
|
+
**When it runs, it can stop idle dev servers anywhere on this computer**, also ones you started yourself and not
|
|
558
|
+
through the queue, in any project. It stops nothing else. To protect a server, add a part of its command line to
|
|
559
|
+
`reaper.keepPattern` (see [Settings](#settings)). To see first what it would do, run it with `--dry`.
|
|
560
|
+
|
|
561
|
+
It stops a dev server only when all of these hold:
|
|
562
|
+
|
|
563
|
+
- its command matches `reaper.serverPattern` (by default `vite`, `vitest`, `next dev`, `wrangler dev`,
|
|
564
|
+
`webpack serve`, `webpack-dev-server` and `nodemon`);
|
|
565
|
+
- its process group is older than `idle.serverIdleMin` (30) minutes and used less than `idle.serverCpuS` (10)
|
|
566
|
+
seconds of CPU in that time;
|
|
567
|
+
- its process group holds nothing but the server and its launchers (details below), so nothing else is stopped
|
|
568
|
+
with it;
|
|
569
|
+
- no process in the group holds a slot, runs a one-shot test command, or matches `reaper.keepPattern`, and the group
|
|
570
|
+
is not the reaper's own.
|
|
571
|
+
|
|
572
|
+
It then sends TERM to the group and, `limits.killGraceMs` later, KILL to what is left. When a signal is refused,
|
|
573
|
+
for example for a server that runs as another user, the reaper prints `stop failed: idle dev server ...` with the
|
|
574
|
+
reason, keeps the server under watch, and sends a notice, at most one an hour for the same process group. CPU use
|
|
575
|
+
is compared between reaper runs, so one run by hand only takes a sample: idle servers show up only after runs have
|
|
576
|
+
covered a whole idle window.
|
|
577
|
+
|
|
578
|
+
Each run also:
|
|
579
|
+
|
|
580
|
+
- sends one notice for a job that used less than `idle.slotCpuS` seconds of CPU in `idle.slotIdleMin` minutes while
|
|
581
|
+
holding a slot;
|
|
582
|
+
- reports a large test run that was not started through the queue: 5 or more test processes, or 2 or more that
|
|
583
|
+
together use 2 GB of memory or more. It is left running, with at most one notice an hour;
|
|
584
|
+
- reports an overloaded computer when two runs in a row see it, at most once an hour;
|
|
585
|
+
- reports low disk space, at most every six hours.
|
|
586
|
+
|
|
587
|
+
A test run counts as started through the queue when it descends from a process that holds a slot. A shell that
|
|
588
|
+
starts a test runner with `-c`, such as `bash -c "npx vitest run"`, is only its launcher: it is not counted as a test
|
|
589
|
+
process and is never reported as the run's root. This holds for `sh`, `bash` and `zsh` in any folder: a shell in
|
|
590
|
+
`/opt/homebrew/bin` or `/usr/local/bin` counts as a launcher just like one in `/bin`.
|
|
591
|
+
|
|
592
|
+
What "nothing but the server and its launchers" means: the server, the processes it started, and the processes
|
|
593
|
+
above it that are package-script launchers (`npm`, `npx`, `pnpm`, `yarn`, `bun`, or the script `node` runs for one
|
|
594
|
+
of them, and `sh -c`, `bash -c`, `zsh -c`) or name a dev server themselves. The server is the innermost matching
|
|
595
|
+
process, so a launcher that names the server is never taken for it. An idle server that shares its group with
|
|
596
|
+
another program is reported and left running.
|
|
597
|
+
|
|
598
|
+
### Scheduling the reaper with cron
|
|
599
|
+
|
|
600
|
+
Run `crontab -e` and add these two lines. On macOS:
|
|
601
|
+
|
|
602
|
+
```
|
|
603
|
+
PATH=/usr/bin:/bin:/usr/sbin
|
|
604
|
+
*/5 * * * * /path/to/node /path/to/deployontime/queue/reaper.mjs >> "$HOME/Library/Logs/dotime-reaper.log" 2>&1
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
On Linux:
|
|
608
|
+
|
|
609
|
+
```
|
|
610
|
+
PATH=/usr/bin:/bin
|
|
611
|
+
*/5 * * * * /path/to/node /path/to/deployontime/queue/reaper.mjs >> "$HOME/.local/state/dotime-reaper.log" 2>&1
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Create the log folder first if it does not exist (`mkdir -p ~/.local/state`).
|
|
615
|
+
|
|
616
|
+
Replace `/path/to/node` with what `command -v node` prints, and `/path/to/deployontime` with the folder of the
|
|
617
|
+
package: `$(npm root -g)/deployontime` after `npm install -g`, or your clone. The
|
|
618
|
+
`PATH` line lets the reaper find the system tools it reads (`sysctl` lives in `/usr/sbin`); it applies to every
|
|
619
|
+
line below it in your crontab. If you use `DOTIME_HOME`, add a `DOTIME_HOME=...` line the same way. If the clone
|
|
620
|
+
sits in a folder that macOS protects, such as Documents, cron may be refused access to it; a clone elsewhere in your
|
|
621
|
+
home folder avoids that. Notices always reach `notify.log`, also when no desktop notice shows.
|
|
622
|
+
|
|
623
|
+
To stop it, run `crontab -e` again and delete the reaper line, plus the `PATH` and `DOTIME_HOME` lines if nothing
|
|
624
|
+
else in your crontab needs them.
|
|
625
|
+
|
|
626
|
+
On a Linux computer with systemd, a user timer does the same. Create `~/.config/systemd/user/dotime-reaper.service`:
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
[Unit]
|
|
630
|
+
Description=dotime reaper
|
|
631
|
+
|
|
632
|
+
[Service]
|
|
633
|
+
Type=oneshot
|
|
634
|
+
ExecStart=/path/to/node /path/to/deployontime/queue/reaper.mjs
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
and `~/.config/systemd/user/dotime-reaper.timer`:
|
|
638
|
+
|
|
639
|
+
```
|
|
640
|
+
[Unit]
|
|
641
|
+
Description=dotime reaper every 5 minutes
|
|
642
|
+
|
|
643
|
+
[Timer]
|
|
644
|
+
OnBootSec=5min
|
|
645
|
+
OnUnitActiveSec=5min
|
|
646
|
+
|
|
647
|
+
[Install]
|
|
648
|
+
WantedBy=timers.target
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
Then run `systemctl --user daemon-reload` and `systemctl --user enable --now dotime-reaper.timer`. The reaper's
|
|
652
|
+
lines go to the journal: `journalctl --user --unit dotime-reaper`. For `DOTIME_HOME`, add
|
|
653
|
+
`Environment=DOTIME_HOME=...` under `[Service]`. A user timer runs only while you are logged in, unless
|
|
654
|
+
`loginctl enable-linger` is on for your account. To stop it, run
|
|
655
|
+
`systemctl --user disable --now dotime-reaper.timer` and delete the two files.
|
|
656
|
+
|
|
657
|
+
## Scheduled-job report
|
|
658
|
+
|
|
659
|
+
```
|
|
660
|
+
node queue/schedule-check.mjs [--dry] [--json]
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
An optional extra, separate from the queue: a health report on your own scheduled jobs. It reads every job file in
|
|
664
|
+
`~/Library/LaunchAgents`, not only ones made for this project, and checks each job: loaded, last exit code
|
|
665
|
+
accepted, scripts present, log as recent as the schedule implies. It changes no job; it only adds to its own log
|
|
666
|
+
files in the state folder. Problems go out as one notice; `--dry` only prints. It exits 1 when it cannot read the
|
|
667
|
+
job list from `launchctl`, and 2, without running, for an option other than `--dry` and `--json` or for one of them
|
|
668
|
+
given twice, as for an option given twice to `run`. Optional rules in `$DOTIME_HOME/schedule-check.json`, where
|
|
669
|
+
`skip` leaves jobs out:
|
|
670
|
+
|
|
671
|
+
```json
|
|
672
|
+
{ "skip": ["com.example.*"], "okExit": { "com.example.sync": [0, 2] }, "maxLogAgeH": { "com.example.weekly": 200 } }
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
A rules file that cannot be read, is not valid JSON or is not one JSON object is ignored, and the report runs
|
|
676
|
+
without rules. The warning goes to stderr, to the front of the notice and into the `warnings` field of the line in
|
|
677
|
+
`schedule-check.jsonl`. A missing file simply means no rules.
|
|
678
|
+
|
|
679
|
+
The report works on macOS only for now, because it reads launchd job files and `launchctl`. On Linux it prints
|
|
680
|
+
`schedule-check: works on macOS only for now: ...` to stderr and exits 1 without checking anything, sending a
|
|
681
|
+
notice or writing to its log; an option it does not know is still refused with exit 2 first. Jobs that cron or
|
|
682
|
+
systemd timers start on Linux are not checked.
|
|
683
|
+
|
|
684
|
+
## Notices
|
|
685
|
+
|
|
686
|
+
A notice is always appended to `$DOTIME_HOME/notify.log`. It is also shown as a desktop notice: on macOS through
|
|
687
|
+
`osascript` (if none appear, look at the notification settings in System Settings), on Linux through `notify-send`
|
|
688
|
+
when it is installed and a desktop session is running. A Linux computer without `notify-send`, such as a server,
|
|
689
|
+
keeps the log line and the notify command only. When `DOTIME_NOTIFY_CMD` is set, the notice is also handed to that
|
|
690
|
+
command through `/bin/sh`, with the texts in the environment variables `DOTIME_TITLE` and `DOTIME_MESSAGE`:
|
|
691
|
+
|
|
692
|
+
```
|
|
693
|
+
export DOTIME_NOTIFY_CMD='printf "%s: %s\n" "$DOTIME_TITLE" "$DOTIME_MESSAGE" >> "$HOME/queue-notices.txt"'
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
`DOTIME_NOTIFY=log` keeps only the log line. Long-run and idle-slot notices are also stored in the folder
|
|
697
|
+
`$DOTIME_HOME/notices/`, one JSON file per notice, as a record you can look through. Each job gets at most one of
|
|
698
|
+
each, also when several processes send notices at the same time. Earlier versions kept them all in one file,
|
|
699
|
+
`notices.json`; it is no longer read, and you can delete it.
|
|
700
|
+
|
|
701
|
+
## Settings
|
|
702
|
+
|
|
703
|
+
Settings live in `$DOTIME_HOME/config.json`. The file is optional: create it only to change a default. The queue
|
|
704
|
+
creates the state folder itself the first time it runs.
|
|
705
|
+
|
|
706
|
+
The settings apply to every caller that uses the state folder. That is on purpose: one agent cannot loosen a limit
|
|
707
|
+
for the others. No environment variable changes a setting. A caller can ask for more for one job only, through the
|
|
708
|
+
flags of `run`: `--max-run`, `--priority` and `--after-fix`, described above. `DOTIME_HOME` does not change a setting
|
|
709
|
+
either: it picks a whole other state folder, with its own settings, slots and journal.
|
|
710
|
+
|
|
711
|
+
```json
|
|
712
|
+
{ "slots": 3, "health": { "minFreeDiskGB": 25 }, "idle": { "serverIdleMin": 45 } }
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
A value that does not fit is replaced by its default, with one warning on stderr. A value does not fit when it is:
|
|
716
|
+
|
|
717
|
+
- of the wrong type;
|
|
718
|
+
- a negative number;
|
|
719
|
+
- a number the table rules out. "Above 0": 0 is too low. "At least 1": anything under 1 is too low. "A whole
|
|
720
|
+
number": a fraction does not fit either;
|
|
721
|
+
- a time in milliseconds (a key ending in `Ms`) above 2147483647, about 24 days;
|
|
722
|
+
- a pattern that does not compile.
|
|
723
|
+
|
|
724
|
+
An unknown name is skipped, also with one warning. A `config.json` that is not valid JSON, or that exists but cannot
|
|
725
|
+
be read (no permission, or a folder in its place), is ignored with one warning, and every setting keeps its
|
|
726
|
+
default. Only a missing file is silent.
|
|
727
|
+
|
|
728
|
+
| Key | Default | Meaning |
|
|
729
|
+
| --- | --- | --- |
|
|
730
|
+
| `slots` | 2 | Jobs that may run at once. At least 1; a fraction is rounded down. |
|
|
731
|
+
| `nestedPerJob` | 2 | Nested runs that one job may run at once; a further one waits for a place under that job. A whole number, at least 1. See nested runs under [`run`](#run). |
|
|
732
|
+
| `mcpMaxJobs` | 20 | Jobs started by `dotime-mcp` that may wait or run at once; `queue_run` refuses a further one with a tool error. Each costs two Node processes while it waits. A whole number, at least 1. |
|
|
733
|
+
| `maxWaitMin` | 60 | Default for `--max-wait`. `0`: no limit. |
|
|
734
|
+
| `pollMs` | 3000 | How often a waiting job looks at the line and reads the health. Above 0. |
|
|
735
|
+
| `health.loadPerCore` | 1.0 | Gate shuts above this 1-minute load per core, while the CPU is busy now. Above 0. |
|
|
736
|
+
| `health.busyCpuPct` | 90 | A load above `health.loadPerCore` shuts the gate only while this percent of CPU time, or more, is in use since the last shared reading (half a second to 5 seconds) or over one second. Above 0, at most 100. |
|
|
737
|
+
| `health.minFreeMemPct` | 20 | Gate shuts below this free memory, in percent, as `memory_pressure` reports it on macOS or `/proc/meminfo` gives it on Linux. |
|
|
738
|
+
| `health.minFreeDiskGB` | 10 | Gate shuts below this free disk space. |
|
|
739
|
+
| `health.minBatteryPct` | 15 | Gate shuts at or below this charge while running on battery. |
|
|
740
|
+
| `limits.defaultMin` | 30 | Run limit with fewer than `limits.minSamples` passed runs. Above 0. |
|
|
741
|
+
| `limits.debugMin` | 15 | Run limit of a debug job. Above 0. |
|
|
742
|
+
| `limits.floorMin` | 10 | Lowest measured run limit. Above 0. |
|
|
743
|
+
| `limits.p90Factor` | 1.5 | Run limit as a multiple of the 90th percentile. Above 0. |
|
|
744
|
+
| `limits.longRunFactor` | 2 | Long-run mark as a multiple of the 75th percentile. Above 0. |
|
|
745
|
+
| `limits.longRunUnmeasuredMin` | 20 | Long-run mark with fewer than `limits.minSamples` passed runs. Above 0. |
|
|
746
|
+
| `limits.minSamples` | 5 | Passed runs needed before history sets a limit. At least 1. |
|
|
747
|
+
| `limits.windowDays` | 14 | How far back history is read. Above 0. |
|
|
748
|
+
| `limits.failWindowHours` | 6 | How long two failures stay "in a row". |
|
|
749
|
+
| `limits.priorityGrace` | 2 | A `--priority` job is stopped at this multiple of its limit. At least 1. |
|
|
750
|
+
| `limits.killGraceMs` | 10000 | Time between TERM and KILL. |
|
|
751
|
+
| `limits.orphanCheckMs` | 2000 | How often a job checks that its queue process is alive. Above 0. |
|
|
752
|
+
| `idle.serverIdleMin` | 30 | Idle window for dev servers. Above 0. |
|
|
753
|
+
| `idle.serverCpuS` | 10 | CPU seconds below which a dev server is idle. |
|
|
754
|
+
| `idle.slotIdleMin` | 10 | Idle window for a job in a slot. Above 0. |
|
|
755
|
+
| `idle.slotCpuS` | 5 | CPU seconds below which a job in a slot is idle. |
|
|
756
|
+
| `reaper.overloadPerCore` | 2.0 | Overload above this load per core. Above 0. |
|
|
757
|
+
| `reaper.overloadSwapPct` | 80 | Overload above this swap use. |
|
|
758
|
+
| `reaper.overloadMemPct` | 10 | Overload below this free memory. |
|
|
759
|
+
| `reaper.overloadDiskGB` | 5 | Overload below this free disk space. |
|
|
760
|
+
| `reaper.lowDiskGB` | 20 | Early low-disk notice below this. |
|
|
761
|
+
| `reaper.serverPattern` | see below | Regular expression for dev-server commands. |
|
|
762
|
+
| `reaper.keepPattern` | `/Applications/\|LaunchAgents` | Commands the reaper never stops. See below. |
|
|
763
|
+
| `outputDirs` | see below | Folder names whose untracked files are left out when failed runs are compared. |
|
|
764
|
+
|
|
765
|
+
Default `reaper.serverPattern`: `vite` (but not `vite build`), `vitest`, `next dev`, `wrangler dev`,
|
|
766
|
+
`webpack serve`, `webpack-dev-server` and `nodemon`. A one-shot test run, such as `vitest run`, `vitest --run`,
|
|
767
|
+
`node --test`, `playwright test` or `jest` without `--watch`, is never taken for a dev server.
|
|
768
|
+
|
|
769
|
+
Default `reaper.keepPattern`: the regular expression `/Applications/` or `LaunchAgents`, written as one pattern with
|
|
770
|
+
a `|` between the two. Programs inside `/Applications/` and scripts kept in a `LaunchAgents` folder are never
|
|
771
|
+
stopped. Both are macOS folders, so on Linux the default protects nothing beyond the other rules above; add the
|
|
772
|
+
servers you want kept the same way. To protect your own server too, add a part of its command line, for example
|
|
773
|
+
`{ "reaper": { "keepPattern": "/Applications/|LaunchAgents|docs-site" } }`.
|
|
774
|
+
|
|
775
|
+
Default `outputDirs`: `node_modules`, `dist`, `build`, `out`, `coverage`, `.cache`, `.next`, `.turbo`, `.wrangler`,
|
|
776
|
+
`.vercel`, `test-results`, `playwright-report`.
|
|
777
|
+
|
|
778
|
+
Environment variables:
|
|
779
|
+
|
|
780
|
+
| Variable | Default | Meaning |
|
|
781
|
+
| --- | --- | --- |
|
|
782
|
+
| `DOTIME_HOME` | `~/.dotime` | The state folder. Callers share a queue only when they use the same folder. |
|
|
783
|
+
| `DOTIME_TZ` | `UTC` | Time zone (an IANA zone name) for printed times and for calendar days. |
|
|
784
|
+
| `DOTIME_NOTIFY` | not set | `log`: notices go to the log file only. |
|
|
785
|
+
| `DOTIME_NOTIFY_CMD` | not set | Shell command that receives each notice. |
|
|
786
|
+
| `DOTIME_JOB` | set by `run` | Given to each job; names the slot of the outermost job, also inside nested runs. Not a setting: see nested runs under [`run`](#run). |
|
|
787
|
+
| `DOTIME_PARENT` | set by `run` | Given to each job; names its direct parent: the slot it holds, or for the job of a nested run that run itself. Not a setting: see nested runs under [`run`](#run). |
|
|
788
|
+
| `DOTIME_NO_SKIP` | set by `run` | `1` in a job started with `--no-skip`, in a job that could not be skipped itself (such as a build), and in any job nested in either; the runs nested in it are then never skipped. Not a setting: see **Checks that already passed** under [`run`](#run). |
|
|
789
|
+
|
|
790
|
+
## Files in the state folder
|
|
791
|
+
|
|
792
|
+
| File | Content |
|
|
793
|
+
| --- | --- |
|
|
794
|
+
| `config.json` | Settings. Optional. |
|
|
795
|
+
| `nested/` | One small file per nested run while it waits for a place and while it runs, so `status` can show it under its parent job; it names the slot or nested run, pid and start time of that job, so it never shows under a later job in the same slot. Its name without `.json` is the `DOTIME_PARENT` the run hands its own job, and it names the outer slot the run hands on in `DOTIME_JOB`. Removed by the run when it ends; the file of a run that died goes the same way as one in `slots/`. |
|
|
796
|
+
| `places/` | One small file per place a running nested run holds under its parent job, named after that job's marker and start time and the place number. Claimed and freed the same way as a slot, and the file of a run that died goes the same way as one in `slots/`. |
|
|
797
|
+
| `slots/`, `line/` | One small file per running and per waiting job. The files of ended processes are removed by a `run` that waits in line and by the reaper (not with `--dry`); `status` leaves them. |
|
|
798
|
+
| `journal.jsonl` | One line per job. |
|
|
799
|
+
| `notices/` | Long-run and idle-slot notices, one file each. |
|
|
800
|
+
| `notify.log` | Every notice sent. |
|
|
801
|
+
| `reaper-state.json` | CPU samples between reaper runs. |
|
|
802
|
+
| `health.json` | The last health reading of a waiting job, with the live CPU reading when one was taken, the time the reading ended and the CPU times it ended on. Other waiting jobs reuse the reading for up to `pollMs`, and never once it is 5 seconds old; the next reading measures the CPU from the saved CPU times. A temporary `health.json.tmp-<pid>` that a process left behind when it died while writing is removed by the next saved reading once it is a minute old. |
|
|
803
|
+
| `schedule-check.json`, `schedule-check.jsonl` | Rules and results of the scheduled-job report. |
|
|
804
|
+
| `mcp-jobs/` | The jobs `dotime-mcp` started: per job id the request (`.json`), the runner and queue pids (`.pid`), how the queue process ended (`.exit`) and its output (`.log`). Removed by `dotime-mcp` 7 days after the job started, or sooner beyond 200 finished jobs; a job whose runner is still alive is kept. |
|
|
805
|
+
|
|
806
|
+
A file in `slots/`, `line/`, `nested/` or `places/` is also removed when its pid now belongs to a process that
|
|
807
|
+
started later.
|
|
808
|
+
|
|
809
|
+
Each line of `journal.jsonl` is one JSON object with `v` (the format, now 1), `label`, `project`, `projectKey`,
|
|
810
|
+
`cwd`, `priority`, `queuedAt`, `startedAt`, `endedAt` (times in ISO form), `waitMin`, `runMin`, `outcome`, `exit`,
|
|
811
|
+
`waitBy` (minutes waited per gate), `cmd`, `head` and `clean` (the commit and whether the tree was clean), `kind`,
|
|
812
|
+
`limitMin`, `limitBasis` and `fp` (the hash of the code, used by the repeated-failure stop). Some lines add `stem`,
|
|
813
|
+
`afterFix`, `signal`, `stopFailed`, `stoppedAt`, `longRunAt`, `warnedAt`, `nested` or `stamp` (on a line with
|
|
814
|
+
outcome `skipped`: the passing run it relied on). Lines written by `run` also carry `pid`, the pid of the `run`
|
|
815
|
+
process, so whoever started that process can find its own line. Copies of the queue that share
|
|
816
|
+
a state folder all read the same fields, so a field keeps its name; a new field is only ever added.
|
|
817
|
+
|
|
818
|
+
The journal and the logs are only ever added to; nothing trims them. Delete or move them when they grow too large:
|
|
819
|
+
the queue starts new ones. The run limits, the stamps and the repeated-failure stop then start again from no
|
|
820
|
+
history. For the same reason, on a computer that starts fresh for every job, such as many CI runners, the queue
|
|
821
|
+
never has a history.
|
|
822
|
+
|
|
823
|
+
These files stay on the computer, but they hold working folders, full command lines, job labels and the labels and
|
|
824
|
+
log paths of scheduled jobs. Keep that in mind before sharing them, and when `DOTIME_NOTIFY_CMD` forwards notices to
|
|
825
|
+
another service.
|
|
826
|
+
|
|
827
|
+
## Code layout
|
|
828
|
+
|
|
829
|
+
All code lives in `queue/`, one module per job. An entry point is started as a script; it reads the settings, the
|
|
830
|
+
state folder and the time zone once and hands them to the libraries, which read none of them by themselves. No
|
|
831
|
+
module opens a network connection; only a `DOTIME_NOTIFY_CMD` that you set can.
|
|
832
|
+
|
|
833
|
+
| Module | Purpose | Kind | Side effects it owns |
|
|
834
|
+
| --- | --- | --- | --- |
|
|
835
|
+
| `cli.mjs` | The `dotime-queue` command: reads the command line and runs `status`, `passed`, `history`, `setup` or `run`. | entry point | Prints to stdout and stderr; ends the process, in one place. |
|
|
836
|
+
| `run.mjs` | The `run` command in steps: plan the limit, wait for a slot (or a nested run's place), run the job. | library | Starts the job wrapper, signals the job, handles INT, TERM and HUP; writes through slots, journal and notices. |
|
|
837
|
+
| `job-wrapper.mjs` | Starts the job in a process group of its own and ends the way the job ended. | entry point | Starts the job, signals its own process group, writes to file descriptor 3. |
|
|
838
|
+
| `reaper.mjs` | One reaper run: idle dev servers, stray test runs, idle slots, overload, low disk. | entry point | Stops idle dev-server groups, writes `reaper-state.json`, prunes `slots/`, `line/`, `nested/` and `places/`. |
|
|
839
|
+
| `schedule-check.mjs` | The report on scheduled jobs in `~/Library/LaunchAgents`, macOS only. | entry point | Reads job files, appends to `schedule-check.jsonl`. |
|
|
840
|
+
| `setup.mjs` | The queue instruction block and where `setup` puts it in a project's agent files; the MCP settings it prints. | library | Reads and, with `--write`, writes `AGENTS.md`, `CLAUDE.md`, `.claude/CLAUDE.md` and `CLAUDE.local.md` in the project folder. |
|
|
841
|
+
| `args.mjs` | The flags each command accepts, their values, and the usage text. | library | None. |
|
|
842
|
+
| `settings.mjs` | Defaults, `config.json`, and the file names in the state folder. | library | Reads `config.json` and the `DOTIME_` variables, when an entry point asks. |
|
|
843
|
+
| `slots.mjs` | Slot, waiting-line, nested-run and place files: snapshot, join, take, release, update. | library | Reads and writes `slots/`, `line/`, `nested/` and `places/`; runs `ps` for process ages. |
|
|
844
|
+
| `nested.mjs` | Nested runs: the marker a job is given, the check that a marker is genuine, and the key of a parent's places. | library | Runs `ps` when no listing is given. |
|
|
845
|
+
| `gate.mjs` | Who may take a free slot, what keeps a job out, when a waiting job gives up. | library | None. |
|
|
846
|
+
| `health.mjs` | The health gate: judges a reading, takes one, shares it for up to `pollMs` and at most 5 s. | library | Runs the health probes; reads and writes `health.json` and removes its abandoned temporary files. |
|
|
847
|
+
| `limits.mjs` | Run limits from the journal history. | library | None. |
|
|
848
|
+
| `kinds.mjs` | Job kinds and command stems. | library | None. |
|
|
849
|
+
| `failstop.mjs` | The stop for a check that failed twice on unchanged code. | library | None. |
|
|
850
|
+
| `fingerprint.mjs` | A short hash of the code under test. | library | Runs read-only git commands, reads files in the working tree. |
|
|
851
|
+
| `journal.mjs` | Journal lines, pass stamps and `history` totals. | library | Reads and appends `journal.jsonl`. |
|
|
852
|
+
| `notices.mjs` | Long-run and idle-slot notices and the notices store. | library | Writes `notices/`; runs `ps` for CPU samples. |
|
|
853
|
+
| `notify.mjs` | Sends a notice: log line, desktop notice, `DOTIME_NOTIFY_CMD`. | library | Appends `notify.log`, runs `osascript` or `notify-send` and the notify command. |
|
|
854
|
+
| `idle.mjs` | Idle verdicts from CPU samples; the dev-server test. | library | None. |
|
|
855
|
+
| `stray.mjs` | Finds large test runs outside the queue. | library | None. |
|
|
856
|
+
| `commands.mjs` | The test, shell and launcher command patterns, each with its reason. | library | None. |
|
|
857
|
+
| `git.mjs` | The queue's git calls, read-only and with time limits; the repository's top folder for `setup`. | library | Runs `git`. |
|
|
858
|
+
| `project.mjs` | The project of a job: label prefix, repository name or folder name. | library | Runs `git` through `git.mjs`. |
|
|
859
|
+
| `probes.mjs` | Readings from the operating system, one function each, with a macOS and a Linux branch where they differ. | library | Runs `ps`, on macOS also `memory_pressure`, `sysctl`, `pmset`, `osascript`, `launchctl`, `plutil`, on Linux `notify-send`; reads `/proc/meminfo` and the disk through `statfs`. |
|
|
860
|
+
| `linux.mjs` | Readings Linux keeps in `/proc` and `/sys`, with their parsers. | library | Reads `/proc/meminfo` and `/sys/class/power_supply`. |
|
|
861
|
+
| `ps.mjs` | Parsers for `ps` output. | library | None. |
|
|
862
|
+
| `proctree.mjs` | Process trees: descendants, ancestors, a job's pids and CPU; group signals and stops. | library | Sends signals; runs `ps` when no listing is given. |
|
|
863
|
+
| `files.mjs` | JSON read with warnings, atomic JSON write, removal of abandoned temporary files, append with folder. | library | Reads, writes and removes the files it is handed. |
|
|
864
|
+
| `timer.mjs` | Timers that can be cancelled, also ones longer than one Node timer can hold, and a sleep that can be ended early. | library | Sets and clears timers. |
|
|
865
|
+
| `clock.mjs` | Clock times, days and zone offsets. | library | None. |
|
|
866
|
+
| `stats.mjs` | The percentile that limits and `history` share. | library | None. |
|
|
867
|
+
| `units.mjs` | Time units and rounding. | library | None. |
|
|
868
|
+
| `testkit.mjs` | Test helpers: temp folders, started processes, isolated git and state folder, stored notices, a script started as on another platform. | test helper | Creates and removes temp folders, signals processes the tests started. |
|
|
869
|
+
|
|
870
|
+
## Tests
|
|
871
|
+
|
|
872
|
+
From the repository's top folder:
|
|
873
|
+
|
|
874
|
+
```
|
|
875
|
+
npm test # everything (the same as node --test)
|
|
876
|
+
node --test queue/slots.test.mjs # one file
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
The code has no switch for the tests. A test that needs a made-up health reading, or a clock that jumps ahead, runs
|
|
880
|
+
the steps of `run` inside the test process and hands them stand-ins for the clock, the health reading and the
|
|
881
|
+
signals (see `queue/run.test.mjs`). Every test file gets a state folder of its own inside the temp folder.
|
|
882
|
+
|
|
883
|
+
The tests run on macOS and on Linux, and CI runs them on both. The Linux readers are tested on sample text on any
|
|
884
|
+
computer, and a few tests start a script as if on the other platform. The tests that need launchd and `plutil` are
|
|
885
|
+
skipped on Linux, each with its reason.
|