Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
/.github/workflows/scripts/test_ai_review.py @wangxiyuan
/.github/agent-review/L1/ @wangxiyuan
/.github/agent-review/L2/ci/ @zhangxinyuehfad
/.github/agent-review/L2/doc-quality/ @liqian79
/.github/agent-review/L2/release-note/ @wangxiyuan
/.github/agent-review/L2/speculative-decoding/ @drslark @slippersss

Expand All @@ -59,7 +60,7 @@
/docs/source/user_guide/feature_guide/quantization.md @kunpengW-code @lcfenglinwan
/.readthedocs.yaml @liqian79 @MrZ20
/README* @liqian79
/mkdocs.yml @MrZ20
/mkdocs.yml @MrZ20 @liqian79

# examples
/examples/ @MrZ20
Expand Down
20 changes: 20 additions & 0 deletions .github/agent-review/L2/doc-quality/checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# L2 Documentation Quality Domain Checklist

- `L2-doc-quality#upstream-rule`: Review changed documentation against the
pinned `ascend-ci/doc-quality` standards in the adjacent `upstream/` directory.
Start with `upstream/common/h2_registry.json`. Read each applicable dimension's
`SKILL.md` and follow its registered rule files, scope and exemptions. In an
English finding, identify the upstream topic and clause and explain the
consequence at the changed line. Map upstream F to `MUST-FIX`, S to
`SHOULD-FIX`, and N or H to `NIT`.

For Chinese `.po` files, review changed entries that have a nonempty translation
(`msgstr`). Read each multiline string in full and compare the translation with
the English source (`msgid`). Check that it preserves the meaning, placeholders
and markup. Skip the catalog header and obsolete entries.

If the author says they withdrew a documentation change, check the current PR
diff against the original finding. You can verify the withdrawal without the
upstream rules. If the change was reverted and the issue is gone, mark the
original finding `resolved` and say what was withdrawn. If the text moved and
the issue persists, keep the finding `open` and cite its new location.
8 changes: 8 additions & 0 deletions .github/agent-review/domains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
#
# Collect every domain with a matching glob. A file can match multiple domains.
domains:
- name: doc-quality
description: documentation accuracy, completeness, readability and Chinese translations
paths:
- "README.md"
- "README.zh.md"
- "docs/*.md"
Comment thread
MrZ20 marked this conversation as resolved.
Resolved
- "vllm_ascend/ops/triton/docs/*.md"
Comment thread
MrZ20 marked this conversation as resolved.
Resolved
- "docs/source/locale/zh_CN/LC_MESSAGES/*.po"
- name: ci
description: CI workflows, bot jobs, runner images, test selection
paths:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/ai_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ jobs:
git config --global --add safe.directory "$GITHUB_WORKSPACE"
python3 .github/workflows/scripts/ai_review.py prepare

- name: Fetch doc-quality rules
if: steps.prepare.outputs.doc_quality == 'true'
env:
DOC_QUALITY_USERNAME: ${{ vars.DOC_QUALITY_USERNAME }}
DOC_QUALITY_TOKEN: ${{ secrets.DOC_QUALITY_TOKEN }}
run: |
revision=9b97d74bb8b35746de34f752973ea834478f532f
repo=/tmp/doc-quality
trap 'rm -rf "$repo"' EXIT
git init -q --bare "$repo"
basic_auth=$(printf '%s:%s' "$DOC_QUALITY_USERNAME" "$DOC_QUALITY_TOKEN" | base64 -w0)
GITCODE_AUTH="Authorization: Basic $basic_auth" git -C "$repo" --config-env=http.extraHeader=GITCODE_AUTH \
fetch --depth=1 https://gitcode.com/ascend-ci/doc-quality.git "$revision"
destination="$GITHUB_WORKSPACE/.github/agent-review/L2/doc-quality/upstream"
mkdir -p "$destination"
git -C "$repo" --work-tree="$destination" checkout 'FETCH_HEAD:skills/01.评估标准' -- .

- uses: actions/checkout@v7
if: steps.prepare.outputs.review == 'true'
with:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/scripts/ai_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,15 @@ def prepare(self, event_name: str, event: dict, run_id: str) -> dict | None:
if diff
else []
)
registry = self.workspace / ".github/agent-review/domains.yaml"

return {
"pr": self.pr,
"comment_id": self.summary_comment_id,
"state": asdict(self.state),
"merge_base": merge_base,
"files": files,
"domains": [domain["name"] for domain in resolve_domains(registry.read_text(), files)],
"diff": diff[:MAX_DIFF_CHARS],
"truncated": len(diff) > MAX_DIFF_CHARS,
"reply": event["comment"]["body"] if event_name == "issue_comment" else "",
Expand Down Expand Up @@ -679,14 +681,13 @@ def build_prompt(workspace: Path, request: dict) -> str:
continue
ids = re.findall(r"^-\s+`([\w-]+#\w[\w-]*)`", path.read_text(), re.M)
mapping.append(f"- {path.relative_to(workspace)}: {', '.join(ids)}")
domains = resolve_domains((kb / "domains.yaml").read_text(), request["files"])

return render_template(
(kb / "prompt_template.md").read_text(),
{
"INSTRUCTIONS": (kb / "instructions.md").read_text(),
"KB_MAP": "\n".join(mapping),
"DOMAINS": "\n".join(d["name"] for d in domains) or "L1 only",
"DOMAINS": "\n".join(request["domains"]) or "L1 only",
"HEAD_SHA": request["state"]["head"],
"BASE_SHA": request["merge_base"],
"FILES": json.dumps(request["files"]),
Expand Down Expand Up @@ -823,6 +824,8 @@ def main() -> int:

with open(os.environ["GITHUB_OUTPUT"], "a") as output:
output.write(f"review=true\nhead={request['state']['head']}\nbase={request['merge_base']}\n")
if "doc-quality" in request["domains"]:
output.write("doc_quality=true\n")

return 0

Expand Down
62 changes: 60 additions & 2 deletions .github/workflows/scripts/test_ai_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,30 @@ def commit(path, content):
git("config", "user.name", "Local Test")
git("config", "user.email", "test@example.invalid")
git("config", "commit.gpgsign", "false")
common = commit("README", "base\n")
common = commit("README.md", "Run the installer.\n")
git("checkout", "-qb", "feature")
commit("feature.py", "first_change = 1\n")
head = commit("second.py", "second_change = 2\n")
next_head = commit("third.py", "followup_change = 3\n")
docs_head = commit("README.md", "Run the installer with --unknown-flag.\n")
git("revert", "--no-edit", docs_head)
withdrawn_head = git("rev-parse", "HEAD")
git("checkout", "-q", "main")
base = commit("base_only.py", "base_only_change = 3\n")
git("remote", "add", "origin", str(repo))

kb = repo / ".github/agent-review"
shutil.copytree(Path(__file__).resolve().parents[2] / "agent-review", kb)
(kb / "allowlist.txt").write_text("maintainer # pilot reviewer\npilot-triager\n")
return SimpleNamespace(repo=repo, common=common, base=base, head=head, next_head=next_head)
return SimpleNamespace(
repo=repo,
common=common,
base=base,
head=head,
next_head=next_head,
docs_head=docs_head,
withdrawn_head=withdrawn_head,
)


class PullRequest:
Expand Down Expand Up @@ -251,6 +262,52 @@ def test_request_rechecks_live_pr_after_queue(pr, phase, agent, change, notice):
# --- Review, pass and manual follow-up ---


@pytest.mark.parametrize(
"paths,expected",
[
(["vllm_ascend/worker/model_runner.py"], {"model-execution"}),
(["README.md"], {"doc-quality"}),
(["README.zh.md"], {"doc-quality"}),
(["docs/source/getting_started.md", "vllm_ascend/worker/model_runner.py"], {"doc-quality", "model-execution"}),
(["vllm_ascend/ops/triton/docs/kernels.md"], {"doc-quality"}),
(["docs/source/locale/zh_CN/LC_MESSAGES/user_guide/getting_started.po"], {"doc-quality"}),
(["docs/source/locale/de/LC_MESSAGES/guide.po", "examples/README.md"], set()),
([".github/agent-review/instructions.md"], {"ci"}),
],
)
def test_doc_quality_path_routing(history, paths, expected):
registry = (history.repo / ".github/agent-review/domains.yaml").read_text()
assert {domain["name"] for domain in ai.resolve_domains(registry, paths)} == expected


def test_doc_finding_can_be_resolved_after_the_author_withdraws_the_change(pr, phase, agent, history):
pr.pull["head"]["sha"] = history.docs_head
assert phase("prepare", pr.command())["doc_quality"] == "true"
doc = finding() | dict(path="README.md", rule="L2-doc-quality#upstream-rule", body="Remove --unknown-flag.")
agent.return_value = result(findings=[doc])
phase("review")
assert {"README.md", "feature.py"} <= set(agent.call_args.args[1]["files"])
[first] = pr.state()["findings"]
assert first["status"] == "open" and "ai-review-passed" not in pr.labels

pr.pull["head"]["sha"] = history.withdrawn_head
reply = f"/ai-review {first['id']}: I reverted the README edit and kept the code changes."
prepared = phase("prepare", pr.command(reply))
assert prepared == {"review": "true", "head": history.withdrawn_head, "base": history.common}
for snapshot in ("base", "head"):
assert ai.git(history.repo, "show", f"{prepared[snapshot]}:README.md") == "Run the installer.\n"
evidence = "README.md matches the base version. The command no longer mentions --unknown-flag."
agent.return_value = result(updates=[dict(id=first["id"], status="resolved", evidence=evidence)])
phase("review")
request = agent.call_args.args[1]
assert "README.md" not in request["files"] and "doc-quality" not in request["domains"]
assert "first_change" in request["diff"] and "--unknown-flag" not in request["diff"]
assert request["reply"] == reply and request["state"]["findings"] == [first]
[reviewed] = pr.state()["findings"]
assert (reviewed["id"], reviewed["status"], reviewed["evidence"]) == (first["id"], "resolved", evidence)
assert len(pr.inline) == 1 and pr.statuses[-1] == (history.withdrawn_head, "success")


def test_label_then_manual_review_of_all_changes(pr, phase, agent, history):
start = pr.label_event(actor="pilot-triager")
assert phase("authorize", start) == {"authorized": "true"}
Expand Down Expand Up @@ -589,6 +646,7 @@ def agent_request(monkeypatch):
"state": {"head": "abc123", "findings": [{"id": "F003"}]},
"merge_base": "def456",
"files": ["example.py"],
"domains": [],
"diff": "+print('{{REPLY}}')",
"truncated": False,
"reply": "/ai-review Recheck F003 and keep {{HEAD_SHA}} literal.",
Expand Down
6 changes: 6 additions & 0 deletions docs/source/community/ai-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ Each round is one agent invocation. The orchestrator assembles the prompt determ

The agent reads the referenced checklist files itself from the checked-out repository and cites only rules it has actually read (every finding has a file path, a rule ID and a severity, with a line number for inline findings).

### Documentation changes

When the current PR diff changes either root README (`README.md` or `README.zh.md`), Markdown in `docs/` or `vllm_ascend/ops/triton/docs/`, or Chinese translations in `docs/source/locale/zh_CN/LC_MESSAGES/`, the agent reviews the documentation against internal standards and reports documentation findings alongside code findings in the same round.

If you withdraw a documentation change, explain why in your next `/ai-review` comment and reference the finding ID. The agent can mark that finding `resolved` after verifying the affected content was withdrawn. If you moved the content and the issue persists, the finding stays open.

### Multi-round interaction and termination

The bot updates one PR summary comment. Its hidden `ai-review-state` JSON block records the reviewed commit, published rounds and finding history. A round counts when the bot publishes its result or a notice that the code changed during review. If a run fails before publication, a rerun starts a fresh review from the last published summary.
Expand Down
Loading