next-issue 7.8.15 → 7.8.17

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
@@ -118,8 +118,10 @@ the run handles one issue. For each issue:
118
118
  checked out, the harness checks out the issue branch again at its commit
119
119
  from before the review. It does the same when the reviewer times out or
120
120
  fails. The state file keeps that commit while the reviewer runs, so when
121
- the run stops during the review, the resumed review first puts the issue
122
- branch back at that commit, and the diff it reads holds no reviewer commit.
121
+ the run stops during the review, the next run that resumes the issue first
122
+ puts the issue branch back at that commit, before the setup command, and
123
+ the diff it reads holds no reviewer commit. A commit that a person adds to
124
+ the branch after a hand-over stays on it.
123
125
  The first reviewer also gets the reply of the implementer, and raises a
124
126
  finding when a behaviour change has no failing run of its test. A later
125
127
  reviewer gets the reply of the last review fixer instead, who quotes the
@@ -401,7 +403,8 @@ A halt that leaves a commit on the base, or a push or revert that may be on
401
403
  it, with checks nobody awaited (`checks error`, `push unknown`,
402
404
  `main checks timeout`, `main checks cancelled`, an error or a failed setup
403
405
  on such a resume before the base is checked, or a stop or kill while the run
404
- pushes a change to the base or waits for the checks of a commit it landed) is
406
+ pushes a change to the base, waits for the checks of a commit it landed, or
407
+ fixes the failed checks of that commit before the fix lands) is
405
408
  saved in the state file of its issue. A stopped issue resumes in the next
406
409
  run; any other waits for a person, so later runs skip it. Either way, no
407
410
  later run lands another change meanwhile: an issue that reaches the landing
package/dist/gate.mjs CHANGED
@@ -5,7 +5,7 @@ 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
- import { revertOrReport, sentence } from './revert.mjs';
8
+ import { revertFailedChecks, revertOrReport, sentence } from './revert.mjs';
9
9
  import { writeState } from './state.mjs';
10
10
  import { HALT_NOTE } from './unsettled.mjs';
11
11
  export async function checkGate(job, sha) {
@@ -20,13 +20,12 @@ export async function checkGate(job, sha) {
20
20
  }
21
21
  return unreadChecks(job, error);
22
22
  }
23
- // Checks that finished leave the base known, so an earlier halt on this issue no longer holds back other landings.
24
- const finished = checks === 'pass' || checks === 'none' || checks === 'fail';
25
- if (finished && job.state.halted === true) {
26
- delete job.state.halted;
27
- await writeState(job.context.repo, job.state);
28
- }
23
+ // Checks that passed leave the base known, so an earlier halt on this issue no longer holds back other landings.
29
24
  if (checks === 'pass' || checks === 'none') {
25
+ if (job.state.halted === true) {
26
+ delete job.state.halted;
27
+ await writeState(job.context.repo, job.state);
28
+ }
30
29
  return GATE_PASSED;
31
30
  }
32
31
  job.mainBroken = true;
@@ -40,6 +39,9 @@ export async function checkGate(job, sha) {
40
39
  if (checks !== 'fail') {
41
40
  return escalateAndFinish(job, `The checks on ${base} did not finish in time. ${HALT_NOTE}`, 'main checks timeout');
42
41
  }
42
+ // Failed checks leave the base broken until the fix lands, so a stop or kill before then keeps other landings back.
43
+ job.state.halted = true;
44
+ await writeState(job.context.repo, job.state);
43
45
  return failedChecksFix(job, sha);
44
46
  }
45
47
  async function waitForChecks(job, sha, fields = {}, restarted = []) {
@@ -96,7 +98,7 @@ async function failedChecksFix(job, sha, refused) {
96
98
  const { repo, config, ports, base } = context;
97
99
  const { round, limit } = budgetUse(job, 'ciFixes');
98
100
  if (round >= limit) {
99
- const reverted = await revertOrReport(job);
101
+ const reverted = await revertFailedChecks(job);
100
102
  return escalateAndFinish(job, `The checks on ${base} failed and the limit of ${limit} check fixes was reached.${reverted}`, 'check budget');
101
103
  }
102
104
  state.ciFixes += 1;
@@ -133,7 +135,7 @@ async function failedChecksFix(job, sha, refused) {
133
135
  }
134
136
  }
135
137
  if (!fix.committed) {
136
- const reverted = await revertOrReport(job);
138
+ const reverted = await revertFailedChecks(job);
137
139
  return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted, fix.aside);
138
140
  }
139
141
  job.repairing = true;
@@ -188,6 +190,6 @@ export async function escalateError(job, error, note, reason) {
188
190
  if (runStopped()) {
189
191
  throw error;
190
192
  }
191
- const reverted = await revertOrReport(job);
193
+ const reverted = await revertFailedChecks(job);
192
194
  return escalateAndFinish(job, `${note}: ${sentence(message(error))}${reverted}`, reason);
193
195
  }
package/dist/pipeline.mjs CHANGED
@@ -4,7 +4,7 @@ import { runStopped } from './children.mjs';
4
4
  import { claimedError, dropClosed, finishClosing, stop, stopNow } from './handover.mjs';
5
5
  import { implement } from './implement.mjs';
6
6
  import { openJob } from './open-job.mjs';
7
- import { reviewRound } from './review.mjs';
7
+ import { reviewRound, settleReview } from './review.mjs';
8
8
  import { skipReport, unclaimedError } from './skip.mjs';
9
9
  import { hasLabel } from './labels.mjs';
10
10
  import { newState, readState, resetState, } from './state.mjs';
@@ -71,6 +71,7 @@ function startState(context, issue, saved, handedOver) {
71
71
  async function work(context, issue, log, state, start, handedOver, pending) {
72
72
  const { job, setup } = await beforeBaseSettled(state, context.base, async () => {
73
73
  const opened = await openJob(context, issue, log, state, start, handedOver, pending);
74
+ await settleReview(opened);
74
75
  return { job: opened, setup: await setUp(opened) };
75
76
  });
76
77
  if (setup.done) {
package/dist/revert.mjs CHANGED
@@ -7,6 +7,15 @@ export async function revertFailedFix(job) {
7
7
  return '';
8
8
  }
9
9
  job.repairing = false;
10
+ return revertFailedChecks(job);
11
+ }
12
+ /** Hands over a fix of failed checks; with no stop, its saved halt gives way, so the run halt alone holds back other landings. */
13
+ export async function revertFailedChecks(job) {
14
+ const { context, state } = job;
15
+ if (state.halted === true && state.pushing === undefined && !runStopped()) {
16
+ delete state.halted;
17
+ await writeState(context.repo, state);
18
+ }
10
19
  return revertOrReport(job);
11
20
  }
12
21
  export async function revertOrReport(job) {
package/dist/review.mjs CHANGED
@@ -71,11 +71,9 @@ function recordVerdict(job, verdict, open) {
71
71
  async function runReviewer(job, earlier) {
72
72
  const { context, issue, log, state, worktree, comments } = job;
73
73
  const { config, ports } = context;
74
- const before = state.reviewing ?? (await ports.revision(worktree));
75
- if (state.reviewing === undefined) {
76
- state.reviewing = before;
77
- await writeState(context.repo, state);
78
- }
74
+ const before = await ports.revision(worktree);
75
+ state.reviewing = before;
76
+ await writeState(context.repo, state);
79
77
  if (await ports.discardChanges(worktree, before, job.branch)) {
80
78
  log.event('review.clean', { round: state.reviewRounds }, 'quiet');
81
79
  }
@@ -103,6 +101,11 @@ async function runReviewer(job, earlier) {
103
101
  }
104
102
  return review.text;
105
103
  }
104
+ export async function settleReview(job) {
105
+ if (job.state.reviewing !== undefined) {
106
+ await undoReview(job, job.state.reviewing);
107
+ }
108
+ }
106
109
  async function undoReview(job, before) {
107
110
  const { context, log, state, worktree } = job;
108
111
  if (await context.ports.discardChanges(worktree, before, job.branch)) {
package/dist/state.mjs CHANGED
@@ -87,13 +87,16 @@ export function newState(issue, branch) {
87
87
  return { issue, phase: 'claimed', branch, ciFixes: 0, reviewRounds: 0, reviewLog: [] };
88
88
  }
89
89
  /**
90
- * Drops the budgets and findings; a hand-over (`handedOver`) also cancels an approval and the closing mark,
90
+ * Drops the budgets and findings; a hand-over (`handedOver`) also cancels an approval, the closing mark and the review start,
91
91
  * so a resume that stops before it finishes is resumed again rather than closed as done.
92
92
  */
93
93
  export function resetState(state, handedOver = false) {
94
- const { handedOver: _handedOver, pendingHandOver: _pending, closing, ...rest } = state;
94
+ const { handedOver: _handedOver, pendingHandOver: _pending, closing, reviewing, ...rest } = state;
95
95
  const phase = handedOver && rest.phase === 'approved' ? 'review' : rest.phase;
96
- const kept = !handedOver && closing !== undefined ? { closing } : {};
96
+ const kept = {
97
+ ...(!handedOver && closing !== undefined ? { closing } : {}),
98
+ ...(!handedOver && reviewing !== undefined ? { reviewing } : {}),
99
+ };
97
100
  return { ...rest, ...kept, phase, ciFixes: 0, commitFixes: 0, reviewRounds: 0, reviewLog: [] };
98
101
  }
99
102
  export async function writeState(repo, state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "7.8.15",
3
+ "version": "7.8.17",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",