next-issue 6.6.84 → 6.6.86

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
@@ -154,13 +154,15 @@ the run handles one issue. For each issue:
154
154
  next run after that hand-over, checks the base on resume and waits for
155
155
  the checks of the commit when it landed. The harness then waits for the
156
156
  checks of the pushed commit on the base branch: the GitHub Actions
157
- workflow runs that a `push` event started on it, its commit statuses
158
- and the check runs of every other GitHub App, so checks from another CI
159
- service count too. It leaves out the check runs of the GitHub Actions
157
+ workflow runs that a `push` of the base branch started on it, its
158
+ commit statuses and the check runs of every other GitHub App, so checks
159
+ from another CI service count too. It leaves out the check runs of the GitHub Actions
160
160
  app, since it judges GitHub Actions by its workflow runs. It leaves out
161
161
  workflow runs that any other event (such as `issues`, `issue_comment` or
162
162
  `schedule`) started, since GitHub gives such a run the tip of the
163
- default branch as its commit. A failed or errored commit status, or a
163
+ default branch as its commit. It also leaves out the `push` runs that a
164
+ push of a tag or of another branch started on the same commit, such as
165
+ a release or a deploy. A failed or errored commit status, or a
164
166
  check run that ends with `failure`, `timed_out` or `action_required`,
165
167
  fails the checks. When any check ends `cancelled`, for example because
166
168
  a later push cancelled the workflow run, that check never finished,
@@ -493,27 +495,27 @@ because no pull request is opened.
493
495
  }
494
496
  ```
495
497
 
496
- | Field | Default | Effect |
497
- | ----------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
498
- | `remote` | `origin` | The git remote for the repository and the branches |
499
- | `issueLimit` | `100` | The maximum number of open issues to read. With `labels.ready` set, only issues with the ready, in-progress or in-review label count |
500
- | `concurrency` | `1` | The most issues that a run handles at the same time |
501
- | `huntCap` | `1` | With `--hunt`, the hunter hunts only while fewer ready issues than this wait besides the running ones |
502
- | `maxCiFixes` | `5` | The budget for check fixes per issue |
503
- | `maxCommitFixes` | `10` | The budget for fixes of a commit that a git hook stopped, per issue |
504
- | `maxReviewRounds` | `5` | The budget for review rounds per issue |
505
- | `checkIntervalSeconds` | `15` | The time between two check states, at most `2147483` |
506
- | `checkGraceSeconds` | `60` | The time to wait for the first check to show, and for more checks after they all pass |
507
- | `checkTimeoutMinutes` | `60` | The limit for one check wait, at most `35791` |
508
- | `agentTimeoutMinutes` | `30` | The limit for one agent call, at most `35791` |
509
- | `setupTimeoutMinutes` | `15` | The limit for the setup command, at most `35791` |
510
- | `commandTimeoutMinutes` | `10` | The limit for one `git` or `gh` command, at most `35791` |
511
- | `logMaxChars` | `20000` | The maximum length of the failed job logs, shared between the failed jobs |
512
- | `diffMaxChars` | `60000` | The maximum length of the diff that the reviewer reads |
513
- | `keepRunDays` | `7` | The number of days to keep the run files; `0` keeps them all |
514
- | `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer |
515
- | `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
516
- | `labels` | see above | The names of the labels that the harness reads and sets |
498
+ | Field | Default | Effect |
499
+ | ----------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
500
+ | `remote` | `origin` | The git remote for the repository and the branches |
501
+ | `issueLimit` | `100` | The maximum number of open issues to read. With `labels.ready` set, only issues with the ready, in-progress or in-review label count |
502
+ | `concurrency` | `1` | The most issues that a run handles at the same time |
503
+ | `huntCap` | `1` | With `--hunt`, the hunter hunts only while fewer ready issues than this wait besides the running ones |
504
+ | `maxCiFixes` | `5` | The budget for check fixes per issue |
505
+ | `maxCommitFixes` | `10` | The budget for fixes of a commit that a git hook stopped, per issue |
506
+ | `maxReviewRounds` | `5` | The budget for review rounds per issue |
507
+ | `checkIntervalSeconds` | `15` | The time between two check states, at most `2147483` |
508
+ | `checkGraceSeconds` | `60` | The time to wait for the first check to show, and for more checks after they all pass; the grace ends at the `checkTimeoutMinutes` limit, where checks that all pass, or no checks, still count as a pass |
509
+ | `checkTimeoutMinutes` | `60` | The limit for one check wait, at most `35791` |
510
+ | `agentTimeoutMinutes` | `30` | The limit for one agent call, at most `35791` |
511
+ | `setupTimeoutMinutes` | `15` | The limit for the setup command, at most `35791` |
512
+ | `commandTimeoutMinutes` | `10` | The limit for one `git` or `gh` command, at most `35791` |
513
+ | `logMaxChars` | `20000` | The maximum length of the failed job logs, shared between the failed jobs |
514
+ | `diffMaxChars` | `60000` | The maximum length of the diff that the reviewer reads |
515
+ | `keepRunDays` | `7` | The number of days to keep the run files; `0` keeps them all |
516
+ | `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer |
517
+ | `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
518
+ | `labels` | see above | The names of the labels that the harness reads and sets |
517
519
 
518
520
  The hunter adds `labels.hunt` to each issue it files, so you can tell those
519
521
  issues apart from your own and filter them.
@@ -13,9 +13,9 @@ function jsonLines(raw) {
13
13
  .filter((line) => line.trim() !== '')
14
14
  .map((line) => JSON.parse(line));
15
15
  }
16
- async function baseRuns(repo, sha) {
17
- const runs = await ghApi(repo, `actions/runs?head_sha=${sha}&per_page=100`, '.workflow_runs[] | {databaseId: .id, name, status, conclusion: (.conclusion // ""), attempt: .run_attempt, event} | @json', { paginate: true });
18
- return jsonLines(runs).filter((entry) => entry.event === 'push');
16
+ async function baseRuns(repo, sha, branch) {
17
+ const runs = await ghApi(repo, `actions/runs?head_sha=${sha}&per_page=100`, '.workflow_runs[] | {databaseId: .id, name, status, conclusion: (.conclusion // ""), attempt: .run_attempt, event, branch: (.head_branch // "")} | @json', { paginate: true });
18
+ return jsonLines(runs).filter((entry) => entry.event === 'push' && entry.branch === branch);
19
19
  }
20
20
  async function externalChecks(repo, sha) {
21
21
  const [runs, statuses] = await Promise.all([
@@ -38,8 +38,11 @@ async function externalChecks(repo, sha) {
38
38
  }));
39
39
  return [...checkRuns, ...commitStatuses];
40
40
  }
41
- async function baseChecks(repo, sha) {
42
- const [runs, external] = await Promise.all([baseRuns(repo, sha), externalChecks(repo, sha)]);
41
+ async function baseChecks(repo, sha, branch) {
42
+ const [runs, external] = await Promise.all([
43
+ baseRuns(repo, sha, branch),
44
+ externalChecks(repo, sha),
45
+ ]);
43
46
  return [...runs.map((entry) => ({ ...entry, url: '' })), ...external];
44
47
  }
45
48
  function failedRun(entry) {
@@ -54,30 +57,30 @@ function baseState(runs) {
54
57
  }
55
58
  return runs.some((entry) => entry.conclusion === 'cancelled') ? 'cancelled' : 'pass';
56
59
  }
57
- export function waitForBaseChecks(repo, sha, options) {
60
+ export function waitForBaseChecks(repo, sha, branch, options) {
58
61
  let checks = [];
59
62
  return pollChecks({
60
63
  head: async () => sha,
61
64
  lags: async () => true,
62
65
  list: async () => {
63
- checks = await baseChecks(repo, sha);
66
+ checks = await baseChecks(repo, sha, branch);
64
67
  return checks.length === 0 ? 'none' : 'some';
65
68
  },
66
69
  watch: async () => baseState(checks),
67
70
  }, options);
68
71
  }
69
- export async function rerunFailedBase(repo, sha, started = () => { }) {
70
- const failed = (await baseRuns(repo, sha)).filter(failedRun);
72
+ export async function rerunFailedBase(repo, sha, branch, started = () => { }) {
73
+ const failed = (await baseRuns(repo, sha, branch)).filter(failedRun);
71
74
  for (const entry of failed) {
72
75
  await gh(repo, ['run', 'rerun', String(entry.databaseId), '--failed']);
73
76
  }
74
77
  started();
75
- await waitForRestart(repo, sha, failed);
78
+ await waitForRestart(repo, sha, branch, failed);
76
79
  return failed.map((entry) => String(entry.databaseId));
77
80
  }
78
- async function waitForRestart(repo, sha, failed) {
81
+ async function waitForRestart(repo, sha, branch, failed) {
79
82
  for (let attempt = 1; attempt <= RESTART_TRIES; attempt += 1) {
80
- const runs = await baseRuns(repo, sha);
83
+ const runs = await baseRuns(repo, sha, branch);
81
84
  const restarted = failed.every((entry) => runs.some((run) => run.databaseId === entry.databaseId && run.attempt > entry.attempt));
82
85
  if (restarted) {
83
86
  return;
@@ -85,8 +88,8 @@ async function waitForRestart(repo, sha, failed) {
85
88
  await delay(secondsToMs(1));
86
89
  }
87
90
  }
88
- export async function failedBaseLogs(repo, sha, maxChars) {
89
- const failed = (await baseRuns(repo, sha))
91
+ export async function failedBaseLogs(repo, sha, branch, maxChars) {
92
+ const failed = (await baseRuns(repo, sha, branch))
90
93
  .filter(failedRun)
91
94
  .map((entry) => ({ heading: `## ${entry.name}`, runId: String(entry.databaseId) }));
92
95
  const external = (await externalChecks(repo, sha)).filter(failedRun).map((entry) => ({
@@ -20,12 +20,14 @@ export async function pollChecks(probe, options, clock = REAL_CLOCK) {
20
20
  const rest = () => Math.max(0, deadline - clock.now());
21
21
  let shown;
22
22
  let failures = 0;
23
+ let last;
23
24
  for (;;) {
24
25
  refuseWhenStopped();
25
26
  if (rest() === 0) {
26
- return 'timeout';
27
+ return last === 'pass' || last === 'none' ? last : 'timeout';
27
28
  }
28
29
  const state = await read(probe, options.head, rest(), () => (shown ??= clock.now()));
30
+ last = state;
29
31
  if (state === 'behind' && shown !== undefined) {
30
32
  return 'moved';
31
33
  }
package/dist/gate.mjs CHANGED
@@ -34,7 +34,7 @@ export async function checkGate(job, sha) {
34
34
  async function waitForChecks(job, sha, fields = {}) {
35
35
  const { context, log } = job;
36
36
  const { repo, config, ports } = context;
37
- const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, checkWaiting(config, true)));
37
+ const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true)));
38
38
  log.event('main-checks.state', { state: checks, ...fields });
39
39
  return checks;
40
40
  }
@@ -48,7 +48,7 @@ async function rerunOnce(job, sha, checks) {
48
48
  await writeState(context.repo, state);
49
49
  let started = false;
50
50
  try {
51
- const runs = await context.ports.rerunFailedBase(context.repo, sha, () => {
51
+ const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, () => {
52
52
  started = true;
53
53
  });
54
54
  log.event('main-checks.rerun', { sha, runs });
@@ -82,7 +82,7 @@ async function failedChecksFix(job, sha) {
82
82
  await writeState(repo, state);
83
83
  let logs;
84
84
  try {
85
- logs = await ports.failedBaseLogs(repo, sha, config.logMaxChars);
85
+ logs = await ports.failedBaseLogs(repo, sha, base, config.logMaxChars);
86
86
  }
87
87
  catch (error) {
88
88
  return escalateError(job, error, `The read of the failed checks on ${base} failed`, 'logs error');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.84",
3
+ "version": "6.6.86",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",