Landing L12: the schedule order, built and not switched on #44

Merged
city-root merged 2 commits from worker/gascitypacks-0wh into main 2026-11-12 11:14:15 +00:00
Contributor

What this adds

Landing row L12 (docs/handoffs.md in gascity-root, 3.1 P3 and 3.11 d): the forgejo pack's schedule order, built and not switched on.

  • gc forgejo order schedule, a subcommand of the pack's Go tool, behind a two-line assets/scripts/schedule.sh and orders/schedule.toml (exec, cooldown 2 minutes). Every cycle, for each closed bead with merge_result=pull_request, it runs pr merge --expect-head <gc.work_commit> --target <target, else the default branch> in-process and handles each answer as table 3.11 d says. The README's section "The schedule order" has the table.
  • The switch: FORGEJO_SCHEDULE=on in the order's environment, which a city gives with the [[orders.overrides]] entry it already has for the order's FORGEJO_TOKEN_FILE. Unset, or anything but on: one line printed, no bead read, no forge request, no gc call. TestScheduleWithTheSwitchOffReadsAndSchedulesNothing pins it with a store that fails on any call and a forge that counts requests, for seven values.
  • An instance for the HQ store is the pack imported at the city level, as the merge order's is. Nothing in this pull request enables it in a city.
  • State kept on the bead of the head: auto_merge=scheduled, and auto_merge_trouble ({"reason","cycles","since"}) while a merge stays unscheduled.
  • The bead for the Operator is #46's bead. The merge order (#46, order.go) makes a bead for the Operator with pr_url and pr_event, looks it up in any status first, and mails with --dedup. This order now makes its bead through that same code, which this round lifted out of the merge order (operatorBead, mailOperatorBead, findOperator, gcFunc in order.go): the bead carries pr_url, pr_event (stuck, no_worker, wrong_base, missing, foreign or forge_refused), pr_head and work_bead; it is found by event, pull request and head (by the work bead when there is no pull request or no head); the mail is --notify --dedup <event>:<url>:<head>. pr_event is what keeps the merge order's scan of the old shape off it, and the head_moved check skips beads that carry it. The first version of this pull request used stuck_head and stuck_event with no pr_event, and the merge order would have closed such a bead as shipped at the merge, or handed it over a second time; TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder runs both orders over one fake city and fails if the skip is removed.

Choices worth a look

  • A forge_refused whose message contains "conflict" is left to the rework order (L13) and only counts toward the two hours; any other is an Operator bead at once. The word is a guess at Forgejo's wording: step 6 of the trial records the real message.
  • Only a bead the order has just made is mailed. gc mail send --dedup suppresses a send only while the earlier mail is un-archived, so a mail every two minutes for a bead already known would come back as soon as the Operator archived it. The price: a mail that fails after its bead was made is not retried; the run says so and exits 1.
  • A closed bead with no pr_url, or a gc.work_commit that is not a full commit, used to be a line on stderr every cycle. It is now counted in auto_merge_trouble as no_head, and the third cycle in a row is a bead for the Operator (event stuck, found by the work bead), since the merge order skips a bead with no pr_url and nobody else would notice.
  • rig = "*" in the [[orders.overrides]] entry reaches the HQ instance as well as every rig's: in this city, where merge has that one entry, gc order show merge --json prints the entry's env for the HQ instance ("rig": null) and for merge:rig:gascitypacks. The README says so, and how to switch on only some stores.
  • head_moved makes a bead for the Operator only when every bead with the pull request's pr_url is closed and none holds the new head as gc.work_commit. The order's own beads for the Operator are not counted (a test caught that they would hide the next head).
  • Writing metadata on a closed bead (gc bd update --set-metadata) is assumed to work, as P2 and P8 assume it. Not tried here: the trial step 7 shows it.
  • client.defaultBranch is openPull's first request taken out, so the order and pr open read the default branch the same way.

Checked

go vet, go test and go test -race ./... of the forgejo module (GOPROXY=off), tests/formula.sh (under env -i: in a Worker's environment it fails on the throwaway city, gascitypacks-pmn), tests/merge.sh, gc lint ., and the v1 changelog checker built from its tag (valid=true), on the branch rebased onto main at 83adff9. The Go tests use one fake of gc for the store, the agents and the mail, a fake gc executable for the argument lists and the directory, and the existing fake forge. Nothing was run against the real forge.

The trial the Operator runs before the switch-on

It needs the review account, so it is not the Worker's. Handoffs questions 6 and 11 and decision 11 ride on it. Use a scratch repository on sarak.sh, gascity-root/schedule-trial, with main protected the way production's is: one approval from city-root-review, the checks required, and dismiss_stale_approvals on. F is the pack's tool from this branch (the city's 0.5.0 has no pr merge yet), CITY the token file of gascity-root, REV the token file of city-root-review, C a clone of the scratch repository.

F="go tool -C <checkout of this branch>/forgejo forgejo"
CITY=/Users/mikluko/.config/gascity-root/forgejo-token   # gascity-root
REV=<token file of city-root-review>
cd "$C" && git switch -c trial && echo one >trial.txt && git add trial.txt && git commit -m trial && git push -u origin trial
PR=$(FORGEJO_TOKEN_FILE=$CITY $F pr open --repo "$C" --title "schedule trial")
H1=$(git rev-parse HEAD)
st() { FORGEJO_TOKEN_FILE=$CITY $F pr state --json --repo "$C" --pr "$PR"; }
sched() { FORGEJO_TOKEN_FILE=$CITY $F pr merge --json --repo "$C" --pr "$PR" --expect-head "$1" --target main; echo "exit $?"; }
# Command Expected by 3.11 If the forge says otherwise
1 sched $H1 outcome:"scheduled", exit 0; the pull request stays open even with green checks (no event follows) exit 9 forge_refused: record forge_message. A refusal about the account or the protection answers question 11 (the city's account cannot schedule into protected main): L12 cannot be switched on until it is mended
2 sched $H1 again already_scheduled, exit 0 scheduled again: the forge no longer answers 409, so already_scheduled never comes and the order's idempotence is by another route; record it
3 echo two >>trial.txt && git commit -am two && git push, H2=$(git rev-parse HEAD), then sched $H1, sched $H2 sched $H1: exit 3 head_moved; sched $H2: already_scheduled, so the push did not remove the schedule (3.11, row 3) scheduled for $H2: the push removed it. The order still re-runs every cycle, so it is mended in two minutes; correct 3.11 and the README
4 FORGEJO_TOKEN_FILE=$REV $F pr review --json --repo "$C" --pr "$PR" --expect-head $H2 --event APPROVED, wait for the checks, st posted; with the checks green the approval is the event that merges: st shows merged within a minute still open with green checks and the approval: the approval of the head does not start the forge's merge check, so the nudge is needed in the normal path and not only in the corner case (rule 6 of 3.1, 3.11 c): stop and tell the user
5 A second pull request, H3: approve it and wait for green before step 1, then sched $H3 scheduled, and it stays open: nothing starts the check (3.11 c) merged at once: the forge does check on schedule, and the nudge (L22) is not needed
5b Then, as gascity-root: curl -X POST -H "Authorization: token $(cat $CITY)" -H 'Content-Type: application/json' -d '{"state":"success","context":"city/merge"}' https://sarak.sh/api/v1/repos/gascity-root/schedule-trial/statuses/$H3 the pull request merges: a status of a context nobody requires starts the check (question 10, decision 12) 403/404 on the post: the account may not post a status; open and unchanged after it: the status does not start the check, and decision 12 is asked again
6 A fourth pull request that conflicts with main; sched its head exit 9 forge_refused: write down the exact forge_message; the order treats a message with "conflict" in it as the rework order's a message without the word: change the match in schedule.go (strings.Contains(..., "conflict")) before the switch-on
7 The order itself: in a scratch city with a rig scratch, create a bead, give it merge_result=pull_request, pr_url=$PR, gc.work_commit=$H5 (a fresh pull request's head), close it, then FORGEJO_TOKEN_FILE=$CITY GC_RIG_ROOT=<the rig> $F order schedule (it prints it is off), then the same with FORGEJO_SCHEDULE=on first run: off, nothing changed on the forge or the bead. Second: scheduled; the bead has auto_merge=scheduled, written on a closed bead; a repeat prints already_scheduled and writes nothing gc bd update refusing a closed bead: P2, P8 and this order all write on closed beads, and the design needs another route
8 Step 7 with H5 replaced by a stale head head_moved printed; one bead for the Operator (pr_event=no_worker, with pr_url and pr_head) once nobody holds the pull request's head, one mail, and no second bead or mail after another run a bead without pr_event, or the merge order closing it: gc bd show it and tell the Operator
9 Step 7's bead with the pull request then merged (or closed), and gc order run merge the Operator's bead of step 8 stays open and assigned, with no pr_closed and no gc.work_outcome the merge order touched it: the pr_event skip is not working in the real store

After 1 to 5b, tell the user the results, and record them in docs/handoffs.md 3.11 and the README's "What Forgejo does with a scheduled merge". Only then does the city turn the order on: FORGEJO_SCHEDULE = "on" in the order's [[orders.overrides]] entry, and only after the user has confirmed dismiss_stale_approvals on each repository (decision 11).

🤖 Generated with Claude Code

Bead: gascitypacks-0wh

## What this adds Landing row L12 (`docs/handoffs.md` in gascity-root, 3.1 P3 and 3.11 d): the forgejo pack's **`schedule` order**, built and **not switched on**. - `gc forgejo order schedule`, a subcommand of the pack's Go tool, behind a two-line `assets/scripts/schedule.sh` and `orders/schedule.toml` (exec, cooldown 2 minutes). Every cycle, for each closed bead with `merge_result=pull_request`, it runs `pr merge --expect-head <gc.work_commit> --target <target, else the default branch>` in-process and handles each answer as table 3.11 d says. The README's section "The schedule order" has the table. - **The switch:** `FORGEJO_SCHEDULE=on` in the order's environment, which a city gives with the `[[orders.overrides]]` entry it already has for the order's `FORGEJO_TOKEN_FILE`. Unset, or anything but `on`: one line printed, no bead read, no forge request, no gc call. `TestScheduleWithTheSwitchOffReadsAndSchedulesNothing` pins it with a store that fails on any call and a forge that counts requests, for seven values. - An instance for the HQ store is the pack imported at the city level, as the `merge` order's is. Nothing in this pull request enables it in a city. - State kept on the bead of the head: `auto_merge=scheduled`, and `auto_merge_trouble` (`{"reason","cycles","since"}`) while a merge stays unscheduled. - **The bead for the Operator is #46's bead.** The merge order (#46, `order.go`) makes a bead for the Operator with `pr_url` and `pr_event`, looks it up in any status first, and mails with `--dedup`. This order now makes its bead through that same code, which this round lifted out of the merge order (`operatorBead`, `mailOperatorBead`, `findOperator`, `gcFunc` in `order.go`): the bead carries `pr_url`, `pr_event` (`stuck`, `no_worker`, `wrong_base`, `missing`, `foreign` or `forge_refused`), `pr_head` and `work_bead`; it is found by event, pull request and head (by the work bead when there is no pull request or no head); the mail is `--notify --dedup <event>:<url>:<head>`. `pr_event` is what keeps the merge order's scan of the old shape off it, and the `head_moved` check skips beads that carry it. The first version of this pull request used `stuck_head` and `stuck_event` with no `pr_event`, and the merge order would have closed such a bead as shipped at the merge, or handed it over a second time; `TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder` runs both orders over one fake city and fails if the skip is removed. ## Choices worth a look - A `forge_refused` whose message contains "conflict" is left to the rework order (L13) and only counts toward the two hours; any other is an Operator bead at once. The word is a guess at Forgejo's wording: step 6 of the trial records the real message. - Only a bead the order has just made is mailed. `gc mail send --dedup` suppresses a send only while the earlier mail is un-archived, so a mail every two minutes for a bead already known would come back as soon as the Operator archived it. The price: a mail that fails after its bead was made is not retried; the run says so and exits 1. - A closed bead with no `pr_url`, or a `gc.work_commit` that is not a full commit, used to be a line on stderr every cycle. It is now counted in `auto_merge_trouble` as `no_head`, and the third cycle in a row is a bead for the Operator (event `stuck`, found by the work bead), since the merge order skips a bead with no `pr_url` and nobody else would notice. - `rig = "*"` in the `[[orders.overrides]]` entry reaches the HQ instance as well as every rig's: in this city, where `merge` has that one entry, `gc order show merge --json` prints the entry's `env` for the HQ instance (`"rig": null`) and for `merge:rig:gascitypacks`. The README says so, and how to switch on only some stores. - `head_moved` makes a bead for the Operator only when every bead with the pull request's `pr_url` is closed and none holds the new head as `gc.work_commit`. The order's own beads for the Operator are not counted (a test caught that they would hide the next head). - Writing metadata on a **closed** bead (`gc bd update --set-metadata`) is assumed to work, as P2 and P8 assume it. Not tried here: the trial step 7 shows it. - `client.defaultBranch` is `openPull`'s first request taken out, so the order and `pr open` read the default branch the same way. ## Checked `go vet`, `go test` and `go test -race ./...` of the forgejo module (GOPROXY=off), `tests/formula.sh` (under `env -i`: in a Worker's environment it fails on the throwaway city, gascitypacks-pmn), `tests/merge.sh`, `gc lint .`, and the v1 changelog checker built from its tag (`valid=true`), on the branch rebased onto main at 83adff9. The Go tests use one fake of gc for the store, the agents and the mail, a fake `gc` executable for the argument lists and the directory, and the existing fake forge. **Nothing was run against the real forge.** ## The trial the Operator runs before the switch-on It needs the review account, so it is not the Worker's. Handoffs questions 6 and 11 and decision 11 ride on it. Use a scratch repository on sarak.sh, `gascity-root/schedule-trial`, with `main` protected the way production's is: one approval from `city-root-review`, the checks required, and **`dismiss_stale_approvals` on**. `F` is the pack's tool from this branch (the city's 0.5.0 has no `pr merge` yet), `CITY` the token file of `gascity-root`, `REV` the token file of `city-root-review`, `C` a clone of the scratch repository. ```sh F="go tool -C <checkout of this branch>/forgejo forgejo" CITY=/Users/mikluko/.config/gascity-root/forgejo-token # gascity-root REV=<token file of city-root-review> cd "$C" && git switch -c trial && echo one >trial.txt && git add trial.txt && git commit -m trial && git push -u origin trial PR=$(FORGEJO_TOKEN_FILE=$CITY $F pr open --repo "$C" --title "schedule trial") H1=$(git rev-parse HEAD) st() { FORGEJO_TOKEN_FILE=$CITY $F pr state --json --repo "$C" --pr "$PR"; } sched() { FORGEJO_TOKEN_FILE=$CITY $F pr merge --json --repo "$C" --pr "$PR" --expect-head "$1" --target main; echo "exit $?"; } ``` | # | Command | Expected by 3.11 | If the forge says otherwise | |---|---|---|---| | 1 | `sched $H1` | `outcome:"scheduled"`, exit 0; the pull request stays **open** even with green checks (no event follows) | exit 9 `forge_refused`: record `forge_message`. A refusal about the account or the protection answers **question 11** (the city's account cannot schedule into protected `main`): L12 cannot be switched on until it is mended | | 2 | `sched $H1` again | `already_scheduled`, exit 0 | `scheduled` again: the forge no longer answers 409, so `already_scheduled` never comes and the order's idempotence is by another route; record it | | 3 | `echo two >>trial.txt && git commit -am two && git push`, `H2=$(git rev-parse HEAD)`, then `sched $H1`, `sched $H2` | `sched $H1`: exit 3 `head_moved`; `sched $H2`: `already_scheduled`, so **the push did not remove the schedule** (3.11, row 3) | `scheduled` for `$H2`: the push removed it. The order still re-runs every cycle, so it is mended in two minutes; correct 3.11 and the README | | 4 | `FORGEJO_TOKEN_FILE=$REV $F pr review --json --repo "$C" --pr "$PR" --expect-head $H2 --event APPROVED`, wait for the checks, `st` | `posted`; with the checks green the **approval is the event that merges**: `st` shows `merged` within a minute | still open with green checks and the approval: the approval of the head does not start the forge's merge check, so the nudge is needed in the normal path and not only in the corner case (rule 6 of 3.1, 3.11 c): stop and tell the user | | 5 | A second pull request, `H3`: approve it and wait for green **before** step 1, then `sched $H3` | `scheduled`, and it stays open: nothing starts the check (3.11 c) | merged at once: the forge does check on schedule, and the nudge (L22) is not needed | | 5b | Then, as `gascity-root`: `curl -X POST -H "Authorization: token $(cat $CITY)" -H 'Content-Type: application/json' -d '{"state":"success","context":"city/merge"}' https://sarak.sh/api/v1/repos/gascity-root/schedule-trial/statuses/$H3` | the pull request merges: a status of a context nobody requires starts the check (question 10, decision 12) | 403/404 on the post: the account may not post a status; open and unchanged after it: the status does not start the check, and decision 12 is asked again | | 6 | A fourth pull request that conflicts with `main`; `sched` its head | exit 9 `forge_refused`: write down the **exact `forge_message`**; the order treats a message with "conflict" in it as the rework order's | a message without the word: change the match in `schedule.go` (`strings.Contains(..., "conflict")`) before the switch-on | | 7 | The order itself: in a scratch city with a rig `scratch`, create a bead, give it `merge_result=pull_request`, `pr_url=$PR`, `gc.work_commit=$H5` (a fresh pull request's head), close it, then `FORGEJO_TOKEN_FILE=$CITY GC_RIG_ROOT=<the rig> $F order schedule` (it prints it is off), then the same with `FORGEJO_SCHEDULE=on` | first run: `off`, nothing changed on the forge or the bead. Second: `scheduled`; the bead has `auto_merge=scheduled`, written on a **closed** bead; a repeat prints `already_scheduled` and writes nothing | `gc bd update` refusing a closed bead: P2, P8 and this order all write on closed beads, and the design needs another route | | 8 | Step 7 with `H5` replaced by a stale head | `head_moved` printed; one bead for the Operator (`pr_event=no_worker`, with `pr_url` and `pr_head`) once nobody holds the pull request's head, one mail, and no second bead or mail after another run | a bead without `pr_event`, or the merge order closing it: `gc bd show` it and tell the Operator | | 9 | Step 7's bead with the pull request then merged (or closed), and `gc order run merge` | the Operator's bead of step 8 stays open and assigned, with no `pr_closed` and no `gc.work_outcome` | the merge order touched it: the `pr_event` skip is not working in the real store | After 1 to 5b, tell the user the results, and record them in `docs/handoffs.md` 3.11 and the README's "What Forgejo does with a scheduled merge". Only then does the city turn the order on: `FORGEJO_SCHEDULE = "on"` in the order's `[[orders.overrides]]` entry, and only after the user has confirmed `dismiss_stale_approvals` on each repository (decision 11). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Bead: gascitypacks-0wh
Landing L12: the schedule order, built and not switched on (gascitypacks-0wh)
All checks were successful
test / changelog (pull_request) Successful in 6s
test / lint (pull_request) Successful in 20s
test / scripts (pull_request) Successful in 33s
77f3b8a01d
Landing needs a clock that schedules the merge of each pull request before the review is asked for (handoffs.md 3.1 P3, 3.11 d). This adds it as the forgejo pack's `schedule` order: a two-line script that starts `gc forgejo order schedule`, a subcommand of the pack's Go tool, so the logic is Go and tested with fakes for gc, bd and the forge, and no shell logic is added.

Every two minutes it lists the closed beads with merge_result=pull_request and runs `pr merge` in-process for each, with the bead's gc.work_commit and its target (else the repository's default branch, read once per repository). It handles each answer as table 3.11 d says: auto_merge=scheduled on scheduled, already_scheduled and merged, asked again every cycle, never cancelled; not_open left to the merge order; head_moved nothing unless no bead of the pull request holds the new head; wrong_base, missing, foreign and a forge refusal that is not a conflict are one bead for the Operator per head; no_diff, a 500 while the forge checks, and anything else are counted in auto_merge_trouble, and become a bead for the Operator after three cycles (the first two) or two hours (any). The order finds its own bead for the Operator again by pr_url and stuck_head, so a head gets one, and the worker check skips those beads, since they carry the pull request's URL too.

It is off: with FORGEJO_SCHEDULE unset or anything but "on" in the order's environment (the [[orders.overrides]] entry a city already gives it for FORGEJO_TOKEN_FILE) it prints one line before it reads a bead, asks the forge or calls gc. The tests pin that with a store that fails on any call and a forge that counts requests. Client.defaultBranch is openPull's first request, taken out so both use it.

Validated: go vet and go test of the forgejo module (GOPROXY=off), tests/formula.sh, tests/merge.sh, gc lint, the v1 changelog checker. Nothing was run against the real forge; the trial is in the pull request's description, for the Operator.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mikluko force-pushed worker/gascitypacks-0wh from 77f3b8a01d
All checks were successful
test / changelog (pull_request) Successful in 6s
test / lint (pull_request) Successful in 20s
test / scripts (pull_request) Successful in 33s
to 6a4b464685
All checks were successful
test / changelog (pull_request) Successful in 3s
test / lint (pull_request) Successful in 18s
test / scripts (pull_request) Successful in 37s
2026-11-12 10:57:02 +00:00
Compare
Author
Contributor

Rebased onto main (3e38bc3, after #40, #42 and #46 merged); head is now 6a4b464. What the rebase touched:

  • CHANGELOG.md: kept main's entries (the service label, order merge) and put the schedule entry after them. I also corrected a wording slip in it and in the README: the order's command is the tool's forgejo order schedule, not a gc forgejo … command.
  • README.md: one row of the packs table, which now names both the merge order (the tool's order merge) and the schedule order.
  • forgejo/assets/forgejo/main.go: both orders in the usage, the header and the unknown-command message. env has main's gc and log beside my newStore and now; run sends order schedule to orderSchedule before main's order timeout, and order merge is unchanged.
  • schedule.go and schedule_test.go: my orderBead is storeBead now, since #46 added an orderBead of its own to order.go with another shape. No other change. The schedule order's gcStore still runs gc in the repository, where the merge order runs it in $PWD; I left both as they are.

Run on the rebased head: go vet and go test ./... in forgejo, gofmt -l, gc lint ., every script under tests/ that CI runs, and the v1 changelog check (valid=true). Nothing else changed.

Rebased onto main (3e38bc3, after #40, #42 and #46 merged); head is now 6a4b464. What the rebase touched: - `CHANGELOG.md`: kept main's entries (the `service` label, `order merge`) and put the `schedule` entry after them. I also corrected a wording slip in it and in the README: the order's command is the tool's `forgejo order schedule`, not a `gc forgejo …` command. - `README.md`: one row of the packs table, which now names both the `merge` order (the tool's `order merge`) and the `schedule` order. - `forgejo/assets/forgejo/main.go`: both orders in the usage, the header and the unknown-command message. `env` has main's `gc` and `log` beside my `newStore` and `now`; `run` sends `order schedule` to `orderSchedule` before main's order timeout, and `order merge` is unchanged. - `schedule.go` and `schedule_test.go`: my `orderBead` is `storeBead` now, since #46 added an `orderBead` of its own to `order.go` with another shape. No other change. The schedule order's `gcStore` still runs gc in the repository, where the merge order runs it in `$PWD`; I left both as they are. Run on the rebased head: `go vet` and `go test ./...` in `forgejo`, `gofmt -l`, `gc lint .`, every script under `tests/` that CI runs, and the v1 changelog check (`valid=true`). Nothing else changed.
Author
Contributor

Review of 6a4b464 (gascitypacks-0wh, Landing L12): changes required.

What must change:

  1. The bead for the Operator is not the bead the merge order makes since #46, which the bead's note of 11:57 asks for. forgejo/assets/forgejo/schedule.go:535-565 (raise) and gcStore.create/gcStore.mail (:162-207) are a second helper of their own. They tag the bead with stuck_head/stuck_event and no pr_event, and mail with --notify but no --dedup. The pull request's description does not say it follows #46. The difference is a bug, not just style: order.go:282 (settleOpen) treats every open bead that has pr_url and no pr_event as a bead of the old shape. So the merge order would close the schedule order's Operator bead as shipped when the pull request merges. If the pull request closes unmerged, it would hand that bead to the Operator a second time, with pr_closed and another mail. The description's "Choices worth a look" calls this harmless, but #46 added pr_event precisely to prevent it. Wanted:
    • Make the bead through the same helper as order.go:489 (operatorBead), lifted out so both orders share it. Give it pr_url and pr_event=<stuck|no_worker|wrong_base|missing|foreign|forge_refused>, and keep the head on it so there is one bead per head. Look it up with gc bd list --all on those keys before making one.
    • Mail with --notify --dedup <event>:<url>:<head>.
    • Change headMoved (:520-524) to skip beads that carry pr_event, not beads that carry stuck_head.
    • Update the README's paragraph "A bead for the Operator", the CHANGELOG entry and the tests (TestGCStore* and the raise tests), and say in the description that the bead is #46's.

Checked, and fine:

  • The switch. With FORGEJO_SCHEDULE unset, empty, ON, On, 1, true, yes, "on " or " on", the built tool, run against a fake gc and a fake forge, printed one line, exited 0 and made no call at all. on made the calls.
  • Nothing in the pack sets the switch. gascity-root's city.toml has no schedule override, so a city that imports the pack as it does today gets the order off. gc still starts the order every 2 minutes, and go tool still builds the tool each time; it reads nothing.
  • The answers of table 3.11 d. The order writes auto_merge=scheduled only on scheduled, already_scheduled and merged, never cancels, and a second cycle writes nothing.
  • The tests use fakes and httptest, with no request to sarak.sh. go vet, go test and go test -race pass. The wrapper is one exec, the pack.toml change is only its description, and the cooldown is 2m. main has not moved since the rebase, so the merge result is the head that CI checked.
  • The trial in the description is complete enough to run.

Smaller points (not blocking):

  • A bead with no pr_url, or with a gc.work_commit that is not a full sha, is skipped with a line on stderr every 2 minutes and nobody is told.
  • The README's override example says rig = "*". Say whether that entry also reaches the HQ instance, or whether the HQ store needs an entry of its own.
Review of 6a4b464 (gascitypacks-0wh, Landing L12): **changes required**. What must change: 1. **The bead for the Operator is not the bead the merge order makes since #46, which the bead's note of 11:57 asks for.** `forgejo/assets/forgejo/schedule.go:535-565` (`raise`) and `gcStore.create`/`gcStore.mail` (`:162-207`) are a second helper of their own. They tag the bead with `stuck_head`/`stuck_event` and no `pr_event`, and mail with `--notify` but no `--dedup`. The pull request's description does not say it follows #46. The difference is a bug, not just style: `order.go:282` (`settleOpen`) treats every open bead that has `pr_url` and no `pr_event` as a bead of the old shape. So the merge order would close the schedule order's Operator bead as shipped when the pull request merges. If the pull request closes unmerged, it would hand that bead to the Operator a second time, with `pr_closed` and another mail. The description's "Choices worth a look" calls this harmless, but #46 added `pr_event` precisely to prevent it. Wanted: - Make the bead through the same helper as `order.go:489` (`operatorBead`), lifted out so both orders share it. Give it `pr_url` and `pr_event=<stuck|no_worker|wrong_base|missing|foreign|forge_refused>`, and keep the head on it so there is one bead per head. Look it up with `gc bd list --all` on those keys before making one. - Mail with `--notify --dedup <event>:<url>:<head>`. - Change `headMoved` (`:520-524`) to skip beads that carry `pr_event`, not beads that carry `stuck_head`. - Update the README's paragraph "A bead for the Operator", the CHANGELOG entry and the tests (`TestGCStore*` and the raise tests), and say in the description that the bead is #46's. Checked, and fine: - The switch. With `FORGEJO_SCHEDULE` unset, empty, `ON`, `On`, `1`, `true`, `yes`, `"on "` or `" on"`, the built tool, run against a fake `gc` and a fake forge, printed one line, exited 0 and made no call at all. `on` made the calls. - Nothing in the pack sets the switch. gascity-root's `city.toml` has no `schedule` override, so a city that imports the pack as it does today gets the order off. gc still starts the order every 2 minutes, and `go tool` still builds the tool each time; it reads nothing. - The answers of table 3.11 d. The order writes `auto_merge=scheduled` only on `scheduled`, `already_scheduled` and `merged`, never cancels, and a second cycle writes nothing. - The tests use fakes and `httptest`, with no request to sarak.sh. `go vet`, `go test` and `go test -race` pass. The wrapper is one `exec`, the pack.toml change is only its description, and the cooldown is 2m. main has not moved since the rebase, so the merge result is the head that CI checked. - The trial in the description is complete enough to run. Smaller points (not blocking): - A bead with no `pr_url`, or with a `gc.work_commit` that is not a full sha, is skipped with a line on stderr every 2 minutes and nobody is told. - The README's override example says `rig = "*"`. Say whether that entry also reaches the HQ instance, or whether the HQ store needs an entry of its own.
mikluko force-pushed worker/gascitypacks-0wh from 6a4b464685
All checks were successful
test / changelog (pull_request) Successful in 3s
test / lint (pull_request) Successful in 18s
test / scripts (pull_request) Successful in 37s
to 8cb5f44074
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 17s
test / scripts (pull_request) Successful in 38s
2026-11-12 11:10:49 +00:00
Compare
Author
Contributor

Rework round for the review of 6a4b464 (rebased onto main at 83adff9; new head 8cb5f44 on top of the first commit).

Changed

  • The bead for the Operator is #46's. operatorBead, mailOperatorBead, findOperator and gcFunc are lifted out of the merge order into order.go, and both orders use them. The schedule order's own raise, gcStore.create and gcStore.mail are gone, with orderStore and gcStore: the scheduler runs gc through gcRunIn, which gcRun is now a case of.
  • The bead carries pr_url, pr_event (stuck, no_worker, wrong_base, missing, foreign, forge_refused), pr_head and work_bead. It is looked up with gc bd list --all on event, pull request and head before one is made, and mailed with --notify --dedup <event>:<url>:<head>. The merge order's own closed bead and mail keep the same shape and key.
  • The schedule order mails only a bead it has just made: the dedup key holds only until the Operator archives the mail, so a mail on every cycle would come back once read. A mail that fails after the bead was made is not retried (the run exits 1 and says so).
  • headMoved skips beads that carry pr_event, not stuck_head.
  • A closed bead with no pr_url, or no full gc.work_commit, is counted in auto_merge_trouble as no_head; the third cycle in a row is a bead for the Operator, found by the work bead.
  • README ("The schedule order"), CHANGELOG and the description follow; the description says the bead is #46's.

The review's question. Yes: rig = "*" reaches the HQ instance. In the city, where merge has that one entry, gc order show merge --json prints its env for the HQ instance ("rig": null) and for merge:rig:gascitypacks. The README says so, and how to switch the order on for some stores only.

Tests. The fake store of schedule_test.go is now a fake of gc (bd list, bd update, bd create, mail send, agent list); the raise tests assert the lookup call, the dedup key and the absence of stuck_head/stuck_event, and that a bead the Operator closed, or a mail it archived, brings neither again. TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder runs both orders over one fake city (pull request merged, and closed) and fails when the pr_event skip in settleOpen is taken out (checked). Trial step 9 repeats it on the real store.

go vet, go test, go test -race, tests/merge.sh, tests/formula.sh (under env -i, gascitypacks-pmn), gc lint . and the v1 changelog checker pass.

Rework round for the review of 6a4b464 (rebased onto main at 83adff9; new head 8cb5f44 on top of the first commit). **Changed** - The bead for the Operator is #46's. `operatorBead`, `mailOperatorBead`, `findOperator` and `gcFunc` are lifted out of the merge order into `order.go`, and both orders use them. The schedule order's own `raise`, `gcStore.create` and `gcStore.mail` are gone, with `orderStore` and `gcStore`: the scheduler runs gc through `gcRunIn`, which `gcRun` is now a case of. - The bead carries `pr_url`, `pr_event` (`stuck`, `no_worker`, `wrong_base`, `missing`, `foreign`, `forge_refused`), `pr_head` and `work_bead`. It is looked up with `gc bd list --all` on event, pull request and head before one is made, and mailed with `--notify --dedup <event>:<url>:<head>`. The merge order's own `closed` bead and mail keep the same shape and key. - The schedule order mails only a bead it has just made: the dedup key holds only until the Operator archives the mail, so a mail on every cycle would come back once read. A mail that fails after the bead was made is not retried (the run exits 1 and says so). - `headMoved` skips beads that carry `pr_event`, not `stuck_head`. - A closed bead with no `pr_url`, or no full `gc.work_commit`, is counted in `auto_merge_trouble` as `no_head`; the third cycle in a row is a bead for the Operator, found by the work bead. - README ("The schedule order"), CHANGELOG and the description follow; the description says the bead is #46's. **The review's question.** Yes: `rig = "*"` reaches the HQ instance. In the city, where `merge` has that one entry, `gc order show merge --json` prints its `env` for the HQ instance (`"rig": null`) and for `merge:rig:gascitypacks`. The README says so, and how to switch the order on for some stores only. **Tests.** The fake store of `schedule_test.go` is now a fake of gc (`bd list`, `bd update`, `bd create`, `mail send`, `agent list`); the raise tests assert the lookup call, the dedup key and the absence of `stuck_head`/`stuck_event`, and that a bead the Operator closed, or a mail it archived, brings neither again. `TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder` runs both orders over one fake city (pull request merged, and closed) and fails when the `pr_event` skip in `settleOpen` is taken out (checked). Trial step 9 repeats it on the real store. `go vet`, `go test`, `go test -race`, `tests/merge.sh`, `tests/formula.sh` (under `env -i`, gascitypacks-pmn), `gc lint .` and the v1 changelog checker pass.
city-root-review left a comment

Reviewed 8cb5f44 (Landing L12, schedule order, off by default): shared Operator bead, switch, tests, merge result.

Reviewed 8cb5f44 (Landing L12, schedule order, off by default): shared Operator bead, switch, tests, merge result.
Author
Contributor

Re-review of 8cb5f44 against comment 2830: passes. Merged as 43dce15 (squash) after the city-root-review approval of 8cb5f44.

Checked:

  • The helper is shared, and the bug is gone. operatorBead, mailOperatorBead and findOperator in order.go now serve both orders. The schedule order's bead for the Operator carries pr_url, pr_event, pr_head and work_bead. It is looked up with bd list --all on pr_event, pr_url and pr_head before one is made, and mailed with --notify --dedup <event>:<url>:<head>. The merge order's own closed bead is unchanged: the same keys, the same lookup and the same dedup closed:<url>.
  • The two cases. Walked against order.go on main: settleOpen skips any bead with pr_event, and settleClosed lists only beads with merge_result. So when the pull request merges, and when it closes unmerged, the merge order leaves the schedule order's Operator bead alone. TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder runs the real merge order over both cases and asserts that nothing touches the bead.
  • headMoved now skips beads that carry pr_event, which includes the merge order's closed bead.
  • A missing or short head is now counted as no_head. The third cycle in a row makes a bead for the Operator, keyed by work_bead.
  • The README answers the question about rig = "*": the entry reaches the HQ instance and every rig's. For per-store control it says to use a separate entry, with or without a rig key.
  • The switch holds. I rebuilt the tool from 8cb5f44 and ran it against a fake gc and a fake forge. Unset, empty, ON, 1, true, yes, "on " and " on" made 0 calls; on made calls.
  • Merge result. go vet, go test and go test -race pass. The branch is on main 83adff9, so the merge result is the head CI checked: changelog, lint and scripts all succeeded.

Follow-up worth a bead (not blocking): raise mails only when it has just made the bead. If gc mail send fails after the bead is created, the next run finds the bead and never mails, so the Operator learns of it only from the bead itself. The merge order instead sends on every run and lets --dedup suppress the repeats.

Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.

Re-review of 8cb5f44 against comment 2830: **passes**. Merged as 43dce15 (squash) after the `city-root-review` approval of 8cb5f44. Checked: - **The helper is shared, and the bug is gone.** `operatorBead`, `mailOperatorBead` and `findOperator` in `order.go` now serve both orders. The schedule order's bead for the Operator carries `pr_url`, `pr_event`, `pr_head` and `work_bead`. It is looked up with `bd list --all` on `pr_event`, `pr_url` and `pr_head` before one is made, and mailed with `--notify --dedup <event>:<url>:<head>`. The merge order's own `closed` bead is unchanged: the same keys, the same lookup and the same dedup `closed:<url>`. - **The two cases.** Walked against `order.go` on main: `settleOpen` skips any bead with `pr_event`, and `settleClosed` lists only beads with `merge_result`. So when the pull request merges, and when it closes unmerged, the merge order leaves the schedule order's Operator bead alone. `TestScheduleBeadForTheOperatorIsLeftAloneByTheMergeOrder` runs the real merge order over both cases and asserts that nothing touches the bead. - **`headMoved`** now skips beads that carry `pr_event`, which includes the merge order's `closed` bead. - **A missing or short head** is now counted as `no_head`. The third cycle in a row makes a bead for the Operator, keyed by `work_bead`. - **The README** answers the question about `rig = "*"`: the entry reaches the HQ instance and every rig's. For per-store control it says to use a separate entry, with or without a `rig` key. - **The switch holds.** I rebuilt the tool from 8cb5f44 and ran it against a fake `gc` and a fake forge. Unset, empty, `ON`, `1`, `true`, `yes`, `"on "` and `" on"` made 0 calls; `on` made calls. - **Merge result.** `go vet`, `go test` and `go test -race` pass. The branch is on main 83adff9, so the merge result is the head CI checked: changelog, lint and scripts all succeeded. Follow-up worth a bead (not blocking): `raise` mails only when it has just made the bead. If `gc mail send` fails after the bead is created, the next run finds the bead and never mails, so the Operator learns of it only from the bead itself. The merge order instead sends on every run and lets `--dedup` suppress the repeats. Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
Author
Contributor

Trial run by the Operator's agent on 2026-11-12 on mikluko/scratch, tool built from v0.6.0.

Tool: go build ./assets/forgejo from v0.6.0 (d9d5ad4), FORGEJO_URL=https://sarak.sh; CITY = city-root's token file, REV = city-root-review's. The repository is mikluko/scratch in place of gascity-root/schedule-trial. pr open was given --summary-file. Commits were pushed over ssh as mikluko; the pull requests are by city-root and the scheduled merges were made as city-root.

Protection of scratch main (not readable, 403; found by refusals on mikluko/scratch#1): one approval required, check test / test (pull_request) required, dismiss_stale_approvals off: after a push R's earlier approval stayed stale: true, dismissed: false and a merge with it succeeded (200). So the trial ran without the rule it asks for; no step below depends on it, but it is the guard of 3.11 (a), and it is off here.

Pull requests: A = #3 (trial-l12, H1 553ec1c, H2 bb30552), B = #4 (trial-l12-b, H3 c112549), conflict = #5 (trial-l12-conflict, H4 43cf68c).

Step Command Expected What happened Same?
1 sched $H1 (checks green) scheduled, exit 0, stays open scheduled, schedule_cancelled: false, exit 0; open 20 s later same
2 sched $H1 already_scheduled, exit 0 already_scheduled, exit 0 same
3 push "two"; sched $H1; sched $H2 3 head_moved; already_scheduled head_moved (head bb30552), exit 3; already_scheduled, exit 0: the push did not remove the schedule same
4 REV pr review APPROVED H2; st posted; merged within a minute approval posted 12:20:04 while checks were still pending (review 204, official: true); checks went green and #3 merged at 12:20:30 as city-root (e783e12) same outcome; the green status after the approval started the check (3.11 b, second case)
5 #4 approved and green, then sched $H3 scheduled, stays open scheduled, exit 0; still open 70 s later same
5b CITY posts {"state":"success","context":"city/merge"} on H3 merges status created (id 4, creator city-root); #4 merged at 12:22:30 as city-root (e816f00) same
6 #5 conflicts with main; sched $H4 exit 9 forge_refused, message with "conflict" rejected/forge_refused, forge_status: 405, forge_message: "Please try again later", exit 9 (twice, 30 s apart; the raw API answer is the same {"message":"Please try again later"}) different: no "conflict" in the message
7 the order in a scratch city not run: needs a scratch city and beads, outside this run's limits not run
8 step 7 with a stale head not run (as 7) not run
9 step 7 with the merge order not run (as 7) not run

What it means:

  • Question 6: confirmed on sarak.sh: the schedule holds no head and survives a push (step 3), a second schedule is already_scheduled (409), storing it merges nothing (1, 5), an approval or a later green status merges (4), and a pull request that already has everything waits for an event (5).
  • Question 11: answered: city-root with write access may schedule into protected main; Forgejo merged #3 and #4 as city-root.
  • Question 10 / decision 12: a success status of a context nobody requires starts the check, and city-root may post one (5b).
  • Decision 11: on this repository dismiss_stale_approvals is off, so the trial shows what 3.11 (a) fears: nothing but that setting keeps a new head from merging on an old approval. The user must still confirm it per repository.
  • Before the switch-on: schedule.go:312 (strings.Contains(..., "conflict")) never matches Forgejo's answer for a conflicting pull request, 405 Please try again later, which also names no cause; every conflict becomes an Operator bead instead of the rework order's. Steps 7 to 9 are still to run.

Clean-up: #5 closed; #3 and #4 merged into scratch main as the trial intends. No branch deleted.

Trial run by the Operator's agent on 2026-11-12 on mikluko/scratch, tool built from v0.6.0. Tool: `go build ./assets/forgejo` from v0.6.0 (`d9d5ad4`), `FORGEJO_URL=https://sarak.sh`; CITY = `city-root`'s token file, REV = `city-root-review`'s. The repository is mikluko/scratch in place of `gascity-root/schedule-trial`. `pr open` was given `--summary-file`. Commits were pushed over ssh as `mikluko`; the pull requests are by `city-root` and the scheduled merges were made as `city-root`. Protection of scratch `main` (not readable, 403; found by refusals on mikluko/scratch#1): one approval required, check `test / test (pull_request)` required, **`dismiss_stale_approvals` off**: after a push R's earlier approval stayed `stale: true, dismissed: false` and a merge with it succeeded (200). So the trial ran without the rule it asks for; no step below depends on it, but it is the guard of 3.11 (a), and it is off here. Pull requests: A = #3 (`trial-l12`, H1 `553ec1c`, H2 `bb30552`), B = #4 (`trial-l12-b`, H3 `c112549`), conflict = #5 (`trial-l12-conflict`, H4 `43cf68c`). | Step | Command | Expected | What happened | Same? | |---|---|---|---|---| | 1 | `sched $H1` (checks green) | `scheduled`, exit 0, stays open | `scheduled`, `schedule_cancelled: false`, exit 0; open 20 s later | same | | 2 | `sched $H1` | `already_scheduled`, exit 0 | `already_scheduled`, exit 0 | same | | 3 | push "two"; `sched $H1`; `sched $H2` | 3 `head_moved`; `already_scheduled` | `head_moved` (head `bb30552`), exit 3; `already_scheduled`, exit 0: the push did not remove the schedule | same | | 4 | REV `pr review APPROVED` H2; `st` | `posted`; merged within a minute | approval posted 12:20:04 while checks were still pending (review 204, `official: true`); checks went green and #3 merged at 12:20:30 as `city-root` (`e783e12`) | same outcome; the green status after the approval started the check (3.11 b, second case) | | 5 | #4 approved and green, then `sched $H3` | `scheduled`, stays open | `scheduled`, exit 0; still open 70 s later | same | | 5b | CITY posts `{"state":"success","context":"city/merge"}` on H3 | merges | status created (id 4, creator `city-root`); #4 merged at 12:22:30 as `city-root` (`e816f00`) | same | | 6 | #5 conflicts with main; `sched $H4` | exit 9 `forge_refused`, message with "conflict" | `rejected`/`forge_refused`, `forge_status: 405`, `forge_message: "Please try again later"`, exit 9 (twice, 30 s apart; the raw API answer is the same `{"message":"Please try again later"}`) | **different**: no "conflict" in the message | | 7 | the order in a scratch city | | not run: needs a scratch city and beads, outside this run's limits | not run | | 8 | step 7 with a stale head | | not run (as 7) | not run | | 9 | step 7 with the merge order | | not run (as 7) | not run | What it means: - **Question 6**: confirmed on sarak.sh: the schedule holds no head and survives a push (step 3), a second schedule is `already_scheduled` (409), storing it merges nothing (1, 5), an approval or a later green status merges (4), and a pull request that already has everything waits for an event (5). - **Question 11**: answered: `city-root` with write access may schedule into protected `main`; Forgejo merged #3 and #4 as `city-root`. - **Question 10 / decision 12**: a success status of a context nobody requires starts the check, and `city-root` may post one (5b). - **Decision 11**: on this repository `dismiss_stale_approvals` is **off**, so the trial shows what 3.11 (a) fears: nothing but that setting keeps a new head from merging on an old approval. The user must still confirm it per repository. - **Before the switch-on**: `schedule.go:312` (`strings.Contains(..., "conflict")`) never matches Forgejo's answer for a conflicting pull request, `405 Please try again later`, which also names no cause; every conflict becomes an Operator bead instead of the rework order's. Steps 7 to 9 are still to run. Clean-up: #5 closed; #3 and #4 merged into scratch `main` as the trial intends. No branch deleted.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
3 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!44
No description provided.