next-issue 6.6.17 → 6.6.19

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 CHANGED
@@ -114,10 +114,11 @@ the run handles one issue. For each issue:
114
114
  fetches the base first, and treats the push as landed when the base holds
115
115
  the commit, for example after a timeout. When that fetch fails too, the
116
116
  harness hands the issue to a person with the reason `push unknown` and
117
- halts. The state file holds the commit during the push, so a run stopped
118
- meanwhile, or the next run after that hand-over, checks the base on resume
119
- and waits for the checks of the commit when it landed. The harness then
120
- waits for the checks of the pushed commit on the base branch. A repository
117
+ halts, even when the hand-over fails. The state file holds the commit
118
+ during the push, so a run stopped meanwhile, or the next run after that
119
+ hand-over, checks the base on resume and waits for the checks of the
120
+ commit when it landed. The harness then waits for the checks of the
121
+ pushed commit on the base branch. A repository
121
122
  that reports no check keeps asking for `checkGraceSeconds`. A pending state
122
123
  waits again, up to `checkTimeoutMinutes`. A read that fails is tried three
123
124
  times. When the checks pass, the harness closes the issue and sets
@@ -137,7 +138,11 @@ the run handles one issue. For each issue:
137
138
  push that the remote refuses, for example because the base moved, makes
138
139
  the revert again on the new base, three times at most. A failed revert
139
140
  push that the base holds after a fetch counts as landed, and a fetch that
140
- fails leaves the revert reported as failed. A resume
141
+ fails leaves the revert reported as failed. The state file holds the
142
+ revert commit during the push, so a run stopped meanwhile checks the base
143
+ on resume. When the base holds the revert, the harness drops the landed
144
+ commits from the state, waits for no checks, does not revert again, hands
145
+ the issue to a person with the reason `revert stopped` and halts. A resume
141
146
  that stopped while the checks of a landed commit ran waits for them
142
147
  again, even when more commits landed on the base since, and a fix that
143
148
  was committed but not landed lands first. A problem that the reviewer
@@ -195,7 +200,8 @@ and comments the reason on the issue, when:
195
200
  - the checks on the base branch fail and the fixer cannot fix them, an error
196
201
  stops the fix, or they do not finish in time. The base branch is then
197
202
  broken, so the run claims no new issue and ends once the running issues
198
- end;
203
+ end. It halts this way even when the hand-over fails; the issue then ends
204
+ in error with both the reason and the hand-over error;
199
205
  - an agent does not finish in `agentTimeoutMinutes`;
200
206
  - the setup command fails, or does not finish in `setupTimeoutMinutes`;
201
207
  - a step of the run fails with an error. A `gh` call that is safe to repeat,
@@ -277,7 +283,9 @@ Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
277
283
  part of the file name.
278
284
 
279
285
  At the start of a run, the harness deletes the files and folders under
280
- `.next-issue/runs/` that are older than `keepRunDays`. Set the field to `0` to keep them all.
286
+ `.next-issue/runs/` that are older than `keepRunDays`. The age of a folder is
287
+ the time since the last change to it or to anything inside it, so the sessions
288
+ of a long run stay while it still writes them. Set the field to `0` to keep them all.
281
289
 
282
290
  A short text summary of the same data goes to standard output. Use `--json` to
283
291
  get the full summary object there instead, so the harness fits in a pipe. All
@@ -1,9 +1,15 @@
1
+ import { escalateAndFinish } from './handover.mjs';
1
2
  import { ROUND_CONTINUE } from './job.mjs';
2
3
  import { resumeLanding } from './land.mjs';
3
4
  import { writeState } from './state.mjs';
4
5
  export async function enterReview(job) {
5
6
  const { context, state } = job;
6
7
  await settlePush(job);
8
+ if (await settleRevert(job)) {
9
+ job.mainBroken = true;
10
+ const { base } = context;
11
+ return escalateAndFinish(job, `The run stopped during the revert of the change on ${base}. The harness reverted the change on ${base}.`, 'revert stopped');
12
+ }
7
13
  const landed = state.landed?.at(-1);
8
14
  if (landed !== undefined) {
9
15
  return resumeLanding(job, landed);
@@ -25,3 +31,18 @@ async function settlePush(job) {
25
31
  state.pushing = undefined;
26
32
  await writeState(repo, state);
27
33
  }
34
+ async function settleRevert(job) {
35
+ const { context, state, worktree } = job;
36
+ const { repo, config, ports, base } = context;
37
+ const sha = state.reverting;
38
+ if (sha === undefined) {
39
+ return false;
40
+ }
41
+ const reverted = await ports.isOnBase(worktree, base, config.remote, sha);
42
+ if (reverted) {
43
+ state.landed = undefined;
44
+ }
45
+ state.reverting = undefined;
46
+ await writeState(repo, state);
47
+ return reverted;
48
+ }
package/dist/git-land.mjs CHANGED
@@ -35,7 +35,7 @@ export async function revertOnBase(cwd, revert) {
35
35
  }
36
36
  }
37
37
  async function pushRevert(cwd, revert) {
38
- const { base, remote, branch, shas, message, reapply } = revert;
38
+ const { base, remote, branch, shas, message, reapply, pushing } = revert;
39
39
  for (let attempt = 1; attempt <= PUSH_TRIES; attempt += 1) {
40
40
  const target = await fetchBase(cwd, base, remote);
41
41
  await git(cwd, ['checkout', '--force', '--detach', target]);
@@ -45,6 +45,7 @@ async function pushRevert(cwd, revert) {
45
45
  }
46
46
  await git(cwd, ['commit', '--no-verify', '-m', message]);
47
47
  const reverted = await revision(cwd);
48
+ await pushing(reverted);
48
49
  if ((await pushToBase(cwd, remote, base)) || (await isOnBase(cwd, base, remote, reverted))) {
49
50
  await git(cwd, ['revert', '--no-commit', reverted]);
50
51
  await git(cwd, ['commit', '--no-verify', '-m', reapply]);
package/dist/handover.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { runStopped } from './children.mjs';
1
2
  import { elapsedMs } from './durations.mjs';
2
3
  import { message } from './errors.mjs';
3
4
  import { HAND_OVER } from './hand-over-comments.mjs';
@@ -8,7 +9,20 @@ import { logIssueError } from './skip.mjs';
8
9
  import { dropState, writeState } from './state.mjs';
9
10
  export async function escalateAndFinish(job, note, reason) {
10
11
  const reverted = await revertFailedFix(job);
11
- await handOver(job.context, job.log, job.issue.number, job.state, `${note}${reverted}`);
12
+ try {
13
+ await handOver(job.context, job.log, job.issue.number, job.state, `${note}${reverted}`);
14
+ }
15
+ catch (error) {
16
+ if (!job.mainBroken || runStopped()) {
17
+ throw error;
18
+ }
19
+ const failure = message(error);
20
+ job.log.event('hand-over.error', { reason, error: failure }, 'quiet');
21
+ return {
22
+ done: true,
23
+ report: await finish(job, 'error', `${reason}; the hand-over failed: ${failure}`),
24
+ };
25
+ }
12
26
  return { done: true, report: await finish(job, 'needs-human', reason) };
13
27
  }
14
28
  export async function finishDone(job) {
@@ -1,4 +1,4 @@
1
- import { rm, stat } from 'node:fs/promises';
1
+ import { readdir, rm, stat } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { daysToMs } from './durations.mjs';
4
4
  import { listOrEmpty } from './files.mjs';
@@ -20,8 +20,7 @@ export async function pruneRuns(root, keepDays) {
20
20
  }
21
21
  async function dropIfOlder(path, cutoff) {
22
22
  try {
23
- const info = await stat(path);
24
- if (info.mtimeMs >= cutoff) {
23
+ if ((await newestChange(path)) >= cutoff) {
25
24
  return false;
26
25
  }
27
26
  await rm(path, { force: true, recursive: true });
@@ -31,3 +30,14 @@ async function dropIfOlder(path, cutoff) {
31
30
  return false;
32
31
  }
33
32
  }
33
+ async function newestChange(path) {
34
+ const info = await stat(path);
35
+ if (!info.isDirectory()) {
36
+ return info.mtimeMs;
37
+ }
38
+ let newest = info.mtimeMs;
39
+ for (const name of await readdir(path)) {
40
+ newest = Math.max(newest, await newestChange(join(path, name)));
41
+ }
42
+ return newest;
43
+ }
package/dist/revert.mjs CHANGED
@@ -34,8 +34,14 @@ export async function revert(job) {
34
34
  shas,
35
35
  message: `revert: issue #${issue.number}\n\nRefs #${issue.number}`,
36
36
  reapply: `${state.title ?? `fix: resolve issue #${issue.number}`}\n\nRefs #${issue.number}`,
37
+ pushing: async (sha) => {
38
+ state.reverting = sha;
39
+ await writeState(repo, state);
40
+ },
37
41
  }));
42
+ state.reverting = undefined;
38
43
  if (!pushed) {
44
+ await writeState(repo, state);
39
45
  return ` The revert of the change on ${base} failed, so the landed commits stay on ${base}.`;
40
46
  }
41
47
  state.landed = undefined;
package/dist/state.mjs CHANGED
@@ -57,6 +57,7 @@ function isState(value) {
57
57
  isOptional(value.commitFixes, 'number') &&
58
58
  (value.landed === undefined || isLanded(value.landed)) &&
59
59
  isOptional(value.pushing, 'string') &&
60
+ isOptional(value.reverting, 'string') &&
60
61
  isOptional(value.rerun, 'string') &&
61
62
  typeof value.reviewRounds === 'number' &&
62
63
  Array.isArray(value.reviewLog) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.17",
3
+ "version": "6.6.19",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",