Skip to content

[CI] Add shadow PR self-review gate - #7003

Merged
zufayu merged 18 commits into
mainfrom
codex/pr-self-review-shadow
Oct 29, 2026
Merged

zufayu merged 18 commits into
mainfrom
codex/pr-self-review-shadow

Conversation

@zufayu

@zufayu zufayu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a zero-token, shadow-mode PR Self-Review gate before human review. It asks the author to explain the current revision, reports active Copilot findings and code/op-test hygiene, and aggregates Black, Ruff, Repository Dependency, and Aiter Test Gate status.

The existing aiter-review-bot.yml, .claude/skills/review-pr/, box308, and the @aiter-bot review flow are untouched.

Motivation

PR authors need to demonstrate that they understand the current revision, have addressed automated review findings, have removed obvious artifacts or redundant op tests, and have baseline CI ready before consuming maintainer review time.

Changes

  • Adds the shadow-mode PR Self-Review evaluator, sticky report and commit status.
  • Adds a read-only review-activity signal workflow so delayed Copilot replies refresh safely.
  • Adds the active GitHub PR template with the full review context plus required self-review answers.
  • Documents the readiness process and includes deterministic workflow selftests.

Performance (if applicable)

N/A — this PR changes GitHub metadata automation and contributor documentation only; it does not change runtime or kernel behavior.

Testing

  • Deterministic selftests added and updated (11 scenarios)
  • Python, Black, Ruff, Vulture and Actionlint validation run
  • Performance benchmarks run — not applicable; no runtime surface changed
  • Tested on MI250X — not applicable; no GPU code changed
  • Tested on MI300X — not applicable; no GPU code changed

Documentation

  • Contributor guide updated
  • GitHub pull request template added and restored with complete review context
  • Docstrings, user guide and performance guide — not applicable to this CI-only change

Dependencies

  • No new third-party dependencies added

Breaking Changes

None. The gate defaults to advisory shadow mode and does not alter existing review-bot or runtime behavior.

PR Self-Review

Reviewed revision

4fa3b4a

Behavior and intent

This adds an independent GitHub-hosted metadata gate that reports whether a PR is prepared for human review. Shadow mode always leaves its commit status successful while exposing the author-answer, Copilot, hygiene, and required-CI blockers that would fail in enforce mode. The goal is to measure real author behavior, including generic or AI-generated answers, before making the gate required.

Validation and unverified scope

Ran the committed pr_self_review_selftest.py suite: 11 deterministic tests cover answer boundaries, Copilot replies, CI failure/unavailability, Draft readiness, untrusted path rendering, 3,000-file pagination, bounded output, sticky-comment ownership and idempotent status writes. Python byte-compilation, Black 26.3.0, full Ruff 0.16.0, Vulture, Actionlint 1.7.12 and git diff --check pass. Five real fork PRs confirmed that workflow_run.pull_requests is empty; the new owner/branch/SHA resolver returned the exact PR for #5887, #7005 and #7014. Read-only evaluation also succeeded on PR #7003 and 12 additional open PRs. Actual bot-authored comments, workflow-run refreshes and status writes remain unverified until the trusted workflow lands on main, so rollout stays in shadow mode.

PR-specific question

The privileged workflow checks out only the trusted default branch and never checks out or executes the PR head. Untrusted PR title, body, filenames, patches and review comments are consumed only as GitHub API data by standard-library Python; rendered filenames use bounded dynamic code spans. Permissions are limited to Checks read, repository contents read, PR metadata read, issue comments write and commit statuses write. A missing Checks response degrades to unavailable and keeps the PR not ready instead of terminating the report. Fork workflow runs resolve the open main-targeting PR from the payload's head owner, branch and SHA without executing fork code.

Changed op tests

None. This PR does not add or modify any op_tests/ file.

Test plan

Rollout

  1. Keep AITER_PR_SELF_REVIEW_MODE unset, which defaults to shadow.
  2. Merge and exercise the workflow on real PRs.
  3. Audit false positives, author behavior, and attempts to use generic AI prose.
  4. Switch the repository variable to enforce only after calibration.

@ROCm ROCm deleted a comment from github-actions Bot Oct 27, 2026
@zufayu
zufayu marked this pull request as ready for review October 27, 2026 09:10
@zufayu
zufayu requested a review from a team October 27, 2026 09:10
@github-actions github-actions Bot added the CI label Oct 27, 2026
Drop the redundant static-check workflow and the fixture-only interface. Simplify the readiness evaluator, fix section boundaries and self-matching debug detection, and document the actual Copilot reply policy.

Signed-off-by: zufayu <[email protected]>
Bound sticky-comment output, cover all PR file pages, treat draft PRs as not ready, and avoid duplicate comment and status writes. Restrict review events to main-targeting PRs and document the draft requirement.

Signed-off-by: zufayu <[email protected]>
@zufayu

zufayu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 702c866fcf4e � mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS � current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

This adds an independent GitHub-hosted metadata gate that reports whether a PR is prepared for human review. Shadow mode always leaves its commit status successful while exposing the author-answer, Copilot, hygiene, and required-CI blockers that would fail in enforce mode. The goal is to measure real author behavior, including generic or AI-generated answers, before making the gate required.

Validation and unverified scope

Ran the committed `pr_self_review_selftest.py` suite: 10 deterministic tests cover answer boundaries, Copilot replies, CI failure/unavailability, Draft readiness, untrusted path rendering, 3,000-file pagination, bounded output, sticky-comment ownership and idempotent status writes. Python byte-compilation, Black 26.3.0, full Ruff 0.16.0, Vulture, Actionlint 1.7.12 and `git diff --check` pass. Five real fork PRs confirmed that `workflow_run.pull_requests` is empty; the new owner/branch/SHA resolver returned the exact PR for #5887, #7005 and #7014. Read-only evaluation also succeeded on PR #7003 and 12 additional open PRs. Actual bot-authored comments, workflow-run refreshes and status writes remain unverified until the trusted workflow lands on `main`, so rollout stays in shadow mode.

PR-specific question

The privileged workflow checks out only the trusted default branch and never checks out or executes the PR head. Untrusted PR title, body, filenames, patches and review comments are consumed only as GitHub API data by standard-library Python; rendered filenames use bounded dynamic code spans. Permissions are limited to Checks read, repository contents read, PR metadata read, issue comments write and commit statuses write. A missing Checks response degrades to `unavailable` and keeps the PR not ready instead of terminating the report. Fork workflow runs resolve the open main-targeting PR from the payload's head owner, branch and SHA without executing fork code.

Changed op tests

None. This PR does not add or modify any `op_tests/` file.

PR state

  • PASS � pull request is marked ready for review

Copilot findings

  • PASS � no active Copilot finding lacks a substantive author reply
  • ADVISORY � Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS � no committed artifact or conflict marker detected

Required CI

  • WAIT � Black: pending
  • PASS � Ruff: passed
  • PASS � Repository dependency: passed
  • WAIT � Aiter Test Gate: missing
  • Required CI is incomplete; this PR is not ready for human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu
zufayu requested review from junhaha666 and valarLip October 27, 2026 10:38
@zufayu

zufayu commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@aiter-bot review

@zufayu
zufayu requested a review from gyohuangxin October 27, 2026 10:41
junhaha666
junhaha666 previously approved these changes Oct 27, 2026
@aiter-bot

Copy link
Copy Markdown

ROCm/aiter PR #7003 — [CI] Add shadow PR self-review gate

Adds a shadow-mode "PR Self-Review" GitHub Actions gate that reads PR metadata over the GitHub API and reports, in one sticky bot comment plus an always-success commit status, whether the author's self-review answers, Copilot findings, code/op-test hygiene and the four required CI checks are ready for human review.

Review (advisory): 🔴 HIGH RISK
Validation (deterministic): N/A — no runtime surface changed
Perf (advisory): N/A — no runtime surface changed

🔴 [verified] .github/workflows/pr-self-review.yml:21-25 grants contents: read, issues: write, pull-requests: read and statuses: write but no checks scope, while .github/scripts/pr_self_review.py:418 reads commits/{head_sha}/check-runs — an endpoint GitHub's app-permission table gates on Checks: read, and once a permissions: block exists every unspecified scope is none — so on the first PR event after this merges, that one call returns 403, the APIError propagates uncaught through evaluate() (pr_self_review.py:439) and main(), and the step dies with a traceback before any sticky comment or status is written, leaving the gate dead on arrival. Author must add checks: read to the permissions block and wrap inspect_ci so one failing axis degrades instead of killing the whole report.
⚠️ [verified] .github/scripts/pr_self_review.py:282 renders changed op_tests/ paths into the sticky comment with no fencing at all and :304-320 wrap paths in single backticks that a backtick inside a filename escapes, while append_findings (:487) appends every finding raw — so a fork PR adding a file named op_tests/[proof](https://evil.example) makes a github-actions[bot] comment carry attacker-chosen markdown links and images (GitHub sanitizes HTML, so this is spoofed content in an official-looking comment, not XSS). Author must fence or escape every path interpolated into the rendered report, the way fenced_text (:476) already does for answers.
⚠️ [inferred] For fork PRs the workflow_run event's pull_requests array is empty — GitHub documents that exact shape for check_run/check_suite, and its own recipe for getting the PR number under workflow_run is artifact download rather than the payload — so the if: guard at .github/workflows/pr-self-review.yml:35-38 skips the CI-completion refresh and a fork PR's report stays at "Required CI is incomplete / not ready" (in enforce mode its status would sit pending indefinitely) until the author pushes again or someone dispatches manually. Author must confirm the refresh path for fork PRs, e.g. by resolving the PR from the run's head SHA, or state that fork PRs refresh only on push and review events.
📝 [verified] The PR ships a 704-line .github/scripts/pr_self_review.py with no committed test — the 36-assertion scenario matrix, the 3,000-file stress run and the 13-PR live evaluation named in the description exist only in the PR body, so no reviewer can re-run the calibration evidence the rollout depends on, while the repo already selftests its CI tooling this way (review-bot-selftest.yml). Author must commit the scenario matrix as a runnable selftest so the shadow-mode calibration data is reproducible.
📝 [verified] The CONTRIBUTE.md rewrite deletes the old PR template's structured "Performance (if applicable)" before/after table and the "Tested on MI250X/MI300X" checklist, and neither the new .github/pull_request_template.md nor the replacement text carries any structured perf or hardware section — for a repo whose kernel reviews hinge on before/after numbers, perf evidence now rests entirely on free-form "Validation" answers. Reviewer should ask whether perf numbers and hardware coverage will still be captured consistently, or whether the template should keep a performance section.

Grant check-run read access and degrade CI API failures, safely render untrusted paths, refresh fork PRs by head identity, add deterministic regression coverage, and restore structured performance evidence in the PR template.

Signed-off-by: zufayu <[email protected]>
Run the selftest explicitly with Python and remove the non-executable shebang flagged by the repository Ruff check.

Signed-off-by: zufayu <[email protected]>
yzhou103
yzhou103 previously approved these changes Oct 28, 2026
@zufayu
zufayu merged commit 48ea6c8 into main Oct 29, 2026
63 checks passed
@zufayu
zufayu deleted the codex/pr-self-review-shadow branch October 29, 2026 09:47
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
* [CI] Add shadow PR self-review gate

* [CI] Fix PR self-review lint findings

* [CI] Read PR checks from head commit

* [CI] Lead self-review comment with readiness

* [CI] Split self-review prompt from readiness report

* [CI] Refresh self-review on review activity

* [CI] Hide shadow audit metrics from PR comments

* [CI] Show accepted self-review answers in report

* [CI] Remove PR self-review unit test fixture

* [CI] Replace self-review unit tests with static checks

* [CI] Avoid blocking on unavailable Copilot review

* [CI] Remove self-review rollout leftovers

Drop the redundant static-check workflow and the fixture-only interface. Simplify the readiness evaluator, fix section boundaries and self-matching debug detection, and document the actual Copilot reply policy.

Signed-off-by: zufayu <[email protected]>

* [CI] Harden self-review gate edge cases

Bound sticky-comment output, cover all PR file pages, treat draft PRs as not ready, and avoid duplicate comment and status writes. Restrict review events to main-targeting PRs and document the draft requirement.

Signed-off-by: zufayu <[email protected]>

* [CI] Address self-review security findings

Grant check-run read access and degrade CI API failures, safely render untrusted paths, refresh fork PRs by head identity, add deterministic regression coverage, and restore structured performance evidence in the PR template.

Signed-off-by: zufayu <[email protected]>

* [CI] Fix self-review selftest executable lint

Run the selftest explicitly with Python and remove the non-executable shebang flagged by the repository Ruff check.

Signed-off-by: zufayu <[email protected]>

* [CI] Isolate self-review refresh signals

* [CI] Restore PR review context

* [CI] Drop template regression assertion

---------

Signed-off-by: zufayu <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
* [CI] Add shadow PR self-review gate

* [CI] Fix PR self-review lint findings

* [CI] Read PR checks from head commit

* [CI] Lead self-review comment with readiness

* [CI] Split self-review prompt from readiness report

* [CI] Refresh self-review on review activity

* [CI] Hide shadow audit metrics from PR comments

* [CI] Show accepted self-review answers in report

* [CI] Remove PR self-review unit test fixture

* [CI] Replace self-review unit tests with static checks

* [CI] Avoid blocking on unavailable Copilot review

* [CI] Remove self-review rollout leftovers

Drop the redundant static-check workflow and the fixture-only interface. Simplify the readiness evaluator, fix section boundaries and self-matching debug detection, and document the actual Copilot reply policy.

Signed-off-by: zufayu <[email protected]>

* [CI] Harden self-review gate edge cases

Bound sticky-comment output, cover all PR file pages, treat draft PRs as not ready, and avoid duplicate comment and status writes. Restrict review events to main-targeting PRs and document the draft requirement.

Signed-off-by: zufayu <[email protected]>

* [CI] Address self-review security findings

Grant check-run read access and degrade CI API failures, safely render untrusted paths, refresh fork PRs by head identity, add deterministic regression coverage, and restore structured performance evidence in the PR template.

Signed-off-by: zufayu <[email protected]>

* [CI] Fix self-review selftest executable lint

Run the selftest explicitly with Python and remove the non-executable shebang flagged by the repository Ruff check.

Signed-off-by: zufayu <[email protected]>

* [CI] Isolate self-review refresh signals

* [CI] Restore PR review context

* [CI] Drop template regression assertion

---------

Signed-off-by: zufayu <[email protected]>
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.

5 participants