next-issue 6.6.5 → 6.6.6

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
@@ -110,17 +110,23 @@ the run handles one issue. For each issue:
110
110
  and hands the issue to a person with the reason `merge conflict`. The
111
111
  harness then pushes the commit to the base branch, without force. A push
112
112
  that the remote refuses, for example because the base moved, starts the
113
- rebase again, three times at most. The harness then waits for the checks
114
- of the pushed commit on the base branch. A repository that reports no
115
- check keeps asking for `checkGraceSeconds`. A pending state waits again,
116
- up to `checkTimeoutMinutes`. A read that fails is tried three times. When
117
- the checks pass, the harness closes the issue and sets `status:done`,
118
- fetches the remote and fast-forwards the local base branch to the landed
119
- commit when that is safe, and the worktree, the local branch and the state
120
- file go away. A fetch that fails or a fast-forward that is not safe leaves
121
- the local base branch as it is and writes a `base.behind` event, and the
122
- issue is still done. When the checks fail, the harness reruns the failed
123
- jobs once with `gh run rerun <id> --failed`, records a
113
+ rebase again, three times at most. When the push fails, the harness
114
+ fetches the base first, and treats the push as landed when the base holds
115
+ the commit, for example after a timeout. When that fetch fails too, the
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
121
+ that reports no check keeps asking for `checkGraceSeconds`. A pending state
122
+ waits again, up to `checkTimeoutMinutes`. A read that fails is tried three
123
+ times. When the checks pass, the harness closes the issue and sets
124
+ `status:done`, fetches the remote and fast-forwards the local base branch
125
+ to the landed commit when that is safe, and the worktree, the local branch
126
+ and the state file go away. A fetch that fails or a fast-forward that is
127
+ not safe leaves the local base branch as it is and writes a `base.behind`
128
+ event, and the issue is still done. When the checks fail, the harness
129
+ reruns the failed jobs once with `gh run rerun <id> --failed`, records a
124
130
  `main-checks.rerun` event, saves the rerun in the state file and waits
125
131
  again once the runs restart. When the rerun cannot start, or the checks
126
132
  fail again, the fixer gets their logs from the check budget, and its fix lands
@@ -3,6 +3,7 @@ import { resumeLanding } from './land.mjs';
3
3
  import { writeState } from './state.mjs';
4
4
  export async function enterReview(job) {
5
5
  const { context, state } = job;
6
+ await settlePush(job);
6
7
  const landed = state.landed?.at(-1);
7
8
  if (landed !== undefined) {
8
9
  return resumeLanding(job, landed);
@@ -11,3 +12,16 @@ export async function enterReview(job) {
11
12
  await writeState(context.repo, state);
12
13
  return ROUND_CONTINUE;
13
14
  }
15
+ async function settlePush(job) {
16
+ const { context, state, worktree } = job;
17
+ const { repo, config, ports, base } = context;
18
+ const sha = state.pushing;
19
+ if (sha === undefined) {
20
+ return;
21
+ }
22
+ if (await ports.isOnBase(worktree, base, config.remote, sha)) {
23
+ state.landed = [...(state.landed ?? []), sha];
24
+ }
25
+ state.pushing = undefined;
26
+ await writeState(repo, state);
27
+ }
package/dist/git.mjs CHANGED
@@ -98,6 +98,9 @@ export async function isAncestor(cwd, ancestor, descendant) {
98
98
  export async function isLanded(cwd, base, remote) {
99
99
  return isAncestor(cwd, 'HEAD', remoteRef(remote, base));
100
100
  }
101
+ export async function isOnBase(cwd, base, remote, sha) {
102
+ return isAncestor(cwd, sha, await fetchBase(cwd, base, remote));
103
+ }
101
104
  export async function deleteBranch(repo, branch) {
102
105
  return succeeds(repo.root, ['branch', '-D', branch]);
103
106
  }
package/dist/land.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { runStopped } from './children.mjs';
1
2
  import { rebase } from './conflict.mjs';
2
3
  import { checkGate } from './gate.mjs';
3
4
  import { PUSH_TRIES } from './git-land.mjs';
@@ -60,10 +61,25 @@ async function pushChange(job) {
60
61
  return rebased;
61
62
  }
62
63
  const sha = await ports.revision(worktree);
63
- const pushed = await log.step('land', { base, sha }, () => ports.pushToBase(worktree, config.remote, base));
64
+ state.pushing = sha;
65
+ await writeState(repo, state);
66
+ const pushed = await log.step('land', { base, sha }, async () => (await ports.pushToBase(worktree, config.remote, base)) ||
67
+ ports.isOnBase(worktree, base, config.remote, sha).catch((error) => {
68
+ if (runStopped()) {
69
+ throw error;
70
+ }
71
+ return undefined;
72
+ }));
73
+ if (pushed === undefined) {
74
+ job.mainBroken = true;
75
+ return escalateAndFinish(job, `The push to ${base} failed and the fetch of ${base} failed too, so the harness cannot tell whether the commit landed.`, 'push unknown');
76
+ }
77
+ state.pushing = undefined;
64
78
  if (pushed) {
65
79
  state.landed = [...(state.landed ?? []), sha];
66
- await writeState(repo, state);
80
+ }
81
+ await writeState(repo, state);
82
+ if (pushed) {
67
83
  job.repairing = false;
68
84
  return sha;
69
85
  }
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, revertOnBase, squashOnto } from './git-land.mjs';
6
6
  import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
7
- import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, latestSubject, push, resetToBase, revision, setAside, } from './git.mjs';
7
+ import { deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, setAside, } from './git.mjs';
8
8
  import { canWrite, closeIssue, commentOnIssue, issueComments, openBlockers, openIssues, reopenIssue, threadComments, viewIssue, } from './github.mjs';
9
9
  import { huntWorktree } from './hunt.mjs';
10
10
  import { ensureLabel, setLabel } from './labels.mjs';
@@ -33,6 +33,7 @@ export const PORTS = {
33
33
  huntWorktree,
34
34
  isDirty,
35
35
  isLanded,
36
+ isOnBase,
36
37
  issueComments,
37
38
  latestSubject,
38
39
  openBlockers,
package/dist/state.mjs CHANGED
@@ -56,6 +56,7 @@ function isState(value) {
56
56
  typeof value.ciFixes === 'number' &&
57
57
  isOptional(value.commitFixes, 'number') &&
58
58
  (value.landed === undefined || isLanded(value.landed)) &&
59
+ isOptional(value.pushing, 'string') &&
59
60
  isOptional(value.rerun, 'string') &&
60
61
  typeof value.reviewRounds === 'number' &&
61
62
  Array.isArray(value.reviewLog) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.5",
3
+ "version": "6.6.6",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",