ADR-0043: The executor follows its own pull request to any base¶
- Status: Accepted
- Date: 2026-11-19
Context¶
Issue #892. A person can change the base branch of a pull request on the code host. The executor read its pull request on the target branch only, so a pull request moved to another base looked closed or gone. The request then released the target lock, or opened a second pull request, while the first could still be merged. ADR-0030 section 1 says that a restart finds the existing pull request, and ADR-0021 says an amendment never widens what is allowed on its own authority. The fix widens two things, so they are decided here, and the amendments of ADR-0030 and ADR-0032 only record them. The amendment of 2026-11-19 below widens a third.
The three things:
- A read.
GetChangeRequest(by number) andListChangeRequestsAnyBaseanswer a pull request from the request's ownshadewright/branch on every base branch of the configured repository, whereGetChangeRequestandListChangeRequestsanswered only on the target branch. - One write.
CloseChangeRequestAnyBasecloses the executor's own marked pull request on a base other than the target branch. Its callers are both in the finalizer of a deleted request:closeOwnOnOtherBases(every open pull request with the request's marker on another base, with or without a recorded number) andcloseAllOwn(the recorded number, where the read finds it open on another base). The kill switch gates it likeCloseChangeRequest. - A second write, decided by ADR-0045 (an amendment cannot widen on its own authority, ADR-0021); the amendment of 2026-11-19 below names it. With reviewer hints on, the failed review check
shadewright/reviewon the head commit of the request's own pull request, in the cases ADR-0045 lists, written by a stale plan, a cancel or a stop. The decision as first accepted listed every check run on another base under "never" (below); this write is that exception. It is a failed check run, which can only stop a merge.
Decision¶
What is read. Only pull requests whose head is a shadewright/ branch of the configured repository and whose base is a branch of that repository. An entry from a fork, from another repository or from another branch is ErrUntrustedAnswer for the whole call, never skipped, because the answer is then not to the question asked. A pull request with a number that is not from such a branch is not found. More than MaxBranchChangeRequests (100) pull requests from the branch is ErrTooLarge: the read fails, the lock stays, and the look is retried. A base name is text from the code host (invariant 4). The provider returns it only when it passes the rule for target branches and leaves it out otherwise; the pull request is still returned with its number, which is what the lock is kept on. A condition message shows the name redacted and cut to 255 bytes.
What is closed. Only the executor's own pull request, and only on the deletion of the request: one that carries the request's marker, found by its recorded number or by the listing of every base. The close is retried like the close on the target branch. A recorded number is closed only when that pull request also carries the marker (an unmarked one is read as not the request's and left open), and the finalizer goes after the ones it found, with the exceptions in limit ©. A pull request without the marker is left open. A stop, a cancel, a deadline or a stale plan closes only on the target branch. The one that expires or is cancelled keeps the lock on a pull request open elsewhere and does not close it.
What is never done on another base. No push, comment, merge, update of title or body, and no auto-merge, once the executor has seen the pull request there, and no check run except the failed review check shadewright/review that a stale plan, a cancel or a stop writes with reviewer hints on (the second write above, decided by ADR-0045, limit (e) below). The executor then writes nothing to that pull request except that failed check and the close above. "Its own" pull request means one from the request's branch that carries the request's marker, not one the executor's App authored: a person with write access to the repository who opens a pull request from that branch and copies the marker gets the same treatment, as on the target branch, and every effect of that is a kept lock, a stop or a close.
Verdicts. The read by number has three verdicts of its own besides open, merged, closed and gone, and every caller handles them (cancel, deadline, supersede, kill switch, deletion, hint look, settlement; a test walks each stop path with the pull request moved):
- Open on another base: the watch and the adoption stop the request in phase
NeedsInterventionwith reasonChangeRequestOnOtherBase, naming the pull request, and the request keeps the lock (status.holdsTarget), saying inTargetHeldthat pull request #N is open on another base and that closing it releases the lock. Moving it back to the target branch does not: the pull request is then open on the target and keeps the lock, and the stopped request only looks at the lock, so it makes no new freshness check there. With reviewer hints on, the step that stops the request fails its review checkshadewright/reviewon the head commit, and the later looks of the stopped request write that failed check again while it is not the latest on the head (amendments of 2026-11-19 and 2026-11-20), so the pull request cannot merge on a check written before the stop; besides that check and the close at a deletion, nothing is written to the pull request. A cancel that finds it says so and endsCancelled, with the lock kept while the pull request is open. - Merged on another base: a merge there delivers nothing the request can verify. The watch and the adoption stop the request in phase
NeedsInterventionwith reasonChangeRequestOnOtherBasenaming the pull request; it records no merge and keeps no lock. A cancel ends the same way, notCancelled, since the change is merged and may be delivered. - Closed on another base is handled as closed, except that nothing is closed on the target branch (the table's row
closeRecordedNothing). A request that lost the write recording its pull request finds it by its marker on any base and in any state, so a restart never opens a second pull request after a person closed, moved or merged the first (invariant 5).
How the invariants hold. Invariant 3: the executor opens, pushes and merges nothing on another base, and the one close is of its own marked pull request, the same kind of close it makes on the target branch, on the deletion of the request. It neither bypasses a check nor changes a protected branch. Invariant 5: the marker and the recorded number are what find the pull request again, now on every base, so a restart finds the existing one instead of opening another. Invariant 4: the base name is only compared for equality with the configured target branch (that comparison picks the verdict, the close path and which listed entries are skipped) and shown redacted and bounded; it is never used as a ref, a path or an instruction. A pull request is kept or closed on its number, its head branch, its repository and its marker.
Consequences¶
The lock is no longer released because a person moved a pull request. The cost is a second read: with no number recorded, a request lists the pull requests of its branch on every base before it releases, and the finalizer lists them before it goes.
Known limits:
- (a) Removed by the amendment of 2026-11-19: any open pull request from the request's branch keeps the lock on every base, marked or not.
- (b) A merge on another base releases the lock on one read. A base branch that is later merged into the target branch then delivers a change the request did not verify. No request records it. A person is told by the stop reason,
ChangeRequestOnOtherBase. - © Narrowed by the amendment of 2026-11-19 (a changed target branch no longer stops the close). The finalizer lets go without closing in some cases: when a close or a listing still fails 24 hours after the first failure (
cleanupFailingBound, and the shorter grace for a refusal), and at once when the plan's repository is gone from the settings (errRepositoryGone), where nothing can be read or closed. An entry that cannot be used (ErrRepositoryUnusable) or a missingRemediationSettingsobject is a failure of the cleanup, retried within the 24 hour bound (#925). A marked pull request can then stay open on another base with no lock, and a person closes it. The Warning EventPullRequestLeftOpensays so in each case. - (d) A cancel, an expiry, a stop or a stale plan closes nothing on another base, so a stopped request can hold the target until a person closes or moves the pull request.
TargetHeldis the signal. - (e) A window between a read and a write. The executor reads the pull request and then writes (a handoff's commit to the branch, the review check on the head commit). A person who moves the pull request to another base between the two gets that one write on a pull request that is now elsewhere, and a check run belongs to the commit, so a passing check written before a move also shows on the new base. Branch protection of that base still applies. In the other direction, a pull request moved back to the target branch after the request stopped keeps the review check it had and gets no new one, so a person can merge a plan that is no longer fresh; the request is final and records nothing. With reviewer hints on, this second half is removed by the amendment of 2026-11-19: a stop now fails the review check. With hints off it stays: the executor owns no review check then and writes none at a stop, so the moved-back pull request keeps whatever check it had.
- (f) The cap has no time bound. More than 100 pull requests from the branch keep the lock for as long as they exist: the look fails closed and is retried.
Alternatives considered¶
- Ignore other bases. This is the defect of #892: a moved pull request looks gone, the lock is released and a second pull request can be opened.
- Refuse to act and leave the moved pull request open for a person. The lock would be kept, but a deleted request would leave an open pull request carrying its marker and branch, which can still merge.
- Close the marked pull request on another base at a cancel or at expiry. A person moved it there on purpose, and a close on a stop is a second write beyond the target branch that the decision of #892 does not take; the cost is limit (d), and
TargetHeldtells the person what holds the target. - Move it back to the target branch. That is a write on a pull request a person changed on purpose, and it can fail on the host's rules.
Amendments¶
2026-11-19: one verdict table, the lock on any open pull request, a failed check at a stop (#925)¶
Built in #925. Limit (a) is removed, the second half of limit (e) is removed with reviewer hints on, and limit © is narrowed. One write is widened, the failed review check in the cases ADR-0045 lists, written by a stale plan, a cancel or a stop, only with reviewer hints on. This amendment does not widen it: ADR-0045 decides it, and this entry only says how it is built:
- One verdict table. Every caller reads what a verdict means from one table in the executor (
verdictTable), with a row for each verdict and a column for each decision; a test built from the list of verdicts fails when a row or a cell is missing, and another fails when code outside the table compares verdicts. Closed on another base is now a verdict of its own (closed elsewhere), which the callers handle like closed: a close on the target branch has nothing to close there. - Gone only after every base. A recorded number read as not found concludes gone only after the listing of every base found nothing; until then the lock is kept.
- Limit (a) is removed. Any open pull request from the request's branch keeps the lock on every base, marked or not, as decided on 2026-11-19. Only a marked one is adopted or closed.
TargetHeldnames the pull request that holds the target. - Limit (e), second half, is removed with reviewer hints on. The executor owns the review check only with hints on, so only then does a stop write it; with hints off the second half of limit (e) stays as a limit. A request that stops while its own pull request is open, on the target branch or on another base, fails its review check
shadewright/reviewon the head commit: in the step that stops it for a pull request open on another base, and at every look of the stopped holder while the check is not yet failed, so a stop for any other reason gets it at its next look and a failed write is tried again there. While it cannot be written (the Git host fails the write, writes are paused, or the settings permit no write: the repository is gone, its entry cannot be used or names another target branch), the request says so with conditionReviewCheckNotFailedand its cause, and a Warning EventReviewCheckNotFailedwhen the condition is set or its cause changes; the write that records the failed check removes it. A stopped holder's look follows one rule (decision of 2026-11-20 on #925, ADR-0046): while the look leaves the lock held, by its own pull request on any base or by another open pull request from its branch, it writes the failed check on the recorded head unless the Git host already shows it last, whatever its own pull request is (open elsewhere, closed on any base, merged elsewhere, gone). Through a new installation of the repository it writes the same check, settled or not and whichever pull request keeps the lock, but a stopped holder reaches a new installation only after its stale cleanup stopped on a refusal; any other stopped holder reads the repository as gone after an installation change and writes nothing (ADR-0046, decision of 2026-11-21, limit (e)). A look that releases the lock ends the condition, and so does the write that records a merge, a look of a request that owns no review check any more (hints off, a handoff) and the first write of a deletion; each says so in the log. The writes of this rule beyond ADR-0045 are decided by ADR-0046, accepted on 2026-11-21. Moved back to the target branch, the pull request keeps the lock and cannot merge on a check written before the stop. This is the one write besides the close that the executor makes to a pull request on another base, and it is a widened write that ADR-0045 decides: the decision as first accepted listed it under "never". A stale plan and a cancel write the same failed check when their read of the pull request by number finds it open or closed on another base, or gone without a new installation; ADR-0045 lists the cases. It is a failed check run, which can only stop a merge. The section "What is never done on another base" holds with that exception, and the third item of the context names it. The first half of limit (e), the window between a read and a write, stays. - Limit © is narrowed. The finalizer of a request whose repository entry now names another target branch closes its own pull requests through the recorded target branch and on every other base, instead of letting go. When the plan's repository is gone from the settings, nothing can be read or closed: the finalizer still goes, and records the Warning Event
PullRequestLeftOpen. An entry that cannot be used, or a missingRemediationSettingsobject, is a failure of the cleanup instead (CleanupFailingwith reasonRepositoryUnusableorSettingsNotFound), tried again within its 24 hour bound, since the pull request may be open and the entry or the object may come back (#786, third round; #925). - The provider contract. A listing never leaves out the name of the target branch; an empty base name always means another base.
- The failed check stays the last one (2026-11-20). A reconcile that worked from an older cached copy of the request could write a pending check over the failed one a stop had just written, and the request stayed stopped with a check that no longer said so (the Git waits model, one seed in 200,000). This is the executor overwriting its own verdict, not the window of limit (e), so it is fixed: before the merge gate writes the review check (in progress, passed, or failed on too many reviews) the request is read live, from the API server, and a request that is stopped, released or being deleted there gets no check from that reconcile. A request the API server no longer has (the read answers not found) is gone, which is not a failed read: nothing is written for it, a pending or failed check no more than a pass, since no request is left whose next look would put the stop's failed check back. When the live read fails, the only check written is the downgrade of a pass (2026-11-20, after a fifth overwritten verdict): a pending or failed check goes on the head only when its last
shadewright/reviewcheck is a success, as a pass that no longer rests on an approval must not stay. Over a failed or pending check, or on a head with none, a failed live read writes nothing, and a passing check is never written without a live read that worked. A stop's failed check is then never covered by a check from an older copy, which a stopped holder's look would put back only at its next look. A failed live read that writes nothing sets conditionApprovedFalse with reasonReviewCheckLiveReadFaileduntil a look writes the check or finds the Git host already showing what the reviews want (a look that returns early, with its comments behind or in a refusal's backoff, keeps it), and the look is tried again at its usual pace. The failed check of a stale plan, a cancel or a stop is written without that read: nothing it can go over passes a merge. A stopped holder that keeps the lock also reads the latest review check of the head at each of its looks once the failed check is recorded, and writes the failed check again when the Git host shows another state last or none: one read and at most one write per look, within the looks above, with no polling of its own (a failed status write after the check write repeats the write at the error backoff, ADR-0046 limit (g)). A look that cannot tell (the read fails, or the settings permit no read) writes nothing and records the Warning EventStoppedCheckUnreadonce when such looks start on a head. Both are reads and writes this amendment already allows (the request itself, and the check runshadewright/reviewon the head of its own pull request, on another base the write ADR-0045 decides); this entry widens nothing. ADR-0028 records the change to its merge gate in its entry of 2026-11-20. - Still a known limit: a pull request reopened after the request released the lock does not take the lock back. A released request asks the Git host nothing, and taking the lock again needs an admission path of its own; that is split out to #940.