From 1b4c5af7b04b7811e806d9f0194463f1e3c74f72 Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 9 Sep 2026 21:02:34 -0400 Subject: [PATCH 1/5] Add org-wide OpenRouter code review workflow Two cheap lanes (meta/muse-spark-1.2, z-ai/glm-5.3-flash) merged by the default judge, first-pass on open/reopen/ready and a latest-commit follow-up on synchronize. Pinned to openrouter-pr-review-action main 4471f596. Fork and Dependabot PRs skip the review step but still succeed so the org ruleset that will require this workflow never blocks them. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/openrouter-code-review.yml | 152 +++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 .github/workflows/openrouter-code-review.yml diff --git a/.github/workflows/openrouter-code-review.yml b/.github/workflows/openrouter-code-review.yml new file mode 100644 index 0000000..0f51487 --- /dev/null +++ b/.github/workflows/openrouter-code-review.yml @@ -0,0 +1,152 @@ +# 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 default judge +# (openai/gpt-5.6-luna) 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) +# +# First pass (opened, reopened, ready_for_review, workflow_dispatch): full-PR +# review, 50 read-only tool rounds. Follow-up (synchronize): latest-commit +# verify round against the existing ledger, 30 tool rounds. +# +# Concurrency is split by pass type so synchronize does not cancel an in-flight +# first pass. fail_on stays "never": this is a reviewer, not a merge gate; the +# ruleset only requires the workflow to complete. +# +# Fork and Dependabot PRs do not receive the org secret, so the review step is +# skipped for them and the job still succeeds, otherwise the required check +# would block those PRs forever. +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 }}-${{ (github.event_name == 'pull_request' && github.event.action == 'synchronize') && 'follow-up' || 'first-pass' }} + cancel-in-progress: true + +jobs: + review: + name: OpenRouter review + if: >- + github.event_name == 'workflow_dispatch' || + (github.event_name == 'pull_request' && !github.event.pull_request.draft) + runs-on: ubuntu-latest + timeout-minutes: 25 + env: + OR_MODELS: meta/muse-spark-1.2,z-ai/glm-5.3-flash + IS_FOLLOW_UP: ${{ (github.event_name == 'pull_request' && github.event.action == 'synchronize') && 'true' || 'false' }} + # Same-repo, non-Dependabot PRs (or a manual dispatch) are eligible for + # a review. Fork PRs have no org secret and no write token. + REVIEW_ELIGIBLE: >- + ${{ + (github.event_name == 'workflow_dispatch' || + (github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.user.login != 'dependabot[bot]' && + github.actor != 'dependabot[bot]')) && 'true' || 'false' + }} + steps: + - name: Resolve PR head + id: pr + env: + GH_TOKEN: ${{ github.token }} + EVENT_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }} + run: | + set -euo pipefail + SHA="${EVENT_HEAD_SHA:-}" + if [ -z "$SHA" ]; then + SHA="$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)" + fi + echo "head_sha=$SHA" >> "$GITHUB_OUTPUT" + echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + + - name: Skip ineligible PR + if: env.REVIEW_ELIGIBLE != 'true' + run: echo "::notice::Fork or Dependabot PR, OpenRouter review skipped (no org secret available)." + + - name: Require OPENROUTER_API_KEY + if: env.REVIEW_ELIGIBLE == 'true' + env: + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} + run: | + if [ -z "${OPENROUTER_API_KEY}" ]; then + echo "::error::OPENROUTER_API_KEY is empty. Set the org-level OPENROUTER_API_KEY secret." + exit 1 + fi + + - name: Checkout PR head + if: env.REVIEW_ELIGIBLE == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + fetch-depth: 0 + ref: ${{ steps.pr.outputs.head_sha }} + + - name: Run OpenRouter review (first pass) + if: env.REVIEW_ELIGIBLE == 'true' && env.IS_FOLLOW_UP != 'true' + id: first + uses: FlyOverCoderKY/openrouter-pr-review-action@4471f5963751223c26a2e169d78c0f13817165aa # main 2026-09-09 + with: + github_token: ${{ github.token }} + pr_number: ${{ steps.pr.outputs.number }} + models: ${{ env.OR_MODELS }} + review_scope: full-pr + review_mode: auto + fail_on: never + roast_level: professional + status_comments: "true" + env: + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} + + - name: Run OpenRouter review (follow-up) + if: env.REVIEW_ELIGIBLE == 'true' && env.IS_FOLLOW_UP == 'true' + id: follow + uses: FlyOverCoderKY/openrouter-pr-review-action@4471f5963751223c26a2e169d78c0f13817165aa # main 2026-09-09 + with: + github_token: ${{ github.token }} + pr_number: ${{ steps.pr.outputs.number }} + models: ${{ env.OR_MODELS }} + review_scope: latest-commit + review_mode: auto + fail_on: never + roast_level: professional + status_comments: "true" + max_tool_turns: "30" + env: + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} + + - name: Summary + if: always() + env: + VERDICT: ${{ steps.first.outputs.verdict || steps.follow.outputs.verdict }} + ISSUES: ${{ steps.first.outputs.issue_count || steps.follow.outputs.issue_count }} + REVIEW_URL: ${{ steps.first.outputs.review_url || steps.follow.outputs.review_url }} + run: | + { + echo "### OpenRouter code review" + echo "" + echo "| Field | Value |" + echo "| --- | --- |" + echo "| Eligible | \`${REVIEW_ELIGIBLE}\` |" + echo "| Pass | \`$([ "${IS_FOLLOW_UP}" = true ] && echo follow-up || echo first-pass)\` |" + echo "| Models | \`${OR_MODELS}\` |" + echo "| Verdict | \`${VERDICT:-n/a}\` |" + echo "| Issues | \`${ISSUES:-n/a}\` |" + echo "| Review | ${REVIEW_URL:-n/a} |" + } >> "$GITHUB_STEP_SUMMARY" From b47554c5ac28531fc65c3613c8b69c4e39f1de64 Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 9 Sep 2026 21:22:06 -0400 Subject: [PATCH 2/5] Harden org OpenRouter review for ruleset semantics and dispatch Review triage of the first-pass findings on this PR: - Valid: gh pr view on workflow_dispatch ran with no checkout and no GH_REPO, so gh could not resolve the repository. Set GH_REPO, validate pr_number and the resolved SHA, and only resolve when eligible. - Valid in spirit: ruleset-triggered runs ignore the types filter and fire only on opened/synchronize/reopened, and a skipped job leaves the required check unsatisfied. The job now always runs and succeeds; eligibility gates the steps. Drafts are reviewed rather than skipped, because ready_for_review never arrives from the ruleset and the action refuses a latest-commit round with no prior ledger. - Accepted as cheap hygiene: pin max_tool_turns 50 on the first pass, pin judge_model explicitly, timeout 30 to match the Grok sibling. - Not valid: the checkout SHA is the actions/checkout v7.0.1 tag; the action inputs and outputs are as documented at the pinned revision; dependabot-preview[bot] no longer exists and Renovate PRs receive org secrets; the read-only tool sandbox is the action's documented design. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/openrouter-code-review.yml | 88 +++++++++++++------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/.github/workflows/openrouter-code-review.yml b/.github/workflows/openrouter-code-review.yml index 0f51487..ed0cf97 100644 --- a/.github/workflows/openrouter-code-review.yml +++ b/.github/workflows/openrouter-code-review.yml @@ -3,22 +3,29 @@ # 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 default judge -# (openai/gpt-5.6-luna) union-merges their findings into one review: +# 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 # # First pass (opened, reopened, ready_for_review, workflow_dispatch): full-PR # review, 50 read-only tool rounds. Follow-up (synchronize): latest-commit -# verify round against the existing ledger, 30 tool rounds. +# round against the existing ledger, 30 tool rounds. # -# Concurrency is split by pass type so synchronize does not cancel an in-flight -# first pass. fail_on stays "never": this is a reviewer, not a merge gate; the -# ruleset only requires the workflow to complete. +# The job always runs and always succeeds; only the review steps are gated. +# Ruleset-triggered runs ignore the `types:` filter below and fire only on +# the default activity types (opened, synchronize, reopened), and fork / +# Dependabot PRs never receive the org secret, so a job-level skip or a hard +# failure in those cases would leave the required check unsatisfied or red. +# Drafts are reviewed like any other PR: the ruleset never sends +# ready_for_review, and a latest-commit follow-up is refused when no initial +# review exists, so skipping drafts would strand them. fail_on stays "never": +# this is a reviewer, not a merge gate; the ruleset only requires the +# workflow to complete. # -# Fork and Dependabot PRs do not receive the org secret, so the review step is -# skipped for them and the job still succeeds, otherwise the required check -# would block those PRs forever. +# Concurrency is split by pass type so synchronize does not cancel an +# in-flight first pass. name: OpenRouter code review on: @@ -43,52 +50,66 @@ concurrency: jobs: review: name: OpenRouter review - if: >- - github.event_name == 'workflow_dispatch' || - (github.event_name == 'pull_request' && !github.event.pull_request.draft) runs-on: ubuntu-latest - timeout-minutes: 25 + timeout-minutes: 30 env: OR_MODELS: meta/muse-spark-1.2,z-ai/glm-5.3-flash + OR_JUDGE: openai/gpt-5.6-luna IS_FOLLOW_UP: ${{ (github.event_name == 'pull_request' && github.event.action == 'synchronize') && 'true' || 'false' }} - # Same-repo, non-Dependabot PRs (or a manual dispatch) are eligible for - # a review. Fork PRs have no org secret and no write token. + # Eligible: a manual dispatch, or a same-repo pull_request event of a + # reviewable type from anyone but Dependabot. Fork PRs have no org + # secret and no write token; Dependabot runs get Dependabot secrets. REVIEW_ELIGIBLE: >- ${{ (github.event_name == 'workflow_dispatch' || - (github.event.pull_request.head.repo.full_name == github.repository && + (github.event_name == 'pull_request' && + contains(fromJSON('["opened","synchronize","reopened","ready_for_review"]'), github.event.action) && + github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]' && github.actor != 'dependabot[bot]')) && 'true' || 'false' }} steps: + - name: Skip ineligible event + if: env.REVIEW_ELIGIBLE != 'true' + env: + EVENT: ${{ github.event_name }} + ACTION: ${{ github.event.action }} + run: echo "::notice::OpenRouter review skipped for ${EVENT}/${ACTION} (fork, Dependabot, or non-review activity)." + + - name: Require OPENROUTER_API_KEY + if: env.REVIEW_ELIGIBLE == 'true' + env: + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} + run: | + if [ -z "${OPENROUTER_API_KEY}" ]; then + echo "::error::OPENROUTER_API_KEY is empty. Set the org-level OPENROUTER_API_KEY secret." + exit 1 + fi + - name: Resolve PR head + if: env.REVIEW_ELIGIBLE == 'true' id: pr env: GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} EVENT_HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }} run: | set -euo pipefail + if [[ ! "${PR_NUMBER}" =~ ^[1-9][0-9]*$ ]]; then + echo "::error::pr_number must be a positive integer, got '${PR_NUMBER}'." + exit 1 + fi SHA="${EVENT_HEAD_SHA:-}" if [ -z "$SHA" ]; then SHA="$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)" fi - echo "head_sha=$SHA" >> "$GITHUB_OUTPUT" - echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - - - name: Skip ineligible PR - if: env.REVIEW_ELIGIBLE != 'true' - run: echo "::notice::Fork or Dependabot PR, OpenRouter review skipped (no org secret available)." - - - name: Require OPENROUTER_API_KEY - if: env.REVIEW_ELIGIBLE == 'true' - env: - OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} - run: | - if [ -z "${OPENROUTER_API_KEY}" ]; then - echo "::error::OPENROUTER_API_KEY is empty. Set the org-level OPENROUTER_API_KEY secret." + if [[ ! "$SHA" =~ ^[0-9a-fA-F]{40}$ ]]; then + echo "::error::Could not resolve a full head SHA for PR ${PR_NUMBER}." exit 1 fi + echo "head_sha=${SHA,,}" >> "$GITHUB_OUTPUT" + echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - name: Checkout PR head if: env.REVIEW_ELIGIBLE == 'true' @@ -106,11 +127,13 @@ jobs: github_token: ${{ github.token }} pr_number: ${{ steps.pr.outputs.number }} models: ${{ env.OR_MODELS }} + judge_model: ${{ env.OR_JUDGE }} review_scope: full-pr review_mode: auto fail_on: never roast_level: professional status_comments: "true" + max_tool_turns: "50" env: OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} @@ -122,6 +145,7 @@ jobs: github_token: ${{ github.token }} pr_number: ${{ steps.pr.outputs.number }} models: ${{ env.OR_MODELS }} + judge_model: ${{ env.OR_JUDGE }} review_scope: latest-commit review_mode: auto fail_on: never @@ -134,6 +158,8 @@ jobs: - name: Summary if: always() env: + EVENT: ${{ github.event_name }} + ACTION: ${{ github.event.action }} VERDICT: ${{ steps.first.outputs.verdict || steps.follow.outputs.verdict }} ISSUES: ${{ steps.first.outputs.issue_count || steps.follow.outputs.issue_count }} REVIEW_URL: ${{ steps.first.outputs.review_url || steps.follow.outputs.review_url }} @@ -143,9 +169,11 @@ jobs: echo "" echo "| Field | Value |" echo "| --- | --- |" + echo "| Event | \`${EVENT}/${ACTION:-dispatch}\` |" echo "| Eligible | \`${REVIEW_ELIGIBLE}\` |" echo "| Pass | \`$([ "${IS_FOLLOW_UP}" = true ] && echo follow-up || echo first-pass)\` |" echo "| Models | \`${OR_MODELS}\` |" + echo "| Judge | \`${OR_JUDGE}\` |" echo "| Verdict | \`${VERDICT:-n/a}\` |" echo "| Issues | \`${ISSUES:-n/a}\` |" echo "| Review | ${REVIEW_URL:-n/a} |" From 86e8c83627897ad9ea6abedaf61d297f4f4bb4ae Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 9 Sep 2026 21:30:41 -0400 Subject: [PATCH 3/5] Serialize passes per PR and skip instead of failing on a missing secret Round 2 triage: Grok's warning is correct that a synchronize arriving while the opened first pass is still running would start a follow-up that the action refuses for lack of a ledger. Use one concurrency group per PR with cancel-in-progress off so the follow-up waits; GitHub keeps only the newest pending run and a latest-commit round covers the whole unreviewed range. GLM's nit is correct that "always succeeds" was false when the org secret is empty; that case now warns and skips so a reviewer outage cannot block every merge in the organization. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/openrouter-code-review.yml | 37 +++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/openrouter-code-review.yml b/.github/workflows/openrouter-code-review.yml index ed0cf97..c5c36bc 100644 --- a/.github/workflows/openrouter-code-review.yml +++ b/.github/workflows/openrouter-code-review.yml @@ -13,7 +13,12 @@ # review, 50 read-only tool rounds. Follow-up (synchronize): latest-commit # round against the existing ledger, 30 tool rounds. # -# The job always runs and always succeeds; only the review steps are gated. +# The job always runs and only the review steps are gated, so the required +# check stays green for events that cannot be reviewed. A missing org secret +# warns and skips rather than failing; a reviewer outage must not block every +# merge in the organization. The only hard failures are a malformed +# pr_number or an unresolvable PR head, which can only happen on a manual +# dispatch and therefore never touch a pull request's required check. # Ruleset-triggered runs ignore the `types:` filter below and fire only on # the default activity types (opened, synchronize, reopened), and fork / # Dependabot PRs never receive the org secret, so a job-level skip or a hard @@ -24,8 +29,11 @@ # this is a reviewer, not a merge gate; the ruleset only requires the # workflow to complete. # -# Concurrency is split by pass type so synchronize does not cancel an -# in-flight first pass. +# One concurrency group per PR with cancel-in-progress off: a synchronize +# that lands while the first pass is still running waits for it instead of +# starting a follow-up that would be refused for lack of a ledger. GitHub +# keeps only the newest pending run per group, and a latest-commit follow-up +# reviews the whole unreviewed range, so superseded pending runs lose nothing. name: OpenRouter code review on: @@ -44,8 +52,8 @@ permissions: pull-requests: write concurrency: - group: openrouter-code-review-${{ github.repository }}-${{ github.event.pull_request.number || github.event.inputs.pr_number }}-${{ (github.event_name == 'pull_request' && github.event.action == 'synchronize') && 'follow-up' || 'first-pass' }} - cancel-in-progress: true + group: openrouter-code-review-${{ github.repository }}-${{ github.event.pull_request.number || github.event.inputs.pr_number }} + cancel-in-progress: false jobs: review: @@ -76,18 +84,21 @@ jobs: ACTION: ${{ github.event.action }} run: echo "::notice::OpenRouter review skipped for ${EVENT}/${ACTION} (fork, Dependabot, or non-review activity)." - - name: Require OPENROUTER_API_KEY + - name: Check OPENROUTER_API_KEY if: env.REVIEW_ELIGIBLE == 'true' + id: key env: OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} run: | if [ -z "${OPENROUTER_API_KEY}" ]; then - echo "::error::OPENROUTER_API_KEY is empty. Set the org-level OPENROUTER_API_KEY secret." - exit 1 + echo "::warning::OPENROUTER_API_KEY is empty; review skipped. Set the org-level OPENROUTER_API_KEY secret with visibility to this repository." + echo "present=false" >> "$GITHUB_OUTPUT" + else + echo "present=true" >> "$GITHUB_OUTPUT" fi - name: Resolve PR head - if: env.REVIEW_ELIGIBLE == 'true' + if: env.REVIEW_ELIGIBLE == 'true' && steps.key.outputs.present == 'true' id: pr env: GH_TOKEN: ${{ github.token }} @@ -112,7 +123,7 @@ jobs: echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - name: Checkout PR head - if: env.REVIEW_ELIGIBLE == 'true' + if: env.REVIEW_ELIGIBLE == 'true' && steps.key.outputs.present == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -120,7 +131,7 @@ jobs: ref: ${{ steps.pr.outputs.head_sha }} - name: Run OpenRouter review (first pass) - if: env.REVIEW_ELIGIBLE == 'true' && env.IS_FOLLOW_UP != 'true' + if: env.REVIEW_ELIGIBLE == 'true' && steps.key.outputs.present == 'true' && env.IS_FOLLOW_UP != 'true' id: first uses: FlyOverCoderKY/openrouter-pr-review-action@4471f5963751223c26a2e169d78c0f13817165aa # main 2026-09-09 with: @@ -138,7 +149,7 @@ jobs: OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} - name: Run OpenRouter review (follow-up) - if: env.REVIEW_ELIGIBLE == 'true' && env.IS_FOLLOW_UP == 'true' + if: env.REVIEW_ELIGIBLE == 'true' && steps.key.outputs.present == 'true' && env.IS_FOLLOW_UP == 'true' id: follow uses: FlyOverCoderKY/openrouter-pr-review-action@4471f5963751223c26a2e169d78c0f13817165aa # main 2026-09-09 with: @@ -160,6 +171,7 @@ jobs: env: EVENT: ${{ github.event_name }} ACTION: ${{ github.event.action }} + KEY_PRESENT: ${{ steps.key.outputs.present }} VERDICT: ${{ steps.first.outputs.verdict || steps.follow.outputs.verdict }} ISSUES: ${{ steps.first.outputs.issue_count || steps.follow.outputs.issue_count }} REVIEW_URL: ${{ steps.first.outputs.review_url || steps.follow.outputs.review_url }} @@ -171,6 +183,7 @@ jobs: echo "| --- | --- |" echo "| Event | \`${EVENT}/${ACTION:-dispatch}\` |" echo "| Eligible | \`${REVIEW_ELIGIBLE}\` |" + echo "| Secret present | \`${KEY_PRESENT:-n/a}\` |" echo "| Pass | \`$([ "${IS_FOLLOW_UP}" = true ] && echo follow-up || echo first-pass)\` |" echo "| Models | \`${OR_MODELS}\` |" echo "| Judge | \`${OR_JUDGE}\` |" From 765c36e9fa2285bebab2d7e692729492c9353e0e Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 9 Sep 2026 21:41:41 -0400 Subject: [PATCH 4/5] Choose review scope from the ledger, not the event Round 3 triage: both reviewers found the same hole in the single concurrency group. GitHub keeps only the newest pending run per group, so a still-queued opened run is discarded by a synchronize, and the survivor would run latest-commit with no ledger, which the action refuses. Scope now comes from the PR itself: a synchronize run narrows to latest-commit only when the bot has already posted a ledger marker on the PR, otherwise it performs the initial full-PR review. The two review steps collapse into one, and bot_login is passed explicitly so the ledger scan and the action agree on the posting identity. The header now states the real hard-failure envelope (timeout, checkout, or the action itself failing) instead of claiming those cannot happen. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/openrouter-code-review.yml | 115 ++++++++++--------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/.github/workflows/openrouter-code-review.yml b/.github/workflows/openrouter-code-review.yml index c5c36bc..232a449 100644 --- a/.github/workflows/openrouter-code-review.yml +++ b/.github/workflows/openrouter-code-review.yml @@ -9,31 +9,29 @@ # z-ai/glm-5.3-flash (Z.ai GLM 5.3 Flash) # judge: openai/gpt-5.6-luna # -# First pass (opened, reopened, ready_for_review, workflow_dispatch): full-PR -# review, 50 read-only tool rounds. Follow-up (synchronize): latest-commit -# round against the existing ledger, 30 tool rounds. +# Scope selection: a run reviews the full PR (50 read-only tool rounds) +# unless this PR already carries a review ledger posted by the bot, in which +# case a synchronize run reviews only the unreviewed commit range (30 +# rounds). The ledger check, not the event type, decides: 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 deriving +# scope from the event alone would strand a PR without an initial review. # -# The job always runs and only the review steps are gated, so the required -# check stays green for events that cannot be reviewed. A missing org secret -# warns and skips rather than failing; a reviewer outage must not block every -# merge in the organization. The only hard failures are a malformed -# pr_number or an unresolvable PR head, which can only happen on a manual -# dispatch and therefore never touch a pull request's required check. -# Ruleset-triggered runs ignore the `types:` filter below and fire only on -# the default activity types (opened, synchronize, reopened), and fork / -# Dependabot PRs never receive the org secret, so a job-level skip or a hard -# failure in those cases would leave the required check unsatisfied or red. -# Drafts are reviewed like any other PR: the ruleset never sends -# ready_for_review, and a latest-commit follow-up is refused when no initial -# review exists, so skipping drafts would strand them. fail_on stays "never": -# this is a reviewer, not a merge gate; the ruleset only requires the -# workflow to complete. +# 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. # -# One concurrency group per PR with cancel-in-progress off: a synchronize -# that lands while the first pass is still running waits for it instead of -# starting a follow-up that would be refused for lack of a ledger. GitHub -# keeps only the newest pending run per group, and a latest-commit follow-up -# reviews the whole unreviewed range, so superseded pending runs lose nothing. +# 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: @@ -63,7 +61,10 @@ jobs: env: OR_MODELS: meta/muse-spark-1.2,z-ai/glm-5.3-flash OR_JUDGE: openai/gpt-5.6-luna - IS_FOLLOW_UP: ${{ (github.event_name == 'pull_request' && github.event.action == 'synchronize') && 'true' || 'false' }} + # 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: "