next-issue 9.8.3 → 9.9.0
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 +3 -3
- package/dist/loop.mjs +26 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,13 +32,13 @@ flowchart TD
|
|
|
32
32
|
|
|
33
33
|
## What it does
|
|
34
34
|
|
|
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,
|
|
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
37
|
Only one worker or command-line run goes at a time in a repository. Both hold one lock, `.next-issue/worker.lock`, with the process id and the start time of that process: the worker for its whole life, and a command-line run from its start to its end. A run that the worker starts takes no lock of its own, since the worker runs at most one run at a time. A command-line run that starts while any worker is alive, busy or idle, or while another command-line run is going, claims no issue and exits with code 1 and the error `another next-issue worker or run (process id <n>) is going in this repository`. Run `next-issue stop` first to stop the worker. A lock whose process is gone, or started at another time, is stale and taken over.
|
|
38
38
|
|
|
39
39
|
Every command uses the main worktree of the repository as its root, the first one that `git worktree list` shows, even when it runs in a linked worktree. So `.next-issue/`, with the config, the locks, the worker socket, the saved state and the notes, and `.worktrees/` are always in the main worktree, and a run or worker started from a linked worktree gets the same refusal as one started from the main worktree.
|
|
40
40
|
|
|
41
|
-
A run handles up to `concurrency` issues at the same time, 1 by default. When an issue ends, the run fetches the open issues again and claims the oldest unseen one for the free slot. Each issue has its own worktree and branch. Step 3 below and the removal of a worktree or branch run for one issue at a time, so two issues never change the git refs or worktrees of the repository at once. An issue blocked by a running issue is skipped and not tried again in that run, even when the blocker closes before the run ends. `--max <n>` counts the handled issues across the run, so with `--max 1` the run handles one issue. For each issue:
|
|
41
|
+
A run handles up to `concurrency` issues at the same time, 1 by default. When an issue ends, the run fetches the open issues again and claims the oldest unseen one for the free slot. Each issue has its own worktree and branch. Step 3 below and the removal of a worktree or branch run for one issue at a time, so two issues never change the git refs or worktrees of the repository at once. An issue blocked by a running issue is skipped and not tried again in that run, even when the blocker closes before the run ends, unless its labels change. `--max <n>` counts the handled issues across the run, so with `--max 1` the run handles one issue. For each issue:
|
|
42
42
|
|
|
43
43
|
1. Claim the issue only when it holds the `status:todo` label and holds no `status:in-progress` or `status:in-review` label. A `status:done`, `status:needs-human` or `status:blocked` label always stops the claim, a resume too, except a `status:needs-human` issue with an answer to its hand-over that the run made, and except an issue whose finish a stop cut short and that was not handed over (see step 7 below). An issue that GitHub lists as blocked by an open issue waits, because its blocker closes only when the change of the blocker lands. An issue with saved state under `.next-issue/` resumes instead, whatever its other labels and blockers.
|
|
44
44
|
2. Add `status:in-progress` to the issue.
|
|
@@ -318,7 +318,7 @@ Versions before 7.0.0 started a run with no command, as `next-issue` or `next-is
|
|
|
318
318
|
|
|
319
319
|
## Watch for new issues
|
|
320
320
|
|
|
321
|
-
A run without `--watch` ends when no unseen issue is left. With `next-issue start --watch`, the harness then waits, reads the open issues again and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker closes. Each pass tries every open issue again, also one that an earlier pass skipped. An issue that failed with an error before the claim is not tried again until the next run. An issue that failed after the claim and was handed over with the needs-human label is tried again
|
|
321
|
+
A run without `--watch` ends when no unseen issue is left. With `next-issue start --watch`, the harness then waits, reads the open issues again and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker closes. Each pass tries every open issue again, also one that an earlier pass skipped. An issue that failed with an error before the claim is not tried again until the next run. An issue that failed after the claim and was handed over with the needs-human label is tried again once a person answers the hand-over or takes the label off. Within a pass, the harness claims a tried issue again at the next read when its labels differ from those it had after its attempt, so an answered hand-over or an unblocked skipped issue does not wait for the next pass. An issue that is done, or that failed with an error and was not handed over, does not come back in the same pass. The hunter counts the same issues as ready.
|
|
322
322
|
|
|
323
323
|
The waits follow a fixed back-off in minutes: 1, 2, 3, 5, 10, then 10 from then on. A pass that handles an issue, with any outcome other than `skipped`, resets the back-off to 1 minute. A pass where every issue is skipped does not reset it. Each wait prints a line on standard error with the minutes until the next pass.
|
|
324
324
|
|
package/dist/loop.mjs
CHANGED
|
@@ -7,11 +7,12 @@ export async function runIssues(args, loop, seen = new Set()) {
|
|
|
7
7
|
let error;
|
|
8
8
|
let crash;
|
|
9
9
|
let claiming = true;
|
|
10
|
+
const tried = { ended: new Set(), labels: new Map() };
|
|
10
11
|
const room = () => running.size < concurrency && (limit === undefined || handled(reports) + running.size < limit);
|
|
11
12
|
for (;;) {
|
|
12
13
|
if (claiming && room()) {
|
|
13
14
|
try {
|
|
14
|
-
claiming = await claimIssues(loop, seen, running, room);
|
|
15
|
+
claiming = await claimIssues(loop, seen, tried, running, room);
|
|
15
16
|
}
|
|
16
17
|
catch (failure) {
|
|
17
18
|
error = failure;
|
|
@@ -29,6 +30,9 @@ export async function runIssues(args, loop, seen = new Set()) {
|
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
reports.push(report);
|
|
33
|
+
if (retryable(report)) {
|
|
34
|
+
tried.ended.add(issue);
|
|
35
|
+
}
|
|
32
36
|
if (claiming && (loop.stop() || report.halt === true)) {
|
|
33
37
|
stoppedAt = issue;
|
|
34
38
|
claiming = false;
|
|
@@ -44,7 +48,7 @@ function loopResult(reports, stoppedAt, error, crash) {
|
|
|
44
48
|
...(crash === undefined ? {} : { crash }),
|
|
45
49
|
};
|
|
46
50
|
}
|
|
47
|
-
async function claimIssues(loop, seen, running, room) {
|
|
51
|
+
async function claimIssues(loop, seen, tried, running, room) {
|
|
48
52
|
if (loop.stop()) {
|
|
49
53
|
return false;
|
|
50
54
|
}
|
|
@@ -52,6 +56,7 @@ async function claimIssues(loop, seen, running, room) {
|
|
|
52
56
|
if (loop.stop()) {
|
|
53
57
|
return false;
|
|
54
58
|
}
|
|
59
|
+
readmitChanged(issues, seen, tried);
|
|
55
60
|
for (const issue of issues.filter((candidate) => !seen.has(candidate.number))) {
|
|
56
61
|
if (!room()) {
|
|
57
62
|
break;
|
|
@@ -61,6 +66,25 @@ async function claimIssues(loop, seen, running, room) {
|
|
|
61
66
|
}
|
|
62
67
|
return true;
|
|
63
68
|
}
|
|
69
|
+
function retryable(report) {
|
|
70
|
+
return report.outcome !== 'done' && (report.outcome !== 'error' || report.handedOver === true);
|
|
71
|
+
}
|
|
72
|
+
function readmitChanged(issues, seen, tried) {
|
|
73
|
+
const listed = new Map(issues.map((issue) => [issue.number, labelKey(issue)]));
|
|
74
|
+
for (const [number, labels] of tried.labels) {
|
|
75
|
+
if (listed.has(number) && listed.get(number) !== labels) {
|
|
76
|
+
tried.labels.delete(number);
|
|
77
|
+
seen.delete(number);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const number of tried.ended) {
|
|
81
|
+
tried.labels.set(number, listed.get(number));
|
|
82
|
+
}
|
|
83
|
+
tried.ended.clear();
|
|
84
|
+
}
|
|
85
|
+
function labelKey(issue) {
|
|
86
|
+
return [...issue.labels].sort().join('\n');
|
|
87
|
+
}
|
|
64
88
|
export function exitCode(reports) {
|
|
65
89
|
return reports.some((report) => report.outcome === 'needs-human' || report.outcome === 'error')
|
|
66
90
|
? 1
|