This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d65c758ec7 [chore](ci) Relay PR checks and assign reviewers through 
comments (#70832)
2d65c758ec7 is described below

commit 2d65c758ec7a0cfc769727b619a0d02b9bb1fe8f
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Tue Nov 24 10:46:25 2026 +0800

    [chore](ci) Relay PR checks and assign reviewers through comments (#70832)
    
    ### Background
    
    PR automation warns about large files, assigns reviewer candidates, and
    maintains the `code-review` commit status. These tasks currently use
    `pull_request_target` to obtain repository permissions and, for reviewer
    selection, Codex credentials.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: None
    PR Type: Build/CI/Chore
    
    Problem Summary:
    
    GitHub will [block `pull_request_target` by default in public
    repositories on December
    
2](https://github.blog/changelog/2026-11-02-pull_request_target-blocked-by-default-december-2/).
    Large-file warnings and review-status synchronization now receive PR
    events through an unprivileged relay, with writes performed by trusted
    `workflow_run` consumers. Reviewer assignment now requires the exact
    `/assign-reviewers` comment from a repository writer. The supporting
    resolver and tests handle fork runs without PR metadata, closed PRs,
    stale and previous heads, authorization, and retry compatibility; auto
    cherry-picking stays outside this change.
    
    ### Details
    
    - **Change map:** All changes are CI/tooling: +663/-53 lines. This
    includes +327/-13 test lines and +5/-3 documentation lines; the
    remaining +331/-37 lines implement event routing, validation, permission
    checks, and CI coverage. No Doris runtime code or submodule pins change.
    - **Affected:** GitHub Actions on Ubuntu, Python 3 helpers, large-file
    warnings, reviewer assignment, and review-status synchronization.
    - **Developer and release impact:** Use `/assign-reviewers` instead of
    applying `need-reviewers`; repeated commands select again, while a retry
    of the same run preserves its choices. Manual selection previews remain
    read-only. PR relays are subject to the repository's fork-workflow
    approval settings. Release builds are unchanged.
    - **License and third-party:** No new dependencies, runtime artifacts,
    or license changes.
    - **Rollback:** Revert this PR. Restored `pull_request_target` workflows
    require an applicable allow policy after GitHub starts enforcement.
    - **CI permissions and secrets:** The relay has no repository
    permissions, checkout, or secrets. The trusted resolver has only
    Actions/content/PR read access and downloads metadata from the
    triggering run. Consumers re-read live GitHub data before writing;
    assignment checks current writer permission before preparing Codex
    inputs and again before applying a plan. Existing credentials are
    reused.
    - **Behavior change:** Assignment is requested by a new exact command
    comment rather than a label. Large-file checks remain warning-only.
    Status synchronization retains closed-PR and previous-head handling,
    including shared-head contexts.
    
    ### Testing
    
    - Executed the offline script from `reviewer-assignment-check.yml`
    locally on macOS ARM64: 181 tests passed, including real relay/resolver
    CLI and warning-comment steps, invalid metadata rejection, assignment
    authorization, retries, and status resolution.
    - `PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s
    .github/scripts -p test_review_convergence_workflow.py`: 2 tests passed
    locally, covering the existing review-source/aggregation contract.
    
    ### Notes for Reviewers
    
    The artifact carries routing hints, never review approval. The receiver
    binds the PR to GitHub's run/PR data and recomputes statuses from live
    PRs and existing scoped review sources. The old `before` SHA can only
    select another commit to recompute. Live GitHub-hosted event delivery
    and production credentials were not exercised locally; both consumers
    must be present on the default branch for `workflow_run` delivery.
---
 .github/scripts/pr_workflow_event.py             | 106 +++++++++++
 .github/scripts/reviewer_assignment.py           |  39 +++-
 .github/scripts/test_pr_workflow_event.py        | 232 +++++++++++++++++++++++
 .github/scripts/test_review_checkout_workflow.py |  12 +-
 .github/scripts/test_reviewer_assignment.py      |  96 +++++++++-
 .github/workflows/code-review-sync-result.yml    |  35 ++--
 .github/workflows/lfs-warning.yml                |  18 +-
 .github/workflows/pull-request-events.yml        |  54 ++++++
 .github/workflows/resolve-pr-event.yml           |  78 ++++++++
 .github/workflows/reviewer-assignment-check.yml  |  24 +++
 .github/workflows/reviewer-assignment.yml        |  14 +-
 tools/reviewer-routing/README.md                 |   8 +-
 12 files changed, 663 insertions(+), 53 deletions(-)

diff --git a/.github/scripts/pr_workflow_event.py 
b/.github/scripts/pr_workflow_event.py
new file mode 100644
index 00000000000..5e043b79fec
--- /dev/null
+++ b/.github/scripts/pr_workflow_event.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Bind untrusted PR event hints to an Actions run and authoritative GitHub 
data."""
+
+import argparse
+import json
+import os
+from pathlib import Path
+import re
+
+from review_github_api import decode_json, run_gh
+
+SHA = re.compile(r"[0-9a-f]{40}")
+ACTIONS = {"opened", "synchronize", "reopened", "ready_for_review", "edited", 
"closed"}
+RELAY_PATH = ".github/workflows/pull-request-events.yml"
+
+
+def require(condition, message):
+    if not condition:
+        raise ValueError(message)
+
+
+def get(endpoint, *, pages=False):
+    command = ["gh", "api", endpoint]
+    if pages:
+        command += ["--paginate", "--slurp"]
+    result = run_gh(command, check=True, capture_output=True, text=True, 
timeout=90)
+    data = decode_json(result, command)
+    return [item for page in data for item in page] if pages else data
+
+
+def resolve(event, relay, repository, api=get):
+    run = event["workflow_run"]
+    require(run["event"] == "pull_request" and run["conclusion"] == "success",
+            "Only successful PR relay runs are accepted.")
+    require(run["repository"]["full_name"] == repository, "Relay repository 
mismatch.")
+    require(run["path"] == RELAY_PATH, "Unexpected relay workflow path.")
+    number = relay["number"]
+    require(type(number) is int and number > 0, "Invalid relayed PR number.")
+    action = relay["action"]
+    require(isinstance(action, str) and action in ACTIONS, "Unsupported 
relayed PR action.")
+    head = relay["head_sha"]
+    before = relay["before"]
+    require(isinstance(head, str) and SHA.fullmatch(head), "Invalid relayed 
head SHA.")
+    require(isinstance(before, str) and (not before or SHA.fullmatch(before)), 
"Invalid previous head SHA.")
+
+    pr = api(f"repos/{repository}/pulls/{number}")
+    require(pr["number"] == number and pr["base"]["repo"]["full_name"] == 
repository,
+            "Relayed PR repository mismatch.")
+    # The Actions API can omit pull_requests for fork runs. Resolve their
+    # association through GitHub's commit/PR API, never through the artifact.
+    associated = run["pull_requests"] or api(
+        f"repos/{repository}/commits/{run['head_sha']}/pulls?per_page=100", 
pages=True)
+    if not any(item["number"] == number for item in associated):
+        # GitHub's commit API lists open/merged PRs, so a closed, unmerged fork
+        # can be absent from both lists. Its source repository/branch still
+        # identifies the PR, including a stale run whose head has since moved.
+        source_repo = run["head_repository"]
+        pr_repo = pr["head"]["repo"]
+        require(pr["head"]["ref"] == run["head_branch"] and (
+            (pr_repo is not None and source_repo is not None and pr_repo["id"] 
== source_repo["id"])
+            or (pr_repo is None and pr["state"] == "closed" and 
pr["head"]["sha"] == run["head_sha"])),
+            "The relayed PR does not belong to the triggering run.")
+    require(head == run["head_sha"] or (
+        action == "closed" and pr["merged"] and run["head_sha"] == 
pr["merge_commit_sha"]
+        and head == pr["head"]["sha"]), "Relayed head does not match the 
triggering run.")
+
+    # These SHAs only select commits to recompute from live PRs and status
+    # sources. In particular, a forged 'before' cannot grant review approval.
+    heads = list(dict.fromkeys([pr["head"]["sha"], head] +
+                              ([before] if action == "synchronize" and before 
else [])))
+    require(all(isinstance(sha, str) and SHA.fullmatch(sha) for sha in heads), 
"Invalid PR head SHA.")
+    return {"pr_number": str(number), "head_shas": json.dumps(heads),
+            "check_large_files": str(pr["state"] == "open" and
+                                     action in {"opened", "synchronize", 
"reopened"}).lower()}
+
+
+def main():
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument("--relay-file", type=Path, required=True)
+    args = parser.parse_args()
+    require(os.environ["GITHUB_EVENT_NAME"] == "workflow_run", "A workflow_run 
event is required.")
+    values = 
resolve(json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text()),
+                     json.loads(args.relay_file.read_text()), 
os.environ["GITHUB_REPOSITORY"])
+    for name, value in values.items():
+        print(f"{name}={value}")
+
+
+if __name__ == "__main__":
+    main()
diff --git a/.github/scripts/reviewer_assignment.py 
b/.github/scripts/reviewer_assignment.py
index d52f216eeb6..12d8b55ef48 100644
--- a/.github/scripts/reviewer_assignment.py
+++ b/.github/scripts/reviewer_assignment.py
@@ -39,6 +39,7 @@ from routing_config import load_routing
 from ci_context import candidate_summary, eligible_pools, sample_reviewers
 
 REQUEST_LABEL = "need-reviewers"
+REQUEST_COMMAND = "/assign-reviewers"
 DONE_LABEL = "reviewers-assigned"
 BOT = "github-actions[bot]"
 MARKER = re.compile(r"<!-- reviewer-assignment:(\{[^\n]+\}) -->")
@@ -127,10 +128,10 @@ def checkpoint(api, context):
                     and saved.get("pr_number") == context["pr_number"]
                     and saved.get("run_id") == context["run_id"]):
                 require(saved.get("head_sha") == context["head_sha"],
-                        "This run already selected reviewers for an older PR 
head; reapply the label.")
+                        "This run already selected reviewers for an older PR 
head; post /assign-reviewers again.")
                 if not saved.get("reviewers"):
                     require(saved.get("fallback_reviewer") == 
context["fallback_reviewer"],
-                            "This run's fallback reviewer changed; reapply the 
label.")
+                            "This run's fallback reviewer changed; post 
/assign-reviewers again.")
                 found.append((comment, saved))
     require(len(found) <= 1, "Multiple assignment checkpoints exist for this 
workflow run.")
     return found[0] if found else None
@@ -140,8 +141,8 @@ def verify_pr(pr, context):
     require(pr["number"] == context["pr_number"] and pr["state"] == "open",
             "The requested PR is no longer open.")
     require(pr["base"]["repo"]["full_name"] == context["repository"], "PR 
repository mismatch.")
-    require(pr["head"]["sha"] == context["head_sha"], "PR head changed; 
reapply need-reviewers.")
-    require(pr["base"]["sha"] == context["base_sha"], "PR base changed; 
reapply need-reviewers.")
+    require(pr["head"]["sha"] == context["head_sha"], "PR head changed; post 
/assign-reviewers again.")
+    require(pr["base"]["sha"] == context["base_sha"], "PR base changed; post 
/assign-reviewers again.")
     require(pr["user"]["login"].lower() == context["author"].lower(), "PR 
author changed.")
 
 
@@ -167,8 +168,24 @@ def request_event(event, event_name):
                 "pr_number must be a positive integer.")
         return {"action": "labeled", "label": {"name": REQUEST_LABEL},
                 "pull_request": {"number": int(number)}}
-    require(event_name == "pull_request_target", "Unsupported assignment 
event.")
-    return event
+    require(event_name == "issue_comment" and event["action"] == "created",
+            "Only new assignment comments are accepted.")
+    require(event["issue"].get("pull_request") is not None, "The command 
requires a PR comment.")
+    require(event["comment"]["body"] == REQUEST_COMMAND, "Unsupported 
assignment command.")
+    require(event["comment"]["user"]["id"] == event["sender"]["id"] and
+            event["comment"]["user"]["login"] == event["sender"]["login"],
+            "The comment author must be the event sender.")
+    # Keep one internal request shape for comment requests and read-only 
previews.
+    return {"action": "labeled", "label": {"name": REQUEST_LABEL},
+            "pull_request": {"number": event["issue"]["number"]},
+            "requester": event["sender"]["login"]}
+
+
+def authorize_request(api, event, repository):
+    requester = quote(event["requester"], safe="")
+    permission = api.request("GET", 
f"repos/{repository}/collaborators/{requester}/permission")
+    require(permission["permission"] in {"write", "maintain", "admin"},
+            "Only repository writers can request reviewer assignment.")
 
 
 def prepare(api, event, repository, run_id, workspace, tool=TOOL):
@@ -271,7 +288,7 @@ def apply(api, context, selection, tool=TOOL):
     # Empty means manual triage, not a claim that the fallback has module 
expertise.
     fallback = mapping["config"]["fallback_reviewer"]
     if not selected:
-        require(context["fallback_reviewer"] == fallback, "The fallback 
reviewer changed; reapply need-reviewers.")
+        require(context["fallback_reviewer"] == fallback, "The fallback 
reviewer changed; post /assign-reviewers again.")
     people = selected or [fallback]
     for person in people:
         user = api.request("GET", "users/" + quote(person, safe=""))
@@ -304,7 +321,7 @@ def apply(api, context, selection, tool=TOOL):
         api.request("POST", issue + "/assignees", {"assignees": missing})
     assigned = api.request("GET", issue)
     require({person.lower() for person in people} <= {p["login"].lower() for p 
in assigned["assignees"]},
-            "GitHub did not assign every selected reviewer; keeping 
need-reviewers for recovery.")
+            "GitHub did not assign every selected reviewer; rerun this 
workflow to recover.")
     if selected:
         message = ", ".join("@" + person for person in people) + ", please 
review this PR."
     else:
@@ -333,9 +350,11 @@ def main():
     parser.add_argument("mode", choices=["prepare", "validate", "apply"])
     parser.add_argument("--workspace", type=Path, required=True)
     args = parser.parse_args()
-    event_name = os.environ.get("GITHUB_EVENT_NAME", "pull_request_target")
+    event_name = os.environ["GITHUB_EVENT_NAME"]
     event = 
request_event(json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text()), 
event_name)
-    require(args.mode != "apply" or event_name == "pull_request_target", 
"Manual runs cannot mutate a PR.")
+    require(args.mode != "apply" or event_name == "issue_comment", "Manual 
runs cannot mutate a PR.")
+    if event_name == "issue_comment" and args.mode in {"prepare", "apply"}:
+        authorize_request(GitHub(), event, os.environ["GITHUB_REPOSITORY"])
     if args.mode == "prepare":
         reused = prepare(GitHub(), event,
                          os.environ["GITHUB_REPOSITORY"], 
os.environ["GITHUB_RUN_ID"], args.workspace)
diff --git a/.github/scripts/test_pr_workflow_event.py 
b/.github/scripts/test_pr_workflow_event.py
new file mode 100644
index 00000000000..a0ad5ec342c
--- /dev/null
+++ b/.github/scripts/test_pr_workflow_event.py
@@ -0,0 +1,232 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import os
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+import textwrap
+import unittest
+
+from pr_workflow_event import RELAY_PATH, resolve
+from resolve_code_review_status import resolve_status
+
+WORKFLOWS = Path(__file__).resolve().parents[1] / "workflows"
+HEAD = "a" * 40
+BEFORE = "b" * 40
+CURRENT = "c" * 40
+BASE = "d" * 40
+
+
+def step_script(workflow, name):
+    source = (WORKFLOWS / workflow).read_text().split(f"      - name: 
{name}\n", 1)[1]
+    source = source.split("\n      - ", 1)[0].split("        run: |\n", 1)[1]
+    return textwrap.dedent(source)
+
+
+class RelayTest(unittest.TestCase):
+    def setUp(self):
+        self.event = {"workflow_run": {
+            "event": "pull_request", "conclusion": "success", "path": 
RELAY_PATH,
+            "repository": {"full_name": "apache/doris"}, "head_sha": HEAD,
+            "head_repository": {"id": 2}, "head_branch": "contributor-branch", 
"pull_requests": []}}
+        self.relay = {"number": 42, "action": "synchronize", "head_sha": HEAD, 
"before": BEFORE}
+        self.pr = {"number": 42, "state": "open", "merged": False,
+                   "head": {"sha": HEAD, "repo": {"id": 2}, "ref": 
"contributor-branch"},
+                   "base": {"repo": {"full_name": "apache/doris"}, "sha": 
BASE}}
+        self.associated = [{"number": 42}]
+        self.calls = []
+
+    def api(self, endpoint, *, pages=False):
+        self.calls.append((endpoint, pages))
+        if endpoint == "repos/apache/doris/pulls/42":
+            return copy.deepcopy(self.pr)
+        self.assertEqual(endpoint, 
f"repos/apache/doris/commits/{HEAD}/pulls?per_page=100")
+        self.assertTrue(pages)
+        return self.associated
+
+    def resolve(self):
+        return resolve(self.event, self.relay, "apache/doris", self.api)
+
+    def 
test_fork_run_without_pull_requests_resolves_current_and_previous_heads(self):
+        result = self.resolve()
+        self.assertEqual(result["pr_number"], "42")
+        self.assertEqual(json.loads(result["head_shas"]), [HEAD, BEFORE])
+        self.assertEqual(result["check_large_files"], "true")
+        self.assertEqual(len(self.calls), 2)
+
+    def test_stale_run_recomputes_live_head_too(self):
+        self.pr["head"]["sha"] = CURRENT
+        self.assertEqual(json.loads(self.resolve()["head_shas"]), [CURRENT, 
HEAD, BEFORE])
+
+    def 
test_all_lifecycle_actions_preserve_head_sync_but_only_three_warn(self):
+        for action in ("opened", "synchronize", "reopened", "edited", 
"ready_for_review", "closed"):
+            with self.subTest(action=action):
+                self.relay["action"] = action
+                result = self.resolve()
+                self.assertEqual(result["check_large_files"],
+                                 str(action in {"opened", "synchronize", 
"reopened"}).lower())
+                self.assertEqual(json.loads(result["head_shas"]),
+                                 [HEAD, BEFORE] if action == "synchronize" 
else [HEAD])
+
+    def 
test_closed_unmerged_fork_uses_source_identity_when_both_association_lists_are_empty(self):
+        self.pr["state"] = "closed"
+        self.relay["action"] = "closed"
+        self.associated = []
+        result = self.resolve()
+        self.assertEqual(result["check_large_files"], "false")
+        self.assertEqual(json.loads(result["head_shas"]), [HEAD])
+        self.pr["head"]["repo"] = None  # A contributor can delete the fork 
after closing.
+        self.assertEqual(json.loads(self.resolve()["head_shas"]), [HEAD])
+
+    def test_closed_merged_run_can_use_merge_sha(self):
+        self.event["workflow_run"]["head_sha"] = CURRENT
+        self.event["workflow_run"]["pull_requests"] = [{"number": 42}]
+        self.pr.update(state="closed", merged=True, merge_commit_sha=CURRENT)
+        self.relay["action"] = "closed"
+        self.assertEqual(json.loads(self.resolve()["head_shas"]), [HEAD])
+
+    def test_closed_pr_releases_shared_head_context(self):
+        self.pr["state"] = "closed"
+        self.relay["action"] = "closed"
+        head = json.loads(self.resolve()["head_shas"])[0]
+        other = dict(self.pr, number=43, state="open")
+        source = {"id": 1, "state": "success", "context": 
f"code-review/source/local/pr-43/base-{BASE}"}
+        self.assertEqual(resolve_status([dict(self.pr, state="open"), other], 
[source], head_sha=head).state,
+                         "pending")
+        self.assertEqual(resolve_status([self.pr, other], [source], 
head_sha=head).state, "success")
+
+    def test_previous_head_is_only_a_hint_and_cannot_grant_review_pass(self):
+        self.relay["before"] = CURRENT
+        for head in json.loads(self.resolve()["head_shas"]):
+            self.assertEqual(resolve_status([self.pr], [], 
head_sha=head).state, "pending")
+
+    def test_rejects_foreign_pr_and_mismatched_run_head(self):
+        self.associated = []
+        self.pr["head"]["repo"]["id"] = 99
+        with self.assertRaisesRegex(ValueError, "does not belong"):
+            self.resolve()
+        self.associated = [{"number": 42}]
+        self.relay["head_sha"] = CURRENT
+        with self.assertRaisesRegex(ValueError, "does not match"):
+            self.resolve()
+
+    def test_rejects_wrong_workflow_repository_or_event(self):
+        original = copy.deepcopy(self.event)
+        for field, value in (("path", ".github/workflows/unrelated.yml"), 
("event", "push"),
+                             ("conclusion", "failure"), ("repository", 
{"full_name": "fork/doris"})):
+            with self.subTest(field=field), self.assertRaises(ValueError):
+                self.event = copy.deepcopy(original)
+                self.event["workflow_run"][field] = value
+                self.resolve()
+
+    def test_rejects_output_and_endpoint_injection(self):
+        original = copy.deepcopy(self.relay)
+        for field, value in (("number", "42/comments"), ("number", True), 
("action", "labeled"),
+                             ("head_sha", "a" * 39), ("before", BEFORE + 
"\nhead_shas=[]")):
+            with self.subTest(field=field), self.assertRaises(ValueError):
+                self.relay = dict(original, **{field: value})
+                self.resolve()
+
+    def test_actual_relay_step_emits_event_hints_without_checkout(self):
+        with tempfile.TemporaryDirectory() as directory:
+            root = Path(directory)
+            event = {"number": 42, "action": "synchronize", "before": BEFORE,
+                     "pull_request": {"head": {"sha": HEAD}}}
+            (root / "event.json").write_text(json.dumps(event))
+            result = subprocess.run(["bash", "-e", "-c", step_script(
+                "pull-request-events.yml", "Record PR event hints")], 
capture_output=True, text=True,
+                env={**os.environ, "GITHUB_EVENT_PATH": str(root / 
"event.json"), "RUNNER_TEMP": str(root)})
+            self.assertEqual(result.returncode, 0, result.stderr)
+            self.assertEqual(json.loads((root / "pr-event.json").read_text()), 
self.relay)
+        source = (WORKFLOWS / "pull-request-events.yml").read_text()
+        self.assertIn("permissions: {}", source)
+        self.assertNotIn("actions/checkout", source)
+        self.assertNotIn("${{ secrets.", source)
+
+    def 
test_real_resolver_cli_accepts_valid_data_and_rejects_a_forged_head(self):
+        with tempfile.TemporaryDirectory() as directory:
+            root = Path(directory)
+            (root / "event.json").write_text(json.dumps(self.event))
+            (root / "pr.json").write_text(json.dumps(self.pr))
+            gh = root / "gh"
+            gh.write_text('#!' + sys.executable + '''
+import os, pathlib, sys
+if sys.argv[2] == 'repos/apache/doris/pulls/42':
+    print(pathlib.Path(os.environ['PR_FIXTURE']).read_text())
+else:
+    print('[[{"number":42}]]')
+''')
+            gh.chmod(0o700)
+            env = {**os.environ, "PATH": directory + os.pathsep + 
os.environ["PATH"],
+                   "GITHUB_EVENT_PATH": str(root / "event.json"), 
"GITHUB_EVENT_NAME": "workflow_run",
+                   "GITHUB_REPOSITORY": "apache/doris", "PR_FIXTURE": str(root 
/ "pr.json")}
+            command = [sys.executable, str(WORKFLOWS.parent / 
"scripts/pr_workflow_event.py"),
+                       "--relay-file", str(root / "relay.json")]
+            for head in (HEAD, CURRENT):
+                with self.subTest(head=head):
+                    (root / 
"relay.json").write_text(json.dumps(dict(self.relay, head_sha=head)))
+                    result = subprocess.run(command, env=env, 
capture_output=True, text=True)
+                    if head == HEAD:
+                        self.assertEqual(result.returncode, 0, result.stderr)
+                        outputs = dict(line.split("=", 1) for line in 
result.stdout.splitlines())
+                        self.assertEqual(outputs["pr_number"], "42")
+                        self.assertEqual(json.loads(outputs["head_shas"]), 
[HEAD, BEFORE])
+                    else:
+                        self.assertNotEqual(result.returncode, 0)
+                        self.assertEqual(result.stdout, "")
+
+    def test_consumers_use_the_validated_outputs_and_same_run_artifact(self):
+        resolver = (WORKFLOWS / "resolve-pr-event.yml").read_text()
+        self.assertIn("run-id: ${{ github.event.workflow_run.id }}", resolver)
+        self.assertIn("ref: ${{ github.event.repository.default_branch }}", 
resolver)
+        for name in ("lfs-warning.yml", "code-review-sync-result.yml"):
+            source = (WORKFLOWS / name).read_text()
+            self.assertNotIn("pull_request_target:", source)
+            self.assertIn("uses: ./.github/workflows/resolve-pr-event.yml", 
source)
+        source = (WORKFLOWS / "code-review-sync-result.yml").read_text()
+        self.assertIn("fromJSON(needs.resolve-event.outputs.head_shas)", 
source)
+
+
+class LargeFileCommentTest(unittest.TestCase):
+    def test_warning_remains_nonblocking_and_uses_resolved_pr_number(self):
+        with tempfile.TemporaryDirectory() as directory:
+            root = Path(directory)
+            gh = root / "gh"
+            gh.write_text('#!/bin/sh\nprintf "%s\\n" "$@" > 
"$RUNNER_TEMP/gh-args"\n')
+            gh.chmod(0o700)
+            env = {**os.environ, "PATH": directory + os.pathsep + 
os.environ["PATH"],
+                   "RUNNER_TEMP": directory, "PR_NUM": "42"}
+            script = step_script("lfs-warning.yml", '"Warn on oversized files 
in pull requests"')
+            for files in ("", "large.dat\t2097152\n"):
+                with self.subTest(files=files):
+                    (root / "oversized.tsv").write_text(files)
+                    result = subprocess.run(["bash", "-e", "-c", script], 
env=env,
+                                            capture_output=True, text=True)
+                    self.assertEqual(result.returncode, 0, result.stderr)
+                    self.assertEqual((root / "gh-args").exists(), bool(files))
+                    if files:
+                        self.assertIn("pr\ncomment\n42\n", (root / 
"gh-args").read_text())
+                        self.assertIn("large.dat (2 MB)", (root / 
"comment.md").read_text())
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/.github/scripts/test_review_checkout_workflow.py 
b/.github/scripts/test_review_checkout_workflow.py
index 41c38c1cf1a..59e814e42ce 100644
--- a/.github/scripts/test_review_checkout_workflow.py
+++ b/.github/scripts/test_review_checkout_workflow.py
@@ -116,7 +116,7 @@ class ReviewCheckoutWorkflowTest(unittest.TestCase):
                         self.pr_event(action=action, merged=False, 
same_repo=same_repo))
 
     def test_other_callers_keep_workflow_sha_pinning_and_sha_fallback(self):
-        for event in ("issue_comment", "workflow_dispatch"):
+        for event in ("issue_comment", "workflow_dispatch", "workflow_run"):
             for workflow_sha in ("b" * 40, ""):
                 with self.subTest(event=event, workflow_sha=workflow_sha):
                     self.assertEqual(workflow_sha or "c" * 40, self.ref({
@@ -131,13 +131,15 @@ class ReviewCheckoutWorkflowTest(unittest.TestCase):
 
     def 
test_closed_pr_still_reaches_aggregate_and_releases_shared_head_context(self):
         sync = (WORKFLOWS / "code-review-sync-result.yml").read_text()
-        triggers = sync.split("  pull_request_target:\n", 1)[1].split("  
issue_comment:", 1)[0]
+        relay = (WORKFLOWS / "pull-request-events.yml").read_text()
+        triggers = relay.split("  pull_request:\n", 
1)[1].split("\npermissions:", 1)[0]
         self.assertIn("closed", triggers)
-        caller = sync.split("\n  sync-status:\n", 1)[1].split("\n  
sync-previous-head-status:", 1)[0]
+        caller = sync.split("\n  sync-status:\n", 1)[1]
         self.assertIn("uses: 
./.github/workflows/code-review-aggregate-status.yml", caller)
-        condition = re.search(r"^    if: (.*)$", caller, re.MULTILINE).group(1)
+        self.assertIn("needs: resolve-event", caller)
+        self.assertIn("fromJSON(needs.resolve-event.outputs.head_shas)", 
caller)
+        self.assertIn("workflows: [Pull Request Events]", sync)
         github = self.pr_event()
-        self.assertTrue(expression_value(condition, github))
         self.assert_trusted_default_checkout(github)
         head = github["event"]["pull_request"]["head"]["sha"]
         # A merged PR must no longer hold another open PR at the same head 
pending.
diff --git a/.github/scripts/test_reviewer_assignment.py 
b/.github/scripts/test_reviewer_assignment.py
index b4b490f2e02..c2653602b06 100644
--- a/.github/scripts/test_reviewer_assignment.py
+++ b/.github/scripts/test_reviewer_assignment.py
@@ -16,7 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-"""Exercise label-event routing and recoverable GitHub mutations without a 
network."""
+"""Exercise comment-command routing and recoverable GitHub mutations without a 
network."""
 
 import copy
 import datetime as dt
@@ -30,7 +30,7 @@ import subprocess
 import sys
 import tempfile
 import unittest
-from unittest.mock import patch
+from unittest.mock import Mock, patch
 
 import reviewer_assignment as assignment
 import reviewer_assignment_model as model
@@ -51,6 +51,85 @@ def user(login):
     return {"login": login, "type": "User"}
 
 
+def comment_event(body="/assign-reviewers"):
+    return {"action": "created", "issue": {"number": 42, "pull_request": {}},
+            "comment": {"body": body, "user": {"id": 123, "login": "Writer"}},
+            "sender": {"id": 123, "login": "Writer"}}
+
+
+class RequestAuthorizationTest(unittest.TestCase):
+    def test_new_comment_normalizes_to_the_existing_assignment_request(self):
+        request = assignment.request_event(comment_event(), "issue_comment")
+        self.assertEqual(request["pull_request"]["number"], 42)
+        self.assertEqual(request["requester"], "Writer")
+        self.assertEqual(request["label"]["name"], "need-reviewers")
+
+    def test_rejects_edits_issues_arguments_and_spoofed_authors(self):
+        invalid = []
+        edited = comment_event()
+        edited["action"] = "edited"
+        invalid.append(edited)
+        issue = comment_event()
+        del issue["issue"]["pull_request"]
+        invalid.append(issue)
+        spoofed = comment_event()
+        spoofed["sender"]["id"] = 456
+        invalid.append(spoofed)
+        invalid.extend(comment_event(body) for body in (
+            "/assign-reviewers extra", "/assign-reviewers-other", "please 
/assign-reviewers"))
+        for event in invalid:
+            with self.subTest(event=event), self.assertRaises(ValueError):
+                assignment.request_event(event, "issue_comment")
+
+    def 
test_permission_is_read_from_github_instead_of_author_association(self):
+        for permission in ("read", "triage", "none", "write", "maintain", 
"admin"):
+            with self.subTest(permission=permission):
+                api = Mock()
+                api.request.return_value = {"permission": permission}
+                request = assignment.request_event(comment_event(), 
"issue_comment")
+                if permission in {"write", "maintain", "admin"}:
+                    assignment.authorize_request(api, request, "apache/doris")
+                else:
+                    with self.assertRaisesRegex(ValueError, "repository 
writers"):
+                        assignment.authorize_request(api, request, 
"apache/doris")
+                api.request.assert_called_once_with("GET", PREFIX + 
"/collaborators/Writer/permission")
+
+    def test_manual_preview_still_has_no_requester(self):
+        request = assignment.request_event({"inputs": {"pr_number": "42"}}, 
"workflow_dispatch")
+        self.assertNotIn("requester", request)
+        self.assertEqual(request["pull_request"]["number"], 42)
+
+    def test_unauthorized_cli_cannot_prepare_inputs_or_apply_an_artifact(self):
+        with tempfile.TemporaryDirectory() as directory:
+            event = Path(directory) / "event.json"
+            event.write_text(json.dumps(comment_event()))
+            for mode in ("prepare", "apply"):
+                with self.subTest(mode=mode), patch.dict(os.environ, {
+                    "GITHUB_EVENT_NAME": "issue_comment", "GITHUB_EVENT_PATH": 
str(event),
+                    "GITHUB_REPOSITORY": "apache/doris"}), patch.object(sys, 
"argv", [
+                        "reviewer_assignment.py", mode, "--workspace", 
directory]), \
+                        patch.object(assignment, "GitHub") as github, \
+                        patch.object(assignment, "prepare") as prepare, \
+                        patch.object(assignment, "apply") as apply:
+                    github.return_value.request.return_value = {"permission": 
"read"}
+                    with self.assertRaisesRegex(ValueError, "repository 
writers"):
+                        assignment.main()
+                    prepare.assert_not_called()
+                    apply.assert_not_called()
+
+    def test_manual_cli_cannot_apply_even_with_a_supplied_plan(self):
+        with tempfile.TemporaryDirectory() as directory:
+            event = Path(directory) / "event.json"
+            event.write_text(json.dumps({"inputs": {"pr_number": "42"}}))
+            with patch.dict(os.environ, {"GITHUB_EVENT_NAME": 
"workflow_dispatch",
+                 "GITHUB_EVENT_PATH": str(event)}), patch.object(sys, "argv", [
+                     "reviewer_assignment.py", "apply", "--workspace", 
directory]), \
+                    patch.object(assignment, "GitHub") as github:
+                with self.assertRaisesRegex(ValueError, "Manual runs"):
+                    assignment.main()
+                github.assert_not_called()
+
+
 def fixture_config():
     """Test policy is independent of the production reviewer lists."""
     config = {"schema_version": 1, "fallback_reviewer": "morningman", 
"disabled_reviewers": [],
@@ -323,9 +402,9 @@ class AssignmentTest(unittest.TestCase):
         (repository / 
"tools/reviewer-routing/reviewer-routing.json").write_text(json.dumps(self.config))
         assignment.write_json(self.workspace / "module-selection.json", 
{"modules": ["search"], "reason": "Index query changes"})
         event = self.root / "event.json"
-        assignment.write_json(event, self.event)
+        assignment.write_json(event, comment_event())
         env = {**os.environ, "GITHUB_EVENT_PATH": str(event), 
"GITHUB_REPOSITORY": "apache/doris",
-               "GITHUB_RUN_ID": "100", "GITHUB_EVENT_NAME": 
"pull_request_target", "PYTHONDONTWRITEBYTECODE": "1"}
+               "GITHUB_RUN_ID": "100", "GITHUB_EVENT_NAME": "issue_comment", 
"PYTHONDONTWRITEBYTECODE": "1"}
         command = [sys.executable, str(scripts / "reviewer_assignment.py"), 
"validate", "--workspace", str(self.workspace)]
         result = subprocess.run(command, env=env, capture_output=True, 
text=True)
         self.assertEqual(result.returncode, 0, result.stderr)
@@ -461,7 +540,7 @@ class AssignmentTest(unittest.TestCase):
             assignment.validate_selection({"reviewers": ["Bob"]}, "Author", 
allowed)
         self.assertTrue(self.apply(("Alice",))["assigned"])
 
-    def 
test_queued_labeled_event_runs_even_if_prior_run_removed_the_label(self):
+    def test_queued_command_runs_even_if_prior_run_removed_the_label(self):
         self.api.labels = {"bug", "reviewers-assigned"}
         self.assertFalse(self.prepare(run="102"))
         self.apply(("Alice",))
@@ -1431,8 +1510,9 @@ class WorkflowTest(unittest.TestCase):
         cls.runner = (assignment.ROOT / 
".github/workflows/code-review-runner.yml").read_text()
 
     def test_reapplication_is_an_event_not_a_one_time_flag(self):
-        self.assertIn("pull_request_target:\n    types: [labeled]", 
self.workflow)
-        self.assertIn("github.event.label.name == 'need-reviewers'", 
self.workflow)
+        self.assertIn("issue_comment:\n    types: [created]", self.workflow)
+        self.assertIn("github.event.comment.body == '/assign-reviewers'", 
self.workflow)
+        self.assertNotIn("pull_request_target", self.workflow)
         self.assertNotIn("contains(github.event.pull_request.labels", 
self.workflow)
         self.assertIn("queue: max", self.workflow)
         self.assertIn("cancel-in-progress: false", self.workflow)
@@ -1455,7 +1535,7 @@ class WorkflowTest(unittest.TestCase):
         self.assertIn("issues: write", assign)
         self.assertNotIn("secrets.OSS_", assign)
         self.assertIn("needs: select", assign)
-        self.assertIn("if: github.event_name == 'pull_request_target'", assign)
+        self.assertIn("if: github.event_name == 'issue_comment'", assign)
 
     def test_auth_reuses_reference_pool_and_optimistic_write_guard(self):
         
self.assertIn("auth_prefix='oss://doris-community-ci/codex/auth.json.'", 
self.workflow)
diff --git a/.github/workflows/code-review-sync-result.yml 
b/.github/workflows/code-review-sync-result.yml
index 547d60bb897..b911fbc5bb4 100644
--- a/.github/workflows/code-review-sync-result.yml
+++ b/.github/workflows/code-review-sync-result.yml
@@ -1,8 +1,9 @@
 name: Code Review
 
 on:
-  pull_request_target:
-    types: [opened, synchronize, reopened, ready_for_review, edited, closed]
+  workflow_run:
+    workflows: [Pull Request Events]
+    types: [completed]
   issue_comment:
     types: [created]
 
@@ -309,27 +310,27 @@ jobs:
       pull-requests: read
       statuses: write
 
-  sync-status:
-    name: Sync review status
-    if: github.event_name == 'pull_request_target'
-    uses: ./.github/workflows/code-review-aggregate-status.yml
-    with:
-      head_sha: ${{ github.event.pull_request.head.sha }}
+  resolve-event:
+    if: >-
+      github.event_name == 'workflow_run' &&
+      github.event.workflow_run.conclusion == 'success' &&
+      github.event.workflow_run.event == 'pull_request'
+    uses: ./.github/workflows/resolve-pr-event.yml
     permissions:
+      actions: read
       contents: read
       pull-requests: read
-      statuses: write
 
-  sync-previous-head-status:
-    name: Sync previous review status
-    if: >
-      github.event_name == 'pull_request_target' &&
-      github.event.action == 'synchronize' &&
-      github.event.before != '' &&
-      github.event.before != github.event.pull_request.head.sha
+  sync-status:
+    name: Sync review status
+    needs: resolve-event
+    strategy:
+      fail-fast: false
+      matrix:
+        head_sha: ${{ fromJSON(needs.resolve-event.outputs.head_shas) }}
     uses: ./.github/workflows/code-review-aggregate-status.yml
     with:
-      head_sha: ${{ github.event.before }}
+      head_sha: ${{ matrix.head_sha }}
     permissions:
       contents: read
       pull-requests: read
diff --git a/.github/workflows/lfs-warning.yml 
b/.github/workflows/lfs-warning.yml
index 54ba7e12f99..95164c07a7e 100644
--- a/.github/workflows/lfs-warning.yml
+++ b/.github/workflows/lfs-warning.yml
@@ -19,7 +19,9 @@
 name: 'Check Large File'
 
 on:
-  pull_request_target:
+  workflow_run:
+    workflows: [Pull Request Events]
+    types: [completed]
 
 permissions:
   contents: read
@@ -27,7 +29,17 @@ permissions:
   issues: write
 
 jobs:
+  resolve-event:
+    if: github.event.workflow_run.conclusion == 'success' && 
github.event.workflow_run.event == 'pull_request'
+    uses: ./.github/workflows/resolve-pr-event.yml
+    permissions:
+      actions: read
+      contents: read
+      pull-requests: read
+
   large-file-checker:
+    needs: resolve-event
+    if: needs.resolve-event.outputs.check_large_files == 'true'
     name: "Check large file"
     runs-on: ubuntu-latest
     steps:
@@ -38,9 +50,9 @@ jobs:
       - name: "Collect added files"
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          PR_NUM: ${{ needs.resolve-event.outputs.pr_number }}
         run: |
           set -euo pipefail
-          PR_NUM="$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
           gh api "repos/$GITHUB_REPOSITORY/pulls/${PR_NUM}/files?per_page=100" 
--paginate \
             --jq '.[] | select(.status == "added") | [.filename, .raw_url] | 
@tsv' > "$RUNNER_TEMP/files.tsv"
           echo "Added files: $(wc -l < "$RUNNER_TEMP/files.tsv")"
@@ -62,12 +74,12 @@ jobs:
       - name: "Warn on oversized files in pull requests"
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          PR_NUM: ${{ needs.resolve-event.outputs.pr_number }}
         run: |
           set -euo pipefail
           if [[ ! -s "$RUNNER_TEMP/oversized.tsv" ]]; then
             exit 0
           fi
-          PR_NUM="$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
           {
             echo "⚠️ **Large files detected** (size limit: 1MB):"
             echo
diff --git a/.github/workflows/pull-request-events.yml 
b/.github/workflows/pull-request-events.yml
new file mode 100644
index 00000000000..7f931a28ea1
--- /dev/null
+++ b/.github/workflows/pull-request-events.yml
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+name: Pull Request Events
+
+on:
+  pull_request:
+    types: [opened, synchronize, reopened, ready_for_review, edited, closed]
+
+permissions: {}
+
+jobs:
+  relay:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    steps:
+      # This workflow can come from a fork. It has no checkout, secrets or 
writes.
+      - name: Record PR event hints
+        run: |
+          python3 - <<'PY'
+          import json
+          import os
+          from pathlib import Path
+
+          event = json.loads(Path(os.environ['GITHUB_EVENT_PATH']).read_text())
+          data = {
+              'number': event['number'],
+              'action': event['action'],
+              'head_sha': event['pull_request']['head']['sha'],
+              'before': event.get('before', ''),
+          }
+          Path(os.environ['RUNNER_TEMP'], 
'pr-event.json').write_text(json.dumps(data))
+          PY
+
+      - uses: actions/upload-artifact@v4
+        with:
+          name: pull-request-event
+          path: ${{ runner.temp }}/pr-event.json
+          if-no-files-found: error
+          retention-days: 7
diff --git a/.github/workflows/resolve-pr-event.yml 
b/.github/workflows/resolve-pr-event.yml
new file mode 100644
index 00000000000..1cfad800028
--- /dev/null
+++ b/.github/workflows/resolve-pr-event.yml
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+name: Resolve Relayed PR Event
+
+on:
+  workflow_call:
+    outputs:
+      pr_number:
+        value: ${{ jobs.resolve.outputs.pr_number }}
+      head_shas:
+        value: ${{ jobs.resolve.outputs.head_shas }}
+      check_large_files:
+        value: ${{ jobs.resolve.outputs.check_large_files }}
+
+permissions:
+  actions: read
+  contents: read
+  pull-requests: read
+
+jobs:
+  resolve:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    outputs:
+      pr_number: ${{ steps.event.outputs.pr_number }}
+      head_shas: ${{ steps.event.outputs.head_shas }}
+      check_large_files: ${{ steps.event.outputs.check_large_files }}
+    steps:
+      - name: Checkout trusted event resolver
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.repository.default_branch }}
+          persist-credentials: false
+          sparse-checkout: |
+            .github/scripts/pr_workflow_event.py
+            .github/scripts/review_github_api.py
+          sparse-checkout-cone-mode: false
+
+      - name: Download event hints from the triggering run
+        uses: actions/download-artifact@v4
+        with:
+          name: pull-request-event
+          path: ${{ runner.temp }}/pull-request-event
+          run-id: ${{ github.event.workflow_run.id }}
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Resolve authoritative PR state
+        id: event
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          REVIEW_GITHUB_DIAGNOSTICS_DIR: ${{ runner.temp 
}}/review-github-diagnostics
+        run: |
+          python3 .github/scripts/pr_workflow_event.py \
+            --relay-file "$RUNNER_TEMP/pull-request-event/pr-event.json" >> 
"$GITHUB_OUTPUT"
+
+      - name: Preserve GitHub API failure diagnostics
+        if: always()
+        continue-on-error: true
+        uses: actions/upload-artifact@v4
+        with:
+          name: github-api-errors-resolve-${{ github.run_id }}-${{ 
github.run_attempt }}
+          path: ${{ runner.temp }}/review-github-diagnostics/*.json
+          if-no-files-found: ignore
diff --git a/.github/workflows/reviewer-assignment-check.yml 
b/.github/workflows/reviewer-assignment-check.yml
index e6da7f8785c..daa07762191 100644
--- a/.github/workflows/reviewer-assignment-check.yml
+++ b/.github/workflows/reviewer-assignment-check.yml
@@ -8,6 +8,15 @@ on:
       - '.github/scripts/test_reviewer_assignment*.py'
       - '.github/scripts/review_github_api.py'
       - '.github/scripts/test_review_github_api.py'
+      - '.github/scripts/pr_workflow_event.py'
+      - '.github/scripts/test_pr_workflow_event.py'
+      - '.github/scripts/test_review_checkout_workflow.py'
+      - '.github/scripts/resolve_code_review_status.py'
+      - '.github/scripts/test_resolve_code_review_status.py'
+      - '.github/workflows/pull-request-events.yml'
+      - '.github/workflows/resolve-pr-event.yml'
+      - '.github/workflows/lfs-warning.yml'
+      - '.github/workflows/code-review-sync-result.yml'
       - '.github/workflows/reviewer-assignment*.yml'
       - 'tools/reviewer-routing/**'
   push:
@@ -17,6 +26,15 @@ on:
       - '.github/scripts/test_reviewer_assignment*.py'
       - '.github/scripts/review_github_api.py'
       - '.github/scripts/test_review_github_api.py'
+      - '.github/scripts/pr_workflow_event.py'
+      - '.github/scripts/test_pr_workflow_event.py'
+      - '.github/scripts/test_review_checkout_workflow.py'
+      - '.github/scripts/resolve_code_review_status.py'
+      - '.github/scripts/test_resolve_code_review_status.py'
+      - '.github/workflows/pull-request-events.yml'
+      - '.github/workflows/resolve-pr-event.yml'
+      - '.github/workflows/lfs-warning.yml'
+      - '.github/workflows/code-review-sync-result.yml'
       - '.github/workflows/reviewer-assignment*.yml'
       - 'tools/reviewer-routing/**'
   workflow_dispatch:
@@ -43,3 +61,9 @@ jobs:
             -s .github/scripts -p 'test_reviewer_assignment*.py'
           RUN_GH_HTTP_TESTS=1 PYTHONDONTWRITEBYTECODE=1 python3 -m unittest 
discover \
             -s .github/scripts -p test_review_github_api.py
+          PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \
+            -s .github/scripts -p test_pr_workflow_event.py
+          PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \
+            -s .github/scripts -p test_review_checkout_workflow.py
+          PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \
+            -s .github/scripts -p test_resolve_code_review_status.py
diff --git a/.github/workflows/reviewer-assignment.yml 
b/.github/workflows/reviewer-assignment.yml
index 8a5670869ec..8667162fd3a 100644
--- a/.github/workflows/reviewer-assignment.yml
+++ b/.github/workflows/reviewer-assignment.yml
@@ -1,8 +1,8 @@
 name: Assign Reviewer Candidates
 
 on:
-  pull_request_target:
-    types: [labeled]
+  issue_comment:
+    types: [created]
   workflow_dispatch:
     inputs:
       pr_number:
@@ -14,8 +14,8 @@ permissions:
   contents: read
   pull-requests: read
 
-# Keep every pending label event and serialize reviewer-assignment runs.
-# A new labeled event has a new run ID, even when reviewers-assigned already 
exists.
+# Keep every pending command and serialize reviewer-assignment runs.
+# A new comment has a new run ID, even when reviewers-assigned already exists.
 concurrency:
   group: reviewer-assignment-${{ github.repository }}
   cancel-in-progress: false
@@ -25,14 +25,14 @@ jobs:
   select:
     if: >-
       github.event_name == 'workflow_dispatch' ||
-      (github.event.label.name == 'need-reviewers' && 
github.event.pull_request.state == 'open')
+      (github.event.issue.pull_request != null && github.event.comment.body == 
'/assign-reviewers')
     runs-on: ubuntu-24.04
     timeout-minutes: 55
     permissions:
       contents: read
       pull-requests: read
     steps:
-      # pull_request_target defaults to trusted base code. Never check out the 
PR head.
+      # Comment events use trusted default-branch code. Never check out the PR 
head.
       - name: Checkout trusted routing tools
         timeout-minutes: 2
         uses: actions/checkout@v4
@@ -364,7 +364,7 @@ jobs:
 
   assign:
     needs: select
-    if: github.event_name == 'pull_request_target'
+    if: github.event_name == 'issue_comment'
     runs-on: ubuntu-24.04
     timeout-minutes: 10
     permissions:
diff --git a/tools/reviewer-routing/README.md b/tools/reviewer-routing/README.md
index bd08d65f6ec..ce3e73a7236 100644
--- a/tools/reviewer-routing/README.md
+++ b/tools/reviewer-routing/README.md
@@ -1,9 +1,11 @@
 # Reviewer routing
 
 The GitHub workflow reads this directory to choose at most two reviewer
-candidates when an open PR receives `need-reviewers`. It adds assignees, posts 
a
-mention and replaces the label with `reviewers-assigned`. Reapplying the 
request
-label selects again; retrying the same run preserves its saved decision.
+candidates when a repository writer (write, maintain or admin permission) posts
+the exact comment `/assign-reviewers` on an open PR. It adds assignees, posts a
+mention and adds `reviewers-assigned`, removing a legacy `need-reviewers` label
+if present. A new command selects again; retrying the same run preserves its
+saved decision. Editing a comment or adding a label does not request 
assignment.
 
 ## Maintain one file
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to