The schedule order cannot tell a conflict: the forge answers 405 'Please try again later' #53

Merged
city-root merged 1 commit from worker/gascitypacks-uuv into main 2026-11-12 12:54:35 +00:00
Contributor

The schedule order now tells a conflicting pull request by what the forge says of the pull request, not by the words of its refusal. Fixes gascitypacks-uuv, found by the Operator's trial of the order (comment on #44, issuecomment-3010).

The problem

Forgejo 17.0.1 answers the merge request of a pull request that conflicts with its base with 405 "Please try again later". "conflict" is not in it, so strings.Contains(..., "conflict") in schedule.go never matched, and every conflicting pull request would have become a bead for the Operator instead of going to rework.

What changed

On forge_refused the order reads the pull request in-process, with the code of pr state (fetchPull and mergeability: the pull request alone, no checks, no reviews) and acts on mergeable:

The forge says The order
not_mergeable the rework order's trigger (row L12, 3.11 d, decision 3): no bead for the Operator, only the clock: auto_merge_trouble with reason not_mergeable. Two hours in a row is still the one stuck bead.
mergeable or draft no conflict as far as the forge knows: one bead for the Operator (forge_refused), as before. The bead and its mail now say what the forge says of the pull request.
the pull request is not open when read left to the next cycle, whose merge command gives its own answer (not_open and so on).
the read fails trouble error, retried next cycle, exit 1.

Which answer of the forge it relies on, and what it does while the forge has not computed it

It relies on mergeable of the forge's pull request object, a bare boolean. It is false for a conflict, for a conflict check still running (checking) and for a failed check alike, and the API does not say which (README, section "mergeable"). So the order does not try to tell them apart: it takes all three as not_mergeable, and the three have the same effect, nothing but the clock. A check that was still running is mended by the next cycle (two minutes later, the order asks again): the merge is then scheduled, auto_merge=scheduled is written and auto_merge_trouble is removed. A real conflict stays not_mergeable and is the rework order's (L13, not built yet) to read from the forge; until then the Operator hears of it at two hours.

Two things to know:

  • A refusal for another reason that arrives in the second between the merge request and the read (the check finishes, mergeable is true) makes one bead for the Operator at once, as every non-conflict refusal did. It is one bead per head, and rare.
  • The two-hour stuck bead for a conflict stays: it is the clock the order had, and L12 says a pull request that keeps refusing is a bead for the Operator. If you want a conflict never to reach the Operator, even at two hours, say so and it is a two-line change.

Not changed

The other steps of the trial (comment on #44) matched, and nothing they cover changed: scheduled, already_scheduled, merged, head_moved, not_open, wrong_base, missing, foreign, no_diff and the 500 are as they were. The order is still off unless FORGEJO_SCHEDULE=on. No shell was added.

Verification

  • go vet and go test in forgejo/assets/forgejo: pass.
  • New Go test with the forge's real answer for the case, HTTP 405 {"message":"Please try again later"}, run through the real prMergeAnswer and prMergeable against the fake forge with mergeable false (no bead), true (a bead) and a draft (a bead). Unit tests for each branch above, and for the retry of a check that was still running. The old conflict test, which fed the word "conflict", is replaced.
  • CHANGELOG checked with the v1 checker the CI runs: valid=true. README's schedule-order table updated.

Bead: gascitypacks-uuv

The schedule order now tells a conflicting pull request by what the forge says of the pull request, not by the words of its refusal. Fixes gascitypacks-uuv, found by the Operator's trial of the order (comment on #44, issuecomment-3010). ## The problem Forgejo 17.0.1 answers the merge request of a pull request that conflicts with its base with `405 "Please try again later"`. "conflict" is not in it, so `strings.Contains(..., "conflict")` in `schedule.go` never matched, and every conflicting pull request would have become a bead for the Operator instead of going to rework. ## What changed On `forge_refused` the order reads the pull request in-process, with the code of `pr state` (`fetchPull` and `mergeability`: the pull request alone, no checks, no reviews) and acts on `mergeable`: | The forge says | The order | |---|---| | `not_mergeable` | the rework order's trigger (row L12, 3.11 d, decision 3): **no bead for the Operator**, only the clock: `auto_merge_trouble` with reason `not_mergeable`. Two hours in a row is still the one `stuck` bead. | | `mergeable` or `draft` | no conflict as far as the forge knows: one bead for the Operator (`forge_refused`), as before. The bead and its mail now say what the forge says of the pull request. | | the pull request is not open when read | left to the next cycle, whose merge command gives its own answer (`not_open` and so on). | | the read fails | trouble `error`, retried next cycle, exit 1. | ## Which answer of the forge it relies on, and what it does while the forge has not computed it It relies on `mergeable` of the forge's pull request object, a bare boolean. It is false for a conflict, for a conflict check still running (`checking`) and for a failed check alike, and the API does not say which (README, section "mergeable"). So the order does not try to tell them apart: it takes all three as `not_mergeable`, and the three have the same effect, nothing but the clock. A check that was still running is mended by the next cycle (two minutes later, the order asks again): the merge is then scheduled, `auto_merge=scheduled` is written and `auto_merge_trouble` is removed. A real conflict stays `not_mergeable` and is the rework order's (L13, not built yet) to read from the forge; until then the Operator hears of it at two hours. Two things to know: - A refusal for another reason that arrives in the second between the merge request and the read (the check finishes, `mergeable` is true) makes one bead for the Operator at once, as every non-conflict refusal did. It is one bead per head, and rare. - The two-hour `stuck` bead for a conflict stays: it is the clock the order had, and L12 says a pull request that keeps refusing is a bead for the Operator. If you want a conflict never to reach the Operator, even at two hours, say so and it is a two-line change. ## Not changed The other steps of the trial (comment on #44) matched, and nothing they cover changed: `scheduled`, `already_scheduled`, `merged`, `head_moved`, `not_open`, `wrong_base`, `missing`, `foreign`, `no_diff` and the 500 are as they were. The order is still off unless `FORGEJO_SCHEDULE=on`. No shell was added. ## Verification - `go vet` and `go test` in `forgejo/assets/forgejo`: pass. - New Go test with the forge's real answer for the case, HTTP 405 `{"message":"Please try again later"}`, run through the real `prMergeAnswer` and `prMergeable` against the fake forge with `mergeable` false (no bead), true (a bead) and a draft (a bead). Unit tests for each branch above, and for the retry of a check that was still running. The old conflict test, which fed the word "conflict", is replaced. - CHANGELOG checked with the v1 checker the CI runs: `valid=true`. README's schedule-order table updated. Bead: gascitypacks-uuv
fix: the schedule order tells a conflict by the forge's mergeable, not by the words of a refusal (gascitypacks-uuv)
All checks were successful
test / changelog (pull_request) Successful in 5s
test / lint (pull_request) Successful in 21s
test / scripts (pull_request) Successful in 36s
492b9b7f20
The trial of the schedule order on a scratch repository (2026-11-12) found
that Forgejo 17.0.1 answers the merge request of a pull request that
conflicts with its base with 405 "Please try again later". The word
"conflict" is not in it, so the order's strings.Contains match never hit and
every conflicting pull request would have become a bead for the Operator
instead of going to rework (row L12 and section 3.11 d of the city's
docs/handoffs.md: a conflict is the rework order's trigger).

On forge_refused the order now reads the pull request with the code of
`pr state` (fetchPull and mergeability: the pull request alone, no checks and
no reviews) and acts on its mergeable. not_mergeable is the rework order's:
no bead for the Operator, only the clock (auto_merge_trouble, reason
not_mergeable; two hours is still the one stuck bead). The forge's boolean is
false for a conflict, for a conflict check still running and for a failed one
alike, so the order takes the three as one and asks again every cycle; a check
that was still running ends with the merge scheduled and the record removed.
mergeable or draft is a refusal for another reason and is one bead for the
Operator, as before. A pull request not open when read is left to the next
cycle; one that cannot be read is retried and counted.

Validation: go vet and go test ./... in forgejo/assets/forgejo, with a Go test
that runs the real prMergeAnswer and prMergeable against the fake forge with
405 "Please try again later" for mergeable false, true and a draft, and unit
tests of each branch; the CHANGELOG checked with the v1 checker CI runs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review left a comment

Review of 492b9b7f20 for gascitypacks-uuv. Checks of the head: success.

Verdict

pass

Findings

  • [minor] CHANGELOG.md:13: the note is a line under [Unreleased] in CHANGELOG.md. That was right at this head, which was cut before #52 (gascitypacks-c7j, 53a9474), and the work bead allows it ("as the repository takes them at your head"). On the current main the README's "Releases" section says a pull request "notes its change in a file of its own in .changelog/ … and never edits CHANGELOG.md". It does not block: the v2 checker passes the merged tree (valid=true, since a note added to CHANGELOG.md counts for missing-fragment), and changelog release folds a note already under [Unreleased] in with the fragments. Only if the branch is rebased for another reason: move the note into .changelog/schedule-conflict-mergeable.md under ### Fixed.

Verified

  • Requirement: the work bead gascitypacks-uuv, the PR description, and row L12 and section 3.11 (d) of gascity-root's docs/handoffs.md (origin/main). 3.11 (d) gives forge_refused two outcomes: a conflict is the rework trigger, and any other refusal is a bead for the Operator. refused() (forgejo/assets/forgejo/schedule.go:367-385) does exactly that. It decides by mergeable and never by the message: not_mergeable records only auto_merge_trouble with reason not_mergeable, mergeable/draft records the trouble and makes one bead for the Operator, and when the PR is not open the order does nothing until the next cycle. When the read fails it records trouble error and exits 1. The PR description says which forge answer it relies on (the mergeable boolean) and what happens while the forge is still checking (the next cycle asks again). This matches the README's mergeable section: the order never takes not_mergeable as a conflict on a single read. The only consequence is that no bead is raised.
  • prMergeable reuses fetchPull and mergeability from pr state, so it reads the pull request alone (one GET, no checks or reviews), and an open pull request with no mergeable field is an error. trouble() keeps Since when the reason changes, so the two-hour stuck bead still fires for a conflict that persists. The test checks this: no bead after 5 cycles, one stuck bead at troubleLimit. Once the check finishes, a scheduled answer clears the trouble (TestScheduleAForgeStillCheckingMergeabilityIsMendedByTheNextCycle).
  • The test with the forge's real answer, TestScheduleOfAConflictTheForgeAnswers405PleaseTryAgainLater, goes through the real prMergeAnswer and prMergeable against the fake Forgejo: 405 {"message":"Please try again later"} with mergeable false gives no bead and trouble not_mergeable, and true or a draft gives one bead. The branches for not open, read error, mergeable and draft each have a unit test. The other steps of the trial (scheduled, already_scheduled, merged, head_moved, not_open, wrong_base, missing, foreign, no_diff, the 500) take the same code path as before, and their tests still pass unchanged. FORGEJO_SCHEDULE is untouched, so the order is still off by default. No shell was added.
  • Merge: the head merged cleanly into current origin/main (53a9474, which includes #52). README.md auto-merged.
  • On the merged tree, with the city's variables removed (proved: 0): go vet ./... ok; go test ./... ok; go test -race -count=1 ./... ok (in forgejo/). I built the changelog checker from the tagged source of actions/validate@v2 (c19d67d, v2.0.1) and ran it with -base main: valid=true, no findings. I did not run the scripts job's shell tests or gc lint: this diff touches neither the shell nor the pack's TOML.
Review of 492b9b7f2085c045abd70ab6d564af3ff84b9b6c for gascitypacks-uuv. Checks of the head: success. ### Verdict pass ### Findings - [minor] CHANGELOG.md:13: the note is a line under `[Unreleased]` in `CHANGELOG.md`. That was right at this head, which was cut before #52 (gascitypacks-c7j, `53a9474`), and the work bead allows it ("as the repository takes them at your head"). On the current `main` the README's "Releases" section says a pull request "notes its change in a file of its own in `.changelog/` … and never edits `CHANGELOG.md`". It does not block: the v2 checker passes the merged tree (`valid=true`, since a note added to `CHANGELOG.md` counts for `missing-fragment`), and `changelog release` folds a note already under `[Unreleased]` in with the fragments. Only if the branch is rebased for another reason: move the note into `.changelog/schedule-conflict-mergeable.md` under `### Fixed`. ### Verified - Requirement: the work bead gascitypacks-uuv, the PR description, and row L12 and section 3.11 (d) of gascity-root's `docs/handoffs.md` (origin/main). 3.11 (d) gives `forge_refused` two outcomes: a conflict is the rework trigger, and any other refusal is a bead for the Operator. `refused()` (`forgejo/assets/forgejo/schedule.go:367-385`) does exactly that. It decides by `mergeable` and never by the message: `not_mergeable` records only `auto_merge_trouble` with reason `not_mergeable`, `mergeable`/`draft` records the trouble and makes one bead for the Operator, and when the PR is not open the order does nothing until the next cycle. When the read fails it records trouble `error` and exits 1. The PR description says which forge answer it relies on (the `mergeable` boolean) and what happens while the forge is still checking (the next cycle asks again). This matches the README's `mergeable` section: the order never takes `not_mergeable` as a conflict on a single read. The only consequence is that no bead is raised. - `prMergeable` reuses `fetchPull` and `mergeability` from `pr state`, so it reads the pull request alone (one GET, no checks or reviews), and an open pull request with no `mergeable` field is an error. `trouble()` keeps `Since` when the reason changes, so the two-hour `stuck` bead still fires for a conflict that persists. The test checks this: no bead after 5 cycles, one `stuck` bead at `troubleLimit`. Once the check finishes, a scheduled answer clears the trouble (`TestScheduleAForgeStillCheckingMergeabilityIsMendedByTheNextCycle`). - The test with the forge's real answer, `TestScheduleOfAConflictTheForgeAnswers405PleaseTryAgainLater`, goes through the real `prMergeAnswer` and `prMergeable` against the fake Forgejo: 405 `{"message":"Please try again later"}` with `mergeable` false gives no bead and trouble `not_mergeable`, and true or a draft gives one bead. The branches for not open, read error, mergeable and draft each have a unit test. The other steps of the trial (`scheduled`, `already_scheduled`, `merged`, `head_moved`, `not_open`, `wrong_base`, `missing`, `foreign`, `no_diff`, the 500) take the same code path as before, and their tests still pass unchanged. `FORGEJO_SCHEDULE` is untouched, so the order is still off by default. No shell was added. - Merge: the head merged cleanly into current `origin/main` (`53a9474`, which includes #52). `README.md` auto-merged. - On the merged tree, with the city's variables removed (proved: 0): `go vet ./...` ok; `go test ./...` ok; `go test -race -count=1 ./...` ok (in `forgejo/`). I built the changelog checker from the tagged source of `actions/validate@v2` (`c19d67d`, v2.0.1) and ran it with `-base main`: `valid=true`, no findings. I did not run the `scripts` job's shell tests or `gc lint`: this diff touches neither the shell nor the pack's TOML.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
mikluko/gascitypacks!53
No description provided.