next-issue 10.2.0 → 10.3.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 +3 -3
- package/dist/job.mjs +11 -2
- package/dist/land.mjs +1 -0
- package/dist/loop.mjs +35 -12
- package/dist/pipeline.mjs +7 -4
- package/dist/run.mjs +1 -1
- package/dist/skip.mjs +1 -1
- package/dist/slots.mjs +60 -0
- package/dist/watch.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Only one worker or command-line run goes at a time in a repository. Both hold on
|
|
|
38
38
|
|
|
39
39
|
Every command uses the main worktree of the repository as its root, the first one that `git worktree list` shows, even when it runs in a linked worktree. So `.next-issue/`, with the config, the locks, the worker socket, the saved state and the notes, and `.worktrees/` are always in the main worktree, and a run or worker started from a linked worktree gets the same refusal as one started from the main worktree.
|
|
40
40
|
|
|
41
|
-
A run
|
|
41
|
+
A run works on up to `concurrency` issues with an agent at the same time, 1 by default. Each claimed issue takes a slot. An approved issue frees its slot while it waits to land, while it lands and while it waits for the checks on the base, so the next issue's agents never wait for CI. When such an issue needs an agent again, for example the fixer for a conflict or for failed checks, it waits for a free slot, takes it before any new issue is claimed and frees it once the agent ends. So no more than `concurrency` agents run at once. When a slot frees up, the run claims the oldest unseen issue for it, and fetches the open issues again only when the last fetch left an unseen issue unclaimed or an issue has ended since. The run ends only once every issue has ended, including those waiting to land. Each issue has its own worktree and branch. Step 3 below and the removal of a worktree or branch run for one issue at a time, so two issues never change the git refs or worktrees of the repository at once. An issue skipped as blocked is tried again in that run once another issue is done, so an issue blocked by one that waits to land is claimed once its blocker closes. `--max <n>` counts the handled issues across the run, so with `--max 1` the run handles one issue. For each issue:
|
|
42
42
|
|
|
43
43
|
1. Claim the issue only when it holds the `status:todo` label and holds no `status:in-progress` or `status:in-review` label. A `status:done`, `status:needs-human` or `status:blocked` label always stops the claim, a resume too, except a `status:needs-human` issue with an answer to its hand-over that the run made, and except an issue whose finish a stop cut short and that was not handed over (see step 7 below). An issue that GitHub lists as blocked by an open issue waits, because its blocker closes only when the change of the blocker lands. An issue with saved state under `.next-issue/` resumes instead, whatever its other labels and blockers.
|
|
44
44
|
2. Add `status:in-progress` to the issue.
|
|
@@ -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 `### next-issue · Worker: 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. 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.
|
|
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, without a slot, 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
|
|
@@ -224,7 +224,7 @@ With no file, every field keeps its default. A field that is not in the file kee
|
|
|
224
224
|
| ----------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
225
225
|
| `remote` | `origin` | The git remote for the repository and the branches |
|
|
226
226
|
| `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 |
|
|
227
|
-
| `concurrency` | `1` | The most issues that
|
|
227
|
+
| `concurrency` | `1` | The most issues that an agent works on at the same time; an issue waiting to land or for checks holds no slot |
|
|
228
228
|
| `huntCap` | `1` | With `--hunt`, the hunter hunts only while fewer ready issues than this wait besides the running ones |
|
|
229
229
|
| `maxCiFixes` | `5` | The budget for check fixes per issue |
|
|
230
230
|
| `maxCommitFixes` | `10` | The budget for fixes of a commit that a git hook stopped, per issue |
|
package/dist/job.mjs
CHANGED
|
@@ -21,14 +21,23 @@ export async function withNotes(root, prompt, writable) {
|
|
|
21
21
|
export async function runRole(job, role, prompt, profile) {
|
|
22
22
|
const { config, ports, repo } = job.context;
|
|
23
23
|
const writable = role === 'implementer' || role === 'fixer';
|
|
24
|
-
|
|
24
|
+
const request = {
|
|
25
25
|
name: role,
|
|
26
26
|
cwd: job.worktree,
|
|
27
27
|
prompt: await withNotes(repo.root, prompt, writable),
|
|
28
28
|
profile,
|
|
29
29
|
model: config.models[role],
|
|
30
30
|
timeoutMs: minutesToMs(config.agentTimeoutMinutes),
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const took = (await job.slot?.take()) === true;
|
|
33
|
+
try {
|
|
34
|
+
return await ports.runAgent(job.log, request);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
if (took) {
|
|
38
|
+
job.slot?.free();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
export function fallbackTitle(issue) {
|
|
34
43
|
return `fix: resolve issue #${issue.number}`;
|
package/dist/land.mjs
CHANGED
|
@@ -43,6 +43,7 @@ function landing(job, work) {
|
|
|
43
43
|
return inLandingLock(job, () => unblocked(job, work));
|
|
44
44
|
}
|
|
45
45
|
function inLandingLock(job, work) {
|
|
46
|
+
job.slot?.free();
|
|
46
47
|
return oneAtATime(`${job.context.repo.root}#land`, async () => {
|
|
47
48
|
if (job.context.halted) {
|
|
48
49
|
return holdBack(job, 'run halted');
|
package/dist/loop.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import { Slots } from './slots.mjs';
|
|
1
2
|
export async function runIssues(args, loop, seen = new Set()) {
|
|
2
3
|
const limit = args.max;
|
|
3
|
-
const
|
|
4
|
+
const slots = new Slots(loop.concurrency ?? 1);
|
|
4
5
|
const reports = [];
|
|
5
6
|
const running = new Map();
|
|
6
7
|
let stoppedAt;
|
|
7
8
|
let error;
|
|
8
9
|
let crash;
|
|
9
10
|
let claiming = true;
|
|
10
|
-
|
|
11
|
-
const
|
|
11
|
+
let unclaimed = true;
|
|
12
|
+
const tried = { ended: new Set(), labels: new Map(), blocked: new Set() };
|
|
13
|
+
const room = () => slots.open() && (limit === undefined || handled(reports) + running.size < limit);
|
|
12
14
|
for (;;) {
|
|
13
|
-
if (claiming && room()) {
|
|
15
|
+
if (claiming && unclaimed && room()) {
|
|
14
16
|
try {
|
|
15
|
-
claiming = await claimIssues(loop, seen, tried, running, room);
|
|
17
|
+
({ claiming, unclaimed } = await claimIssues(loop, seen, tried, { running, slots }, room));
|
|
16
18
|
}
|
|
17
19
|
catch (failure) {
|
|
18
20
|
error = failure;
|
|
@@ -22,8 +24,14 @@ export async function runIssues(args, loop, seen = new Set()) {
|
|
|
22
24
|
if (running.size === 0) {
|
|
23
25
|
break;
|
|
24
26
|
}
|
|
25
|
-
const
|
|
27
|
+
const settled = await Promise.race([...running.values(), slots.freed()]);
|
|
28
|
+
if (settled === undefined) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const { issue, slot, report, failure } = settled;
|
|
26
32
|
running.delete(issue);
|
|
33
|
+
slot.free();
|
|
34
|
+
unclaimed = true;
|
|
27
35
|
if (report === undefined) {
|
|
28
36
|
crash ??= { failure };
|
|
29
37
|
claiming = false;
|
|
@@ -33,6 +41,12 @@ export async function runIssues(args, loop, seen = new Set()) {
|
|
|
33
41
|
if (retryable(report)) {
|
|
34
42
|
tried.ended.add(issue);
|
|
35
43
|
}
|
|
44
|
+
if (report.blocked === true) {
|
|
45
|
+
tried.blocked.add(issue);
|
|
46
|
+
}
|
|
47
|
+
if (report.outcome === 'done') {
|
|
48
|
+
readmitBlocked(seen, tried);
|
|
49
|
+
}
|
|
36
50
|
if (claiming && (loop.stop() || report.halt === true)) {
|
|
37
51
|
stoppedAt = issue;
|
|
38
52
|
claiming = false;
|
|
@@ -48,23 +62,24 @@ function loopResult(reports, stoppedAt, error, crash) {
|
|
|
48
62
|
...(crash === undefined ? {} : { crash }),
|
|
49
63
|
};
|
|
50
64
|
}
|
|
51
|
-
async function claimIssues(loop, seen, tried,
|
|
65
|
+
async function claimIssues(loop, seen, tried, pool, room) {
|
|
52
66
|
if (loop.stop()) {
|
|
53
|
-
return false;
|
|
67
|
+
return { claiming: false, unclaimed: false };
|
|
54
68
|
}
|
|
55
69
|
const issues = await loop.issues();
|
|
56
70
|
if (loop.stop()) {
|
|
57
|
-
return false;
|
|
71
|
+
return { claiming: false, unclaimed: false };
|
|
58
72
|
}
|
|
59
73
|
readmitChanged(issues, seen, tried);
|
|
60
74
|
for (const issue of issues.filter((candidate) => !seen.has(candidate.number))) {
|
|
61
75
|
if (!room()) {
|
|
62
|
-
|
|
76
|
+
return { claiming: true, unclaimed: true };
|
|
63
77
|
}
|
|
64
78
|
seen.add(issue.number);
|
|
65
|
-
|
|
79
|
+
const slot = pool.slots.claim();
|
|
80
|
+
pool.running.set(issue.number, loop.process(issue, undefined, slot).then((report) => ({ issue: issue.number, slot, report }), (failure) => ({ issue: issue.number, slot, failure })));
|
|
66
81
|
}
|
|
67
|
-
return true;
|
|
82
|
+
return { claiming: true, unclaimed: false };
|
|
68
83
|
}
|
|
69
84
|
function retryable(report) {
|
|
70
85
|
return report.outcome !== 'done' && (report.outcome !== 'error' || report.handedOver === true);
|
|
@@ -82,6 +97,14 @@ function readmitChanged(issues, seen, tried) {
|
|
|
82
97
|
}
|
|
83
98
|
tried.ended.clear();
|
|
84
99
|
}
|
|
100
|
+
function readmitBlocked(seen, tried) {
|
|
101
|
+
for (const number of tried.blocked) {
|
|
102
|
+
tried.ended.delete(number);
|
|
103
|
+
tried.labels.delete(number);
|
|
104
|
+
seen.delete(number);
|
|
105
|
+
}
|
|
106
|
+
tried.blocked.clear();
|
|
107
|
+
}
|
|
85
108
|
function labelKey(issue) {
|
|
86
109
|
return [...issue.labels].sort().join('\n');
|
|
87
110
|
}
|
package/dist/pipeline.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { hasLabel } from './labels.mjs';
|
|
|
11
11
|
import { newState, readState, resetState, } from './state.mjs';
|
|
12
12
|
import { beforeBaseSettled } from './unsettled.mjs';
|
|
13
13
|
import { setUp } from './worktree-setup.mjs';
|
|
14
|
-
export async function processIssue(context, issue, claimed = () => undefined) {
|
|
14
|
+
export async function processIssue(context, issue, claimed = () => undefined, slot) {
|
|
15
15
|
const { repo } = context;
|
|
16
16
|
const started = Date.now();
|
|
17
17
|
const log = context.recorder.scope({ issue: issue.number });
|
|
@@ -39,7 +39,7 @@ export async function processIssue(context, issue, claimed = () => undefined) {
|
|
|
39
39
|
try {
|
|
40
40
|
report = closing
|
|
41
41
|
? await finishClosing(context, issue, log, state, started)
|
|
42
|
-
: await work(context, issue, log, state, saved === undefined, handedOver, saved?.pendingHandOver);
|
|
42
|
+
: await work(context, issue, log, state, saved === undefined, handedOver, saved?.pendingHandOver, slot);
|
|
43
43
|
}
|
|
44
44
|
catch (error) {
|
|
45
45
|
if (!runStopped()) {
|
|
@@ -69,9 +69,12 @@ function startState(context, issue, saved, handedOver) {
|
|
|
69
69
|
const { pendingHandOver: _pending, ...rest } = saved;
|
|
70
70
|
return context.reset || handedOver ? resetState(saved, handedOver) : rest;
|
|
71
71
|
}
|
|
72
|
-
async function work(context, issue, log, state, start, handedOver, pending) {
|
|
72
|
+
async function work(context, issue, log, state, start, handedOver, pending, slot) {
|
|
73
73
|
const { job, setup } = await beforeBaseSettled(state, context.base, async () => {
|
|
74
|
-
const opened =
|
|
74
|
+
const opened = {
|
|
75
|
+
...(await openJob(context, issue, log, state, start, handedOver, pending)),
|
|
76
|
+
slot,
|
|
77
|
+
};
|
|
75
78
|
await settleReview(opened);
|
|
76
79
|
await settleSquash(opened);
|
|
77
80
|
return { job: opened, setup: await setUp(opened) };
|
package/dist/run.mjs
CHANGED
|
@@ -64,7 +64,7 @@ async function handle(args, config, repo, recorder, controls) {
|
|
|
64
64
|
const context = await startRun(args, config, repo, recorder, interrupts);
|
|
65
65
|
const loop = {
|
|
66
66
|
issues: () => pendingIssues(context),
|
|
67
|
-
process: (issue, claimed) => processIssue(context, issue, claimed),
|
|
67
|
+
process: (issue, claimed, slot) => processIssue(context, issue, claimed, slot),
|
|
68
68
|
stop: interrupts.afterIssue,
|
|
69
69
|
concurrency: config.concurrency,
|
|
70
70
|
};
|
package/dist/skip.mjs
CHANGED
|
@@ -57,7 +57,7 @@ export async function skipReport(context, log, issue, saved, started) {
|
|
|
57
57
|
}
|
|
58
58
|
if (blockers.length > 0) {
|
|
59
59
|
log.event('issue.skip', { title: issue.title, reason: 'blocked', blockers });
|
|
60
|
-
return skipped(issue);
|
|
60
|
+
return { ...skipped(issue), blocked: true };
|
|
61
61
|
}
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
package/dist/slots.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** The `concurrency` slots of a run; an issue that waits for a slot comes before a new claim. */
|
|
2
|
+
export class Slots {
|
|
3
|
+
size;
|
|
4
|
+
used = 0;
|
|
5
|
+
waiting = [];
|
|
6
|
+
changed;
|
|
7
|
+
constructor(size) {
|
|
8
|
+
this.size = size;
|
|
9
|
+
}
|
|
10
|
+
open() {
|
|
11
|
+
return this.used < this.size && this.waiting.length === 0;
|
|
12
|
+
}
|
|
13
|
+
claim() {
|
|
14
|
+
this.used += 1;
|
|
15
|
+
let held = true;
|
|
16
|
+
return {
|
|
17
|
+
free: () => {
|
|
18
|
+
if (held) {
|
|
19
|
+
held = false;
|
|
20
|
+
this.release();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
take: async () => {
|
|
24
|
+
if (held) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
await this.acquire();
|
|
28
|
+
held = true;
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
freed() {
|
|
34
|
+
if (this.changed === undefined) {
|
|
35
|
+
let resolve = () => undefined;
|
|
36
|
+
const promise = new Promise((settle) => {
|
|
37
|
+
resolve = settle;
|
|
38
|
+
});
|
|
39
|
+
this.changed = { promise, resolve };
|
|
40
|
+
}
|
|
41
|
+
return this.changed.promise;
|
|
42
|
+
}
|
|
43
|
+
acquire() {
|
|
44
|
+
if (this.open()) {
|
|
45
|
+
this.used += 1;
|
|
46
|
+
return Promise.resolve();
|
|
47
|
+
}
|
|
48
|
+
return new Promise((resolve) => this.waiting.push(resolve));
|
|
49
|
+
}
|
|
50
|
+
release() {
|
|
51
|
+
const next = this.waiting.shift();
|
|
52
|
+
if (next !== undefined) {
|
|
53
|
+
next();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.used -= 1;
|
|
57
|
+
this.changed?.resolve();
|
|
58
|
+
this.changed = undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/watch.mjs
CHANGED
|
@@ -12,10 +12,10 @@ export async function watchIssues(args, watch) {
|
|
|
12
12
|
try {
|
|
13
13
|
return await watchPasses(args, failed, {
|
|
14
14
|
...watch,
|
|
15
|
-
process: async (issue) => {
|
|
15
|
+
process: async (issue, _claimed, slot) => {
|
|
16
16
|
running.add(issue.number);
|
|
17
17
|
try {
|
|
18
|
-
return await watch.process(issue, claims.ring);
|
|
18
|
+
return await watch.process(issue, claims.ring, slot);
|
|
19
19
|
}
|
|
20
20
|
finally {
|
|
21
21
|
running.delete(issue.number);
|