diff options
| author | Claude <noreply@anthropic.com> | 2026-12-03 17:22:15 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-12-03 17:22:15 +0000 |
| commit | a7a063b80923a8abbf3fb9354286f73a007709c5 (patch) | |
| tree | 36b079f5c06cd4b0a62758462fa1cb523b7d6c4f /.github/workflows | |
| parent | e599fbcef8b361848e833ec5e3f5de10f450dac7 (diff) | |
Replace operational CI with a basic build checkclaude/beautiful-noether-ig0090
Remove the SHA bump, failed-bump revert, plugin scan, plugin validation and
MCP URL workflows, and the scripts and policy files only they used. Add one
Build workflow that checks marketplace.json and the local plugin folders with
no network calls, model calls or secrets. The license check and the external
PR closer stay.
Co-authored-by: tobin <tobin@anthropic.com>
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/build.yml | 71 | ||||
| -rw-r--r-- | .github/workflows/bump-plugin-shas.yml | 110 | ||||
| -rw-r--r-- | .github/workflows/check-mcp-urls.yml | 131 | ||||
| -rw-r--r-- | .github/workflows/revert-failed-bumps.yml | 284 | ||||
| -rw-r--r-- | .github/workflows/scan-plugins.yml | 595 | ||||
| -rw-r--r-- | .github/workflows/validate-plugins.yml | 91 |
6 files changed, 71 insertions, 1211 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..4413481c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: Build + +# A basic check that the marketplace still loads. It runs no scans, calls no +# model or external service, and needs no secrets. + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: build-${{ github.event.pull_request.number || github.ref }} + # Keep every run on main, so each merged commit gets a result. + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + # Pinned so a new CLI release can't turn this check red on its own. + CLAUDE_CODE_VERSION: 2.1.332 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install Claude Code + run: | + # npm can exit 0 without the native binary, or hang, so check that + # `claude` runs before calling an attempt good. + for attempt in 1 2 3; do + timeout 180 npm install -g --include=optional "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \ + && claude --version && exit 0 + echo "Install attempt $attempt failed, retrying in 10s" + sleep 10 + done + exit 1 + + - name: Check local plugin folders + run: | + # The CLI's marketplace check doesn't open the JSON files inside each + # plugin folder, and a broken one stops the plugin from loading. + root="$(jq -r '.metadata.pluginRoot // "."' .claude-plugin/marketplace.json)" + dirs="$(jq -r '.plugins[] | select(.source | type == "string") | .source' .claude-plugin/marketplace.json)" + failed=0 + while IFS= read -r dir; do + [[ -n "$dir" ]] || continue + path="$root/$dir" + if [[ ! -d "$path" ]]; then + echo "::error file=.claude-plugin/marketplace.json::Plugin source folder not found: $dir" + failed=1 + continue + fi + for file in .claude-plugin/plugin.json .mcp.json .lsp.json hooks/hooks.json; do + if [[ -f "$path/$file" ]] && ! jq empty "$path/$file" 2>/dev/null; then + echo "::error file=$path/$file::Not valid JSON" + failed=1 + fi + done + done <<< "$dirs" + exit "$failed" + + - name: Validate marketplace + run: claude plugin validate .claude-plugin/marketplace.json diff --git a/.github/workflows/bump-plugin-shas.yml b/.github/workflows/bump-plugin-shas.yml deleted file mode 100644 index 8e6f67a2..00000000 --- a/.github/workflows/bump-plugin-shas.yml +++ /dev/null @@ -1,110 +0,0 @@ -name: Bump Plugin SHAs - -# Nightly sweep: for each external entry whose upstream HEAD has moved past -# its pinned SHA, validate at the new SHA with `claude plugin validate` -# inline, then open one PR per bumped plugin on branch `bump/<slug>`. -# Failing entries stay isolated in their own PR; passing bumps merge -# independently. -# -# Bot-free — uses the default GITHUB_TOKEN. PRs opened with GITHUB_TOKEN don't -# trigger on:pull_request workflows, so the required status checks on main -# (`scan` from Scan Plugins, `check` from Check MCP URLs, `validate` from -# Validate Plugins) would never run and the bump PR could never merge. -# workflow_dispatch is exempt from that recursion guard, so we dispatch all -# three ourselves against each per-entry bump branch after its PR is opened. -# Each check run lands on the branch HEAD — the same SHA as the PR head — and -# satisfies the corresponding required check. (Each of those workflows runs -# its job unconditionally on workflow_dispatch, so a dispatch always reports.) -# -# max-bumps caps the per-night work for cost control. Per-entry scans are -# more expensive than a single batched scan, so the cap is conservative. -# Raised 30 -> 60 (2026-09): with ~290 external entries and ~15 upstream -# movers a day plus re-bumps of stale merges, 30 was hit on consecutive -# nights and late-alphabet entries went unbumped for days (discovery walks -# the manifest in order and stops at the cap). -# The composite action skips entries that already have an open bump PR, so -# re-dispatches don't pile up duplicate work. - -on: - schedule: - - cron: '23 7 * * *' # Daily 07:23 UTC - workflow_dispatch: - inputs: - max_bumps: - description: Cap on plugins bumped this run - required: false - default: '60' - plugin: - description: >- - Bump ONLY this plugin name (exact entry name; empty = all stale). A - frozen/sha-exempt target is still skipped (same as a full run). - required: false - default: '' - -permissions: - contents: write - pull-requests: write - actions: write # gh workflow run {scan-plugins,check-mcp-urls,validate-plugins}.yml per bump branch - -concurrency: - group: bump-plugin-shas - -jobs: - bump: - runs-on: ubuntu-latest - # Per-bump cost is ~2s (ls-remote + shallow clone + validate); 60 entries - # is ~2-4 min. The 60 min ceiling absorbs slow upstreams without letting a - # pathological run consume the default 360 min budget. - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - # createCommitOnBranch-based bump so commits are signed by GitHub and - # satisfy the org-level required_signatures ruleset on main. - - uses: anthropics/claude-plugins-community/.github/actions/bump-plugin-shas@24479d5a1fb7a1c4f068a6d3b74d0c0fbc1acfda - id: bump - with: - marketplace-path: .claude-plugin/marketplace.json - max-bumps: ${{ inputs.max_bumps || '60' }} - only: ${{ inputs.plugin }} - pr-mode: per-entry - # Entries listed in .github/bump-tracking.json {"releases-only": [...]} - # bump to the latest published release tag's commit instead of HEAD - # (no release / not-ahead / lookup failure -> pin held; see the action - # README). All other entries HEAD-track exactly as before. - tracking-config: .github/bump-tracking.json - claude-cli-version: latest - - # Per-entry fan-out: dispatch the three required checks against each bump - # branch. `pr-urls` is a JSON array of {name, old_sha, new_sha, branch, - # pr_url} entries emitted by the composite action when pr-mode is - # per-entry. All three (scan / check / validate) are required on main and - # none fire on the GITHUB_TOKEN-opened PR, so each must be dispatched. - # A single failed dispatch (transient API error / rate limit) must not - # strand the remaining branches, so we attempt every dispatch, then fail - # the step if any failed: a missing required check would otherwise leave - # its bump PR silently blocked behind a green run, and the composite - # action skips slugs with an open PR so it would never be retried. - - name: Dispatch required checks per per-entry PR - if: steps.bump.outputs.pr-urls != '' && steps.bump.outputs.pr-urls != '[]' - env: - GH_TOKEN: ${{ github.token }} - PR_URLS: ${{ steps.bump.outputs.pr-urls }} - run: | - set -euo pipefail - dispatch_failures="$(mktemp)" - jq -c '.[]' <<<"$PR_URLS" | while read -r entry; do - branch=$(jq -r '.branch' <<<"$entry") - name=$(jq -r '.name' <<<"$entry") - for wf in scan-plugins check-mcp-urls validate-plugins; do - echo "Dispatching ${wf}.yml against $branch ($name)" - if ! gh workflow run "${wf}.yml" --ref "$branch"; then - echo "::error::Failed to dispatch ${wf}.yml against $branch ($name) — required check will be missing; re-dispatch with: gh workflow run ${wf}.yml --ref $branch" - echo "${wf} ${branch}" >> "$dispatch_failures" - fi - done - done - if [ -s "$dispatch_failures" ]; then - echo "::error::$(wc -l < "$dispatch_failures" | tr -d ' ') required-check dispatch(es) failed; the affected bump PR(s) are blocked until re-dispatched (see annotations above)." - exit 1 - fi diff --git a/.github/workflows/check-mcp-urls.yml b/.github/workflows/check-mcp-urls.yml deleted file mode 100644 index c2ad8a9c..00000000 --- a/.github/workflows/check-mcp-urls.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: Check MCP URLs - -# Liveness check for http/sse MCP server URLs declared by the plugins in this -# repository (.github/scripts/plugin-dirs.sh). Catches typos, and endpoints -# that disappear after merge. -# -# What counts as "alive": anything that proves the hostname/path resolves to -# a server. 401/403/405/5xx all pass — auth and method errors are expected -# without credentials. Only 404/410 and connection/DNS/TLS failures fail. - -on: - pull_request: - paths: - - 'plugins/**' - - 'external_plugins/**' - - '.github/scripts/plugin-dirs.sh' - - '.github/workflows/check-mcp-urls.yml' - schedule: - - cron: '0 6 * * *' - workflow_dispatch: - -permissions: - contents: read - -jobs: - check: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v4 - - - name: Discover and probe MCP server URLs - run: | - set -euo pipefail - - # Each line: "<plugin>\t<server>\t<url>". - discover() { - bash .github/scripts/plugin-dirs.sh | - while IFS= read -r dir; do - plugin="${dir##*/}" - for cfg in "$dir/.mcp.json" "$dir/mcp.json" "$dir/.claude-plugin/plugin.json"; do - [[ -f "$cfg" ]] || continue - # MCP config comes in two shapes: a bare map of server name -> - # config, or wrapped under a top-level "mcpServers" key (also - # the shape inside plugin.json). Normalize, then keep entries - # with an http/sse type and a string url. - # Skip entries with empty url — those are placeholders awaiting - # user config, not dead endpoints, and would false-fail. - jq -r --arg plugin "$plugin" ' - (if (type == "object" and has("mcpServers")) then .mcpServers else . end) - | to_entries[] - | select((.value | type) == "object") - | select(.value.type == "http" or .value.type == "sse") - | select(.value.url | type == "string" and . != "") - | "\($plugin)\t\(.key)\t\(.value.url)" - ' "$cfg" 2>/dev/null || true - done - done | sort -u - } - - # Returns 0 on pass, 1 on fail; prints "PASS|FAIL <code> <note>". - probe() { - local url="$1" - local code - # HEAD first — cheap and covers plain web endpoints. -L follows - # redirects so a permanent redirect to a live page still passes. - # - # On a connection-level failure curl writes "000" to -w AND exits - # nonzero. The fallback assignment must happen OUTSIDE the command - # substitution — `... || echo "000"` inside $() would *append* a - # second "000", producing "000000" which falls through the case - # statement and silently passes a dead host. - code="$(curl -sS -o /dev/null -w '%{http_code}' \ - --connect-timeout 10 --max-time 10 \ - --retry 2 --retry-delay 2 \ - -L -I "$url" 2>/dev/null)" || code="000" - - # MCP endpoints typically reject HEAD (404/405) but answer POST - # with a JSON-RPC body. Retry as a real MCP client would. - if [[ "$code" == "000" || "$code" == "404" || "$code" == "405" ]]; then - code="$(curl -sS -o /dev/null -w '%{http_code}' \ - --connect-timeout 10 --max-time 10 \ - --retry 2 --retry-delay 2 \ - -L -X POST \ - -H 'Content-Type: application/json' \ - -H 'Accept: application/json, text/event-stream' \ - --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"ci","version":"0"}}}' \ - "$url" 2>/dev/null)" || code="000" - fi - - case "$code" in - 000) echo "FAIL $code unreachable"; return 1 ;; - 404|410) echo "FAIL $code gone"; return 1 ;; - *) echo "PASS $code"; return 0 ;; - esac - } - - entries="$(discover)" - if [[ -z "$entries" ]]; then - echo "::notice::No http/sse MCP server URLs found in this repository's plugins." - exit 0 - fi - - failures=0 - printf '%-24s %-18s %-52s %s\n' "PLUGIN" "SERVER" "URL" "RESULT" - while IFS=$'\t' read -r plugin server url; do - # Skip URLs with template placeholders — they need user config - # and can't be probed as-is. - if [[ "$url" == *'${'* || "$url" == *'{{'* ]]; then - printf '%-24s %-18s %-52s %s\n' "$plugin" "$server" "$url" "SKIP templated" - continue - fi - # example.com is reserved for documentation, so nothing is ever there. - if [[ "$url" =~ ^https?://([^/:]+\.)?example\.com([/:]|$) ]]; then - printf '%-24s %-18s %-52s %s\n' "$plugin" "$server" "$url" "SKIP example" - continue - fi - result="$(probe "$url")" || true - printf '%-24s %-18s %-52s %s\n' "$plugin" "$server" "$url" "$result" - if [[ "$result" == FAIL* ]]; then - failures=$((failures + 1)) - echo "::error::MCP server URL for plugin '$plugin' (server '$server') is unreachable: $url ($result)" - fi - done <<< "$entries" - - echo - if (( failures > 0 )); then - echo "::error::$failures MCP server URL(s) failed liveness check." - exit 1 - fi - echo "All MCP server URLs reachable." diff --git a/.github/workflows/revert-failed-bumps.yml b/.github/workflows/revert-failed-bumps.yml deleted file mode 100644 index 37cbb4ce..00000000 --- a/.github/workflows/revert-failed-bumps.yml +++ /dev/null @@ -1,284 +0,0 @@ -name: Revert Failed Bumps - -# Drops policy-failing entries from a bump PR so one bad upstream can't -# block the rest. Runs after a Scan Plugins workflow_run on bump/plugin-shas -# concludes with a failure: read the per-entry verdicts the scan uploaded, -# revert just the failing entries' source.sha back to main's pin, push a -# follow-up signed commit, and re-dispatch the scan. The re-dispatched scan -# finds only cached-pass entries in the new diff and goes green in seconds. -# -# Scope and guardrails — this job has contents:write so it must be tight: -# - Only acts on bump/plugin-shas (literal branch match). -# - Only acts when the scan was dispatched (workflow_dispatch event), i.e. -# by bump-plugin-shas.yml. A scan on a regular PR never triggers this. -# - Only reverts source.sha. If any other field in a failing entry differs -# from main, the run aborts — that means the bump branch was tampered -# with and a human needs to look. -# - Bounded at MAX_REVERT_PASSES per night via a PR comment marker; a -# persistent loop means the cache or scan is broken and a human needs -# to look. -# - The revert commit is created with createCommitOnBranch (GitHub-signed, -# compare-and-swap via expectedHeadOid) — no signing key on the runner. - -on: - workflow_run: - workflows: ["Scan Plugins"] - types: [completed] - -permissions: - contents: read - -env: - MARKETPLACE: .claude-plugin/marketplace.json - BUMP_BRANCH: bump/plugin-shas - MAX_REVERT_PASSES: '3' - REVERT_MARKER: '<!-- revert-failed-bumps -->' - -jobs: - revert: - # Tight gate: the triggering scan must be a workflow_dispatch run on the - # bump branch (i.e. the one bump-plugin-shas.yml dispatched) that failed. - # A scan on a regular PR, a passing scan, or a manual dispatch on another - # branch must never reach this job. - if: > - github.event.workflow_run.conclusion == 'failure' && - github.event.workflow_run.event == 'workflow_dispatch' && - github.event.workflow_run.head_branch == 'bump/plugin-shas' - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - contents: write # createCommitOnBranch on bump/plugin-shas - pull-requests: write # comment on / close the bump PR - actions: write # gh workflow run scan-plugins.yml --ref bump/plugin-shas - concurrency: - group: revert-failed-bumps - cancel-in-progress: false - steps: - # The artifact carries run-failed.json (just plugin names) and - # run-verdicts.json (full per-entry verdicts for the PR comment). It is - # uploaded by scan-plugins.yml for every relevant run so we can tell - # "policy failures found" from "scan never ran" (infra error → no revert). - # The artifact won't exist when the scan died before the upload step - # (cache restore error, jq failure, timeout) — that is an infra error, - # not a policy failure, so the right move is to do nothing. The - # download must not fail the job; the next step handles the missing file. - - name: Download scan verdicts - continue-on-error: true - uses: actions/download-artifact@v4 - with: - name: scan-verdicts - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ github.token }} - path: scan-out - - - name: Determine revert set - id: plan - run: | - set -euo pipefail - if [[ ! -f scan-out/run-failed.json ]]; then - echo "::warning::No run-failed.json in scan artifact — nothing to revert." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - if ! jq -e 'type == "array"' scan-out/run-failed.json >/dev/null 2>&1; then - echo "::warning::run-failed.json is not a JSON array — refusing to act." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - fail_count="$(jq 'length' scan-out/run-failed.json)" - if [[ "$fail_count" -eq 0 ]]; then - # The scan job failed but reported zero policy failures: that is - # an infra error (API key missing, clone failure, schema break). - # Reverting nothing is correct; surfacing the infra error is the - # scan job's responsibility. - echo "::notice::Scan failed with zero parsed policy failures — infra error, not a policy failure. Not reverting." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - echo "act=true" >> "$GITHUB_OUTPUT" - echo "fail_count=$fail_count" >> "$GITHUB_OUTPUT" - echo "Failing entries:" - jq -r '.[]' scan-out/run-failed.json - - - name: Locate bump PR and check revert budget - if: steps.plan.outputs.act == 'true' - id: pr - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - run: | - set -euo pipefail - # Resolve the bump PR by head ref. `gh pr list --head <ref>` matches - # by ref name across forks, so reject any PR whose head repo isn't - # ours — a fork PR named bump/plugin-shas must never reach the - # contents:write paths below. - pr_json="$(gh api "repos/$REPO/pulls?head=${REPO%%/*}:$BUMP_BRANCH&base=main&state=open&per_page=1" \ - --jq '.[0] // empty')" - if [[ -z "$pr_json" ]]; then - echo "::warning::No open bump PR on $BUMP_BRANCH — nothing to revert." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - pr_number="$(jq -r '.number' <<<"$pr_json")" - head_repo="$(jq -r '.head.repo.full_name' <<<"$pr_json")" - head_sha="$(jq -r '.head.sha' <<<"$pr_json")" - # The list endpoint omits `commits`; the single-PR endpoint has it. - commit_count="$(gh api "repos/$REPO/pulls/$pr_number" --jq '.commits')" - if [[ "$head_repo" != "$REPO" ]]; then - echo "::error::Bump PR head is from $head_repo, not $REPO — refusing to act." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - # Loop bound: every nightly bump force-resets the branch to a single - # commit and every revert pass adds exactly one. Counting commits is - # therefore the per-night pass count + 1, with no date math, no - # pagination, and no exposure to comment spoofing. - if [[ "$commit_count" -gt $(( MAX_REVERT_PASSES + 1 )) ]]; then - echo "::error::Revert budget exhausted ($((commit_count - 1))/$MAX_REVERT_PASSES passes on this PR). The cache or scan is likely broken — needs a human." - gh pr comment "$pr_number" --repo "$REPO" --body \ - "$REVERT_MARKER"$'\n\n'"⚠️ Revert budget exhausted ($((commit_count - 1)) passes). The scan keeps failing after reverting — likely a cache or scan bug. Pausing automatic reverts until the next nightly bump." - echo "act=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - echo "Bump PR #$pr_number @ $head_sha ($commit_count commit(s))" - { - echo "act=true" - echo "number=$pr_number" - echo "head_sha=$head_sha" - } >> "$GITHUB_OUTPUT" - - - name: Revert failing SHAs - if: steps.plan.outputs.act == 'true' && steps.pr.outputs.act == 'true' - id: revert - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - HEAD_SHA: ${{ steps.pr.outputs.head_sha }} - run: | - set -euo pipefail - mkdir -p work - - gh api "repos/$REPO/contents/${MARKETPLACE}?ref=$HEAD_SHA" --jq '.content' | base64 -d > work/head.json - gh api "repos/$REPO/contents/${MARKETPLACE}?ref=main" --jq '.content' | base64 -d > work/base.json - - # Build the reverted marketplace: for each failing plugin, restore - # source.sha to main's value. Refuse if anything else differs — a - # difference outside source.sha on a bump-branch entry means the - # branch was tampered with. - jq -c -s \ - '.[0] as $head | .[1] as $base | (.[2] | map({(.): true}) | add // {}) as $fail - | ($base.plugins | map({(.name): .}) | add // {}) as $b - | $head | .plugins = [ - .plugins[] | - if ($fail[.name] // false) and ($b[.name] // null) != null then - # Verify the only delta is source.sha — never silently - # accept a structural change masquerading as a bump. - if (. | del(.source.sha)) == ($b[.name] | del(.source.sha)) then - .source.sha = $b[.name].source.sha - else - error("entry \(.name) differs from main beyond source.sha — refusing to revert") - end - else . end - ]' \ - work/head.json work/base.json scan-out/run-failed.json > work/reverted.json.compact - - # Match the marketplace's existing pretty-print so the diff is - # human-reviewable. - jq --indent 2 '.' work/reverted.json.compact > work/reverted.json - - # Two no-action cases: - # - nothing actually reverted (failed names not in this PR's diff) - # - everything reverted (the file is back to main → PR is empty) - if cmp -s work/reverted.json.compact <(jq -c '.' work/head.json); then - echo "::notice::No entries to revert (failing names not in this PR)." - echo "committed=false" >> "$GITHUB_OUTPUT" - echo "empty=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - if cmp -s work/reverted.json.compact <(jq -c '.' work/base.json); then - echo "::warning::Every bumped entry failed policy — the PR would be empty." - echo "committed=false" >> "$GITHUB_OUTPUT" - echo "empty=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - - # Vendored entries have a string `source` — restrict to object - # sources or `.source.sha` errors. - reverted="$(jq -c -s \ - '.[0] as $head | .[1] as $rev - | ($head.plugins | map(select(.source | type == "object") | {(.name): .source.sha}) | add // {}) as $h - | [$rev.plugins[] | select(.source | type == "object") - | select(($h[.name] // null) != .source.sha) | .name]' \ - work/head.json work/reverted.json.compact)" - echo "Reverted: $reverted" - echo "reverted=$reverted" >> "$GITHUB_OUTPUT" - - msg="Drop $(jq 'length' <<<"$reverted") policy-failing entries from bump" - # createCommitOnBranch: GitHub-signed, expectedHeadOid CAS so a - # concurrent force-reset from the nightly bump fails this push - # loudly instead of being clobbered. The base64'd marketplace can - # exceed MAX_ARG_STRLEN, so the body travels via stdin. - oid="$(jq -n \ - --rawfile content work/reverted.json \ - --arg repo "$REPO" \ - --arg branch "$BUMP_BRANCH" \ - --arg oid "$HEAD_SHA" \ - --arg msg "$msg" \ - --arg path "$MARKETPLACE" \ - '{ - query: "mutation($repo:String!,$branch:String!,$oid:GitObjectID!,$msg:String!,$path:String!,$contents:Base64String!){createCommitOnBranch(input:{branch:{repositoryNameWithOwner:$repo,branchName:$branch},message:{headline:$msg},fileChanges:{additions:[{path:$path,contents:$contents}]},expectedHeadOid:$oid}){commit{oid}}}", - variables: { repo: $repo, branch: $branch, oid: $oid, msg: $msg, path: $path, contents: ($content | @base64) } - }' \ - | gh api graphql --input - --jq '.data.createCommitOnBranch.commit.oid')" - [[ "$oid" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::createCommitOnBranch did not return a commit OID."; exit 1; } - echo "committed=true" >> "$GITHUB_OUTPUT" - echo "empty=false" >> "$GITHUB_OUTPUT" - echo "::notice::Pushed revert commit $oid to $BUMP_BRANCH." - - - name: Close empty bump PR - if: steps.revert.outputs.empty == 'true' - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - PR: ${{ steps.pr.outputs.number }} - run: | - set -euo pipefail - gh pr comment "$PR" --repo "$REPO" --body \ - "$REVERT_MARKER"$'\n\n'"Every bumped entry failed the policy scan. Closing — the next nightly run will retry." - gh pr close "$PR" --repo "$REPO" - - - name: Comment with revert detail - if: steps.revert.outputs.committed == 'true' - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - PR: ${{ steps.pr.outputs.number }} - REVERTED: ${{ steps.revert.outputs.reverted }} - SCAN_RUN_URL: ${{ github.event.workflow_run.html_url }} - run: | - set -euo pipefail - { - printf '%s\n\n' "$REVERT_MARKER" - echo "Dropped $(jq 'length' <<<"$REVERTED") entrie(s) that failed the policy scan. The remaining bumps were unaffected." - echo - echo "| Plugin | Violations |" - echo "|---|---|" - # `violations` is model-generated text shaped by a cloned external - # repo. Strip markdown control characters and wrap in a code span - # so a prompt-injected upstream can't smuggle links/images/table - # breakouts into a public PR comment. - jq -r --argjson rev "$REVERTED" \ - 'def neutralize: gsub("[|\n\r\\[\\]<>`]"; " "); - .[] | select(.name as $n | $rev | index($n)) - | "| \(.name) | `\(.violations | neutralize | .[0:200])` |"' \ - scan-out/run-verdicts.json - echo - echo "These entries will be retried at their next upstream SHA. See the [scan run]($SCAN_RUN_URL) for full verdicts." - } > /tmp/comment.md - gh pr comment "$PR" --repo "$REPO" --body-file /tmp/comment.md - - - name: Re-dispatch scan on revised bump branch - if: steps.revert.outputs.committed == 'true' - env: - GH_TOKEN: ${{ github.token }} - run: gh workflow run scan-plugins.yml --ref "$BUMP_BRANCH" diff --git a/.github/workflows/scan-plugins.yml b/.github/workflows/scan-plugins.yml deleted file mode 100644 index e282bad5..00000000 --- a/.github/workflows/scan-plugins.yml +++ /dev/null @@ -1,595 +0,0 @@ -name: Scan Plugins - -# Claude policy scan of changed external marketplace entries. -# -# `scan` is a required status check on main. A path-filtered workflow never -# reports a check run when its paths don't match, which would leave unrelated -# PRs blocked forever — so this workflow runs on every PR and skips the heavy -# scan setup at the step level when nothing scan-relevant changed. The check -# always reports. -# -# Verdict cache: each (plugin, sha) pair is scanned at most once. The bump -# workflow force-resets bump/plugin-shas every night, which makes the same -# SHAs reappear in the diff on consecutive nights — without a cache, the -# scan would re-burn ~90s of Claude time per entry per night. The cache is -# keyed on the hash of the policy the run actually uses, so a prompt or -# schema change invalidates all verdicts and triggers a clean re-scan. The -# cache directory and that policy live under the runner's temp directory, -# outside the checkout; verdicts are only read back from an actual -# actions/cache restore, and only on workflow_dispatch runs — a pull_request -# run always reviews its changed entries fresh. -# -# Failure handling: a cached `passes:false` verdict still fails the job. The -# Revert Failed Bumps workflow (revert-failed-bumps.yml) reacts to that by -# dropping the failing entries from the bump PR, so one bad upstream can't -# block the rest. After the revert, the re-dispatched scan finds only -# cached-pass entries and goes green in seconds. - -on: - pull_request: - workflow_dispatch: - inputs: - scan_all: - description: Scan every external entry (full re-review). Slow. - type: boolean - default: false - -permissions: - contents: read - id-token: write # Anthropic Workload Identity Federation (scan-plugins action) - -# Serialize scans per ref so concurrent runs (a re-dispatch racing the -# original, or a manual dispatch) don't both restore the same cache, scan -# overlapping sets, and lose one another's verdicts on save. -concurrency: - group: scan-plugins-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: false - -env: - MARKETPLACE: .claude-plugin/marketplace.json - CACHE_TTL_DAYS: '30' - # CACHE_DIR and POLICY_PROMPT are exported by the "Prepare scan directories - # and policy" step; both point under the runner's temp directory. - -jobs: - scan: - runs-on: ubuntu-latest - timeout-minutes: 360 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # Same paths the workflow-level filter used to gate on. workflow_dispatch - # always runs the scan (no PR diff to inspect). - - name: Check for scan-relevant changes - id: changes - env: - EVENT_NAME: ${{ github.event_name }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: | - set -euo pipefail - if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then - echo "relevant=true" >> "$GITHUB_OUTPUT" - echo "base_ref=origin/main" >> "$GITHUB_OUTPUT" - exit 0 - fi - echo "base_ref=$BASE_SHA" >> "$GITHUB_OUTPUT" - if git diff --quiet "$BASE_SHA" HEAD -- "$MARKETPLACE" .github/policy/; then - echo "relevant=false" >> "$GITHUB_OUTPUT" - echo "::notice::No changes to marketplace.json or policy/ — skipping policy scan." - else - echo "relevant=true" >> "$GITHUB_OUTPUT" - fi - - # Auth: the shared scan-plugins action below uses Workload Identity - # Federation (anthropic-federation-rule-id input) — the IDs are literal - # in this file, so the action's "skip if no auth" path can't trigger. - # The previous "Require ANTHROPIC_API_KEY" fail-closed guard is - # therefore no longer needed. - - # The verdict cache and the policy the scan runs with both live under - # the runner's temp directory, never inside the PR checkout. On - # pull_request the policy files (.github/policy/) are read from the base - # commit: a PR that edits the policy is scanned under the policy already - # on the base branch, and its edit takes effect for scans after it - # merges. A workflow_dispatch run uses the dispatched ref's own copy. - # The step also emits the hash the cache is keyed on. - - name: Prepare scan directories and policy - if: steps.changes.outputs.relevant == 'true' - id: policy - env: - EVENT_NAME: ${{ github.event_name }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: | - set -euo pipefail - cache_dir="$RUNNER_TEMP/scan-cache" - policy_dir="$RUNNER_TEMP/scan-policy" - rm -rf "$cache_dir" "$policy_dir" - mkdir -p "$cache_dir" "$policy_dir" - if [[ "$EVENT_NAME" == "pull_request" ]]; then - if ! git cat-file -e "${BASE_SHA}:.github/policy/prompt.md" 2>/dev/null; then - echo "::error::.github/policy/prompt.md does not exist at base commit ${BASE_SHA}; the scan policy has to be on the base branch before it can be used." - exit 1 - fi - git archive --format=tar "$BASE_SHA" .github/policy | tar -x -C "$policy_dir" --strip-components=2 - else - cp -R .github/policy/. "$policy_dir/" - fi - policy_hash="$(cd "$policy_dir" && find . -type f -print0 | sort -z | xargs -0r sha256sum | sha256sum | cut -c1-16)" - { - echo "CACHE_DIR=$cache_dir" - echo "POLICY_PROMPT=$policy_dir/prompt.md" - } >> "$GITHUB_ENV" - echo "hash=$policy_hash" >> "$GITHUB_OUTPUT" - echo "::notice::Scan policy $policy_hash from $([[ "$EVENT_NAME" == "pull_request" ]] && echo "base commit ${BASE_SHA:0:12}" || echo "the dispatched ref")." - - # Verdict cache, keyed on the policy content hash from the step above. - # A prompt change invalidates every cached verdict — that is - # intentional. The save key includes run_id so each run writes a fresh - # cache; restore-keys picks the most recent one. Verdicts older than - # CACHE_TTL_DAYS are pruned on restore to bound cache size as the - # marketplace grows. - # - # The cache is only used on workflow_dispatch (the nightly bump path). PR runs - # review their changed entries fresh each time. - - name: Restore verdict cache - if: steps.changes.outputs.relevant == 'true' && github.event_name != 'pull_request' - id: cache-restore - uses: actions/cache/restore@v4 - with: - path: ${{ env.CACHE_DIR }} - # run_attempt so a re-run can save its own verdicts (cache keys are - # immutable; without it a re-run would silently fail to save). - key: scan-verdicts-${{ steps.policy.outputs.hash }}-${{ github.run_id }}-${{ github.run_attempt }} - restore-keys: | - scan-verdicts-${{ steps.policy.outputs.hash }}- - - # Split the diff into cached (skip) and uncached (scan) entries. The - # cache key is "<name>@<sha>" — a SHA is immutable, so a verdict for a - # given (plugin, sha) is permanent under a fixed policy. - - name: Filter scan targets against cache - if: steps.changes.outputs.relevant == 'true' - id: filter - env: - BASE_REF: ${{ steps.changes.outputs.base_ref }} - SCAN_ALL: ${{ inputs.scan_all || 'false' }} - TTL_DAYS: ${{ env.CACHE_TTL_DAYS }} - CACHE_MATCHED_KEY: ${{ steps.cache-restore.outputs.cache-matched-key }} - run: | - set -euo pipefail - mkdir -p "$CACHE_DIR" - - # Initialize / prune the verdict map. A verdicts.json is only trusted - # when actions/cache actually restored one in the step above. - if [[ -n "$CACHE_MATCHED_KEY" && -f "$CACHE_DIR/verdicts.json" ]] && jq -e 'type == "object"' "$CACHE_DIR/verdicts.json" >/dev/null 2>&1; then - # Drop entries older than TTL. Verdicts are immutable per (plugin, sha) - # but pruning keeps the cache from accumulating forever. - cutoff="$(date -u -d "-${TTL_DAYS} days" +%Y-%m-%dT%H:%M:%SZ)" - jq --arg cutoff "$cutoff" \ - 'with_entries(select(.value.scanned_at >= $cutoff))' \ - "$CACHE_DIR/verdicts.json" > "$CACHE_DIR/verdicts.json.tmp" - mv "$CACHE_DIR/verdicts.json.tmp" "$CACHE_DIR/verdicts.json" - else - echo '{}' > "$CACHE_DIR/verdicts.json" - fi - - # Build the change set: entries in HEAD whose object differs from base. - # scan_all overrides to "every external entry" (full re-review). - if [[ "$SCAN_ALL" == "true" ]]; then - jq -c '[.plugins[] | select(.source | type == "object")]' "$MARKETPLACE" \ - > "$CACHE_DIR/changed.json" - else - if git cat-file -e "${BASE_REF}:${MARKETPLACE}" 2>/dev/null; then - git show "${BASE_REF}:${MARKETPLACE}" > "$CACHE_DIR/base.json" - else - echo '{"plugins":[]}' > "$CACHE_DIR/base.json" - fi - jq -c -s \ - '(.[0].plugins | map({(.name): .}) | add // {}) as $b - | [.[1].plugins[] - | select(.source | type == "object") - | select(($b[.name] // null) != .)]' \ - "$CACHE_DIR/base.json" "$MARKETPLACE" > "$CACHE_DIR/changed.json" - fi - - changed_count="$(jq 'length' "$CACHE_DIR/changed.json")" - - # Split changed entries into cached vs uncached. A hit requires the - # *whole* source object (repo, sha, path, ref) to match the cached - # entry, not just name@sha — a repo migration or path change with the - # same SHA is different scan content and must miss the cache. - jq -c -s \ - '.[0] as $cache - | (.[1] | map(. + {key: (.name + "@" + (.source.sha // "")) })) as $entries - | { - to_scan: [$entries[] | select(($cache[.key].source // null) != .source)], - cached: [$entries[] | select(($cache[.key].source // null) == .source) - | . + {verdict: $cache[.key]}] - }' \ - "$CACHE_DIR/verdicts.json" "$CACHE_DIR/changed.json" > "$CACHE_DIR/split.json" - - jq -c '.to_scan' "$CACHE_DIR/split.json" > "$CACHE_DIR/to-scan.json" - jq -c '.cached' "$CACHE_DIR/split.json" > "$CACHE_DIR/cached.json" - - to_scan_count="$(jq 'length' "$CACHE_DIR/to-scan.json")" - cached_count="$(jq 'length' "$CACHE_DIR/cached.json")" - cached_fail_count="$(jq '[.[] | select(.verdict.passes == false)] | length' "$CACHE_DIR/cached.json")" - - # Build a filtered marketplace containing only the uncached entries. - # Passing this as the action's marketplace-path means the action's own - # base diff (which can't resolve a path outside git) falls back to an - # empty base and scans everything in the file — which is exactly the - # to-scan set. Annotations point to the temp file rather than the real - # marketplace, but the per-entry verdicts still land in the artifact - # and the step summary. - jq -c '{plugins: .}' "$CACHE_DIR/to-scan.json" > "$CACHE_DIR/scan-targets.json" - - { - echo "changed=$changed_count" - echo "to_scan=$to_scan_count" - echo "cached=$cached_count" - echo "cached_failures=$cached_fail_count" - } >> "$GITHUB_OUTPUT" - - echo "::notice::$changed_count changed entrie(s): $cached_count cached ($cached_fail_count failing), $to_scan_count to scan." - - - name: Scan uncached entries - if: steps.changes.outputs.relevant == 'true' && steps.filter.outputs.to_scan != '0' - id: scan - # Capture the action's per-entry outputs even when it exits nonzero. - # The verdict (cached + fresh) is what gates the job, not the action's - # exit code, and the revert workflow needs the artifact even on failure. - continue-on-error: true - # Pin to a claude-plugins-community main-branch commit. - uses: anthropics/claude-plugins-community/.github/actions/scan-plugins@456db8779f3333f235c86169cc40b45457407a87 - with: - # Anthropic auth via Workload Identity Federation — the action - # mints a GitHub OIDC token (id-token: write above) and exchanges it - # for a short-lived bearer. The federation rule is - # bound to this repository (repository_id-pinned). - anthropic-federation-rule-id: fdrl_0147kJdru6bZKTtzwFNEqsDf - anthropic-organization-id: 1ec12c5c-6542-4da8-bf2f-c15919aef01c - anthropic-service-account-id: svac_01DnC3BtPHGjYJEGeuUUXZ8v - marketplace-path: ${{ env.CACHE_DIR }}/scan-targets.json - policy-prompt: ${{ env.POLICY_PROMPT }} - fail-on-findings: "true" - - # Merge fresh verdicts into the cache and assemble this run's full - # verdict set (cached + fresh) for downstream consumers. Runs even when - # the scan step failed so that fail verdicts are also cached — that is - # what lets the revert workflow drop them and what stops the same - # failing SHA from being re-scanned every night. - - name: Merge verdicts and assemble run report - if: steps.changes.outputs.relevant == 'true' - id: report - # The action's `scanned` output travels here via an env var, which is - # subject to the OS argv/envp size limit (~128 KiB on Linux). At ~300 - # bytes/entry that is ~400 entries — an order of magnitude above the - # cold-start case, and steady state with the cache is ~10/night. If - # the limit is ever hit the runner fails the step before the script - # runs ("argument list too long") — the right response is to clear - # the cache key and lower max-bumps temporarily. Documented here so - # nobody has to rediscover it. - env: - SCANNED_JSON: ${{ steps.scan.outputs.scanned || '[]' }} - run: | - set -euo pipefail - mkdir -p "$CACHE_DIR" - [[ -f "$CACHE_DIR/cached.json" ]] || echo '[]' > "$CACHE_DIR/cached.json" - [[ -f "$CACHE_DIR/changed.json" ]] || echo '[]' > "$CACHE_DIR/changed.json" - - # Defensive: a partial or unparseable action output must not poison - # the cache. Treat it as "scanned nothing". - printf '%s' "$SCANNED_JSON" > "$CACHE_DIR/scanned-raw.json" - if ! jq -e 'type == "array"' "$CACHE_DIR/scanned-raw.json" >/dev/null 2>&1; then - echo "::warning::scan action output is not a valid JSON array — treating as empty." - echo '[]' > "$CACHE_DIR/scanned-raw.json" - fi - - # Defense in depth: the verdict's text is shaped by an external repo. - # Scrub sk-ant- keys and JWTs (three base64url segments, the first two - # starting "eyJ"), so credential-shaped strings never reach the cache, - # artifact, or PR comment. - jq -c '(.. | strings) |= (gsub("sk-ant-[A-Za-z0-9_-]{8,}"; "[REDACTED]") - | gsub("eyJ[A-Za-z0-9_-]{8,}\\.eyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}"; "[REDACTED]"))' \ - "$CACHE_DIR/scanned-raw.json" > "$CACHE_DIR/scanned-raw.json.tmp" - mv "$CACHE_DIR/scanned-raw.json.tmp" "$CACHE_DIR/scanned-raw.json" - - now="$(date -u +%Y-%m-%dT%H:%M:%SZ)" - - # The action's `scanned` output has no SHA or source — join it with - # the change set by name to recover both for the cache key + the - # source-equality lookup guard. - jq -c -s --arg now "$now" \ - '.[0] as $changed - | (.[1] // []) as $scanned - | ($changed | map({(.name): .source}) | add // {}) as $srcs - | [$scanned[] - | . + {source: ($srcs[.name] // null), sha: ($srcs[.name].sha // ""), scanned_at: $now}]' \ - "$CACHE_DIR/changed.json" "$CACHE_DIR/scanned-raw.json" \ - > "$CACHE_DIR/fresh.json" - - # Merge fresh verdicts into the cache, keyed by name@sha. The - # full source object is stored so a future repo/path change with the - # same SHA fails the lookup guard. summary/violations are model - # output — truncate to bound cache size (the artifact carries the - # full text for the run that produced it). - jq -c -s \ - '.[0] + ([.[1][] | select(.sha != "") | {(.name + "@" + .sha): { - source: .source, - passes: .passes, - summary: ((.summary // "") | .[0:300]), - violations: ((.violations // "") | .[0:500]), - scanned_at: .scanned_at - }}] | add // {})' \ - "$CACHE_DIR/verdicts.json" "$CACHE_DIR/fresh.json" \ - > "$CACHE_DIR/verdicts.json.tmp" - mv "$CACHE_DIR/verdicts.json.tmp" "$CACHE_DIR/verdicts.json" - - # The full per-entry verdict for THIS run's diff: cached verdicts - # plus freshly-scanned verdicts. The revert workflow consumes the - # `failed` list to know exactly which SHAs to drop. - jq -c -s \ - '(.[0] | map({name, sha: .source.sha, passes: .verdict.passes, - summary: (.verdict.summary // ""), - violations: (.verdict.violations // ""), - source: "cache"})) - + (.[1] | map({name, sha, passes, - summary: (.summary // ""), - violations: (.violations // ""), - source: "scan"}))' \ - "$CACHE_DIR/cached.json" "$CACHE_DIR/fresh.json" \ - > "$CACHE_DIR/run-verdicts.json" - - jq -c '[.[] | select(.passes == false) | .name]' "$CACHE_DIR/run-verdicts.json" \ - > "$CACHE_DIR/run-failed.json" - - fail_count="$(jq 'length' "$CACHE_DIR/run-failed.json")" - total="$(jq 'length' "$CACHE_DIR/run-verdicts.json")" - - { - echo "failed_count=$fail_count" - echo "total=$total" - } >> "$GITHUB_OUTPUT" - - # `summary` and `violations` are model-generated text shaped by a - # cloned external repo. Strip markdown control characters AND wrap - # in code spans before they hit a publicly-rendered sink — code - # spans neutralize auto-linked bare URLs that a prompt-injected - # upstream could smuggle in. Stripping backticks first stops a - # breakout from the code span. - { - echo "## Policy scan (with verdict cache)" - echo - echo "Changed entries: ${total} · cached: $(jq 'length' "$CACHE_DIR/cached.json") · scanned fresh: $(jq 'length' "$CACHE_DIR/fresh.json") · failures: ${fail_count}" - echo - if [[ "$total" -gt 0 ]]; then - echo "| Plugin | SHA | Passes | Source | Summary |" - echo "|---|---|---|---|---|" - jq -r 'def neutralize: gsub("[|\n\r\\[\\]<>`]"; " "); - .[] | "| \(.name) | `\(.sha[0:8])` | \(if .passes then "✅" else "❌" end) | \(.source) | `\(.summary | neutralize | .[0:120])` |"' \ - "$CACHE_DIR/run-verdicts.json" - fi - if [[ "$fail_count" -gt 0 ]]; then - echo - echo "### Violations" - jq -r 'def neutralize: gsub("[|\n\r\\[\\]<>`]"; " "); - .[] | select(.passes == false) | "- **\(.name)** — `\(.violations | neutralize | .[0:500])`"' "$CACHE_DIR/run-verdicts.json" - fi - } >> "$GITHUB_STEP_SUMMARY" - - # Used by revert-failed-bumps.yml to know which entries to drop. Always - # uploaded when relevant so the revert workflow can distinguish "scan - # found policy failures" from "scan never ran" (infra error → no revert). - - name: Upload scan verdicts artifact - if: steps.changes.outputs.relevant == 'true' - uses: actions/upload-artifact@v4 - with: - name: scan-verdicts - path: | - ${{ env.CACHE_DIR }}/run-verdicts.json - ${{ env.CACHE_DIR }}/run-failed.json - retention-days: 7 - - # Save even when the scan failed — fail verdicts are what stop us from - # re-burning Claude time on a known-bad SHA every night. - - name: Save verdict cache - if: always() && steps.changes.outputs.relevant == 'true' && env.CACHE_DIR != '' && github.event_name != 'pull_request' - uses: actions/cache/save@v4 - with: - path: ${{ env.CACHE_DIR }} - key: scan-verdicts-${{ steps.policy.outputs.hash }}-${{ github.run_id }}-${{ github.run_attempt }} - - # Required-check gate. Fails on either fresh or cached policy failures — - # a known-bad SHA must keep failing until it is reverted or upstream - # fixes it (a new SHA is a new cache key and gets a fresh scan). - - name: Gate on policy verdict - if: steps.changes.outputs.relevant == 'true' - env: - CHANGED: ${{ steps.filter.outputs.changed }} - FAILED: ${{ steps.report.outputs.failed_count || '0' }} - SCAN_OUTCOME: ${{ steps.scan.outcome }} - run: | - set -euo pipefail - if [[ "$FAILED" != "0" ]]; then - echo "::error::$FAILED entrie(s) fail policy. See the run summary for verdicts." - exit 1 - fi - # The action can also fail without a policy verdict (clone error, - # API error, schema mismatch). With zero parsed failures and a - # nonzero exit, that is an infra error — fail loudly so the revert - # workflow does NOT misread it as "everything passed". - if [[ "$SCAN_OUTCOME" == "failure" ]]; then - echo "::error::Scan step failed without a parseable policy verdict (likely an infra error)." - exit 1 - fi - # Every changed external entry needs its own passing verdict. - passed="$(jq '[.[] | select(.passes == true)] | length' "$CACHE_DIR/run-verdicts.json")" - if [[ "$passed" != "$CHANGED" ]]; then - echo "::error::$passed of $CHANGED changed external entries have a passing policy verdict. See the scan step log." - exit 1 - fi - - # ───────────────────────────────────────────────────────────────────────────── - # emit-verdict: post a sticky comment per entry to the bump PR with the - # structured verdict, so downstream tooling (label automation, delist - # authoring) can read verdicts directly instead of scraping job logs. - # Sticky comment marker: `<!-- bump-pr-verdict:<name> -->`. - # - # Mirrors the schema_v1 contract from - # anthropics/claude-plugins-community-internal#3908 so the triage scripts - # in mcp-local-directory/scripts/triage/ work uniformly across both repos. - # -official doesn't run per-entry static checks (zombie, schema, binaries, - # etc.) so the `scan.*` axes are emitted as "skipped". The granular policy - # booleans (`has_broad_scope_hooks`, `has_undisclosed_telemetry`, - # `description_matches_behavior`) aren't surfaced by this workflow's - # per-entry artifact yet, so they're emitted as null; the triage - # `triage_bool_to_str` helper maps null → "?" so display is graceful. - # Status describes the execution state, not the outcome — `ran` when the - # scan action evaluated this SHA fresh, `cached` when a prior verdict was - # reused (cf. run-verdicts.json's `source` field). Outcome lives in - # `policy.passes`. policy-sweep.sh dispatches on this exact vocabulary. - # - # PR resolution: pull_request events carry the PR number directly. The - # bump workflow creates bump PRs via GITHUB_TOKEN (which doesn't fire - # pull_request triggers — recursion guard) and dispatches this scan via - # workflow_dispatch on the bump branch. In that case we look up the - # open PR by head ref. No PR (scan_all dispatch on main, etc.) → no-op. - # - # continue-on-error at the job level: emit failure must NOT block the - # `scan` required check. Consumers fall back to log-scraping if the - # comment is absent (gradual migration; no flag day). - # ───────────────────────────────────────────────────────────────────────────── - emit-verdict: - needs: [scan] - if: always() && needs.scan.result != 'skipped' && needs.scan.result != 'cancelled' - runs-on: ubuntu-latest - continue-on-error: true - permissions: - contents: read - pull-requests: write - steps: - - name: Download scan verdicts - uses: actions/download-artifact@v4 - with: - name: scan-verdicts - path: /tmp/scan-verdicts - continue-on-error: true - - - name: Resolve PR number for this ref - id: pr - env: - GH_TOKEN: ${{ github.token }} - EVENT_NAME: ${{ github.event_name }} - PR_FROM_EVENT: ${{ github.event.pull_request.number }} - REF: ${{ github.ref_name }} - REPO: ${{ github.repository }} - run: | - set -euo pipefail - if [[ "$EVENT_NAME" == "pull_request" && -n "$PR_FROM_EVENT" ]]; then - echo "number=$PR_FROM_EVENT" >> "$GITHUB_OUTPUT" - exit 0 - fi - # workflow_dispatch on the bump branch: find the open PR for it. - # head filter takes the form owner:branch. - owner="${REPO%%/*}" - pr=$(gh api "/repos/${REPO}/pulls?state=open&head=${owner}:${REF}&per_page=1" \ - --jq '.[0].number // ""') - if [[ -z "$pr" ]]; then - echo "::notice::No open PR for ref ${REF} — sticky comments skipped (verdicts still in scan-verdicts artifact)" - fi - echo "number=$pr" >> "$GITHUB_OUTPUT" - - - name: Build and post sticky comments - if: steps.pr.outputs.number != '' - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - PR: ${{ steps.pr.outputs.number }} - RUN_ID: ${{ github.run_id }} - run: | - set -euo pipefail - - verdicts_path=/tmp/scan-verdicts/run-verdicts.json - # Missing/empty artifact: scan job ran but didn't produce verdicts - # (e.g. the relevance gate said "no changes"). Nothing to comment; - # exit clean. - if [[ ! -s "$verdicts_path" ]]; then - echo "::notice::No run-verdicts.json artifact — nothing to emit" - exit 0 - fi - count=$(jq 'length' "$verdicts_path") - if [[ "$count" == "0" ]]; then - echo "::notice::run-verdicts.json is empty — nothing to emit" - exit 0 - fi - - ran_at=$(date -u +%Y-%m-%dT%H:%M:%SZ) - - # scan.* axes: -official doesn't run per-entry static checks; emit - # "skipped" for each so the schema is shape-compatible with -internal. - scan_stub='{"clone":"skipped","subpath_missing":"skipped","schema":"skipped","zombie":"skipped","tool_allowlist":"skipped","binaries":"skipped","unique":"skipped","mcp":"skipped"}' - - # Pre-fetch all PR comments once (paginated) for the marker lookup. - gh api --paginate "/repos/$REPO/issues/$PR/comments" \ - --jq '.[] | {id, body}' > /tmp/comments.ndjson - - jq -c '.[]' "$verdicts_path" | while read -r entry; do - name=$(jq -r '.name' <<< "$entry") - passes=$(jq -r '.passes' <<< "$entry") - summary=$(jq -r '.summary // ""' <<< "$entry") - violations=$(jq -r '.violations // ""' <<< "$entry") - source=$(jq -r '.source // "scan"' <<< "$entry") - - # status = execution state (cf. -internal#3908 vocabulary). - # Outcome is in `passes`. Map source → status: scan-action-run - # → "ran"; cache-served → "cached". Anything else falls through - # as "ran" (only those two values appear in run-verdicts.json). - case "$source" in - cache) status="cached" ;; - scan) status="ran" ;; - *) status="ran" ;; - esac - - policy=$(jq -n \ - --argjson passes "$passes" \ - --arg summary "$summary" \ - --arg violations "$violations" \ - --arg source "$source" \ - --arg status "$status" \ - '{passes: $passes, - has_broad_scope_hooks: null, - has_undisclosed_telemetry: null, - description_matches_behavior: null, - summary: $summary, - violations: $violations, - source: $source, - status: $status}') - - verdict=$(jq -n \ - --argjson scan "$scan_stub" \ - --argjson policy "$policy" \ - --arg ran_at "$ran_at" \ - --arg run_id "$RUN_ID" \ - '{schema_version: 1, ran_at: $ran_at, run_id: $run_id, scan: $scan, policy: $policy}') - - marker="<!-- bump-pr-verdict:$name -->" - body=$(printf '%s\n```json\n%s\n```' "$marker" "$verdict") - - # jq's first() short-circuits and avoids SIGPIPE under pipefail if - # duplicate markers exist (shouldn't, but a prior buggy run could - # double-post). -s slurps NDJSON; `// empty` yields no output when - # no match. - existing=$(jq -rs --arg m "$marker" \ - 'first(.[] | select(.body | startswith($m)) | .id) // empty' \ - /tmp/comments.ndjson) - - if [[ -n "$existing" ]]; then - gh api -X PATCH "/repos/$REPO/issues/comments/$existing" -f body="$body" >/dev/null - echo "Updated comment $existing for $name" - else - gh api -X POST "/repos/$REPO/issues/$PR/comments" -f body="$body" >/dev/null - echo "Created comment for $name" - fi - done diff --git a/.github/workflows/validate-plugins.yml b/.github/workflows/validate-plugins.yml deleted file mode 100644 index 0a07ee98..00000000 --- a/.github/workflows/validate-plugins.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Validate Plugins - -# Checks the plugin folders in this repository (.github/scripts/plugin-dirs.sh). -# A folder is checked whether or not marketplace.json lists it. -# -# `validate` is a required status check on main, so this has no path filter: a -# filtered-out run never reports, and the PR then waits for it forever. - -on: - pull_request: - push: - branches: [main] - # Bump PRs are opened with GITHUB_TOKEN, which doesn't fire on:pull_request - # (recursion guard), so the bump workflow dispatches this against each bump - # branch instead. - workflow_dispatch: - -permissions: - contents: read - -jobs: - validate: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 (sha-pinned) - - - name: Install Claude Code - run: | - # The native binary is an optional dependency whose download sometimes - # stalls, so check that it runs and retry from a clean state. - for attempt in 1 2 3; do - timeout -k 10 300 npm install -g --include=optional @anthropic-ai/claude-code@latest || true - if claude --version; then exit 0; fi - timeout -k 10 300 node "$(npm root -g)/@anthropic-ai/claude-code/install.cjs" || true - if claude --version; then exit 0; fi - npm uninstall -g @anthropic-ai/claude-code || true - npm cache clean --force || true - sleep $((attempt * 10)) - done - echo "::error::Claude Code did not install after 3 attempts." - exit 1 - - - name: Validate plugin folders - run: bun .github/scripts/validate-plugin-folders.ts - - - name: Validate frontmatter of agents, skills and commands - run: | - set -euo pipefail - (cd .github/scripts && bun install --no-save yaml@2) - dirs="$(bash .github/scripts/plugin-dirs.sh)" - failed=0 - while IFS= read -r dir; do - bun .github/scripts/validate-frontmatter.ts "$dir" || failed=1 - done <<< "$dirs" - exit "$failed" - - # TODO: remove this step and the next once marketplace.json lists only - # first-party plugins. Until then it still serves third-party entries, so a - # change to the file must keep it loadable and every source SHA-pinned (I5). - - name: Check whether marketplace.json changed - id: marketplace - env: - EVENT: ${{ github.event_name }} - BASE: ${{ github.event.pull_request.base.sha || github.event.before || 'origin/main' }} - run: | - if [[ "$EVENT" != "workflow_dispatch" ]] && - git diff --quiet "$BASE"...HEAD -- .claude-plugin/ .github/workflows/validate-plugins.yml; then - echo "changed=false" >> "$GITHUB_OUTPUT" - else - # On a dispatch (bump branches), and when the diff itself fails: - # check rather than skip. - echo "changed=true" >> "$GITHUB_OUTPUT" - fi - - - name: Validate marketplace.json - if: steps.marketplace.outputs.changed == 'true' - uses: anthropics/claude-plugins-community/.github/actions/validate-plugins@24479d5a1fb7a1c4f068a6d3b74d0c0fbc1acfda - with: - marketplace-path: .claude-plugin/marketplace.json - skip-local-folders: "true" - warn-invariants: "I1 I3 I8 I11" - # Plugins resolved by a local command instead of a git repo (no sha to - # pin). Each name here is a listing decision: add one only with - # marketplace-ops sign-off. - command-exempt: "xcode" - claude-cli-version: latest |
