next-issue 6.6.103 → 6.6.105
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 +22 -13
- package/dist/budget.mjs +16 -1
- package/dist/children.mjs +15 -0
- package/dist/conflict.mjs +7 -4
- package/dist/enter-review.mjs +3 -1
- package/dist/files.mjs +15 -0
- package/dist/gate.mjs +14 -5
- package/dist/land.mjs +3 -1
- package/dist/revert.mjs +2 -0
- package/dist/review.mjs +5 -3
- package/dist/state.mjs +5 -1
- package/dist/unsettled.mjs +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -327,9 +327,11 @@ before the others, and a running one still resumes, so an older issue that
|
|
|
327
327
|
reaches the landing first does not keep it from checking the base. Once a person answers or
|
|
328
328
|
takes the label off, the issue resumes, checks the base and waits for the
|
|
329
329
|
checks of its commit; when those are known (the issue is done, or its
|
|
330
|
-
commits are reverted or found not on the base), the
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
commits are reverted or found not on the base), the issue drops the halt
|
|
331
|
+
from its state and the next run lands the held issues again. A later
|
|
332
|
+
landing of that issue blocks other runs only if it halts again. A
|
|
333
|
+
person who gives such an issue up instead (the `skip` label, which
|
|
334
|
+
**Give up** in pi adds) releases the block: the next run skips
|
|
333
335
|
the issue, drops its halt from the state and logs a `land.released` event,
|
|
334
336
|
so other issues land again on a base whose last checks nobody read. The state
|
|
335
337
|
keeps the commits, so taking the `skip` label off later resumes the issue
|
|
@@ -372,16 +374,23 @@ Press `Ctrl-C` to stop the run step by step:
|
|
|
372
374
|
starts, so the reviewer sees only the commits of the branch. Files that
|
|
373
375
|
git ignores, such as build output, stay. When it
|
|
374
376
|
resumes before the first commit, the implementer runs again and the
|
|
375
|
-
commit holds them. A review round or a check fix whose reviewer
|
|
376
|
-
fixer this press kills does not count, so the next run runs that step
|
|
377
|
-
again with the same budget.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
377
|
+
commit holds them. A review round or a check fix whose reviewer,
|
|
378
|
+
fixer or read of the failed logs this press kills does not count, so the next run runs that step
|
|
379
|
+
again with the same budget. A rerun of the failed jobs on the base
|
|
380
|
+
branch that this press kills before any job restarted runs again in the
|
|
381
|
+
next run, before any fixer.
|
|
382
|
+
|
|
383
|
+
`SIGTERM` to a command-line run while a command runs, and `SIGTERM` or
|
|
384
|
+
`SIGINT` to the worker (as `next-issue stop` sends), act like the third
|
|
385
|
+
press: they give back the review round, the check fix and the rerun in the
|
|
386
|
+
same way.
|
|
387
|
+
|
|
388
|
+
When the reviewer approved the change and the run stopped before its
|
|
389
|
+
commit reached the base branch, the next run drops those edits and any
|
|
390
|
+
unfinished merge of the base branch, then lands the change with no new
|
|
391
|
+
review round. A hand-over of the issue cancels that approval, so the
|
|
392
|
+
issue resumes in review. A revert of the landed change cancels it too,
|
|
393
|
+
even when the hand-over after it does not finish.
|
|
385
394
|
|
|
386
395
|
Signals that arrive within 100 ms of the last counted one count as one press,
|
|
387
396
|
because `npx` and `npm exec` pass on a press as a second signal.
|
package/dist/budget.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { onKill } from './children.mjs';
|
|
1
2
|
import { escalateAndFinish } from './handover.mjs';
|
|
2
|
-
import { writeState } from './state.mjs';
|
|
3
|
+
import { writeState, writeStateNow } from './state.mjs';
|
|
3
4
|
const LIMITS = { ciFixes: 'maxCiFixes', reviewRounds: 'maxReviewRounds' };
|
|
4
5
|
export function budgetUse(job, budget) {
|
|
5
6
|
return { round: job.state[budget], limit: job.context.config[LIMITS[budget]] };
|
|
@@ -20,3 +21,17 @@ export async function refundBudget(job, budget) {
|
|
|
20
21
|
state[budget] = Math.max(0, state[budget] - 1);
|
|
21
22
|
await writeState(context.repo, state);
|
|
22
23
|
}
|
|
24
|
+
/** Gives the spent budget back if the process is killed (third Ctrl-C) while `body` runs. */
|
|
25
|
+
export async function refundOnKill(job, budget, body) {
|
|
26
|
+
const { context, state } = job;
|
|
27
|
+
const forget = onKill(() => {
|
|
28
|
+
state[budget] = Math.max(0, state[budget] - 1);
|
|
29
|
+
writeStateNow(context.repo, state);
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
return await body();
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
forget();
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/children.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
const groups = new Set();
|
|
3
3
|
const stoppers = new Set();
|
|
4
|
+
const undos = new Set();
|
|
4
5
|
const current = new AsyncLocalStorage();
|
|
5
6
|
export function runChildren() {
|
|
6
7
|
return { groups: new Set(), stoppers: new Set(), stopped: false };
|
|
@@ -45,8 +46,22 @@ export function onStop(stopper) {
|
|
|
45
46
|
children?.stoppers.delete(stopper);
|
|
46
47
|
};
|
|
47
48
|
}
|
|
49
|
+
/** Runs `undo` (synchronously) if the process is killed, for a step the kill leaves unsettled. */
|
|
50
|
+
export function onKill(undo) {
|
|
51
|
+
undos.add(undo);
|
|
52
|
+
return () => {
|
|
53
|
+
undos.delete(undo);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
48
56
|
export function stopChildren(signal) {
|
|
49
57
|
stopAll({ groups, stoppers }, signal);
|
|
58
|
+
for (const undo of undos) {
|
|
59
|
+
try {
|
|
60
|
+
undo();
|
|
61
|
+
}
|
|
62
|
+
catch { }
|
|
63
|
+
}
|
|
64
|
+
undos.clear();
|
|
50
65
|
process.off('SIGTERM', onTerminate);
|
|
51
66
|
process.kill(process.pid, signal);
|
|
52
67
|
}
|
package/dist/conflict.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseCommitSubject } from './agent-reply.mjs';
|
|
2
|
-
import { refundBudget, spendBudget } from './budget.mjs';
|
|
2
|
+
import { refundBudget, refundOnKill, spendBudget } from './budget.mjs';
|
|
3
3
|
import { runStopped } from './children.mjs';
|
|
4
4
|
import { commitWork, runFixer } from './fix.mjs';
|
|
5
5
|
import { escalateAndFinish } from './handover.mjs';
|
|
@@ -66,9 +66,12 @@ async function resolve(job, merge) {
|
|
|
66
66
|
const { before, files } = merge;
|
|
67
67
|
const { config, ports } = context;
|
|
68
68
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const fixAndCommit = async () => {
|
|
70
|
+
const text = files.length > 0 ? await fixConflict(job, files) : '';
|
|
71
|
+
const subject = parseCommitSubject(text, `chore: merge ${config.remote}/${context.base}`);
|
|
72
|
+
return commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd, merge, message));
|
|
73
|
+
};
|
|
74
|
+
return await (files.length > 0 ? refundOnKill(job, 'ciFixes', fixAndCommit) : fixAndCommit());
|
|
72
75
|
}
|
|
73
76
|
catch (error) {
|
|
74
77
|
if (files.length > 0 && runStopped()) {
|
package/dist/enter-review.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { ROUND_CONTINUE } from './job.mjs';
|
|
|
3
3
|
import { landApproved, resumeLanding } from './land.mjs';
|
|
4
4
|
import { reapplyMessage, restoreChange } from './revert.mjs';
|
|
5
5
|
import { writeState } from './state.mjs';
|
|
6
|
-
import { beforeBaseSettled } from './unsettled.mjs';
|
|
6
|
+
import { beforeBaseSettled, releaseSettled } from './unsettled.mjs';
|
|
7
7
|
export async function enterReview(job) {
|
|
8
8
|
const { context, state } = job;
|
|
9
9
|
const reverted = await beforeBaseSettled(state, context.base, async () => {
|
|
@@ -44,6 +44,7 @@ async function settlePush(job) {
|
|
|
44
44
|
state.landed = [...(state.landed ?? []), sha];
|
|
45
45
|
}
|
|
46
46
|
state.pushing = undefined;
|
|
47
|
+
releaseSettled(state);
|
|
47
48
|
await writeState(repo, state);
|
|
48
49
|
}
|
|
49
50
|
async function settleSquash(job) {
|
|
@@ -75,6 +76,7 @@ async function settleRevert(job) {
|
|
|
75
76
|
restoreChange(state);
|
|
76
77
|
}
|
|
77
78
|
state.reverting = undefined;
|
|
79
|
+
releaseSettled(state);
|
|
78
80
|
await writeState(repo, state);
|
|
79
81
|
return reverted;
|
|
80
82
|
}
|
package/dist/files.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
2
4
|
import { readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
5
|
import { hasCode } from './errors.mjs';
|
|
4
6
|
export function readTextOrEmpty(path) {
|
|
@@ -24,6 +26,19 @@ export async function replaceJson(path, value) {
|
|
|
24
26
|
throw error;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
/** The synchronous `replaceJson`, for a write that must land before the process dies. */
|
|
30
|
+
export function replaceJsonNow(path, value) {
|
|
31
|
+
const draft = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
32
|
+
try {
|
|
33
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
34
|
+
writeFileSync(draft, prettyJson(value));
|
|
35
|
+
renameSync(draft, path);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
rmSync(draft, { force: true });
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
export async function unlessMissing(read) {
|
|
28
43
|
try {
|
|
29
44
|
return await read();
|
package/dist/gate.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { budgetUse, refundBudget } from './budget.mjs';
|
|
1
|
+
import { budgetUse, refundBudget, refundOnKill } from './budget.mjs';
|
|
2
2
|
import { checkWaiting } from './check-poll.mjs';
|
|
3
|
-
import { runStopped } from './children.mjs';
|
|
3
|
+
import { onKill, 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 } from './state.mjs';
|
|
9
|
+
import { writeState, writeStateNow } 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;
|
|
@@ -20,6 +20,8 @@ export async function checkGate(job, sha) {
|
|
|
20
20
|
}
|
|
21
21
|
return unreadChecks(job, error);
|
|
22
22
|
}
|
|
23
|
+
// The checks are known now, so an earlier halt on this issue no longer holds back other landings.
|
|
24
|
+
delete job.state.halted;
|
|
23
25
|
if (checks === 'pass' || checks === 'none') {
|
|
24
26
|
return GATE_PASSED;
|
|
25
27
|
}
|
|
@@ -52,13 +54,20 @@ async function rerunOnce(job, sha, checks) {
|
|
|
52
54
|
state.rerun = sha;
|
|
53
55
|
await writeState(context.repo, state);
|
|
54
56
|
const restarted = [];
|
|
57
|
+
const forget = onKill(() => {
|
|
58
|
+
state.rerun = before;
|
|
59
|
+
writeStateNow(context.repo, state);
|
|
60
|
+
});
|
|
55
61
|
try {
|
|
56
62
|
const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, (run) => {
|
|
63
|
+
forget();
|
|
57
64
|
restarted.push(run);
|
|
58
65
|
});
|
|
66
|
+
forget();
|
|
59
67
|
log.event('main-checks.rerun', { sha, runs });
|
|
60
68
|
}
|
|
61
69
|
catch (error) {
|
|
70
|
+
forget();
|
|
62
71
|
if (runStopped()) {
|
|
63
72
|
if (restarted.length > 0) {
|
|
64
73
|
throw error;
|
|
@@ -95,7 +104,7 @@ async function failedChecksFix(job, sha) {
|
|
|
95
104
|
await writeState(repo, state);
|
|
96
105
|
let logs;
|
|
97
106
|
try {
|
|
98
|
-
logs = await ports.failedBaseLogs(repo, sha, base, config.logMaxChars);
|
|
107
|
+
logs = await refundOnKill(job, 'ciFixes', () => ports.failedBaseLogs(repo, sha, base, config.logMaxChars));
|
|
99
108
|
}
|
|
100
109
|
catch (error) {
|
|
101
110
|
await refundStopped(job);
|
|
@@ -104,7 +113,7 @@ async function failedChecksFix(job, sha) {
|
|
|
104
113
|
log.event('main-checks.logs', { chars: logs.length });
|
|
105
114
|
let fix;
|
|
106
115
|
try {
|
|
107
|
-
fix = await fixRound(job, `The checks on ${base} failed after the change landed there.`, logs, [], 'checks');
|
|
116
|
+
fix = await refundOnKill(job, 'ciFixes', () => fixRound(job, `The checks on ${base} failed after the change landed there.`, logs, [], 'checks'));
|
|
108
117
|
}
|
|
109
118
|
catch (error) {
|
|
110
119
|
await refundStopped(job);
|
package/dist/land.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { escalateAndFinish, finishDone, stop } from './handover.mjs';
|
|
|
6
6
|
import { oneAtATime } from './lock.mjs';
|
|
7
7
|
import { revertFailedFix } from './revert.mjs';
|
|
8
8
|
import { readState, savedIssues, writeState } from './state.mjs';
|
|
9
|
-
import { beforeBaseSettled, blocksLanding, HALT_NOTE } from './unsettled.mjs';
|
|
9
|
+
import { beforeBaseSettled, blocksLanding, HALT_NOTE, releaseSettled } from './unsettled.mjs';
|
|
10
10
|
export function landApproved(job) {
|
|
11
11
|
return landing(job, () => landLoop(job));
|
|
12
12
|
}
|
|
@@ -112,6 +112,8 @@ async function pushChange(job) {
|
|
|
112
112
|
return rebased;
|
|
113
113
|
}
|
|
114
114
|
const sha = await ports.revision(worktree);
|
|
115
|
+
// A halt saved before nothing of this issue was left on the base must not block once this push lands.
|
|
116
|
+
releaseSettled(state);
|
|
115
117
|
state.pushing = sha;
|
|
116
118
|
await writeState(repo, state);
|
|
117
119
|
const pushed = await log.step('land', { base, sha }, async () => (await ports.pushToBase(worktree, config.remote, base)) ||
|
package/dist/revert.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runStopped } from './children.mjs';
|
|
2
2
|
import { message } from './errors.mjs';
|
|
3
3
|
import { writeState } from './state.mjs';
|
|
4
|
+
import { releaseSettled } from './unsettled.mjs';
|
|
4
5
|
export async function revertFailedFix(job) {
|
|
5
6
|
if (!job.repairing || (job.state.landed ?? []).length === 0) {
|
|
6
7
|
return '';
|
|
@@ -57,6 +58,7 @@ export async function revert(job) {
|
|
|
57
58
|
return ` The revert of the change on ${base} failed, so the landed commits stay on ${base}.`;
|
|
58
59
|
}
|
|
59
60
|
restoreChange(state);
|
|
61
|
+
releaseSettled(state);
|
|
60
62
|
await writeState(repo, state);
|
|
61
63
|
return ` The harness reverted the change on ${base}.`;
|
|
62
64
|
}
|
package/dist/review.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { REVIEWING } from './agents.mjs';
|
|
2
2
|
import { runStopped } from './children.mjs';
|
|
3
|
-
import { budgetUse, refundBudget, spendBudget } from './budget.mjs';
|
|
3
|
+
import { budgetUse, refundBudget, refundOnKill, spendBudget } from './budget.mjs';
|
|
4
4
|
import { message } from './errors.mjs';
|
|
5
5
|
import { fixRound } from './fix.mjs';
|
|
6
6
|
import { escalateAndFinish } from './handover.mjs';
|
|
@@ -21,8 +21,10 @@ export async function reviewRound(job) {
|
|
|
21
21
|
const earlier = history(state.reviewLog);
|
|
22
22
|
let text;
|
|
23
23
|
try {
|
|
24
|
-
await
|
|
25
|
-
|
|
24
|
+
text = await refundOnKill(job, 'reviewRounds', async () => {
|
|
25
|
+
await setStatus(context, issue.number, config.labels.inReview);
|
|
26
|
+
return runReviewer(job, earlier);
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
catch (error) {
|
|
28
30
|
if (runStopped()) {
|
package/dist/state.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { parseJson } from './errors.mjs';
|
|
4
|
-
import { readTextIfPresent, replaceJson, unlessMissing } from './files.mjs';
|
|
4
|
+
import { readTextIfPresent, replaceJson, replaceJsonNow, unlessMissing } from './files.mjs';
|
|
5
5
|
import { isRecord } from './records.mjs';
|
|
6
6
|
export const STATE_DIR = '.next-issue';
|
|
7
7
|
export function stateDir(root) {
|
|
@@ -95,6 +95,10 @@ export async function writeState(repo, state) {
|
|
|
95
95
|
await mkdir(stateDir(repo.root), { recursive: true });
|
|
96
96
|
await replaceJson(file(repo, state.issue), state);
|
|
97
97
|
}
|
|
98
|
+
/** Writes the state synchronously, from a kill of the process. */
|
|
99
|
+
export function writeStateNow(repo, state) {
|
|
100
|
+
replaceJsonNow(file(repo, state.issue), state);
|
|
101
|
+
}
|
|
98
102
|
export async function dropState(repo, issue) {
|
|
99
103
|
await rm(file(repo, issue), { force: true });
|
|
100
104
|
}
|
package/dist/unsettled.mjs
CHANGED
|
@@ -18,6 +18,12 @@ export const HALT_NOTE = 'The run halts, and no run lands another change until t
|
|
|
18
18
|
export function blocksLanding(state, base) {
|
|
19
19
|
return state.halted === true && state.closing !== true && heldOnBase(state, base) !== '';
|
|
20
20
|
}
|
|
21
|
+
/** Drops a saved halt once nothing of this issue is, or may be, on the base with unknown checks. */
|
|
22
|
+
export function releaseSettled(state) {
|
|
23
|
+
if (heldOnBase(state, '') === '') {
|
|
24
|
+
delete state.halted;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
21
27
|
export function unsettledNote(held, step) {
|
|
22
28
|
return ` ${step} before it checked the base: ${held}, and its checks were not awaited. ${HALT_NOTE}`;
|
|
23
29
|
}
|