Repository navigation
Support trusted pull_request_target and repository_dispatch review callers - #54
Merged
Merged
Conversation
…llers The reusable review workflow now admits two default-branch caller events alongside pull_request and workflow_dispatch, which keep their current job selection, permissions, and behavior. - pull_request_target (opened, reopened, ready_for_review, synchronize) keeps the first-pass / follow-up split and runs only for PRs that target the default branch. - repository_dispatch from the default branch is a first pass. Callers map client_payload into pr_number, review_level, and the new optional expected_head_sha input, which fails the review and gate closed when the live PR head moved. - A new review-config step resolves the PR number, pass, and event head, base, and before SHAs explicitly, and rejects mismatched PR numbers. - The gate exposes the evaluated head and conclusion as gate_* workflow outputs. The new openrouter-review-gate-check.yml entry point publishes that result as a GitHub Actions check run on the exact evaluated head for default-branch dispatch runs. It is the only job that requests checks: write, so existing callers keep working without new scopes. - Reviewed checkouts stay inert data: submodules and LFS are explicitly off, and a commit containing the reserved trusted checkout paths is refused. - Bot-sent repository_dispatch reviews wake profile completion like bot-sent workflow_dispatch reviews. Profile provenance (Python and the Node consumer) admits the new events. repository_dispatch runs must be on the default branch with a matching caller blob. pull_request_target runs report the PR head, so their caller is proven through the head branch: every same-repository PR from it must target the default branch with no recorded base change. They also need the exact reusable pin, a run head equal to the receipt head, and a matching PR head branch. The Node consumer now also requires pull-request review runs to match the receipt head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two optional, default-branch caller events to the shared OpenRouter review workflow. Existing
pull_requestandworkflow_dispatchcallers keep their current job selection, permissions, and behavior.pull_request_target(opened,reopened,ready_for_review,synchronize) keeps thepull_requestfirst-pass / follow-up split. It runs only for PRs that target the default branch.repository_dispatchfrom the default branch is a first pass, likeworkflow_dispatch. Callers mapclient_payloadintowith:(pr_number,review_level, and the new optionalexpected_head_sha). The reusable workflow never readsclient_payloaddirectly.review-configresolves the PR number, pass, and event head/base/before SHAs explicitly and rejects a PR number that differs from the triggering PR.github.shais never treated as the PR head.gate_pr_number,gate_head_sha,gate_conclusion, andgate_review_urloutputs. The newopenrouter-review-gate-check.ymlentry point publishes that result (success or failure) as a GitHub Actions check run namedreview / openrouter-first-pass-gate(configurable viagate_check_name) on the exact head the gate evaluated.Permissions compatibility
All six current org callers grant
actions: write,contents: read,pull-requests: write, andstatuses: writeat the top level, with no job override and nochecks: write. GitHub checks reusable-job permissions before runtime conditions, so achecks: writejob insideopenrouter-code-review.ymlwould reject those callers on their next pin bump. The check publisher is therefore its own entry point and the only job that requestschecks: write. The review workflow requests no scope beyond what callers grant today, and a contract test enforces that.Where checks land
On public repositories, GitHub records
pull_request_targetruns (head_sha,head_branch, and the check suite) on the PR head. The native gate job check therefore already reports on the reviewed commit. Default-branch dispatch runs record the default-branch tip instead. Inautomode the publisher acts only for those runs. It publishes only from default-branch refs and skips a head that moved after evaluation.Checkout isolation
Jobs that hold the OpenRouter key keep the reviewed head as inert data:
persist-credentials: false, with submodules and LFS explicitly off.-Pand a trustedPYTHONPATH. Git only reads objects..trusted-review-orgor.trusted-review-actionpaths (including a symlink) is refused before the trusted checkouts.Profile provenance
Python (
profile_github,profile_completion,profile_requests,profile_gate) andprofile_consumer.mjsstay aligned:repository_dispatchmust run on the default branch, and the caller blob at the run's default-branch commit must match the trusted caller.pull_request_targetruns report the PR head, not the commit whose caller ran. The caller is proven through the head branch: every same-repository PR from that branch must target the default branch with noBASE_REF_CHANGED_EVENTorAUTOMATIC_BASE_CHANGE_SUCCEEDED_EVENT. The run also needs the exact reusable pin, a run head equal to the receipt head, and a PR whose head branch matches the run. A receipt for an older head never satisfies a newer one.deep/cancelstill require a maintainer and a default-branch dispatch (workflow_dispatchorrepository_dispatch).repository_dispatchreviews wake profile completion the same way bot-sentworkflow_dispatchreviews do.Tests
python -m unittest discover -s tests: 155 tests (was 114). New coverage includes:pull_request/workflow_dispatchjob selection, evaluated from the workflowif:expressions;node --test: 55 tests (was 37), including the newgate-check.test.mjs(payload, name, SHA, update-in-place, auto/always modes, moved heads, forged inputs).actionlint1.7.12 passes on all three workflows.No caller changes are required. Callers adopt the new events by advancing their pin and adding the second job shown in the README.
🤖 Generated with Claude Code