next-issue 9.8.1 → 9.8.3

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
@@ -46,7 +46,7 @@ A run handles up to `concurrency` issues at the same time, 1 by default. When an
46
46
  4. Let the implementer agent do the work, then commit it. For a behaviour change, the implementer writes the test first and quotes its failing output in its reply. The harness keeps that reply in the state file for the reviewer. The branch is not pushed. When a git hook stops a commit, the agent that made the change gets the hook output, fixes it, and the harness commits again. A `commit:` line in the reply of the agent replaces the subject, so a hook that rejects the subject can pass. The harness drops each GitHub closing keyword (`close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, `resolve`, `resolves`, `resolved`) that names an issue from the subject, so a push to the base never closes an issue: the issue closes only after its checks pass. The budget is `maxCommitFixes`. Any other git failure in the commit stops the run with an error. An implementer that makes no change hands the issue to a person, unless the branch is already ahead of the base, for example when an issue resumes from saved state in phase `claimed`, or when the remote holds branch `<n>`: the run then carries on with the commits on the branch, and the newest of them gives the subject of the landed commit. A lost state file does not count, since an issue with no saved state resets its local branch (step 3). When the base already does all that the issue asks, the implementer makes no change and ends its reply with a `done: <evidence>` line. If the branch is not ahead of the base, a reviewer then checks that claim against the base. When it raises no blocking finding, the harness comments `### Already done` with the evidence and the summary of the reviewer, adds `status:done` and closes the issue as completed, and the issue ends as `done`. Otherwise it hands the issue to a person with the reason `already done disputed`, and the comment holds the evidence and the findings of the reviewer. A reply with a `question:` line asks the questions instead. To close a parent issue once its sub-issues land, mark it as blocked by each sub-issue and give it the `status:todo` label: it waits while a sub-issue is open (step 1), then the implementer finds it already done and the harness closes it. The implementer checks the issue first. When the scope, the expected behaviour or the acceptance criteria are ambiguous, it makes no change and asks instead of guessing, with each question on its own `question: <n>. <question>` line, its options labelled by letters and one option recommended. A reply with at least one `question:` line makes the harness drop any change in the worktree, commit nothing and hand the issue to a person with the reason `questions`. The hand-over comment lists the questions in order, numbered by the harness. The harness reads the issue again and adds the questions after any text under its `Open questions` heading, or adds that heading at the end of the body when it has none. When that read or body edit fails, the harness records a `questions.body-failed` event in the run log and still hands the issue over with the questions in the comment. It also keeps the questions in the state of the issue, so the implementer of the run that resumes the issue finds them next to the answer of a person, not in the issue body.
47
47
  5. Let the reviewer agent judge the diff, at most `diffMaxChars` of it. The reviewer reads files and runs commands in the worktree, so it can prove a finding with the tests or the type check. The harness then throws away every change that the reviewer left in the worktree, so no such change can reach a later commit. When the reviewer left another branch or a detached `HEAD` checked out, the harness checks out the issue branch again at its commit from before the review. It does the same when the reviewer times out or fails. The state file keeps that commit while the reviewer runs, so when the run stops during the review, the next run that resumes the issue first puts the issue branch back at that commit, before the setup command, and the diff it reads holds no reviewer commit. A commit that a person adds to the branch after a hand-over stays on it. The first reviewer also gets the reply of the implementer, and raises a finding when a behaviour change has no failing run of its test. A later reviewer gets the reply of the last review fixer instead, who quotes the failing run of a test for a behaviour change. The reviewer ends its last message with its verdict as a json block: a summary and one entry per finding, each rated `blocking` or `minor`. A reply without a valid block hands the issue to a person. The findings are the only ground truth. The reviewer gives no approve or reject field, because such a field can contradict the findings. The harness puts the result on the issue. A result longer than a GitHub comment (65536 characters) is cut to fit, with a last line that says so.
48
48
  6. An open finding is any finding, blocking or minor, while a review round is left. In the last round, only a blocking finding stays open: a minor finding there goes on the issue but starts no fix, because a fix in the last round gets no review. Thus `maxReviewRounds` of `1` never fixes a minor finding.
49
- 7. No open finding means approval: the change lands on the base branch. Approved changes land one at a time, so the next one waits until the checks of the last one end, and other issues go on meanwhile. The harness fetches the remote base, merges it into the branch and makes the change one commit on top of it, with the subject of the implementer's commit. A review fix keeps that subject, but a commit fix for the implementer's commit replaces it, and a fix for failed checks after the landing lands under the fixer's own subject. The reapply commit after a revert uses the subject of the change. When git merges the base cleanly, no agent runs. When a conflicted file holds no conflict marker, for example a file that one side deletes and the other changes, a renamed file or a binary file that both sides change, no agent runs: the harness undoes the merge and hands the issue to a person with the reason `merge conflict`, since git leaves only one side in the file. When git reports conflicted files, the fixer gets the list from the check budget, `maxCiFixes`, removes the conflict markers, and the harness commits the merge. A merge that the fixer commits itself counts only when the branch then holds the base commit that was merged and the listed files hold no conflict marker. With the budget used up, or when the fixer leaves a conflict marker or the merge unresolved, aborts the merge, or fails, the harness undoes the merge and hands the issue to a person with the reason `merge conflict`. When `checks` lists commands, the harness then runs the setup command again in the worktree, so the checks use the dependencies of the merged base. It runs the setup after it makes the change one commit, and commits what the setup writes, unless git ignores it, on top of that commit without hooks. Every check runs on that setup commit. After the checks, the harness puts the branch back at the change commit, so what this setup writes does not land on the base; after a stop or kill during the checks, the next run puts the branch back first. What the first setup writes, before the implementer, is part of the implementer's commit and lands. When this setup rewrites such a file, for example a lock file, the checks run on the rewritten file, but the base gets the file of the change. A change that the base already holds is an `empty change` before the setup runs. A setup that fails or does not finish in `setupTimeoutMinutes` keeps the merged commit, stops the landing before the push and hands the issue to a person with the reason `setup failed` or `setup timeout`. The harness then runs each command in `checks` in the worktree, in order, with `bash -c` and stderr merged into stdout, each for at most `checksTimeoutMinutes`. Their output goes to the run log (`check.output`, and `check.fail` for a failure). After each command, the harness resets the worktree to the commit it checked and removes untracked files that git does not ignore, so a file that a command writes never lands on the base. A command that fails or does not finish stops the landing before the push: the fixer gets the command and the tail of its output (at most `logMaxChars`) from the check budget, `maxCiFixes`, and its fix is squashed into the change, which keeps its subject. The harness then merges the base again and runs every command again, so nothing lands until all pass. When the budget runs out, the harness hands the issue to a person with the reason `local checks failed: <command>` and the tail of the output in the comment; a fixer that adds no commit or calls the failure unrelated hands it over too, as for the checks on the base. Nothing of the change reaches the base. A run that stops while a command runs keeps the budget, and the next run merges and runs every command again before any push. The state file keeps the merged commit from the squash until the push, so the next run that resumes the issue first puts the issue branch back at that commit, before the setup command. A commit that a person adds to the branch after a hand-over stays on it. The harness then pushes the commit to the base branch, without force. A push that the remote refuses, for example because the base moved, starts the rebase again, three times at most. When the push fails, the harness fetches the base first, and treats the push as landed when the base holds the commit, for example after a timeout. When that fetch fails too, the harness hands the issue to a person with the reason `push unknown` and halts, even when the hand-over fails. The state file holds the commit during the push, so a run stopped meanwhile, or the resume after that hand-over (once a person answers or takes the label off), checks the base and waits for the checks of the commit when it landed. Until then, no run lands another change (see below). Once the commit lands, the harness fetches the remote and fast-forwards the local base branch to it when that is safe. A fetch that fails or a fast-forward that is not safe leaves the local base branch as it is and writes a `base.behind` event, and the landing goes on. The harness then waits for the checks of the pushed commit on the base branch: the GitHub Actions workflow runs that a `push` of the base branch started on it, its commit statuses and the check runs of every other GitHub App, so checks from another CI service count too. It leaves out the check runs of the GitHub Actions app, since it judges GitHub Actions by its workflow runs. It leaves out workflow runs that any other event (such as `issues`, `issue_comment` or `schedule`) started, since GitHub gives such a run the tip of the default branch as its commit. It also leaves out the `push` runs that a push of a tag or of another branch started on the same commit, such as a release or a deploy. It leaves out every GitHub Actions job, check run and commit status whose name is in `ignoredChecks`: it does not wait for it, its result does not fail the checks and its logs do not go to the fixer. With `ignoredChecks` set, the harness judges each workflow run by its other jobs, so a run whose only failed job is ignored passes when every other job passes. When an ignored job fails and GitHub cancels another job of the same run, for example through the default `strategy.fail-fast` of a matrix, that job never finished: the harness hands the issue to a person with the reason `main checks cut short` and halts, and the issue stays open. Set `fail-fast: false` on a matrix with an ignored job to avoid this. The same goes when an ignored job fails and another job of the same run ends `skipped`, for example because it `needs` the ignored job; a skipped job in a run with no failed job still passes. A failed or errored commit status, or a workflow run or check run that ends with `failure`, `timed_out` or `action_required`, fails the checks. The harness does not rerun a workflow run that ends `action_required`, since it waits for a person to approve it. When any check ends `cancelled`, for example because a later push cancelled the workflow run, that check never finished, even when another check (such as a release workflow) ends `success`: the harness hands the issue to a person with the reason `main checks cancelled` and halts, and the issue stays open. A repository that reports no check keeps asking for `checkGraceSeconds`. When every check passes, the harness keeps asking until `checkGraceSeconds` have gone by since it first read the checks, since GitHub can add a check a few seconds after the others; a check that shows up in that time counts, and one that shows up later does not. A pending state waits again, up to `checkTimeoutMinutes`. A read that fails is tried three times. When the first read of the checks of a landed change still fails, for example on a rate limit or an expired token, the harness hands the issue to a person with the reason `checks error` and halts, before the next change lands. The comment holds the error and says that the landed commit is on the base and its checks were not awaited. The state file keeps the commit, so the resume after a person answers or takes the label off waits for its checks, and until then no run lands another change (see below). When the checks pass, the harness marks the state file as closing, sets `status:done` and closes the issue. When a run stops or dies before the close, the next run sees the mark, sets `status:done` and closes the issue, with no new push, revert or hand-over. A hand-over clears the mark, so an issue taken back after a failed label edit or close is resumed, not closed, by later runs. When a run stops or dies after the close, before the state file goes away, the next run finds the closed issue through its state file and removes the worktree, the local branches and the state file, with no new push, revert, label, close or hand-over. A label or close that fails for another reason hands the issue over, and it then waits for a person like any other hand-over. Then the worktree, the local branch and the state file go away. When the checks fail, the harness reruns the failed jobs of each failed GitHub Actions workflow run once with `gh run rerun <id> --failed`, records a `ci-checks.rerun` event and waits again once the runs restart. A failed run whose failed jobs were already rerun (its attempt on GitHub is above 1) is not rerun again, so a resumed run reruns only the runs not rerun yet. A failure that gets a rerun ends the wait at once; any other failure (a run that was rerun, a run that waits for approval, a check from another CI service) waits until every check has finished, so a workflow run that fails later, even after the first rerun started, still gets its own rerun before any fixer. A workflow run whose kept job failed while a job in `ignoredChecks` still runs gets its rerun only once the whole run has finished on GitHub, as GitHub refuses to rerun a running run. A rerun that GitHub refuses because the run is already running counts as started. When at least one run restarted and a later rerun or read fails, the event carries the error and the harness still waits for the checks again, counting each restarted run as running until a later attempt of it completes, so the fixer never runs while a rerun is queued or in progress. When the rerun cannot start (no run restarted, a `ci-checks.rerun-failed` event), or the checks fail again with no run left to rerun, the fixer gets their logs from the check budget (for a check from another CI service, only its name and link), and its fix lands the same way. When the fixer cannot fix them, its fix cannot land, an error stops the fix, or the budget runs out, the harness reverts every commit of the change on the base branch, pushes the revert and hands the issue to a person. When the push of the fix ends as `push unknown`, the harness does not revert: it hands the issue over and halts as for any other `push unknown`. A revert push that the remote refuses, for example because the base moved, makes the revert again on the new base, three times at most. A failed revert push that the base holds after a fetch counts as landed. Once the revert lands, the harness fast-forwards the local base branch to it, as after a landed commit. When that fetch fails too, the revert may be on the base with checks nobody awaited: the harness reports it so, saves the halt and blocks later landings. The state file holds the revert commit during the push, so a run stopped meanwhile checks the base on resume. When the base holds the revert, the harness puts the change back on the branch on top of the revert, as after a revert that completes (an unlanded fix commit is dropped), drops the landed commits from the state, waits for no checks, does not revert again, hands the issue to a person with the reason `revert stopped` and halts. A resume that stopped while the checks of a landed commit ran waits for them again, even when more commits landed on the base since, and a fix that was committed but not landed lands first. Before that, the resume drops any change left in the worktree, including a merge of the base that a stopped fix landing left in progress, so the fix merges the current base again from the start. A problem that the reviewer leaves out of the findings thus gets an approval: only the findings count.
49
+ 7. No open finding means approval: the change lands on the base branch. Approved changes land one at a time, so the next one waits until the checks of the last one end, and other issues go on meanwhile. The harness fetches the remote base, merges it into the branch and makes the change one commit on top of it, with the subject of the implementer's commit. A review fix keeps that subject, but a commit fix for the implementer's commit replaces it, and a fix for failed checks after the landing lands under the fixer's own subject. The reapply commit after a revert uses the subject of the change. When git merges the base cleanly, no agent runs. When a conflicted file holds no conflict marker, for example a file that one side deletes and the other changes, a renamed file or a binary file that both sides change, no agent runs: the harness undoes the merge and hands the issue to a person with the reason `merge conflict`, since git leaves only one side in the file. When git reports conflicted files, the fixer gets the list from the check budget, `maxCiFixes`, removes the conflict markers, and the harness commits the merge. A merge that the fixer commits itself counts only when the branch then holds the base commit that was merged and the listed files hold no conflict marker. With the budget used up, or when the fixer leaves a conflict marker or the merge unresolved, aborts the merge, or fails, the harness undoes the merge and hands the issue to a person with the reason `merge conflict`. When `checks` lists commands, the harness then runs the setup command again in the worktree, so the checks use the dependencies of the merged base. It runs the setup after it makes the change one commit, and commits what the setup writes, unless git ignores it, on top of that commit without hooks. Every check runs on that setup commit. After the checks, the harness puts the branch back at the change commit, so what this setup writes does not land on the base; after a stop or kill during the checks, the next run puts the branch back first. What the first setup writes, before the implementer, is part of the implementer's commit and lands. When this setup rewrites such a file, for example a lock file, the checks run on the rewritten file, but the base gets the file of the change. A change that the base already holds is an `empty change` before the setup runs. A setup that fails or does not finish in `setupTimeoutMinutes` keeps the merged commit, stops the landing before the push and hands the issue to a person with the reason `setup failed` or `setup timeout`. The harness then runs each command in `checks` in the worktree, in order, with `bash -c` and stderr merged into stdout, each for at most `checksTimeoutMinutes`. Their output goes to the run log (`check.output`, and `check.fail` for a failure). After each command, the harness resets the worktree to the commit it checked and removes untracked files that git does not ignore, so a file that a command writes never lands on the base. A command that fails or does not finish stops the landing before the push: the fixer gets the command and the tail of its output (at most `logMaxChars`) from the check budget, `maxCiFixes`, and its fix is squashed into the change, which keeps its subject. The harness then merges the base again and runs every command again, so nothing lands until all pass. When the budget runs out, the harness hands the issue to a person with the reason `local checks failed: <command>` and the tail of the output in the comment; a fixer that adds no commit or calls the failure unrelated hands it over too, as for the checks on the base. Nothing of the change reaches the base. A run that stops while a command runs keeps the budget, and the next run merges and runs every command again before any push. The state file keeps the merged commit from the squash until the push, so the next run that resumes the issue first puts the issue branch back at that commit, before the setup command. A commit that a person adds to the branch after a hand-over stays on it. The harness then pushes the commit to the base branch, without force. When the push fails, the harness fetches the base first, and treats the push as landed when the base holds the commit, for example after a timeout. When the base moved, for example because someone else pushed first, the harness starts the rebase again, three times at most. When the base did not move, for example on a missing permission or a branch protection rule, the harness hands the issue to a person at once with the reason `push failed`, without running the checks again. Each `push failed` comment holds the tail of the last error of git. When that fetch fails too, the harness hands the issue to a person with the reason `push unknown` and halts, even when the hand-over fails. The state file holds the commit during the push, so a run stopped meanwhile, or the resume after that hand-over (once a person answers or takes the label off), checks the base and waits for the checks of the commit when it landed. Until then, no run lands another change (see below). Once the commit lands, the harness fetches the remote and fast-forwards the local base branch to it when that is safe. A fetch that fails or a fast-forward that is not safe leaves the local base branch as it is and writes a `base.behind` event, and the landing goes on. The harness then waits for the checks of the pushed commit on the base branch: the GitHub Actions workflow runs that a `push` of the base branch started on it, its commit statuses and the check runs of every other GitHub App, so checks from another CI service count too. It leaves out the check runs of the GitHub Actions app, since it judges GitHub Actions by its workflow runs. It leaves out workflow runs that any other event (such as `issues`, `issue_comment` or `schedule`) started, since GitHub gives such a run the tip of the default branch as its commit. It also leaves out the `push` runs that a push of a tag or of another branch started on the same commit, such as a release or a deploy. It leaves out every GitHub Actions job, check run and commit status whose name is in `ignoredChecks`: it does not wait for it, its result does not fail the checks and its logs do not go to the fixer. With `ignoredChecks` set, the harness judges each workflow run by its other jobs, so a run whose only failed job is ignored passes when every other job passes. When an ignored job fails and GitHub cancels another job of the same run, for example through the default `strategy.fail-fast` of a matrix, that job never finished: the harness hands the issue to a person with the reason `main checks cut short` and halts, and the issue stays open. Set `fail-fast: false` on a matrix with an ignored job to avoid this. The same goes when an ignored job fails and another job of the same run ends `skipped`, for example because it `needs` the ignored job; a skipped job in a run with no failed job still passes. A failed or errored commit status, or a workflow run or check run that ends with `failure`, `timed_out` or `action_required`, fails the checks. The harness does not rerun a workflow run that ends `action_required`, since it waits for a person to approve it. When any check ends `cancelled`, for example because a later push cancelled the workflow run, that check never finished, even when another check (such as a release workflow) ends `success`: the harness hands the issue to a person with the reason `main checks cancelled` and halts, and the issue stays open. A repository that reports no check keeps asking for `checkGraceSeconds`. When every check passes, the harness keeps asking until `checkGraceSeconds` have gone by since it first read the checks, since GitHub can add a check a few seconds after the others; a check that shows up in that time counts, and one that shows up later does not. A pending state waits again, up to `checkTimeoutMinutes`. A read that fails is tried three times. When the first read of the checks of a landed change still fails, for example on a rate limit or an expired token, the harness hands the issue to a person with the reason `checks error` and halts, before the next change lands. The comment holds the error and says that the landed commit is on the base and its checks were not awaited. The state file keeps the commit, so the resume after a person answers or takes the label off waits for its checks, and until then no run lands another change (see below). When the checks pass, the harness marks the state file as closing, sets `status:done` and closes the issue. When a run stops or dies before the close, the next run sees the mark, sets `status:done` and closes the issue, with no new push, revert or hand-over. A hand-over clears the mark, so an issue taken back after a failed label edit or close is resumed, not closed, by later runs. When a run stops or dies after the close, before the state file goes away, the next run finds the closed issue through its state file and removes the worktree, the local branches and the state file, with no new push, revert, label, close or hand-over. A label or close that fails for another reason hands the issue over, and it then waits for a person like any other hand-over. Then the worktree, the local branch and the state file go away. When the checks fail, the harness reruns the failed jobs of each failed GitHub Actions workflow run once with `gh run rerun <id> --failed`, records a `ci-checks.rerun` event and waits again once the runs restart. A failed run whose failed jobs were already rerun (its attempt on GitHub is above 1) is not rerun again, so a resumed run reruns only the runs not rerun yet. A failure that gets a rerun ends the wait at once; any other failure (a run that was rerun, a run that waits for approval, a check from another CI service) waits until every check has finished, so a workflow run that fails later, even after the first rerun started, still gets its own rerun before any fixer. A workflow run whose kept job failed while a job in `ignoredChecks` still runs gets its rerun only once the whole run has finished on GitHub, as GitHub refuses to rerun a running run. A rerun that GitHub refuses because the run is already running counts as started. When at least one run restarted and a later rerun or read fails, the event carries the error and the harness still waits for the checks again, counting each restarted run as running until a later attempt of it completes, so the fixer never runs while a rerun is queued or in progress. When the rerun cannot start (no run restarted, a `ci-checks.rerun-failed` event), or the checks fail again with no run left to rerun, the fixer gets their logs from the check budget (for a check from another CI service, only its name and link), and its fix lands the same way. When the fixer cannot fix them, its fix cannot land, an error stops the fix, or the budget runs out, the harness reverts every commit of the change on the base branch, pushes the revert and hands the issue to a person. When the push of the fix ends as `push unknown`, the harness does not revert: it hands the issue over and halts as for any other `push unknown`. A revert push that the remote refuses, for example because the base moved, makes the revert again on the new base, three times at most. A failed revert push that the base holds after a fetch counts as landed. Once the revert lands, the harness fast-forwards the local base branch to it, as after a landed commit. When that fetch fails too, the revert may be on the base with checks nobody awaited: the harness reports it so, saves the halt and blocks later landings. The state file holds the revert commit during the push, so a run stopped meanwhile checks the base on resume. When the base holds the revert, the harness puts the change back on the branch on top of the revert, as after a revert that completes (an unlanded fix commit is dropped), drops the landed commits from the state, waits for no checks, does not revert again, hands the issue to a person with the reason `revert stopped` and halts. A resume that stopped while the checks of a landed commit ran waits for them again, even when more commits landed on the base since, and a fix that was committed but not landed lands first. Before that, the resume drops any change left in the worktree, including a merge of the base that a stopped fix landing left in progress, so the fix merges the current base again from the start. A problem that the reviewer leaves out of the findings thus gets an approval: only the findings count.
50
50
  8. With an open finding, run the fixer agent and go to step 5 again. The budget is `maxReviewRounds`. A fixer that holds every finding to be wrong changes nothing and gives its reason instead. The reason goes on the issue and into the next round, where it answers every finding of its own round, so the reviewer withdraws them all or repeats them all. With only some findings wrong, the fixer fixes the correct ones, and the next round holds the rest. A fixer that settles every finding with no code change, for example by showing a failing test run, changes nothing and ends with a `resolved:` line instead. The note goes on the issue and into the next round in the same way, and a change it leaves behind is handled as for a dispute.
51
51
 
52
52
  ## Issue format
@@ -83,7 +83,7 @@ The harness hands the issue to a person, with the `status:needs-human` label, an
83
83
  - a fixer disputes or settles the findings and leaves a change behind, either in the worktree or in a commit of its own. A dispute carries a reason, not a diff, and a retry of the issue cleans the worktree before the next review, so the change does not stay there: its edits are committed with no hooks on top of any commit of its own, that commit moves to a new local `<n>-dispute-<commit>` branch, and the hand-over comment names that branch. The `<n>` branch keeps only what will land, and the reviewer of a retry sees none of the change. Neither lands. The `<n>-dispute-<commit>` branches go away with the `<n>` branch when the issue is done;
84
84
  - the reviewer gives no verdict, or the checks do not finish in time;
85
85
  - a command in `checks` still fails before the push when the check budget runs out; nothing of the change is pushed;
86
- - the push to the base branch fails three times;
86
+ - the push to the base branch fails while the base did not move, or fails three times;
87
87
  - the checks on the base branch fail and the fixer cannot fix them, an error stops the fix, or they do not finish in time. The base branch is then broken, so the run claims no new issue and ends once the running issues end. It halts this way even when the hand-over fails; the issue then ends in error with both the reason and the hand-over error;
88
88
  - the implementer asks questions about the issue (reason `questions`);
89
89
  - a person without write access last changed the title or body of the issue (reason `untrusted editor`, see [Safety](#safety));
@@ -136,7 +136,7 @@ No person checks a change before it lands. To replace those checks, [ADR 0004](h
136
136
  Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
137
137
 
138
138
  - `<id>.jsonl` — one JSON object per event, with `ts`, `runId`, `kind`, and the `issue`, `role` or `round` in scope;
139
- - `<id>.summary.json` — token totals per agent role, event counts, and one report per issue with the outcome, the reason and the budgets used (in a watch run, an issue skipped in several passes gets one report, and an issue handled in more than one pass keeps a report for each);
139
+ - `<id>.summary.json` — token totals per agent role, event counts, and one report per issue with the outcome, the reason and the budgets used (in a watch run, an issue skipped in several passes gets one report, and an issue handled in more than one pass keeps a report for each; when an issue crashes the run, the file still holds the reports of the issues that finished);
140
140
  - `<id>/sessions/` — the full pi session of each agent call, with every message, tool call and tool result. The session id in a `usage` event is part of the file name.
141
141
 
142
142
  At the start of a run, the harness deletes the files and folders under `.next-issue/runs/` that are older than `keepRunDays`. The age of a folder is the time since the last change to it or to anything inside it, so the sessions of a long run stay while it still writes them. Set the field to `0` to keep them all.
@@ -354,7 +354,7 @@ In a run of the `serve` worker, a client can switch hunting and watching on or o
354
354
  - sends each `error` as `{ "type": "error", "root": "<path>", "message": "<text>" }`. When a `start`, `stop`, `watch`, `hunt` or `refresh` message carries an `"id"`, the `error` that refuses it carries the same `id`;
355
355
  - runs at most one run at a time. A client starts it with `{ "type": "start", "root": "<path>", "args": [...] }`. Each run is like `next-issue start` with those args, or with none when `args` is left out (the pi extension sends none). It takes `--max <n>`, `--watch`, `--hunt`, `--reset`, `--verbose` and `--quiet`, and refuses a command (`start` too), `--json`, `--force`, `--help` or an unknown argument with an `error` message;
356
356
  - sends every client the progress of every run when it connects and on every change: for each running issue the issue, the step, the tool count and the last tool, and the handled issues (an issue handled in more than one pass appears once for each);
357
- - sends every client a `questions` message for each repository: the open issues with the `needsHuman` label, each with its number, title, the reason of the hand-over, the url of the comment that holds it, the `owner/name` repository, and the `needsHuman` and `skip` labels. It reads them from GitHub, so the list is the same after a restart. It sends them when a client connects, for its repository, after each issue of a run ends, and when a client sends `{ "type": "questions", "root": "<path>" }`. An issue that no longer has the label leaves the list, and so does an issue whose hand-over has an answer from a writer, the same answer that lets a run claim it. An issue that a person holds with the label stays in the list, even when an earlier hand-over has an answer. An issue with the label but no hand-over comment is in the list with an empty reason and url. The issues are read one at a time. A client never gets an older list after a newer one. When the client adds an `"id"` to its message, the list that answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets `{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
357
+ - sends every client a `questions` message for each repository: the open issues with the `needsHuman` label, each with its number, title, the reason of the hand-over, the url of the comment that holds it, the `owner/name` repository, and the `needsHuman`, `skip` and `ready` labels. It reads them from GitHub, so the list is the same after a restart. It sends them when a client connects, for its repository, after each issue of a run ends, and when a client sends `{ "type": "questions", "root": "<path>" }`. An issue that no longer has the label leaves the list, and so does an issue whose hand-over has an answer from a writer, the same answer that lets a run claim it. An issue that a person holds with the label stays in the list, even when an earlier hand-over has an answer. An issue with the label but no hand-over comment is in the list with an empty reason and url. The issues are read one at a time. A client never gets an older list after a newer one. When the client adds an `"id"` to its message, the list that answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets `{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
358
358
  - answers `{ "type": "upcoming", "root": "<path>" }` with `{ "type": "upcoming", "root": "<path>", "claimable": [...], "blocked": [...] }`: the open issues with the `ready` label that a run would claim, oldest first, each with its `issue` number and `title`, without issues that have saved state or a label that stops a claim. An issue blocked by open issues is in `blocked` with their references in `blockers`. When the list cannot be read, the client gets `{ "type": "upcoming-error", "root": "<path>", "message": "<text>" }`;
359
359
  - stops a run when a client sends `{ "type": "stop", "root": "<path>", "after": "issue" | "round" | "now" }`. With no `after`, it stops after `issue`. `issue` works like a first `Ctrl-C`: no new claim or hunt, and the held issues and a going hunt finish. `round` works like a second `Ctrl-C`: each running issue stops after its current round, with the state kept, and a going hunt ends first. `now` stops every agent, command and hunt of the run at once, and each running issue ends as `stopped` with its state and labels kept; the worker keeps running. A later point than one already asked for changes nothing, and an earlier one replaces it. An unknown `after` gets an `error` message;
360
360
  - switches watching of a run on or off when a client sends `{ "type": "watch", "root": "<path>", "on": true | false }`. The run keeps its issues, worktrees and progress, and nothing restarts. A run started with `--watch` or `--hunt` starts with watching on, and any other run with it off. On keeps the run going after the current pass, as with `--watch`. Off ends the run after the current pass, or at once when it waits between passes, and also turns hunting off. With no run going, the message gets an `error` and starts nothing;
package/dist/git-land.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { evenWhenStopped } from './children.mjs';
2
- import { fetchBase, git, isAncestor, isDirty, isLanded, isOnBase, oneFetchAtATime, revision, succeeds, } from './git.mjs';
2
+ import { run, succeeded } from './exec.mjs';
3
+ import { fetchBase, git, isAncestor, isDirty, isLanded, isOnBase, oneFetchAtATime, remoteRef, revision, succeeds, } from './git.mjs';
3
4
  import { commitEverything } from './git-commit.mjs';
4
5
  export const PUSH_TRIES = 3;
5
6
  export async function squashOnto(cwd, target, message) {
@@ -18,7 +19,12 @@ export async function squashOnto(cwd, target, message) {
18
19
  return true;
19
20
  }
20
21
  export async function pushToBase(cwd, remote, base) {
21
- return oneFetchAtATime(() => succeeds(cwd, ['push', remote, `HEAD:refs/heads/${base}`]));
22
+ const result = await oneFetchAtATime(() => run('git', ['push', remote, `HEAD:refs/heads/${base}`], { cwd }));
23
+ return succeeded(result) ? { pushed: true } : { pushed: false, error: result.stderr };
24
+ }
25
+ /** Whether the last fetched base holds a commit that `HEAD` lacks. */
26
+ export async function baseMoved(cwd, base, remote) {
27
+ return !(await isAncestor(cwd, remoteRef(remote, base), 'HEAD'));
22
28
  }
23
29
  export async function revertOnBase(cwd, revert) {
24
30
  try {
@@ -66,7 +72,8 @@ async function pushRevert(cwd, revert) {
66
72
  await git(cwd, ['commit', '--no-verify', '-m', message]);
67
73
  const reverted = await revision(cwd);
68
74
  await pushing(reverted);
69
- if ((await pushToBase(cwd, remote, base)) || (await isOnBase(cwd, base, remote, reverted))) {
75
+ if ((await pushToBase(cwd, remote, base)).pushed ||
76
+ (await isOnBase(cwd, base, remote, reverted))) {
70
77
  await commitReapply(cwd, reverted, reapply, branch);
71
78
  return true;
72
79
  }
package/dist/git.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { must, optionalFlag, run, succeeded } from './exec.mjs';
1
+ import { must, run, succeeded } from './exec.mjs';
2
2
  import { oneAtATime } from './lock.mjs';
3
3
  import { lines } from './text.mjs';
4
4
  const REMOTE_PATTERNS = [
@@ -28,7 +28,7 @@ async function sshHost(url, host) {
28
28
  if (host === 'github.com' || /^https?:/.test(url.trim())) {
29
29
  return host;
30
30
  }
31
- const result = await run('ssh', ['-G', host]).catch(() => undefined);
31
+ const result = await run('ssh', ['-G', '--', host]).catch(() => undefined);
32
32
  const resolved = /^hostname[^\S\r\n]+(\S+)$/m.exec(result?.stdout ?? '')?.[1];
33
33
  return result !== undefined && succeeded(result) && resolved !== undefined
34
34
  ? githubHost(resolved)
@@ -113,10 +113,6 @@ export async function saveSetupOutput(cwd) {
113
113
  }
114
114
  export async function setAside(cwd, target, branch) {
115
115
  await git(cwd, ['branch', branch]);
116
- if (await isDirty(cwd)) {
117
- await git(cwd, ['reset', '--soft', target]);
118
- return;
119
- }
120
116
  await discardChanges(cwd, target);
121
117
  }
122
118
  export async function disputeBranches(repo, branch) {
@@ -127,9 +123,6 @@ export async function disputeBranches(repo, branch) {
127
123
  ]);
128
124
  return lines(list);
129
125
  }
130
- export async function push(cwd, remote, branch, force = false) {
131
- await oneFetchAtATime(() => git(cwd, ['push', '-u', ...optionalFlag(force, '--force'), remote, branch]));
132
- }
133
126
  export async function fetchBase(cwd, base, remote) {
134
127
  await gitFetch(cwd, [remote, base]);
135
128
  return remoteRef(remote, base);
@@ -140,10 +133,6 @@ export function oneFetchAtATime(work) {
140
133
  export function gitFetch(cwd, args) {
141
134
  return oneFetchAtATime(() => git(cwd, ['fetch', ...args]));
142
135
  }
143
- export async function resetToBase(cwd, base, remote) {
144
- const target = await fetchBase(cwd, base, remote);
145
- await git(cwd, ['reset', '--hard', target]);
146
- }
147
136
  export async function latestSubject(cwd, base, remote) {
148
137
  const subject = await git(cwd, ['log', '-1', '--format=%s', `${remoteRef(remote, base)}..HEAD`]);
149
138
  return subject === '' ? undefined : subject;
@@ -92,7 +92,11 @@ async function waitingQuestion(repo, config, ports, writer, issue) {
92
92
  reason: comment?.body.slice(HAND_OVER.length).trim() ?? pending?.reason ?? '',
93
93
  url: comment?.url ?? '',
94
94
  repo: repoArg(repo),
95
- labels: { needsHuman: config.labels.needsHuman, skip: config.labels.skip },
95
+ labels: {
96
+ needsHuman: config.labels.needsHuman,
97
+ skip: config.labels.skip,
98
+ ready: config.labels.ready,
99
+ },
96
100
  };
97
101
  }
98
102
  export async function writerComments(context, log, issue) {
package/dist/land.mjs CHANGED
@@ -7,7 +7,9 @@ import { localChecks } from './local-checks.mjs';
7
7
  import { escalateAndFinish, finishDone, stop } from './handover.mjs';
8
8
  import { oneAtATime } from './lock.mjs';
9
9
  import { readState, savedIssues, writeState } from './state.mjs';
10
+ import { outputBlock } from './text.mjs';
10
11
  import { beforeBaseSettled, blocksLanding, HALT_NOTE, releaseSettled } from './unsettled.mjs';
12
+ const GIT_ERROR_CHARS = 1000;
11
13
  export function landApproved(job) {
12
14
  return landing(job, () => landLoop(job));
13
15
  }
@@ -126,13 +128,20 @@ async function pushChange(job) {
126
128
  state.pushing = sha;
127
129
  state.halted = true;
128
130
  await writeState(repo, state);
129
- const pushed = await log.step('land', { base, sha }, async () => (await ports.pushToBase(worktree, config.remote, base)) ||
130
- ports.isOnBase(worktree, base, config.remote, sha).catch((error) => {
131
+ let failure = '';
132
+ const pushed = await log.step('land', { base, sha }, async () => {
133
+ const push = await ports.pushToBase(worktree, config.remote, base);
134
+ if (push.pushed) {
135
+ return true;
136
+ }
137
+ failure = push.error;
138
+ return ports.isOnBase(worktree, base, config.remote, sha).catch((error) => {
131
139
  if (runStopped()) {
132
140
  throw error;
133
141
  }
134
142
  return undefined;
135
- }));
143
+ });
144
+ });
136
145
  if (pushed === undefined) {
137
146
  job.mainBroken = true;
138
147
  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');
@@ -150,9 +159,16 @@ async function pushChange(job) {
150
159
  await updateLocalBase(job);
151
160
  return sha;
152
161
  }
162
+ if (!(await ports.baseMoved(worktree, base, config.remote))) {
163
+ return escalateAndFinish(job, `The push to ${base} failed, and ${base} did not move, so the harness did not try again.${gitError('The error of git:', failure)}`, 'push failed');
164
+ }
153
165
  attempt += 1;
154
166
  if (attempt > PUSH_TRIES) {
155
- return escalateAndFinish(job, `The push to ${base} failed ${PUSH_TRIES} times.`, 'push failed');
167
+ return escalateAndFinish(job, `The push to ${base} failed ${PUSH_TRIES} times.${gitError('The last error of git:', failure)}`, 'push failed');
156
168
  }
157
169
  }
158
170
  }
171
+ function gitError(label, failure) {
172
+ const block = outputBlock(failure, GIT_ERROR_CHARS);
173
+ return block === '' ? '' : ` ${label}${block}`;
174
+ }
@@ -5,9 +5,8 @@ import { succeeded } from './exec.mjs';
5
5
  import { escalateCheckFix, fixRound } from './fix.mjs';
6
6
  import { escalateAndFinish } from './handover.mjs';
7
7
  import { writeState } from './state.mjs';
8
- import { keepTail } from './text.mjs';
8
+ import { outputBlock } from './text.mjs';
9
9
  import { setUpBeforeChecks } from './worktree-setup.mjs';
10
- const COMMENT_OUTPUT_CHARS = 3000;
11
10
  /**
12
11
  * Runs the configured check commands in the worktree before a push.
13
12
  * Gives `true` when every command passed, `false` when the fixer committed a fix (merge and check again),
@@ -59,15 +58,6 @@ function failure(job, command, result) {
59
58
  ? `The local check \`${command}\` did not finish in ${job.context.config.checksTimeoutMinutes} minutes.`
60
59
  : `The local check \`${command}\` failed with code ${result.code}.`;
61
60
  }
62
- function outputBlock(output) {
63
- const kept = keepTail(output.trim(), COMMENT_OUTPUT_CHARS);
64
- if (kept === '') {
65
- return '';
66
- }
67
- const longest = Math.max(2, ...(kept.match(/`+/g) ?? []).map((run) => run.length));
68
- const fence = '`'.repeat(longest + 1);
69
- return `\n\n${fence}\n${kept}\n${fence}`;
70
- }
71
61
  async function failedCheck(job, command, result) {
72
62
  const { context, log, state } = job;
73
63
  const { repo, base } = context;
package/dist/loop.mjs CHANGED
@@ -34,16 +34,14 @@ export async function runIssues(args, loop, seen = new Set()) {
34
34
  claiming = false;
35
35
  }
36
36
  }
37
- if (crash !== undefined) {
38
- throw crash.failure;
39
- }
40
- return loopResult(reports, stoppedAt, error);
37
+ return loopResult(reports, stoppedAt, error, crash);
41
38
  }
42
- function loopResult(reports, stoppedAt, error) {
39
+ function loopResult(reports, stoppedAt, error, crash) {
43
40
  return {
44
41
  reports,
45
42
  ...(stoppedAt === undefined ? {} : { stoppedAt }),
46
43
  ...(error === undefined ? {} : { error }),
44
+ ...(crash === undefined ? {} : { crash }),
47
45
  };
48
46
  }
49
47
  async function claimIssues(loop, seen, running, room) {
package/dist/ports.mjs CHANGED
@@ -2,9 +2,9 @@ import { runAgent } from './agents.mjs';
2
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
- import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
5
+ import { baseMoved, pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
6
6
  import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
7
- import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, saveSetupOutput, setAside, } from './git.mjs';
7
+ import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, revision, saveEdits, saveSetupOutput, setAside, } from './git.mjs';
8
8
  import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, issueEditors, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
9
9
  import { huntWorktree } from './hunt.mjs';
10
10
  import { ensureLabel, setLabel } from './labels.mjs';
@@ -21,6 +21,7 @@ async function runCheck(command, cwd, timeoutMs, tailChars) {
21
21
  export const PORTS = {
22
22
  abortMerge,
23
23
  addWorktree,
24
+ baseMoved,
24
25
  canWrite,
25
26
  changedFiles,
26
27
  closeIssue,
@@ -46,14 +47,12 @@ export const PORTS = {
46
47
  latestSubject,
47
48
  openBlockers,
48
49
  openIssues,
49
- push,
50
50
  pushToBase,
51
51
  reapplyRevert,
52
52
  removeWorktree,
53
53
  reopenIssue,
54
54
  repositorySlug,
55
55
  rerunFailedCi,
56
- resetToBase,
57
56
  revertOnBase,
58
57
  revision,
59
58
  runAgent,
package/dist/run.mjs CHANGED
@@ -69,11 +69,14 @@ async function handle(args, config, repo, recorder, controls) {
69
69
  concurrency: config.concurrency,
70
70
  };
71
71
  const print = controls.print ?? (async () => undefined);
72
- const { reports, stoppedAt, error } = args.watch || controls.watching !== undefined
72
+ const { reports, stoppedAt, error, crash } = args.watch || controls.watching !== undefined
73
73
  ? await watchRun(args, loop, context, controls, print)
74
74
  : await runIssues(args, loop);
75
75
  recordLoopEnd(recorder, stoppedAt, error);
76
76
  const summary = await endRun(recorder, reports);
77
+ if (crash !== undefined) {
78
+ throw crash.failure;
79
+ }
77
80
  if (!args.watch) {
78
81
  await print(summary);
79
82
  }
package/dist/text.mjs CHANGED
@@ -23,3 +23,13 @@ export function fitComment(comment, cut) {
23
23
  const splitsPair = /[\uD800-\uDBFF]/.test(comment.charAt(end - 1));
24
24
  return `${comment.slice(0, splitsPair ? end - 1 : end)}${cut}`;
25
25
  }
26
+ const COMMENT_OUTPUT_CHARS = 3000;
27
+ export function outputBlock(output, limit = COMMENT_OUTPUT_CHARS) {
28
+ const kept = keepTail(output.trim(), limit);
29
+ if (kept === '') {
30
+ return '';
31
+ }
32
+ const longest = Math.max(2, ...(kept.match(/`+/g) ?? []).map((run) => run.length));
33
+ const fence = '`'.repeat(longest + 1);
34
+ return `\n\n${fence}\n${kept}\n${fence}\n`;
35
+ }
package/dist/watch.mjs CHANGED
@@ -98,6 +98,9 @@ async function watchPasses(args, failed, watch) {
98
98
  for (;;) {
99
99
  const pass = await runIssues({ max: limit === undefined ? undefined : limit - handled(reports) }, watch, new Set(failed));
100
100
  addReports(reports, pass.reports);
101
+ if (pass.crash !== undefined) {
102
+ return { ...pass, reports };
103
+ }
101
104
  recordFailures(failed, pass.reports);
102
105
  if (handled(pass.reports) > 0) {
103
106
  await watch.passEnd(pass.reports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "9.8.1",
3
+ "version": "9.8.3",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",
@@ -50,7 +50,6 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@earendil-works/pi-coding-agent": "^1.5.2",
53
- "typebox": "^1.4.7",
54
53
  "ws": "^8.23.0"
55
54
  }
56
55
  }