next-issue 8.8.0 → 9.0.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 CHANGED
@@ -11,6 +11,8 @@ npx -y next-issue@latest start
11
11
 
12
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 of each failed workflow run once, and only a run that fails again 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
+ The harness is built for a flow with as few people in it as possible: people write issues and answer hand-overs, and the harness does the rest. [ADR 0004](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0004-humanless-flow.md) records this principle, its accepted risks and the setup it recommends.
15
+
14
16
  ```mermaid
15
17
  flowchart TD
16
18
  claim[Claim the oldest status:todo issue] --> worktree[Add a worktree and branch]
@@ -216,7 +218,11 @@ the run handles one issue. For each issue:
216
218
  holds the commit during the push, so a run stopped meanwhile, or the
217
219
  resume after that hand-over (once a person answers or takes the label
218
220
  off), checks the base and waits for the checks of the commit when it
219
- landed. Until then, no run lands another change (see below). The
221
+ landed. Until then, no run lands another change (see below). Once the
222
+ commit lands, the harness fetches the remote and fast-forwards the local
223
+ base branch to it when that is safe. A fetch that fails or a
224
+ fast-forward that is not safe leaves the local base branch as it is and
225
+ writes a `base.behind` event, and the landing goes on. The
220
226
  harness then waits for the checks of the pushed commit on the base
221
227
  branch: the GitHub Actions workflow runs that a `push` of the base
222
228
  branch started on it, its commit statuses and the check runs of every
@@ -274,14 +280,10 @@ the run handles one issue. For each issue:
274
280
  file and removes the worktree, the local branches and the state file,
275
281
  with no new push, revert, label, close or hand-over. A label or close
276
282
  that fails for another reason hands the issue over, and it then waits
277
- for a person like any other hand-over. Then the harness fetches the
278
- remote and fast-forwards the local base branch to the landed commit
279
- when that is safe, and the worktree, the local branch and the state
280
- file go away. A fetch that fails or a fast-forward that is
281
- not safe leaves the local base branch as it is and writes a `base.behind`
282
- event, and the issue is still done. When the checks fail, the harness
283
+ for a person like any other hand-over. Then the worktree, the local
284
+ branch and the state file go away. When the checks fail, the harness
283
285
  reruns the failed jobs of each failed GitHub Actions workflow run once
284
- with `gh run rerun <id> --failed`, records a `main-checks.rerun` event
286
+ with `gh run rerun <id> --failed`, records a `ci-checks.rerun` event
285
287
  and waits again once the runs restart. A failed run whose failed jobs
286
288
  were already rerun (its attempt on GitHub is above 1) is not rerun
287
289
  again, so a resumed run reruns only the runs not rerun yet. A failure
@@ -298,7 +300,7 @@ the run handles one issue. For each issue:
298
300
  harness still waits for the checks again, counting each restarted run as
299
301
  running until a later attempt of it completes, so the fixer never runs
300
302
  while a rerun is queued or in progress. When the rerun cannot start (no
301
- run restarted, a `main-checks.rerun-failed` event), or the checks
303
+ run restarted, a `ci-checks.rerun-failed` event), or the checks
302
304
  fail again with no run left to rerun, the fixer gets their logs from the check budget (for a check
303
305
  from another CI service, only its name and link), and its fix
304
306
  lands the same way. When the fixer cannot fix them, its fix cannot land,
@@ -309,7 +311,9 @@ the run handles one issue. For each issue:
309
311
  other `push unknown`. A revert
310
312
  push that the remote refuses, for example because the base moved, makes
311
313
  the revert again on the new base, three times at most. A failed revert
312
- push that the base holds after a fetch counts as landed. When that fetch
314
+ push that the base holds after a fetch counts as landed. Once the revert
315
+ lands, the harness fast-forwards the local base branch to it, as after a
316
+ landed commit. When that fetch
313
317
  fails too, the revert may be on the base with checks nobody awaited: the
314
318
  harness reports it so, saves the halt and blocks later landings. The state file holds the
315
319
  revert commit during the push, so a run stopped meanwhile checks the base
@@ -569,6 +573,12 @@ on a repository where you trust the writers, or run it in a container.
569
573
  [ADR 0001](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0001-reviewer-isolation.md) records why the reviewer
570
574
  keeps a full shell, and which other options were considered.
571
575
 
576
+ No person checks a change before it lands. To replace those checks,
577
+ [ADR 0004](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0004-humanless-flow.md)
578
+ recommends a non-empty `checks` gate, a different model for the reviewer than
579
+ for the implementer and the fixer in `models`, and running the whole harness in
580
+ a container.
581
+
572
582
  ## Observability
573
583
 
574
584
  Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
@@ -593,7 +603,7 @@ get the full summary object there instead, so the harness fits in a pipe. All
593
603
  progress goes to standard error.
594
604
 
595
605
  Recorded for each step: `claim`, `comments`, `reply`, `worktree`, `setup`,
596
- `editors`, `implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `main-checks`, `revert` and `hunt`, each with a
606
+ `editors`, `implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `ci-checks`, `revert` and `hunt`, each with a
597
607
  `.start`, `.end` or `.error` event and a duration in `ms`. Every `git` and `gh`
598
608
  command is recorded with its exit code and duration. A `tool` event holds the
599
609
  tool name, and for a `bash` tool the command too. Each agent call adds a `usage`
@@ -116,7 +116,7 @@ function baseState(runs, external) {
116
116
  }
117
117
  return checks.some((entry) => entry.conclusion === CUT) ? 'cut' : 'pass';
118
118
  }
119
- export function waitForBaseChecks(repo, sha, branch, options, restarted = [], ignored = []) {
119
+ export function waitForCiChecks(repo, sha, branch, options, restarted = [], ignored = []) {
120
120
  let read = {
121
121
  runs: [],
122
122
  external: [],
@@ -132,7 +132,7 @@ export function waitForBaseChecks(repo, sha, branch, options, restarted = [], ig
132
132
  watch: async () => (read.rerunning ? 'pending' : baseState(read.runs, read.external)),
133
133
  }, options);
134
134
  }
135
- export async function rerunFailedBase(repo, sha, branch, started = () => { }, ignored = []) {
135
+ export async function rerunFailedCi(repo, sha, branch, started = () => { }, ignored = []) {
136
136
  const failed = (await baseRuns(repo, sha, branch, ignored)).filter(rerunnable);
137
137
  for (const entry of failed) {
138
138
  await rerun(repo, entry.databaseId);
@@ -164,7 +164,7 @@ async function waitForRestart(repo, sha, branch, failed, ignored) {
164
164
  await delay(secondsToMs(1));
165
165
  }
166
166
  }
167
- export async function failedBaseLogs(repo, sha, branch, maxChars, ignored = []) {
167
+ export async function failedCiLogs(repo, sha, branch, maxChars, ignored = []) {
168
168
  const failed = (await baseRuns(repo, sha, branch, ignored)).filter(failedRun).flatMap((entry) => entry.jobs === undefined
169
169
  ? [{ heading: `## ${entry.name}`, view: [String(entry.databaseId)] }]
170
170
  : entry.jobs.filter(failedRun).map((job) => ({
package/dist/gate.mjs CHANGED
@@ -50,8 +50,8 @@ export async function checkGate(job, sha) {
50
50
  async function waitForChecks(job, sha, fields = {}, restarted = []) {
51
51
  const { context, log } = job;
52
52
  const { repo, config, ports } = context;
53
- const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true), restarted, config.ignoredChecks));
54
- log.event('main-checks.state', { state: checks, ...fields });
53
+ const checks = await log.step('ci-checks', { sha, ...fields }, () => ports.waitForCiChecks(repo, sha, context.base, checkWaiting(config, true), restarted, config.ignoredChecks));
54
+ log.event('ci-checks.state', { state: checks, ...fields });
55
55
  return checks;
56
56
  }
57
57
  /** Reruns the failed jobs of each failed workflow run once; GitHub keeps the attempts, so a resume reruns only runs not rerun yet. */
@@ -73,22 +73,22 @@ async function rerunFailed(job, sha) {
73
73
  const { context, log } = job;
74
74
  const restarted = [];
75
75
  try {
76
- const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, (run) => {
76
+ const runs = await context.ports.rerunFailedCi(context.repo, sha, context.base, (run) => {
77
77
  restarted.push(run);
78
78
  }, context.config.ignoredChecks);
79
79
  // An empty list tells why the fixer starts with no rerun: no failed workflow run is left to rerun.
80
- log.event('main-checks.rerun', { sha, runs });
80
+ log.event('ci-checks.rerun', { sha, runs });
81
81
  }
82
82
  catch (error) {
83
83
  if (runStopped()) {
84
84
  throw error;
85
85
  }
86
86
  if (restarted.length === 0) {
87
- log.event('main-checks.rerun-failed', { sha, error: asError(error).message });
87
+ log.event('ci-checks.rerun-failed', { sha, error: asError(error).message });
88
88
  return restarted;
89
89
  }
90
90
  // Some runs restarted, so the fixer waits for them rather than getting a failure with no log.
91
- log.event('main-checks.rerun', {
91
+ log.event('ci-checks.rerun', {
92
92
  sha,
93
93
  runs: restarted.map((run) => String(run.id)),
94
94
  error: asError(error).message,
@@ -108,13 +108,13 @@ async function failedChecksFix(job, sha, refused) {
108
108
  await writeState(repo, state);
109
109
  let logs;
110
110
  try {
111
- logs = await refundOnKill(job, 'ciFixes', () => ports.failedBaseLogs(repo, sha, base, config.logMaxChars, config.ignoredChecks));
111
+ logs = await refundOnKill(job, 'ciFixes', () => ports.failedCiLogs(repo, sha, base, config.logMaxChars, config.ignoredChecks));
112
112
  }
113
113
  catch (error) {
114
114
  await refundStopped(job);
115
115
  return escalateError(job, error, `The read of the failed checks on ${base} failed`, 'logs error');
116
116
  }
117
- log.event('main-checks.logs', { chars: logs.length });
117
+ log.event('ci-checks.logs', { chars: logs.length });
118
118
  let fix;
119
119
  try {
120
120
  fix = await refundOnKill(job, 'ciFixes', () => fixRound(job, `The checks on ${base} failed after the change landed there.${refusedNote(refused)}`, logs, [], 'checks'));
package/dist/handover.mjs CHANGED
@@ -44,7 +44,6 @@ export async function finishDone(job) {
44
44
  await setStatus(context, issue.number, context.config.labels.done);
45
45
  await context.ports.closeIssue(context.repo, issue.number);
46
46
  }
47
- await updateLocalBase(job);
48
47
  return { done: true, report: await finish(job, 'done') };
49
48
  }
50
49
  export async function finishClosing(context, issue, log, state, started) {
@@ -83,14 +82,6 @@ export async function dropClosed(context, log, issue, branch) {
83
82
  ms: 0,
84
83
  };
85
84
  }
86
- async function updateLocalBase(job) {
87
- const { context, log } = job;
88
- const { repo, ports, config, base } = context;
89
- const updated = await oneAtATime(repo.root, () => ports.fastForwardBase(repo, base, config.remote)).catch(() => false);
90
- if (!updated) {
91
- log.event('base.behind', { base }, 'quiet');
92
- }
93
- }
94
85
  export function stop(job, reason) {
95
86
  job.log.event('issue.stop', { phase: job.state.phase, reason }, 'quiet');
96
87
  return jobReport(job, 'stopped', reason);
package/dist/land.mjs CHANGED
@@ -2,6 +2,7 @@ import { runStopped } from './children.mjs';
2
2
  import { rebase } from './conflict.mjs';
3
3
  import { checkGate, escalateError } from './gate.mjs';
4
4
  import { PUSH_TRIES } from './git-land.mjs';
5
+ import { updateLocalBase } from './local-base.mjs';
5
6
  import { localChecks } from './local-checks.mjs';
6
7
  import { escalateAndFinish, finishDone, stop } from './handover.mjs';
7
8
  import { oneAtATime } from './lock.mjs';
@@ -146,6 +147,7 @@ async function pushChange(job) {
146
147
  await writeState(repo, state);
147
148
  if (pushed) {
148
149
  job.repairing = false;
150
+ await updateLocalBase(job);
149
151
  return sha;
150
152
  }
151
153
  attempt += 1;
@@ -0,0 +1,9 @@
1
+ import { oneAtATime } from './lock.mjs';
2
+ export async function updateLocalBase(job) {
3
+ const { context, log } = job;
4
+ const { repo, ports, config, base } = context;
5
+ const updated = await oneAtATime(repo.root, () => ports.fastForwardBase(repo, base, config.remote)).catch(() => false);
6
+ if (!updated) {
7
+ log.event('base.behind', { base }, 'quiet');
8
+ }
9
+ }
package/dist/ports.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { runAgent } from './agents.mjs';
2
- import { failedBaseLogs, rerunFailedBase, waitForBaseChecks } from './base-checks.mjs';
2
+ import { failedCiLogs, rerunFailedCi, waitForCiChecks } from './ci-checks.mjs';
3
3
  import { run } from './exec.mjs';
4
4
  import { commitAll } from './git-commit.mjs';
5
5
  import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
@@ -34,7 +34,7 @@ export const PORTS = {
34
34
  disputeBranches,
35
35
  editIssueBody,
36
36
  ensureLabel,
37
- failedBaseLogs,
37
+ failedCiLogs,
38
38
  fastForwardBase,
39
39
  findWorktree,
40
40
  huntWorktree,
@@ -52,7 +52,7 @@ export const PORTS = {
52
52
  removeWorktree,
53
53
  reopenIssue,
54
54
  repositorySlug,
55
- rerunFailedBase,
55
+ rerunFailedCi,
56
56
  resetToBase,
57
57
  revertOnBase,
58
58
  revision,
@@ -67,5 +67,5 @@ export const PORTS = {
67
67
  startMerge,
68
68
  threadComments,
69
69
  viewIssue,
70
- waitForBaseChecks,
70
+ waitForCiChecks,
71
71
  };
package/dist/revert.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { runStopped } from './children.mjs';
2
2
  import { message } from './errors.mjs';
3
+ import { updateLocalBase } from './local-base.mjs';
3
4
  import { writeState } from './state.mjs';
4
5
  import { HALT_NOTE, releaseSettled } from './unsettled.mjs';
5
6
  export async function revertFailedFix(job) {
@@ -80,5 +81,6 @@ export async function revert(job) {
80
81
  restoreChange(state);
81
82
  releaseSettled(state);
82
83
  await writeState(repo, state);
84
+ await updateLocalBase(job);
83
85
  return ` The harness reverted the change on ${base}.`;
84
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "8.8.0",
3
+ "version": "9.0.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",