next-issue 6.6.98 → 6.6.100
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 +40 -19
- package/dist/agents.mjs +19 -3
- package/dist/gate.mjs +9 -3
- package/dist/handover.mjs +4 -0
- package/dist/land.mjs +52 -13
- package/dist/state.mjs +2 -1
- package/dist/unsettled.mjs +7 -1
- package/dist/worktree-setup.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,12 +151,14 @@ the run handles one issue. For each issue:
|
|
|
151
151
|
fetch fails too, the harness hands the issue to a person with the reason
|
|
152
152
|
`push unknown` and halts, even when the hand-over fails. The state file
|
|
153
153
|
holds the commit during the push, so a run stopped meanwhile, or the
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
resume after that hand-over (once a person answers or takes the label
|
|
155
|
+
off), checks the base and waits for the checks of the commit when it
|
|
156
|
+
landed. Until then, no run lands another change (see below). The
|
|
157
|
+
harness then waits for the checks of the pushed commit on the base
|
|
158
|
+
branch: the GitHub Actions workflow runs that a `push` of the base
|
|
159
|
+
branch started on it, its commit statuses and the check runs of every
|
|
160
|
+
other GitHub App, so checks from another CI service count too. It
|
|
161
|
+
leaves out the check runs of the GitHub Actions
|
|
160
162
|
app, since it judges GitHub Actions by its workflow runs. It leaves out
|
|
161
163
|
workflow runs that any other event (such as `issues`, `issue_comment` or
|
|
162
164
|
`schedule`) started, since GitHub gives such a run the tip of the
|
|
@@ -182,19 +184,21 @@ the run handles one issue. For each issue:
|
|
|
182
184
|
issue to a person with the reason `checks error` and halts, before the
|
|
183
185
|
next change lands. The comment holds the error and says that the landed
|
|
184
186
|
commit is on the base and its checks were not awaited. The state file
|
|
185
|
-
keeps the commit, so the
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
187
|
+
keeps the commit, so the resume after a person answers or takes the
|
|
188
|
+
label off waits for its checks, and until then no run lands another
|
|
189
|
+
change (see below). When the checks pass, the harness marks the state
|
|
190
|
+
file as closing, sets `status:done` and closes the issue. When a run
|
|
191
|
+
stops or dies before the close, the next run sees the mark, sets
|
|
192
|
+
`status:done` and closes the issue, with no new push, revert or
|
|
193
|
+
hand-over. When a run stops or dies after the close, before the state
|
|
194
|
+
file goes away, the next run finds the closed issue through its state
|
|
195
|
+
file and removes the worktree, the local branches and the state file,
|
|
196
|
+
with no new push, revert, label, close or hand-over. A label or close
|
|
197
|
+
that fails for another reason hands the issue over, and it then waits
|
|
198
|
+
for a person like any other hand-over. Then the harness fetches the
|
|
199
|
+
remote and fast-forwards the local base branch to the landed commit
|
|
200
|
+
when that is safe, and the worktree, the local branch and the state
|
|
201
|
+
file go away. A fetch that fails or a fast-forward that is
|
|
198
202
|
not safe leaves the local base branch as it is and writes a `base.behind`
|
|
199
203
|
event, and the issue is still done. When the checks fail, the harness
|
|
200
204
|
reruns the failed GitHub Actions jobs once with
|
|
@@ -302,6 +306,23 @@ broken base branch: it ends `stopped` with the reason `run halted` and keeps
|
|
|
302
306
|
its state, branch and labels. The next run resumes it and lands it with no new
|
|
303
307
|
review.
|
|
304
308
|
|
|
309
|
+
A halt that leaves a commit on the base, or a push or revert that may be on
|
|
310
|
+
it, with checks nobody awaited (`checks error`, `push unknown`,
|
|
311
|
+
`main checks timeout`, `main checks cancelled`, or an error or a failed setup
|
|
312
|
+
on such a resume before the base is checked) is saved in the state file of
|
|
313
|
+
its issue. The issue waits for a person, so later runs skip it, but no
|
|
314
|
+
later run lands another change meanwhile: an issue that reaches the
|
|
315
|
+
landing ends `stopped` with the reason `base unchecked`, keeps its state,
|
|
316
|
+
branch and labels, and halts that run too; the log holds a
|
|
317
|
+
`land.blocked` event with the waiting issues. Once a person answers or
|
|
318
|
+
takes the label off, the issue resumes, checks the base and waits for the
|
|
319
|
+
checks of its commit; when those are known (the issue is done, or its
|
|
320
|
+
commits are reverted or found not on the base), the next run lands the
|
|
321
|
+
held issues again. Such a resume is not held back
|
|
322
|
+
by another halted issue while it only checks its commit already on the
|
|
323
|
+
base; a fix it has to land waits like any other change. The hand-over
|
|
324
|
+
comment says so.
|
|
325
|
+
|
|
305
326
|
The fixer sees the findings of all earlier rounds, not only the last one, with
|
|
306
327
|
its own disputes next to them. From round two, the reviewer judges only the
|
|
307
328
|
earlier findings and any regression.
|
package/dist/agents.mjs
CHANGED
|
@@ -27,15 +27,31 @@ export async function runAgent(recorder, request) {
|
|
|
27
27
|
process.argv[1] = PI_CLI;
|
|
28
28
|
log.event('agent.start', { model: request.model, timeoutMs: request.timeoutMs });
|
|
29
29
|
const session = await openSession(recorder, log, request, agentDir);
|
|
30
|
-
|
|
30
|
+
// pi drops an abort that comes before its run starts (during bindExtensions or the prompt
|
|
31
|
+
// preflight), so remember it and abort again once the run is active, before its first turn.
|
|
32
|
+
let ended = false;
|
|
33
|
+
const end = () => {
|
|
34
|
+
ended = true;
|
|
35
|
+
void session.abort();
|
|
36
|
+
};
|
|
37
|
+
const timer = deadline(request.timeoutMs, end);
|
|
31
38
|
const unsubscribe = session.subscribe((event) => observe(log, event));
|
|
32
|
-
const release = onStop(
|
|
39
|
+
const release = onStop(end);
|
|
33
40
|
try {
|
|
34
41
|
refuseWhenStopped();
|
|
35
42
|
await session.bindExtensions({});
|
|
36
43
|
let result;
|
|
37
44
|
try {
|
|
38
|
-
|
|
45
|
+
if (!ended) {
|
|
46
|
+
await session.prompt(request.prompt, {
|
|
47
|
+
expandPromptTemplates: false,
|
|
48
|
+
preflightResult: (disposition) => {
|
|
49
|
+
if (disposition === 'started' && ended) {
|
|
50
|
+
void session.abort();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
39
55
|
}
|
|
40
56
|
finally {
|
|
41
57
|
// A call that times out, fails or is stopped has spent tokens too.
|
package/dist/gate.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { escalateAndFinish } from './handover.mjs';
|
|
|
7
7
|
import { GATE_FIXED, GATE_PASSED } from './job.mjs';
|
|
8
8
|
import { revertOrReport, sentence } from './revert.mjs';
|
|
9
9
|
import { writeState } from './state.mjs';
|
|
10
|
+
import { HALT_NOTE } from './unsettled.mjs';
|
|
10
11
|
export async function checkGate(job, sha) {
|
|
11
12
|
const { base } = job.context;
|
|
12
13
|
let checks;
|
|
@@ -23,11 +24,15 @@ export async function checkGate(job, sha) {
|
|
|
23
24
|
return GATE_PASSED;
|
|
24
25
|
}
|
|
25
26
|
job.mainBroken = true;
|
|
27
|
+
if (checks !== 'fail') {
|
|
28
|
+
// Checks that never finished leave the base unknown, so later runs land nothing until a person resumes this issue.
|
|
29
|
+
job.state.halted = true;
|
|
30
|
+
}
|
|
26
31
|
if (checks === 'cancelled') {
|
|
27
|
-
return escalateAndFinish(job, `The checks on ${base} were cancelled before they finished
|
|
32
|
+
return escalateAndFinish(job, `The checks on ${base} were cancelled before they finished. ${HALT_NOTE}`, 'main checks cancelled');
|
|
28
33
|
}
|
|
29
34
|
if (checks !== 'fail') {
|
|
30
|
-
return escalateAndFinish(job, `The checks on ${base} did not finish in time
|
|
35
|
+
return escalateAndFinish(job, `The checks on ${base} did not finish in time. ${HALT_NOTE}`, 'main checks timeout');
|
|
31
36
|
}
|
|
32
37
|
return failedChecksFix(job, sha);
|
|
33
38
|
}
|
|
@@ -116,7 +121,8 @@ async function unreadChecks(job, error) {
|
|
|
116
121
|
}
|
|
117
122
|
const { base } = job.context;
|
|
118
123
|
job.mainBroken = true;
|
|
119
|
-
|
|
124
|
+
job.state.halted = true;
|
|
125
|
+
return escalateAndFinish(job, `The read of the checks on ${base} failed: ${sentence(message(error))} The landed commit is on \`${base}\`, and its checks were not awaited. ${HALT_NOTE}`, 'checks error');
|
|
120
126
|
}
|
|
121
127
|
export async function escalateError(job, error, note, reason) {
|
|
122
128
|
if (runStopped()) {
|
package/dist/handover.mjs
CHANGED
|
@@ -182,6 +182,10 @@ function handOverComment(reason) {
|
|
|
182
182
|
}
|
|
183
183
|
export async function claimedError(context, log, issue, state, error, started) {
|
|
184
184
|
const reason = message(error);
|
|
185
|
+
if (error instanceof UnsettledBase) {
|
|
186
|
+
// Saved with the hand-over, so later runs land nothing before the base is checked.
|
|
187
|
+
state.halted = true;
|
|
188
|
+
}
|
|
185
189
|
try {
|
|
186
190
|
const earlier = error instanceof HandOverFailed ? error.pending : undefined;
|
|
187
191
|
await handOver(context, log, issue.number, state, handOverReason(error, reason), earlier);
|
package/dist/land.mjs
CHANGED
|
@@ -5,24 +5,27 @@ import { PUSH_TRIES } from './git-land.mjs';
|
|
|
5
5
|
import { escalateAndFinish, finishDone, stop } from './handover.mjs';
|
|
6
6
|
import { oneAtATime } from './lock.mjs';
|
|
7
7
|
import { revertFailedFix } from './revert.mjs';
|
|
8
|
-
import { writeState } from './state.mjs';
|
|
9
|
-
import { beforeBaseSettled } from './unsettled.mjs';
|
|
8
|
+
import { readState, savedIssues, writeState } from './state.mjs';
|
|
9
|
+
import { beforeBaseSettled, blocksLanding, HALT_NOTE } from './unsettled.mjs';
|
|
10
10
|
export function landApproved(job) {
|
|
11
11
|
return landing(job, () => landLoop(job));
|
|
12
12
|
}
|
|
13
13
|
export function resumeLanding(job, sha) {
|
|
14
|
-
return
|
|
14
|
+
return inLandingLock(job, async () => {
|
|
15
15
|
const { state, context } = job;
|
|
16
16
|
if (await beforeBaseSettled(state, context.base, () => holdsUnlandedFix(job, sha))) {
|
|
17
|
-
job
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return unblocked(job, () => {
|
|
18
|
+
job.mainBroken = true;
|
|
19
|
+
job.repairing = true;
|
|
20
|
+
return landLoop(job);
|
|
21
|
+
});
|
|
20
22
|
}
|
|
23
|
+
// Checking a commit that is already on the base lands nothing, so other halted issues do not hold it back.
|
|
21
24
|
const gate = await checkGate(job, sha);
|
|
22
25
|
if (gate.done) {
|
|
23
26
|
return gate;
|
|
24
27
|
}
|
|
25
|
-
return gate.fixed ? landLoop(job) : finishDone(job);
|
|
28
|
+
return gate.fixed ? unblocked(job, () => landLoop(job)) : finishDone(job);
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
31
|
async function holdsUnlandedFix(job, sha) {
|
|
@@ -34,15 +37,50 @@ async function holdsUnlandedFix(job, sha) {
|
|
|
34
37
|
return !(await ports.isLanded(worktree, base, config.remote));
|
|
35
38
|
}
|
|
36
39
|
function landing(job, work) {
|
|
40
|
+
return inLandingLock(job, () => unblocked(job, work));
|
|
41
|
+
}
|
|
42
|
+
function inLandingLock(job, work) {
|
|
37
43
|
return oneAtATime(`${job.context.repo.root}#land`, async () => {
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
44
|
+
if (job.context.halted) {
|
|
45
|
+
return holdBack(job, 'run halted');
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
await writeState(job.context.repo, job.state);
|
|
43
|
-
return { done: true, report: stop(job, 'run halted') };
|
|
47
|
+
return work();
|
|
44
48
|
});
|
|
45
49
|
}
|
|
50
|
+
/** Runs a step that lands a change, unless an earlier run halted with a commit on the base whose checks nobody read. */
|
|
51
|
+
async function unblocked(job, work) {
|
|
52
|
+
const { context, log } = job;
|
|
53
|
+
const unchecked = await uncheckedIssues(job);
|
|
54
|
+
if (unchecked.length === 0) {
|
|
55
|
+
return work();
|
|
56
|
+
}
|
|
57
|
+
// Landing now would build on a commit whose checks nobody read.
|
|
58
|
+
log.event('land.blocked', { issues: unchecked }, 'quiet');
|
|
59
|
+
context.halted = true;
|
|
60
|
+
const held = await holdBack(job, 'base unchecked');
|
|
61
|
+
return { ...held, report: { ...held.report, halt: true } };
|
|
62
|
+
}
|
|
63
|
+
async function holdBack(job, reason) {
|
|
64
|
+
job.state.phase = 'approved';
|
|
65
|
+
await writeState(job.context.repo, job.state);
|
|
66
|
+
return { done: true, report: stop(job, reason) };
|
|
67
|
+
}
|
|
68
|
+
/** The other saved issues whose halt left a commit on the base with checks nobody awaited. */
|
|
69
|
+
async function uncheckedIssues(job) {
|
|
70
|
+
const { repo, base } = job.context;
|
|
71
|
+
const unchecked = [];
|
|
72
|
+
for (const issue of await savedIssues(repo)) {
|
|
73
|
+
if (issue === job.issue.number) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// An unreadable state file fails its own issue; it does not hold back every landing.
|
|
77
|
+
const state = await readState(repo, issue).catch(() => undefined);
|
|
78
|
+
if (state !== undefined && blocksLanding(state, base)) {
|
|
79
|
+
unchecked.push(issue);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return unchecked.sort((a, b) => a - b);
|
|
83
|
+
}
|
|
46
84
|
async function landLoop(job) {
|
|
47
85
|
for (;;) {
|
|
48
86
|
const pushed = await pushChange(job).catch(async (error) => {
|
|
@@ -85,7 +123,8 @@ async function pushChange(job) {
|
|
|
85
123
|
}));
|
|
86
124
|
if (pushed === undefined) {
|
|
87
125
|
job.mainBroken = true;
|
|
88
|
-
|
|
126
|
+
state.halted = true;
|
|
127
|
+
return escalateAndFinish(job, `The push to ${base} failed and the fetch of ${base} failed too, so the harness cannot tell whether the commit landed. ${HALT_NOTE}`, 'push unknown');
|
|
89
128
|
}
|
|
90
129
|
state.pushing = undefined;
|
|
91
130
|
if (pushed) {
|
package/dist/state.mjs
CHANGED
|
@@ -73,7 +73,8 @@ function isState(value) {
|
|
|
73
73
|
value.reviewLog.every(isReviewRound) &&
|
|
74
74
|
isOptional(value.handedOver, 'boolean') &&
|
|
75
75
|
(value.pendingHandOver === undefined || isPending(value.pendingHandOver)) &&
|
|
76
|
-
isOptional(value.closing, 'boolean')
|
|
76
|
+
isOptional(value.closing, 'boolean') &&
|
|
77
|
+
isOptional(value.halted, 'boolean'));
|
|
77
78
|
}
|
|
78
79
|
export async function savedIssues(repo) {
|
|
79
80
|
const names = (await unlessMissing(() => readdir(stateDir(repo.root)))) ?? [];
|
package/dist/unsettled.mjs
CHANGED
|
@@ -12,8 +12,14 @@ export function heldOnBase(state, base) {
|
|
|
12
12
|
.filter((part) => part !== '')
|
|
13
13
|
.join(', ');
|
|
14
14
|
}
|
|
15
|
+
/** What a halt with an unchecked commit on the base means for the next runs. */
|
|
16
|
+
export const HALT_NOTE = 'The run halts, and no run lands another change until this issue resumes (after an answer or once the label is off) and checks the base.';
|
|
17
|
+
/** Whether this state keeps every run from landing: it halted with a commit on the base whose checks are still unknown. */
|
|
18
|
+
export function blocksLanding(state, base) {
|
|
19
|
+
return state.halted === true && state.closing !== true && heldOnBase(state, base) !== '';
|
|
20
|
+
}
|
|
15
21
|
export function unsettledNote(held, step) {
|
|
16
|
-
return ` ${step} before it checked the base: ${held}, and its checks were not awaited.
|
|
22
|
+
return ` ${step} before it checked the base: ${held}, and its checks were not awaited. ${HALT_NOTE}`;
|
|
17
23
|
}
|
|
18
24
|
/** An error thrown on a resume before it settled the base, while a commit is or may be on it. */
|
|
19
25
|
export class UnsettledBase extends Error {
|
package/dist/worktree-setup.mjs
CHANGED
|
@@ -25,6 +25,7 @@ async function setupFailed(job, setup) {
|
|
|
25
25
|
const unsettled = unsettledBase(job);
|
|
26
26
|
if (unsettled !== '') {
|
|
27
27
|
job.mainBroken = true;
|
|
28
|
+
job.state.halted = true;
|
|
28
29
|
}
|
|
29
30
|
const note = late
|
|
30
31
|
? `The setup command did not finish in ${job.context.config.setupTimeoutMinutes} minutes.`
|