next-issue 6.6.111 → 6.6.113

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
@@ -271,8 +271,12 @@ and comments the reason on the issue, when:
271
271
  - the fixer reports that the checks fail for a reason the change did not cause,
272
272
  such as a test already broken on the base branch or one that fails only under
273
273
  load. It changes nothing and the reason reaches the issue, rather than
274
- the fixer spending its whole budget on a failure it cannot fix. A commit it
275
- makes anyway moves aside, as for a dispute of the findings;
274
+ the fixer spending its whole budget on a failure it cannot fix. The revert
275
+ of the change reuses the worktree, so a change the fixer leaves behind does
276
+ not stay there: its edits are committed with no hooks on top of any commit
277
+ of its own, that commit moves to a new local `<n>-dispute-<commit>` branch,
278
+ and the hand-over comment names that branch. The branch goes away with the
279
+ `<n>` branch when the issue is done;
276
280
  - a fixer disputes or settles the findings and leaves a change behind, either
277
281
  in the worktree or in a commit of its own. A dispute carries a reason, not a
278
282
  diff, so the harness throws none of it away: an unclean worktree stays on
@@ -381,10 +385,12 @@ Press `Ctrl-C` to stop the run step by step:
381
385
  branch that this press kills before any job restarted runs again in the
382
386
  next run, before any fixer.
383
387
 
384
- `SIGTERM` to a command-line run while a command runs, and `SIGTERM` or
385
- `SIGINT` to the worker (as `next-issue stop` sends), act like the third
386
- press: they give back the review round, the check fix and the rerun in the
387
- same way.
388
+ `SIGTERM` to a command-line run while a command or an agent runs, and
389
+ `SIGTERM` or `SIGINT` to the worker (as `next-issue stop` sends), act like
390
+ the third press: they stop the running harness commands and agents, with
391
+ 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` ends a
393
+ command-line run at once.
388
394
 
389
395
  When the reviewer approved the change and the run stopped before its
390
396
  commit reached the base branch, the next run drops those edits and any
package/dist/children.mjs CHANGED
@@ -39,11 +39,13 @@ export function refuseWhenStopped() {
39
39
  }
40
40
  export function onStop(stopper) {
41
41
  const children = current.getStore();
42
+ guard();
42
43
  stoppers.add(stopper);
43
44
  children?.stoppers.add(stopper);
44
45
  return () => {
45
46
  stoppers.delete(stopper);
46
47
  children?.stoppers.delete(stopper);
48
+ unguard();
47
49
  };
48
50
  }
49
51
  /** Runs `undo` (synchronously) if the process is killed, for a step the kill leaves unsettled. */
@@ -66,13 +68,22 @@ export function stopChildren(signal) {
66
68
  process.kill(process.pid, signal);
67
69
  }
68
70
  const onTerminate = () => stopChildren('SIGTERM');
71
+ /** Handles `SIGTERM` while a command or an agent runs, so its process group is stopped too. */
72
+ function guard() {
73
+ if (groups.size === 0 && stoppers.size === 0) {
74
+ process.on('SIGTERM', onTerminate);
75
+ }
76
+ }
77
+ function unguard() {
78
+ if (groups.size === 0 && stoppers.size === 0) {
79
+ process.off('SIGTERM', onTerminate);
80
+ }
81
+ }
69
82
  export function watch(pid) {
70
83
  if (pid === undefined) {
71
84
  return () => undefined;
72
85
  }
73
- if (groups.size === 0) {
74
- process.on('SIGTERM', onTerminate);
75
- }
86
+ guard();
76
87
  groups.add(pid);
77
88
  const children = current.getStore();
78
89
  children?.groups.add(pid);
@@ -83,9 +94,7 @@ export function watch(pid) {
83
94
  }
84
95
  function unwatch(pid) {
85
96
  groups.delete(pid);
86
- if (groups.size === 0) {
87
- process.off('SIGTERM', onTerminate);
88
- }
97
+ unguard();
89
98
  }
90
99
  export function killTree(child) {
91
100
  if (child.pid === undefined) {
package/dist/fix.mjs CHANGED
@@ -9,11 +9,16 @@ import { fallbackTitle, runRole } from './job.mjs';
9
9
  import { fixPrompt, hookPrompt } from './prompts.mjs';
10
10
  import { writeState } from './state.mjs';
11
11
  import { keepTail } from './text.mjs';
12
- export function escalateCheckFix(job, unrelated, checks, after = '') {
12
+ export function escalateCheckFix(job, unrelated, checks, after = '', aside) {
13
13
  if (unrelated === undefined) {
14
14
  return escalateAndFinish(job, `The fixer added no commit for the failed ${checks}.${after}`, 'no fix commit');
15
15
  }
16
- return escalateAndFinish(job, `The ${checks} fail for a reason this change did not cause: ${unrelated}${after}`, 'unrelated failure');
16
+ return escalateAndFinish(job, `The ${checks} fail for a reason this change did not cause: ${unrelated}${savedIn(aside)}${after}`, 'unrelated failure');
17
+ }
18
+ function savedIn(aside) {
19
+ return aside === undefined
20
+ ? ''
21
+ : ` The fixer left a change behind; it is saved in the branch \`${aside}\`.`;
17
22
  }
18
23
  export async function fixRound(job, reason, detail, earlier, kind) {
19
24
  const { context, issue, log, worktree } = job;
@@ -25,11 +30,11 @@ export async function fixRound(job, reason, detail, earlier, kind) {
25
30
  }
26
31
  const unrelated = parseUnrelated(text);
27
32
  if (unrelated !== undefined) {
28
- return disputedFix(job, before, reason, { unrelated });
33
+ return disputedFix(job, before, reason, { unrelated }, kind);
29
34
  }
30
35
  const resolved = kind === 'review' ? parseResolved(text) : undefined;
31
36
  if (resolved !== undefined) {
32
- return disputedFix(job, before, reason, { resolved });
37
+ return disputedFix(job, before, reason, { resolved }, kind);
33
38
  }
34
39
  const subject = parseCommitSubject(text, `fix: address feedback on issue #${issue.number}`);
35
40
  const title = job.state.title;
@@ -54,20 +59,28 @@ export async function runFixer(job, reason, detail, earlier, kind) {
54
59
  function fixBudget(job, kind) {
55
60
  return budgetUse(job, kind === 'review' ? 'reviewRounds' : 'ciFixes');
56
61
  }
57
- async function disputedFix(job, before, reason, note) {
58
- const { context, log, worktree, branch } = job;
62
+ async function disputedFix(job, before, reason, note, kind) {
63
+ const { context, issue, log, worktree, branch } = job;
59
64
  const { ports } = context;
65
+ // The revert after a failed check reuses this worktree, so edits left there would be lost.
66
+ const saved = kind === 'checks' &&
67
+ (await ports.saveEdits(worktree, `fix: edits left by the check fixer\n\nRefs #${issue.number}`));
60
68
  const disputed = await ports.revision(worktree);
61
69
  const moved = disputed !== before;
62
70
  if (moved) {
63
71
  const aside = `${branch}-dispute-${disputed.slice(0, 7)}`;
64
72
  await ports.setAside(worktree, before, aside);
65
- log.event('fix.aside', { branch: aside }, 'quiet');
73
+ log.event('fix.aside', { branch: aside, saved }, 'quiet');
74
+ if (kind === 'checks') {
75
+ return disputedNote(job, reason, note, { stray: true, aside });
76
+ }
66
77
  }
67
- const stray = moved || (await ports.isDirty(worktree));
78
+ return disputedNote(job, reason, note, { stray: moved || (await ports.isDirty(worktree)) });
79
+ }
80
+ function disputedNote(job, reason, note, left) {
68
81
  const event = 'unrelated' in note ? 'fix.unrelated' : 'fix.resolved';
69
- log.event(event, { reason, note: Object.values(note)[0], stray }, 'quiet');
70
- return { committed: false, ...note, stray };
82
+ job.log.event(event, { reason, note: Object.values(note)[0], ...left }, 'quiet');
83
+ return { committed: false, ...note, ...left };
71
84
  }
72
85
  export async function commitWork(job, before, subject, role, commit) {
73
86
  const { context, issue, log, state, worktree } = job;
package/dist/gate.mjs CHANGED
@@ -121,7 +121,7 @@ async function failedChecksFix(job, sha) {
121
121
  }
122
122
  if (!fix.committed) {
123
123
  const reverted = await revertOrReport(job);
124
- return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted);
124
+ return escalateCheckFix(job, fix.unrelated, `checks on ${base}`, reverted, fix.aside);
125
125
  }
126
126
  job.repairing = true;
127
127
  return GATE_FIXED;
package/dist/git.mjs CHANGED
@@ -77,6 +77,15 @@ export async function resetHard(cwd, target) {
77
77
  await git(cwd, ['reset', '--hard', target]);
78
78
  await git(cwd, ['clean', '-fd']);
79
79
  }
80
+ /** Commits every edit in the worktree, with no hooks, so a later checkout cannot throw it away. */
81
+ export async function saveEdits(cwd, commitMessage) {
82
+ if (!(await isDirty(cwd))) {
83
+ return false;
84
+ }
85
+ await git(cwd, ['add', '-A']);
86
+ await git(cwd, ['commit', '--no-verify', '-m', commitMessage]);
87
+ return true;
88
+ }
80
89
  export async function setAside(cwd, target, branch) {
81
90
  await git(cwd, ['branch', branch]);
82
91
  if (await isDirty(cwd)) {
package/dist/ports.mjs CHANGED
@@ -4,7 +4,7 @@ import { run } from './exec.mjs';
4
4
  import { commitAll } from './git-commit.mjs';
5
5
  import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
6
6
  import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
7
- import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, setAside, } from './git.mjs';
7
+ import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, setAside, } from './git.mjs';
8
8
  import { canWrite, closeIssue, commentOnIssue, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
9
9
  import { huntWorktree } from './hunt.mjs';
10
10
  import { ensureLabel, setLabel } from './labels.mjs';
@@ -50,6 +50,7 @@ export const PORTS = {
50
50
  revision,
51
51
  runAgent,
52
52
  runSetup,
53
+ saveEdits,
53
54
  setAside,
54
55
  setLabel,
55
56
  squashOnto,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.111",
3
+ "version": "6.6.113",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",