next-issue 6.6.113 → 6.6.115
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 +18 -11
- package/dist/base-checks.mjs +25 -10
- package/dist/children.mjs +8 -1
- package/dist/gate.mjs +20 -25
- package/dist/serve.mjs +3 -0
- package/dist/state.mjs +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npx -y next-issue@latest
|
|
|
9
9
|
|
|
10
10
|
## Overview
|
|
11
11
|
|
|
12
|
-
The harness claims the oldest open issue with the `status:todo` label and gives it its own git worktree and branch. An implementer agent does the work and the harness commits it. A reviewer agent judges the diff, and a fixer agent deals with any open finding, and the review runs again. With no open finding left, the harness rebases the change onto the base branch as one commit, pushes it there with no pull request and waits for the checks of that commit. On a red build the harness reruns the failed jobs once, and only a
|
|
12
|
+
The harness claims the oldest open issue with the `status:todo` label and gives it its own git worktree and branch. An implementer agent does the work and the harness commits it. A reviewer agent judges the diff, and a fixer agent deals with any open finding, and the review runs again. With no open finding left, the harness rebases the change onto the base branch as one commit, pushes it there with no pull request and waits for the checks of that commit. On a red build the harness reruns the failed jobs of each failed workflow run once, and only a run that fails again goes to the fixer, whose fix lands the same way. When the checks pass, the issue is closed and gets `status:done`. When a budget runs out or the work cannot go on, the issue gets `status:needs-human` and goes to a person. Then the harness takes the next issue.
|
|
13
13
|
|
|
14
14
|
```mermaid
|
|
15
15
|
flowchart TD
|
|
@@ -201,17 +201,23 @@ the run handles one issue. For each issue:
|
|
|
201
201
|
file go away. A fetch that fails or a fast-forward that is
|
|
202
202
|
not safe leaves the local base branch as it is and writes a `base.behind`
|
|
203
203
|
event, and the issue is still done. When the checks fail, the harness
|
|
204
|
-
reruns the failed GitHub Actions
|
|
205
|
-
`gh run rerun <id> --failed`, records a
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
reruns the failed jobs of each failed GitHub Actions workflow run once
|
|
205
|
+
with `gh run rerun <id> --failed`, records a `main-checks.rerun` event
|
|
206
|
+
and waits again once the runs restart. A failed run whose failed jobs
|
|
207
|
+
were already rerun (its attempt on GitHub is above 1) is not rerun
|
|
208
|
+
again, so a resumed run reruns only the runs not rerun yet. A failure
|
|
209
|
+
that gets a rerun ends the wait at once; any other failure (a run that
|
|
210
|
+
was rerun, a run that waits for approval, a check from another CI
|
|
211
|
+
service) waits until every check has finished, so a workflow run that
|
|
212
|
+
fails later, even after the first rerun started, still gets its own
|
|
213
|
+
rerun before any fixer. A rerun that GitHub refuses because the run
|
|
208
214
|
is already running counts as started. When at least one run restarted
|
|
209
215
|
and a later rerun or read fails, the event carries the error and the
|
|
210
216
|
harness still waits for the checks again, counting each restarted run as
|
|
211
217
|
running until a later attempt of it completes, so the fixer never runs
|
|
212
218
|
while a rerun is queued or in progress. When the rerun cannot start (no
|
|
213
219
|
run restarted, a `main-checks.rerun-failed` event), or the checks
|
|
214
|
-
fail again, the fixer gets their logs from the check budget (for a check
|
|
220
|
+
fail again with no run left to rerun, the fixer gets their logs from the check budget (for a check
|
|
215
221
|
from another CI service, only its name and link), and its fix
|
|
216
222
|
lands the same way. When the fixer cannot fix them, its fix cannot land,
|
|
217
223
|
an error stops the fix, or the budget runs out, the harness reverts every
|
|
@@ -385,12 +391,13 @@ Press `Ctrl-C` to stop the run step by step:
|
|
|
385
391
|
branch that this press kills before any job restarted runs again in the
|
|
386
392
|
next run, before any fixer.
|
|
387
393
|
|
|
388
|
-
`SIGTERM`
|
|
389
|
-
|
|
394
|
+
`SIGTERM` or `SIGHUP` (its terminal or ssh session closes) to a
|
|
395
|
+
command-line run while a command or an agent runs, and `SIGTERM`, `SIGHUP`
|
|
396
|
+
or `SIGINT` to the worker (`next-issue stop` sends `SIGTERM`), act like
|
|
390
397
|
the third press: they stop the running harness commands and agents, with
|
|
391
398
|
the commands the agents started, and give back the review round, the check
|
|
392
|
-
fix and the rerun in the same way. When nothing runs, `SIGTERM`
|
|
393
|
-
command-line run at once.
|
|
399
|
+
fix and the rerun in the same way. When nothing runs, `SIGTERM` or `SIGHUP`
|
|
400
|
+
ends a command-line run at once.
|
|
394
401
|
|
|
395
402
|
When the reviewer approved the change and the run stopped before its
|
|
396
403
|
commit reached the base branch, the next run drops those edits and any
|
|
@@ -825,7 +832,7 @@ affect another. The worker:
|
|
|
825
832
|
holds it;
|
|
826
833
|
- closes once no run is going when a client with a newer version connects, so
|
|
827
834
|
that the client can start the newer worker;
|
|
828
|
-
- stops every agent and command and exits on `SIGTERM` or `SIGINT`, and
|
|
835
|
+
- stops every agent and command and exits on `SIGTERM`, `SIGHUP` or `SIGINT`, and
|
|
829
836
|
removes its socket and lock files;
|
|
830
837
|
- keeps `.next-issue/worker.log`, where the extension writes the output of
|
|
831
838
|
the worker, within 10 MiB: when it starts and once a minute while it runs,
|
package/dist/base-checks.mjs
CHANGED
|
@@ -48,39 +48,54 @@ async function baseChecks(repo, sha, branch, restarted) {
|
|
|
48
48
|
]);
|
|
49
49
|
// A rerun run counts as running until a later attempt of it completes, so its old failure never ends the wait.
|
|
50
50
|
const rerunning = restarted.some((entry) => !runs.some((run) => run.databaseId === entry.id && run.attempt > entry.attempt && run.status === 'completed'));
|
|
51
|
-
return {
|
|
51
|
+
return { runs, external, rerunning };
|
|
52
52
|
}
|
|
53
53
|
function failedRun(entry) {
|
|
54
54
|
return entry.status === 'completed' && FAILED_CONCLUSIONS.has(entry.conclusion);
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/** A failed workflow run whose failed jobs were not rerun yet; one that waits for approval cannot be rerun. */
|
|
57
|
+
function rerunnable(entry) {
|
|
58
|
+
return failedRun(entry) && entry.conclusion !== AWAITS_APPROVAL && !(entry.attempt > 1);
|
|
59
|
+
}
|
|
60
|
+
function baseState(runs, external) {
|
|
61
|
+
// A failure that gets a rerun ends the wait at once; any other failure waits for every check, so no run that fails later misses its rerun.
|
|
62
|
+
if (runs.some(rerunnable)) {
|
|
58
63
|
return 'fail';
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
const checks = [...runs, ...external];
|
|
66
|
+
if (!checks.every((entry) => entry.status === 'completed')) {
|
|
61
67
|
return 'pending';
|
|
62
68
|
}
|
|
63
|
-
|
|
69
|
+
if (checks.some(failedRun)) {
|
|
70
|
+
return 'fail';
|
|
71
|
+
}
|
|
72
|
+
return checks.some((entry) => entry.conclusion === 'cancelled') ? 'cancelled' : 'pass';
|
|
64
73
|
}
|
|
65
74
|
export function waitForBaseChecks(repo, sha, branch, options, restarted = []) {
|
|
66
|
-
let read = {
|
|
75
|
+
let read = {
|
|
76
|
+
runs: [],
|
|
77
|
+
external: [],
|
|
78
|
+
rerunning: false,
|
|
79
|
+
};
|
|
67
80
|
return pollChecks({
|
|
68
81
|
head: async () => sha,
|
|
69
82
|
lags: async () => true,
|
|
70
83
|
list: async () => {
|
|
71
84
|
read = await baseChecks(repo, sha, branch, restarted);
|
|
72
|
-
return read.
|
|
85
|
+
return read.runs.length + read.external.length === 0 && !read.rerunning ? 'none' : 'some';
|
|
73
86
|
},
|
|
74
|
-
watch: async () => (read.rerunning ? 'pending' : baseState(read.
|
|
87
|
+
watch: async () => (read.rerunning ? 'pending' : baseState(read.runs, read.external)),
|
|
75
88
|
}, options);
|
|
76
89
|
}
|
|
77
90
|
export async function rerunFailedBase(repo, sha, branch, started = () => { }) {
|
|
78
|
-
const failed = (await baseRuns(repo, sha, branch)).filter(
|
|
91
|
+
const failed = (await baseRuns(repo, sha, branch)).filter(rerunnable);
|
|
79
92
|
for (const entry of failed) {
|
|
80
93
|
await rerun(repo, entry.databaseId);
|
|
81
94
|
started({ id: entry.databaseId, attempt: entry.attempt });
|
|
82
95
|
}
|
|
83
|
-
|
|
96
|
+
if (failed.length > 0) {
|
|
97
|
+
await waitForRestart(repo, sha, branch, failed);
|
|
98
|
+
}
|
|
84
99
|
return failed.map((entry) => String(entry.databaseId));
|
|
85
100
|
}
|
|
86
101
|
async function rerun(repo, id) {
|
package/dist/children.mjs
CHANGED
|
@@ -65,18 +65,25 @@ export function stopChildren(signal) {
|
|
|
65
65
|
}
|
|
66
66
|
undos.clear();
|
|
67
67
|
process.off('SIGTERM', onTerminate);
|
|
68
|
+
process.off('SIGHUP', onHangUp);
|
|
68
69
|
process.kill(process.pid, signal);
|
|
69
70
|
}
|
|
70
71
|
const onTerminate = () => stopChildren('SIGTERM');
|
|
71
|
-
|
|
72
|
+
const onHangUp = () => stopChildren('SIGHUP');
|
|
73
|
+
/**
|
|
74
|
+
* Handles `SIGTERM` and `SIGHUP` (a closed terminal) while a command or an agent runs,
|
|
75
|
+
* so its process group is stopped too.
|
|
76
|
+
*/
|
|
72
77
|
function guard() {
|
|
73
78
|
if (groups.size === 0 && stoppers.size === 0) {
|
|
74
79
|
process.on('SIGTERM', onTerminate);
|
|
80
|
+
process.on('SIGHUP', onHangUp);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
function unguard() {
|
|
78
84
|
if (groups.size === 0 && stoppers.size === 0) {
|
|
79
85
|
process.off('SIGTERM', onTerminate);
|
|
86
|
+
process.off('SIGHUP', onHangUp);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
export function watch(pid) {
|
package/dist/gate.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { budgetUse, refundBudget, refundOnKill } from './budget.mjs';
|
|
2
2
|
import { checkWaiting } from './check-poll.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { runStopped } from './children.mjs';
|
|
4
4
|
import { asError, message } from './errors.mjs';
|
|
5
5
|
import { escalateCheckFix, fixRound } from './fix.mjs';
|
|
6
6
|
import { escalateAndFinish } from './handover.mjs';
|
|
7
7
|
import { GATE_FIXED, GATE_PASSED } from './job.mjs';
|
|
8
8
|
import { revertOrReport, sentence } from './revert.mjs';
|
|
9
|
-
import { writeState
|
|
9
|
+
import { writeState } from './state.mjs';
|
|
10
10
|
import { HALT_NOTE } from './unsettled.mjs';
|
|
11
11
|
export async function checkGate(job, sha) {
|
|
12
12
|
const { base } = job.context;
|
|
@@ -45,40 +45,38 @@ async function waitForChecks(job, sha, fields = {}, restarted = []) {
|
|
|
45
45
|
log.event('main-checks.state', { state: checks, ...fields });
|
|
46
46
|
return checks;
|
|
47
47
|
}
|
|
48
|
+
/** Reruns the failed jobs of each failed workflow run once; GitHub keeps the attempts, so a resume reruns only runs not rerun yet. */
|
|
48
49
|
async function rerunOnce(job, sha, checks) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
let state = checks;
|
|
51
|
+
while (state === 'fail') {
|
|
52
|
+
const restarted = await rerunFailed(job, sha);
|
|
53
|
+
if (restarted.length === 0) {
|
|
54
|
+
return state;
|
|
55
|
+
}
|
|
56
|
+
state = await waitForChecks(job, sha, { rerun: true }, restarted).catch((error) => {
|
|
57
|
+
job.mainBroken = true;
|
|
58
|
+
throw error;
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
return state;
|
|
62
|
+
}
|
|
63
|
+
async function rerunFailed(job, sha) {
|
|
64
|
+
const { context, log } = job;
|
|
56
65
|
const restarted = [];
|
|
57
|
-
const forget = onKill(() => {
|
|
58
|
-
state.rerun = before;
|
|
59
|
-
writeStateNow(context.repo, state);
|
|
60
|
-
});
|
|
61
66
|
try {
|
|
62
67
|
const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, (run) => {
|
|
63
|
-
forget();
|
|
64
68
|
restarted.push(run);
|
|
65
69
|
});
|
|
66
|
-
|
|
70
|
+
// An empty list tells why the fixer starts with no rerun: no failed workflow run is left to rerun.
|
|
67
71
|
log.event('main-checks.rerun', { sha, runs });
|
|
68
72
|
}
|
|
69
73
|
catch (error) {
|
|
70
|
-
forget();
|
|
71
74
|
if (runStopped()) {
|
|
72
|
-
if (restarted.length > 0) {
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
state.rerun = before;
|
|
76
|
-
await writeState(context.repo, state);
|
|
77
75
|
throw error;
|
|
78
76
|
}
|
|
79
77
|
if (restarted.length === 0) {
|
|
80
78
|
log.event('main-checks.rerun-failed', { sha, error: asError(error).message });
|
|
81
|
-
return
|
|
79
|
+
return restarted;
|
|
82
80
|
}
|
|
83
81
|
// Some runs restarted, so the fixer waits for them rather than getting a failure with no log.
|
|
84
82
|
log.event('main-checks.rerun', {
|
|
@@ -87,10 +85,7 @@ async function rerunOnce(job, sha, checks) {
|
|
|
87
85
|
error: asError(error).message,
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
|
-
return
|
|
91
|
-
job.mainBroken = true;
|
|
92
|
-
throw error;
|
|
93
|
-
});
|
|
88
|
+
return restarted;
|
|
94
89
|
}
|
|
95
90
|
async function failedChecksFix(job, sha) {
|
|
96
91
|
const { context, log, state } = job;
|
package/dist/serve.mjs
CHANGED
|
@@ -157,13 +157,16 @@ export async function serve(root, logCheckMs = LOG_CHECK_MS) {
|
|
|
157
157
|
const end = (signal) => {
|
|
158
158
|
process.off('SIGTERM', onTerminate);
|
|
159
159
|
process.off('SIGINT', onInterrupt);
|
|
160
|
+
process.off('SIGHUP', onHangUp);
|
|
160
161
|
worker.release();
|
|
161
162
|
stopChildren(signal);
|
|
162
163
|
};
|
|
163
164
|
const onTerminate = () => end('SIGTERM');
|
|
164
165
|
const onInterrupt = () => end('SIGINT');
|
|
166
|
+
const onHangUp = () => end('SIGHUP');
|
|
165
167
|
process.on('SIGTERM', onTerminate);
|
|
166
168
|
process.on('SIGINT', onInterrupt);
|
|
169
|
+
process.on('SIGHUP', onHangUp);
|
|
167
170
|
process.stderr.write(`next-issue: worker listening on ${paths.socketPath}\n`);
|
|
168
171
|
await worker.closed;
|
|
169
172
|
stopTrimming();
|
package/dist/state.mjs
CHANGED
|
@@ -66,7 +66,6 @@ function isState(value) {
|
|
|
66
66
|
isOptional(value.pushing, 'string') &&
|
|
67
67
|
isOptional(value.reverting, 'string') &&
|
|
68
68
|
isOptional(value.squashing, 'string') &&
|
|
69
|
-
isOptional(value.rerun, 'string') &&
|
|
70
69
|
isOptional(value.reviewing, 'string') &&
|
|
71
70
|
typeof value.reviewRounds === 'number' &&
|
|
72
71
|
Array.isArray(value.reviewLog) &&
|