From 316ba0ccfaa7762070f31391a64af42b1d896fa8 Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sat, 14 Nov 2026 20:37:17 +0100 Subject: [PATCH] refactor(release): cut marketplace releases with release-please Replace the custom preparation, proposal and publication workflows and their scripts with release-please (#705, part 1 of 2). One root package bumps .metadata.version in both marketplace manifests through a reviewable release PR opened with the App token; merging it tags vX.Y.Z and publishes the GitHub release with the workflow token. Per-plugin version and changelog gates are unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 87 +--- .../prepare-marketplace-release.yaml | 46 -- .../propose-marketplace-release.yaml | 121 ----- .../publish-marketplace-release.yaml | 120 ----- .github/workflows/release-please.yaml | 66 +++ .release-please-manifest.json | 3 + AGENTS.md | 28 +- CONTRIBUTING.md | 6 +- README.md | 2 +- docs/marketplace-releases.md | 448 ++---------------- docs/scripts.md | 5 +- docs/tool-ownership.md | 31 +- docs/validation.md | 20 +- release-please-config.json | 23 + scripts/check-marketplace-release-remote.sh | 95 ---- .../check-marketplace-release-remote.test.sh | 204 -------- scripts/check-marketplace-version.sh | 57 --- scripts/check-marketplace-version.test.sh | 136 ------ .../ci-script-test-sharding-workflow.test.sh | 34 +- scripts/inspect-marketplace-release.sh | 76 --- scripts/inspect-marketplace-release.test.sh | 184 ------- scripts/marketplace-caller-context.test.sh | 43 -- ...rketplace-observation-completeness.test.sh | 136 ------ scripts/marketplace-permissions.jq | 11 - scripts/marketplace-proposal-workflow.test.sh | 94 ---- scripts/marketplace-proposal.jq | 95 ---- .../marketplace-publication-identity.test.sh | 74 --- .../marketplace-publication-workflow.test.sh | 81 ---- scripts/marketplace-publication.jq | 31 -- scripts/marketplace-release.jq | 48 +- scripts/marketplace-remote-state.jq | 43 -- scripts/prepare-marketplace-release.sh | 200 -------- scripts/prepare-marketplace-release.test.sh | 314 ------------ scripts/prepare-merged-marketplace-release.sh | 84 ---- ...prepare-merged-marketplace-release.test.sh | 180 ------- scripts/propose-marketplace-release.sh | 172 ------- scripts/propose-marketplace-release.test.sh | 319 ------------- scripts/publish-marketplace-release.sh | 110 ----- scripts/publish-marketplace-release.test.sh | 267 ----------- .../release-observation-boundaries.test.sh | 119 ----- scripts/verify-marketplace-release.sh | 151 ------ scripts/verify-marketplace-release.test.sh | 175 ------- 42 files changed, 169 insertions(+), 4370 deletions(-) delete mode 100644 .github/workflows/prepare-marketplace-release.yaml delete mode 100644 .github/workflows/propose-marketplace-release.yaml delete mode 100644 .github/workflows/publish-marketplace-release.yaml create mode 100644 .github/workflows/release-please.yaml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json delete mode 100755 scripts/check-marketplace-release-remote.sh delete mode 100755 scripts/check-marketplace-release-remote.test.sh delete mode 100644 scripts/check-marketplace-version.sh delete mode 100644 scripts/check-marketplace-version.test.sh delete mode 100755 scripts/inspect-marketplace-release.sh delete mode 100755 scripts/inspect-marketplace-release.test.sh delete mode 100644 scripts/marketplace-caller-context.test.sh delete mode 100644 scripts/marketplace-observation-completeness.test.sh delete mode 100644 scripts/marketplace-permissions.jq delete mode 100644 scripts/marketplace-proposal-workflow.test.sh delete mode 100644 scripts/marketplace-proposal.jq delete mode 100644 scripts/marketplace-publication-identity.test.sh delete mode 100644 scripts/marketplace-publication-workflow.test.sh delete mode 100644 scripts/marketplace-publication.jq delete mode 100644 scripts/marketplace-remote-state.jq delete mode 100644 scripts/prepare-marketplace-release.sh delete mode 100644 scripts/prepare-marketplace-release.test.sh delete mode 100644 scripts/prepare-merged-marketplace-release.sh delete mode 100644 scripts/prepare-merged-marketplace-release.test.sh delete mode 100644 scripts/propose-marketplace-release.sh delete mode 100644 scripts/propose-marketplace-release.test.sh delete mode 100755 scripts/publish-marketplace-release.sh delete mode 100755 scripts/publish-marketplace-release.test.sh delete mode 100644 scripts/release-observation-boundaries.test.sh delete mode 100644 scripts/verify-marketplace-release.sh delete mode 100644 scripts/verify-marketplace-release.test.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3c3f3e2..fe504c80 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -197,81 +197,6 @@ jobs: - name: πŸ§ͺ Verify signed skill metadata publication run: bash scripts/publish-skill-metadata.test.sh - test-marketplace: - name: Test marketplace automation - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: πŸ“„ Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: πŸ”§ Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: "24" - - - name: πŸ“¦ Install the locked Markdown parser - run: npm ci --ignore-scripts --no-audit --no-fund - - - name: πŸ”§ Set up the minimum supported Go toolchain - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: - go-version: "1.22.12" - cache: false - - - name: πŸ§ͺ Verify marketplace caller checkout isolation - run: bash scripts/marketplace-caller-context.test.sh - - - name: πŸ§ͺ Self-test marketplace release preparation - run: bash scripts/prepare-marketplace-release.test.sh - - - name: πŸ§ͺ Verify original release observations and reserved output writes - run: bash scripts/release-observation-boundaries.test.sh - - - name: πŸ§ͺ Self-test marketplace release verification - run: bash scripts/verify-marketplace-release.test.sh - - - name: πŸ§ͺ Self-test historical marketplace inspection - run: bash scripts/inspect-marketplace-release.test.sh - - - name: πŸ§ͺ Self-test complete marketplace observations - run: bash scripts/marketplace-observation-completeness.test.sh - - - name: πŸ§ͺ Self-test marketplace version proposals - run: bash scripts/check-marketplace-version.test.sh - - - name: πŸ§ͺ Self-test remote marketplace release assessment - run: bash scripts/check-marketplace-release-remote.test.sh - - - name: πŸ§ͺ Self-test marketplace publication - run: bash scripts/publish-marketplace-release.test.sh - - - name: πŸ§ͺ Self-test merged marketplace preparation and exact main CI - run: bash scripts/prepare-merged-marketplace-release.test.sh - - - name: πŸ§ͺ Self-test marketplace workflow authorization branches - run: bash scripts/marketplace-publication-workflow.test.sh - - - name: πŸ§ͺ Self-test marketplace publication checkout identity - run: bash scripts/marketplace-publication-identity.test.sh - - - name: πŸ§ͺ Self-test create-only marketplace proposals - run: bash scripts/propose-marketplace-release.test.sh - - - name: πŸ§ͺ Self-test marketplace proposal workflow boundaries - run: bash scripts/marketplace-proposal-workflow.test.sh - - - name: Verify the native Actions proposal identity - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api graphql --hostname github.com -f query='query { viewer { login } }' > "$RUNNER_TEMP/native-proposal-identity.json" - jq '{login: .data.viewer.login}' "$RUNNER_TEMP/native-proposal-identity.json" - jq -e '.data.viewer.login == "github-actions[bot]"' "$RUNNER_TEMP/native-proposal-identity.json" - test-packages: name: Test packaged resources runs-on: ubuntu-latest @@ -439,15 +364,6 @@ jobs: ./scripts/check-plugin-version-bump.sh "$BASE_SHA" HEAD bash scripts/plugin-changelog.sh check "$BASE_SHA" HEAD - - name: πŸ”’ Verify the marketplace version proposal - # A published tag occupies the version, so this prepublication gate belongs - # to PRs only. Use the actual head, never GitHub's synthetic merge commit. - if: github.event_name == 'pull_request' - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: bash scripts/check-marketplace-version.sh "$BASE_SHA" "$HEAD_SHA" - check-bundled-skill-edits: name: Check bundled skill edits runs-on: ubuntu-latest @@ -626,7 +542,7 @@ jobs: permissions: actions: read timeout-minutes: 5 - needs: [retired-repo-links, validate-manifests, lint-scripts, test-marketplace, test-packages, check-version-bump, check-bundled-skill-edits, validate-spec] + needs: [retired-repo-links, validate-manifests, lint-scripts, test-packages, check-version-bump, check-bundled-skill-edits, validate-spec] if: ${{ always() }} steps: - uses: devantler-tech/.github/actions/aggregate-job-checks@da5f0839b418626a8a0b69df1f04ba931a38e371 # v19.1.0 @@ -636,7 +552,6 @@ jobs: ${{ needs.retired-repo-links.result }} ${{ needs.validate-manifests.result }} ${{ needs.lint-scripts.result }} - ${{ needs.test-marketplace.result }} ${{ needs.test-packages.result }} ${{ needs.check-version-bump.result }} ${{ needs.check-bundled-skill-edits.result }} diff --git a/.github/workflows/prepare-marketplace-release.yaml b/.github/workflows/prepare-marketplace-release.yaml deleted file mode 100644 index 7e1fbd1e..00000000 --- a/.github/workflows/prepare-marketplace-release.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: πŸ“¦ Prepare marketplace release - -on: - workflow_dispatch: - inputs: - base-tag: - description: Last stable marketplace tag, or initial for the first release - required: true - type: string - -permissions: {} - -jobs: - prepare: - name: Prepare review artifact - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout selected revision and complete tag history - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Validate repository manifests - run: bash scripts/validate-manifests.sh - - - name: Prepare the release candidate - env: - BASE_TAG: ${{ inputs.base-tag }} - SOURCE_COMMIT: ${{ github.sha }} - run: | - bash scripts/prepare-marketplace-release.sh \ - --base-tag "$BASE_TAG" --head "$SOURCE_COMMIT" \ - --output "$RUNNER_TEMP/marketplace-release" - - - name: Upload the review artifact - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: marketplace-release-${{ github.sha }}-${{ github.run_attempt }} - path: ${{ runner.temp }}/marketplace-release - if-no-files-found: error - # The generated directory contains only the plan, notes, and two public manifests. - include-hidden-files: true - retention-days: 14 diff --git a/.github/workflows/propose-marketplace-release.yaml b/.github/workflows/propose-marketplace-release.yaml deleted file mode 100644 index a1af2edf..00000000 --- a/.github/workflows/propose-marketplace-release.yaml +++ /dev/null @@ -1,121 +0,0 @@ -name: πŸ“ Propose marketplace release - -on: - workflow_dispatch: - inputs: - ci-run: - description: Exact successful main CI run, or latest - type: string - default: latest - propose: - description: Create a verified draft version proposal - type: boolean - default: false - schedule: - - cron: "35 * * * *" - -permissions: {} - -concurrency: - # Serialize every armed path together; read-only assessments cannot displace a writer. - group: marketplace-proposal-${{ ((github.event_name == 'workflow_dispatch' && inputs.propose) || (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPROPOSE == 'true')) && 'write' || 'assessment' }} - cancel-in-progress: false - -jobs: - assess: - name: Prepare a current-main proposal - if: >- - github.ref == 'refs/heads/main' && - (github.event_name == 'workflow_dispatch' || - (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPROPOSE == 'true')) - runs-on: ubuntu-latest - # Read source, exact CI and open proposal occupancy without creation authority. - permissions: - contents: read - actions: read - pull-requests: read - outputs: - status: ${{ steps.assessment.outputs.status }} - steps: - - name: Checkout current main tooling and complete history - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: main - fetch-depth: 0 - persist-credentials: false - - name: Reconstruct and assess the proposal - id: assessment - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - CI_RUN: ${{ inputs.ci-run || 'latest' }} - run: | - bash scripts/propose-marketplace-release.sh \ - --repo "$GH_REPO" --source "$(git rev-parse HEAD)" --ci-run "$CI_RUN" \ - --output "$RUNNER_TEMP/proposal-candidate" > "$RUNNER_TEMP/proposal-assessment.json" - jq . "$RUNNER_TEMP/proposal-assessment.json" - printf 'status=%s\n' "$(jq -er .status "$RUNNER_TEMP/proposal-assessment.json")" >> "$GITHUB_OUTPUT" - cat "$RUNNER_TEMP/proposal-assessment.json" >> "$GITHUB_STEP_SUMMARY" - - name: Retain read-only proposal evidence - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: marketplace-proposal-assessment-${{ github.sha }}-${{ github.run_attempt }} - path: | - ${{ runner.temp }}/proposal-assessment.json - ${{ runner.temp }}/proposal-candidate - include-hidden-files: true - if-no-files-found: error - - propose: - name: Create a signed version draft - needs: assess - if: >- - github.ref == 'refs/heads/main' && needs.assess.outputs.status == 'PREPARED' && - ((github.event_name == 'workflow_dispatch' && inputs.propose == true) || - (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPROPOSE == 'true')) - runs-on: ubuntu-latest - # The explicitly armed native writer creates only its verified branch, commit and draft. - permissions: - contents: write - pull-requests: write - actions: read - outputs: - status: ${{ steps.creation.outputs.status }} - steps: - - name: Checkout current main for independent reconstruction - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: main - fetch-depth: 0 - persist-credentials: false - - name: Create and independently read back the draft - id: creation - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - CI_RUN: ${{ inputs.ci-run || 'latest' }} - run: | - bash scripts/propose-marketplace-release.sh \ - --repo "$GH_REPO" --source "$(git rev-parse HEAD)" --ci-run "$CI_RUN" \ - --output "$RUNNER_TEMP/proposal-created-candidate" --propose > "$RUNNER_TEMP/proposal-created.json" - jq . "$RUNNER_TEMP/proposal-created.json" - printf 'status=%s\n' "$(jq -er .status "$RUNNER_TEMP/proposal-created.json")" >> "$GITHUB_OUTPUT" - cat "$RUNNER_TEMP/proposal-created.json" >> "$GITHUB_STEP_SUMMARY" - - recheck: - name: Start normal required PR checks - needs: propose - if: >- - github.ref == 'refs/heads/main' && needs.propose.outputs.status == 'CREATED' && - ((github.event_name == 'workflow_dispatch' && inputs.propose == true) || - (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPROPOSE == 'true')) - runs-on: ubuntu-latest - # Dispatch the existing rechecker; this job cannot read or change repository contents or PRs. - permissions: - actions: write - steps: - - name: Dispatch the existing current-main CI recheck - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: gh workflow run recheck-open-prs.yaml --repo "$GH_REPO" --ref main -F dry-run=false diff --git a/.github/workflows/publish-marketplace-release.yaml b/.github/workflows/publish-marketplace-release.yaml deleted file mode 100644 index 9fc9e446..00000000 --- a/.github/workflows/publish-marketplace-release.yaml +++ /dev/null @@ -1,120 +0,0 @@ -name: πŸ“¦ Publish marketplace release - -on: - schedule: - - cron: "25 * * * *" - workflow_dispatch: - inputs: - ci-run: - description: Successful main push CI run ID, or latest to resolve the newest run - default: latest - type: string - publish: - description: Create the verified absent tag and release (assessment otherwise) - type: boolean - default: false - -permissions: {} - -concurrency: - # Assessments cannot displace an armed publication; never cancel a writer mid-operation. - group: marketplace-publication-${{ ((github.event_name == 'workflow_dispatch' && inputs.publish) || (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPUBLISH == 'true')) && 'write' || 'assessment' }} - cancel-in-progress: false - -jobs: - assess: - name: Reconstruct the merged proposal - if: >- - (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || - (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPUBLISH == 'true') - runs-on: ubuntu-latest - timeout-minutes: 10 - # Assessment reads the committed proposal and the exact CI run; it cannot publish. - permissions: - contents: read - actions: read - outputs: - status: ${{ steps.prepare.outputs.status }} - release: ${{ steps.prepare.outputs.release }} - ci-run: ${{ steps.prepare.outputs.ci-run }} - steps: - - name: Checkout current main and complete tag history - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: main - fetch-depth: 0 - persist-credentials: false - - - name: Validate repository manifests - run: bash scripts/validate-manifests.sh - - - name: Verify exact main CI and reconstruct the candidate - id: prepare - env: - GH_TOKEN: ${{ github.token }} - REPOSITORY: ${{ github.repository }} - CI_RUN: ${{ inputs.ci-run || 'latest' }} - run: | - RELEASE_COMMIT=$(git rev-parse --verify HEAD) - bash scripts/prepare-merged-marketplace-release.sh \ - --repo "$REPOSITORY" --release "$RELEASE_COMMIT" --ci-run "$CI_RUN" \ - --output "$RUNNER_TEMP/marketplace-candidate" > "$RUNNER_TEMP/assessment.json" - jq . "$RUNNER_TEMP/assessment.json" - { - printf 'status=%s\n' "$(jq -er '.status' "$RUNNER_TEMP/assessment.json")" - printf 'release=%s\n' "$RELEASE_COMMIT" - printf 'ci-run=%s\n' "$(jq -er '.ciRunId' "$RUNNER_TEMP/assessment.json")" - } >> "$GITHUB_OUTPUT" - cat "$RUNNER_TEMP/assessment.json" >> "$GITHUB_STEP_SUMMARY" - - - name: Upload the assessment and candidate - if: steps.prepare.outputs.status == 'VERIFIED' - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: marketplace-publication-assessment-${{ steps.prepare.outputs.release }}-${{ github.run_attempt }} - path: | - ${{ runner.temp }}/marketplace-candidate - ${{ runner.temp }}/assessment.json - include-hidden-files: true - if-no-files-found: error - retention-days: 14 - - publish: - name: Publish the verified marketplace - needs: assess - if: >- - needs.assess.outputs.status == 'VERIFIED' && - ((github.event_name == 'workflow_dispatch' && inputs.publish) || - (github.event_name == 'schedule' && vars.MARKETPLACE_AUTOPUBLISH == 'true')) - runs-on: ubuntu-latest - timeout-minutes: 10 - # Only this explicitly armed job can create the absent release and tag. - permissions: - contents: write - actions: read - steps: - - name: Checkout current main and complete tag history - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: main - fetch-depth: 0 - persist-credentials: false - - # No downloaded artifact is authority: reconstruct again from this fresh main checkout. - - name: Recheck CI and publish with independent remote readback - env: - GH_TOKEN: ${{ github.token }} - REPOSITORY: ${{ github.repository }} - RELEASE_COMMIT: ${{ needs.assess.outputs.release }} - CI_RUN: ${{ needs.assess.outputs.ci-run }} - run: | - bash scripts/prepare-merged-marketplace-release.sh \ - --repo "$REPOSITORY" --release "$RELEASE_COMMIT" --ci-run "$CI_RUN" \ - --output "$RUNNER_TEMP/marketplace-candidate" > "$RUNNER_TEMP/assessment.json" - jq -e '.status == "VERIFIED"' "$RUNNER_TEMP/assessment.json" > /dev/null - SOURCE_COMMIT=$(jq -er '.sourceCommit' "$RUNNER_TEMP/assessment.json") - bash scripts/publish-marketplace-release.sh --repo "$REPOSITORY" \ - --candidate "$RUNNER_TEMP/marketplace-candidate" --source "$SOURCE_COMMIT" \ - --release "$RELEASE_COMMIT" --publish > "$RUNNER_TEMP/publication.json" - jq . "$RUNNER_TEMP/publication.json" - cat "$RUNNER_TEMP/publication.json" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml new file mode 100644 index 00000000..64ba403c --- /dev/null +++ b/.github/workflows/release-please.yaml @@ -0,0 +1,66 @@ +name: πŸš€ Release Please + +# Cuts marketplace releases with release-please (release-please-config.json and +# .release-please-manifest.json). Each push to main updates one reviewable release PR that +# bumps `.metadata.version` in both marketplace manifests. Merging that PR tags `vX.Y.Z` and +# publishes the GitHub release with its notes. Per-plugin versions and changelogs stay +# author-maintained and are enforced by CI, not by this workflow. + +on: + push: + branches: [main] + +# One release run at a time, and never cancel one in progress: a cancelled run could leave +# a merged release PR untagged. A newer queued push replaces an older queued one, which is +# safe because every run reads the current state of main. +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +permissions: {} + +jobs: + release: + name: Tag and publish a merged release + runs-on: ubuntu-latest + # Creating the release creates the `vX.Y.Z` tag. Only GitHub Actions may create `v*` + # tags in this repository, so this step uses the workflow token, not the App token. + # `pull-requests: write` lets release-please relabel the merged release PR as + # `autorelease: tagged` and comment the release link; without it, the next run would + # find the PR still pending and try to release it again. + permissions: + contents: write # create the vX.Y.Z tag and the GitHub release + pull-requests: write # relabel and comment on the merged release PR + timeout-minutes: 10 + steps: + - name: 🏷️ Tag and publish a merged release PR + uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + with: + token: ${{ github.token }} + skip-github-pull-request: true + + release-pr: + name: Open or update the release PR + # Runs after the release job, because release-please refuses to open the next release PR + # while a merged release PR is still untagged. + needs: release + runs-on: ubuntu-latest + permissions: {} + timeout-minutes: 10 + steps: + - name: πŸ”‘ Generate GitHub App token + id: app-token + # A PR opened with the workflow token does not start CI, so the release PR could + # never pass its required checks. An App-authored PR does. + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + client-id: ${{ vars.APP_CLIENT_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + permission-contents: write + permission-pull-requests: write + + - name: πŸ“ Open or update the release PR + uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + with: + token: ${{ steps.app-token.outputs.token }} + skip-github-release: true diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..a5d1cf28 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.2.0" +} diff --git a/AGENTS.md b/AGENTS.md index e2eec8a1..bf705965 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,9 +21,7 @@ Copilot, and by Cursor, Codex, and Claude (via `CLAUDE.md` β†’ `@AGENTS.md`). β”‚ └── marketplace.json # Copilot / VS Code marketplace manifest (kept in parity with the Claude one) └── workflows/ β”œβ”€β”€ ci.yaml # Runs scripts/validate-manifests.sh + lint-scripts (shellcheck + self-test) + agentskills.io spec per skill - β”œβ”€β”€ prepare-marketplace-release.yaml # Manual, read-only release-candidate artifact - β”œβ”€β”€ propose-marketplace-release.yaml # Current-main assessment; separate opt-in signed draft creation - β”œβ”€β”€ publish-marketplace-release.yaml # Exact-main CI assessment; separate opt-in publication job + β”œβ”€β”€ release-please.yaml # Release PR on each push to main; merging it tags vX.Y.Z and publishes the release └── update-agent-skills.yaml # Daily gh skill update --all; one PR per drifted skill plugins/ └── / @@ -42,7 +40,9 @@ README.md # Short introduction and getting started docs/plugins.md # Validated plugin catalogue and resource inventory docs/installation.md # Per-tool installation instructions docs/resources.md # Bundled servers, agents, and onboarding -docs/marketplace-releases.md # Opt-in candidate preparation and publication boundary +docs/marketplace-releases.md # How release-please cuts marketplace releases +release-please-config.json # release-please configuration (one root package, vX.Y.Z tags) +.release-please-manifest.json # Last released marketplace version docs/validation.md # Every validation command, and how the CI gates behave docs/scripts.md # What each repository script is for ``` @@ -187,11 +187,10 @@ The daily updater still refreshes external skills independently with no lockfile it needs at the workflow or job level. Set `persist-credentials: false` on `actions/checkout` unless a job must push. 7. **Conventional-commit messages** (`feat:`/`fix:`/`chore:`/`ci:`/`docs:`/`refactor:`). The repo is - consumed directly as a marketplace. The opt-in [release-preparation command](docs/marketplace-releases.md) - calculates a repository version proposal from commit history. Publication is a separate manual - command, read-only unless explicitly invoked with `--publish`; it never overwrites existing tags - or releases. Establish current-head readiness before enabling that operation. - Per-plugin versions are moved explicitly, per the next convention. + consumed directly as a marketplace. [release-please](docs/marketplace-releases.md) reads those + titles on `main`, keeps one release PR that moves the marketplace `.metadata.version`, and + tags `vX.Y.Z` and publishes the GitHub release when that PR merges. Never edit the marketplace + version by hand. Per-plugin versions are moved explicitly, per the next convention. 8. **A plugin's version is its cache key β€” move it whenever its content changes.** Runtimes cache plugins by `//`, so a content change that leaves the version alone is unreachable for every consumer that already installed it: the update command reports "already at the @@ -270,15 +269,8 @@ row here rather than growing this file. ## Maintenance (autonomous AI engineer) -**Feature flags:** release preparation is explicit and read-only. Publication uses the existing -`--publish` CLI option or the Actions `publish` boolean input, both default-off. Automatic Actions -publication requires `MARKETPLACE_AUTOPUBLISH` to be exactly `true`; missing, false or any other -value disables it. Proposal creation uses `--propose` or the Actions `propose` boolean, both default-off; -scheduled creation separately requires `MARKETPLACE_AUTOPROPOSE` to be exactly `true`. Assessment -retains read-only permissions. Track rollout and eventual flag removal -in [#277](https://github.com/devantler-tech/agent-plugins/issues/277). -Historical content inspection requires the verifier's explicit `--inspect-existing` option. Its -`INSPECTED` result supplies no proposal, publication, remote-state or readiness clearance. +**Releases:** release-please keeps the marketplace release PR up to date on every push to `main`. +Drive it like any other PR: merging it is the release decision, and it publishes `vX.Y.Z`. These conventions guide the autonomous **Agentic Engineer** β€” and any agentic tool β€” doing repository maintenance. The **shared** cross-repo conventions are defined centrally in the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0312eef7..2a216915 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,6 @@ fork's branch to `devantler-tech/agent-plugins:main`, use the supplied PR templa for substantial work. Explain the reader problem, the outcome, and the checks you actually ran. Follow the [organization code of conduct](https://github.com/devantler-tech/.github/blob/main/.github/CODE_OF_CONDUCT.md), retain [license and attribution obligations](LICENSE), and disclose AI assistance when applicable. -Respond to findings; CI and an exact-current-head review must pass before merge. Release preparation -and publication are separate [maintainer operations](docs/marketplace-releases.md), not contribution -setup steps. +Respond to findings; CI and an exact-current-head review must pass before merge. Marketplace +releases are cut separately by an [automated release PR](docs/marketplace-releases.md), not by +contribution steps. diff --git a/README.md b/README.md index ae1c2c15..c4b51591 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ records which gaps to fill. Maintained first-party skills are authored in their plugins here; curated external skills retain their original authors and upstream update paths. To suggest a bundle or report a problem, [open an issue](https://github.com/devantler-tech/agent-plugins/issues). For a safe first repository change, start with [Contributing](CONTRIBUTING.md). -Maintainers can [prepare and publish a marketplace release](docs/marketplace-releases.md) with a reviewed version proposal, matching manifests, and verified release notes. Actions can explicitly create a signed draft containing only the generated marketplace versions and start normal PR CI. Review and merge remain separate gates. Pull-request CI checks that a version update exactly matches its generated proposal; publication separately requires exact successful main CI. Scheduled proposal creation and publication are independently opt-in. +Marketplace releases are cut by [release-please](docs/marketplace-releases.md): it keeps one reviewable release PR open, and merging it tags `vX.Y.Z` and publishes the GitHub release with its notes. If a pull-request recheck fails, follow the [recovery guide](docs/pr-recheck-recovery.md) to retrieve its saved merge settings and verify the current PR before restoring them. diff --git a/docs/marketplace-releases.md b/docs/marketplace-releases.md index e3c1d1a9..678967af 100644 --- a/docs/marketplace-releases.md +++ b/docs/marketplace-releases.md @@ -1,428 +1,58 @@ -# Prepare and publish a marketplace release +# Marketplace releases -A marketplace version describes the entire catalogue at a source revision. Each plugin retains its -own version and runtime cache identity. Release preparation produces a review artifact containing -the proposed marketplace version, release notes, and both updated marketplace manifests. +A marketplace version describes the whole catalogue at one commit of `main`. It is the +`.metadata.version` in both marketplace manifests, and each release is tagged `vX.Y.Z`. Each plugin +keeps its own version, which is its runtime cache key; the marketplace version does not replace it. -Preparation is opt-in and offline. It does not publish, create tags, change the checkout, or update -installed plugins. A candidate is not an installable marketplace snapshot: it contains manifest -proposals and identifies the source commit containing the plugins. +## How a release happens -Versions are complete canonical stable SemVer strings, without whitespace or line terminators. -Source manifests and native API observations must contain exactly one complete JSON value with -unique decoded object keys, including nested objects and paginated arrays. A GraphQL observation's -error envelope must be absent or an empty array; false, null and other malformed values refuse -proposal and publication observations, including signed-commit and draft readback responses. Contradictory fields -are refused before candidate, readiness, occupancy or writer decisions. An ambiguous response -after a write leaves any created remote objects intact and reports uncertainty for explicit recovery; -it never establishes completed publication or a verified draft. +[release-please](https://github.com/googleapis/release-please) cuts releases from the Conventional +Commit titles that squash merges leave on `main`. The +[Release Please workflow](../.github/workflows/release-please.yaml) runs on every push to `main`: -## Prepare locally +1. It opens or updates one **release PR**. The PR moves `.metadata.version` in + [`.claude-plugin/marketplace.json`](../.claude-plugin/marketplace.json) and + [`.github/plugin/marketplace.json`](../.github/plugin/marketplace.json) together, and its body holds + the release notes. The repository's GitHub App opens it, so normal CI runs on it. +2. The release PR is an ordinary pull request. Review it like any other, and merge it when the + release should go out. Until then it keeps collecting the changes that land on `main`. +3. Merging it tags the merge commit `vX.Y.Z` and publishes a GitHub release with the same notes. + GitHub Actions creates the tag, which is the only identity allowed to create `v*` tags here. -Use Bash, Git, iconv, and jq 1.6 or later from a complete repository clone. Each release helper derives -Git evidence and output exclusions from the caller's checkout. Inherited Git directory, worktree, -index, object-store and command-scoped configuration overrides cannot redirect that evidence. Configuration queries must -complete before an offline result is possible: only Git's no-match status proves an absent -partial-clone setting. Failed reads, including partial output, refuse preparation and validation; -lazy object fetching is disabled defensively. -Shallow and partial -(`--filter`) clones are refused, because reading their history would need the network. Refresh -tags from the trusted remote before choosing a baseline; the offline command cannot establish -remote freshness. +The version follows the commits merged since the last release: -For the first marketplace release, explicitly select `initial`: - -```sh -git fetch origin --tags -bash scripts/prepare-marketplace-release.sh \ - --base-tag initial --output /tmp/marketplace-candidate -``` - -The output directory must not exist, its parent must exist, and it must be outside every working -tree of the repository, linked worktrees included, so preparation never leaves files in a checkout. -Initial preparation uses the current marketplace manifest version and refuses to run if any stable -marketplace tag is present locally. It records the legacy first-parent history without inferring a -new version from that history. - -For a later release, name the latest reachable stable tag: - -```sh -bash scripts/prepare-marketplace-release.sh \ - --base-tag v1.0.0 --output /tmp/marketplace-next -``` - -`v1.0.0` is an example; use the verified baseline for the source being reviewed. The command reads -committed objects at `HEAD`, not uncommitted files. To prepare a specific revision, add -`--head `. Shallow history, a non-ancestor/side-branch baseline, mismatched -manifest versions, or a locally occupied candidate tag stops preparation without a candidate. - -The baseline must be on the source commit's first-parent history. Version calculation follows the -repository's squash-merge convention: - -| First-parent commit | Result | +| Commit title | Result | | --- | --- | -| A breaking `!` header or `BREAKING CHANGE:` / `BREAKING-CHANGE:` line | Major | -| `feat:` or a scoped feature | Minor | -| `fix:` or `perf:` | Patch | -| Other conventional types, or no new commits | No release | -| Reverts, blank descriptions, or nonconventional subjects | Stop for human assessment | - -The largest change wins. Type names are case-insensitive. Stable versions have three numeric -components, each from 0 to 999999999, with no leading zeroes. Prerelease and build-metadata versions -are not supported. The source manifests must still carry the baseline version: preparation does -not guess how to reconcile an independently edited version. - -## Inspect the result - -- `release.json` binds the source commit, baseline tag and commit, calculated version and release - type, first-parent commits, and plugin inventory. `publication: NOT_AUTHORIZED` is always present. -- `RELEASE_NOTES.md` presents that proposal and the contributing commit subjects as escaped text. -- `.github/plugin/marketplace.json` and `.claude-plugin/marketplace.json` contain identical proposed - marketplace manifests. Every other field, including plugin versions and rename history, is preserved. - -For `NO_RELEASE`, only the plan and notes are emitted; there are no proposed manifest updates. -Repeated preparation from the same Git objects produces identical files. Existing output paths are -never reused. Preparation checks that its entered reservation is empty before writing; writes and -artifact readback stay inside that directory. Movement detected by the directory-identity checks -refuses success and preserves both the replacement and any partial output for explicit recovery; -preparation never recursively removes a mutable public output pathname, including after a late -CI or ref refusal in merged preparation. These observations do not provide an atomic creation -handle or serialize other processes writing inside the directory. Use a separate new destination -for each preparation and inspect retained output before recovery. -Original JSON must preserve its bytes through Unicode validation and contain no unpaired surrogate -escapes. Valid international text and genuine replacement characters remain supported. -Preparation validates manifest shape and parity; full resource/provenance checks -remain the responsibility of `bash scripts/validate-manifests.sh` and the rest of repository CI. - -## Prepare in GitHub Actions - -Run **Prepare marketplace release** manually, select the source branch/ref, and provide the baseline -tag or `initial`. The workflow checks out the selected revision with full history, validates the -repository manifests, runs the same command, and uploads `marketplace-release--` for 14 days. -The archive includes the two hidden manifest directories. The job has read-only repository access; -this preparation workflow has no publishing job. - -## Publish the merged proposal in Actions - -**Publish marketplace release** supports manual main dispatch and an opt-in hourly check at minute -25 UTC. It uses -current-main tooling and regenerates the candidate from the version proposal's sole parent. The -assessment commit and its output bind to the actual current-main checkout, including when main -advances after dispatch. Both -remote main and the named CI run are checked before and after verification. A stale, foreign, -failed, PR or unrelated workflow run is refused. An ordinary commit reports `NO_VERSION_CHANGE` -and cannot publish. No downloaded artifact supplies publication authority. - -For manual assessment, select main and pass the successful main CI run ID: - -```sh -gh workflow run publish-marketplace-release.yaml --repo devantler-tech/agent-plugins \ - --ref main -f ci-run= -F publish=false -``` - -The assessment job has contents and Actions read access and uploads its regenerated candidate for -inspection. Publication is a separate job, disabled by default, with contents write and Actions -read access. To publish that exact current-main proposal, dispatch again with `-F publish=true`. -It reconstructs the candidate again, verifies the same CI run and current main, and invokes the -create-only publisher. Main movement refuses the operation rather than using stale evidence. - -Automatic publication after successful main CI is enabled only when the repository variable -`MARKETPLACE_AUTOPUBLISH` is exactly `true`. Missing, false or any other value leaves publication -disabled. Enable it only as a separate validated rollout step; remove or change it to disable the -automatic path. The rollout decision and eventual removal are tracked in -[#277](https://github.com/devantler-tech/agent-plugins/issues/277). - -The workflow does not create, approve or merge version proposals. Their review and CI gates remain -required. It accepts only a version-only proposal at current main, refuses occupied tags/releases, -and never overwrites or retries a write. Inspect remote objects after any failed publication; -a failure is not proof that no write happened. `GITHUB_TOKEN` publication is not a promise that -other release-triggered workflows ran. Independently verify the published tag, release, notes and -a real pinned consumer installation. The scheduled job runs only while the rollout variable is -enabled; GitHub can delay scheduled runs. The `ci-run` input defaults to `latest`, which selects the -newest exact-main push CI run and refuses it if pending or failed, rather than finding an older -green. A changed latest run identity also refuses verification. -[ADR 0012](adr/0012-guarded-marketplace-publication-workflow.md) -records the workflow's trust and permission boundaries. - -## Publication and recovery - -Before reserving a tag, verify the candidate against the exact proposed release commit: - -```sh -bash scripts/verify-marketplace-release.sh \ - --candidate /tmp/marketplace-next \ - --source \ - --release -``` - -Run the verifier from a complete clone using the reviewed repository tooling. Select the source -independently from the reviewed proposal, rather than trusting a value supplied by an arbitrary -download. For a subsequent release, copy the two proposed manifests into an isolated branch based -on that source, review and commit only those files, and pass that commit as `--release`. The release -commit must have exactly one parent, the selected source. Squash merging the version-only PR onto -that same source preserves this relationship. If main moves first, regenerate and review a new -candidate; do not reuse the stale assessment. For an initial release whose manifests already match, -the source itself may be the release commit. - -The verifier regenerates and compares the complete four-file candidate, rejects unexpected entries -and symlinks, checks both committed manifest values, and rejects unrelated tree or file-mode changes. -It reads Git objects, so a dirty checkout cannot supply evidence for the release. It makes no -checkout, index or ref changes and does not access the network. Committed manifests must match the -generated bytes, including formatting, so duplicate JSON keys cannot hide an unreviewed value. An -initial release may instead retain its unchanged source manifest bytes. Copy the generated files -without reformatting them. A `NO_RELEASE` plan is not a candidate -for verification. The intended tag must still be absent locally; this is not a post-publication -verification command. - -Pull-request CI enforces this contract whenever a branch changes the marketplace version. To run -that gate locally, supply the exact current base and proposed head: - -```sh -bash scripts/check-marketplace-version.sh -``` - -The gate detects version changes against the branch's unique merge base, so ordinary branches are -not blamed for releases that landed after they branched. A version proposal must be one commit on -the current base containing only the generated manifests. If main advances, regenerate the proposal -and repeat review and CI. The baseline is the stable tag matching the base manifests' version; -missing history, malformed or ambiguous versions, and stale proposals fail closed. An unchanged -marketplace version returns `NO_VERSION_CHANGE`; that result does not approve a release. - -The gate uses the pull request's actual head, not its synthetic merge commit. It is intentionally -pre-merge: main CI reruns must continue to work after the release tag exists. After merging, still -run the verifier and publisher against the actual merged commit as described below. -[ADR 0011](adr/0011-marketplace-version-proposal-gate.md) records this boundary. - -Only exit zero with a single JSON result reporting `status: VERIFIED` is a successful local -assessment. It includes both full commits and `authority: assessment-only`, with -`publication: NOT_AUTHORIZED`. Invalid input or any mismatch exits nonzero without a success result. -The same inputs produce the same assessment. Re-run it against the final merged release commit; -an earlier PR commit's result does not transfer to a new commit. - -This check cannot establish remote freshness, genuine readiness, who reviewed the source, or actual -consumer installation. Keep the candidate immutable while reviewing and verifying it; a later edit -invalidates the result. Full repository validation and the independent review gate still apply. - -### Inspect a retained proposal after its tag is occupied +| A breaking `!` header or a `BREAKING CHANGE:` footer | Major | +| `feat:` | Minor | +| `fix:`, `perf:` or `revert:` | Patch | +| Other types, such as `chore:`, `docs:` or `ci:` | No release on their own | -For an operator investigating a retained candidate or completed release, explicitly select the -verifier's read-only historical mode: +The configuration is in [`release-please-config.json`](../release-please-config.json): a single root +package with the `simple` release type, tags without a component, and no root changelog. The last +released version is recorded in [`.release-please-manifest.json`](../.release-please-manifest.json); +release-please updates it in each release PR. Never edit either manifest's `.metadata.version` by +hand. -```sh -bash scripts/verify-marketplace-release.sh \ - --candidate /tmp/retained-marketplace-candidate \ - --source \ - --release \ - --inspect-existing -``` - -Use reviewed tooling from a complete local clone and keep the candidate immutable. The inspector -reuses the complete candidate reproduction, source parent, two-manifest tree and file-mode checks -in a disposable local repository. Only that private repository's copy of the candidate tag is -removed for reconstruction. The caller's tags, branches, index and working files are preserved; -neither GitHub nor another remote is contacted. Inherited Git layout overrides are neutralized. -Physical checkout pathnames retain all their bytes, including trailing newlines. Verification keeps -configured filesystem observation hooks inert and preserves the caller's index and configuration. - -Success emits `status: INSPECTED`, `scope: local-historical-content`, and a `localTag` snapshot. -`PRESENT` records the tag object, resolved commit and whether it targets the nominated release; -`ABSENT` records null identities and match status. A different target is reported without adopting -or changing it. A non-commit tag or any tag-inventory movement during inspection is refused. - -This is content evidence for an operator decision. `proposal: NOT_AUTHORIZED`, -`publication: NOT_AUTHORIZED`, `readiness: NOT_ASSESSED` and `remoteState: UNKNOWN` remain explicit. -`INSPECTED` never satisfies a writer's `VERIFIED` contract, reserves a version, authenticates a -proposal author, or establishes current main, CI, review or consumer discovery. The ordinary -verifier still refuses an occupied tag. Inspect remote identities and permissions separately; -regenerate and review a new current-main candidate before any subsequent write. - -All other local tags remain available to the strict history checks. Initial-release reconstruction -still requires no other stable tags, and a changed baseline identity is refused. Inspection does -not manufacture missing historical evidence or permit an arbitrary baseline. A snapshot can change -after the final observation; the result is not an atomic reservation. -[ADR 0015](adr/0015-historical-marketplace-content-inspection.md) records this boundary. - -## Check against GitHub - -After the proposed release commit lands on the default branch, use the opt-in remote assessment: - -```sh -bash scripts/check-marketplace-release-remote.sh \ - --repo devantler-tech/agent-plugins \ - --candidate /tmp/marketplace-next \ - --source \ - --release -``` - -This needs an authenticated `gh` with effective repository write permissions, so draft releases -are visible; the operation itself creates no remote objects. Both user and GitHub App authentication -are supported. Each observation reads the native REST repository and binds its immutable node ID, -name, default branch and archive state to GraphQL. It also calls GitHub's nonpersistent release-note -generation endpoint with the candidate tag and exact commit. This endpoint requires contents-write -access and saves nothing remotely; its successful, well-formed response proves writer capability. -The generated text is discarded and never supplies publication notes or authority. A user role must -be WRITE, MAINTAIN or ADMIN; an explicitly null App role still requires the same positive native -capability proof. Missing fields, unknown roles, failed capability checks and incomplete responses -are refused. Repository permission projections alone do not establish an installation token's access. Choose -the repository independently of the candidate. The command uses that explicit identity and host, -not the checkout's Git transport configuration or `GH_HOST`. - -It runs the local verifier and compares the complete local tag inventory with GitHub, including -annotated tag object identities. The selected release must be the remote default-branch tip, and -both its intended tag and GitHub release must be absent. GraphQL errors, missing fields, incomplete -pagination and conflicting observations fail closed. A draft release also occupies the version. -An account with only read or triage access cannot establish draft absence and is refused. -See [GitHub's release visibility rules](https://docs.github.com/en/rest/releases/releases#list-releases). -The command repeats the remote observation around another local verification and rejects movement -of the default branch, tags or release, or a change in local tags during the check. - -Exit zero emits one JSON assessment with `scope: remote-prepublication-snapshot`, the repository, -immutable repository ID, default branch, full commits and observed tag inventory. `authority: assessment-only` and -`publication: NOT_AUTHORIZED` remain unchanged. It never fetches into your clone, edits files or -refs, reserves tags, or creates releases. The command is manual; no publishing trigger is enabled. - -When tags disagree, refresh them in an isolated complete clone and regenerate the candidate there. -Do not overwrite a conflicting tag or reuse a stale assessment. When the default branch has moved, -prepare and review a new candidate from its current source. This check records two agreeing -observations, not an atomic reservation: state can change between reads or immediately afterward. -It cannot prove review readiness, release permissions, or consumer discovery. The publisher below -reserves the tag with a create-only operation and verifies the published result independently. - -[ADR 0009](adr/0009-marketplace-remote-assessment.md) records this observation boundary. - -## Create a version proposal through Actions - -The proposal workflow prepares the next marketplace version from current main and the latest stable -published baseline. Manual dispatch defaults to read-only assessment: - -```sh -gh workflow run propose-marketplace-release.yaml --repo devantler-tech/agent-plugins \ - --ref main -f ci-run=latest -F propose=false -``` +## What stays with each pull request -It matches complete local and remote tag objects, the published baseline commit, immutable repository -identity and exact successful main push CI. It refuses an occupied proposal branch, candidate release -or an open PR touching either marketplace manifest. A complete unrelated PR is not a blocker. The -latest selector refuses a pending or failed latest CI run rather than finding an older green one. -For renamed PR files, complete REST filename/status records must match GraphQL before the original -paths are considered. Moving a manifest away is a conflict; complete unrelated renames are allowed. -The CI workflow identity accepts its plain path or the exact main-qualified forms -`.github/workflows/ci.yaml@main` and `.github/workflows/ci.yaml@refs/heads/main`. -Two agreeing observations and byte-exact private reconstruction are required. `NO_CHANGE` performs -no writes, including when proposal creation was requested. Evidence artifacts supply no write authority. -Read-only candidate-release visibility is the reader's projection; it does not establish visibility of -every draft release. The writer repeats occupancy checks with positively proven native write capability -before creating objects. `PREPARED` is an assessment, not a reservation or mutation clearance. +Release-please does not move plugin versions. A PR that changes a plugin's shipped content still +bumps that plugin with [`scripts/bump-plugin-version.sh`](../scripts/bump-plugin-version.sh) and adds +a matching entry to `plugins//CHANGELOG.md`. CI's **Check version bump** job enforces both; +see [validation](validation.md). -To deliberately create the reviewed-tooling proposal, use the same dispatch with **`-F propose=true`**. -The native Actions bot reconstructs its own candidate. It creates a new deterministic branch and a -GitHub-signed commit containing only the generated marketplace manifests, preserving individual -plugin versions. The expected parent prevents appending to another writer's branch. Independent -signature readback, a fresh fetch and exact release-tree verification precede draft creation. -Final readback binds the bot author, branch, source, commit, draft, title and plain-language body. -Only `CREATED` with `proposal: DRAFT_READBACK_VERIFIED` reports success. +## Install a released version -The final job dispatches the existing `recheck-open-prs.yaml` on main so the normal App-backed reopen -starts fresh required PR checks. That dispatch reports a request, not successful CI. The draft still -requires current-head checks, substantive review, zero unresolved findings and normal promotion and -merge. It is never automatically promoted or merged, and proposal creation never reserves a release -tag or publishes a release. - -Read-only local assessment uses the same command without write opt-in: - -```sh -bash scripts/propose-marketplace-release.sh --repo devantler-tech/agent-plugins \ - --source --ci-run latest --output /tmp/marketplace-proposal -``` - -The CLI's `--propose` writer requires native Actions authentication. It refuses another actor before -creating a branch. Contents-write capability is positively checked without saving provider-generated -notes at each write phase. Preparation needs contents, actions and pull-request read permissions; -creation adds contents and pull-request write, while the separate CI dispatcher has only actions write. -Checkouts retain no credentials and read-only artifacts are never downloaded into the writer. -Final draft readback joins independent REST and GraphQL PR observations by their exact PR and -author node identities. The author must be REST `Bot` `github-actions[bot]` and GraphQL `Bot` -`github-actions`; missing identities, human actors or mismatched projections are refused. - -Scheduled proposal creation runs hourly at minute 35 UTC only when `MARKETPLACE_AUTOPROPOSE` is -exactly `true`. Missing, false or any other value disables scheduled work. This variable is independent -of publication's flag. Both remain default-off; rollout and eventual removal are tracked in #277. -All armed manual and scheduled runs share one writer queue. Read-only assessments use a separate -queue and cannot displace a queued writer; an active writer is never cancelled by a newer dispatch. - -### Recover a partial proposal - -Branch creation, signed commit creation and draft creation are separate create-only operations. A -failed response can follow a successful write. The tool never retries, updates, deletes or adopts -existing remote objects. On failure it names the repository, branch and source to inspect; it emits -no delivered result. Retain the candidate, inspect the actual branch and any draft, and independently -verify their parent, two-manifest tree and author before choosing an operator recovery. Preserve a -competing writer's objects. A later invocation refuses an occupied or partially created branch; -rerunning it is not a resume operation. Main advancement requires a fresh candidate and readiness. -If the candidate tag is already occupied, use the explicit historical inspection above for local -content evidence; its result does not authorize resuming the partial writer. - -[ADR 0014](adr/0014-create-only-marketplace-proposals.md) records this boundary. - -## Publish the reviewed commit - -First establish genuine readiness at the final merged commit: successful repository validation and -required CI, completed current-head review with no unresolved findings, and the deployment's authority -to release it. Neither a candidate nor a successful assessment establishes those independent gates. -Use reviewed tooling from a complete clone and independently select the repository and full commits. - -Run the publisher without its write option for another read-only assessment: - -```sh -bash scripts/publish-marketplace-release.sh \ - --repo devantler-tech/agent-plugins \ - --candidate /tmp/marketplace-next \ - --source \ - --release -``` - -To deliberately publish, add **`--publish`** to that same command. It regenerates a private candidate -from the verified Git objects, assesses fresh remote state, reserves the tag at the selected commit, -and creates a public, non-draft release. Publication notes render the verified plan's escaped commit -subjects and plugin inventory with source/release identities; the proposal-only warning is not used -as a published release description. GitHub's version-based latest-release selection is used. - -Both remote writes are create-only, attempted once. Existing tags or releases are never updated, -deleted or reused, even if they appear to match. A fresh read between writes checks the default branch, -reserved tag and absent release. Each phase also re-reads effective native permissions and binds -both API identities to the immutable repository ID established during assessment and repeats the -nonpersistent capability check. Losing permission -or changing repository identity stops publication. A final independent read verifies the published release ID, notes, -tag commit and URL. Only exit zero with `status: PUBLISHED` and `scope: remote-publication-readback` -reports successful publication. The default mode retains `publication: NOT_AUTHORIZED` and makes no -remote writes. No scheduled publishing workflow is enabled. - -After success, verify an actual consumer against the release tag and resolve its installed provenance -back to the reported release commit. Native plugin discovery and updates depend on the chosen runtime; -publication does not modify installed caches. For a skills-only smoke test in a disposable directory: +Consumers can pin a release tag. For a skills-only smoke test in a disposable directory: ```sh gh skill install devantler-tech/agent-plugins \ plugins/agentic-engineering/skills/agent-instructions \ - --pin v1.0.0 --dir /tmp/marketplace-release-smoke + --pin v2.2.0 --dir /tmp/marketplace-release-smoke ``` -Replace the example tag with the verified published tag. Check the installed file and provenance; -the install command exiting successfully alone is not sufficient. - -### Recover a partial attempt - -A failed write response may still mean the write succeeded. On any failure after a write was attempted, -the command prints the repository, tag and exact commit to investigate. It emits no success result and -never retries or rolls back automatically. Inspect that tag and both draft/published release state with -write-capable visibility before deciding what to do. Preserve a conflicting writer's objects. An -existing reservation requires an operator decision; rerunning the command does not resume it. - -Remote reads and the two writes are not atomic. A competing writer or default-branch movement can -make a later check fail after the tag or release exists. A nonzero exit is not proof of absence. Record -the observed state, restore correctness through the normal reviewed procedure, and independently -verify any manual recovery. Discarding an unused local candidate needs no repository rollback. +Replace the example tag with the release you are checking, then check the installed file and its +provenance; the command exiting successfully is not enough on its own. -[ADR 0008](adr/0008-marketplace-release-preparation.md) defines this boundary. -[ADR 0010](adr/0010-create-only-marketplace-publication.md) records the publication and recovery rules. -[ADR 0013](adr/0013-native-publication-permission-proof.md) records the native permission and identity proof. +Earlier releases were cut by a custom preparation, proposal and publication toolchain. The ADRs under +[`docs/adr/`](adr/) from 0008 to 0015 record that history. diff --git a/docs/scripts.md b/docs/scripts.md index 00fb909f..956071d9 100644 --- a/docs/scripts.md +++ b/docs/scripts.md @@ -10,12 +10,11 @@ complete inventory; read a script's header for its arguments and safeguards. | Update versions and release notes | Use [bump-plugin-version.sh](../scripts/bump-plugin-version.sh) and add a matching changelog entry; skill syncs use [plugin-changelog.sh write](../scripts/plugin-changelog.sh) | | Refresh generated resource digests | [refresh-desired-state-digests.sh](../scripts/refresh-desired-state-digests.sh) | | Synchronize one curated plugin | Dispatch [Update Agent Skills](../.github/workflows/update-agent-skills.yaml) with `agentic-engineering`; [skill-update-scope.sh](../scripts/skill-update-scope.sh) resolves only declared selections before the normal per-skill updater runs. Default and scheduled `all` updates still cover the full catalogue. | -| Prepare or inspect a marketplace release | [Release guide](marketplace-releases.md) and [prepare-marketplace-release.sh](../scripts/prepare-marketplace-release.sh) | -| Propose or publish a marketplace release | [Release guide](marketplace-releases.md), which explains the separate opt-in steps and recovery | +| Cut a marketplace release | No script: merge the release-please release PR, as the [release guide](marketplace-releases.md) explains | | Recheck open pull requests after changing CI | [recheck-open-prs.sh](../scripts/recheck-open-prs.sh) | The directory also contains checks for package discovery, skill provenance, licensing and authoring rules, -version changes, changelogs, generated writes, release observations and instruction size. +version changes, changelogs, generated writes and instruction size. The [validation guide](validation.md) explains which checks to run and what they establish. The scope resolver also passes any reviewed skill hold, as ` `, to diff --git a/docs/tool-ownership.md b/docs/tool-ownership.md index 6d6418ff..3b66e9ee 100644 --- a/docs/tool-ownership.md +++ b/docs/tool-ownership.md @@ -39,7 +39,7 @@ Their documented interfaces are supported here; none establishes an independent | Candidate | Observed caller and task | Ownership rationale | |---|---|---| -| [`validate-manifests.sh`](../scripts/validate-manifests.sh) | CI, release preparation/publication workflows and maintainer instructions validate manifests, provenance and resource parity | Marketplace schema and consumer promises belong here. A generic schema checker does not replace the parity and provenance policy. | +| [`validate-manifests.sh`](../scripts/validate-manifests.sh) | CI and maintainer instructions validate manifests, provenance and resource parity | Marketplace schema and consumer promises belong here. A generic schema checker does not replace the parity and provenance policy. | | [`bump-plugin-version.sh`](../scripts/bump-plugin-version.sh) | Skill-update workflow and maintainer invocation move four related manifests together | Keep version selection with the four manifests. The assessment found failed Git observations could be accepted; [#319](https://github.com/devantler-tech/agent-plugins/issues/319) tracks the repair. | | [`check-plugin-version-bump.sh`](../scripts/check-plugin-version-bump.sh) | CI compares a change with its merge base and requires changed plugin content to move version | The cache/version promise is marketplace policy. The same discovery failure is covered by #319; a language migration would not itself correct it. | | [`guard-bundled-skill-edits.sh`](../scripts/guard-bundled-skill-edits.sh) | PR CI checks changed paths against base provenance and the authorized sync writer | Retain the source-ownership and writer rules here. Skill installation transport cannot decide this repository's editing exemption. | @@ -53,23 +53,12 @@ Their documented interfaces are supported here; none establishes an independent ## Marketplace release tools -These eight `scripts/` entrypoints also stay repository-local. GitHub CLI owns forge transport; -the marketplace owns version occupancy, content reconstruction and create-only publication policy. -Shared use of the release API does not make source-skill and marketplace publication interchangeable. - -| Candidate | Observed caller and responsibility | -|---|---| -| [`prepare-marketplace-release.sh`](../scripts/prepare-marketplace-release.sh) | Preparation workflow, proposal helper, publication helper and merged-proposal verifier reproduce a candidate from exact Git history. The assessment found an unchecked second worktree census and newline-trimming output boundary; [#323](https://github.com/devantler-tech/agent-plugins/pull/323) delivers the repair for #322. | -| [`verify-marketplace-release.sh`](../scripts/verify-marketplace-release.sh) | Proposal, publication and merged-proposal helpers verify candidate contents and commit relationships. Its explicit historical-inspection option delegates to the inspector. | -| [`inspect-marketplace-release.sh`](../scripts/inspect-marketplace-release.sh) | The verifier's opt-in historical path checks occupied releases without granting fresh publication readiness. | -| [`check-marketplace-version.sh`](../scripts/check-marketplace-version.sh) | PR CI and merged-proposal preparation check the proposed marketplace version against reproduced content. | -| [`check-marketplace-release-remote.sh`](../scripts/check-marketplace-release-remote.sh) | Publication helper and documented maintainer assessment inspect remote tag/release occupancy before a write. | -| [`prepare-merged-marketplace-release.sh`](../scripts/prepare-merged-marketplace-release.sh) | Publication workflow reconstructs the selected merged release with exact successful main CI. | -| [`propose-marketplace-release.sh`](../scripts/propose-marketplace-release.sh) | Proposal workflow assesses current main and separately opts into a signed, create-only draft proposal. | -| [`publish-marketplace-release.sh`](../scripts/publish-marketplace-release.sh) | Publication workflow separately opts into create-only publication after reproducing local and remote evidence. | - -The distinct contracts separate read-only assessment from a separately authorized write. -Collapsing those boundaries into one apparently generic publisher is not a behavior-preserving extraction. +The eight release entrypoints this assessment recorded here (preparation, verification, historical +inspection, version-proposal checking, remote assessment, merged-release preparation, proposal and +publication) and their jq modules were retired in +[#705](https://github.com/devantler-tech/agent-plugins/issues/705). Marketplace releases are now cut +by release-please, as the [release guide](marketplace-releases.md) describes. ADRs 0008 to 0015 keep +the history of that toolchain. ## Installed agent and skill helpers @@ -88,10 +77,8 @@ owning plugin or upstream skill**, released and installed as that resource rathe ## Companion mechanisms and alternatives -The five local jq modules (`marketplace-release`, `marketplace-remote-state`, `marketplace-publication`, -`marketplace-proposal`, `marketplace-permissions`) are invoked by their release wrappers. They retain -marketplace policy: candidate calculation, remote occupancy, native identity/capability joins and -proposal/publication decisions. Keep them local. The CommonMark companion +The local jq module `marketplace-release` now holds only the canonical stable-version predicates that +the manifest validator and the cache-version tools share; keep it local. The CommonMark companion [`changelog-headings.cjs`](../scripts/changelog-headings.cjs) is invoked by the changelog wrapper and uses the locked existing parser; rewriting its grammar merely to change language is not a demonstrated benefit. This assessment grants no new embedded-language exception. diff --git a/docs/validation.md b/docs/validation.md index af3e9e8c..db67c416 100644 --- a/docs/validation.md +++ b/docs/validation.md @@ -86,22 +86,8 @@ bash scripts/plugin-changelog-release-boundaries.test.sh # caller identity, comm ./scripts/refresh-desired-state-digests.sh --check bash scripts/generated-write-safety.test.sh # resource refusal and failed batch-write recovery -# 1d. Offline marketplace candidate preparation: real Git histories, no publication. -# Source manifests and every native release/proposal observation require unique decoded -# object keys before semantic checks, including objects inside paginated arrays. Stable -# versions contain no whitespace or line terminators. Partial-write ambiguity remains -# uncertain and preserves remote objects for explicit recovery. -bash scripts/marketplace-caller-context.test.sh # inherited Git selectors cannot redirect caller evidence -bash scripts/prepare-marketplace-release.test.sh -bash scripts/release-observation-boundaries.test.sh # original Unicode, census completeness and reserved output identity -bash scripts/verify-marketplace-release.test.sh # artifact reproduction and exact release-tree binding -bash scripts/inspect-marketplace-release.test.sh # historical content, occupied tags and caller-state preservation -bash scripts/check-marketplace-release-remote.test.sh # remote state, pagination and movement; offline forge -bash scripts/publish-marketplace-release.test.sh # opt-in publication, competing writers and readback; offline forge -bash scripts/prepare-merged-marketplace-release.test.sh # exact main CI and fresh proposal reconstruction -bash scripts/marketplace-publication-workflow.test.sh # actual workflow authorization and permission branches -bash scripts/propose-marketplace-release.test.sh # signed draft creation and complete readback; offline forge -bash scripts/marketplace-proposal-workflow.test.sh # default-off proposal and CI dispatch boundaries +# 1d. Signed skill metadata publication: scoped App-signed requests and complete readback. +# Marketplace releases need no local step: release-please cuts them (docs/marketplace-releases.md). bash scripts/publish-skill-metadata.test.sh # scoped App-signed requests and complete readback; offline forge # 1e. AGENTS.md is loaded by every session and must stay under the 32 KiB Codex reads; @@ -151,7 +137,7 @@ at the base commit and preserves whole path components, including embedded and t never supply provenance, and malformed base provenance remains UNKNOWN. The required gate is the aggregated **`CI - Required Checks`** job. It requires retired-repository -link checks, manifest validation, script lint/tests, marketplace tests, package tests, version/changelog +link checks, manifest validation, script lint/tests, package tests, version/changelog checks, the bundled-skill edit guard, and skill-spec validation. The exact dependency list lives in [`ci.yaml`](../.github/workflows/ci.yaml); `actionlint` above is a local-only convenience, not a CI gate. Never weaken a check to pass β€” fix the root cause. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..f0fda873 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "simple", + "include-component-in-tag": false, + "include-v-in-tag": true, + "skip-changelog": true, + "packages": { + ".": { + "extra-files": [ + { + "type": "json", + "path": ".claude-plugin/marketplace.json", + "jsonpath": "$.metadata.version" + }, + { + "type": "json", + "path": ".github/plugin/marketplace.json", + "jsonpath": "$.metadata.version" + } + ] + } + } +} diff --git a/scripts/check-marketplace-release-remote.sh b/scripts/check-marketplace-release-remote.sh deleted file mode 100755 index da11d6ee..00000000 --- a/scripts/check-marketplace-release-remote.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -# Read-only prepublication snapshot. This does not reserve a tag or authorize publication. -set -euo pipefail -export GIT_NO_REPLACE_OBJECTS=1 -here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# shellcheck source=scripts/marketplace-git-context.lib.sh -. "$here/marketplace-git-context.lib.sh" -marketplace_git_context -# shellcheck source=scripts/json-object.lib.sh -. "$here/json-object.lib.sh" -# Stop without emitting a successful remote assessment. -fail() { printf 'remote release assessment: %s\n' "$*" >&2; exit 1; } -# Describe the candidate and exact source/release commit selectors. -usage() { printf 'usage: check-marketplace-release-remote.sh --repo --candidate --source --release \n'; } -repo='' candidate='' source='' release='' -while [ "$#" -gt 0 ]; do - case "$1" in - --repo|--candidate|--source|--release) - if [ "$#" -lt 2 ] || [ -z "$2" ]; then fail 'each option requires a value'; fi - case "$1" in - --repo) [ -z "$repo" ] || fail 'duplicate repo'; repo=$2 ;; - --candidate) [ -z "$candidate" ] || fail 'duplicate candidate'; candidate=$2 ;; - --source) [ -z "$source" ] || fail 'duplicate source'; source=$2 ;; - --release) [ -z "$release" ] || fail 'duplicate release'; release=$2 ;; - esac - shift 2 ;; - --help) usage; exit 0 ;; - *) fail "unknown argument: $1" ;; - esac -done -[[ "$repo" =~ ^[A-Za-z0-9][A-Za-z0-9-]*/[A-Za-z0-9][A-Za-z0-9_.-]*$ ]] || fail 'repo must be an explicit github.com owner/name' -[[ "$source" =~ ^[0-9a-f]{40}$ && "$release" =~ ^[0-9a-f]{40}$ ]] || fail 'source and release must be full commits' -[ -n "$candidate" ] || fail 'candidate is required' -temp=$(mktemp -d "${TMPDIR:-/tmp}/marketplace-remote.XXXXXX") -trap 'rm -rf "$temp"' EXIT -# Regenerate and validate the complete local candidate against exact Git objects. -verify() { - bash "$here/verify-marketplace-release.sh" --candidate "$candidate" --source "$source" --release "$release" -} -# Validate before contacting the forge, including artifact types and all candidate bytes. -verify > "$temp/assessment" -tag=$(jq -er '.tag' "$temp/assessment") -jq -n --arg tag "$tag" --arg release "$release" '{tag_name:$tag,target_commitish:$release}' > "$temp/writer-request" -# shellcheck disable=SC2016 # GraphQL variables are passed separately as data. -query='query($owner:String!,$name:String!,$tag:String!,$endCursor:String) { - repository(owner:$owner,name:$name) { - id nameWithOwner isArchived viewerPermission defaultBranchRef { name target { __typename oid } } - release(tagName:$tag) { tagName isDraft isPrerelease } - refs(refPrefix:"refs/tags/",first:100,after:$endCursor,orderBy:{field:ALPHABETICAL,direction:ASC}) { - totalCount pageInfo { hasNextPage endCursor } nodes { name target { __typename oid } } - } - } -}' -# Capture every local tag object so missing or stale refs cannot establish absence. -local_tags() { - git for-each-ref --format='%(refname:strip=2) %(objectname)' refs/tags/ > "$temp/local-refs" - jq -Rn '[inputs | split(" ") | {name:.[0],oid:.[1]}] | sort_by(.name)' < "$temp/local-refs" -} -# Read positive writer capability and complete remote state without creating objects. -remote_snapshot() { - # Bind repository identity and positively exercise contents-write without saving notes. - gh api --hostname github.com "repos/$repo" > "$temp/permission" - json_object_unique "$temp/permission" || fail 'ambiguous repository observation' - gh api --hostname github.com --method POST "repos/$repo/releases/generate-notes" \ - --input "$temp/writer-request" > "$temp/writer" - json_object_unique "$temp/writer" || fail 'ambiguous writer capability observation' - # Variables remain data; neither candidate content nor configured Git transports choose the host. - gh api graphql --hostname github.com --paginate --slurp -f query="$query" \ - -f owner="${repo%%/*}" -f name="${repo#*/}" -f tag="$tag" > "$temp/pages" - json_value_unique "$temp/pages" || fail 'ambiguous remote page observation' - # --slurp must return exactly one array. Do not accept trailing JSON or a partial API result. - jq -es 'length == 1 and (.[0] | type == "array")' "$temp/pages" >/dev/null || fail 'invalid page stream' - jq -e -L "$here" --arg repo "$repo" --arg release "$release" --slurpfile permission "$temp/permission" \ - --slurpfile writer "$temp/writer" \ - -f "$here/marketplace-remote-state.jq" "$temp/pages" > "$temp/remote" - jq -r '.tags[].name' "$temp/remote" > "$temp/tag-names" - while IFS= read -r name; do - git check-ref-format "refs/tags/$name" || fail 'invalid remote tag name' - [ "$name" != "$tag" ] || fail 'candidate tag is already reserved remotely' - done < "$temp/tag-names" - jq '.tags' "$temp/remote" > "$temp/remote-tags" - cmp -s "$temp/local-tags" "$temp/remote-tags" || fail 'local and remote tags differ; refresh in an isolated clone' - cat "$temp/remote" -} -local_tags > "$temp/local-tags" -remote_snapshot > "$temp/before" -verify > "$temp/reassessment" -cmp -s "$temp/assessment" "$temp/reassessment" || fail 'local assessment changed' -remote_snapshot > "$temp/after" -cmp -s "$temp/before" "$temp/after" || fail 'remote state changed during assessment' -local_tags > "$temp/final-local-tags" -cmp -s "$temp/local-tags" "$temp/final-local-tags" || fail 'local tags changed during assessment' -jq --slurpfile remote "$temp/after" '. + {repository:$remote[0].repository, - repositoryId:$remote[0].repositoryId,defaultBranch:$remote[0].defaultBranch,remoteTags:$remote[0].tags,candidateRelease:"ABSENT", - scope:"remote-prepublication-snapshot"}' "$temp/reassessment" diff --git a/scripts/check-marketplace-release-remote.test.sh b/scripts/check-marketplace-release-remote.test.sh deleted file mode 100755 index c5062895..00000000 --- a/scripts/check-marketplace-release-remote.test.sh +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/env bash -# Real Git histories and an offline forge: assessments must never perform writes. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -tool="$root/scripts/check-marketplace-release-remote.sh" -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false -export REMOTE_FIXTURE="$work/remote" REMOTE_SECOND="$work/second" CALLS="$work/calls" -export PERMISSION_FIXTURE="$work/permission" PERMISSION_SECOND="$work/permission-second" -export WRITER_FIXTURE="$work/writer" WRITER_SECOND="$work/writer-second" -mkdir "$work/bin" -cat > "$work/bin/gh" <<'STUB' -#!/usr/bin/env bash -set -euo pipefail -if [ "$*" = 'api --hostname github.com repos/example/catalogue' ]; then - printf 'repository\n' >> "$CALLS" - [ "${FORGE_FAIL:-false}" != true ] || exit 92 - if [ "$(grep -c '^repository$' "$CALLS")" -gt 1 ] && [ -e "$PERMISSION_SECOND" ]; then cat "$PERMISSION_SECOND"; else cat "$PERMISSION_FIXTURE"; fi - exit 0 -fi -if [ "$#" -eq 8 ] && [ "$1 $2 $3 $4 $5 $6 $7" = 'api --hostname github.com --method POST repos/example/catalogue/releases/generate-notes --input' ]; then - printf 'writer\n' >> "$CALLS" - [ "${WRITER_FAIL:-false}" != true ] || exit 93 - jq -e --arg tag "$FIXTURE_TAG" --arg head "$FIXTURE_HEAD" '.=={tag_name:$tag,target_commitish:$head}' "$8" >/dev/null || exit 94 - if [ "$(grep -c '^writer$' "$CALLS")" -gt 1 ] && [ -e "$WRITER_SECOND" ]; then cat "$WRITER_SECOND"; else cat "$WRITER_FIXTURE"; fi - exit 0 -fi -printf 'graphql\n' >> "$CALLS" -[[ "$*" == 'api graphql '* && "$*" == *'--hostname github.com'* && "$*" == *'--paginate --slurp'* ]] || exit 90 -[[ "$*" != *mutation* && "$*" == *'owner=example'* && "$*" == *'name=catalogue'* ]] || exit 91 -[[ ${FORGE_FAIL:-false} != true ]] || exit 92 -if [ "$(grep -c '^graphql$' "$CALLS")" -gt 1 ] && [ -e "$REMOTE_SECOND" ]; then cat "$REMOTE_SECOND"; else cat "$REMOTE_FIXTURE"; fi -STUB -chmod +x "$work/bin/gh" -export PATH="$work/bin:$PATH" -passed=0 -# Stop on the first behavior that violates the remote assessment contract. -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } -# Build a complete candidate from real Git history and reset independent API fixtures. -setup() { - repo=$(mktemp -d "$work/repo.XXXXXX") - candidate="$repo-candidate" - git -C "$repo" init -q - git -C "$repo" config user.name Test - git -C "$repo" config user.email test@example.invalid - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - printf '%s\n' '{"name":"example","metadata":{"version":"1.2.3"},"plugins":[{"name":"example","version":"4.5.6","source":"./plugins/example"}]}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'Initial import' - base=initial - if [ "${1:-}" = incremental ]; then - git -C "$repo" -c tag.gpgsign=false tag -a v1.2.3 -m baseline - git -C "$repo" commit --allow-empty -qm 'feat: expand catalogue' - base=v1.2.3 - fi - source=$(git -C "$repo" rev-parse HEAD) - (cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag "$base" --output "$candidate") >/dev/null - if [ "$base" != initial ]; then - cp "$candidate/.github/plugin/marketplace.json" "$repo/.github/plugin/marketplace.json" - cp "$candidate/.claude-plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'chore(release): prepare version' - fi - release=$(git -C "$repo" rev-parse HEAD) - export FIXTURE_HEAD="$release" FIXTURE_TAG - FIXTURE_TAG=$(jq -r .tag "$candidate/release.json") - rm -f "$REMOTE_SECOND" "$PERMISSION_SECOND" "$WRITER_SECOND" - unset FORGE_FAIL WRITER_FAIL - snapshot -} -# Construct a complete remote inventory and successful nonpersistent capability response. -snapshot() { - git -C "$repo" for-each-ref --format='%(refname:strip=2) %(objectname)' refs/tags/ > "$work/tags" - jq -Rn --arg head "$release" '[inputs | split(" ") | {name:.[0],target:{__typename:"Tag",oid:.[1]}}] as $tags | - [{data:{repository:{id:"R_catalogue",nameWithOwner:"example/catalogue",isArchived:false,viewerPermission:"WRITE", - defaultBranchRef:{name:"main",target:{__typename:"Commit",oid:$head}},release:null, - refs:{totalCount:($tags|length),nodes:$tags,pageInfo:{hasNextPage:false,endCursor:null}}}}}]' < "$work/tags" > "$REMOTE_FIXTURE" - printf '%s\n' '{"id":123,"node_id":"R_catalogue","full_name":"example/catalogue","archived":false,"default_branch":"main","permissions":{"push":true,"pull":true}}' > "$PERMISSION_FIXTURE" - printf '%s\n' '{"name":"Preview","body":"Nonpersistent generated notes"}' > "$WRITER_FIXTURE" -} -# Change only the selected remote observation for a refusal scenario. -mutate() { jq "$1" "$REMOTE_FIXTURE" > "$work/change"; mv "$work/change" "$REMOTE_FIXTURE"; } -# Exercise the production command with the independently selected candidate and commits. -run() { - : > "$CALLS" - (cd "$repo" && bash "$tool" --repo example/catalogue --candidate "$candidate" --source "$source" --release "$release" "$@") -} -# Require a successful, read-only assessment and repeated native capability observations. -accept() { - run > "$work/result" 2> "$work/error" || { cat "$work/error"; fail "$1 rejected"; } - jq -e --arg release "$release" '.status=="VERIFIED" and .releaseCommit==$release and .repository=="example/catalogue" and .scope=="remote-prepublication-snapshot" and .authority=="assessment-only" and .publication=="NOT_AUTHORIZED"' "$work/result" >/dev/null || fail "$1 verdict" - [ "$(grep -c '^graphql$' "$CALLS")" -eq 2 ] || fail "$1 did not reobserve remote" - [ "$(grep -c '^repository$' "$CALLS")" -eq 2 ] || fail "$1 did not reobserve native writer evidence" - [ "$(grep -c '^writer$' "$CALLS")" -eq 2 ] || fail "$1 did not reobserve native writer capability" - passed=$((passed+1)) -} -# Require failure without any success assessment. -reject() { - if run > "$work/result" 2> "$work/error"; then fail "$1 accepted"; fi - [ ! -s "$work/result" ] || fail "$1 emitted assessment" - passed=$((passed+1)) -} -setup incremental; mutate '.[0].data.repository.viewerPermission=null' -jq '.permissions={pull:false,push:false}' "$PERMISSION_FIXTURE" > "$work/change"; mv "$work/change" "$PERMISSION_FIXTURE" -accept 'App null-role with provider-enforced writer capability' -setup; accept 'initial snapshot' -setup incremental; accept 'annotated baseline and manifest-only release' -for errors in false null '{}' '"unavailable"'; do - setup incremental; mutate ".[0].errors=$errors"; reject "invalid GraphQL error envelope $errors" -done -setup incremental; mutate '.[0].errors=[]'; accept 'explicit empty GraphQL error envelope' -git -C "$repo" show-ref > "$work/refs-before" -printf 'local work\n' > "$repo/local" -git -C "$repo" status --porcelain > "$work/status-before" -accept 'dirty worktree is not changed' -git -C "$repo" show-ref > "$work/refs-after" -git -C "$repo" status --porcelain > "$work/status-after" -cmp "$work/refs-before" "$work/refs-after"; cmp "$work/status-before" "$work/status-after" -for change in \ - '.[0].data.repository.nameWithOwner="other/catalogue"' \ - '.[0].data.repository.isArchived=true' \ - '.[0].data.repository.viewerPermission="READ"' \ - '.[0].data.repository.viewerPermission="TRIAGE"' \ - 'del(.[0].data.repository.viewerPermission)' \ - '.[0].data.repository.defaultBranchRef.target.oid="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"' \ - '.[0].data.repository.defaultBranchRef=null' \ - '.[0].data.repository.defaultBranchRef.target.__typename="Tag"' \ - '.[0].data.repository.release={tagName:"v1.3.0",isDraft:true}' \ - 'del(.[0].data.repository.release)' \ - '.[0].data.repository.refs.nodes[0].target.oid="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"' \ - '.[0].data.repository.refs.nodes=[] | .[0].data.repository.refs.totalCount=0' \ - '.[0].data.repository.refs.totalCount=2' \ - '.[0].data.repository.refs.pageInfo.hasNextPage=true | .[0].data.repository.refs.pageInfo.endCursor="next"' \ - '.[0].data.repository.refs.nodes += .[0].data.repository.refs.nodes | .[0].data.repository.refs.totalCount=2' \ - '.[0].data.repository.refs.nodes[0].name="../unsafe"' \ - '.[0].data.repository.refs.nodes[0].target.oid="main"' \ - '.[0].data.repository.refs.nodes[0].target=null' \ - '.[0].errors=[{message:"partial failure"}]' \ - '.[0].data.repository=null' \ - '[]' \ - '{}'; do - setup incremental; mutate "$change"; reject "$change" -done -for change in '.node_id="R_foreign"' '.id=null' \ - '.full_name="other/catalogue"' '.archived=true' '.default_branch="trunk"'; do - setup incremental - jq "$change" "$PERMISSION_FIXTURE" > "$work/change"; mv "$work/change" "$PERMISSION_FIXTURE" - reject "native repository identity $change" -done -for change in '{}' '.name=""' '.name=true' 'del(.body)' '.body=null'; do - setup incremental; jq "$change" "$WRITER_FIXTURE" > "$work/change"; mv "$work/change" "$WRITER_FIXTURE" - reject "invalid writer capability $change" -done -setup incremental; mutate '.[0].data.repository.viewerPermission=null'; export WRITER_FAIL=true -reject 'read-only App cannot generate notes' -setup incremental; mutate '.[0].data.repository.viewerPermission=null' -printf '{}\n' > "$WRITER_SECOND" -reject 'App permission lost during assessment' -setup incremental; printf '{}\n{}\n' > "$WRITER_FIXTURE"; reject 'trailing native capability response' -setup incremental; printf '{}\n{}\n' > "$PERMISSION_FIXTURE"; reject 'trailing native permission response' -setup; printf 'not json\n' > "$REMOTE_FIXTURE"; reject 'malformed response' -setup; printf '\n[]\n' >> "$REMOTE_FIXTURE"; reject 'trailing JSON document' -setup; export FORGE_FAIL=true; reject 'forge failure'; unset FORGE_FAIL -setup incremental -# shellcheck disable=SC2016 # These are jq variables, not shell expansions. -mutate '.[0].data.repository.defaultBranchRef.target.oid as $head | .[0].data.repository.refs.nodes += [{name:"v1.3.0",target:{__typename:"Commit",oid:$head}}] | .[0].data.repository.refs.totalCount=2' -reject 'remotely occupied candidate tag' -setup incremental; jq '.[0].data.repository.defaultBranchRef.target.oid="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"' "$REMOTE_FIXTURE" > "$REMOTE_SECOND"; reject 'main moved during assessment' -setup incremental; jq '.[0].data.repository.defaultBranchRef.name="trunk"' "$REMOTE_FIXTURE" > "$REMOTE_SECOND"; reject 'default branch renamed during assessment' -setup incremental; jq '.[0].data.repository.release={tagName:"v1.3.0"}' "$REMOTE_FIXTURE" > "$REMOTE_SECOND"; reject 'release appeared during assessment' -setup incremental; printf 'changed\n' >> "$candidate/RELEASE_NOTES.md"; reject 'tampered local artifact' -[ ! -s "$CALLS" ] || fail 'tampered artifact reached forge' -setup -for number in $(seq 1 101); do git -C "$repo" tag "archive/$number"; done -snapshot -# shellcheck disable=SC2016 # These are jq variables, not shell expansions. -mutate '.[0] as $p | [($p | .data.repository.refs.nodes=$p.data.repository.refs.nodes[:100] | .data.repository.refs.pageInfo={hasNextPage:true,endCursor:"page1"}), ($p | .data.repository.refs.nodes=$p.data.repository.refs.nodes[100:] | .data.repository.refs.pageInfo={hasNextPage:false,endCursor:"page2"})]' -accept 'complete multi-page tag inventory' -mutate '.[1].data.repository.refs.totalCount=102'; reject 'inventory changed across pages' -setup; git -C "$repo" tag local-only; reject 'extra stale local tag' -setup; GH_HOST=other.invalid accept 'host remains github.com' -setup -: > "$CALLS" -bash "$tool" --help > "$work/help" -[ ! -s "$CALLS" ] || fail 'help reached forge' -if bash "$tool" > "$work/result" 2> "$work/error"; then fail 'no-argument invocation accepted'; fi -[ ! -s "$CALLS" ] || fail 'no-argument invocation reached forge' -passed=$((passed+1)) -setup -if run --repo unexpected/repo > "$work/result" 2> "$work/error"; then fail 'duplicate repo accepted'; fi -[ ! -s "$CALLS" ] || fail 'invalid arguments reached forge' -passed=$((passed+1)) -setup incremental -jq -c . "$PERMISSION_FIXTURE" | sed 's/^{/{"archived":true,/' > "$work/change"; mv "$work/change" "$PERMISSION_FIXTURE" -reject 'contradictory native repository identity' -setup incremental -jq -c . "$WRITER_FIXTURE" | sed 's/^{/{"body":false,/' > "$work/change"; mv "$work/change" "$WRITER_FIXTURE" -reject 'contradictory native writer capability' -setup incremental -jq -c . "$REMOTE_FIXTURE" | sed 's/"release":null/"release":{"tagName":"occupied"},"release":null/' > "$work/change"; mv "$work/change" "$REMOTE_FIXTURE" -reject 'contradictory candidate release absence' -printf 'PASS: %s remote release assessment cases\n' "$passed" diff --git a/scripts/check-marketplace-version.sh b/scripts/check-marketplace-version.sh deleted file mode 100644 index 8337158e..00000000 --- a/scripts/check-marketplace-version.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash -# Verify marketplace version proposals before merge without changing any Git state. -set -euo pipefail -export GIT_NO_REPLACE_OBJECTS=1 GIT_NO_LAZY_FETCH=1 -here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# shellcheck source=scripts/marketplace-git-context.lib.sh -. "$here/marketplace-git-context.lib.sh" -marketplace_git_context -# Refuse incomplete evidence without emitting a success record. -fail() { printf 'marketplace version gate: %s\n' "$*" >&2; exit 1; } -[ "$#" -eq 2 ] || fail 'usage: check-marketplace-version.sh ' -base=$1 head=$2 -[[ "$base" =~ ^[0-9a-f]{40}$ && "$head" =~ ^[0-9a-f]{40}$ ]] || fail 'base and head must be full 40-character commits' -[ "$(git rev-parse --is-shallow-repository)" = false ] || fail 'complete Git history is required' -grafts=$(git rev-parse --git-path info/grafts) || fail 'graft path is unreadable' -[ -n "$grafts" ] || fail 'graft path is empty' -[ ! -s "$grafts" ] || fail 'grafted history is unsupported' -# shellcheck source=scripts/complete-clone.lib.sh -. "$here/complete-clone.lib.sh" -assert_complete_clone_config || fail 'incomplete Git configuration; offline history is required' -for commit in "$base" "$head"; do - [ "$(git cat-file -t "$commit")" = commit ] || fail 'base and head must identify commits' -done -fork=$(git merge-base --all "$base" "$head") || fail 'base and head have no common ancestor' -[[ "$fork" =~ ^[0-9a-f]{40}$ ]] || fail 'a unique merge base is required' -temp=$(mktemp -d "${TMPDIR:-/tmp}/marketplace-version.XXXXXX") -trap 'rm -rf "$temp"' EXIT -# Read both regular committed manifests and reject ambiguous version evidence. -version_at() { - local commit=$1 path mode n=0 - for path in .github/plugin/marketplace.json .claude-plugin/marketplace.json; do - n=$((n+1)) - mode=$(git ls-tree --full-tree "$commit" -- "$path") - [[ "$mode" == '100644 blob '* || "$mode" == '100755 blob '* ]] || fail "manifest is not a regular tracked file: $path" - git cat-file blob "$commit:$path" > "$temp/manifest-$n.json" - jq -es -L "$here" 'include "marketplace-release"; length==1 and (.[0] | valid_marketplace)' "$temp/manifest-$n.json" >/dev/null || fail "invalid marketplace manifest: $path" - # Streaming retains repeated keys that ordinary JSON parsing collapses. - jq --stream -s -e '[.[] | select(length==2 and .[0]==["metadata","version"])] | length==1' "$temp/manifest-$n.json" >/dev/null || fail 'marketplace version is ambiguous' - done - jq -ne --slurpfile a "$temp/manifest-1.json" --slurpfile b "$temp/manifest-2.json" '$a==$b' >/dev/null || fail 'marketplace manifests differ' - jq -r '.metadata.version' "$temp/manifest-1.json" -} -fork_version=$(version_at "$fork") -head_version=$(version_at "$head") -# Compare branch intent, not changes that landed only on its base. An ordinary old -# PR must remain valid when another PR released the marketplace after it branched. -if [ "$fork_version" = "$head_version" ]; then - jq -n --arg base "$base" --arg head "$head" --arg fork "$fork" \ - '{status:"NO_VERSION_CHANGE",scope:"branch-marketplace-version",baseCommit:$base,headCommit:$head,mergeBase:$fork,publication:"NOT_AUTHORIZED"}' - exit 0 -fi -[ "$(git show -s --no-show-signature --format=%P "$head")" = "$base" ] || fail 'version proposal must have exactly the current base as its only parent; regenerate from the current base' -base_version=$(version_at "$base") -# Preparation and verification are the shared release contract, not a second -# SemVer implementation. Keep their diagnostics off the structured result stream. -bash "$here/prepare-marketplace-release.sh" --base-tag "v$base_version" --head "$base" --output "$temp/candidate" > "$temp/preparation.log" -bash "$here/verify-marketplace-release.sh" --candidate "$temp/candidate" --source "$base" --release "$head" diff --git a/scripts/check-marketplace-version.test.sh b/scripts/check-marketplace-version.test.sh deleted file mode 100644 index 623758e4..00000000 --- a/scripts/check-marketplace-version.test.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env bash -# Real branch histories: removing exact candidate verification admits the wrong-version case. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -tool="$root/scripts/check-marketplace-version.sh" -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false -passed=0 -# Stop at the first violated observable contract. -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } -# Build an independent tagged history; fixture commits are never pushed. -fixture() { - repo=$(mktemp -d "$work/repo.XXXXXX") - git -C "$repo" init -q - git -C "$repo" config user.name Test - git -C "$repo" config user.email test@example.invalid - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - printf '%s\n' '{"name":"test","metadata":{"version":"1.2.3"},"plugins":[{"name":"example","version":"4.5.6","source":"./plugins/example"}]}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'Initial import' - git -C "$repo" tag v1.2.3 - git -C "$repo" commit --allow-empty -qm "${1:-feat: capability}" - base=$(git -C "$repo" rev-parse HEAD) - head=$base -} -# Commit exactly the proposed manifests on the independently selected base. -proposal() { - candidate=$(mktemp -d "$work/holder.XXXXXX")/candidate - (cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag v1.2.3 --head "$base" --output "$candidate") >/dev/null - cp "$candidate/.github/plugin/marketplace.json" "$repo/.github/plugin/marketplace.json" - cp "$candidate/.claude-plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - commit_pair -} -# Record deliberate fixture changes and refresh the tested head identity. -commit_pair() { - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'chore(release): update marketplace' - head=$(git -C "$repo" rev-parse HEAD) -} -# Change the fixture's version without using the generator. -set_version() { - jq --arg version "$1" '.metadata.version=$version' "$repo/.github/plugin/marketplace.json" > "$work/changed" - cp "$work/changed" "$repo/.github/plugin/marketplace.json" - cp "$work/changed" "$repo/.claude-plugin/marketplace.json" - commit_pair -} -# Invoke the real gate, never code from the fixture history. -run() { (cd "$repo" && bash "$tool" "$base" "$head"); } -# Assert a structured verdict bound to the selected commits. -accept() { - local name=$1 status=$2 - run > "$work/result" 2> "$work/error" || { cat "$work/error"; fail "$name rejected"; } - jq -e --arg status "$status" '.status==$status and .publication=="NOT_AUTHORIZED"' "$work/result" >/dev/null || fail "$name verdict" - if [ "$status" = VERIFIED ]; then - jq -e --arg base "$base" --arg head "$head" '.sourceCommit==$base and .releaseCommit==$head' "$work/result" >/dev/null || fail "$name identities" - fi - passed=$((passed+1)) -} -# A refusal must not leave a success record on stdout. -reject() { - local name=$1 - if run > "$work/result" 2> "$work/error"; then fail "$name accepted"; fi - [ ! -s "$work/result" ] || fail "$name emitted success output" - passed=$((passed+1)) -} -fixture; set_version 9.0.0; reject 'arbitrary version' -fixture; proposal; accept 'generated minor proposal' VERIFIED -fixture 'fix: repair'; proposal; accept 'generated patch proposal' VERIFIED -fixture 'feat!: break'; proposal; accept 'generated major proposal' VERIFIED -fixture; accept 'unchanged version' NO_VERSION_CHANGE -fixture; git -C "$repo" tag -d v1.2.3 >/dev/null; accept 'ordinary work before first release' NO_VERSION_CHANGE -fixture; proposal -cp "$work/result" "$work/old-result" -printf 'dirty\n' > "$repo/.github/plugin/marketplace.json" -git -C "$repo" status --porcelain > "$work/status-before" -git -C "$repo" show-ref > "$work/refs-before" -accept 'dirty checkout is not evidence' VERIFIED -git -C "$repo" status --porcelain > "$work/status-after" -git -C "$repo" show-ref > "$work/refs-after" -cmp "$work/status-before" "$work/status-after"; cmp "$work/refs-before" "$work/refs-after" -run > "$work/repeated"; cmp "$work/result" "$work/repeated"; passed=$((passed+1)) -fixture 'docs: explain'; set_version 1.2.4; reject 'no releasable changes' -fixture; proposal; git -C "$repo" tag -d v1.2.3 >/dev/null; reject 'missing baseline' -fixture; proposal; git -C "$repo" tag v1.3.0 "$head"; reject 'occupied release tag' -fixture; proposal; base=$(git -C "$repo" rev-parse v1.2.3); reject 'wrong source parent' -fixture; proposal; git -C "$repo" commit --allow-empty -qm 'docs: extra commit'; head=$(git -C "$repo" rev-parse HEAD); reject 'extra proposal commit' -fixture; proposal; base=$(printf 'docs: concurrent main change\n' | git -C "$repo" commit-tree "$base^{tree}" -p "$base"); reject 'main moved' -# An old ordinary PR must not be blamed for a release that landed on its base. -fixture; old_base=$base; proposal; base=$head -head=$(printf 'docs: ordinary branch\n' | git -C "$repo" commit-tree "$old_base^{tree}" -p "$old_base") -accept 'ordinary branch behind marketplace release' NO_VERSION_CHANGE -fixture; proposal; head=$(printf 'merge\n' | git -C "$repo" commit-tree "$head^{tree}" -p "$base" -p "$(git -C "$repo" rev-parse v1.2.3)"); reject 'merge commit instead of proposal' -fixture; proposal; printf 'unrelated\n' > "$repo/unrelated"; git -C "$repo" add unrelated; git -C "$repo" commit --amend --no-edit -q; head=$(git -C "$repo" rev-parse HEAD); reject 'unrelated content' -fixture; proposal; chmod +x "$repo/.github/plugin/marketplace.json"; git -C "$repo" add .github/plugin/marketplace.json; git -C "$repo" commit --amend --no-edit -q; head=$(git -C "$repo" rev-parse HEAD); reject 'manifest mode change' -fixture; proposal; jq '.plugins[0].version="9.0.0"' "$repo/.github/plugin/marketplace.json" > "$work/changed"; cp "$work/changed" "$repo/.github/plugin/marketplace.json"; cp "$work/changed" "$repo/.claude-plugin/marketplace.json"; git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json; git -C "$repo" commit --amend --no-edit -q; head=$(git -C "$repo" rev-parse HEAD); reject 'plugin version changed with marketplace' -fixture; printf '{broken\n' > "$repo/.github/plugin/marketplace.json"; commit_pair; reject 'malformed manifest' -fixture; jq '.metadata.version="1.3.0"' "$repo/.github/plugin/marketplace.json" > "$work/changed"; cp "$work/changed" "$repo/.github/plugin/marketplace.json"; commit_pair; reject 'manifest disagreement' -fixture; rm "$repo/.github/plugin/marketplace.json"; commit_pair; reject 'missing manifest' -fixture; rm "$repo/.github/plugin/marketplace.json"; ln -s ../../.claude-plugin/marketplace.json "$repo/.github/plugin/marketplace.json"; commit_pair; reject 'symlink manifest' -fixture; printf '%s\n%s\n' '{"metadata":{"version":"1.2.3"}}' '{}' > "$repo/.github/plugin/marketplace.json"; commit_pair; reject 'multiple JSON documents' -fixture; sed 's/"version":"1.2.3"/"version":"9.0.0","version":"1.2.3"/' "$repo/.github/plugin/marketplace.json" > "$work/changed"; cp "$work/changed" "$repo/.github/plugin/marketplace.json"; cp "$work/changed" "$repo/.claude-plugin/marketplace.json"; commit_pair; reject 'duplicate version hidden behind unchanged value' -fixture; base=HEAD; reject 'symbolic base' -fixture; head=HEAD; reject 'symbolic head' -fixture; head=$(git -C "$repo" rev-parse 'HEAD^{tree}'); reject 'noncommit head' -fixture; head=0000000000000000000000000000000000000000; reject 'missing commit' -fixture; head=$(printf 'orphan\n' | git -C "$repo" commit-tree "$base^{tree}"); reject 'unrelated histories' -fixture; git -C "$repo" rev-parse HEAD > "$repo/.git/shallow"; reject 'shallow unchanged history' -fixture; git -C "$repo" config remote.origin.promisor true; reject 'partial unchanged history' -# Empty/prefix failures are not a successful no-match config observation. -real_git=$(command -v git) -mkdir "$work/config-fault" -cat > "$work/config-fault/git" <<'STUB' -#!/usr/bin/env bash -if [ "$1" = config ] && [[ "$*" == *"$CONFIG_QUERY"* ]]; then - if [ "$CONFIG_OUTPUT" = partial ]; then - if [ "$CONFIG_QUERY" = extensions.partialClone ]; then printf 'origin\n'; else printf 'remote.origin.promisor false\n'; fi - fi - exit 2 -fi -exec "$REAL_GIT" "$@" -STUB -chmod +x "$work/config-fault/git" -for query in extensions.partialClone promisor; do - for output in empty partial; do - fixture - if PATH="$work/config-fault:$PATH" REAL_GIT="$real_git" CONFIG_QUERY="$query" CONFIG_OUTPUT="$output" run > "$work/result" 2> "$work/error"; then - fail "failed $query $output configuration was accepted" - fi - grep -q 'unreadable partial-clone configuration' "$work/error" || fail "failed configuration misdiagnosed" - test ! -s "$work/result" || fail "failed configuration emitted a success record" - passed=$((passed+1)) - done -done -printf 'PASS %s marketplace version gate cases\n' "$passed" diff --git a/scripts/ci-script-test-sharding-workflow.test.sh b/scripts/ci-script-test-sharding-workflow.test.sh index 5b7713c2..5ed541c2 100755 --- a/scripts/ci-script-test-sharding-workflow.test.sh +++ b/scripts/ci-script-test-sharding-workflow.test.sh @@ -21,12 +21,11 @@ job_block() { # Verify that every script-test command is assigned once to an independent required shard. check_workflow() { - local workflow=$1 lint marketplace packages required combined failures=0 + local workflow=$1 lint packages required combined failures=0 lint=$(job_block lint-scripts "$workflow") - marketplace=$(job_block test-marketplace "$workflow") packages=$(job_block test-packages "$workflow") required=$(job_block ci-required-checks "$workflow") - combined="$lint"$'\n'"$marketplace"$'\n'"$packages" + combined="$lint"$'\n'"$packages" # Record a failure when a fixed string occurs a different number of times than required. require_count() { @@ -47,15 +46,13 @@ check_workflow() { } require_count 'static/core job exists once' ' lint-scripts:' 1 "$lint" - require_count 'marketplace job exists once' ' test-marketplace:' 1 "$marketplace" require_count 'package job exists once' ' test-packages:' 1 "$packages" - require_count 'each shard checks out independently' 'uses: actions/checkout@' 3 "$combined" + require_count 'each shard checks out independently' 'uses: actions/checkout@' 2 "$combined" require_count 'each shard installs the locked parser independently' \ - 'run: npm ci --ignore-scripts --no-audit --no-fund' 3 "$combined" - require_count 'each shard provisions Node independently' 'uses: actions/setup-node@' 3 "$combined" - require_count 'each shard provisions Go independently' 'uses: actions/setup-go@' 3 "$combined" - require_count 'each shard has read-only repository permission' 'contents: read' 3 "$combined" - require_count 'marketplace shard is required and aggregated' 'test-marketplace' 2 "$required" + 'run: npm ci --ignore-scripts --no-audit --no-fund' 2 "$combined" + require_count 'each shard provisions Node independently' 'uses: actions/setup-node@' 2 "$combined" + require_count 'each shard provisions Go independently' 'uses: actions/setup-go@' 2 "$combined" + require_count 'each shard has read-only repository permission' 'contents: read' 2 "$combined" require_count 'package shard is required and aggregated' 'test-packages' 2 "$required" local expected_commands=( @@ -74,21 +71,6 @@ check_workflow() { 'bash scripts/ci-skill-validation-workflow.test.sh' 'bash scripts/skill-spec-view.test.sh' 'bash scripts/ci-script-test-sharding-workflow.test.sh' - 'bash scripts/marketplace-caller-context.test.sh' - 'bash scripts/prepare-marketplace-release.test.sh' - 'bash scripts/release-observation-boundaries.test.sh' - 'bash scripts/verify-marketplace-release.test.sh' - 'bash scripts/inspect-marketplace-release.test.sh' - 'bash scripts/marketplace-observation-completeness.test.sh' - 'bash scripts/check-marketplace-version.test.sh' - 'bash scripts/check-marketplace-release-remote.test.sh' - 'bash scripts/publish-marketplace-release.test.sh' - 'bash scripts/prepare-merged-marketplace-release.test.sh' - 'bash scripts/marketplace-publication-workflow.test.sh' - 'bash scripts/marketplace-publication-identity.test.sh' - 'bash scripts/propose-marketplace-release.test.sh' - 'bash scripts/marketplace-proposal-workflow.test.sh' - 'jq -e '\''.data.viewer.login == "github-actions[bot]"'\''' './scripts/recheck-open-prs.test.sh' 'bash scripts/recheck-open-prs-observations.test.sh' 'uses: actions/upload-artifact@' @@ -149,7 +131,7 @@ sed 's/bash scripts\/package-boundaries.test.sh/bash scripts\/package-discovery. "$WORKFLOW" >"$WORK/duplicate-command.yaml" expect_rejected duplicate-command "$WORK/duplicate-command.yaml" -sed 's/bash scripts\/marketplace-caller-context.test.sh/bash scripts\/marketplace-caller-context.test.sh || true/' \ +sed 's/bash scripts\/plugin-changelog.test.sh/bash scripts\/plugin-changelog.test.sh || true/' \ "$WORKFLOW" >"$WORK/tolerated-failure.yaml" expect_rejected tolerated-failure "$WORK/tolerated-failure.yaml" diff --git a/scripts/inspect-marketplace-release.sh b/scripts/inspect-marketplace-release.sh deleted file mode 100755 index e5122ee5..00000000 --- a/scripts/inspect-marketplace-release.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash -# Read-only historical content assessment, invoked by verify-marketplace-release.sh. -set -euo pipefail -here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# Stop inspection without exposing the private verifier's success result. -fail() { printf 'release inspection: %s\n' "$*" >&2; exit 1; } -[ "$#" -eq 3 ] || fail 'candidate, source and release are required' -candidate=$1 source=$2 release=$3 -[[ "$source" =~ ^[0-9a-f]{40}$ && "$release" =~ ^[0-9a-f]{40}$ ]] || fail 'full source and release commits are required' -if [ ! -d "$candidate" ] || [ -L "$candidate" ]; then fail 'candidate must be a real directory'; fi -candidate=$(cd "$candidate" && pwd -P && printf '.') -candidate=${candidate%$'\n.'} -if [ ! -f "$candidate/release.json" ] || [ -L "$candidate/release.json" ]; then fail 'candidate plan must be a regular file'; fi -# No inherited layout or command-scoped configuration may redirect private ref writes. -unset GIT_DIR GIT_WORK_TREE GIT_COMMON_DIR GIT_INDEX_FILE GIT_OBJECT_DIRECTORY \ - GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_PREFIX GIT_NAMESPACE GIT_CONFIG_PARAMETERS GIT_CONFIG_COUNT -unset GIT_CONFIG GIT_CONFIG_GLOBAL GIT_CONFIG_SYSTEM GIT_CONFIG_NOSYSTEM -export GIT_NO_REPLACE_OBJECTS=1 GIT_NO_LAZY_FETCH=1 -original=$(git rev-parse --show-toplevel && printf '.') || fail 'a Git working tree is required' -original=${original%$'\n.'} -original=$(cd "$original" && pwd -P && printf '.') || fail 'physical working tree is unavailable' -original=${original%$'\n.'} -temp=$(mktemp -d "${TMPDIR:-/tmp}/marketplace-inspect.XXXXXX") -trap 'rm -rf "$temp"' EXIT -# Check the original before cloning; a local clone need not retain these restrictions. -[ "$(git -C "$original" rev-parse --is-shallow-repository)" = false ] || fail 'complete Git history is required' -grafts=$(git -C "$original" rev-parse --path-format=absolute --git-path info/grafts) -[ ! -s "$grafts" ] || fail 'grafted history is unsupported' -# Observe the original configuration; the private clone does not retain it. -# shellcheck source=scripts/complete-clone.lib.sh -. "$here/complete-clone.lib.sh" -(cd "$original" && assert_complete_clone_config) || fail 'incomplete Git configuration; offline history is required' -for commit in "$source" "$release"; do - [ "$(git -C "$original" cat-file -t "$commit")" = commit ] || fail 'selected commits must be available locally' -done -jq -es -L "$here" --arg source "$source" ' - include "marketplace-release"; - length == 1 and (.[0] | .schemaVersion==1 and .status=="CANDIDATE" - and .sourceCommit==$source and .publication=="NOT_AUTHORIZED" - and (.version | stable_version) and .tag==("v" + .version)) -' "$candidate/release.json" >/dev/null || fail 'candidate plan does not match the selected source' -tag=$(jq -r .tag "$candidate/release.json") -git -C "$original" for-each-ref --sort=refname --format='%(refname) %(objectname)' refs/tags > "$temp/tags-before" -tag_oid=$(awk -v ref="refs/tags/$tag" '$1 == ref { print $2 }' "$temp/tags-before") -if [ -n "$tag_oid" ]; then - [[ "$tag_oid" =~ ^[0-9a-f]{40}$ ]] || fail 'candidate tag inventory is invalid' - tag_commit=$(git -C "$original" rev-parse --verify "$tag_oid^{commit}") || fail 'candidate tag does not resolve to a commit' - jq -n --arg object "$tag_oid" --arg commit "$tag_commit" --arg release "$release" \ - '{state:"PRESENT",objectOid:$object,commitOid:$commit,targetsRelease:($commit==$release)}' > "$temp/local-tag.json" -else - printf '%s\n' '{"state":"ABSENT","objectOid":null,"commitOid":null,"targetsRelease":null}' > "$temp/local-tag.json" -fi -# A separate local repository copies immutable objects, never the caller's refs or index. -# No checkout, network call or nominated source code is executed. -# Shared-clone alternates use line records and cannot retain every physical pathname. -git clone --no-hardlinks --no-checkout --quiet "$original" "$temp/repository" -private=$(cd "$temp/repository" && pwd -P) -[ "$(git -C "$private" rev-parse --show-toplevel)" = "$private" ] || fail 'private worktree layout is invalid' -[ "$(git -C "$private" rev-parse --path-format=absolute --git-common-dir)" = "$private/.git" ] || fail 'private Git directory is invalid' -if [ -n "$tag_oid" ]; then - git -C "$private" update-ref -d "refs/tags/$tag" "$tag_oid" || fail 'candidate tag changed while cloning' -fi -# Reuse every strict byte, history, parent, tree and mode check. Capture its verdict -# privately: prepublication clearance from this disposable repository is never exposed. -(cd "$private" && bash "$here/verify-marketplace-release.sh" \ - --candidate "$candidate" --source "$source" --release "$release") > "$temp/verified.json" -git -C "$original" for-each-ref --sort=refname --format='%(refname) %(objectname)' refs/tags > "$temp/tags-after" -cmp -s "$temp/tags-before" "$temp/tags-after" || fail 'tag inventory changed during inspection' -jq -es --arg source "$source" --arg release "$release" --arg tag "$tag" ' - length==1 and (.[0] | .status=="VERIFIED" and .scope=="local-prepublication" - and .sourceCommit==$source and .releaseCommit==$release and .tag==$tag) -' "$temp/verified.json" >/dev/null || fail 'strict verification result is invalid' -jq --slurpfile localTag "$temp/local-tag.json" ' - .status="INSPECTED" | .scope="local-historical-content" | .localTag=$localTag[0] - | .proposal="NOT_AUTHORIZED" | .readiness="NOT_ASSESSED" | .remoteState="UNKNOWN" -' "$temp/verified.json" diff --git a/scripts/inspect-marketplace-release.test.sh b/scripts/inspect-marketplace-release.test.sh deleted file mode 100755 index 0a2c258a..00000000 --- a/scripts/inspect-marketplace-release.test.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env bash -# Exercise historical inspection through the public verifier with real Git histories. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -tool="$root/scripts/verify-marketplace-release.sh" -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false -passed=0 -# Stop the suite at the first contract mismatch. -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } -# Build a real baseline, feature source, four-file candidate and version-only release. -fixture() { - repo=$(mktemp -d "$work/repo.XXXXXX") - repo=$(cd "$repo" && pwd -P) - unset GIT_DIR GIT_WORK_TREE GIT_COMMON_DIR GIT_INDEX_FILE GIT_OBJECT_DIRECTORY \ - GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_PREFIX GIT_NAMESPACE GIT_CONFIG_PARAMETERS \ - GIT_CONFIG GIT_CONFIG_GLOBAL GIT_CONFIG_SYSTEM GIT_CONFIG_NOSYSTEM - git -C "$repo" init -q - git -C "$repo" config user.name Test - git -C "$repo" config user.email test@example.invalid - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - printf '%s\n' '{"name":"test","metadata":{"version":"1.2.3"},"plugins":[{"name":"example","version":"4.5.6","source":"./plugins/example"}]}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - printf 'original\n' > "$repo/content" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json content - git -C "$repo" commit -qm 'Initial import' - git -C "$repo" tag v1.2.3 - git -C "$repo" commit --allow-empty -qm 'feat: add capability' - source=$(git -C "$repo" rev-parse HEAD) - candidate=$(mktemp -d "$work/artifact.XXXXXX"); rmdir "$candidate" - (cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag v1.2.3 --head "$source" --output "$candidate") >/dev/null - cp "$candidate/.github/plugin/marketplace.json" "$repo/.github/plugin/marketplace.json" - cp "$candidate/.claude-plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'chore(release): prepare 1.3.0' - release=$(git -C "$repo" rev-parse HEAD) -} -# Exercise the public entrypoint against the selected fixture and explicit options. -run() { (cd "$repo" && bash "$tool" --candidate "$candidate" --source "$source" --release "$release" "$@"); } -# Require a non-authoritative historical verdict and the expected local tag observation. -accept() { - local name=$1 state=$2 matches=$3 - run --inspect-existing > "$work/result" 2> "$work/error" || { cat "$work/error"; fail "$name rejected"; } - jq -e --arg source "$source" --arg release "$release" --arg state "$state" --argjson matches "$matches" ' - .schemaVersion==1 and .status=="INSPECTED" and .scope=="local-historical-content" - and .sourceCommit==$source and .releaseCommit==$release and .tag=="v1.3.0" - and .authority=="assessment-only" and .publication=="NOT_AUTHORIZED" - and .proposal=="NOT_AUTHORIZED" and .readiness=="NOT_ASSESSED" and .remoteState=="UNKNOWN" - and .localTag.state==$state and .localTag.targetsRelease==$matches - ' "$work/result" >/dev/null || fail "$name verdict" - passed=$((passed+1)) -} -# Require nonzero refusal with no leaked successful result. -reject() { - local name=$1; shift - if run --inspect-existing "$@" > "$work/result" 2> "$work/error"; then fail "$name accepted"; fi - [ ! -s "$work/result" ] || fail "$name emitted success" - passed=$((passed+1)) -} -# Capture caller refs, dirty/untracked files and index checksum for before/after comparison. -snapshot() { - git -C "$repo" for-each-ref --sort=refname --format='%(refname) %(objectname)' > "$1.refs" - git -C "$repo" status --porcelain > "$1.status" - cksum "$repo/.git/index" > "$1.index" -} -# A subprocess exercises the real fixture setup under a foreign inherited Git layout. -if [ "${1:-}" = --fixture-isolation-check ]; then - [ "$#" -eq 1 ] || fail 'one fixture isolation option is supported' - fixture; run --inspect-existing > "$work/result" - jq -e '.status=="INSPECTED" and .localTag.state=="ABSENT"' "$work/result" >/dev/null - exit 0 -fi -[ "$#" -eq 0 ] || fail 'unknown suite option' -fixture -run > "$work/default" -jq -e '.status=="VERIFIED" and .scope=="local-prepublication"' "$work/default" >/dev/null -passed=$((passed+1)) -accept 'absent tag is an inspection, never prepublication clearance' ABSENT null -fixture -newline_repo="$repo"$'\n' -mv "$repo" "$newline_repo"; repo=$newline_repo -snapshot "$work/newline-before" -accept 'exact trailing-newline checkout identity' ABSENT null -snapshot "$work/newline-after" -for field in refs status index; do - cmp "$work/newline-before.$field" "$work/newline-after.$field" || fail "newline checkout $field changed" -done -passed=$((passed+1)) -git -C "$repo" tag v1.3.0 "$release" -if run > "$work/default" 2> "$work/error"; then fail 'default mode accepted occupied tag'; fi -[ ! -s "$work/default" ] || fail 'default emitted clearance' -passed=$((passed+1)) -printf 'dirty\n' > "$repo/content" -printf 'untracked\n' > "$repo/local" -snapshot "$work/before" -accept 'published lightweight tag' PRESENT true -for field in refs status index; do snapshot "$work/after"; cmp "$work/before.$field" "$work/after.$field" || fail "caller $field changed"; done -passed=$((passed+1)) -run --inspect-existing > "$work/repeat" -cmp "$work/result" "$work/repeat" || fail 'nondeterministic inspection' -passed=$((passed+1)) -if run > "$work/default" 2> "$work/error"; then fail 'inspection removed the caller tag'; fi -passed=$((passed+1)) - -fixture; git -C "$repo" tag -a -m 'release' v1.3.0 "$release"; accept 'annotated commit tag' PRESENT true -tag_object=$(git -C "$repo" rev-parse refs/tags/v1.3.0) -jq -e --arg oid "$tag_object" --arg commit "$release" '.localTag.objectOid==$oid and .localTag.commitOid==$commit' "$work/result" >/dev/null -passed=$((passed+1)) -fixture; git -C "$repo" tag v1.3.0 "$source"; accept 'retained proposal differs from the occupied tag' PRESENT false -fixture; git -C "$repo" tag v1.3.0 'HEAD^{tree}'; reject 'non-commit candidate tag' - -for file in release.json RELEASE_NOTES.md .github/plugin/marketplace.json .claude-plugin/marketplace.json; do - fixture; git -C "$repo" tag v1.3.0 "$release"; printf '\nmodified\n' >> "$candidate/$file"; reject "tampered $file" - fixture; rm "$candidate/$file"; reject "missing $file" - fixture; mv "$candidate/$file" "$work/saved"; ln -s "$work/saved" "$candidate/$file"; reject "symlink $file"; rm "$work/saved" -done -fixture; ln -s "$candidate" "$work/link"; candidate="$work/link"; reject 'symlink candidate root' -fixture; mkfifo "$candidate/extra-pipe"; reject 'special artifact' -fixture; printf x > "$candidate/extra"; reject 'unexpected artifact' -fixture; source=HEAD; reject 'symbolic source' -fixture; release=HEAD; reject 'symbolic release' -fixture; reject 'duplicate inspection flag' --inspect-existing -fixture; git -C "$repo" config remote.origin.promisor true; reject 'partial source clone' -fixture; git -C "$repo" rev-parse HEAD > "$repo/.git/shallow"; reject 'shallow source history' -fixture; mkdir -p "$repo/.git/info"; printf 'grafted\n' > "$repo/.git/info/grafts"; reject 'grafted source history' -fixture; mkdir -p "$repo/sub" "$repo/.git/info"; printf '%s\n' "$source" > "$repo/.git/info/grafts" -if (cd "$repo/sub" && bash "$tool" --candidate "$candidate" --source "$source" --release "$release" --inspect-existing) > "$work/result" 2> "$work/error"; then - fail 'grafted source inspected from a subdirectory was accepted' -fi -[ ! -s "$work/result" ] || fail 'subdirectory graft refusal emitted success' -grep -q 'grafted history is unsupported' "$work/error" || fail 'subdirectory graft was refused for another reason' -passed=$((passed+1)) -fixture; git -C "$repo" tag v1.3.0 "$release"; printf changed > "$repo/content"; git -C "$repo" add content; git -C "$repo" commit --amend --no-edit -q; release=$(git -C "$repo" rev-parse HEAD); reject 'unrelated release content' -fixture; chmod +x "$repo/.github/plugin/marketplace.json"; git -C "$repo" add .github/plugin/marketplace.json; git -C "$repo" commit --amend --no-edit -q; release=$(git -C "$repo" rev-parse HEAD); reject 'changed manifest mode' -fixture; git -C "$repo" commit --allow-empty -qm 'fix: later work'; release=$(git -C "$repo" rev-parse HEAD); reject 'wrong source parent' - -# Inherited Git layout overrides must never redirect the private tag deletion. -fixture; git -C "$repo" tag v1.3.0 "$release" -foreign=$(mktemp -d "$work/foreign.XXXXXX") -git clone --shared --no-checkout -q "$repo" "$foreign" -foreign_tag=$(git -C "$foreign" rev-parse refs/tags/v1.3.0) -cp "$foreign/.git/config" "$work/foreign-config-before" -git -C "$foreign" for-each-ref --sort=refname --format='%(refname) %(objectname)' > "$work/foreign-refs-before" -GIT_DIR="$foreign/.git" GIT_WORK_TREE="$foreign" bash "${BASH_SOURCE[0]}" --fixture-isolation-check || fail 'inherited fixture layout was not isolated' -cmp "$work/foreign-config-before" "$foreign/.git/config" || fail 'fixture changed foreign configuration' -git -C "$foreign" for-each-ref --sort=refname --format='%(refname) %(objectname)' > "$work/foreign-refs-after" -cmp "$work/foreign-refs-before" "$work/foreign-refs-after" || fail 'fixture changed foreign refs' -passed=$((passed+1)) -GIT_DIR="$foreign/.git" GIT_WORK_TREE="$foreign" accept 'inherited foreign Git layout is neutralized' PRESENT true -[ "$(git -C "$foreign" rev-parse refs/tags/v1.3.0)" = "$foreign_tag" ] || fail 'foreign tag changed' -passed=$((passed+1)) -GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.worktree GIT_CONFIG_VALUE_0="$foreign" accept 'inherited worktree configuration is neutralized' PRESENT true -[ "$(git -C "$foreign" rev-parse refs/tags/v1.3.0)" = "$foreign_tag" ] || fail 'configured foreign tag changed' -passed=$((passed+1)) - -# Initial inspection preserves the no-other-stable-tags history requirement. -fixture -source=$(git -C "$repo" rev-parse v1.2.3); release=$source -git -C "$repo" tag -d v1.2.3 >/dev/null -candidate=$(mktemp -d "$work/initial.XXXXXX"); rmdir "$candidate" -(cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag initial --head "$source" --output "$candidate") >/dev/null -git -C "$repo" tag v1.2.3 "$release" -run --inspect-existing > "$work/result" -jq -e '.status=="INSPECTED" and .tag=="v1.2.3" and .localTag.targetsRelease==true' "$work/result" >/dev/null -passed=$((passed+1)) -git -C "$repo" tag v9.0.0 "$release"; reject 'initial history with another stable tag' - -# A concurrent ref writer at the final observation must invalidate the result. -real_git=$(command -v git) -mkdir "$work/bin" -cat > "$work/bin/git" <<'STUB' -#!/usr/bin/env bash -if [ "${1:-}" = -C ] && [ "${2:-}" = "$MOVE_REPO" ] && [ "${3:-}" = for-each-ref ]; then - count=$(cat "$MOVE_COUNT"); count=$((count+1)); printf '%s' "$count" > "$MOVE_COUNT" - if [ "$count" -eq 2 ]; then "$REAL_GIT" -C "$MOVE_REPO" update-ref refs/tags/v1.3.0 "$MOVE_TARGET"; fi -fi -exec "$REAL_GIT" "$@" -STUB -chmod +x "$work/bin/git" -fixture; git -C "$repo" tag v1.3.0 "$release"; printf 0 > "$work/move-count" -REAL_GIT="$real_git" MOVE_REPO="$repo" MOVE_TARGET="$source" MOVE_COUNT="$work/move-count" PATH="$work/bin:$PATH" reject 'moving tag inventory' -grep -q 'tag inventory changed' "$work/error" || fail 'movement was rejected for another reason' -printf 'PASS %s historical inspection cases\n' "$passed" diff --git a/scripts/marketplace-caller-context.test.sh b/scripts/marketplace-caller-context.test.sh deleted file mode 100644 index cb560646..00000000 --- a/scripts/marketplace-caller-context.test.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# Real independent checkouts prove public helpers cannot inherit a different Git repository. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -unset GIT_DIR GIT_WORK_TREE GIT_COMMON_DIR GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_NAMESPACE -fixture() { - local repo=$1 - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - git -C "$repo" init -q - git -C "$repo" config user.name Fixture - git -C "$repo" config user.email fixture@example.invalid - git -C "$repo" config commit.gpgsign false - printf '%s\n' '{"name":"test","metadata":{"version":"1.2.3"},"plugins":[{"name":"example","version":"1.0.0","source":"./plugins/example"}]}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add -- .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm "chore: $repo" -} -fixture "$work/intended"; fixture "$work/redirected" -head=$(git -C "$work/intended" rev-parse HEAD) -export GIT_DIR="$work/redirected/.git" GIT_WORK_TREE="$work/redirected" GIT_COMMON_DIR="$work/redirected/.git" GIT_INDEX_FILE="$work/redirected/.git/index" GIT_OBJECT_DIRECTORY="$work/redirected/.git/objects" -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.worktree GIT_CONFIG_VALUE_0="$work/redirected" -failed=0 -(cd "$work/intended" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag initial --output "$work/candidate") > "$work/prepared" -if ! jq -e --arg head "$head" '.sourceCommit==$head' "$work/candidate/release.json" >/dev/null; then printf 'FAIL redirected source\n';failed=$((failed+1));fi -if (cd "$work/intended" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag initial --output "$work/intended/forbidden") > "$work/result" 2> "$work/error"; then printf 'FAIL wrote inside caller\n';failed=$((failed+1));fi -if ! (cd "$work/intended" && bash "$root/scripts/verify-marketplace-release.sh" --candidate "$work/candidate" --source "$head" --release "$head") > "$work/result" 2> "$work/error"; then printf 'FAIL redirected verifier\n';failed=$((failed+1));fi - -mkdir -p "$work/intended/subdirectory" -if ! (cd "$work/intended/subdirectory" && GIT_CEILING_DIRECTORIES="$work/intended" bash "$root/scripts/prepare-marketplace-release.sh" --base-tag initial --output "$work/subdirectory-candidate") > "$work/result" 2> "$work/error"; then - cat "$work/error" >&2 - printf 'FAIL inherited ceiling hides caller root\n'; failed=$((failed+1)) -elif ! jq -e --arg head "$head" '.sourceCommit==$head' "$work/subdirectory-candidate/release.json" >/dev/null; then - printf 'FAIL subdirectory caller source differs\n'; failed=$((failed+1)) -fi - - -if ! (cd "$work/intended/subdirectory" && GIT_CEILING_DIRECTORIES="$work/intended" bash "$root/scripts/verify-marketplace-release.sh" --candidate "$work/subdirectory-candidate" --source "$head" --release "$head") > "$work/result" 2> "$work/error"; then cat "$work/error" >&2; printf 'FAIL subdirectory verifier\n'; failed=$((failed+1)); fi -if ! (cd "$work/intended/subdirectory" && GIT_CEILING_DIRECTORIES="$work/intended" bash "$root/scripts/check-marketplace-version.sh" "$head" "$head") > "$work/result" 2> "$work/error"; then cat "$work/error" >&2; printf 'FAIL subdirectory version gate\n'; failed=$((failed+1)); fi - -printf 'caller context: %s failures\n' "$failed" -[ "$failed" -eq 0 ] diff --git a/scripts/marketplace-observation-completeness.test.sh b/scripts/marketplace-observation-completeness.test.sh deleted file mode 100644 index cc763ece..00000000 --- a/scripts/marketplace-observation-completeness.test.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env bash -# Real release histories with incomplete observations at external command boundaries. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false -real_git=$(command -v git) -real_find=$(command -v find) -export REAL_GIT="$real_git" REAL_FIND="$real_find" -passed=0 failed=0 -fixture() { - repo=$(mktemp -d "$work/repo.XXXXXX") - repo=$(cd "$repo" && pwd -P) - git -C "$repo" init -q - git -C "$repo" config user.name Test - git -C "$repo" config user.email test@example.invalid - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - printf '%s\n' '{"name":"test","metadata":{"version":"1.2.3"},"plugins":[{"name":"example","version":"4.5.6","source":"./plugins/example"}]}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - printf 'original\n' > "$repo/content" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json content - git -C "$repo" commit -qm 'Initial import' - git -C "$repo" tag v1.2.3 - git -C "$repo" commit --allow-empty -qm 'feat: capability' - source=$(git -C "$repo" rev-parse HEAD) - candidate=$(mktemp -d "$work/holder.XXXXXX")/candidate - (cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag v1.2.3 --head "$source" --output "$candidate") >/dev/null - candidate=$(cd "$candidate" && pwd -P) - cp "$candidate/.github/plugin/marketplace.json" "$repo/.github/plugin/marketplace.json" - cp "$candidate/.claude-plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'chore(release): proposal' - release=$(git -C "$repo" rev-parse HEAD) -} -run() { - case "$mode" in - inspect) (cd "$repo" && bash "$root/scripts/verify-marketplace-release.sh" --candidate "$candidate" --source "$source" --release "$release" --inspect-existing) ;; - verify) (cd "$repo" && bash "$root/scripts/verify-marketplace-release.sh" --candidate "$candidate" --source "$source" --release "$release") ;; - version) (cd "$repo" && bash "$root/scripts/check-marketplace-version.sh" "$source" "$source") ;; - prepare) (cd "$repo" && bash "$root/scripts/prepare-marketplace-release.sh" --base-tag v1.2.3 --head "$source" --output "$destination") ;; - esac -} -refuse() { - local name=$1 - if run > "$work/result" 2> "$work/error"; then - printf 'FAIL %s was accepted\n' "$name" >&2; failed=$((failed+1)) - elif [ -s "$work/result" ]; then - printf 'FAIL %s emitted a success record\n' "$name" >&2; failed=$((failed+1)) - elif [ -n "${2:-}" ] && ! grep -Fq "$2" "$work/error"; then - printf 'FAIL %s refused for another reason: %s\n' "$name" "$(cat "$work/error")" >&2; failed=$((failed+1)) - else - passed=$((passed+1)) - fi -} -accept() { - local name=$1 status=$2 - if ! run > "$work/result" 2> "$work/error"; then - printf 'FAIL %s was refused: %s\n' "$name" "$(cat "$work/error")" >&2; failed=$((failed+1)) - elif ! jq -e --arg status "$status" '.status==$status and .publication=="NOT_AUTHORIZED"' "$work/result" >/dev/null; then - printf 'FAIL %s has the wrong assessment\n' "$name" >&2; failed=$((failed+1)) - else - passed=$((passed+1)) - fi -} -mkdir "$work/bin" -cat > "$work/bin/git" <<'STUB' -#!/usr/bin/env bash -if { [ "${1:-}" = -C ] && [ "${2:-}" = "$OBS_REPO" ] && [ "${3:-}" = config ]; } || - { [ "${1:-}" = config ] && [ "$PWD" = "$OBS_REPO" ]; }; then - case "$OBS_FAULT:$*" in - extension:*extensions.partialClone*) printf 'origin\n'; exit 1 ;; - promisor:*promisor*) printf 'remote.origin.promisor false\n'; exit 1 ;; - extension-newline:*extensions.partialClone*) printf '\n'; exit 1 ;; - promisor-newline:*promisor*) printf '\n'; exit 1 ;; - esac -fi -if [ "$OBS_FAULT" = graft ] && [ "${1:-}" = rev-parse ] && [ "${2:-}" = --git-path ]; then exit 1; fi -if [ "$OBS_FAULT" = changes ] && - { [ "${1:-}" = diff-tree ] || - { [ "${1:-}" = -c ] && [ "${2:-}" = core.fsmonitor=false ] && [ "${3:-}" = diff-tree ]; }; }; then - printf '.claude-plugin/marketplace.json\0.github/plugin/marketplace.json\0content' - exit 0 -fi -if [ "$OBS_FAULT" = worktrees ] && [ "${1:-}" = worktree ] && [ "${2:-}" = list ]; then - printf 'worktree %s\0HEAD %s\0branch refs/heads/main\0\0worktree %s' "$OBS_REPO" "$OBS_SOURCE" "$OBS_OTHER" - exit 0 -fi -exec "$REAL_GIT" "$@" -STUB -cat > "$work/bin/find" <<'STUB' -#!/usr/bin/env bash -if [ "$OBS_FAULT" = artifacts ] && [ "${1:-}" = "$OBS_CANDIDATE" ]; then - "$REAL_FIND" "$1" -mindepth 1 ! -name extra -print0 - printf '%s/extra' "$1" - exit 0 -fi -exec "$REAL_FIND" "$@" -STUB -chmod +x "$work/bin/git" "$work/bin/find" -fixture; mode=inspect -run > "$work/result" -jq -e '.status=="INSPECTED" and .publication=="NOT_AUTHORIZED"' "$work/result" >/dev/null -passed=$((passed+1)) -git -C "$repo" config extensions.partialClone '' -refuse 'defined empty partial-clone extension remains refused' -for mode in verify inspect; do - fixture - mv "$candidate" "$candidate"$'\n' - candidate=$candidate$'\n' - status=VERIFIED; [ "$mode" != inspect ] || status=INSPECTED - accept "literal trailing-newline candidate in $mode" "$status" -done -for fault in extension promisor extension-newline promisor-newline; do - fixture; mode=inspect - PATH="$work/bin:$PATH" REAL_GIT="$real_git" OBS_REPO="$repo" OBS_FAULT="$fault" refuse "partial failed $fault configuration" 'unreadable partial-clone configuration' -done -fixture; mode=version -PATH="$work/bin:$PATH" REAL_GIT="$real_git" OBS_FAULT=graft refuse 'failed graft-path observation' 'graft path is unreadable' -fixture; mode=verify; printf extra > "$candidate/extra" -refuse 'complete inventory catches extra artifact' -PATH="$work/bin:$PATH" REAL_GIT="$real_git" REAL_FIND="$real_find" OBS_FAULT=artifacts OBS_CANDIDATE="$candidate" refuse 'unterminated extra artifact' 'unterminated record' -fixture; mode=verify -printf changed > "$repo/content"; git -C "$repo" add content; git -C "$repo" commit --amend --no-edit -q -release=$(git -C "$repo" rev-parse HEAD) -refuse 'complete inventory catches unrelated content' -PATH="$work/bin:$PATH" REAL_GIT="$real_git" OBS_FAULT=changes refuse 'unterminated release change' 'unterminated record' -fixture; mode=prepare -other=$(mktemp -d "$work/other.XXXXXX"); rmdir "$other" -git -C "$repo" worktree add --detach -q "$other" "$source" -destination="$other/candidate" -refuse 'complete census catches a destination inside another worktree' -PATH="$work/bin:$PATH" REAL_GIT="$real_git" OBS_FAULT=worktrees OBS_REPO="$repo" OBS_SOURCE="$source" OBS_OTHER="$other" refuse 'unterminated final worktree' 'unterminated record' -if [ -e "$destination" ]; then printf 'FAIL refused worktree census created output\n' >&2; failed=$((failed+1)); fi -printf 'PASS %s marketplace observation cases; FAIL %s\n' "$passed" "$failed" -[ "$failed" -eq 0 ] diff --git a/scripts/marketplace-permissions.jq b/scripts/marketplace-permissions.jq deleted file mode 100644 index 8bdfa502..00000000 --- a/scripts/marketplace-permissions.jq +++ /dev/null @@ -1,11 +0,0 @@ -# Bind native repository identity to a successful nonpersistent notes response. -# GitHub requires contents-write for generation, but creates no remote object. -def native_writer_repository($repo;$branch;$node;$proof): - type=="object" and .full_name==$repo and .node_id==$node and - (.id|type=="number" and .>0 and floor==.) and .archived==false and - .default_branch==$branch and - ($proof | type=="object" and (.name|type=="string" and length>0) and (.body|type=="string")); - -# The native capability proof is required for a user role or an explicit null App role. -def compatible_user_role: - has("viewerPermission") and (.viewerPermission | .==null or .=="ADMIN" or .=="MAINTAIN" or .=="WRITE"); diff --git a/scripts/marketplace-proposal-workflow.test.sh b/scripts/marketplace-proposal-workflow.test.sh deleted file mode 100644 index 6fb81ed2..00000000 --- a/scripts/marketplace-proposal-workflow.test.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash -# Test the actual workflow's guards and permissions; no provider or host mutations. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -workflow=${1:-"$root/.github/workflows/propose-marketplace-release.yaml"} -passed=0 -# Report the violated workflow boundary and stop the suite. -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } -[ -f "$workflow" ] || fail 'proposal workflow is not implemented' -# Read a job's actual folded conditional from the workflow under test. -guard() { - awk -v wanted="$1" '/^ [a-z]+:/ {job=$1;sub(/:$/,"",job)} job==wanted && /^ if: >-$/ {reading=1;next} reading && /^ / {sub(/^ /,"");printf "%s ",$0;next} reading {exit}' "$workflow" -} -assess=$(guard assess) propose=$(guard propose) recheck=$(guard recheck) -if [ -z "$assess" ] || [ -z "$propose" ] || [ -z "$recheck" ]; then fail 'missing explicit job guards'; fi -# Evaluate the workflow's boolean guard against one synthetic event context. -evaluate() { - local expression - expression=$(printf '%s' "$1" | sed -E "s/'/\"/g;s/&&/and/g;s/\|\|/or/g;s/(github|inputs|vars|needs)\./\$context.\1./g") - jq -nr --argjson context "$2" "$expression" -} -# Assert the three job admission results for one event, flag and status combination. -check() { - local event=$1 ref=$2 armed=$3 flag=$4 assessment=$5 creation=$6 expected=$7 context actual - context=$(jq -nc --arg event "$event" --arg ref "$ref" --argjson armed "$armed" --arg flag "$flag" --arg assessment "$assessment" --arg creation "$creation" '{github:{event_name:$event,ref:$ref},inputs:{propose:$armed},vars:{MARKETPLACE_AUTOPROPOSE:$flag},needs:{assess:{outputs:{status:$assessment}},propose:{outputs:{status:$creation}}}}') - actual="$(evaluate "$assess" "$context") $(evaluate "$propose" "$context") $(evaluate "$recheck" "$context")" - [ "$actual" = "$expected" ] || fail "$event/$ref/$armed/$flag/$assessment/$creation: $actual" - passed=$((passed+1)) -} -check workflow_dispatch refs/heads/main false '' PREPARED '' 'true false false' -check workflow_dispatch refs/heads/main false true PREPARED '' 'true false false' -check workflow_dispatch refs/heads/main true '' PREPARED CREATED 'true true true' -for status in '' NO_CHANGE REFUSED prepared; do - check workflow_dispatch refs/heads/main true '' "$status" '' 'true false false' -done -for flag in '' false TRUE 1 enabled; do - check schedule refs/heads/main false "$flag" PREPARED '' 'false false false' -done -check schedule refs/heads/main false true PREPARED CREATED 'true true true' -for status in '' NO_CHANGE REFUSED prepared; do - check schedule refs/heads/main false true "$status" '' 'true false false' -done -for status in '' PREPARED NO_CHANGE REFUSED created; do - check workflow_dispatch refs/heads/main true '' PREPARED "$status" 'true true false' -done -for ref in refs/heads/feature refs/tags/v1.0.0; do - check workflow_dispatch "$ref" true true PREPARED CREATED 'false false false' -done -for event in push pull_request pull_request_target workflow_run; do - check "$event" refs/heads/main true true PREPARED CREATED 'false false false' -done -awk ' - /^permissions: \{\}$/ {root++} - /^ assess:/ {job="assess"} - /^ propose:/ {job="propose"} - /^ recheck:/ {job="recheck"} - /^ permissions:$/ {permissions=job;next} - permissions && /^ (contents|actions|pull-requests):/ {p[permissions,$1]=$2;next} - permissions && !/^ / {permissions=""} - /^ ref: main$/ {main++} - /^ fetch-depth: 0$/ {history++} - /^ persist-credentials: false$/ {credentials++} - /^ default: false$/ {off++} - /^ needs: assess$/ {create_needs++} - /^ needs: propose$/ {recheck_needs++} - END {exit !(root==1 && p["assess","contents:"]=="read" && p["assess","actions:"]=="read" && p["assess","pull-requests:"]=="read" && - p["propose","contents:"]=="write" && p["propose","pull-requests:"]=="write" && p["propose","actions:"]=="read" && - p["recheck","actions:"]=="write" && !p["recheck","contents:"] && !p["recheck","pull-requests:"] && - main==2 && history==2 && credentials==2 && off==1 && create_needs==1 && recheck_needs==1)} -' "$workflow" || fail 'permission, dependency, checkout or default-off boundary' -passed=$((passed+1)) -concurrency=$(sed -n 's/^ group: marketplace-proposal-${{ \(.*\) }}$/\1/p' "$workflow") -suffix=" && 'write' || 'assessment'" -condition=${concurrency%"$suffix"} -if [ -z "$condition" ] || [ "$condition" = "$concurrency" ]; then fail 'missing shared writer concurrency group'; fi -# Evaluate the actual concurrency condition so every armed event shares the write queue. -check_concurrency() { - local event=$1 armed=$2 flag=$3 expected=$4 context actual - context=$(jq -nc --arg event "$event" --argjson armed "$armed" --arg flag "$flag" '{github:{event_name:$event},inputs:{propose:$armed},vars:{MARKETPLACE_AUTOPROPOSE:$flag}}') - if [ "$(evaluate "$condition" "$context")" = true ]; then actual='write'; else actual='assessment'; fi - [ "$actual" = "$expected" ] || fail "concurrency $event/$armed/$flag: $actual" - passed=$((passed+1)) -} -check_concurrency workflow_dispatch true '' write -check_concurrency workflow_dispatch true true write -check_concurrency workflow_dispatch false true assessment -check_concurrency workflow_dispatch false '' assessment -check_concurrency schedule false true write -for flag in '' false TRUE; do check_concurrency schedule false "$flag" assessment; done -# shellcheck disable=SC2016 # Match the literal variable reference used by the actual workflow. -grep -Fq 'gh workflow run recheck-open-prs.yaml --repo "$GH_REPO" --ref main -F dry-run=false' "$workflow" || fail 'CI must use the existing canonical recheck' -! grep -Eq 'workflow_run:|pull_request_target:|download-artifact|APP_PRIVATE_KEY|gh pr (merge|ready)' "$workflow" || fail 'unexpected authority or artifact consumer' -passed=$((passed+1)) -printf 'PASS marketplace proposal workflow (%s cases)\n' "$passed" diff --git a/scripts/marketplace-proposal.jq b/scripts/marketplace-proposal.jq deleted file mode 100644 index 75b4a8a2..00000000 --- a/scripts/marketplace-proposal.jq +++ /dev/null @@ -1,95 +0,0 @@ -include "graphql-observation"; -# Complete repository-bound observations; content fields are compared only as data. -include "marketplace-release"; -# Demand a complete, uniquely identified PR/file inventory before resolving rename sources. -def proposal_pr_inventory: - type=="object" and (.totalCount|type=="number" and .>=0 and .<=100 and floor==.) and - (.nodes|type=="array") and .totalCount==(.nodes|length) and - (.totalCount==([.nodes[].number]|unique|length)) and - all(.nodes[]; (.number|type=="number" and .>0 and .<=2147483647 and floor==.) and (.headRefName|nonblank) and - (.files | type=="object" and (.totalCount|type=="number" and .>=0 and .<=100 and floor==.) and - (.nodes|type=="array") and .totalCount==(.nodes|length) and - (.totalCount==([.nodes[].path]|unique|length)) and - all(.nodes[]; (.path|nonblank) and - (.changeType=="ADDED" or .changeType=="DELETED" or .changeType=="RENAMED" or - .changeType=="COPIED" or .changeType=="MODIFIED" or .changeType=="CHANGED")))); - -# Bind complete REST filename/status records to GraphQL before using original rename paths. -def proposal_rename_metadata($number;$files): - . as $pages | - if ($files|length)!=1 or ($files[0]|type!="array" or length==0 or any(.[];type!="array")) - then error("rename page stream is incomplete") else . end | - ($files[0]|add) as $native | - if all($native[]; (.filename|nonblank) and - (.status=="added" or .status=="removed" or .status=="renamed" or .status=="copied" or .status=="modified" or .status=="changed") and - (if .status=="renamed" then (.previous_filename|nonblank) else true end)) and - ([$native[].filename]|unique|length)==($native|length) and - any($pages[];any(.data.repository.pullRequests.nodes[];.number==$number)) and - all($pages[];.data.repository.pullRequests.nodes[]|select(.number==$number)| - .files.totalCount==($native|length) and - ([.files.nodes[]|{filename:.path,changeType}]|sort_by(.filename))== - ([$native[]|{filename,changeType:(.status|if .=="removed" then "DELETED" else ascii_upcase end)}]|sort_by(.filename))) - then . else error("REST and GraphQL rename identities differ") end | - map(.data.repository.pullRequests.nodes |= map(if .number==$number then - .files.nodes |= map(. as $file | if .changeType=="RENAMED" then - . + {previousPath:($native[]|select(.filename==$file.path)|.previous_filename)} else . end) - else . end)); - -def proposal_snapshot($repo;$source;$baseline;$tags;$permission;$branch;$owned): - . as $pages | - if ($permission|length)!=1 or - ($permission[0] | type!="object" or .full_name!=$repo or .archived!=false or - .default_branch!="main" or (.id|type!="number" or .<=0 or floor!=.) or (.node_id|nonblank|not)) or - type!="array" or length==0 then error("repository identity or page stream is incomplete") else . end | - if all(.[]; graphql_complete and (.data.repository | - type=="object" and .id==$permission[0].node_id and .nameWithOwner==$repo and .isArchived==false and - .defaultBranchRef.name=="main" and .defaultBranchRef.target.__typename=="Commit" and - .defaultBranchRef.target.oid==$source and - (.baseline | type=="object" and (.databaseId|type=="number" and .>0 and floor==.) and .tagName==$baseline.tag and - .isDraft==false and .isPrerelease==false and (.publishedAt|nonblank) and .tagCommit.oid==$baseline.commit) and - .baseline==$pages[0].data.repository.baseline and - has("candidate") and .candidate==null and has("proposal") and - (if $owned=="" then .proposal==null else - .proposal.name==$branch and .proposal.target.__typename=="Commit" and .proposal.target.oid==$owned end) and - (.pullRequests | proposal_pr_inventory and - all(.nodes[]; - (.headRefName|startswith("automation/marketplace-v")|not) and - all(.files.nodes[]; .path!=".github/plugin/marketplace.json" and .path!=".claude-plugin/marketplace.json" and - (if .changeType=="RENAMED" then (.previousPath|nonblank) and - .previousPath!=".github/plugin/marketplace.json" and .previousPath!=".claude-plugin/marketplace.json" else true end)))))) - then . else error("main, baseline, occupancy or complete PR visibility is invalid") end | - if all(range(0;length); . as $i | $pages[$i].data.repository.refs | - type=="object" and (.totalCount|type=="number" and .>=0 and floor==.) and .totalCount==$pages[0].data.repository.refs.totalCount and - (.nodes|type=="array" and length<=100) and - all(.nodes[]; (.name|nonblank) and (.target.__typename=="Commit" or .target.__typename=="Tag") and - (.target.oid|type=="string" and test("^[0-9a-f]{40}$"))) and - (.pageInfo | type=="object" and has("hasNextPage") and has("endCursor") and - (.hasNextPage|type=="boolean")) and - .pageInfo.hasNextPage==($i<($pages|length)-1) and - (if .pageInfo.hasNextPage then (.pageInfo.endCursor|nonblank) - else .pageInfo.endCursor==null or (.pageInfo.endCursor|nonblank) end)) then . - else error("tag pagination or identities are incomplete") end | - ([.[].data.repository.refs.nodes[]|{name,oid:.target.oid}]|sort_by(.name)) as $remote | - if ($remote|length)!=$pages[0].data.repository.refs.totalCount or - ($remote|map(.name)|unique|length)!=($remote|length) or $remote!=$tags - then error("local and complete remote tag objects differ") else . end | - {repository:$repo,repositoryId:$permission[0].node_id,repositoryDatabaseId:$permission[0].id, - sourceCommit:$source,baseline:$baseline,publishedBaseline:$pages[0].data.repository.baseline,tags:$remote}; - -# A draft readback binds the mutable PR projection to the exact signed, reproduced commit. -def proposal_readback($repo;$node;$source;$branch;$commit;$number;$title;$body;$native): - ($native|length==1) and ($native[0] | - (.node_id|nonblank) and .number==$number and .state=="open" and .draft==true and - .user.login=="github-actions[bot]" and .user.type=="Bot" and (.user.node_id|nonblank) and - .head.ref==$branch and .head.sha==$commit and .head.repo.full_name==$repo and - .base.ref=="main" and .base.sha==$source and .base.repo.full_name==$repo and - .title==$title and .body==$body and .html_url==("https://github.com/"+$repo+"/pull/"+($number|tostring))) and - graphql_complete and (.data.repository | - .id==$node and .nameWithOwner==$repo and .isArchived==false and - .defaultBranchRef.name=="main" and .defaultBranchRef.target.oid==$source and - .ref.name==$branch and .ref.target.oid==$commit and - (.pullRequest | .id==$native[0].node_id and .number==$number and .state=="OPEN" and .isDraft==true and - .author.__typename=="Bot" and .author.login=="github-actions" and .author.id==$native[0].user.node_id and - .headRefName==$branch and .headRefOid==$commit and .baseRefName=="main" and .baseRefOid==$source and - .headRepository.nameWithOwner==$repo and .title==$title and .body==$body and - .url==("https://github.com/"+$repo+"/pull/"+($number|tostring)))); diff --git a/scripts/marketplace-publication-identity.test.sh b/scripts/marketplace-publication-identity.test.sh deleted file mode 100644 index d4ad98e8..00000000 --- a/scripts/marketplace-publication-identity.test.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -# Run the publication workflow's actual assessment shell against an advanced checkout. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -awk ' - /^ assess:/ {assessment=1} - /^ publish:/ {assessment=0} - assessment && /^ id: prepare$/ {selected=1} - selected && /^ run: \|$/ {reading=1; next} - reading && /^ / {sub(/^ /,""); print; next} - reading {exit} -' "$root/.github/workflows/publish-marketplace-release.yaml" > "$work/step" -[[ -s $work/step ]] || { echo 'FAIL: assessment step is unavailable' >&2; exit 1; } -git init -q "$work/repo" -git -C "$work/repo" config user.name 'Publication identity fixture' -git -C "$work/repo" config user.email fixture@example.invalid -git -C "$work/repo" config commit.gpgsign false -git -C "$work/repo" commit --allow-empty -qm baseline -dispatch=$(git -C "$work/repo" rev-parse HEAD) -git -C "$work/repo" commit --allow-empty -qm current -current=$(git -C "$work/repo" rev-parse HEAD) -mkdir "$work/repo/scripts" "$work/bin" -cat > "$work/repo/scripts/prepare-merged-marketplace-release.sh" <<'STUB' -#!/usr/bin/env bash -set -euo pipefail -printf 'called\n' >> "$CALLED" -release= ci= -while (($#)); do - case $1 in - --release) release=$2; shift 2 ;; - --ci-run) ci=$2; shift 2 ;; - --repo|--output) shift 2 ;; - *) exit 91 ;; - esac -done -[[ $release == "$CURRENT" && $ci == latest ]] || exit 92 -jq -n --arg release "$release" '{status:"NO_VERSION_CHANGE",releaseCommit:$release,ciRunId:42}' -STUB -cat > "$work/bin/git" <<'STUB' -#!/usr/bin/env bash -if [[ ${FAIL_HEAD:-false} == true && " $* " == *' rev-parse '* ]]; then - printf '%s\n' "$CURRENT" - exit 73 -fi -exec "$REAL_GIT" "$@" -STUB -chmod +x "$work/bin/git" -real_git=$(command -v git) -pass=0 fail=0 -for mode in ordinary queued wrong-ci failed-head; do - : > "$work/called"; : > "$work/outputs"; : > "$work/summary" - selected=$current; [[ $mode != queued ]] || selected=$dispatch - ci=latest; [[ $mode != wrong-ci ]] || ci=41 - failed=false; [[ $mode != failed-head ]] || failed=true - status=0 - (cd "$work/repo" && CALLED="$work/called" CURRENT="$current" REAL_GIT="$real_git" \ - FAIL_HEAD=$failed PATH="$work/bin:$PATH" RELEASE_COMMIT="$selected" CI_RUN=$ci \ - REPOSITORY=example/catalogue RUNNER_TEMP="$work" GITHUB_OUTPUT="$work/outputs" \ - GITHUB_STEP_SUMMARY="$work/summary" bash -euo pipefail "$work/step") \ - > "$work/out" 2> "$work/error" || status=$? - ok=false - case $mode in - ordinary|queued) - if [[ $status == 0 ]] && grep -qx "release=$current" "$work/outputs"; then ok=true; fi ;; - wrong-ci) [[ $status != 0 && ! -s $work/outputs ]] && ok=true ;; - failed-head) [[ $status != 0 && ! -s $work/called && ! -s $work/outputs ]] && ok=true ;; - esac - if [[ $ok == true ]]; then printf 'PASS: publication identity %s\n' "$mode"; pass=$((pass+1)) - else printf 'FAIL: publication identity %s (exit %s)\n' "$mode" "$status"; fail=$((fail+1)); fi -done -printf 'Publication identity controls: %s pass, %s fail\n' "$pass" "$fail" -[[ $fail == 0 ]] diff --git a/scripts/marketplace-publication-workflow.test.sh b/scripts/marketplace-publication-workflow.test.sh deleted file mode 100644 index 6040f6f9..00000000 --- a/scripts/marketplace-publication-workflow.test.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash -# Exercise the actual workflow's boolean guards with independent event and output fixtures. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -workflow=${1:-"$root/.github/workflows/publish-marketplace-release.yaml"} -passed=0 -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } - -# Job guards use only typed boolean inputs, explicit string comparisons, and &&/||. -# Read the expressions from YAML; adding syntax outside this subset must fail this test. -guard() { - awk -v wanted="$1" ' - /^ [a-z]+:/ {job=$1; sub(/:$/, "", job)} - job==wanted && /^ if: >-$/ {reading=1; next} - reading && /^ / {sub(/^ /, ""); printf "%s ", $0; next} - reading {exit} - ' "$workflow" -} -assess=$(guard assess) -publish=$(guard publish) -if [ -z "$assess" ] || [ -z "$publish" ]; then fail 'missing workflow guards'; fi - -evaluate() { - local expression - expression=$(printf '%s' "$1" | sed -E "s/'/\"/g; s/&&/and/g; s/\|\|/or/g; s/(github|inputs|vars|needs)\./\$context.\1./g") - jq -n -r --argjson context "$2" "$expression" -} -case_check() { - local name=$1 event=$2 ref=$3 armed=$4 variable=$5 status=$6 expected_assess=$7 expected_publish=$8 - local context actual_assess actual_publish - context=$(jq -nc --arg event "$event" --arg ref "$ref" --argjson armed "$armed" \ - --arg variable "$variable" --arg status "$status" \ - '{github:{event_name:$event,ref:$ref},inputs:{publish:$armed},vars:{MARKETPLACE_AUTOPUBLISH:$variable},needs:{assess:{outputs:{status:$status}}}}') - actual_assess=$(evaluate "$assess" "$context") - actual_publish=$(evaluate "$publish" "$context") - # Actions implicitly requires the assessment dependency to run successfully. - if [ "$actual_assess" = false ]; then actual_publish=false; fi - if [ "$actual_assess" != "$expected_assess" ] || [ "$actual_publish" != "$expected_publish" ]; then - fail "$name: assessment=$actual_assess publication=$actual_publish" - fi - passed=$((passed + 1)) -} - -case_check 'manual defaults to read-only' workflow_dispatch refs/heads/main false '' VERIFIED true false -case_check 'manual input overrides enabled schedule variable' workflow_dispatch refs/heads/main false true VERIFIED true false -case_check 'manual publication explicitly armed' workflow_dispatch refs/heads/main true '' VERIFIED true true -case_check 'manual assessment accepts no version change' workflow_dispatch refs/heads/main false '' NO_VERSION_CHANGE true false -for status in '' NO_VERSION_CHANGE REJECTED verified; do - case_check "manual refuses unverified output $status" workflow_dispatch refs/heads/main true '' "$status" true false - case_check "schedule refuses unverified output $status" schedule refs/heads/main false true "$status" true false -done -case_check 'manual branch cannot assess or publish' workflow_dispatch refs/heads/feature true true VERIFIED false false -case_check 'manual tag cannot assess or publish' workflow_dispatch refs/tags/v1.2.0 true true VERIFIED false false -for variable in '' false TRUE 1 enabled; do - case_check "schedule refuses variable $variable" schedule refs/heads/main false "$variable" VERIFIED false false -done -case_check 'schedule explicitly enabled' schedule refs/heads/main false true VERIFIED true true -for event in pull_request pull_request_target workflow_run push; do - case_check "unsupported event $event" "$event" refs/heads/main true true VERIFIED false false -done - -# Verify the permissions and checkout boundary used by these tested branches. -awk ' - /^permissions: \{\}$/ {root++} - /^ assess:/ {job="assess"} - /^ publish:/ {job="publish"} - /^ permissions:$/ {permissions=job; next} - permissions && /^ contents:/ {contents[permissions]=$2; next} - permissions && /^ actions:/ {actions[permissions]=$2; next} - permissions && !/^ / {permissions=""} - /^ needs: assess$/ {dependency++} - /^ ref: main$/ {main++} - /^ fetch-depth: 0$/ {history++} - /^ persist-credentials: false$/ {credentials++} - /^ default: false$/ {default_off++} - END {exit !(root==1 && contents["assess"]=="read" && actions["assess"]=="read" && - contents["publish"]=="write" && actions["publish"]=="read" && dependency==1 && - main==2 && history==2 && credentials==2 && default_off==1)} -' "$workflow" || fail 'permission, dependency, checkout or default input boundary' -passed=$((passed + 1)) -printf 'PASS marketplace publication workflow (%s cases)\n' "$passed" diff --git a/scripts/marketplace-publication.jq b/scripts/marketplace-publication.jq deleted file mode 100644 index 9cdccb46..00000000 --- a/scripts/marketplace-publication.jq +++ /dev/null @@ -1,31 +0,0 @@ -include "graphql-observation"; -include "marketplace-release"; -include "marketplace-permissions"; - -# Render the verified plan as public notes, escaping its data-derived Markdown text. -def publication_notes($release): - ["> πŸ€– Generated by the Agentic Engineer", "# Marketplace \(.version)", - "Source commit: `\(.sourceCommit)`", "Release commit: `\($release)`", - "Baseline: \(if .baseline == null then "initial snapshot" else "`"+.baseline.tag+"` at `"+.baseline.commit+"`" end)", - "## Changes", (.commits[] | "- \(.subject | markdown_text) (`\(.sha)`)"), - "## Plugin inventory", (.plugins[] | "- \(.name | markdown_text): \(.version | markdown_text)"), - "Per-plugin versions and runtime cache identities remain independent of the marketplace version." - ] | join("\n\n") + "\n"; - -# Accept one observed publication phase only when all expected identities still agree. -def publication_snapshot($phase;$repo;$node;$branch;$tag;$release;$id;$notes;$permission;$proof): - graphql_complete and - ($permission | native_writer_repository($repo;$branch;$node;$proof)) and - (.data.repository | type=="object" and .id==$node and .nameWithOwner==$repo and .isArchived==false and - compatible_user_role and - .defaultBranchRef.name==$branch and .defaultBranchRef.target.__typename=="Commit" and - .defaultBranchRef.target.oid==$release and has("ref") and has("release") and - (if $phase=="absent" then .ref==null else - .ref.prefix=="refs/tags/" and .ref.name==$tag and .ref.target.__typename=="Commit" and .ref.target.oid==$release - end) and - (if $phase!="published" then .release==null else - (.release | type=="object" and .databaseId==$id and .tagName==$tag and .isDraft==false and - .isPrerelease==false and .name==$tag and .description==$notes and - (.publishedAt|type=="string" and length>0) and .tagCommit.oid==$release and - .url==("https://github.com/"+$repo+"/releases/tag/"+$tag)) - end)); diff --git a/scripts/marketplace-release.jq b/scripts/marketplace-release.jq index a0a8cf14..2a2b7447 100644 --- a/scripts/marketplace-release.jq +++ b/scripts/marketplace-release.jq @@ -1,50 +1,4 @@ -# Stable marketplace release preparation; the publishing boundary is deliberately absent. +# Canonical stable version predicates shared by the manifest validator and the cache-version tools. def stable_syntax: type == "string" and test("\\A(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\z"); def stable_version: stable_syntax and (split(".") | all(.[]; length <= 9)); -def nonblank: type == "string" and test("\\S"); -def valid_marketplace: - type == "object" and (.name | nonblank) and (.metadata.version | stable_version) - and (.plugins | type == "array" and length > 0 - and (map(.name) | length == (unique | length)) - and all(.[]; (.name | type == "string" and test("^[a-z0-9]+(-[a-z0-9]+)*$")) - and (.version | stable_version) and .source == ("./plugins/" + .name))); -def commit_level: - . as $commit | (.message | split("\n")[0]) as $subject - | ((try ($subject | capture("^(?[a-z][a-z0-9-]*)(\\([^()\\r\\n]+\\))?(?!)?: +\\S"; "i")) catch null) // null) as $header - | if $header == null then error("unclassified commit requires review: " + .sha) - elif ($header.type | ascii_downcase) == "revert" then error("revert requires review: " + .sha) - elif $header.breaking == "!" or (.message | test("(^|\n)BREAKING( CHANGE|-CHANGE): [^\\s]")) then 3 - elif ($header.type | ascii_downcase) == "feat" then 2 - elif ([$header.type | ascii_downcase] | any(.[]; . == "fix" or . == "perf")) then 1 - else 0 end; -def prepare($source; $base; $baseTag; $current; $commits): - (if $baseTag == "initial" then 0 else ([$commits[] | commit_level] | max // 0) end) as $level - | ($current | split(".") | map(tonumber)) as $parts - | (if $baseTag == "initial" then $current - elif $level == 3 then [$parts[0]+1,0,0] | join(".") - elif $level == 2 then [$parts[0],$parts[1]+1,0] | join(".") - elif $level == 1 then [$parts[0],$parts[1],$parts[2]+1] | join(".") - else null end) as $version - | if $version != null and ($version | stable_version | not) then error("version component exceeds supported range") else - {schemaVersion:1, status:(if $version == null then "NO_RELEASE" else "CANDIDATE" end), - publication:"NOT_AUTHORIZED", sourceCommit:$source, - baseline:(if $baseTag == "initial" then null else {tag:$baseTag,commit:$base,version:$current} end), - version:$version, tag:(if $version == null then null else "v"+$version end), - releaseType:(if $baseTag == "initial" then "initial" else ["none","patch","minor","major"][$level] end), - commits:($commits | map({sha,subject:(.message | split("\n")[0])})), - plugins:(.plugins | map({name,version,source}))} end; -def markdown_text: - gsub("[[:space:]]+"; " ") | gsub("&"; "&") | gsub("<"; "<") | gsub(">"; ">") - | gsub("(?[\\\\`*_{}\\[\\]()!|~#+.=-])"; "\\\(.mark)"); -def release_notes: - ["# Marketplace release preparation", "Status: \(.status)", - "This is a review artifact. It is not a published release and grants no publication authority.", - "Source commit: `\(.sourceCommit)`", - "Baseline: \(if .baseline == null then "initial snapshot" else "`"+.baseline.tag+"` at `"+.baseline.commit+"`" end)", - "Proposed version: \(.version // "none") (\(.releaseType))", - "## Changes", (.commits[] | "- \(.subject | markdown_text) (`\(.sha)`)") , - "## Plugin inventory", (.plugins[] | "- \(.name | markdown_text): \(.version | markdown_text)"), - "## Before publication", - "Refresh remote tags, review the proposed manifests, validate the exact release commit, and follow the reviewed publication procedure. Per-plugin cache versions are independent." - ] | join("\n\n") + "\n"; diff --git a/scripts/marketplace-remote-state.jq b/scripts/marketplace-remote-state.jq deleted file mode 100644 index 8a59531d..00000000 --- a/scripts/marketplace-remote-state.jq +++ /dev/null @@ -1,43 +0,0 @@ -include "graphql-observation"; -# Normalize a complete paginated GitHub observation; absence is meaningful only in valid data. -include "marketplace-permissions"; -def oid: type == "string" and test("^[0-9a-f]{40}$"); -def nonempty: type == "string" and length > 0; -def require($condition; $message): if $condition then . else error($message) end; -require(type == "array" and length > 0; "missing remote pages") -| . as $pages -| require(all(.[]; - graphql_complete and - (.data.repository | type == "object" and - .nameWithOwner == $repo and .isArchived == false and - (.id | nonempty) and compatible_user_role and - (. as $repository | ($permission | length)==1 and ($writer | length)==1 and - ($permission[0] | native_writer_repository($repo;$repository.defaultBranchRef.name;$repository.id;$writer[0]))) and - (.defaultBranchRef | type == "object" and (.name | nonempty) and - .target.__typename == "Commit" and (.target.oid | oid) and .target.oid == $release) and - has("release") and .release == null and - (.refs | type == "object" and - (.totalCount | type == "number" and . >= 0 and floor == .) and - (.nodes | type == "array" and length <= 100) and - (.pageInfo | type == "object" and (.hasNextPage | type == "boolean") and - has("endCursor") and (.endCursor == null or (.endCursor | nonempty))) and - all(.nodes[]; (.name | nonempty) and (.target.oid | oid) and - (.target.__typename | . == "Commit" or . == "Tag" or . == "Tree" or . == "Blob"))))); - "remote identity, release, branch, or tag response is invalid") -| require(all(range(0; length); . as $i | - $pages[$i].data.repository.refs.pageInfo.hasNextPage == ($i < ($pages | length) - 1) and - (if $i < ($pages | length) - 1 then - ($pages[$i].data.repository.refs.pageInfo.endCursor | nonempty) and - ($pages[$i].data.repository.refs.nodes | length > 0) - else true end)); "incomplete pagination") -| require(([.[].data.repository.refs.pageInfo.endCursor | select(. != null)] | length) == - ([.[].data.repository.refs.pageInfo.endCursor | select(. != null)] | unique | length); - "repeated pagination cursor") -| require(([.[].data.repository | {id,nameWithOwner,isArchived,viewerPermission,defaultBranchRef,release}] | unique | length) == 1; - "repository changed across pages") -| require(([.[].data.repository.refs.totalCount] | unique | length) == 1; "tag count changed across pages") -| [.[].data.repository.refs.nodes[] | {name,oid:.target.oid}] | sort_by(.name) -| require(length == $pages[0].data.repository.refs.totalCount; "incomplete tag inventory") -| require(length == ([.[].name] | unique | length); "duplicate tag") -| {repository:$repo,repositoryId:$pages[0].data.repository.id,defaultBranch:$pages[0].data.repository.defaultBranchRef.name, - releaseCommit:$release,tags:.,candidateRelease:"ABSENT"} diff --git a/scripts/prepare-marketplace-release.sh b/scripts/prepare-marketplace-release.sh deleted file mode 100644 index 8208f1da..00000000 --- a/scripts/prepare-marketplace-release.sh +++ /dev/null @@ -1,200 +0,0 @@ -#!/usr/bin/env bash -# Prepare immutable, offline review artifacts. No checkout, ref, or remote writes. -set -euo pipefail -export GIT_NO_REPLACE_OBJECTS=1 GIT_NO_LAZY_FETCH=1 -here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# shellcheck source=scripts/marketplace-git-context.lib.sh -. "$here/marketplace-git-context.lib.sh" -marketplace_git_context -# shellcheck source=scripts/json-object.lib.sh -. "$here/json-object.lib.sh" -# Stop preparation without emitting a prepared candidate. -fail() { printf 'release preparation: %s\n' "$*" >&2; exit 1; } -directory_identity() { - [ -d "$1" ] && [ ! -L "$1" ] || return 1 - case "$(uname -s)" in - Darwin) stat -f '%d:%i' "$1" ;; - Linux) stat -c '%d:%i' "$1" ;; - *) return 1 ;; - esac -} -# Describe offline preparation and the explicit Git head selector. -usage() { printf 'usage: prepare-marketplace-release.sh --base-tag --output [--head ]\n'; } -base_tag='' output='' head='' -while [ "$#" -gt 0 ]; do - case "$1" in - --base-tag) - if [ "$#" -lt 2 ] || [ -n "$base_tag" ]; then fail 'one base tag is required'; fi - base_tag=$2; shift 2 ;; - --output) - if [ "$#" -lt 2 ] || [ -n "$output" ]; then fail 'one output directory is required'; fi - output=$2; shift 2 ;; - --head) - if [ "$#" -lt 2 ] || [ -n "$head" ]; then fail 'one full head commit is required'; fi - head=$2; shift 2 ;; - --help) usage; exit 0 ;; - *) fail "unknown argument: $1" ;; - esac -done -if [ -z "$base_tag" ] || [ -z "$output" ]; then fail 'base tag and output are required'; fi -if [ "$base_tag" != initial ]; then - if [[ "$base_tag" != v* ]] || ! jq -en -L "$here" --arg v "${base_tag#v}" 'include "marketplace-release"; $v | stable_version' >/dev/null; then - fail 'base must be initial or a stable vX.Y.Z tag' - fi -fi -[ "$(git rev-parse --is-shallow-repository)" = false ] || fail 'complete Git history is required' -grafts=$(git rev-parse --git-path info/grafts) -[ ! -s "$grafts" ] || fail 'grafted history is unsupported' -# A partial clone fetches missing objects on demand, which would break the offline guarantee. -# shellcheck source=scripts/complete-clone.lib.sh -. "$here/complete-clone.lib.sh" -assert_complete_clone_config || fail 'incomplete Git configuration; offline history is required' -if [ -z "$head" ]; then head=$(git rev-parse --verify HEAD); fi -[[ "$head" =~ ^[0-9a-f]{40}$ ]] || fail 'head must be a full 40-character commit' -[ "$(git cat-file -t "$head")" = commit ] || fail 'head must identify a commit' -# A sentinel retains path newlines that command substitution would otherwise trim. -parent=$(dirname "$output" && printf '.') || fail 'output parent must exist' -parent=${parent%.}; parent=${parent%$'\n'} -parent=$(cd "$parent" && pwd -P && printf '.') || fail 'output parent must exist' -parent=${parent%.}; parent=${parent%$'\n'} -name=$(basename "$output" && printf '.') || fail 'output must name a new directory' -parent_identity=$(directory_identity "$parent") || fail 'cannot identify output parent' -[[ $parent_identity =~ ^[0-9]+:[0-9]+$ ]] || fail 'invalid output parent identity' -name=${name%.}; name=${name%$'\n'} -[[ "$name" != . && "$name" != .. && "$name" != / ]] || fail 'output must name a new directory' -output="$parent/$name" -caller=$(git rev-parse --show-toplevel && printf '.') || fail 'must run inside a Git worktree' -caller=${caller%.}; caller=${caller%$'\n'} -caller=$(cd "$caller" && pwd -P && printf '.') || fail 'cannot resolve caller worktree' -caller=${caller%.}; caller=${caller%$'\n'} -# Retain one complete NUL census and its producer status before consuming it. -# Keep this private scratch file separate from the not-yet-authorized output. -census=$(mktemp) || fail 'cannot retain Git worktrees' -trap 'rm -f "$census"' EXIT -git worktree list --porcelain -z > "$census" || fail 'cannot list Git worktrees' -record='' entry='' head_seen=false selector_seen=false bare_seen=false caller_seen=false -trees=() -while IFS= read -r -d '' record; do - case "$record" in - 'worktree '*) - [ -z "$entry" ] || fail 'worktree census has overlapping entries' - entry=${record#worktree } - [[ $entry == /* ]] || fail 'worktree census has an invalid path' - for known in ${trees[@]+"${trees[@]}"}; do [ "$known" != "$entry" ] || fail 'worktree census repeats a path'; done - trees+=("$entry") - head_seen=false; selector_seen=false; bare_seen=false - if tree=$(cd "$entry" 2>/dev/null && pwd -P && printf '.'); then - tree=${tree%.}; tree=${tree%$'\n'} - else tree=$entry; fi - [ "$tree" != "$caller" ] || caller_seen=true - case "$output/" in "$tree"/*) fail 'output must be outside every Git worktree' ;; esac ;; - 'HEAD '*) - [[ -n $entry && $head_seen == false && $bare_seen == false && ${record#HEAD } =~ ^[0-9a-f]{40}$ ]] || fail 'invalid worktree HEAD observation' - head_seen=true ;; - 'branch '*|detached) - [[ -n $entry && $head_seen == true && $selector_seen == false && $bare_seen == false ]] || fail 'invalid worktree selector observation' - if [[ $record == 'branch '* ]]; then [[ ${record#branch } == refs/heads/?* ]] || fail 'invalid worktree branch'; fi - selector_seen=true ;; - bare) - [[ -n $entry && $head_seen == false && $selector_seen == false && $bare_seen == false ]] || fail 'invalid bare worktree observation' - bare_seen=true ;; - locked|'locked '*|prunable|'prunable '*) - [[ -n $entry ]] || fail 'worktree metadata has no entry' ;; - '') - [[ -n $entry && ( $bare_seen == true || ( $head_seen == true && $selector_seen == true ) ) ]] || fail 'incomplete worktree entry' - entry='' ;; - *) fail 'unsupported worktree census record' ;; - esac -done < "$census" -[[ -z $record ]] || fail 'unterminated record in Git worktree census' -[[ -z $entry && $caller_seen == true ]] || fail 'worktree census is incomplete or omits caller' -rm -f "$census" -trap - EXIT -if [ -e "$output" ] || [ -L "$output" ]; then fail 'output already exists'; fi -temp=$(mktemp -d /tmp/.marketplace-release.XXXXXX) -# Independent scratch may be deleted; an entered output is retained on failure -# for explicit recovery. Never recursively clean a mutable public pathname. -cleanup() { - rm -rf "$temp" -} -trap cleanup EXIT -mkdir "$temp/data" "$temp/candidate" -# Read one unambiguous regular tracked manifest at the explicitly selected commit. -read_manifest() { - local commit=$1 path=$2 destination=$3 mode - mode=$(git ls-tree --full-tree "$commit" -- "$path") - [[ "$mode" == '100644 blob '* || "$mode" == '100755 blob '* ]] || fail "manifest is not a regular tracked file: $path" - git cat-file blob "$commit:$path" > "$destination" - json_object_unique "$destination" || fail "ambiguous marketplace manifest: $path" - jq -es -L "$here" 'include "marketplace-release"; length==1 and (.[0] | valid_marketplace)' "$destination" >/dev/null || fail "invalid marketplace manifest: $path" -} -# Require both marketplace adapter manifests at a commit to validate and agree. -read_pair() { - local commit=$1 prefix=$2 - read_manifest "$commit" .github/plugin/marketplace.json "$temp/data/$prefix-copilot.json" - read_manifest "$commit" .claude-plugin/marketplace.json "$temp/data/$prefix-claude.json" - jq -n -e --slurpfile a "$temp/data/$prefix-copilot.json" --slurpfile b "$temp/data/$prefix-claude.json" '$a==$b' >/dev/null || fail 'marketplace manifests differ' -} -read_pair "$head" head -current=$(jq -r '.metadata.version' "$temp/data/head-copilot.json") -# One tag per line whatever column.tag says; the readers below expect exactly that. -git tag --list --no-column --format='%(refname:strip=2)' > "$temp/data/tags" -jq -Rn -L "$here" 'include "marketplace-release"; [inputs | select(startswith("v")) | select(.[1:] | stable_syntax)]' < "$temp/data/tags" > "$temp/data/stable-tags.json" -jq -e -L "$here" 'include "marketplace-release"; all(.[]; .[1:] | stable_version)' "$temp/data/stable-tags.json" >/dev/null || fail 'a stable tag exceeds the supported version range' -base= -if [ "$base_tag" = initial ]; then - jq -e 'length==0' "$temp/data/stable-tags.json" >/dev/null || fail 'initial release requires no local stable marketplace tags' - git rev-list --first-parent --reverse "$head" > "$temp/data/commits" -else - base=$(git rev-parse --verify "refs/tags/$base_tag^{commit}") || fail 'base tag is missing' - git rev-list --first-parent "$head" > "$temp/data/parents" - grep -Fxq "$base" "$temp/data/parents" || fail 'base must be a first-parent ancestor of source' - git tag --merged "$head" --no-column --format='%(refname:strip=2)' > "$temp/data/merged-tags" - latest=$(jq -Rnr -L "$here" 'include "marketplace-release"; [inputs | select(startswith("v")) | select(.[1:] | stable_version)] | sort_by(.[1:] | split(".") | map(tonumber)) | last // ""' < "$temp/data/merged-tags") - [ "$latest" = "$base_tag" ] || fail 'base is not the latest reachable stable marketplace tag' - read_pair "$base" base - [ "$(jq -r '.metadata.version' "$temp/data/base-copilot.json")" = "${base_tag#v}" ] || fail 'tag does not match baseline manifest version' - [ "$current" = "${base_tag#v}" ] || fail 'source manifest version differs from baseline' - git rev-list --first-parent --reverse "$base..$head" > "$temp/data/commits" -fi -: > "$temp/data/messages.jsonl" -while IFS= read -r sha; do - git show -s --no-show-signature --encoding=UTF-8 --format=%B "$sha" > "$temp/data/message" - jq -n --arg sha "$sha" --rawfile message "$temp/data/message" '{sha:$sha,message:$message}' >> "$temp/data/messages.jsonl" -done < "$temp/data/commits" -jq -e -L "$here" --arg source "$head" --arg base "$base" --arg baseTag "$base_tag" --arg current "$current" --slurpfile commits "$temp/data/messages.jsonl" \ - 'include "marketplace-release"; prepare($source;$base;$baseTag;$current;$commits)' "$temp/data/head-copilot.json" > "$temp/candidate/release.json" -version=$(jq -r '.version // empty' "$temp/candidate/release.json") -if [ -n "$version" ]; then - if git show-ref --verify --quiet "refs/tags/v$version"; then fail 'candidate tag already exists'; fi - mkdir -p "$temp/candidate/.github/plugin" "$temp/candidate/.claude-plugin" - jq --arg version "$version" '.metadata.version=$version' "$temp/data/head-copilot.json" > "$temp/candidate/.github/plugin/marketplace.json" - cp "$temp/candidate/.github/plugin/marketplace.json" "$temp/candidate/.claude-plugin/marketplace.json" -fi -jq -r -L "$here" 'include "marketplace-release"; release_notes' "$temp/candidate/release.json" > "$temp/candidate/RELEASE_NOTES.md" -# Reserve the destination exclusively only after every source check and rendering step passed. -( - cd "$parent" || fail 'cannot enter output parent; recovery retained' - [[ $(directory_identity .) == "$parent_identity" && $(directory_identity "$parent") == "$parent_identity" ]] || - fail 'output parent moved before reservation; recovery retained' - # Relative operands remain in the entered parent even if its public name moves. - mkdir "./$name" || fail 'output was concurrently created' - reserved=$(directory_identity "./$name") || fail 'cannot identify reserved output; recovery retained' - [[ $reserved =~ ^[0-9]+:[0-9]+$ ]] || fail 'invalid reserved output identity; recovery retained' - cd "./$name" || fail 'cannot enter reserved output; recovery retained' - [[ $(directory_identity .) == "$reserved" && $(directory_identity "$output") == "$reserved" ]] || - fail 'reserved output moved before copy; recovery retained' - # A replacement inserted before the first identity observation is not evidence - # of an empty reservation. Retain a complete successful inventory before writing. - find . -mindepth 1 -maxdepth 1 -print0 > "$temp/reservation-inventory" || - fail 'cannot inventory reserved output; recovery retained' - [[ ! -s $temp/reservation-inventory ]] || fail 'reserved output contains unexpected data; recovery retained' - cp -R "$temp/candidate/." . || fail 'copy failed; reserved output retained for recovery' - # All readback stays relative to the entered directory even if its name moved. - diff -r "$temp/candidate" . >/dev/null || fail 'candidate readback differs; recovery retained' - status=$(jq -r .status ./release.json) || fail 'candidate status readback failed; recovery retained' - [[ $status == CANDIDATE || $status == NO_RELEASE ]] || fail 'candidate status is invalid; recovery retained' - [[ $(directory_identity "$parent") == "$parent_identity" && $(directory_identity "$output") == "$reserved" ]] || - fail 'reserved output or parent moved during copy; recovery retained' - printf 'Prepared %s at %s\n' "$status" "$output" -) diff --git a/scripts/prepare-marketplace-release.test.sh b/scripts/prepare-marketplace-release.test.sh deleted file mode 100644 index d926dc6d..00000000 --- a/scripts/prepare-marketplace-release.test.sh +++ /dev/null @@ -1,314 +0,0 @@ -#!/usr/bin/env bash -# Real Git histories catch incorrect version selection, baseline drift, and accidental writes. -set -euo pipefail -root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) -tool="$root/scripts/prepare-marketplace-release.sh" -release_test_path=$PATH -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT -export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false -passed=0 -# Stop the suite when an observable preparation contract fails. -fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } -# Initialize an independent real Git history with matching marketplace manifests. -new_repo() { - repo=$(mktemp -d "$work/repo.XXXXXX") - git -C "$repo" init -q - git -C "$repo" config user.name Test - git -C "$repo" config user.email test@example.invalid - mkdir -p "$repo/.github/plugin" "$repo/.claude-plugin" - printf '%s\n' '{"name":"test-marketplace","metadata":{"version":"1.2.3","description":"Kept"},"plugins":[{"name":"example","version":"4.5.6","source":"./plugins/example","description":"Kept"}],"extra":{"keep":true}}' > "$repo/.github/plugin/marketplace.json" - cp "$repo/.github/plugin/marketplace.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json - git -C "$repo" commit -qm 'Initial legacy import' -} -# Append the selected Conventional Commit to the independent fixture history. -commit() { git -C "$repo" commit --allow-empty -qm "$1"; } -# Invoke production preparation from the fixture's actual Git context. -run() { (cd "$repo" && bash "$tool" --base-tag "$1" --output "$2"); } -# Require the prepared artifact to carry the expected marketplace version. -expect_version() { - local name=$1 want=$2 base=${3:-v1.2.3} out - out=$(mktemp -u "$work/out.XXXXXX") - run "$base" "$out" > "$work/stdout" 2> "$work/stderr" || { cat "$work/stderr"; fail "$name did not prepare"; } - jq -e --arg want "$want" '.status=="CANDIDATE" and .version==$want and .tag==("v"+$want) and .publication=="NOT_AUTHORIZED"' "$out/release.json" >/dev/null || fail "$name version" - for manifest in .github/plugin/marketplace.json .claude-plugin/marketplace.json; do - jq -e --arg want "$want" '.metadata.version==$want and .metadata.description=="Kept" and .extra.keep and .plugins[0].version=="4.5.6"' "$out/$manifest" >/dev/null || fail "$name preserved plugin" - done - cmp "$out/.github/plugin/marketplace.json" "$out/.claude-plugin/marketplace.json" - test "$(git -C "$repo" status --porcelain | wc -l | tr -d ' ')" = 0 || fail "$name changed checkout" - passed=$((passed + 1)) -} -# Require malformed input to fail without creating a candidate output. -reject() { - local name=$1 base=${2:-v1.2.3} out - out=$(mktemp -u "$work/rejected.XXXXXX") - if run "$base" "$out" > "$work/stdout" 2> "$work/stderr"; then fail "$name accepted"; fi - test ! -e "$out" || fail "$name left partial candidate" - test ! -s "$work/stdout" || fail "$name emitted success output" - passed=$((passed + 1)) -} -new_repo -expect_version 'explicit first release' 1.2.3 initial -git -C "$repo" tag v1.2.3 -for pair in 'fix: repair|1.2.4' 'feat(api): add|1.3.0' 'perf: speed|1.2.4' 'refactor!: remove|2.0.0' 'FEAT(API): add|1.3.0'; do - new_repo; git -C "$repo" tag v1.2.3 - commit "${pair%|*}"; expect_version "${pair%|*}" "${pair#*|}" -done -for footer in 'BREAKING CHANGE: remove old option' 'BREAKING-CHANGE: remove old option'; do - new_repo; git -C "$repo" tag v1.2.3 - commit "$(printf 'chore: adjust\n\n%s' "$footer")"; expect_version "$footer" 2.0.0 -done -# A signature is not part of the message, so log.showSignature must not change what is classified. -# The commit carries a gpgsig header and a stub verifier prints the line git would prepend. -new_repo; git -C "$repo" tag v1.2.3 -printf '#!/usr/bin/env bash\necho "Good signature from stub" >&2\n' > "$work/stub-gpg"; chmod +x "$work/stub-gpg" -signed=$(printf 'tree %s\nparent %s\nauthor Test 1700000000 +0000\ncommitter Test 1700000000 +0000\ngpgsig -----BEGIN PGP SIGNATURE-----\n \n stub\n -----END PGP SIGNATURE-----\n\nfix: signed\n' \ - "$(git -C "$repo" rev-parse 'HEAD^{tree}')" "$(git -C "$repo" rev-parse HEAD)" | git -C "$repo" hash-object -t commit -w --stdin) -git -C "$repo" update-ref HEAD "$signed" -git -C "$repo" config log.showSignature true; git -C "$repo" config gpg.program "$work/stub-gpg" -out="$work/signed"; run v1.2.3 "$out" > "$work/stdout" 2> "$work/stderr" || { cat "$work/stderr"; fail 'signed commit did not prepare'; } -jq -e '.version=="1.2.4" and .commits[0].subject=="fix: signed"' "$out/release.json" >/dev/null || fail 'signature output was read as the commit message' -passed=$((passed + 1)) -# column.tag must not put several tags on one line, where no line reads as a stable tag. -new_repo; git -C "$repo" tag v1.2.1; git -C "$repo" tag v1.2.2; git -C "$repo" config column.tag always -reject 'column-formatted tags still block an initial release' initial -git -C "$repo" tag v1.2.3; commit 'fix: repair'; expect_version 'column-formatted tags still find the baseline' 1.2.4 -# Messages are read as UTF-8 whatever output encoding the maintainer configured. -new_repo; git -C "$repo" tag v1.2.3 -git -C "$repo" -c i18n.commitEncoding=ISO-8859-1 commit --allow-empty -qm "$(printf 'fix: caf\351')" -git -C "$repo" config i18n.logOutputEncoding ISO-8859-1 -out="$work/latin1"; run v1.2.3 "$out" > "$work/stdout" 2> "$work/stderr" || { cat "$work/stderr"; fail 'Latin-1 commit did not prepare'; } -jq -e '.version=="1.2.4" and .commits[0].subject=="fix: cafΓ©"' "$out/release.json" >/dev/null || fail 'commit message was not read as UTF-8' -passed=$((passed + 1)) -new_repo; git -C "$repo" tag -a v1.2.3 -m baseline -commit 'fix: repair'; commit 'feat: add'; expect_version 'largest bump and annotated tag' 1.3.0 -new_repo; git -C "$repo" tag v1.2.3; commit 'docs: explain' -out="$work/no-release"; run v1.2.3 "$out" >/dev/null -jq -e '.status=="NO_RELEASE" and .version==null and .tag==null' "$out/release.json" >/dev/null -test ! -e "$out/.github/plugin/marketplace.json" || fail 'no-release wrote update' -passed=$((passed + 1)) -new_repo; git -C "$repo" tag v1.2.3; reject 'initial would reset published history' initial -commit 'Make it better'; reject 'ambiguous commit' -new_repo; git -C "$repo" tag v1.2.3; commit 'revert: undo feature'; reject 'revert requires assessment' -new_repo; git -C "$repo" tag v1.2.3 -# Verbatim keeps the trailing spaces that git's default cleanup would strip. -git -C "$repo" commit --allow-empty --cleanup=verbatim -qm 'fix: '; reject 'blank change description' -new_repo; git -C "$repo" tag v1000000000.0.0; reject 'unsupported stable tag cannot disappear' initial -new_repo; git -C "$repo" tag v1.2.3; commit 'fix: change'; git -C "$repo" tag v1.2.4; reject 'stale baseline' -new_repo; git -C "$repo" tag v1.2.3; reject 'missing tag' v9.9.9 -reject 'option-like tag' --help -for mutation in '.metadata.version="01.2.3"' '.metadata.version="1.2.3-rc.1"' '.metadata.version=4' 'del(.metadata.version)' '.plugins=[]' '.plugins += [.plugins[0]]'; do - new_repo - jq "$mutation" "$repo/.github/plugin/marketplace.json" > "$work/bad.json" - cp "$work/bad.json" "$repo/.github/plugin/marketplace.json"; cp "$work/bad.json" "$repo/.claude-plugin/marketplace.json" - git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json; commit 'fix: malformed' - reject "bad manifest $mutation" initial -done -new_repo; git -C "$repo" tag v1.2.3 -jq '.metadata.version="1.2.4"' "$repo/.github/plugin/marketplace.json" > "$work/changed.json" -cp "$work/changed.json" "$repo/.github/plugin/marketplace.json" -git -C "$repo" add .github/plugin/marketplace.json; commit 'fix: one manifest changed'; reject 'manifest drift' -cp "$work/changed.json" "$repo/.claude-plugin/marketplace.json" -git -C "$repo" add .claude-plugin/marketplace.json; commit 'fix: both changed'; reject 'source version diverged from tag' -new_repo; git -C "$repo" tag v1.2.3; commit 'fix: keep selected source' -head=$(git -C "$repo" rev-parse HEAD) -printf 'dirty input ignored\n' > "$repo/.github/plugin/marketplace.json" -out="$work/immutable"; run v1.2.3 "$out" >/dev/null -jq -e --arg head "$head" '.sourceCommit==$head and .version=="1.2.4"' "$out/release.json" >/dev/null -grep -q 'dirty input ignored' "$repo/.github/plugin/marketplace.json" -passed=$((passed + 1)) -out2="$work/repeated"; run v1.2.3 "$out2" >/dev/null; diff -r "$out" "$out2" >/dev/null -passed=$((passed + 1)) -if run v1.2.3 "$out" > "$work/stdout" 2> "$work/stderr"; then fail 'existing output replaced'; fi -diff -r "$out" "$out2" >/dev/null; passed=$((passed + 1)) - -# Full history and an explicit source commit prevent accidental comparison to another branch. -new_repo; git -C "$repo" tag v1.2.3; commit 'fix: first' -selected=$(git -C "$repo" rev-parse HEAD); commit 'feat: later' -out="$work/selected-head" -(cd "$repo" && bash "$tool" --base-tag v1.2.3 --head "$selected" --output "$out") >/dev/null -jq -e --arg head "$selected" '.sourceCommit==$head and .version=="1.2.4" and (.commits|length)==1' "$out/release.json" >/dev/null -passed=$((passed + 1)) -if (cd "$repo" && bash "$tool" --base-tag v1.2.3 --head main --output "$work/non-sha") > "$work/stdout" 2> "$work/stderr"; then fail 'non-immutable head accepted'; fi -test ! -e "$work/non-sha"; passed=$((passed + 1)) -shallow="$work/shallow" -git clone -q --depth 1 "file://$repo" "$shallow" -repo=$shallow; reject 'shallow history' initial -# A filtered clone would lazily fetch missing objects, so the offline preparation must refuse it. -new_repo; git -C "$repo" config uploadpack.allowFilter true -partial="$work/partial" -git clone -q --filter=blob:none --no-checkout "file://$repo" "$partial" -repo=$partial; reject 'partial clone' initial -# The candidate must never land in the checkout it describes, relative or absolute. -new_repo -for inside in candidate "$repo/.github/candidate"; do - if run initial "$inside" > "$work/stdout" 2> "$work/stderr"; then fail "output inside worktree accepted: $inside"; fi - test "$(git -C "$repo" status --porcelain --ignored | wc -l | tr -d ' ')" = 0 || fail "output inside worktree changed checkout: $inside" - test ! -s "$work/stdout" || fail "output inside worktree emitted success output: $inside" - passed=$((passed + 1)) -done -# A linked worktree is a checkout of the same repository too. -git -C "$repo" worktree add -q --detach "$work/linked" -if run initial "$work/linked/candidate" > "$work/stdout" 2> "$work/stderr"; then fail "output inside a linked worktree accepted"; fi -test ! -e "$work/linked/candidate" || fail "output inside a linked worktree was written" -test ! -s "$work/stdout" || fail "output inside a linked worktree emitted success output" -passed=$((passed + 1)) -new_repo; first=$(git -C "$repo" rev-parse HEAD) -commit 'feat: branch-only'; git -C "$repo" tag v1.2.3 -git -C "$repo" checkout -q --detach "$first"; commit 'fix: independent' -reject 'non-ancestor baseline' -new_repo; git -C "$repo" tag v1.2.3 -commit 'fix: future'; git -C "$repo" tag v1.2.4 -git -C "$repo" checkout -q --detach v1.2.3; commit 'fix: alternative' -reject 'candidate tag already exists on another branch' -new_repo; git -C "$repo" tag v1.2.2; commit 'fix: wrong tagged metadata'; reject 'tag disagrees with baseline metadata' v1.2.2 -new_repo; git -C "$repo" tag v1.2.3 -out="$work/empty-range"; run v1.2.3 "$out" >/dev/null -jq -e '.status=="NO_RELEASE" and (.commits|length)==0' "$out/release.json" >/dev/null -passed=$((passed + 1)) -new_repo -jq '.metadata.version="1.2.999999999"' "$repo/.github/plugin/marketplace.json" > "$work/overflow.json" -cp "$work/overflow.json" "$repo/.github/plugin/marketplace.json"; cp "$work/overflow.json" "$repo/.claude-plugin/marketplace.json" -git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json; commit 'chore: baseline'; git -C "$repo" tag v1.2.999999999 -commit 'fix: overflow'; reject 'version overflow' v1.2.999999999 -new_repo -cat "$repo/.github/plugin/marketplace.json" "$repo/.github/plugin/marketplace.json" > "$work/multiple.json" -cp "$work/multiple.json" "$repo/.github/plugin/marketplace.json"; cp "$work/multiple.json" "$repo/.claude-plugin/marketplace.json" -git -C "$repo" add .github/plugin/marketplace.json .claude-plugin/marketplace.json; commit 'fix: duplicate documents' -reject 'multiple JSON documents' initial -new_repo -rm "$repo/.claude-plugin/marketplace.json"; ln -s ../.github/plugin/marketplace.json "$repo/.claude-plugin/marketplace.json" -git -C "$repo" add .claude-plugin/marketplace.json; commit 'fix: symlink' -reject 'manifest symlink' initial -new_repo; git -C "$repo" tag v1.2.3 -commit 'fix: [spoof](https://example.invalid)