Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions changelog.d/1209-controller-issue-events.md
Original file line number Diff line number Diff line change
@@ -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).
15 changes: 11 additions & 4 deletions tests/test_process_controller.py
Original file line number Diff line number Diff line change
@@ -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``.
Expand Down Expand Up @@ -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"}
Expand Down
Loading