next-issue 12.5.1 → 12.5.3
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/README.md +4 -4
- package/dist/serve.mjs +2 -1
- package/dist/worker-client.mjs +1 -1
- package/dist/worker-run.mjs +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ flowchart TD
|
|
|
34
34
|
|
|
35
35
|
Before each issue, fetch the open issues again and take the oldest one not yet seen in this run. An issue seen once in a run is not tried again in that run while its labels stay as the first fetch after its attempt found them. When its labels change, for example once a person answers a hand-over or makes a skipped issue ready, the next fetch claims it again in the usual order. An issue that is done, or that failed with an error and was not handed over, is not tried again in that run. The run ends when no unseen issue is left. When the fetch fails, the run claims no new issue, ends once the running issues end, writes the summary of the issues it handled and exits with code 1.
|
|
36
36
|
|
|
37
|
-
`next-issue start` runs the work in the worker of the repository, see [Worker](#worker). It connects to the worker, or starts one in the background (`next-issue serve` of the same version, with its output in `.next-issue/worker.log`) when none answers, and then starts the run there with its flags. It prints the output of the run on standard error and the summary on standard output, and exits with the exit code of the run. When the terminal closes or the command ends some other way, the run keeps going in the worker, and pi and `next-issue logs` still show it. pi shows the run in `/next-issue` and the dashboard, and its Stop, Watch, Hunt and Refresh work on it. When the worker is older than `start` and no run is going, it closes and `start` starts a new one. When a newer client, such as a newer pi, connects while a run of `start` watches, the worker upgrades it between issues like any other run (see [Worker](#worker)): the run stops after its running issues and starts again on the newer worker with watching on and its `--hunt` setting. `start` follows it across the upgrade: it connects to the newer worker, prints `next-issue: the worker was updated from <old> to <new>` once on standard error, goes on printing the output of the run, keeps `Ctrl-C` working (a press while it moves to the newer worker reaches the run there) and exits only when the run ends, with exit code 1 when an issue needed a person or failed before or after the upgrade. Lines that the run prints on the newer worker before `start` connects go only to `.next-issue/worker.log`. When the run does not go on in the newer worker within
|
|
37
|
+
`next-issue start` runs the work in the worker of the repository, see [Worker](#worker). It connects to the worker, or starts one in the background (`next-issue serve` of the same version, with its output in `.next-issue/worker.log`) when none answers, and then starts the run there with its flags. It prints the output of the run on standard error and the summary on standard output, and exits with the exit code of the run. When the terminal closes or the command ends some other way, the run keeps going in the worker, and pi and `next-issue logs` still show it. pi shows the run in `/next-issue` and the dashboard, and its Stop, Watch, Hunt and Refresh work on it. When the worker is older than `start` and no run is going, it closes and `start` starts a new one. When a newer client, such as a newer pi, connects while a run of `start` watches, the worker upgrades it between issues like any other run (see [Worker](#worker)): the run stops after its running issues and starts again on the newer worker with watching on and its `--hunt` setting. `start` follows it across the upgrade: it connects to the newer worker, prints `next-issue: the worker was updated from <old> to <new>` once on standard error, goes on printing the output of the run, keeps `Ctrl-C` working (a press while it moves to the newer worker reaches the run there) and exits only when the run ends, with exit code 1 when an issue needed a person or failed before or after the upgrade. Lines that the run prints on the newer worker before `start` connects go only to `.next-issue/worker.log`. When the run does not go on in the newer worker within 2 minutes, `start` fails with `the worker closed the connection, and the run did not go on in the newer worker` and exits with 1. A run that does not watch is not upgraded: the worker upgrades once it ends. `start` tells the worker its version each time it connects, as pi does. When a run is going in the worker already, `start` exits with code 1 and the error `a run is going in this repository already`. When that worker is older, the error adds `; the worker updates to <version> after the running issues`: a watching run stops after its running issues and starts again on the newer worker, as for pi; a run that does not watch is upgraded once it ends. `start` ignores `--force`, as before.
|
|
38
38
|
|
|
39
39
|
Only one worker goes at a time in a repository. It holds the lock `.next-issue/worker.lock`, with the process id and the start time of that process, for its whole life. A run that the worker starts takes no lock of its own, since the worker runs at most one run at a time. When a process that does not take connections on the worker socket holds the lock for more than 2 seconds, `start` starts a worker anyway, which exits with `another worker is running`, so `start` claims no issue and exits with code 1 and the error `the next-issue worker exited before it listened: exit code 1 (see .next-issue/worker.log)`. A lock whose process is gone, or started at another time, is stale and taken over.
|
|
40
40
|
|
|
@@ -366,12 +366,12 @@ In a run of the `serve` worker, a client can switch hunting and watching on or o
|
|
|
366
366
|
- sends every client a `questions` message for each repository: the open issues with the `needsHuman` label, each with its number, title, the reason of the hand-over, the url of the comment that holds it, the `owner/name` repository, and the `needsHuman`, `skip` and `ready` labels. It reads them from GitHub, so the list is the same after a restart. It sends them when a client connects, for its repository, after each issue of a run ends, and when a client sends `{ "type": "questions", "root": "<path>" }`. An issue that no longer has the label leaves the list, and so does an issue whose hand-over has an answer from a writer, the same answer that lets a run claim it. An issue that a person holds with the label stays in the list, even when an earlier hand-over has an answer. An issue with the label but no hand-over comment is in the list with an empty reason and url. The issues are read one at a time. A client never gets an older list after a newer one. When the client adds an `"id"` to its message, the list that answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets `{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
|
|
367
367
|
- answers `{ "type": "upcoming", "root": "<path>" }` with `{ "type": "upcoming", "root": "<path>", "claimable": [...], "blocked": [...] }`: the open issues with the `ready` label that a run would claim, oldest first, each with its `issue` number and `title`, without issues that have saved state or a label that stops a claim. An issue blocked by open issues is in `blocked` with their references in `blockers`. When the list cannot be read, the client gets `{ "type": "upcoming-error", "root": "<path>", "message": "<text>" }`;
|
|
368
368
|
- stops a run when a client sends `{ "type": "stop", "root": "<path>", "after": "issue" | "round" | "now" }`. With no `after`, it stops after `issue`. `issue` works like a first `Ctrl-C`: no new claim or hunt, and the held issues and a going hunt finish. `round` works like a second `Ctrl-C`: each running issue stops after its current round, with the state kept, and a going hunt ends first. `now` stops every agent, command and hunt of the run at once, and each running issue ends as `stopped` with its state and labels kept; the worker keeps running. A later point than one already asked for changes nothing, and an earlier one replaces it. An unknown `after` gets an `error` message. While a run is going, the client that sent the stop gets `{ "type": "stopping", "root": "<path>", "waiting": <bool>, "hunting": <bool> }`, with the `id` of the stop when it has one: `waiting` is `true` when the run waited between passes, and `hunting` is `true` when a hunt was going then. `next-issue start` picks its note from it;
|
|
369
|
-
- switches watching of a run on or off when a client sends `{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. A run starts with watching on, unless it was started with `--watch off`. On keeps the run going after the current pass, as with `--watch on`. Off ends the run after the current pass, or at once when it waits between passes, and also turns hunting off. With no run going, the message gets an `error` and starts nothing;
|
|
370
|
-
- switches hunting of a run on or off when a client sends `{ "type": "hunt", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. Every run of the worker has a hunter: a run started with `--hunt on` starts with hunting on, and any other run with it off. Off lets a hunt that is going finish, so the issues it files stay, and starts no new hunt. On wakes the hunter at once, with no back-off wait, and also turns watching on. With no run going, the message gets an `error` and starts nothing. The settings last for the run only: a new run takes them from its own flags. The progress of each run carries `hunting`, `true` while hunting is on, and `watching`, `true` when the run watches for issues;
|
|
369
|
+
- switches watching of a run on or off when a client sends `{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. A run starts with watching on, unless it was started with `--watch off`. On keeps the run going after the current pass, as with `--watch on`. On for a run that a person asked to stop gets an `error` (`the run is stopping`, with the `id` of the request) and changes nothing; on for a run that stops for an upgrade keeps the upgrade, so the run is still resumed. Off ends the run after the current pass, or at once when it waits between passes, and also turns hunting off. With no run going, the message gets an `error` and starts nothing;
|
|
370
|
+
- switches hunting of a run on or off when a client sends `{ "type": "hunt", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. Every run of the worker has a hunter: a run started with `--hunt on` starts with hunting on, and any other run with it off. Off lets a hunt that is going finish, so the issues it files stay, and starts no new hunt. On wakes the hunter at once, with no back-off wait, and also turns watching on. On for a run that a person asked to stop gets the same `error` as watch on. With no run going, the message gets an `error` and starts nothing. The settings last for the run only: a new run takes them from its own flags. The progress of each run carries `hunting`, `true` while hunting is on, and `watching`, `true` when the run watches for issues;
|
|
371
371
|
- asks a watching run to check for new issues now when a client sends `{ "type": "refresh", "root": "<path>" }`. A run that waits between passes starts a new pass at once, and its next wait starts again at 1 minute; a refresh during the last read of the open issues of a pass, or while the pass ends, also starts a new pass at once; a waiting hunter checks the ready count again. While a pass runs, the run reads the open issues again, so its open-issue count is current, and claims a new issue only when a slot is free. A refresh for a run that is stopping or does not watch, or with no run going, changes nothing and gets no answer;
|
|
372
372
|
- exits, and removes its socket and lock files, when no run is going and no client is connected, or when no client connects in the 30 seconds after it starts;
|
|
373
373
|
- waits up to 5 seconds for the lock when a worker that is closing still holds it;
|
|
374
|
-
- closes once no run is going when a client with a newer version connects, so that the client can start the newer worker. The `hello` of a client can say how to start the worker of its version, as `"launch": { "command": "<command>", "args": ["<arg>", ...] }`: pi sends `npx -y next-issue@<version> serve`, and `next-issue start` its own `node <script> serve`. A run that watches is stopped between issues for that, as `stop` with `issue` does: it claims nothing new, and its running issues and its current hunt finish. Its progress then holds `"upgrade": { "from": "<worker version>", "to": "<client version>" }`, with `"resumes": true` when the first newer client gave a `launch`. A stop by a person, or turning watching off, drops that field, so the run does not start again. With `resumes`, once the run ends, the worker stops listening, runs that command in the repository with its output in `.next-issue/worker.log` (or uses a worker that already listens there), and asks the newer worker to start the run again with `--watch on` and the same `--hunt` setting, before it closes. This works with no client connected. When the newer worker does not start or does not start the run, the worker writes the reason to `.next-issue/worker.log`, and its clients see the run `failed` with an `error` that starts with `the worker could not start next-issue <version>`. Without `resumes`, a client starts the newer worker and the run again. A run that does not watch is left alone; a run that `next-issue start` started is not, and `start` follows it to the newer worker. Meanwhile the worker refuses every start with `the worker is restarting, try again soon`. A `start` with `"resume": true` gets no error when the worker refuses it;
|
|
374
|
+
- closes once no run is going when a client with a newer version connects, so that the client can start the newer worker. The `hello` of a client can say how to start the worker of its version, as `"launch": { "command": "<command>", "args": ["<arg>", ...] }`: pi sends `npx -y next-issue@<version> serve`, and `next-issue start` its own `node <script> serve`. A run that watches is stopped between issues for that, as `stop` with `issue` does: it claims nothing new, and its running issues and its current hunt finish. Its progress then holds `"upgrade": { "from": "<worker version>", "to": "<client version>" }`, with `"resumes": true` when the first newer client gave a `launch`. A stop by a person, or turning watching off, drops that field, so the run does not start again. With `resumes`, once the run ends, the worker stops listening, runs that command in the repository with its output in `.next-issue/worker.log` (or uses a worker that already listens there), waits up to 2 minutes for it to listen, as pi does, since `npx` may first download it, and asks the newer worker to start the run again with `--watch on` and the same `--hunt` setting, before it closes. This works with no client connected. When the newer worker does not start or does not start the run, the worker writes the reason to `.next-issue/worker.log`, and its clients see the run `failed` with an `error` that starts with `the worker could not start next-issue <version>`. Without `resumes`, a client starts the newer worker and the run again. A run that does not watch is left alone; a run that `next-issue start` started is not, and `start` follows it to the newer worker. Meanwhile the worker refuses every start with `the worker is restarting, try again soon`. A `start` with `"resume": true` gets no error when the worker refuses it;
|
|
375
375
|
- stops every agent and command and exits on `SIGTERM`, `SIGHUP` or `SIGINT`, and removes its socket and lock files;
|
|
376
376
|
- keeps `.next-issue/worker.log`, where the extension writes the output of the worker, within 10 MiB: when it starts and once a minute while it runs, it cuts a log of more than 10 MiB to its newest 5 MiB, from the start of a line. It skips the cut while a command that writes to the log runs. The run logs under `.next-issue/runs/` hold the same events.
|
|
377
377
|
|
package/dist/serve.mjs
CHANGED
|
@@ -145,6 +145,7 @@ export async function startWorker(options) {
|
|
|
145
145
|
}
|
|
146
146
|
const run = runs.get(root);
|
|
147
147
|
if (run !== undefined && active(run)) {
|
|
148
|
+
run.stoppedByPerson = true;
|
|
148
149
|
send(socket, stoppingMessage(root, run, id));
|
|
149
150
|
}
|
|
150
151
|
const dropped = dropUpgrade(run);
|
|
@@ -154,7 +155,7 @@ export async function startWorker(options) {
|
|
|
154
155
|
};
|
|
155
156
|
const toggle = (refuse, root, on, set) => {
|
|
156
157
|
const run = runs.get(root);
|
|
157
|
-
const refusal = switchRefusal(run);
|
|
158
|
+
const refusal = switchRefusal(run, on);
|
|
158
159
|
if (refusal !== undefined) {
|
|
159
160
|
refuse(refusal);
|
|
160
161
|
return;
|
package/dist/worker-client.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { lockHolder } from './lock.mjs';
|
|
|
8
8
|
import { isNewer, } from './protocol.mjs';
|
|
9
9
|
import { checkSocketPath, workerPaths } from './worker-paths.mjs';
|
|
10
10
|
const ANSWER_TIMEOUT_MS = 5_000;
|
|
11
|
-
const START_TIMEOUT_MS =
|
|
11
|
+
const START_TIMEOUT_MS = 120_000;
|
|
12
12
|
const HOLDER_GRACE_MS = 2_000;
|
|
13
13
|
const POLL_MS = 200;
|
|
14
14
|
const UPGRADE_TRIES = 3;
|
package/dist/worker-run.mjs
CHANGED
|
@@ -69,9 +69,13 @@ export function stoppingMessage(root, run, id) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
export function requestUpgrade(run, upgrade) {
|
|
72
|
-
if (!run
|
|
72
|
+
if (!active(run) ||
|
|
73
|
+
!run.watching.on() ||
|
|
74
|
+
run.stoppedByPerson === true ||
|
|
75
|
+
run.progress.upgrade !== undefined) {
|
|
73
76
|
return false;
|
|
74
77
|
}
|
|
78
|
+
requestStop(run, 'issue');
|
|
75
79
|
run.progress = { ...run.progress, upgrade };
|
|
76
80
|
return true;
|
|
77
81
|
}
|
|
@@ -82,8 +86,11 @@ export function dropUpgrade(run) {
|
|
|
82
86
|
run.progress = { ...run.progress, upgrade: undefined };
|
|
83
87
|
return true;
|
|
84
88
|
}
|
|
85
|
-
export function switchRefusal(run) {
|
|
86
|
-
|
|
89
|
+
export function switchRefusal(run, on) {
|
|
90
|
+
if (!active(run)) {
|
|
91
|
+
return 'no run is going in this repository';
|
|
92
|
+
}
|
|
93
|
+
return on && run.stoppedByPerson === true ? 'the run is stopping' : undefined;
|
|
87
94
|
}
|
|
88
95
|
// Only a running watch run refreshes: it wakes the wait between passes, or reads the open issues again during a pass.
|
|
89
96
|
export function requestRefresh(run) {
|