next-issue 5.0.0 → 5.1.0
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 +5 -2
- package/dist/base-checks.mjs +23 -2
- package/dist/gate.mjs +27 -4
- package/dist/ports.mjs +2 -1
- package/dist/state.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npx -y next-issue@latest
|
|
|
9
9
|
|
|
10
10
|
## Overview
|
|
11
11
|
|
|
12
|
-
The harness claims the oldest open issue with the `status:todo` label and gives it its own git worktree and branch. An implementer agent does the work and the harness commits it. A reviewer agent judges the diff, and a fixer agent deals with any open finding, and the review runs again. With no open finding left, the harness rebases the change onto the base branch as one commit, pushes it there with no pull request and waits for the checks of that commit.
|
|
12
|
+
The harness claims the oldest open issue with the `status:todo` label and gives it its own git worktree and branch. An implementer agent does the work and the harness commits it. A reviewer agent judges the diff, and a fixer agent deals with any open finding, and the review runs again. With no open finding left, the harness rebases the change onto the base branch as one commit, pushes it there with no pull request and waits for the checks of that commit. On a red build the harness reruns the failed jobs once, and only a second red build goes to the fixer, whose fix lands the same way. When the checks pass, the issue is closed and gets `status:done`. When a budget runs out or the work cannot go on, the issue gets `status:needs-human` and goes to a person. Then the harness takes the next issue.
|
|
13
13
|
|
|
14
14
|
```mermaid
|
|
15
15
|
flowchart TD
|
|
@@ -109,7 +109,10 @@ the run handles one issue. For each issue:
|
|
|
109
109
|
up to `checkTimeoutMinutes`. A read that fails is tried three times. When
|
|
110
110
|
the checks pass, the harness closes the issue and sets `status:done`, and
|
|
111
111
|
the worktree, the local branch and the state file go away. When the checks
|
|
112
|
-
fail, the
|
|
112
|
+
fail, the harness reruns the failed jobs once with `gh run rerun <id>
|
|
113
|
+
--failed`, records a `main-checks.rerun` event, saves the rerun in the
|
|
114
|
+
state file and waits again once the runs restart. When the rerun cannot
|
|
115
|
+
start, or the checks fail again, the fixer gets their logs from the check budget, and its fix lands
|
|
113
116
|
the same way. When the fixer cannot fix them, its fix cannot land, or the
|
|
114
117
|
budget runs out, the harness reverts every commit of the change on the
|
|
115
118
|
base branch, pushes the revert and hands the issue to a person. A resume
|
package/dist/base-checks.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
1
2
|
import { pollChecks } from './check-poll.mjs';
|
|
2
|
-
import {
|
|
3
|
+
import { secondsToMs } from './durations.mjs';
|
|
4
|
+
import { gh, ghJson } from './gh.mjs';
|
|
3
5
|
import { runLogs } from './run-logs.mjs';
|
|
6
|
+
const RESTART_TRIES = 10;
|
|
4
7
|
const FAILED_CONCLUSIONS = new Set(['failure', 'timed_out', 'startup_failure']);
|
|
5
8
|
async function baseRuns(repo, sha) {
|
|
6
9
|
return ghJson(repo, [
|
|
@@ -9,7 +12,7 @@ async function baseRuns(repo, sha) {
|
|
|
9
12
|
'--commit',
|
|
10
13
|
sha,
|
|
11
14
|
'--json',
|
|
12
|
-
'databaseId,name,status,conclusion',
|
|
15
|
+
'databaseId,name,status,conclusion,attempt',
|
|
13
16
|
]);
|
|
14
17
|
}
|
|
15
18
|
function failedRun(entry) {
|
|
@@ -29,6 +32,24 @@ export function waitForBaseChecks(repo, sha, options) {
|
|
|
29
32
|
watch: async () => baseState(await baseRuns(repo, sha)),
|
|
30
33
|
}, options);
|
|
31
34
|
}
|
|
35
|
+
export async function rerunFailedBase(repo, sha) {
|
|
36
|
+
const failed = (await baseRuns(repo, sha)).filter(failedRun);
|
|
37
|
+
for (const entry of failed) {
|
|
38
|
+
await gh(repo, ['run', 'rerun', String(entry.databaseId), '--failed']);
|
|
39
|
+
}
|
|
40
|
+
await waitForRestart(repo, sha, failed);
|
|
41
|
+
return failed.map((entry) => String(entry.databaseId));
|
|
42
|
+
}
|
|
43
|
+
async function waitForRestart(repo, sha, failed) {
|
|
44
|
+
for (let attempt = 1; attempt <= RESTART_TRIES; attempt += 1) {
|
|
45
|
+
const runs = await baseRuns(repo, sha);
|
|
46
|
+
const restarted = failed.every((entry) => runs.some((run) => run.databaseId === entry.databaseId && run.attempt > entry.attempt));
|
|
47
|
+
if (restarted) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await delay(secondsToMs(1));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
32
53
|
export async function failedBaseLogs(repo, sha, maxChars) {
|
|
33
54
|
const failed = (await baseRuns(repo, sha))
|
|
34
55
|
.filter(failedRun)
|
package/dist/gate.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { budgetUse } from './budget.mjs';
|
|
2
2
|
import { checkWaiting } from './check-poll.mjs';
|
|
3
|
+
import { asError } from './errors.mjs';
|
|
3
4
|
import { escalateCheckFix, fixRound } from './fix.mjs';
|
|
4
5
|
import { escalateAndFinish } from './handover.mjs';
|
|
5
6
|
import { GATE_FIXED, GATE_PASSED } from './job.mjs';
|
|
6
7
|
import { revert } from './revert.mjs';
|
|
7
8
|
import { writeState } from './state.mjs';
|
|
8
9
|
export async function checkGate(job, sha) {
|
|
9
|
-
const {
|
|
10
|
-
const
|
|
11
|
-
const checks = await log.step('main-checks', { sha }, () => ports.waitForBaseChecks(repo, sha, checkWaiting(config, true)));
|
|
12
|
-
log.event('main-checks.state', { state: checks });
|
|
10
|
+
const { base } = job.context;
|
|
11
|
+
const checks = await rerunOnce(job, sha, await waitForChecks(job, sha));
|
|
13
12
|
if (checks === 'pass' || checks === 'none') {
|
|
14
13
|
return GATE_PASSED;
|
|
15
14
|
}
|
|
@@ -19,6 +18,30 @@ export async function checkGate(job, sha) {
|
|
|
19
18
|
}
|
|
20
19
|
return failedChecksFix(job, sha);
|
|
21
20
|
}
|
|
21
|
+
async function waitForChecks(job, sha, fields = {}) {
|
|
22
|
+
const { context, log } = job;
|
|
23
|
+
const { repo, config, ports } = context;
|
|
24
|
+
const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, checkWaiting(config, true)));
|
|
25
|
+
log.event('main-checks.state', { state: checks, ...fields });
|
|
26
|
+
return checks;
|
|
27
|
+
}
|
|
28
|
+
async function rerunOnce(job, sha, checks) {
|
|
29
|
+
const { context, log, state } = job;
|
|
30
|
+
if (checks !== 'fail' || state.rerun === sha) {
|
|
31
|
+
return checks;
|
|
32
|
+
}
|
|
33
|
+
state.rerun = sha;
|
|
34
|
+
await writeState(context.repo, state);
|
|
35
|
+
try {
|
|
36
|
+
const runs = await context.ports.rerunFailedBase(context.repo, sha);
|
|
37
|
+
log.event('main-checks.rerun', { sha, runs });
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
log.event('main-checks.rerun-failed', { sha, error: asError(error).message });
|
|
41
|
+
return checks;
|
|
42
|
+
}
|
|
43
|
+
return waitForChecks(job, sha, { rerun: true });
|
|
44
|
+
}
|
|
22
45
|
async function failedChecksFix(job, sha) {
|
|
23
46
|
const { context, log, state } = job;
|
|
24
47
|
const { repo, config, ports, base } = context;
|
package/dist/ports.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { runAgent } from './agents.mjs';
|
|
2
|
-
import { failedBaseLogs, waitForBaseChecks } from './base-checks.mjs';
|
|
2
|
+
import { failedBaseLogs, rerunFailedBase, waitForBaseChecks } from './base-checks.mjs';
|
|
3
3
|
import { run } from './exec.mjs';
|
|
4
4
|
import { commitAll } from './git-commit.mjs';
|
|
5
5
|
import { pushToBase, revertOnBase, squashOnto } from './git-land.mjs';
|
|
@@ -36,6 +36,7 @@ export const PORTS = {
|
|
|
36
36
|
pushToBase,
|
|
37
37
|
removeWorktree,
|
|
38
38
|
reopenIssue,
|
|
39
|
+
rerunFailedBase,
|
|
39
40
|
resetToBase,
|
|
40
41
|
revertOnBase,
|
|
41
42
|
revision,
|
package/dist/state.mjs
CHANGED
|
@@ -50,6 +50,7 @@ function isState(value) {
|
|
|
50
50
|
typeof value.ciFixes === 'number' &&
|
|
51
51
|
isOptional(value.commitFixes, 'number') &&
|
|
52
52
|
(value.landed === undefined || isLanded(value.landed)) &&
|
|
53
|
+
isOptional(value.rerun, 'string') &&
|
|
53
54
|
typeof value.reviewRounds === 'number' &&
|
|
54
55
|
Array.isArray(value.reviewLog) &&
|
|
55
56
|
value.reviewLog.every(isReviewRound) &&
|