Skip to content

[chore](ci) refactor code review workflow to run on PR events with comment-triggered dispatch#62302

Closed
zclllyybb wants to merge 1 commit intoapache:masterfrom
zclllyybb:ai_review
Closed

[chore](ci) refactor code review workflow to run on PR events with comment-triggered dispatch#62302
zclllyybb wants to merge 1 commit intoapache:masterfrom
zclllyybb:ai_review

Conversation

@zclllyybb
Copy link
Copy Markdown
Contributor

Split code review workflow into two parts:

  1. Main workflow (opencode-review.yml) now triggers on PR events (opened/synchronize/reopened/ready_for_review) as a required check, but only runs actual review when called via workflow_call
  2. New comment dispatcher (opencode-review-comment.yml) triggers on /review comments and invokes the main workflow with PR context

@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 9, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zclllyybb
Copy link
Copy Markdown
Contributor Author

run buildall

@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

@zclllyybb zclllyybb requested a review from Copilot April 9, 2026 16:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors the automated code review GitHub Actions setup so the main review workflow is visible on PR events, while the actual review execution is dispatched via a /review PR comment.

Changes:

  • Split review execution into a reusable workflow (workflow_call) and a comment-driven dispatcher workflow.
  • Make the “Code Review” workflow appear on PR events as a stable (potentially required) check without running the reviewer unless dispatched.
  • Update contributor/agent guidance in AGENTS.md and expand review checkpoints documentation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
AGENTS.md Updates developer guidance and adds a rule about keeping commits task-focused.
.github/workflows/pr-approve-status.yml Removes the “Need_2_Approval” workflow.
.github/workflows/opencode-review.yml Refactors review workflow: PR-triggered visibility + workflow_call-only execution.
.github/workflows/opencode-review-comment.yml Adds /review comment dispatcher that resolves PR context and calls the reusable workflow.
.claude/skills/code-review/SKILL.md Updates review checkpoint guidance and adds emphasis on concurrency reasoning and test results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to +17
if: >-
github.event.issue.pull_request &&
contains(github.event.comment.body, '/review')
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

As written, any user who can comment on a PR can trigger /review, and secrets: inherit will pass repository secrets into a workflow that checks out and processes untrusted PR code. This is a privilege-escalation risk (especially for PRs from forks). Recommended: (1) gate dispatch on github.event.comment.author_association (e.g., OWNER/MEMBER/COLLABORATOR) and/or an allowlist; (2) fetch PR metadata and refuse to run (or run without sensitive secrets) when .head.repo.fork == true or .head.repo.full_name != github.repository; and (3) avoid secrets: inherit—pass only the minimal required secrets explicitly.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
uses: ./.github/workflows/opencode-review.yml
secrets: inherit
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

As written, any user who can comment on a PR can trigger /review, and secrets: inherit will pass repository secrets into a workflow that checks out and processes untrusted PR code. This is a privilege-escalation risk (especially for PRs from forks). Recommended: (1) gate dispatch on github.event.comment.author_association (e.g., OWNER/MEMBER/COLLABORATOR) and/or an allowlist; (2) fetch PR metadata and refuse to run (or run without sensitive secrets) when .head.repo.fork == true or .head.repo.full_name != github.repository; and (3) avoid secrets: inherit—pass only the minimal required secrets explicitly.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +99
- If issues found, submit a review with inline comments plus a comprehensive summary body. Use GitHub Reviews API to ensure comments are inline:
- Inline comment bodies may include GitHub suggested changes blocks when you can propose a precise patch.
- Prefer suggested changes for small, self-contained fixes (for example typos, trivial refactors, or narrowly scoped code corrections).
- Do not force suggested changes for broad, architectural, or multi-file issues; explain those normally.
- Build a JSON array of comments like: [{ "path": "<file>", "position": <diff_position>, "body": "..." }]
- Submit via: gh api repos/PLACEHOLDER_REPO/pulls/PLACEHOLDER_PR_NUMBER/reviews --input <json_file>
- The JSON file should contain: {"event":"COMMENT","body":"<summary>","comments":[...]}
- Do not use: gh pr review --approve or --request-changes
- MUST clearly state your stance on PRs: execute `gh pr review --approve` if there are no significant issues, otherwise request changes with `gh pr review --request-changes`.
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The prompt now instructs the agent to (a) submit a PR review via the Reviews API with event: COMMENT and (b) also run gh pr review --approve/--request-changes. This will create two separate reviews and can lead to confusing/duplicated outcomes (the API review won’t carry an approval state, and the CLI review likely won’t contain inline comments). Prefer a single mechanism: keep the GitHub Reviews API submission and set event to APPROVE or REQUEST_CHANGES (with inline comments included) so stance + inline comments are in one review.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +5
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

On pull_request events this job always succeeds after printing messages, so if branch protection marks “Code Review” as a required check, PRs can merge without an actual /review run. If the intent is gating, consider making the PR-event run fail/neutral until a dispatcher-run succeeds, or emit a separate status/check that the dispatcher updates (e.g., a dedicated check name for the dispatched review) and require that instead.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +32
- name: Keep required check visible on pull requests
if: ${{ github.event_name == 'pull_request' }}
run: |
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
HEAD_SHA=$(echo "$PR_JSON" | jq -r '.head.sha')
BASE_SHA=$(echo "$PR_JSON" | jq -r '.base.sha')
HEAD_REF=$(echo "$PR_JSON" | jq -r '.head.ref')
BASE_REF=$(echo "$PR_JSON" | jq -r '.base.ref')
echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
echo "head_ref=$HEAD_REF" >> "$GITHUB_OUTPUT"
echo "base_ref=$BASE_REF" >> "$GITHUB_OUTPUT"
echo "Code Review is exposed as a stable required check on pull requests."
echo "The actual automated review still runs only when the comment dispatcher invokes this workflow."
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

On pull_request events this job always succeeds after printing messages, so if branch protection marks “Code Review” as a required check, PRs can merge without an actual /review run. If the intent is gating, consider making the PR-event run fail/neutral until a dispatcher-run succeeds, or emit a separate status/check that the dispatcher updates (e.g., a dedicated check name for the dispatched review) and require that instead.

Copilot uses AI. Check for mistakes.
@@ -1,8 +1,19 @@
name: Code Review
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The PR description focuses on refactoring the code review workflow/dispatcher, but this PR also deletes .github/workflows/pr-approve-status.yml (Need_2_Approval). If that removal is intentional, it should be called out in the PR description (and ideally reference what replaces its functionality, if anything).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Found 2 issues that should be fixed before this workflow refactor lands.

  1. .github/workflows/opencode-review.yml: the new pull_request path reports a successful Code Review check after only printing two echo lines. Because every real review step is gated behind github.event_name == workflow_call, branch protection will see the required check as green even when no /review comment was posted and no automated review ran.\n2. .github/workflows/opencode-review-comment.yml: any public commenter can trigger /review. issue_comment runs in the base-repo context, and the called workflow inherits secrets plus write permissions, so external users can repeatedly burn the OpenCode/GitHub automation budget on arbitrary PRs.\n\nCritical checkpoint conclusions:\n- Goal of the task: split the workflow so Code Review stays visible on PRs while actual review is comment-dispatched. The current implementation does not safely achieve that goal, because the required check no longer proves a review ran and the dispatcher is not caller-restricted.\n- Small / focused change: the diff is localized, but it changes review-policy and workflow-security semantics in addition to event wiring.\n- Concurrency: no meaningful shared-state or lock-based concurrency concerns in these YAML changes.\n- Lifecycle: reusable-workflow lifecycle is straightforward; no special lifecycle hazards beyond the new two-path execution model.\n- Configuration items: no new runtime config items added.\n- Compatibility / parallel paths: there are now two parallel execution paths (pull_request and workflow_call), but only one performs the real review, which creates a behavioral gap.\n- Special conditions: the /review substring check is not sufficient as the sole gate; author permission checks are needed.\n- Test coverage: no automated validation was added for these workflow semantics.\n- Test result files: not applicable.\n- Observability: existing logging is not the main blocker here.\n- Transaction / persistence / data-write concerns: not applicable.\n- Performance: unrestricted /review triggering can create unnecessary runner and API usage.\n- Other issues: none beyond the inline findings above.\n\nPlease address the inline comments before merging.

echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT"
echo "head_ref=$HEAD_REF" >> "$GITHUB_OUTPUT"
echo "base_ref=$BASE_REF" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This turns Code Review into a misleading green required check. On pull_request events the job now succeeds after two echo statements, while every real review step is guarded by github.event_name == "workflow_call". That means a PR can show the required Code Review status as passing even if nobody ever comments /review and no automated review actually ran. Please keep the required check tied to a real review result, or make the non-review path fail/neutral instead of reporting success.

resolve-pr:
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This dispatcher is callable by any user who can comment on a public PR. Because issue_comment runs in the base-repo context and the called workflow uses secrets: inherit, an outside commenter can trigger secret-backed review runs and write-capable bot actions just by posting /review. Please gate this on github.event.comment.author_association (for example OWNER, MEMBER, or COLLABORATOR) before invoking the reusable workflow.

@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

I found 2 blocking issues.

  1. Deleting .github/workflows/pr-approve-status.yml removes the producer for the Need_2_Approval status, but .asf.yaml:65 still lists that status as required on master. After this merges, PRs to master will never be able to satisfy branch protection because the context will never be reported. Even if branch protection is updated separately, this PR also drops the existing two-approval policy down to GitHub's built-in required_approving_review_count: 1 with no replacement.

  2. .github/workflows/opencode-review.yml now tells the automated reviewer to run gh pr review --approve / --request-changes. That is the opposite of this workflow's existing contract and the submission rules used by the review runner, which require either a plain PR comment or a COMMENT review created through the Reviews API. In practice the bot will mutate approval state directly instead of leaving non-blocking review comments.

Critical checkpoint conclusions:

  • Goal of the task: Partially met. The dispatcher split itself is wired, but the overall change is not safe because approval enforcement and review semantics regress. There is no end-to-end test proving the new workflow arrangement preserves existing behavior.
  • Scope and focus: Not sufficiently focused. Besides splitting the dispatcher, the PR also changes review-policy behavior and deletes an externally required status without preserving compatibility.
  • Concurrency: No in-repo concurrency or locking concerns are introduced by these workflow-only changes.
  • Lifecycle and compatibility: Broken for the external workflow/branch-protection contract around Need_2_Approval.
  • Configuration items: No new configuration items are added.
  • Parallel code paths: The comment-triggered dispatch path is connected, but the approval-status path has no replacement.
  • Special conditional checks: The github.event_name gating is straightforward and readable.
  • Test coverage: No automated validation of workflow behavior or branch-protection integration is included.
  • Test results: No new test results were added or modified.
  • Observability: Existing failure-comment handling is adequate for workflow failures.
  • Transaction, persistence, data writes, FE/BE protocol: Not applicable to this PR.
  • Performance: No material performance issue found beyond the functional regressions above.
  • Other issues: None beyond the findings above.

# specific language governing permissions and limitations
# under the License.
---
name: Need_2_Approval
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deleting the only workflow named Need_2_Approval breaks master branch protection as currently configured: .asf.yaml:65 still lists that context under required_status_checks, and grep shows there is no other workflow left that publishes the same status. Once this lands, every PR to master will be missing a required check forever. If the intent is to retire this gate, the protection config has to change in the same PR; otherwise we need a replacement workflow/job that preserves the context.

- Prefer suggested changes for small, self-contained fixes (for example typos, trivial refactors, or narrowly scoped code corrections).
- Do not force suggested changes for broad, architectural, or multi-file issues; explain those normally.
- Build a JSON array of comments like: [{ "path": "<file>", "position": <diff_position>, "body": "..." }]
- Submit via: gh api repos/PLACEHOLDER_REPO/pulls/PLACEHOLDER_PR_NUMBER/reviews --input <json_file>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This flips the automation contract. The existing prompt and the runner instructions require the bot to leave either a plain PR comment or a COMMENT review via gh api .../reviews, explicitly not an APPROVED/CHANGES_REQUESTED review. Telling the model to run gh pr review --approve / --request-changes will make it mutate the PR's approval state directly instead of leaving non-blocking review comments.

Suggested change
- Submit via: gh api repos/PLACEHOLDER_REPO/pulls/PLACEHOLDER_PR_NUMBER/reviews --input <json_file>
- Do not use: gh pr review --approve or --request-changes

@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Summary opinion: blocking issues found.

Findings:

  1. .github/workflows/opencode-review-comment.yml lets any PR commenter trigger the reusable review workflow from the base-repo issue_comment context while forwarding secrets: inherit. That exposes repository secrets and a write-capable token to untrusted PR code, especially on fork PRs.
  2. Deleting .github/workflows/pr-approve-status.yml breaks master branch protection as currently declared in .asf.yaml, because Need_2_Approval remains a required status check and no replacement publisher is added.

Critical checkpoint conclusions:

  • Goal of current task: only partially accomplished. The workflow split is implemented, but the new dispatcher is unsafe and the PR removes a required status without replacement.
  • Modification size/focus: not fully focused, because it also changes branch-protection behavior by deleting Need_2_Approval.
  • Concurrency: no meaningful concurrency concern in these workflows.
  • Lifecycle/static initialization: not applicable.
  • Configuration items: no new runtime config items, but the workflow/branch-protection contract changes incompatibly.
  • Incompatible changes / parallel paths: yes. The current repository policy still requires Need_2_Approval, and the new comment-triggered path is not equivalently protected.
  • Special conditional checks: contains(github.event.comment.body, '/review') is not sufficient without actor authorization and fork checks.
  • Test coverage: no end-to-end workflow validation or protection-policy validation is included in the PR.
  • Test results modified: none.
  • Observability: failure comments exist, but they do not mitigate the blocking regressions above.
  • Transaction/persistence/data-write concerns: not applicable.
  • Performance: no material issue observed.
  • Other issues: none beyond the blocking findings above.

resolve-pr:
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue_comment runs in the base repository context, but this job only checks for a /review substring before invoking a reusable workflow with secrets: inherit. That means any outside user who can comment on a public PR can trigger a secret-backed run over untrusted head code. Please gate this on trusted author_association values and refuse fork heads (or avoid inheriting sensitive secrets entirely).

# specific language governing permissions and limitations
# under the License.
---
name: Need_2_Approval
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing this workflow breaks the repository's current master protection rules: .asf.yaml:65 still requires the Need_2_Approval status, and there is no remaining workflow that publishes the same context. After merge, PRs will be permanently missing a required check unless the protection config is updated in the same change or this status is replaced.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

AGENTS.md:83

  • The new paragraph duplicates the existing “Files in git commit should only be related…” rule earlier in this document, which makes the guidance conflicting/noisy. Please keep this rule in a single place (either remove this duplicate block or replace the earlier one).
5. The test section must honestly reflect the testing performed; do not claim tests that were not actually run

Files in a git commit should only be related to the current modification task. Environment modifications for running (for example `conf/`, `AGENTS.md`, `hooks/`) must not be `git add`ed. When delivering the final task, ensure all actual code modifications have been committed.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


#### 1.3.1 Concurrency and Thread Safety (Highest Priority)

If it involves the judgment of concurrent scenarios, it is necessary to find the starting point of concurrency and actually understand all actually possible concurrent situations (which thread initiated what at what stage, and what concurrent operations there will be). Due to the clear program semantics, some functions of the same module are executed in stages, so concurrency is definitely not present, there should be no misjudgment.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This added sentence has awkward repeated wording (“actually understand all actually possible…”), which reads like a copy/edit mistake. Please rephrase to remove the repetition so the guideline is clear.

Suggested change
If it involves the judgment of concurrent scenarios, it is necessary to find the starting point of concurrency and actually understand all actually possible concurrent situations (which thread initiated what at what stage, and what concurrent operations there will be). Due to the clear program semantics, some functions of the same module are executed in stages, so concurrency is definitely not present, there should be no misjudgment.
If it involves the judgment of concurrent scenarios, it is necessary to find the starting point of concurrency and fully understand all possible concurrent situations (which thread initiated what at what stage, and what concurrent operations there will be). Due to the clear program semantics, some functions of the same module are executed in stages, so concurrency is definitely not present, there should be no misjudgment.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +19
resolve-pr:
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request &&
contains(github.event.comment.body, '/review')
outputs:
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This workflow can be triggered by any user who comments “/review”, but it runs with write permissions and uses inherited secrets. Please restrict triggering to trusted actors (e.g., check github.event.comment.author_association for OWNER/MEMBER/COLLABORATOR or verify org/team membership) to avoid untrusted users invoking a secrets-bearing workflow.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +66
run: |
RUNS_JSON=$(gh api repos/${REPO}/actions/workflows/opencode-review.yml/runs --paginate -f event=pull_request -f head_sha=${HEAD_SHA})
RUN_ID=$(printf '%s' "$RUNS_JSON" | jq -r '
.workflow_runs
| sort_by(.created_at)
| reverse
| map(select(.head_sha != null))
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The rerun logic relies on gh api .../actions/workflows/.../runs query params event and especially head_sha. If head_sha is not supported/ignored, this may select and rerun the most recent workflow run from a different PR/commit. Safer approach: fetch recent runs and filter in jq by both .head_sha == HEAD_SHA and .pull_requests[].number == PR_NUMBER (you already have pr_number available) before picking the run id.

Suggested change
run: |
RUNS_JSON=$(gh api repos/${REPO}/actions/workflows/opencode-review.yml/runs --paginate -f event=pull_request -f head_sha=${HEAD_SHA})
RUN_ID=$(printf '%s' "$RUNS_JSON" | jq -r '
.workflow_runs
| sort_by(.created_at)
| reverse
| map(select(.head_sha != null))
PR_NUMBER: ${{ needs.resolve-pr.outputs.pr_number }}
run: |
RUNS_JSON=$(gh api repos/${REPO}/actions/workflows/opencode-review.yml/runs --paginate -f event=pull_request)
RUN_ID=$(printf '%s' "$RUNS_JSON" | jq -r --arg head_sha "$HEAD_SHA" --argjson pr_number "$PR_NUMBER" '
.workflow_runs
| map(
select(
.head_sha == $head_sha and
any(.pull_requests[]?; .number == $pr_number)
)
)
| sort_by(.created_at)
| reverse

Copilot uses AI. Check for mistakes.
Comment on lines 1 to +8
name: Code Review

on:
issue_comment:
types: [created]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
pull-requests: write
contents: read
issues: write
pull-requests: read
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This PR removes the Need_2_Approval workflow, but .asf.yaml still lists Need_2_Approval as a required status check for master (see .asf.yaml:65). As-is, merges to master will be blocked because the required context can no longer be produced. Please either keep a workflow that reports Need_2_Approval or update the required contexts accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 14
name: Code Review

on:
issue_comment:
types: [created]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
pull-requests: write
contents: read
issues: write
pull-requests: read

jobs:
code-review:
runs-on: ubuntu-latest
timeout-minutes: 60
if: >-
github.event.issue.pull_request &&
contains(github.event.comment.body, '/review')
steps:
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

PR description says the main workflow (opencode-review.yml) “only runs actual review when called via workflow_call”, but opencode-review.yml no longer has a workflow_call trigger—the review execution lives in opencode-review-runner.yml. Please align the PR description (or workflow naming/triggers) so future maintainers understand which workflow is the callable runner vs the required-check gate.

Copilot uses AI. Check for mistakes.
…mment-triggered dispatch

Split code review workflow into two parts:
1. Main workflow (opencode-review.yml) now triggers on PR events (opened/synchronize/reopened/ready_for_review) as a required check, but only runs actual review when called via workflow_call
2. New comment dispatcher (opencode-review-comment.yml) triggers on /review comments and invokes the main workflow with PR context

This ensures the Code Review check is always
@zclllyybb
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Found 1 blocking issue.

  1. Goal / correctness: The PR splits automated review into a /review dispatcher plus a pull_request status workflow, but the new runner is not safe for fork PRs. opencode-review-runner.yml checks out the untrusted PR head and then explicitly instructs OpenCode to read and follow AGENTS.md and .claude/skills/code-review/SKILL.md from that checkout while GH_TOKEN and CODE_REVIEW_ZCLLL_COPILOT_OPENCODE_KEY are available. A fork author can change those files to steer the agent into exfiltrating secrets or using the write-scoped token to mutate PR state, so the implementation does not safely accomplish its goal. No test covers this trust-boundary regression.

  2. Scope / focus: The workflow split itself is small, but it also changes the trust model of the review runner. That part is not sufficiently isolated because it couples privileged execution with attacker-controlled repository content.

  3. Concurrency: No meaningful shared-memory concurrency issue in the YAML itself; the main risk is workflow/event sequencing, not locking.

  4. Lifecycle / initialization: No special lifecycle or static-initialization concern applies here.

  5. Config changes: No new Doris runtime config is added. GitHub Actions permissions and triggers do change, and the new issue_comment trigger now runs with inherited secrets.

  6. Compatibility / parallel paths: The PR replaces the old approval-status path with a new review-status path. The new path needs the same fork-safety guarantees as other privileged PR automations, but it currently lacks them.

  7. Special conditions: The critical conditional path is /review on issue_comment. That condition is clear enough, but the privileged execution that follows is unsafe because it trusts head contents.

  8. Test coverage: There are no tests or other safeguards demonstrating safe behavior for fork PRs or attacker-controlled instruction files.

  9. Test results modified: None.

  10. Observability: Failure logging is adequate for operational errors, but it would not help after a prompt-injection-driven misuse of the token.

  11. Transaction / persistence: Not applicable.

  12. Data writes / modifications: Not applicable to Doris data paths, but the workflow does have PR-write side effects through gh. Those writes are precisely what make the trust-boundary bug serious.

  13. FE/BE variable passing: Not applicable.

  14. Performance: No significant performance concern compared with the security issue.

  15. Other issues: None beyond the blocking trust-boundary problem above.

Summary: Requesting changes in spirit. The runner must stop consuming reviewer instructions from untrusted head content, or avoid exposing secrets/write-scoped tokens when reviewing fork-controlled files.

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.head_sha }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checking out ${{ inputs.head_sha }} here makes the rest of this job run against untrusted PR contents, but this reusable workflow is invoked from issue_comment with secrets: inherit. That is a concrete privilege-escalation path for fork PRs: the contributor can change AGENTS.md or .claude/skills/code-review/SKILL.md, and the prompt later requires OpenCode to read and follow those files from the checked-out workspace while GH_TOKEN and CODE_REVIEW_ZCLLL_COPILOT_OPENCODE_KEY are available. In that scenario the model can be steered into exfiltrating credentials or performing arbitrary PR writes. The trusted review instructions need to come from the base repository revision only, or this job must avoid exposing secrets/write permissions when operating on head-controlled content.

@zclllyybb zclllyybb closed this Apr 10, 2026
@zclllyybb zclllyybb deleted the ai_review branch April 10, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants