Order handover: one mail to the Operator when a bead is handed over (HANDOVER <bead>: <pr_url>) #78
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!78
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-uop1"
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?
What this adds
The
handoverorder in the roles pack: the Operator is mailed once when a Worker hands a bead over, so it no longer has to poll the bead to find out.roles/orders/handover.toml:trigger = "event",on = "bead.updated",scope = "city",execa four-line stub (roles/assets/scripts/handover.sh) in the shape ofmerge.sh.roles order handover(roles/assets/roles/, Go, standard library only): reads thebead.updatedevents of the last 10 minutes (HANDOVER_LOOKBACK) and takes each bead's latest state. A bead that is not closed, carriesmetadata.pr_urland is assigned to the user gets one mail to the Operator: subjectHANDOVER <bead>: <pr_url>,--from controller --notify --dedup "handover:<bead>:<pr_url>", body with rig, title, branch and pull request.human(the city's Worker), theuserof each rig'sformula_varsread fromgc config show --json(a rig's Worker), andHANDOVER_USERS. A bead a Worker halted to the Operator with its pull request, one a Worker holds, and a closed one are not handovers.handover.jsonunderGC_PACK_STATE_DIR, atomically and one at a time, for a day, aspermission-request.shdoes. A mail that fails is not recorded: the order exits non-zero and the next run sends it.Why Go, and why the module moved
docs/shell.md§2.3: an unattended order with state and more than 30 code lines must be Go. The roles pack had no tool, and the docs' answer (§3.2) is one module at the repository root, soforgejo/go.modbecomesgo.mod(modulesarak.sh/mikluko/gascitypacks) with atooldirective forforgejoand forroles. This is the first part of item 0 of the plan;internal/gcxand the budget test are not in this PR. Thegcrunner and the Operator lookup are copies of the forgejo tool's, whichgcxwill absorb (said indocs/shell.md). CI and the README rungo vet ./...andgo test ./...from the root; the forgejo wrappers find the root module from the pack directory as before (tests/merge.shpasses).Things for the reviewer to decide
gascitypacks-hzpj). Say so if each hand-over should mail.go.mod.gascitypacks-hzpj(checks order) is in flight in the forgejo pack; if it moves the module too, the second to merge resolves a trivial conflict.mikluko/scratch. That needs the order enabled in a running city, which a Worker cannot do; it comes with the bump and the Operator's first sling. What I ran is below.What I ran
go vet ./...,go test ./...: the newhandover_test.gocovers a rig's and the city's handover, closed/halted/held/unassigned beads sent nothing, latest event wins (rework and out-of-order events), nothing sent twice and a new pull request on the same bead sent, a failed mail retried while the others go out, config unreadable (human still served, run fails), longest rig prefix,$OPERATORand the ambiguous Operator, state file (atomic write, 24 h pruning, corrupt file), lookback passed togc events, exit codes.bash tests/handover.sh(new, in CI'sscriptsjob): the wrapper with nogo, noPACK_DIR, a stubgo(arguments and exit status), a tool that does not build (nothing read or mailed), and the real tool throughgo tool -Cwith a fakegc: one mail, none on the second run.bash tests/merge.sh,bash tests/formula.sh,gc lint ., and the changelog v2 checker with-base main: pass.gc mail sendstubbed to succeed: 66 handovers found among 3 h of events, none for review beads, closed beads or beads held by a Worker. Nothing was mailed.Bead: gascitypacks-uop1
Review of
a4dc478aecfor gascitypacks-uop1. Checks of the head: success.Verdict
pass
Findings
bead.updated, but gc reports most closes asbead.closedalone. In the live city's last 30 minutes there were 444bead.closedevents against 35bead.updatedevents whose bead wasclosed. So "a closed one is not a handover" (README, changelog) holds only when the close also comes as an update. A bead handed over and closed in the same lookback, before a run has mailed it, still gets a HANDOVER mail. Right now that is rare, since a handed-over bead waits for a review. Fix: readbead.closedtoo and let it win byseq, and add a test fixture that closes a bead with abead.closedevent.bead.updatedof a bead that is still handed over then mails HANDOVER again. That happens when a pull request waits more than a day and someone appends a note to its bead.--dedupstops it only while the first mail is unarchived. The bead's "done" asks for exactly one mail. Fix: keep a record for much longer (e.g. 30 days), or drop it only once the bead's latest state is no longer a handover.forgejo/go.modto the root" as future work that "Needs the user's decisions 1 and 2". Section 3.1 now says this pull request made the move and that decisions 1 and 2 were taken. The row should say the root module is done and thatinternal/gcx, the ledger and the budget test remain.On the questions the description leaves to the reviewer: the dedup key
handover:<bead>:<pr_url>is what the bead's text asks for, so a rework handed over again on the same pull request not mailing a second time is within scope. Whether it should mail is the Operator's call. Nothing here blocks the checks order (gascitypacks-hzpj).Verified
e6c6adb). Merging it into origin/main is a clean fast-forward, and the forge saysmergeable.~/.gc/cache/repos/<hash>/holds.git,forgejo,rolesandtests), sogo tool -C "$PACK_DIR"finds the rootgo.modfrom either pack. The forgejo tool's import path is unchanged (…/forgejo/assets/forgejo). Outside docs and the changelog, nothing in the tree still namesforgejo/go.modorgo -C forgejo.merge.sh. The order istrigger = "event",on = "bead.updated",scope = "city", as the mail asks. The mail is fromcontrollerwith--notify,--dedup handover:<bead>:<pr_url>, the subjectHANDOVER <bead>: <pr_url>, and a body of rig, title, branch and pr_url. State goes underGC_PACK_STATE_DIR, written by temp file and rename. The users are human, each rig'sformula_vars.user, andHANDOVER_USERS. Nothing in it runsrm -rf.notify-on-human-gate-creationfired 9 times in 30 min), not once per event, so a 10-minute lookback covers the gap between runs. The livebead.updatedpayload carriesbead.{id,title,status,assignee,metadata}, as the code'seventstruct expects.env -i; a count of 0 confirmed it):go vet ./...passed;go test ./...andgo test -race ./...passed (forgejo, roles).tests/handover.sh,merge.sh,worktree-setup.sh,worktree.sh,gnu-tools.sh,apply.sh,upgrade.sh,view-beads.sh,view-mail.sh,permission-deny.shandpermission-request.shall passed.gc lint .(2 packs ok),tests/formula.shandtests/reviewer.shpassed, run with a throwaway HOME. The changelog checker, built from mikluko/changelog at v2, passed with-base=main: valid, with no errors or warnings.success.city-root referenced this pull request2026-11-12 15:56:30 +00:00