Rebase a pull request that is behind main, instead of retrying it for an hour #148

Merged
nectenda-agent merged 1 commit from worktree-queue-outdated-fix into main 2026-09-24 15:31:18 +01:00
Collaborator

The merge queue never rebased an outdated PR. It trusted pr.base.sha, which Forgejo reports as the base branch's current tip, so every PR looked up to date. NEC-49 (#143) was refused as "behind the base branch" every 2 minutes for an hour, blocking the queue.

  • Up to date means merge_base === main head, nothing else.
  • An "outdated" merge refusal leads to a rebase.
  • Any other refusal is retried at most 3 ticks, then the card goes to Blocked and the queue moves on.
  • The test fake now behaves like Forgejo; the old code fails two tests against it. All three rules were mutation-checked.

Changelog

NONE

The merge queue never rebased an outdated PR. It trusted `pr.base.sha`, which Forgejo reports as the base branch's current tip, so every PR looked up to date. NEC-49 (#143) was refused as "behind the base branch" every 2 minutes for an hour, blocking the queue. - Up to date means `merge_base === main head`, nothing else. - An "outdated" merge refusal leads to a rebase. - Any other refusal is retried at most 3 ticks, then the card goes to Blocked and the queue moves on. - The test fake now behaves like Forgejo; the old code fails two tests against it. All three rules were mutation-checked. ## Changelog NONE
Rebase a pull request that is behind main, instead of retrying it for an hour
All checks were successful
Release note / release-note (pull_request) Successful in 14s
CI / build (pull_request) Successful in 5m3s
CI / e2e (pull_request) Successful in 5m9s
CI / promote (pull_request) Has been skipped
1d106bb0f4
The merge queue decided a pull request was up to date if its merge base
or its `base.sha` matched main's head. Forgejo reports the base branch's
*current tip* as `base.sha`, so that half was always true: the queue
never rebased, and retried a merge that Forgejo refused as "behind the
base branch" every two minutes. NEC-49 (PR #143) sat like that for an
hour, and everything behind it waited.

The tests did not catch it because their fake pull request had
`base: { sha: 'x' }`. It modelled what I assumed Forgejo returns, not
what it does. The fake now reports main's tip there and refuses an
outdated merge with Forgejo's own message, and against it the old
check fails two tests.

- Up to date is `merge_base === main's head`, and nothing else.
- A merge refused as outdated (main moved between the check and the
  merge) is rebased, not retried.
- Any other refusal is retried at most three ticks running, then the
  card goes to Blocked with the message and the queue moves on. A loop
  that only writes to a log is how this went unnoticed.

Each rule was broken once to see its test fail.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015k9tkUtbU3wBpCHAHq7Qas
cruelacid force-pushed worktree-queue-outdated-fix from 1d106bb0f4
All checks were successful
Release note / release-note (pull_request) Successful in 14s
CI / build (pull_request) Successful in 5m3s
CI / e2e (pull_request) Successful in 5m9s
CI / promote (pull_request) Has been skipped
to 868358c717
All checks were successful
Release note / release-note (pull_request) Successful in 13s
CI / build (pull_request) Successful in 4m27s
CI / e2e (pull_request) Successful in 5m13s
CI / promote (pull_request) Has been skipped
CI / build (push) Successful in 5m15s
CI / e2e (push) Successful in 5m33s
CI / promote (push) Successful in 31s
2026-09-24 15:22:57 +01:00
Compare
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Nectenda/nectenda!148
No description provided.