From 29dfaf7805e58f5fe55069f8d07dffea94d6cfa0 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:48:13 -0500 Subject: [PATCH 1/2] feat(claude-lanes): migrate hosted review callers to pr-review-cli.yml --- .github/workflows/pr-review-security.yml | 47 ++++++------- .github/workflows/pr-review.yml | 50 +++++++------- .../claude-lanes-hosted/claude-review.yml | 65 ++++++++--------- .../claude-security-review.yml | 69 ++++++++++--------- .../runner-policy/runner-policy.test.mjs | 67 ++++++++++++------ distribution/README.md | 20 +++--- distribution/sync-manifest.yml | 21 +++--- 7 files changed, 182 insertions(+), 157 deletions(-) diff --git a/.github/workflows/pr-review-security.yml b/.github/workflows/pr-review-security.yml index 1206a39b..a71f2b17 100644 --- a/.github/workflows/pr-review-security.yml +++ b/.github/workflows/pr-review-security.yml @@ -1,23 +1,26 @@ name: PR Review Security -# Automated PR security review via the ci-workflows reusable workflow, the -# security sibling of pr-review.yml. Advisory: never add any check in this -# file to required status checks (github-iac ADR 0011). +# Automated PR security review via the ci-workflows pr-review-cli reusable +# workflow (lane `security`), the security sibling of pr-review.yml. Advisory: +# never add any check in this file to required status checks (github-iac +# ADR 0011). # -# Repo-local rather than the sync-managed `claude-security-review-caller` -# component (components/claude-lanes/claude-security-review.yml): this +# Repo-local rather than the sync-managed `claude-security-review-hosted-caller` +# component (components/claude-lanes-hosted/claude-security-review.yml): this # repository is the manifest SOURCE, not a sync target. It tracks that -# component except for the runner note below. +# component except that it passes no `allowed-bot-sender-ids`. # -# Every non-draft same-repository PR is reviewed; the reusable skips fork PRs -# (they receive no secrets and a read-only token) and every `[bot]` actor. +# Every non-draft same-repository PR is reviewed on GitHub-hosted +# `ubuntu-24.04` (this repository is PUBLIC); the reusable skips fork PRs +# (they receive no secrets and a read-only token), Dependabot, and every +# `[bot]` actor. # # NEVER add workflow-level `paths:`/`paths-ignore:`: a check whose workflow # never triggers stays Pending forever. on: pull_request: - # NO `merge_group:`: the pinned action cannot serve that event; see + # NO `merge_group:`: the reusable runs only on `pull_request`; see # melodic-software/ci-workflows#272 before enabling a merge queue. types: [opened, synchronize, ready_for_review, reopened] @@ -36,23 +39,21 @@ jobs: # A draft does not spend a review; ready_for_review delivers one. if: github.event.pull_request.draft == false permissions: + actions: read # check-key-credit reads its marker; Publish Review reads this workflow's runs + checks: read # Publish Review reads its earlier runs' cost notices contents: read # checkout + read the diff - pull-requests: write # post the security review + tracking comment - id-token: write # OIDC, mints the Claude GitHub App token (required - # even with an OAuth/API-key credential) - uses: melodic-software/ci-workflows/.github/workflows/pr-review-security.yml@main + pull-requests: write # post the security review, comments, and the lane's reviewed-head marker comment + uses: melodic-software/ci-workflows/.github/workflows/pr-review-cli.yml@main with: - # Names (never the value) the fallback secret in the lane-outcome record. - fallback-credential-name: FALLBACK_CLAUDE_CODE_OAUTH_TOKEN - # DEVIATION from the component, which names the managed fleet label: - # this repository is PUBLIC, and runner-policy admits a managed label - # only for an enrolled private consumer (`components/runner-policy/README.md`), - # so this caller pins the approved hosted label directly. - runner: ubuntu-24.04 + lane: security + publish: comments + docs-only-paths: | + docs/**/*.md + **/README.md + **/CHANGELOG.md # Pass only the named secrets (least privilege) rather than `secrets: # inherit`, which would forward every parent secret to the called workflow. secrets: - CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # The central fallback subscription: the review retries once on it after - # a usage limit on the token above. + CLAUDE_API_KEY: ${{ secrets.REVIEWS_CLAUDE_API_KEY }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.REVIEWS_CLAUDE_CODE_OAUTH_TOKEN }} FALLBACK_CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.FALLBACK_CLAUDE_CODE_OAUTH_TOKEN }} diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index d578666a..f4ea0827 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -1,23 +1,26 @@ name: PR Review -# Automated PR code review via the ci-workflows reusable workflow. The caller -# owns the triggers + GITHUB_TOKEN permission grant (a called workflow can only -# downgrade them, never elevate); the reusable workflow owns the action pin, the -# model, and the secret-handling model. +# Automated PR code review via the ci-workflows pr-review-cli reusable workflow +# (lane `code`). The caller owns the triggers + GITHUB_TOKEN permission grant +# (a called workflow can only downgrade them, never elevate); the reusable +# workflow owns the launcher, the credential order (reviews API key, then +# subscription token, then central fallback), and the secret-handling model. # -# Repo-local rather than the sync-managed `claude-review-caller` component -# (melodic-software/standards, components/claude-lanes/claude-review.yml): this -# repository is the manifest SOURCE, not a sync target. It tracks that component -# except where a documented constraint forces a deviation — see the trigger, -# concurrency, and runner notes below. +# Repo-local rather than the sync-managed `claude-review-hosted-caller` +# component (melodic-software/standards, +# components/claude-lanes-hosted/claude-review.yml): this repository is the +# manifest SOURCE, not a sync target. It tracks that component except where a +# documented choice differs (this caller passes no `allowed-bot-sender-ids`). # -# The reusable skips drafts, fork PRs (they receive no secrets and a read-only -# token) and every `[bot]` actor, so none of them is reviewed by design. +# The reusable runs on GitHub-hosted `ubuntu-24.04` (this repository is +# PUBLIC) and skips drafts, fork PRs (they receive no secrets and a read-only +# token), Dependabot, and every `[bot]` actor, so none of them is reviewed by +# design. on: pull_request: # `synchronize` reviews every push, including the push that resolves a - # merge conflict, matching components/claude-lanes/claude-review.yml: + # merge conflict, matching components/claude-lanes-hosted/claude-review.yml: # GitHub runs no pull_request workflow while a PR conflicts with its base. # # Re-running the job does NOT review a newer head: a re-run replays the @@ -46,19 +49,14 @@ jobs: # ready_for_review trigger above is what delivers one when it is ready. if: github.event.pull_request.draft == false permissions: + actions: read # check-key-credit reads its marker; Publish Review reads this workflow's runs + checks: read # Publish Review reads its earlier runs' cost notices contents: read # checkout + read the diff - pull-requests: write # post review + track_progress tracking comment - id-token: write # OIDC — mints the Claude GitHub App token (required - # even with an OAuth/API-key credential) - uses: melodic-software/ci-workflows/.github/workflows/pr-review.yml@main + pull-requests: write # post review, comments, and the lane's reviewed-head marker comment + uses: melodic-software/ci-workflows/.github/workflows/pr-review-cli.yml@main with: - # Names (never the value) the fallback secret in the lane-outcome record. - fallback-credential-name: FALLBACK_CLAUDE_CODE_OAUTH_TOKEN - # DEVIATION from the component, which names the managed fleet label: - # this repository is PUBLIC, and runner-policy admits a fleet label only - # for an enrolled private consumer (`public-self-hosted-routing` - # otherwise), so this caller pins the approved hosted label directly. - runner: ubuntu-24.04 + lane: code + publish: comments # People whose closing issues the review reads in full, by numeric user # id: the `human` entries of components/trusted-actors/trusted-actors.json. # trusted-actors.test.mjs fails when this value, or the one in either @@ -70,8 +68,6 @@ jobs: # Pass only the named secrets (least privilege) rather than `secrets: # inherit`, which would forward every parent secret to the called workflow. secrets: - CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # The central fallback subscription: the review retries once on it after - # a usage limit on the token above. + CLAUDE_API_KEY: ${{ secrets.REVIEWS_CLAUDE_API_KEY }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.REVIEWS_CLAUDE_CODE_OAUTH_TOKEN }} FALLBACK_CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.FALLBACK_CLAUDE_CODE_OAUTH_TOKEN }} - diff --git a/components/claude-lanes-hosted/claude-review.yml b/components/claude-lanes-hosted/claude-review.yml index 09b0898f..55c89773 100644 --- a/components/claude-lanes-hosted/claude-review.yml +++ b/components/claude-lanes-hosted/claude-review.yml @@ -1,6 +1,6 @@ name: PR Review Hosted -# SYNC-MANAGED FILE: DO NOT EDIT IN THE CONSUMING REPOSITORY. +# SYNC-MANAGED FILE — DO NOT EDIT IN THE CONSUMING REPOSITORY. # Source of truth: melodic-software/standards, # components/claude-lanes-hosted/claude-review.yml (the # `claude-review-hosted-caller` component in distribution/sync-manifest.yml). @@ -8,31 +8,26 @@ name: PR Review Hosted # upstream, or move the component to `locally-owned` in the manifest to # customize. # -# Thin caller for the org's reusable code-review lane. The reusable workflow -# owns the action pin, model, and the secret-handling model; per its header, -# this caller owns the triggers, concurrency, and the GITHUB_TOKEN permission -# grant (a called workflow can only downgrade the caller's grant, never -# elevate it). +# Thin caller for the org's pr-review-cli reusable, lane `code`. The reusable +# workflow owns the launcher, the credential order (the reviews role's API key, +# then its subscription token after a handoff, then the central fallback +# subscription), and the secret-handling model; per its header, this caller +# owns the triggers, concurrency, and the GITHUB_TOKEN permission grant (a +# called workflow can only downgrade the caller's grant, never elevate it). # -# The reusable skips fork PRs (they receive no secrets and a read-only token) -# and every `[bot]` actor whose sender id is not in `allowed-bot-sender-ids` -# (below), so neither is reviewed by design. On a public repository that means -# the lane reviews only pull requests from branches of this repository: fork -# and Dependabot pull requests get no secrets. +# The reusable skips fork PRs (they receive no secrets and a read-only token), +# Dependabot, and every `[bot]` actor whose sender id is not in +# `allowed-bot-sender-ids` (below), so none is reviewed by design. On a public +# repository that means the lane reviews only pull requests from branches of +# this repository: fork and Dependabot pull requests get no secrets. # -# RUNNER PLACEMENT: hosted shape. This file runs the lane on the GitHub-hosted -# `ubuntu-24.04` runner, which the standards `runner-policy` component admits -# on a public repository. It is the hosted sibling of -# components/claude-lanes/claude-review.yml, which names the private fleet -# review label, and differs from it only in these comments, `runner` and the -# workflow `name:`, which is each file's stem in Title Case. The job id is the same, so -# the check context is the same on every target. A target manages one of the -# two, never both. -# -# INTERIM: this per-visibility pair is removed when the runner choice moves -# inside the ci-workflows reusable and runner-policy gains a cross-repo -# routing kind, so one caller serves both visibilities -# (distribution/sync-manifest.yml, the claude lane caller note). +# RUNNER PLACEMENT: hosted shape. Every job of pr-review-cli.yml runs on +# GitHub-hosted `ubuntu-24.04` (it takes no `runner` input), which the +# standards `runner-policy` component admits on a public repository. It is the +# hosted sibling of components/claude-lanes/claude-review.yml. The workflow +# `name:` is the destination file's stem in Title Case and the job id stays +# `pr-review`, keeping the `PR Review / Publish Review` check context on every +# target. A target manages one of the two, never both. # # This lane is advisory (github-iac ADR 0011: no organization ruleset may make # an agentic review a merge prerequisite). @@ -77,16 +72,14 @@ jobs: # ready_for_review trigger above is what delivers one when it is ready. if: github.event.pull_request.draft == false permissions: + actions: read # check-key-credit reads its marker; Publish Review reads this workflow's runs + checks: read # Publish Review reads its earlier runs' cost notices contents: read # checkout + read the diff - pull-requests: write # post review, tracking comment and the lane's - # reviewed-head marker comment - id-token: write # OIDC, mints the Claude GitHub App token (required - # even with an OAuth/API-key credential) - uses: melodic-software/ci-workflows/.github/workflows/pr-review.yml@main + pull-requests: write # post review, comments, and the lane's reviewed-head marker comment + uses: melodic-software/ci-workflows/.github/workflows/pr-review-cli.yml@main with: - # Names (never the value) the fallback secret in the lane-outcome record. - fallback-credential-name: FALLBACK_CLAUDE_CODE_OAUTH_TOKEN - runner: ubuntu-24.04 + lane: code + publish: comments # Bot senders this lane reviews, by numeric user id: the # automation-lanes App, so a commit it pushes to a pull request is # reviewed. Where the repository does not set this variable the value is @@ -102,9 +95,9 @@ jobs: allowed-author-ids: '153232337' # Pass only the named secrets (least privilege) rather than # `secrets: inherit`, which would forward every parent secret to the - # called workflow. + # called workflow. The reviews role's API key runs first, then its + # subscription token after a handoff, then the central fallback subscription. secrets: - CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # The central fallback subscription: the review retries once on it after - # a usage limit on the token above. + CLAUDE_API_KEY: ${{ secrets.REVIEWS_CLAUDE_API_KEY }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.REVIEWS_CLAUDE_CODE_OAUTH_TOKEN }} FALLBACK_CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.FALLBACK_CLAUDE_CODE_OAUTH_TOKEN }} diff --git a/components/claude-lanes-hosted/claude-security-review.yml b/components/claude-lanes-hosted/claude-security-review.yml index 7d7daa90..80e97fcc 100644 --- a/components/claude-lanes-hosted/claude-security-review.yml +++ b/components/claude-lanes-hosted/claude-security-review.yml @@ -1,6 +1,6 @@ name: PR Review Security Hosted -# SYNC-MANAGED FILE: DO NOT EDIT IN THE CONSUMING REPOSITORY. +# SYNC-MANAGED FILE — DO NOT EDIT IN THE CONSUMING REPOSITORY. # Source of truth: melodic-software/standards, # components/claude-lanes-hosted/claude-security-review.yml (the # `claude-security-review-hosted-caller` component in @@ -9,32 +9,35 @@ name: PR Review Security Hosted # upstream, or move the component to `locally-owned` in the manifest to # customize. # -# Thin caller for the org's reusable security-review lane (advisory verdict, -# fail-closed execution check). The reusable workflow owns the action pin, -# model, and the secret-handling model; per its header, this caller owns the -# triggers, concurrency, and the GITHUB_TOKEN permission grant. +# Thin caller for the org's pr-review-cli reusable, lane `security` (advisory +# verdict, fail-closed execution check). The reusable workflow owns the +# launcher, the credential order (the reviews role's API key, then its +# subscription token after a handoff, then the central fallback subscription), +# and the secret-handling model; per its header, this caller owns the triggers, +# concurrency, and the GITHUB_TOKEN permission grant. # -# There is no workflow-level path gating. The reusable skips, with a green -# check, a review whose files in scope are all documentation (its -# `docs-only-paths` default: `docs/**/*.md`, READMEs and changelogs). A +# There is no workflow-level path gating. `docs-only-paths` below skips, with +# a green check, a review whose files in scope are all documentation +# (`docs/**/*.md`, READMEs and changelogs), matching the legacy security +# reusable's default (pr-review-cli.yml defaults empty). A # `.github/claude-security-paths` file has no effect. # # NEVER add workflow-level `paths:`/`paths-ignore:` to this caller: a check # whose workflow never triggers is missing, not green, so a required check # would stay Pending forever, and the babysit merge gate, which waits for -# `PR Review Security / Claude`, never arms. +# `PR Review Security / Publish Review`, never arms. # -# The reusable skips fork PRs (they receive no secrets and a read-only token) -# and every `[bot]` actor whose sender id is not in `allowed-bot-sender-ids` -# (below); a required check does NOT prove a fork PR was reviewed (see the -# reusable's header). On a public repository the lane reviews only pull -# requests from branches of this repository: fork and Dependabot pull requests -# get no secrets. +# The reusable skips fork PRs (they receive no secrets and a read-only token), +# Dependabot, and every `[bot]` actor whose sender id is not in +# `allowed-bot-sender-ids` (below); a required check does NOT prove a fork PR +# was reviewed (see the reusable's header). On a public repository the lane +# reviews only pull requests from branches of this repository: fork and +# Dependabot pull requests get no secrets. # -# RUNNER PLACEMENT: hosted shape, the sibling of -# components/claude-lanes/claude-security-review.yml, differing from it only -# in these comments, `runner` and the workflow `name:`. It is an interim with -# the same removal trigger as the code-review caller. See that file's header. +# RUNNER PLACEMENT: hosted shape. Every job of pr-review-cli.yml runs on +# GitHub-hosted `ubuntu-24.04` (it takes no `runner` input), which the +# standards `runner-policy` component admits on a public repository. It is the +# hosted sibling of components/claude-lanes/claude-security-review.yml. on: pull_request: @@ -46,7 +49,7 @@ on: # from making an agentic review a merge or deployment prerequisite. With # the per-PR group below cancelling, a push supersedes the in-flight review. # - # NO `merge_group:`: the pinned action cannot serve that event; see + # NO `merge_group:`: the reusable runs only on `pull_request`; see # melodic-software/ci-workflows#272 before enabling a merge queue. types: [opened, synchronize, ready_for_review, reopened] @@ -70,16 +73,18 @@ jobs: # ready_for_review trigger above is what delivers one when it is ready. if: github.event.pull_request.draft == false permissions: + actions: read # check-key-credit reads its marker; Publish Review reads this workflow's runs + checks: read # Publish Review reads its earlier runs' cost notices contents: read # checkout + read the diff - pull-requests: write # post the security review, tracking comment and - # the lane's reviewed-head marker comment - id-token: write # OIDC, mints the Claude GitHub App token (required - # even with an OAuth/API-key credential) - uses: melodic-software/ci-workflows/.github/workflows/pr-review-security.yml@main + pull-requests: write # post the security review, comments, and the lane's reviewed-head marker comment + uses: melodic-software/ci-workflows/.github/workflows/pr-review-cli.yml@main with: - # Names (never the value) the fallback secret in the lane-outcome record. - fallback-credential-name: FALLBACK_CLAUDE_CODE_OAUTH_TOKEN - runner: ubuntu-24.04 + lane: security + publish: comments + docs-only-paths: | + docs/**/*.md + **/README.md + **/CHANGELOG.md # Bot senders this lane reviews, by numeric user id: the # automation-lanes App, so a commit it pushes to a pull request is # reviewed. Where the repository does not set this variable the value is @@ -87,9 +92,9 @@ jobs: allowed-bot-sender-ids: ${{ vars.AUTOMATION_LANES_APP_SENDER_ID }} # Pass only the named secrets (least privilege) rather than # `secrets: inherit`, which would forward every parent secret to the - # called workflow. + # called workflow. The reviews role's API key runs first, then its + # subscription token after a handoff, then the central fallback subscription. secrets: - CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # The central fallback subscription: the review retries once on it after - # a usage limit on the token above. + CLAUDE_API_KEY: ${{ secrets.REVIEWS_CLAUDE_API_KEY }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.REVIEWS_CLAUDE_CODE_OAUTH_TOKEN }} FALLBACK_CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.FALLBACK_CLAUDE_CODE_OAUTH_TOKEN }} diff --git a/components/runner-policy/runner-policy.test.mjs b/components/runner-policy/runner-policy.test.mjs index e63fdf73..4a407314 100644 --- a/components/runner-policy/runner-policy.test.mjs +++ b/components/runner-policy/runner-policy.test.mjs @@ -6623,42 +6623,65 @@ ${secrets.length > 0 ? ` secrets:\n${block(secrets, " ")}\n` : ""}`, assert.equal(asserted, 6); }); -// The hosted lane callers (components/claude-lanes-hosted/) are the public -// shape of the fleet callers: same bytes except comments and a hosted -// `runner`, managed only for public targets, and never beside the fleet +// The hosted lane callers (components/claude-lanes-hosted/) call the hosted-only +// pr-review-cli.yml reusable (lane `code` / `security`, API-key-first secret +// contract), managed only for public targets, and never beside the fleet // variant of the same lane (distribution/sync-manifest.yml, the public-shape // note). const HOSTED_LANE_DIR = "components/claude-lanes-hosted/"; -function withoutComments(body) { - return body - .split("\n") - .filter((line) => !/^\s*#/u.test(line)) - .map((line) => line.replace(/\s+#.*$/u, "")) - .join("\n"); -} - // The workflow `name:` is each destination's stem in Title Case, so the hosted -// file's name is its fleet sibling's plus ` Hosted`; the job ids, and so the -// check contexts, stay the same. -test("each hosted claude lane caller equals its fleet sibling except for comments, runner and the Hosted name", async () => { +// file's name is its fleet sibling's plus ` Hosted`; the job ids stay the same +// (`pr-review` / `pr-review-security`). +test("each hosted claude lane caller calls pr-review-cli with the expected lane, secrets and Hosted name", async () => { const hosted = await claudeLaneCallerComponents(HOSTED_LANE_DIR); assert.equal(hosted.length, 2, "expected a hosted code-review and security-review caller"); for (const { source, body } of hosted) { const fleetSource = source.replace(HOSTED_LANE_DIR, "components/claude-lanes/"); const fleet = await readFile(new URL(`../../${fleetSource}`, import.meta.url), "utf8"); - assert.match(body, /^ {6}runner: ubuntu-24\.04$/mu, `${source} must run on ubuntu-24.04`); const fleetName = fleet.match(/^name: (.+)$/mu)?.[1]; assert.ok(fleetName, `${fleetSource} has no workflow name`); assert.match(body, new RegExp(`^name: ${fleetName} Hosted$`, "mu"), `${source} name`); - const normalize = (text) => - withoutComments(text) - .replace(/^( {6}runner:) \S+$/mu, "$1") - .replace(/^name: .+$/mu, "name:"); + const parsed = parse(body); + const fleetParsed = parse(fleet); + assert.deepEqual( + Object.keys(parsed.jobs), + Object.keys(fleetParsed.jobs), + `${source} job ids must match ${fleetSource}`, + ); + const [jobId] = Object.keys(parsed.jobs); + const job = parsed.jobs[jobId]; + const expectedLane = source.endsWith("claude-security-review.yml") ? "security" : "code"; assert.equal( - normalize(body), - normalize(fleet), - `${source} drifted from ${fleetSource} beyond comments, runner and name`, + job.uses, + "melodic-software/ci-workflows/.github/workflows/pr-review-cli.yml@main", + `${source} must call pr-review-cli.yml@main`, + ); + assert.equal(job.with?.lane, expectedLane, `${source} lane input`); + assert.equal(job.with?.publish, "comments", `${source} publish input`); + assert.equal( + job.with?.runner, + undefined, + `${source} must not pass runner to pr-review-cli.yml`, + ); + assert.deepEqual( + job.permissions, + { + actions: "read", + checks: "read", + contents: "read", + "pull-requests": "write", + }, + `${source} caller permissions`, + ); + assert.deepEqual( + job.secrets, + { + CLAUDE_API_KEY: `\${{ secrets.REVIEWS_CLAUDE_API_KEY }}`, + CLAUDE_CODE_OAUTH_TOKEN: `\${{ secrets.REVIEWS_CLAUDE_CODE_OAUTH_TOKEN }}`, + FALLBACK_CLAUDE_CODE_OAUTH_TOKEN: `\${{ secrets.FALLBACK_CLAUDE_CODE_OAUTH_TOKEN }}`, + }, + `${source} review secrets`, ); } }); diff --git a/distribution/README.md b/distribution/README.md index 8ead4162..7f83ef50 100644 --- a/distribution/README.md +++ b/distribution/README.md @@ -371,14 +371,17 @@ differently for each lane: advisory lanes. Public repos, `claude-code-plugins` and `ci-workflows` among them, remain ineligible for the fleet-routed shape. -Public targets take a hosted pair instead, as an interim (#622): +Public targets take the hosted pair: `claude-review-hosted-caller` and `claude-security-review-hosted-caller`, sourced from `components/claude-lanes-hosted/` and materialized at `.github/workflows/pr-review-hosted.yml` and -`.github/workflows/pr-review-security-hosted.yml`. Each file equals its -fleet sibling except for comments, `runner: ubuntu-24.04` and the workflow -`name:`, which is each file's stem in Title Case; the job ids match, so the check -contexts do too. The destinations differ because +`.github/workflows/pr-review-security-hosted.yml`. Both call +`ci-workflows`' hosted-only `pr-review-cli.yml@main` (`lane: code` / +`lane: security`, running on GitHub-hosted `ubuntu-24.04` with API-key-first +routing via `REVIEWS_CLAUDE_API_KEY`, `REVIEWS_CLAUDE_CODE_OAUTH_TOKEN`, and +`FALLBACK_CLAUDE_CODE_OAUTH_TOKEN`), with the workflow `name:` set to each +destination file's stem in Title Case and the same job ids (`pr-review` / +`pr-review-security`). The destinations differ because a destination has one owning component. They are `managed` for .github, agent-plugins, ci-runner, claude-code-account-rotation, codex-plugins and cursor-plugins. @@ -404,9 +407,10 @@ constraint, now stated over the fleet literal rather than the retired selector: "fleet-routed claude lane callers are not managed for a public sync target", "claude lane caller components pass runner policy for a private self-hosted consumer", and "a fleet-routed claude lane caller is rejected outright on a -public consumer". Three more hold the hosted pair: it equals its fleet sibling -except for comments, `runner` and the `-hosted` name, every target managing it is public and -audits clean, and no target manages both variants of one lane. +public consumer". Three more hold the hosted pair: each calls `pr-review-cli.yml@main` with the +expected lane, permissions, org review secrets, job id and `Hosted` workflow +name, every target managing it is public and audits clean, and no target +manages both variants of one lane. Public/shared-shape removal trigger: moving the runner indirection inside the `ci-workflows` reusable is necessary but not sufficient for one managed diff --git a/distribution/sync-manifest.yml b/distribution/sync-manifest.yml index 588f34bf..62fab42e 100644 --- a/distribution/sync-manifest.yml +++ b/distribution/sync-manifest.yml @@ -75,15 +75,18 @@ components: # review lane over untrusted third-party content — and then for a security # or content-scanning lane, not for claude-review as written. # - # PUBLIC SHAPE, ACCEPTED AS AN INTERIM (#622): `claude-review-hosted-caller` - # and `claude-security-review-hosted-caller`, sourced from - # `components/claude-lanes-hosted/`. Each file equals its fleet sibling - # except for comments and `runner: ubuntu-24.04`, which runner-policy admits - # on a public repository and GitHub recommends there (self-hosted runners - # "should almost never be used for public repositories", - # docs.github.com/en/actions/reference/security/secure-use). Same job ids, - # so the check contexts match the fleet callers. The destinations differ - # (`.github/workflows/pr-review-hosted.yml`, + # PUBLIC SHAPE (`claude-review-hosted-caller` and + # `claude-security-review-hosted-caller`), sourced from + # `components/claude-lanes-hosted/`: both call `pr-review-cli.yml@main` + # (`lane: code` / `lane: security`), which is hosted-only (`ubuntu-24.04` + # inside the reusable, no `runner` input) and runs the reviews role's API key + # first, then its subscription token, then `FALLBACK_CLAUDE_CODE_OAUTH_TOKEN` + # (melodic-software/control-hub#13). runner-policy admits `pr-review-cli.yml` + # on public repositories, matching GitHub's recommendation against self-hosted + # runners on public repos + # (docs.github.com/en/actions/reference/security/secure-use). Same job ids as + # the fleet callers (`pr-review` / `pr-review-security`). The destinations + # differ (`.github/workflows/pr-review-hosted.yml`, # `.github/workflows/pr-review-security-hosted.yml`) because a destination # has exactly one owning component; each workflow `name:` is its stem in Title Case. The files live outside # `components/claude-lanes/` so the fleet-only runner-policy tests keyed on From 29538b7f5204b0be5a39d34a1da5b888befe6919 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:55:10 -0500 Subject: [PATCH 2/2] fix(runner-policy): preserve shared hosted/fleet parity assertions and clarify check-name comment --- .../claude-lanes-hosted/claude-review.yml | 6 ++-- .../runner-policy/runner-policy.test.mjs | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/components/claude-lanes-hosted/claude-review.yml b/components/claude-lanes-hosted/claude-review.yml index 55c89773..7e141a72 100644 --- a/components/claude-lanes-hosted/claude-review.yml +++ b/components/claude-lanes-hosted/claude-review.yml @@ -26,8 +26,10 @@ name: PR Review Hosted # standards `runner-policy` component admits on a public repository. It is the # hosted sibling of components/claude-lanes/claude-review.yml. The workflow # `name:` is the destination file's stem in Title Case and the job id stays -# `pr-review`, keeping the `PR Review / Publish Review` check context on every -# target. A target manages one of the two, never both. +# `pr-review`; this hosted caller reports `PR Review / Publish Review` (the +# fleet sibling still reports `PR Review / Claude` until private callers +# migrate, and the org's review-lane check lists accept both). A target manages +# one of the two, never both. # # This lane is advisory (github-iac ADR 0011: no organization ruleset may make # an agentic review a merge prerequisite). diff --git a/components/runner-policy/runner-policy.test.mjs b/components/runner-policy/runner-policy.test.mjs index 4a407314..bfc39e46 100644 --- a/components/runner-policy/runner-policy.test.mjs +++ b/components/runner-policy/runner-policy.test.mjs @@ -6651,6 +6651,30 @@ test("each hosted claude lane caller calls pr-review-cli with the expected lane, ); const [jobId] = Object.keys(parsed.jobs); const job = parsed.jobs[jobId]; + const fleetJob = fleetParsed.jobs[jobId]; + assert.deepEqual(parsed.on, fleetParsed.on, `${source} triggers must match ${fleetSource}`); + assert.deepEqual( + parsed.permissions, + fleetParsed.permissions, + `${source} top-level permissions must match ${fleetSource}`, + ); + assert.deepEqual( + parsed.concurrency, + fleetParsed.concurrency, + `${source} concurrency must match ${fleetSource}`, + ); + assert.equal(job.name, fleetJob.name, `${source} job name must match ${fleetSource}`); + assert.equal(job.if, fleetJob.if, `${source} job condition must match ${fleetSource}`); + assert.equal( + job.with?.["allowed-bot-sender-ids"], + fleetJob.with?.["allowed-bot-sender-ids"], + `${source} allowed-bot-sender-ids must match ${fleetSource}`, + ); + assert.equal( + job.with?.["allowed-author-ids"], + fleetJob.with?.["allowed-author-ids"], + `${source} allowed-author-ids must match ${fleetSource}`, + ); const expectedLane = source.endsWith("claude-security-review.yml") ? "security" : "code"; assert.equal( job.uses, @@ -6659,6 +6683,13 @@ test("each hosted claude lane caller calls pr-review-cli with the expected lane, ); assert.equal(job.with?.lane, expectedLane, `${source} lane input`); assert.equal(job.with?.publish, "comments", `${source} publish input`); + if (expectedLane === "security") { + assert.equal( + job.with?.["docs-only-paths"], + "docs/**/*.md\n**/README.md\n**/CHANGELOG.md\n", + `${source} docs-only-paths must preserve legacy security default`, + ); + } assert.equal( job.with?.runner, undefined,