next-issue 8.7.0 → 8.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 +26 -9
- package/dist/handover.mjs +0 -9
- package/dist/land.mjs +2 -0
- package/dist/local-base.mjs +9 -0
- package/dist/revert.mjs +2 -0
- package/dist/serve.mjs +21 -9
- package/dist/worker-run.mjs +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ npx -y next-issue@latest start
|
|
|
11
11
|
|
|
12
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
|
+
The harness is built for a flow with as few people in it as possible: people write issues and answer hand-overs, and the harness does the rest. [ADR 0004](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0004-humanless-flow.md) records this principle, its accepted risks and the setup it recommends.
|
|
15
|
+
|
|
14
16
|
```mermaid
|
|
15
17
|
flowchart TD
|
|
16
18
|
claim[Claim the oldest status:todo issue] --> worktree[Add a worktree and branch]
|
|
@@ -216,7 +218,11 @@ the run handles one issue. For each issue:
|
|
|
216
218
|
holds the commit during the push, so a run stopped meanwhile, or the
|
|
217
219
|
resume after that hand-over (once a person answers or takes the label
|
|
218
220
|
off), checks the base and waits for the checks of the commit when it
|
|
219
|
-
landed. Until then, no run lands another change (see below).
|
|
221
|
+
landed. Until then, no run lands another change (see below). Once the
|
|
222
|
+
commit lands, the harness fetches the remote and fast-forwards the local
|
|
223
|
+
base branch to it when that is safe. A fetch that fails or a
|
|
224
|
+
fast-forward that is not safe leaves the local base branch as it is and
|
|
225
|
+
writes a `base.behind` event, and the landing goes on. The
|
|
220
226
|
harness then waits for the checks of the pushed commit on the base
|
|
221
227
|
branch: the GitHub Actions workflow runs that a `push` of the base
|
|
222
228
|
branch started on it, its commit statuses and the check runs of every
|
|
@@ -274,12 +280,8 @@ the run handles one issue. For each issue:
|
|
|
274
280
|
file and removes the worktree, the local branches and the state file,
|
|
275
281
|
with no new push, revert, label, close or hand-over. A label or close
|
|
276
282
|
that fails for another reason hands the issue over, and it then waits
|
|
277
|
-
for a person like any other hand-over. Then the
|
|
278
|
-
|
|
279
|
-
when that is safe, and the worktree, the local branch and the state
|
|
280
|
-
file go away. A fetch that fails or a fast-forward that is
|
|
281
|
-
not safe leaves the local base branch as it is and writes a `base.behind`
|
|
282
|
-
event, and the issue is still done. When the checks fail, the harness
|
|
283
|
+
for a person like any other hand-over. Then the worktree, the local
|
|
284
|
+
branch and the state file go away. When the checks fail, the harness
|
|
283
285
|
reruns the failed jobs of each failed GitHub Actions workflow run once
|
|
284
286
|
with `gh run rerun <id> --failed`, records a `main-checks.rerun` event
|
|
285
287
|
and waits again once the runs restart. A failed run whose failed jobs
|
|
@@ -309,7 +311,9 @@ the run handles one issue. For each issue:
|
|
|
309
311
|
other `push unknown`. A revert
|
|
310
312
|
push that the remote refuses, for example because the base moved, makes
|
|
311
313
|
the revert again on the new base, three times at most. A failed revert
|
|
312
|
-
push that the base holds after a fetch counts as landed.
|
|
314
|
+
push that the base holds after a fetch counts as landed. Once the revert
|
|
315
|
+
lands, the harness fast-forwards the local base branch to it, as after a
|
|
316
|
+
landed commit. When that fetch
|
|
313
317
|
fails too, the revert may be on the base with checks nobody awaited: the
|
|
314
318
|
harness reports it so, saves the halt and blocks later landings. The state file holds the
|
|
315
319
|
revert commit during the push, so a run stopped meanwhile checks the base
|
|
@@ -569,6 +573,12 @@ on a repository where you trust the writers, or run it in a container.
|
|
|
569
573
|
[ADR 0001](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0001-reviewer-isolation.md) records why the reviewer
|
|
570
574
|
keeps a full shell, and which other options were considered.
|
|
571
575
|
|
|
576
|
+
No person checks a change before it lands. To replace those checks,
|
|
577
|
+
[ADR 0004](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0004-humanless-flow.md)
|
|
578
|
+
recommends a non-empty `checks` gate, a different model for the reviewer than
|
|
579
|
+
for the implementer and the fixer in `models`, and running the whole harness in
|
|
580
|
+
a container.
|
|
581
|
+
|
|
572
582
|
## Observability
|
|
573
583
|
|
|
574
584
|
Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
|
|
@@ -1043,7 +1053,14 @@ affect another. The worker:
|
|
|
1043
1053
|
- waits up to 5 seconds for the lock when a worker that is closing still
|
|
1044
1054
|
holds it;
|
|
1045
1055
|
- closes once no run is going when a client with a newer version connects, so
|
|
1046
|
-
that the client can start the newer worker
|
|
1056
|
+
that the client can start the newer worker. A run that watches is stopped
|
|
1057
|
+
between issues for that, as `stop` with `issue` does: it claims nothing new,
|
|
1058
|
+
and its running issues and its current hunt finish. Its progress then holds
|
|
1059
|
+
`"upgrade": { "from": "<worker version>", "to": "<client version>" }`. A
|
|
1060
|
+
stop by a person drops that field, so no client starts the run again. A run
|
|
1061
|
+
that does not watch is left alone. Meanwhile the worker refuses every start
|
|
1062
|
+
with `the worker is restarting, try again soon`. A `start` with
|
|
1063
|
+
`"resume": true` gets no error when the worker refuses it;
|
|
1047
1064
|
- stops every agent and command and exits on `SIGTERM`, `SIGHUP` or `SIGINT`, and
|
|
1048
1065
|
removes its socket and lock files;
|
|
1049
1066
|
- keeps `.next-issue/worker.log`, where the extension writes the output of
|
package/dist/handover.mjs
CHANGED
|
@@ -44,7 +44,6 @@ export async function finishDone(job) {
|
|
|
44
44
|
await setStatus(context, issue.number, context.config.labels.done);
|
|
45
45
|
await context.ports.closeIssue(context.repo, issue.number);
|
|
46
46
|
}
|
|
47
|
-
await updateLocalBase(job);
|
|
48
47
|
return { done: true, report: await finish(job, 'done') };
|
|
49
48
|
}
|
|
50
49
|
export async function finishClosing(context, issue, log, state, started) {
|
|
@@ -83,14 +82,6 @@ export async function dropClosed(context, log, issue, branch) {
|
|
|
83
82
|
ms: 0,
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
|
-
async function updateLocalBase(job) {
|
|
87
|
-
const { context, log } = job;
|
|
88
|
-
const { repo, ports, config, base } = context;
|
|
89
|
-
const updated = await oneAtATime(repo.root, () => ports.fastForwardBase(repo, base, config.remote)).catch(() => false);
|
|
90
|
-
if (!updated) {
|
|
91
|
-
log.event('base.behind', { base }, 'quiet');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
85
|
export function stop(job, reason) {
|
|
95
86
|
job.log.event('issue.stop', { phase: job.state.phase, reason }, 'quiet');
|
|
96
87
|
return jobReport(job, 'stopped', reason);
|
package/dist/land.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { runStopped } from './children.mjs';
|
|
|
2
2
|
import { rebase } from './conflict.mjs';
|
|
3
3
|
import { checkGate, escalateError } from './gate.mjs';
|
|
4
4
|
import { PUSH_TRIES } from './git-land.mjs';
|
|
5
|
+
import { updateLocalBase } from './local-base.mjs';
|
|
5
6
|
import { localChecks } from './local-checks.mjs';
|
|
6
7
|
import { escalateAndFinish, finishDone, stop } from './handover.mjs';
|
|
7
8
|
import { oneAtATime } from './lock.mjs';
|
|
@@ -146,6 +147,7 @@ async function pushChange(job) {
|
|
|
146
147
|
await writeState(repo, state);
|
|
147
148
|
if (pushed) {
|
|
148
149
|
job.repairing = false;
|
|
150
|
+
await updateLocalBase(job);
|
|
149
151
|
return sha;
|
|
150
152
|
}
|
|
151
153
|
attempt += 1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { oneAtATime } from './lock.mjs';
|
|
2
|
+
export async function updateLocalBase(job) {
|
|
3
|
+
const { context, log } = job;
|
|
4
|
+
const { repo, ports, config, base } = context;
|
|
5
|
+
const updated = await oneAtATime(repo.root, () => ports.fastForwardBase(repo, base, config.remote)).catch(() => false);
|
|
6
|
+
if (!updated) {
|
|
7
|
+
log.event('base.behind', { base }, 'quiet');
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/revert.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { runStopped } from './children.mjs';
|
|
2
2
|
import { message } from './errors.mjs';
|
|
3
|
+
import { updateLocalBase } from './local-base.mjs';
|
|
3
4
|
import { writeState } from './state.mjs';
|
|
4
5
|
import { HALT_NOTE, releaseSettled } from './unsettled.mjs';
|
|
5
6
|
export async function revertFailedFix(job) {
|
|
@@ -80,5 +81,6 @@ export async function revert(job) {
|
|
|
80
81
|
restoreChange(state);
|
|
81
82
|
releaseSettled(state);
|
|
82
83
|
await writeState(repo, state);
|
|
84
|
+
await updateLocalBase(job);
|
|
83
85
|
return ` The harness reverted the change on ${base}.`;
|
|
84
86
|
}
|
package/dist/serve.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { runRepo } from './run.mjs';
|
|
|
14
14
|
import { packageVersion } from './version.mjs';
|
|
15
15
|
import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
|
|
16
16
|
import { checkSocketPath, workerPaths } from './worker-paths.mjs';
|
|
17
|
-
import { active, endStatus, newRun, requestRefresh, requestStop, runControls, runsMessage, setHunting, setWatching, startRefusal, stopPoint, switchRefusal, } from './worker-run.mjs';
|
|
17
|
+
import { active, dropUpgrade, endStatus, newRun, requestRefresh, requestStop, requestUpgrade, runControls, runsMessage, setHunting, setWatching, startRefusal, stopPoint, switchRefusal, } from './worker-run.mjs';
|
|
18
18
|
import { broadcast, closer, fileId, listen, parseMessage, removeOwned, shutdown, } from './worker-server.mjs';
|
|
19
19
|
const LOCK_WAIT_MS = 5_000;
|
|
20
20
|
const IDLE_MS = 30_000;
|
|
@@ -32,7 +32,7 @@ export async function startWorker(options) {
|
|
|
32
32
|
socket: '',
|
|
33
33
|
};
|
|
34
34
|
const runs = new Map();
|
|
35
|
-
let restart
|
|
35
|
+
let restart;
|
|
36
36
|
const server = createServer();
|
|
37
37
|
const sockets = new WebSocketServer({ server });
|
|
38
38
|
const sendQuestions = questionSender(options.questions);
|
|
@@ -46,14 +46,21 @@ export async function startWorker(options) {
|
|
|
46
46
|
await shutdown(server, sockets, owned);
|
|
47
47
|
});
|
|
48
48
|
const closeWhenIdle = () => {
|
|
49
|
-
if ((restart || sockets.clients.size === 0) && !busy()) {
|
|
49
|
+
if ((restart !== undefined || sockets.clients.size === 0) && !busy()) {
|
|
50
50
|
void close();
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const upgradeBetweenIssues = (run) => {
|
|
54
|
+
if (restart !== undefined && requestUpgrade(run, { from: options.version, to: restart })) {
|
|
55
|
+
broadcast(sockets, runs);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const start = (socket, root, argv, resume) => {
|
|
59
|
+
const refusal = startRefusal(runs.get(root), restart !== undefined);
|
|
55
60
|
if (refusal !== undefined) {
|
|
56
|
-
|
|
61
|
+
if (!resume) {
|
|
62
|
+
send(socket, { type: 'error', root, message: refusal });
|
|
63
|
+
}
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
66
|
let args;
|
|
@@ -79,8 +86,11 @@ export async function startWorker(options) {
|
|
|
79
86
|
const point = stopPoint(after);
|
|
80
87
|
if (point === undefined) {
|
|
81
88
|
send(socket, { type: 'error', root, message: `stop does not take --after ${String(after)}` });
|
|
89
|
+
return;
|
|
82
90
|
}
|
|
83
|
-
|
|
91
|
+
const run = runs.get(root);
|
|
92
|
+
const dropped = dropUpgrade(run);
|
|
93
|
+
if (requestStop(run, point) || dropped) {
|
|
84
94
|
broadcast(sockets, runs);
|
|
85
95
|
}
|
|
86
96
|
};
|
|
@@ -93,6 +103,7 @@ export async function startWorker(options) {
|
|
|
93
103
|
}
|
|
94
104
|
set(run, on);
|
|
95
105
|
broadcast(sockets, runs);
|
|
106
|
+
upgradeBetweenIssues(run);
|
|
96
107
|
};
|
|
97
108
|
const receive = (socket, value) => {
|
|
98
109
|
if (value.type === 'hello') {
|
|
@@ -100,7 +111,8 @@ export async function startWorker(options) {
|
|
|
100
111
|
throw new Error('a hello message needs its version as a string');
|
|
101
112
|
}
|
|
102
113
|
if (isNewer(value.version, options.version)) {
|
|
103
|
-
restart
|
|
114
|
+
restart ??= value.version;
|
|
115
|
+
runs.forEach(upgradeBetweenIssues);
|
|
104
116
|
closeWhenIdle();
|
|
105
117
|
}
|
|
106
118
|
}
|
|
@@ -112,7 +124,7 @@ export async function startWorker(options) {
|
|
|
112
124
|
});
|
|
113
125
|
}
|
|
114
126
|
else if (value.type === 'start') {
|
|
115
|
-
start(socket, value.root, value.args ?? []);
|
|
127
|
+
start(socket, value.root, value.args ?? [], value.resume === true);
|
|
116
128
|
}
|
|
117
129
|
else if (value.type === 'stop') {
|
|
118
130
|
stop(socket, value.root, value.after);
|
package/dist/worker-run.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { runChildren, stopRunChildren } from './children.mjs';
|
|
|
2
2
|
import { wakeableSleep } from './durations.mjs';
|
|
3
3
|
import { onOff } from './switch.mjs';
|
|
4
4
|
import { applyEvent } from './progress.mjs';
|
|
5
|
-
import { STOP_POINTS } from './protocol.mjs';
|
|
5
|
+
import { STOP_POINTS, } from './protocol.mjs';
|
|
6
6
|
import { refresher } from './refresh.mjs';
|
|
7
7
|
export function newRun(progress) {
|
|
8
8
|
return {
|
|
@@ -58,6 +58,20 @@ export function requestStop(run, after) {
|
|
|
58
58
|
run.progress = { ...run.progress, status: 'stopping' };
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
|
+
export function requestUpgrade(run, upgrade) {
|
|
62
|
+
if (!run.watching.on() || run.stop !== undefined || !requestStop(run, 'issue')) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
run.progress = { ...run.progress, upgrade };
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
export function dropUpgrade(run) {
|
|
69
|
+
if (run?.progress.upgrade === undefined) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
run.progress = { ...run.progress, upgrade: undefined };
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
61
75
|
export function switchRefusal(run) {
|
|
62
76
|
return active(run) ? undefined : 'no run is going in this repository';
|
|
63
77
|
}
|