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/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). 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"}