diff --git a/.github/workflows/openrouter-code-review.yml b/.github/workflows/openrouter-code-review.yml new file mode 100644 index 0000000..c11f5fe --- /dev/null +++ b/.github/workflows/openrouter-code-review.yml @@ -0,0 +1,207 @@ +# Organization-required OpenRouter PR review. +# Enforced via org ruleset "Require OpenRouter code review" pointing at this +# file, so every pegma-dev repository (including new ones) gets it without a +# per-repo workflow. Auth: org-level OPENROUTER_API_KEY secret only. +# +# Two cheap review lanes run in parallel and the pinned judge union-merges +# their findings into one review: +# meta/muse-spark-1.2 (Meta Muse Spark 1.2) +# z-ai/glm-5.3-flash (Z.ai GLM 5.3 Flash) +# judge: openai/gpt-5.6-luna +# +# Scope selection: opened, reopened, and manual runs always review the full +# PR (50 read-only tool rounds). A synchronize run reviews only the +# unreviewed commit range (30 rounds) when this PR already carries a review +# ledger posted by the bot, and otherwise performs the full-PR review +# itself. The action refuses a latest-commit round with no ledger, and +# GitHub can discard a still-queued first pass when a newer run enters the +# same concurrency group, so a synchronize must never assume a ledger +# exists. If the ledger probe itself fails, the run falls back to full-pr. +# +# One concurrency group per PR with cancel-in-progress off, so runs for the +# same PR execute one at a time and each sees the ledger the previous one +# wrote. GitHub keeps only the newest pending run per group; with ledger- +# based scope selection the survivor always does the right thing. +# +# The job always runs and only the review steps are gated, so the required +# check stays green for events that cannot be reviewed: ruleset-triggered +# runs ignore the `types:` filter below and fire only on opened, synchronize, +# and reopened; fork and Dependabot PRs never receive the org secret; drafts +# are reviewed like any other PR because ready_for_review never arrives from +# the ruleset. A missing org secret warns and skips. What can still turn the +# check red: the job timeout, a checkout failure, or the action itself +# failing (for example every lane and retry failing during an OpenRouter +# outage). Those are accepted; organization admins bypass the ruleset, and +# fail_on stays "never" so review findings are never a merge gate. +name: OpenRouter code review + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + # Optional manual re-run from the Actions tab on a PR's head repo + workflow_dispatch: + inputs: + pr_number: + description: PR number to review + required: true + type: string + +permissions: + contents: read + pull-requests: write + +concurrency: + group: openrouter-code-review-${{ github.repository }}-${{ github.event.pull_request.number || github.event.inputs.pr_number }} + cancel-in-progress: false + +jobs: + review: + name: OpenRouter review + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + OR_MODELS: meta/muse-spark-1.2,z-ai/glm-5.3-flash + OR_JUDGE: openai/gpt-5.6-luna + # Must match the posting identity (github.token posts as github-actions[bot]). + BOT_LOGIN: github-actions[bot] + # Hidden marker the action embeds in every review body that carries loop state. + LEDGER_MARKER: "