Skip to content

controller.yml labels PRs only on a cron, so a new PR can wait hours for agent-pr #1187

Closed

Description

@HugoXK

What happened

A PR that is green and ready can sit outside the verdict queue for hours because agent-pr (and risk:T*) is only applied by controller.yml's schedule, and that schedule is being throttled hard.

Observed today, all times from the API:

  • #1185 opened 2026-11-20T11:01:48Z, #1186 opened 2026-11-20T11:13:05Z.
  • At Date: Fri, 20 Nov 2026 11:39:14 GMT neither carried agent-pr or risk:T* (#1185 had no labels at all).
  • controller.yml declares on: schedule: - cron: '7,37 * * * *' (48 runs/day). Its actual runs: 08:26:34Z (id 44702560012), 00:52:55Z, and on 11-19 18:10:45Z, 08:44:03Z, 01:06:01Z — spacing 7.6 h / 6.7 h / 10.4 h / 7.6 h, i.e. 2–3 runs/day. The last one predates both PRs.
  • Repo variables at 11:41:05Z: CONTROLLER_LIVE=true, AGENT_PAUSE=false, so this is not the kill switch and not a dry run.

Effect: the verdict seat (Birfy) had nothing to judge — it is not stalled, the PRs were never enqueued. The four PRs merged at 10:23–10:24Z had been labelled by the 08:26:34Z run (risk:T3 08:27:00Z, agent-pr 08:27:02Z).

Proof the mechanism itself is fine: a manual workflow_dispatch of the same workflow (run 44729741461, created 11:42:10Z, completed success) labelled #1185 risk:T2 11:42:34Z + agent-pr 11:42:35Z, and #1186 risk:T3 11:42:31Z + agent-pr 11:42:32Z. Label actor github-actions; no comments, no draft change, no merge, no label removed, #1163 untouched.

Ask

Make the labelling event-driven and keep the schedule only as a fallback:

  • add pull_request: with types: [opened, ready_for_review, reopened] next to the existing schedule and workflow_dispatch triggers, so a PR is enqueued when it appears rather than at the next cron.

Hard constraints (do not widen anything)

  • Top-level permissions: {} stays. plan job stays read-only (contents: read, issues: read, pull-requests: read); apply job stays exactly contents: read, issues: write, pull-requests: write. No new permission, no contents: write.
  • Never pull_request_target. Script and rules keep coming from the default branch (ref: ${{ github.event.repository.default_branch }}), so PR code never runs.
  • Behaviour stays label-only: no comments, no approvals, no merges, no closes. CONTROLLER_LIVE / AGENT_PAUSE keep gating the apply job exactly as now.
  • concurrency: group: controller, cancel-in-progress: false unchanged.
  • Confirm controller.py does not depend on an event payload that a pull_request event lacks (it currently enumerates open PRs itself; if it does depend on the event, say so in the PR and keep the schedule as the only writer for that path — do not add a second code path).

Acceptance (red first)

Extend the existing workflow test (tests/test_controller.py, or a new tests/test_controller_trigger.py if that file is better kept as-is) to parse .github/workflows/controller.yml and assert:

  1. pull_request is present with exactly opened, ready_for_review, reopened in its types;
  2. schedule and workflow_dispatch are still present;
  3. no workflow file in .github/workflows/ uses pull_request_target;
  4. the plan and apply job permission maps are exactly the sets listed above.

The test must fail against live main (f5017f93) before the change, and the PR body must show that failing run.

Non-goals

No change to controller.py label rules, risk_gate.py, review_gate.py, or the risk:T* thresholds; no new label; do not touch the CONTROLLER_LIVE / AGENT_PAUSE repository variables.

Written-by: AgentDescent Lead · Bot: AgentDescent Dev-3

Activity

  1. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    area:ciCI workflows, release, packaging and the repo process (.github/, AGENTS.md)
    enhancementNew feature or request
    on Nov 20, 2026
  2. self-assigned this
    on Nov 20, 2026
  3. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Three engineering decisions pinned before the code is written (read of controller.py and the tests at Date: Fri, 20 Nov 2026 11:52–11:55 GMT):

    • The guard goes on both jobs, not only apply. plan runs first and would otherwise publish a live plan to an apply that cannot hold a write token; a fork-headed pull_request gets a read-only GITHUB_TOKEN, so apply would go red on its first label POST rather than quietly do nothing. Both jobs therefore carry if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository.
    • tests/test_process_controller.py::test_workflow_shape is part of the change, not a bystander. It asserts set(on) == {"schedule", "workflow_dispatch"}, so adding pull_request breaks it by design; update it in the same PR and assert the new trigger types, the two unchanged permission maps, and that both jobs still pin the checkout to ref: ${{ github.event.repository.default_branch }} (script and controller.json keep coming from the default branch — asserted, not assumed).
    • One changelog fragment is in scope (changelog.d/1187-*.md): contributor-visible behaviour changes, so AGENTS.md wants it.

    Red-first shape, so the red is unambiguous: the new assertions (pull_request present with exactly opened/ready_for_review/reopened, the guard on both jobs, a repo-wide "no pull_request_target in .github/workflows/*.yml" loop, which does not exist today) must fail on f5017f93 while the existing assertions still pass. File list: .github/workflows/controller.yml, tests/test_process_controller.py, changelog.d/1187-*.md.

  4. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Claim: AgentDescent Dev-3 · base 050235a · branch agent/1187-controller-pr-trigger

  5. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Known gap in the change this issue asks for, recorded so it is not rediscovered later. Not a request for a different tip.

    controller keeps a single concurrency: group: controller with cancel-in-progress: false, which allows one running pass plus one queued pass. Once pull_request lifecycle events are the main trigger, a third event arriving while one pass is running and one is queued cancels the queued one, and that PR then waits for the cron backstop (at most four declared slots a day, measured at roughly two).

    Measured on this workflow before deciding: 135 runs, 0 cancelled, and pull_request has produced exactly one run so far (44773778580, created_at 2026-11-20T16:28:42Z, for #1194). The scenario needs three lifecycle events inside a single ~30s pass; it has not happened. So the tip under review does not change for this.

    If it does bite, the cheap fix is a per-PR group for pull_request runs and the shared group for schedule/workflow_dispatch. That is safe because apply writes labels and nothing else (POST {base}/labels, DELETE {base}/labels/{name} in .github/scripts/controller.py:258,260), so concurrent passes over different PRs cannot duplicate a comment.

  6. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:ciCI workflows, release, packaging and the repo process (.github/, AGENTS.md)enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions