From 82988665082599467865d3ded63e486f70304eb2 Mon Sep 17 00:00:00 2001 From: HugoXK Date: Sat, 21 Nov 2026 01:40:09 +0000 Subject: [PATCH 1/4] ci(controller): wake on the issue label and edit events The demotion half of the controller had no event trigger: a label set by a non-maintainer, or an edit after the approval, was only read at the next cron tick. Measured on this repository: the schedule skipped 14 h 16 min once (19 Nov 18:10 -> 20 Nov 08:26 UTC), so an approval someone had just voided stayed usable for that window. Adding issues labeled/unlabeled/edited cannot loop: the controller never labels an issue itself, and the run its own removal triggers plans nothing. --- .github/workflows/controller.yml | 9 +++++++++ AGENTS.md | 4 +++- tests/test_process_controller.py | 15 +++++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/controller.yml b/.github/workflows/controller.yml index 5238552a..925dcfda 100644 --- a/.github/workflows/controller.yml +++ b/.github/workflows/controller.yml @@ -18,9 +18,18 @@ name: controller # so immediacy comes from these events and manual dispatch, and the cron is a # four-a-day backstop only. A `pull_request` run from a fork head carries a # read-only token, so both jobs skip it: the fallback cron still labels fork PRs. +# +# The demotion half is the safety-critical one and it had no event at all: a +# label set by a non-maintainer, or an edit after the approval, was only read at +# the next tick. The schedule skipped 14 h 16 min once (19 Nov 18:10 -> 20 Nov +# 08:26 UTC), and for that whole window an approval someone had just voided was +# still usable. So `issues` `labeled` / `unlabeled` / `edited` wake it too. The +# run the controller's own removal triggers plans nothing, so this cannot loop. on: pull_request: types: [opened, ready_for_review, reopened] + issues: + types: [labeled, unlabeled, edited] schedule: - cron: '17 */6 * * *' workflow_dispatch: diff --git a/AGENTS.md b/AGENTS.md index a4dbadda..afd2618b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -107,7 +107,9 @@ question in a comment. Agents develop **only** `agent-ready` issues. [`.github/workflows/controller.yml`](.github/workflows/controller.yml) runs on the `pull_request` events `opened`, `ready_for_review` and `reopened` (a -fork-head run is skipped: that token cannot write) and on a four-a-day cron +fork-head run is skipped: that token cannot write), on the `issues` events +`labeled`, `unlabeled` and `edited` so an approval that someone voided is read +in the same minute, and on a four-a-day cron backstop, with the built-in `GITHUB_TOKEN` only (no GitHub App, no secrets) and changes labels and nothing else: it sets `risk:T*` and `agent-pr` on open non-draft PRs, removes `agent-ready`/`agent-working` when a non-maintainer set diff --git a/tests/test_process_controller.py b/tests/test_process_controller.py index 0caa798d..876ba96d 100644 --- a/tests/test_process_controller.py +++ b/tests/test_process_controller.py @@ -1,8 +1,9 @@ """The label-only controller (AGENTS.md › Controller). It runs on ``pull_request`` ``opened`` / ``ready_for_review`` / -``reopened`` (same-repo) and on a four-a-day cron backstop, with a write -token, so its contract is tested offline: it touches only the labels it +``reopened`` (same-repo), on the ``issues`` events that can void an approval, +and on a four-a-day cron backstop, with a write token, so its contract is +tested offline: it touches only the labels it manages, only in the allowed direction, never adds ``agent-ready``, stops entirely on ``AGENT_PAUSE`` and is a dry run unless ``CONTROLLER_LIVE`` is exactly ``true``. @@ -275,13 +276,19 @@ def test_workflow_shape(): text = WORKFLOW.read_text(encoding="utf-8") wf = yaml.safe_load(text) on = wf.get("on", wf.get(True)) - assert set(on) == {"schedule", "workflow_dispatch", "pull_request"} + assert set(on) == {"schedule", "workflow_dispatch", "pull_request", "issues"} assert on["schedule"] == [{"cron": "17 */6 * * *"}], ( "four slots a day: the half-hourly cron only ran two or three times a day, " - "so immediacy comes from the pull_request events, not the schedule" + "so immediacy comes from the event triggers, not the schedule" ) assert on["pull_request"] == {"types": ["opened", "ready_for_review", "reopened"]}, \ "label a PR when it becomes reviewable, not on every push to its head" + assert on["issues"] == {"types": ["labeled", "unlabeled", "edited"]}, ( + "the demotion path is the safety-critical one: a label set by a non-maintainer " + "or an edit after the approval has to be read in the same minute, not at the " + "next tick. The schedule alone skipped 14 h 16 min (19 Nov 18:10 -> 20 Nov " + "08:26 UTC), and an approval voided by an edit stays usable for that long." + ) assert wf["permissions"] == {} plan, apply = wf["jobs"]["plan"], wf["jobs"]["apply"] assert plan["permissions"] == {"contents": "read", "issues": "read", "pull-requests": "read"} From ad308c53b52c4aed4dbc15e38736dc6ebc547981 Mon Sep 17 00:00:00 2001 From: Dev-3 Date: Sat, 21 Nov 2026 17:59:14 +0000 Subject: [PATCH 2/4] docs(changelog): fragment for the controller issue events (#1209) --- changelog.d/1209-controller-issue-events.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog.d/1209-controller-issue-events.md diff --git a/changelog.d/1209-controller-issue-events.md b/changelog.d/1209-controller-issue-events.md new file mode 100644 index 00000000..481598c4 --- /dev/null +++ b/changelog.d/1209-controller-issue-events.md @@ -0,0 +1,5 @@ +Fixed +The controller workflow also runs on the `issues` events `labeled`, `unlabeled` +and `edited`, so an approval that someone voided by setting a label or editing +the issue is read in the same minute instead of at the next cron tick -- the +schedule once skipped 14 h 16 min (#1209). From 9694b4222a7840f1575a299d6920a9a5529d1db1 Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:31:32 +0800 Subject: [PATCH 3/4] docs(changelog): fragment for #1210 --- changelog.d/1210-controller-issue-events.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog.d/1210-controller-issue-events.md diff --git a/changelog.d/1210-controller-issue-events.md b/changelog.d/1210-controller-issue-events.md new file mode 100644 index 00000000..d8fd4f05 --- /dev/null +++ b/changelog.d/1210-controller-issue-events.md @@ -0,0 +1,5 @@ +Changed +The controller wakes on the `issues` events `labeled`, `unlabeled` and `edited` +as well as on the four-a-day cron, so a label set by a non-maintainer or an edit +after the approval demotes the issue in the same minute instead of at the next +tick (#1210). From 334e4d6abfbbd8e53041cccf2909767f079a123a Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:34:00 +0800 Subject: [PATCH 4/4] docs(changelog): drop the duplicate fragment, the issue is #1209 --- changelog.d/1210-controller-issue-events.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 changelog.d/1210-controller-issue-events.md diff --git a/changelog.d/1210-controller-issue-events.md b/changelog.d/1210-controller-issue-events.md deleted file mode 100644 index d8fd4f05..00000000 --- a/changelog.d/1210-controller-issue-events.md +++ /dev/null @@ -1,5 +0,0 @@ -Changed -The controller wakes on the `issues` events `labeled`, `unlabeled` and `edited` -as well as on the four-a-day cron, so a label set by a non-maintainer or an edit -after the approval demotes the issue in the same minute instead of at the next -tick (#1210).