Order checks: one mail to the Operator when a pull request's checks settle (CHECKS <bead>: <state> <pr_url>) #79
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!79
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-hzpj"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds the forgejo pack's
checksorder: one poller for the city that mails the Operator once when the checks of a bead's open pull request settle, in place of awatch.shper bead. This is piece 2 of the user's mail of 2026-11-12 (mail gcg-367617).What it does.
forgejo order checks(newchecks_order.go;assets/scripts/checks.shis the four-line stub,orders/checks.tomliscooldown,2m, likemerge). For each bead of its store that follows a pull request, it reads the pull request once, and when that is open, the head's checks through the codepr stateuses. When the head issuccessorfailureand the bead's recorded head and state are not those, it mails the Operator:CHECKS <bead>: <success|failure> <pr_url>; body: the pull request, the store, the head sha,- <context>: <status>for each commit status, and the count of workflow runs by status;--from controller --notify --dedup checks:<bead>:<sha>;checks-<rig>.json(checks-hq.json) underGC_PACK_STATE_DIR, written atomically after the mail, and only for a mail that was sent: a failed mail is retried, and a mail that--dedupsuppressed is not recorded.not_started,pendingandnoneare left alone, and so is a pull request that is not open (the merge order's). Beads taken: open/in_progress/blocked withpr_url, and closed withmerge_result=pull_request; a bead withpr_eventorreview_headis skipped, so the order does not repeat gascitypacks-n905 (a review bead taken for work).checks.gogainsheadChecksDetail, which returns the statuses and runsheadCheckscombined;pr state --jsonis unchanged.Where the logic lives. In Go, as
docs/shell.mdrequires; the script is the stub the merge order has.Decisions to look at.
CHECKS: <n> pull requests settled, dedup on the hash of the bead:head pairs). Without it the first run in a store mails every open pull request, which is the flood of #51. In the dry run below, that is 23 pull requests.checks:<bead>:<sha>), so a run of the same head that changes state (failure to success, or the other way) is a new mail, which gc suppresses (exit 0) while the Operator has not archived the first. Round 1 found the order recorded such a mail as sent and lost it. It now sends with--json, treatscount0 withalready_doneas not sent, and does not record the bead: each run asks again and the run after the archive delivers the mail. The change is late until the Operator archives the first mail, not lost. A key that carries the state would deliver it at once, and the bead's key does not carry it. The one case that still mails a head twice is a record that failed to write: the next run's mail waits for the archive, then goes once more.FORGEJO_TOKEN_FILEwith an[[orders.overrides]]entry namedchecks(exec orders do not getworkspace.env), as formergeandschedule. That is a change in gascity-root, not here; until it is made, the order fails every run at the token.What I ran.
b05a214):go vet ./...andgo test -count=1 -race ./...inforgejo/pass, with a test that runs the second run with the first key live and a third after the archive, one for the flip back, and one for a held-back batch;tests/merge.sh,handover.shandformula.shpass. gc's answer to a suppressed send was seen in a scratch city:count0,already_donetrue, exit 0.go vet ./...,go test -count=1 ./...inforgejo/: pass. 20 new tests inchecks_order_test.go(settled success and failure with contexts; waits for pending, running, pending beside a failure, not started, none; same head and state is silent; success to failure on one head; new head; merged, closed, missing and foreign pull requests; both bead shapes and the skipped ones; one read per pull request; flood; mail failure retried; no place for state; state write failing after the mail; undecodable state; one bead unreadable; forgotten beads; per-rig file; state directory fallback; Operator lookup only when needed; usage). I broke the code on purpose in two places (compare the head alone, not the state; stop skippingreview_headbeads) and the tests failed each time.gc lint .ok;bash tests/merge.shok; the v2 changelog checker with-base mainis valid.go tool -C forgejo forgejo order checks, against the live gascitypacks store and sarak.sh, with aGC_BINthat runs the real gc for reads and writes the mail it would send to a file: one batch mail for 23 pull requests (21 success, 2 failure), no mail on the second run,checks-gascitypacks.jsonholding the 23 records. No mail was sent.Not done. The end-to-end on mikluko/scratch (a slung bead's handover and its checks, one mail each) needs the order imported and the token override in the city, so it is the Operator's after the release; the dry run above is as far as a Worker's session can take it.
Bead: gascitypacks-hzpj
🤖 Generated with Claude Code
Review of
add1ca0d0dfor gascitypacks-hzpj. Checks of the head: success.Verdict
fail
Findings
mailOnesends with--dedup checks:<bead>:<sha>. gc suppresses the send because the first mail is live, andgc mail send --helpsays "Suppression exits 0".tellthen counts the bead as told, and the run records{head, new state}. Every later run finds the record equal to the head's state and sends nothing, so archiving the first mail does not bring the second. The README says the opposite ("the Operator gets it only after archiving the first"). Description decision 2 and the comment onmailOneimply it too ("held back"). The testTestChecksOrderMailsAgainWhenTheStateOfTheHeadChangeshides the case: it clearsmailKeys, which is the archive, before the second run. The case that matters is a failed head the Operator has not yet archived, re-run to green, and today it never gets aCHECKS … successmail. Once nothing polls, that pull request can sit unnoticed. One fix: send with--jsonand leave the record unchanged when the result says the send was suppressed, so a later run delivers the mail after the archive. Then add a test in which the second run happens with the first key still live, and a third run after the archive. The other fix is to keep the code and correct the README, the comment and decision 2 to say the change is dropped, so the Operator decides on decision 2 knowing what it costs. The bead's keychecks:<bead>:<sha>is fine either way; what must change is that the order records a mail that was never sent, or that the docs say otherwise.floodLimit): the batch applies to every run, not only the first run or the end of an outage. When four Workers' pull requests settle within one 2-minute window, the result is oneCHECKS: 4 pull requests settledmail and noCHECKS <bead>:mail for any of them. The description and the README flag this as decision 1, and the merge order does the same. Whatever handles these mails on the Operator's side has to read the batch subject as well. This is for the Operator to decide, not to fix here.FORGEJO_TOKEN_FILEuntil gascity-root adds an[[orders.overrides]]entry namedchecks. That city change should land together with the import upgrade that brings this order in.Verified
docs/shell.mdon main and the whole diff (9 files, +954/−8). The head is a fast-forward of main ate6c6adb: the merge is clean, andmergeablereports mergeable.merge.toml; one instance per store; settled meanssuccessorfailurethroughheadChecksDetail, so no pending status and no unfinished run; the subject, body,--from controller --notify --dedup checks:<bead>:<sha>match the bead; state is per store underGC_PACK_STATE_DIR; it reusesfetchPull,findOperator,floodLimitandmailSender; it skipsreview_headandpr_eventbeads, so gascitypacks-n905 is not repeated;checks.shis the 4-code-line stubdocs/shell.mdallows; it adds a README section and a changelog fragment;pr state --jsonis unchanged.go vet ./...,go test -count=1 ./...andgo test -race -count=1 ./...inforgejo/pass.gc lint .reports 2 packs ok. These tests pass:tests/formula.sh,reviewer.sh,merge.sh,apply.sh,upgrade.sh,worktree.sh,worktree-setup.sh,gnu-tools.sh,view-beads.sh,view-mail.sh,permission-deny.sh,permission-request.sh. The changelog checker, built from mikluko/changelog at tag v2 (c19d67d), exits 0 with-base=main.gc mail send --help: "the send is suppressed while a previous message with the same key is still live (un-archived)" and "Suppression exits 0". The first finding rests on these two lines.add1ca0d0d463fb30d2bReview of
463fb30d2bfor gascitypacks-hzpj (round 2). Checks of the head: success.Verdict
pass
Findings
owedon every run until the Operator archives its first mail, so it counts towardfloodLimit. Example: three held-back beads plus one newly settled bead make a batch of four,CHECKS: 4 pull requests settled. The batch has a different dedup key, so it goes out and records all four. The held-back changes are then told in the batch rather than lost. This is harmless and needs no change; whatever reads these mails on the Operator's side should expect it.FORGEJO_TOKEN_FILEuntil gascity-root adds an[[orders.overrides]]entry namedchecks. That city change should land in the same pull request as the import upgrade.Round 1's blocking finding is resolved
send(checks_order.go:375) now runsgc mail send ... --jsonand returns sent only forcount > 0 && !already_done. Intell, a suppressed single mail (line 351) and a suppressed batch (line 337) are not returned, so they are not recorded, and a later run delivers them after the archive.gc mail send --json-schema resultmakescount(integer, minimum 0) a required field of a single result object, with additional properties allowed. A successful send therefore hascount≥ 1, and the order never takes a sent mail for a suppressed one. The tool reads only gc's stdout (cmd.Output(), order.go:50), so a dedup warning on stderr cannot break the decode.orderChecks,tellandmailOne, the changelog fragment and decision 2 of the description now say "held back, not lost". That is what the code does.TestChecksOrderMailsAgainWhenTheStateOfTheHeadChangesruns the second and third runs with the first key still live, then a run after the archive. Together with the tests for the flip back, a record that failed to write and a held-back batch, it pins the behaviour. As a mutation test I madesendreturn true always: three tests fail (...MailsAgainWhenTheStateOfTheHeadChanges,...DoesNotMailTwiceWhenItsRecordFailedToWrite,...DoesNotRecordABatchThatWasHeldBack). I then restored the file.Verified
add1ca0), and the whole diff: 10 files, +1052/−10, two commits onb05a214. The target has noREVIEW.md,AGENTS.mdorCLAUDE.md; I read the README from the target.915ce14(#76) since the branch was cut. Merging463fb30into origin/main is clean (README.md auto-merged), and the forge reportsmergeable.cooldown2m likemerge.toml; one instance per store; state per store underGC_PACK_STATE_DIR. Settled meanssuccessorfailurethroughheadChecksDetail. Subject, body and--from controller --notify --dedup checks:<bead>:<sha>match the bead's text. It reusesfetchPull,findOperator,floodLimitandmailSender. It skipsreview_headandpr_eventbeads, so gascitypacks-n905 is not repeated.checks.shis a thin stub, asdocs/shell.mdasks. It adds a README section and a changelog fragment.pr state --jsonis unchanged.go vet ./...,go test -count=1 ./...andgo test -count=1 -race ./...pass.gc lint .reports 2 packs ok. Every script CI runs passes:tests/formula.sh,reviewer.sh,worktree-setup.sh,worktree.sh,gnu-tools.sh,merge.sh,handover.sh,apply.sh,upgrade.sh,view-beads.sh,view-mail.sh,permission-deny.shandpermission-request.sh.-base=mainit reportsvalid=trueand exits 0.