Skip to content

feat(agentx): gate PR and manual runs on a reviewer allowlist - #246

Merged
zhenhuang12 merged 4 commits into
mainfrom
feat/agentx-allowlist
Nov 18, 2026
Merged

zhenhuang12 merged 4 commits into
mainfrom
feat/agentx-allowlist

Conversation

@RuibinCheung

@RuibinCheung RuibinCheung commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Any collaborator who can add ci:agentx-mi355x to a PR, or start the workflow by hand, can take the MI355X runner for a full AgentX sweep, and the models come from the PR author's own AgentX: line. This PR moves both decisions to a short list of reviewers in benchmarks/agentx/allowlist.yaml. A labeled PR runs only after one of them comments /agentx-mi355x <model ids or all>, and the comment picks the models. Manual runs must be started by one of them, from main.

Scope

  • PR runs (pull_request with ci:agentx-mi355x): the plan job reads the PR's comments and uses the latest one by an allowlisted reviewer whose first line starts with /agentx-mi355x. That comment replaces the PR description's AgentX: line in picking the models, with the same rules: model ids ignoring case, all alone, unknown names skipped with a warning, and no enabled model skipping the run. Without such a comment the plan fails with an error that names the reviewers to ask.
  • Manual runs (workflow_dispatch): github.triggering_actor (whoever clicked Run or Re-run) must be on the allowlist and the ref must be refs/heads/main; otherwise the plan fails before any sweep. Scheduled runs are unchanged.
  • Allowlist and ownership: allowlist.yaml holds the reviewers, so adding one is a one-line change. It is checked to be a non-empty list of distinct, valid GitHub logins. The plan authorizes against main's copy, fetched through the API, never the checked-out one a PR branch or an older commit carries; the workflow's concurrency group holds a copy, tested to match, so a refused manual run gets a group of its own and cannot replace a queued run. CODEOWNERS assigns it and agentx-ci.yaml to the same reviewers. The README (en/zh) and the PR template's AgentX: hint describe the new flow.
  • AgentX tests on pytest: pyproject.toml sets pytest's pythonpath to benchmarks/agentx, so every AgentX test under tests/benchmarks imports agentx_ci directly instead of patching sys.path around importlib. Patches use monkeypatch (or pytest.MonkeyPatch.context() where one must end before the test does), as tests/AGENTS.md asks; mock.Mock remains only as a double whose calls a test checks. No test is added or dropped by this part.

Tradeoffs

  • A comment does not start a run. After a reviewer comments, re-run the failed workflow or push a commit. The trigger stays pull_request, so the run still shows among the PR's checks; an issue_comment trigger would not show there and would need the head commit pinned by hand.
  • The authorization stays with the PR. Later pushes run under the latest reviewer request, until a reviewer comments again.
  • "Re-run failed jobs" skips the sweep. Sweep and report need this attempt's plan, as in ci.yaml, so a re-run always re-checks authorization; use "Re-run all jobs".
  • A command must start the comment's first line, with no leading whitespace: GitHub renders an indented line as code, such as a quoted example.

Verification

Environment: head 6c263053, CPU only (no GPU needed: the change is in planning only), Python 3.12, PyYAML, jsonschema
Gate overrides: none

Code

  • pytest tests/benchmarks -k agentx: 325 passed; each AgentX test file also passes alone. On main the same command passes 299 before and after the pytest change.
  • python3 tests/check_layout.py and pre-commit on the changed files: clean.
  • New or rewritten tests in tests/benchmarks/test_agentx_plan.py:
    • comment parsing: first line only, command and model ids ignoring case, all, unknown names, and a request that selects no model;
    • the latest allowlisted request wins, and comments from others are ignored;
    • the plan fails, with an ::error annotation and a job summary, when no reviewer has authorized;
    • manual runs: allowed for a reviewer on main, refused for another user or another ref;
    • allowlist file validation;
    • the workflow fetches every comment page and main's allowlist, and passes --pr-comments, --allowlist, --manual-actor and --manual-ref;
    • the workflow's queue allowlist matches allowlist.yaml, and sweep and report need this attempt's plan;
    • indented or code-fenced commands do not authorize.
  • ruff check and ruff format --check on benchmarks/agentx and tests/benchmarks: clean. actionlint on .github/workflows/agentx-ci.yaml: clean.
  • No aklr/core change; no schema or measurement version change.

Not run

  • No AgentX run on GitHub: neither a labeled PR nor a manual dispatch was tried. Until this merges, main has no allowlist.yaml, so a labeled or manual run of this branch fails at the allowlist fetch; the flow can be checked end to end only after merging.
  • No GPU sweep: this PR changes only which runs are planned, and how they are measured stays the same.

Risk

Affects: AgentX CI only, the plan job of agentx-ci.yaml. No kernel, op or serving path changes.
AgentX: none
If wrong: AgentX PR or manual runs fail at plan, or run the wrong models. Open PRs that already carry ci:agentx-mi355x now fail at plan until a reviewer comments. The gate is not a security boundary against writers: a PR runs its own branch's workflow and allowlist.yaml, and a writer can dispatch from an edited branch workflow. Limiting the runner to main's workflow would need an org-level runner group.
Undo: git revert. Nothing persistent changes: no schema, measurement version or published result.

A ci:agentx-mi355x PR run now needs authorization from a reviewer listed in
benchmarks/agentx/allowlist.yaml: the plan job reads the PR comments and uses
the latest comment by an allowlisted reviewer whose first line is
`/agentx-mi355x <model ids or all>` to pick the models, replacing the PR
description's `AgentX:` line. Without one, the plan fails and asks the author
to get a reviewer's authorization.

Manual runs must be started (or re-run) by an allowlisted reviewer, from main.

CODEOWNERS assigns allowlist.yaml and agentx-ci.yaml to the reviewers.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Sweep authorization can be bypassed through reused plans or stale allowlists, while unauthorized dispatches can disrupt queued runs and indented examples can unintentionally authorize sweeps.

4 open issues
What changed in this PR

Introduces reviewer-controlled planning for AgentX CI on MI355X. Labeled PR runs use reviewer comments instead of the PR description to select models, while manual runs gain reviewer and branch checks.

Changes:

  • Selects PR models from the latest allowlisted reviewer's /agentx-mi355x comment.
  • Adds allowlist validation, manual actor/ref checks, and ownership rules.
  • Updates planner tests and contributor documentation for the new authorization flow.
File Description
tests/​benchmarks/​test_agentx_plan.py Tests comment selection, authorization, allowlist validation, and workflow wiring.
benchmarks/​agentx/​README.zh.md Updates Chinese instructions for reviewer authorization.
benchmarks/​agentx/​README.md Documents reviewer commands and manual-run restrictions.
benchmarks/​agentx/​allowlist.yaml Defines reviewers permitted to authorize runs.
benchmarks/​agentx/​agentx_ci/​pr_scope.py Validates reviewers and parses authorized model requests.
benchmarks/​agentx/​agentx_ci/​plan.py Enforces planning gates and reports authorization outcomes.
.github/​workflows/​agentx-ci.yaml Fetches PR comments and passes manual-run context to planning.
.github/​pull_request_template.md Updates the AgentX: hint to describe reviewer authorization.
.github/​CODEOWNERS Assigns allowlist and workflow ownership to AgentX reviewers.

Review effort: Max

PR_BODY: ${{ github.event_name == 'pull_request' && 'pr-body.md' || '' }}
PR_COMMENTS: ${{ github.event_name == 'pull_request' && 'pr-comments.json' || '' }}
# A manual run needs an allowlisted reviewer (who clicked Run or Re-run) and main.
MANUAL_ACTOR: ${{ github.event_name == 'workflow_dispatch' && github.triggering_actor || '' }}
"""Let only an allowlisted reviewer start a manual run, and only from main."""
if args.manual_actor is None:
return
allowlist = load_reviewers(args.allowlist)
${REQUIRE_RECIPE_DURATION:+--require-recipe-duration "$REQUIRE_RECIPE_DURATION"} \
${PR_BODY:+--pr-body "$RUNNER_TEMP/$PR_BODY"} \
${PR_COMMENTS:+--pr-comments "$RUNNER_TEMP/$PR_COMMENTS"} \
${MANUAL_ACTOR:+--manual-actor "$MANUAL_ACTOR" --manual-ref "$GITHUB_REF"} \
Comment thread benchmarks/agentx/agentx_ci/pr_scope.py Outdated

def is_request(body: str) -> bool:
"""Whether the comment's first line starts with the command, ignoring case."""
words = (body or "").splitlines()[0].split(maxsplit=1) if body else []
- Sweep and report run only with this attempt's plan, so "Re-run failed jobs"
  cannot reuse a plan without re-checking authorization.
- Authorize against main's allowlist.yaml, fetched through the API, not the
  checked-out copy a PR branch or an older commit carries.
- Give manual runs by someone off the allowlist, or from another ref, a
  concurrency group of their own, so they cannot replace a queued run; the
  workflow's copy of the allowlist must match allowlist.yaml (tested).
- Refuse a `/agentx-mi355x` command with leading whitespace, which GitHub
  renders as code.
main (#250) moved the AgentX tests to pytest. Port this branch's PR-comment,
allowlist, manual-run and workflow tests in test_agentx_plan.py to plain pytest
functions with parametrize, on main's PlanCase.
- pyproject.toml sets pytest's pythonpath to benchmarks/agentx, so the tests
  import agentx_ci directly instead of patching sys.path around importlib.
- Replace mock.patch.object with monkeypatch.setattr, and with
  pytest.MonkeyPatch.context() where a patch must end before the test does.
  Plain functions and a charted fixture replace doubles nobody inspects;
  mock.Mock stays only where a test checks the calls.
- agentx_results.py keeps the shared payloads; each test imports the
  agentx_ci modules it uses.
@zhenhuang12
zhenhuang12 merged commit b6dd38e into main Nov 18, 2026
9 checks passed

This branch was previously deployed

1 inactive deployment
gpu-trusted — 6c263053 Deployed Nov 18, 2026 by RuibinCheung via prepare-gpu / prepare #1040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants