OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
feat(release): align Action publication with CLI releases (#1418)
mldangelo-oaieaed287d653b
diff --git a/.github/actions/check-action-candidate/action.yml b/.github/actions/check-action-candidate/action.ymlnew file mode 100644index 000000000..95b59bda3--- /dev/null+++ b/.github/actions/check-action-candidate/action.yml@@ -0,0 +1,27 @@+name: Check Action against release candidate+description: Exercise the Action adapter against the packed CLI without model calls.+runs:+ using: composite+ steps:+ - name: Set up Action Node.js runtime+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0+ with:+ node-version: "24"+ package-manager-cache: false+ - name: Set up the Ubuntu sandbox+ shell: bash+ run: |+ sudo apt-get update+ sudo apt-get install --yes bubblewrap apparmor-profiles+ sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict+ - name: Test Action compatibility with the packed CLI+ shell: bash+ run: |+ set -euo pipefail+ npm --prefix github-action ci --ignore-scripts --no-audit --no-fund+ consumer="$(mktemp -d)"+ trap 'rm -rf "$consumer"' EXIT+ printf '%s\n' '{"name":"action-candidate-check","private":true,"type":"module"}' > "$consumer/package.json"+ npm install --prefix "$consumer" --ignore-scripts --include=optional --no-audit --no-fund ./dist/*.tgz+ version="$(node -p 'require("./sdk/typescript/package.json").version')"+ npm --prefix github-action run test:cli -- "$consumer/node_modules/@openai/codex-security" "$version"diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.ymlindex f9c768108..edcf86f6f 100644--- a/.github/workflows/node-ci.yml+++ b/.github/workflows/node-ci.yml@@ -278,6 +278,10 @@ jobs:working-directory: sdk/typescriptrun: node scripts/check-package.mjs ../../dist/*.tgz+ - name: Check Action against the release candidate+ if: matrix.os == 'ubuntu-latest' && matrix.node == '24'+ uses: ./.github/actions/check-action-candidate+mcp:name: MCP app testsneeds: [validate-title, package]diff --git a/.github/workflows/node-github-release.yml b/.github/workflows/node-github-release.ymlindex d7c89121c..fe4d8edd3 100644--- a/.github/workflows/node-github-release.yml+++ b/.github/workflows/node-github-release.yml@@ -29,6 +29,11 @@ jobs:permissions:actions: readcontents: write+ outputs:+ version: ${{ steps.release.outputs.version }}+ sha: ${{ steps.release.outputs.sha }}+ integrity: ${{ steps.artifact.outputs.integrity }}+ has-action: ${{ steps.action.outputs.present }}steps:- name: Checkout release automation@@ -356,6 +361,16 @@ jobs:"$verified_run_id"printf 'archive=%s\n' "$archive" >> "$GITHUB_OUTPUT"+ printf 'integrity=%s\n' "$(jq -r '."dist.integrity" // .dist.integrity' <<< "$metadata")" >> "$GITHUB_OUTPUT"++ - name: Detect Action release source+ id: action+ env:+ RELEASE_SHA: ${{ steps.release.outputs.sha }}+ run: |+ if git cat-file -e "$RELEASE_SHA:action.yml" 2>/dev/null; then+ echo 'present=true' >> "$GITHUB_OUTPUT"+ fi- name: Resolve published release historyid: history@@ -443,3 +458,251 @@ jobs:process.exit(error.status);}' "$release_workspace"++ installed:+ name: verify published installation+ needs: release+ uses: ./.github/workflows/published-install-smoke.yml+ with:+ version: ${{ needs.release.outputs.version }}+ # Use current checks when recovering releases that predate exact-version smoke.+ ref: ${{ github.sha }}++ action-verify:+ name: verify matching Action+ needs: [release, installed]+ if: needs.release.outputs.has-action == 'true'+ runs-on: ubuntu-24.04+ timeout-minutes: 30+ permissions:+ contents: read+ outputs:+ runtime-lock-artifact: ${{ steps.runtime-lock.outputs.artifact-id }}+ env:+ RELEASE_VERSION: ${{ needs.release.outputs.version }}+ RELEASE_SHA: ${{ needs.release.outputs.sha }}+ CLI_INTEGRITY: ${{ needs.release.outputs.integrity }}++ steps:+ - &action-checkout-automation+ name: Checkout release automation+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: ${{ github.sha }}+ path: automation+ persist-credentials: false++ - &action-checkout-source+ name: Checkout verified CLI source+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: ${{ needs.release.outputs.sha }}+ path: release-source+ fetch-depth: 0+ persist-credentials: false++ - &action-setup-node+ name: Set up Node.js+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0+ with:+ node-version: "24"+ package-manager-cache: false++ - name: Set up Socket Firewall+ uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2+ with:+ mode: firewall-free+ firewall-version: "1.15.0"++ - name: Set up the Ubuntu sandbox+ run: |+ sudo apt-get update+ sudo apt-get install --yes bubblewrap apparmor-profiles+ sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict++ - &action-reuse-distribution+ name: Reuse an existing immutable Action distribution+ id: distribution+ working-directory: release-source+ shell: bash+ run: |+ set -euo pipefail+ action_tag="action-v$RELEASE_VERSION"+ if git show-ref --verify --quiet "refs/tags/$action_tag"; then+ action_sha="$(git rev-parse "$action_tag^{commit}")"+ if [[ "$(git rev-parse "$action_sha^")" != "$RELEASE_SHA" ]]; then+ echo 'The existing Action tag must derive from the exact CLI source.' >&2+ exit 1+ fi+ changed_source="$(git diff --name-only "$RELEASE_SHA" "$action_sha" -- . \+ ':!github-action/package.json' ':!github-action/package-lock.json' \+ ':!github-action/runtime/package.json' ':!github-action/runtime/package-lock.json' \+ ':!github-action/dist/index.cjs' ':!github-action/dist/post.cjs')"+ if [[ -n "$changed_source" ]]; then+ echo 'The existing Action tag contains changes outside release packaging.' >&2+ exit 1+ fi+ git checkout --detach "$action_sha"+ node "$GITHUB_WORKSPACE/automation/github-action/scripts/release.mjs" verify \+ "$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \+ "$GITHUB_WORKSPACE/release-source/github-action"+ echo 'existing=true' >> "$GITHUB_OUTPUT"+ fi++ - name: Resolve the verified CLI runtime lock+ if: steps.distribution.outputs.existing != 'true'+ run: |+ node automation/github-action/scripts/release.mjs prepare \+ "$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \+ "$GITHUB_WORKSPACE/release-source/github-action"++ - name: Install Action and CLI dependencies+ working-directory: release-source/github-action+ run: |+ npm ci --ignore-scripts --no-audit --no-fund+ runtime_cache="$(mktemp -d "$RUNNER_TEMP/action-runtime-firewall-cache.XXXXXX")"+ trap 'rm -rf "$runtime_cache"' EXIT+ sfw npm ci --prefix runtime --ignore-scripts --include=optional --no-audit --no-fund \+ --registry=https://registry.npmjs.org/ --cache="$runtime_cache"++ - name: Build Action distribution+ if: steps.distribution.outputs.existing != 'true'+ working-directory: release-source/github-action+ run: npm run build++ - name: Validate the packaged Action+ working-directory: release-source/github-action+ run: |+ npm run validate+ npm run test:cli+ node scripts/linux-smoke.mjs+ npm audit --audit-level=high+ npm audit --prefix runtime --omit=dev --audit-level=high+ npm run check-dist++ - name: Save verified CLI runtime lock+ id: runtime-lock+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: action-runtime-lock+ path: release-source/github-action/runtime/package-lock.json+ if-no-files-found: error+ retention-days: 7++ action:+ name: publish matching Action+ needs: [release, action-verify]+ if: needs.release.outputs.has-action == 'true'+ runs-on: ubuntu-24.04+ timeout-minutes: 15+ permissions:+ contents: write+ env:+ RELEASE_VERSION: ${{ needs.release.outputs.version }}+ RELEASE_SHA: ${{ needs.release.outputs.sha }}+ CLI_INTEGRITY: ${{ needs.release.outputs.integrity }}++ steps:+ - *action-checkout-automation+ - *action-checkout-source+ - *action-setup-node+ - *action-reuse-distribution++ - name: Download verified CLI runtime lock+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ artifact-ids: ${{ needs.action-verify.outputs.runtime-lock-artifact }}+ path: ${{ runner.temp }}/action-runtime-lock+ merge-multiple: true++ - name: Stage verified CLI runtime lock+ run: |+ node automation/github-action/scripts/release.mjs stage \+ "$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \+ "$RUNNER_TEMP/action-runtime-lock/package-lock.json" \+ "$GITHUB_WORKSPACE/release-source/github-action"++ # Rebuild from reviewed source in a fresh job; never run the CLI here.+ - name: Install Action build dependencies+ working-directory: release-source/github-action+ run: npm ci --ignore-scripts --no-audit --no-fund++ - name: Build Action distribution+ if: steps.distribution.outputs.existing != 'true'+ working-directory: release-source/github-action+ run: npm run build++ - name: Check Action distribution before publication+ working-directory: release-source/github-action+ run: npm run check-dist++ - name: Commit and verify release metadata+ working-directory: release-source+ env:+ EXISTING: ${{ steps.distribution.outputs.existing }}+ run: |+ set -euo pipefail+ if [[ "$EXISTING" != true ]]; then+ git add github-action/package.json github-action/package-lock.json \+ github-action/runtime/package.json github-action/runtime/package-lock.json \+ github-action/dist/index.cjs github-action/dist/post.cjs+ git -c user.name='github-actions[bot]' \+ -c user.email='41898282+github-actions[bot]@users.noreply.github.com' \+ -c commit.gpgsign=false commit --allow-empty -m "chore(release): package Action $RELEASE_VERSION"+ fi+ node "$GITHUB_WORKSPACE/automation/github-action/scripts/release.mjs" metadata \+ "$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" "$(git rev-parse HEAD)" \+ "$GITHUB_WORKSPACE/release-source/github-action"++ - name: Publish immutable Action tag and metadata+ working-directory: release-source+ env:+ GH_TOKEN: ${{ github.token }}+ EXISTING: ${{ steps.distribution.outputs.existing }}+ run: |+ set -euo pipefail+ if [[ "$EXISTING" != true ]]; then+ git -c credential.helper= -c 'credential.helper=!gh auth git-credential' \+ push origin "HEAD:refs/tags/action-v$RELEASE_VERSION"+ fi+ cp github-action/build/release-manifest.json "$RUNNER_TEMP/action-release-manifest.json"+ cp github-action/build/sbom.cdx.json "$RUNNER_TEMP/action-sbom.cdx.json"+ existing_assets="$(gh release view "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name')"+ comparison="$(mktemp -d)"+ trap 'rm -rf "$comparison"' EXIT+ for asset in action-release-manifest.json action-sbom.cdx.json; do+ if grep -Fxq "$asset" <<< "$existing_assets"; then+ gh release download "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" \+ --pattern "$asset" --dir "$comparison"+ if ! cmp "$RUNNER_TEMP/$asset" "$comparison/$asset"; then+ echo "Published Action metadata differs: $asset" >&2+ exit 1+ fi+ else+ gh release upload "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" "$RUNNER_TEMP/$asset"+ fi+ done+ {+ printf '### Codex Security %s\n\n' "$RELEASE_VERSION"+ printf 'CLI source: `%s`\n\n' "$RELEASE_SHA"+ printf 'Action: `uses: %s@%s` (`action-v%s`)\n' "$GITHUB_REPOSITORY" "$(git rev-parse HEAD)" "$RELEASE_VERSION"+ } >> "$GITHUB_STEP_SUMMARY"++ complete:+ name: release status+ if: always()+ needs: [release, installed, action]+ runs-on: ubuntu-latest+ steps:+ - name: Require completed release channels+ env:+ RELEASE_RESULT: ${{ needs.release.result }}+ INSTALL_RESULT: ${{ needs.installed.result }}+ ACTION_RESULT: ${{ needs.action.result }}+ HAS_ACTION: ${{ needs.release.outputs.has-action }}+ run: |+ test "$RELEASE_RESULT" = success+ test "$INSTALL_RESULT" = success+ if [[ "$HAS_ACTION" == true ]]; then+ test "$ACTION_RESULT" = success+ fidiff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.ymlindex 0f20fc8f3..015b56ec7 100644--- a/.github/workflows/node-release.yml+++ b/.github/workflows/node-release.yml@@ -234,6 +234,9 @@ jobs:"$consumer/node_modules/.bin/cs" --version"$consumer/node_modules/.bin/cs" --help+ - name: Check Action against the release candidate+ uses: ./.github/actions/check-action-candidate+- name: Upload verified packageid: uploaduses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1diff --git a/.github/workflows/published-install-smoke.yml b/.github/workflows/published-install-smoke.ymlindex 37f2ed0ad..7ca54fa32 100644--- a/.github/workflows/published-install-smoke.yml+++ b/.github/workflows/published-install-smoke.yml@@ -11,17 +11,36 @@ on:schedule:- cron: "43 9 * * *"workflow_dispatch:+ inputs:+ version:+ description: Published npm version to verify, or latest+ type: string+ default: latest+ ref:+ description: Source commit or tag containing the smoke checks+ type: string+ required: false+ workflow_call:+ inputs:+ version:+ description: Published npm version to verify, or latest+ type: string+ default: latest+ ref:+ description: Source commit or tag containing the smoke checks+ type: string+ required: falsepermissions:contents: readconcurrency:- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}+ group: published-install-smoke-${{ inputs.version || 'latest' }}-${{ github.event.pull_request.number || inputs.ref || github.ref }}cancel-in-progress: ${{ github.event_name == 'pull_request' }}jobs:install:- name: published latest / ${{ matrix.os }} / node-${{ matrix.node }}+ name: published ${{ inputs.version || 'latest' }} / ${{ matrix.os }} / node-${{ matrix.node }}runs-on: ${{ matrix.os }}timeout-minutes: 15strategy:@@ -39,10 +58,14 @@ jobs:uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false+ ref: ${{ inputs.ref || github.sha }}- name: Set up Node.jsuses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0with:node-version: ${{ matrix.node }}package-manager-cache: false- name: Install and start the published package- run: node sdk/typescript/scripts/smoke-published-package.mjs+ shell: bash+ env:+ PUBLISHED_VERSION: ${{ inputs.version || 'latest' }}+ run: node sdk/typescript/scripts/smoke-published-package.mjs "$PUBLISHED_VERSION"diff --git a/.github/workflows/test-quality.yml b/.github/workflows/test-quality.ymlindex 9e92ca74a..3b2e12d46 100644--- a/.github/workflows/test-quality.yml+++ b/.github/workflows/test-quality.yml@@ -116,8 +116,17 @@ jobs:sdk/typescript/pnpm-lock.yamlplugins/codex-security/mcp-app/pnpm-lock.yaml- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ if: runner.os == 'Windows'with:bun-version: "1.4.2"+ - name: Set up Bun on Linux+ if: runner.os == 'Linux'+ shell: bash+ run: |+ # Includes the subprocess fix from https://github.com/oven-sh/bun/pull/44581+ # for the isolated-runner hang tracked in https://github.com/oven-sh/bun/issues/34069.+ npm install --prefix "$RUNNER_TEMP/bun" --ignore-scripts --no-audit --no-fund @oven/[email protected]+ echo "$RUNNER_TEMP/bun/node_modules/@oven/bun-linux-x64/bin" >> "$GITHUB_PATH"- name: Install dependenciesrun: |pnpm --dir sdk/typescript install --frozen-lockfilediff --git a/RELEASING.md b/RELEASING.mdindex a77f67b1e..608c6d6f2 100644--- a/RELEASING.md+++ b/RELEASING.md@@ -5,7 +5,9 @@ canonical changelog. Under the current process, each new release combines ashort, reviewed summary with a categorized list of merged pull requests.Historical releases may contain generated notes only. The release tag and npmpackage use the same stable version: `npm-vX.Y.Z` and-`@openai/[email protected]`.+`@openai/[email protected]`. Releases whose source includes the GitHub Action+also publish `action-vX.Y.Z`, which installs that exact CLI version. The Action's+manifest and SBOM accompany the npm archive on the same GitHub Release.## Pull request titles and categories@@ -107,6 +109,14 @@ review. New suggestions for human-owned notes still appear in a comment.Before merging the proposal, check CI and request a final Codex reviewif the last review targets an older head.+The proposal updates the SDK version and the Action version in+`github-action/package.json` and `github-action/package-lock.json` together.+The Action's runtime dependency and lockfile keep their previously published+CLI version until npm publishes the proposed version. Release packaging then+updates that pin and lockfile to the verified publication. This lets release+PRs run CI while the next npm version is still unavailable; `node-ci` also+tests the Action against the packed CLI candidate before publication.+If a run reports that GitHub has not exposed the updated PR head, manuallyrerun the updater with **dry_run** disabled after the PR catches up. Thisallows any deferred review request or note suggestions to be posted. Verify@@ -201,8 +211,11 @@ Generated PRs leave the disclosure attestations unchecked for maintainer review.## Prepare a release-1. Choose the next stable version and update `sdk/typescript/package.json`.- Keep the lockfile version in sync when it records the package version.+1. Choose the next stable version and update `sdk/typescript/package.json`,+ `github-action/package.json`, and both root version fields in+ `github-action/package-lock.json`. The rolling release PR normally prepares+ these changes. Keep the Action runtime pin on the previously published CLI;+ release packaging updates it after npm publication.2. Update `.github/release-notes.md`. Its first line must be`<!-- release-version: X.Y.Z -->` with the exact package version.3. Summarize the changes a user will notice. Call out required migration or@@ -230,6 +243,31 @@ for that exact commit:3. `node-github-release` verifies the public package, provenance, tag, andarchive before publishing the GitHub release. It prepends the reviewedsummary to GitHub's categorized notes.+4. The same workflow runs `published-install-smoke` against the exact published+ version on Linux, macOS, and Windows. It uses the current release automation+ so the checks also work for historical backfills.+5. If the release source contains `action.yml`, the workflow prepares the+ Action from that exact source commit, pins its runtime to the verified npm+ version and integrity, and fetches the locked runtime through Socket Firewall+ with an empty cache before executing it. The lock retains public npm URLs.+ It builds and tests the distribution in a job with read-only repository+ permissions. A fresh publisher checks out the same+ source, downloads only the tested runtime lock by artifact ID, and rebuilds+ and verifies the bundles without executing the CLI. It creates+ `action-vX.Y.Z` and uploads the Action release manifest and SBOM to the+ existing `npm-vX.Y.Z` GitHub Release. A final status job reports publication,+ installation smoke, and Action results.++The Action tag points to a generated distribution commit whose parent is the+CLI release commit. That additional commit contains the runnable Action bundle+and runtime lockfile. Its release manifest records both commits, both tags,+the aligned version, and the npm integrity. Metadata finalization verifies the+bundle hashes against the files being published. Consumers can pin the Action's+distribution commit from that manifest.++Historical releases whose source predates `action.yml` skip Action publication+and still run the exact-version installation checks. The workflow does not add+Action code from a later commit to an older CLI release.After npm accepts a publication, its registry can take several minutes to exposethe version. GitHub publication waits up to ten minutes for that version to@@ -241,18 +279,30 @@ registry errors fail immediately.`sdk/typescript/_bundled_plugin/` directory is not a committed release input;do not prepare a release by editing or committing files there.-Monitor all three workflows. A version bump is not a completed release until-the npm package and GitHub release both exist and match the tag.+Monitor all three workflows and the final status in `node-github-release`.+A release is complete when npm and GitHub publication, exact-version install+checks, and applicable Action publication have succeeded. The protected npm+publication gates and immutable `npm-vX.Y.Z` tag remain in place.++Container publication currently has its own workflow and approval. It uses+`container-vX.Y.Z` or a manual `container-release` run on `main`, with the version+matching the SDK package. It is not part of the coordinated npm and Action+completion status. See [Container releases](docker/README.md) for its+publication and verification steps.## VerifyCheck the published state before announcing the release:-- The tag points to the merged release commit.+- `npm-vX.Y.Z` points to the merged release commit.- `npm view @openai/[email protected]` reports the expected version andcommit, and the provenance check passed in `node-release`.-- The GitHub release is stable, has the correct title, and contains exactly one- verified package archive.+- The GitHub release is stable, has the correct title, and contains one verified+ npm package archive plus the Action manifest and SBOM when applicable.+- The exact-version published installation checks succeeded.+- For releases with the Action, `action-vX.Y.Z` points to the distribution+ commit recorded in its manifest, whose parent is the CLI release commit.+ The manifest and runtime lock identify the same CLI version and npm integrity.- The newest version is marked Latest. A historical backfill is not.- For releases created under this process, the reviewed highlights, categoryheadings, documentation links, and full comparison link are correct.@@ -260,19 +310,22 @@ Check the published state before announcing the release:- Every merged pull request is included or has an intentional`skip-release-notes` label.-The `published-install-smoke` workflow checks npm's current `latest` daily,-on pull requests changing its smoke checks, and on manual dispatch. It installs-into a temporary consumer, checks the npm CLI shim and public SDK, starts the-bundled Codex executable with `--version`,+The `published-install-smoke` workflow checks each exact version during release+publication. It also checks npm's current `latest` daily and on pull requests+changing its smoke checks. Manual dispatch accepts a **version** (default+`latest`) and an optional **ref** for the source of the smoke checks. It installs+into a temporary consumer, verifies the requested version, checks the npm CLI+shim and public SDK, starts the bundled Codex executable with `--version`,and initializes the bundled MCP server. Linux covers supported Node majors22, 24, and 26; macOS and Windows cover Node 24. These checks use temporaryconfiguration directories and do not run scans or call model APIs.-The smoke test uses the installed version, so it can run while `main` contains-unreleased changes. A failure reports the installed version or failing startup-command in the Actions log; inspect that job before treating it as a release-regression. To reproduce locally, run-`node sdk/typescript/scripts/smoke-published-package.mjs` from the repository.+The smoke test verifies the installed package independently of the version on+`main`, so it can run while the checkout contains unreleased changes. A failure+reports the installed version or failing startup command in the Actions log;+inspect that job before treating it as a release regression. To reproduce+locally, run `node sdk/typescript/scripts/smoke-published-package.mjs X.Y.Z`+from the repository. Omit the version to check `latest`.## Recover or repair a release@@ -283,7 +336,16 @@ keeping the original tag and package identity.To retry GitHub publication, run `node-github-release` from `main` with theexisting `npm-vX.Y.Z` tag. Supply the successful `node-release` run ID whenautomatic lookup is not enough. The workflow verifies the npm artifact and-provenance again before it creates or updates the release.+provenance again before it creates or updates the release, repeats the+exact-version installation checks, and completes applicable Action publication.+If `action-vX.Y.Z` already exists, recovery checks its package manifests and+lockfiles against the reviewed source and CLI release identity before installing+dependencies or running package scripts. It then reuses that distribution commit.+Do not move that tag or regenerate the release from newer Action source.+A failure after npm publication can leave+the npm package or GitHub Release visible while later checks or Action+publication remain incomplete; use the final workflow status to identify the+remaining work.To repair categories on an existing release, correct the merged pull request'stitle or release label first, then rerun `node-github-release` for the tag. Fordiff --git a/github-action/README.md b/github-action/README.mdindex 93117d0e3..86f55bdec 100644--- a/github-action/README.md+++ b/github-action/README.md@@ -13,6 +13,8 @@ with access to the selected model. For Amazon Bedrock, see the separateAdd your API key as a repository secret named `CODEX_SECURITY_API_KEY`, thensave this workflow in `.github/workflows/codex-security.yml`.Replace `REPLACE_WITH_REVIEWED_COMMIT` with the full SHA of an Action commit.+The matching `action-vX.Y.Z` tag and distribution commit are listed in each+product release after the CLI and Action have both passed release checks.When using a fork, replace `openai` with the fork owner.This example requests Daybreak Blue. Use an API key from a project with Blue@@ -314,9 +316,29 @@ Validation checks types, tests, Action metadata, documentation, and bundlereproducibility. CI also tests the result adapter against the pinned CLI and itsSARIF exporter using synthetic scans, runs the packaged Linux smoke test, andaudits the Action and CLI dependency locks. The `@openai/codex-security` dependency in-`runtime/package.json` is the CLI version source. To upgrade, update that exact-pin and regenerate `runtime/package-lock.json`, rebuild the bundles, and run-validation. Verify report compatibility when adopting a new release.+`runtime/package.json` is the installed CLI version source. Main keeps the last+published CLI pin so its checks remain runnable while a release PR prepares the+next product version. To upgrade that development pin, update it and regenerate+`runtime/package-lock.json`, rebuild the bundles, and run validation.++Releases use the product version from `sdk/typescript/package.json`. Before npm+publication, the release workflow exercises the Action's compatibility suite+against the packed CLI candidate. After publication and provenance verification,+the Action release workflow starts from that exact CLI source commit, updates+the runtime pin and integrity lock, and fetches the locked runtime through+Socket Firewall with an empty cache before running the CLI. The lock keeps+public npm URLs for Action consumers. The workflow rebuilds the bundles and+runs the Action checks in a job with read-only repository permissions.+A fresh publisher takes only the tested runtime lock, rebuilds+from the same source, and verifies the bundle hashes without executing the CLI.+It creates a distribution commit and an immutable `action-vX.Y.Z` tag with the+same version as `npm-vX.Y.Z`.++The Action distribution commit differs from the CLI source commit because the+registry integrity lock is finalized after publication. Release metadata records+both commits, both tags, and the verified CLI integrity. A failed Action stage+can be rerun without republishing npm. Existing version tags are never moved.+See [the release process](../RELEASING.md) for the orchestration and recovery flow.<!-- prettier-ignore-start -->diff --git a/github-action/package.json b/github-action/package.jsonindex ffe0ad2c6..ccb7660e3 100644--- a/github-action/package.json+++ b/github-action/package.json@@ -9,7 +9,7 @@},"scripts": {"typecheck": "tsc --noEmit",- "test": "node --import tsx --test tests/*.test.ts",+ "test": "node --import tsx --test tests/*.test.*","test:cli": "node --import tsx scripts/cli-integration.ts","build": "node scripts/build.mjs","check-dist": "node scripts/build.mjs --check",diff --git a/github-action/scripts/cli-integration.ts b/github-action/scripts/cli-integration.tsindex 55f0b34c6..b877c18e8 100644--- a/github-action/scripts/cli-integration.ts+++ b/github-action/scripts/cli-integration.ts@@ -1,4 +1,4 @@-// Exercise the published, locked CLI and exporter without credentials or model calls.+// Exercise the locked CLI or an installed release candidate without model calls.import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';import { copyFile, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';@@ -9,9 +9,15 @@ import { analyzeResults } from '../src/results.js';import { captureRunnerPath, checkPython, resolveTool, runtimeEnvironment, writeRuntimeLauncher } from '../src/runtime.js';import runtimeManifest from '../runtime/package.json' with { type: 'json' };-const cliPackage = resolve(import.meta.dirname, '../runtime/node_modules/@openai/codex-security');+const [candidatePackage, candidateVersion] = process.argv.slice(2);+assert.equal(process.argv.length === 2 || process.argv.length === 4, true,+ 'Expected no arguments, or an installed CLI package directory and version');+const cliPackage = candidatePackage === undefined+ ? resolve(import.meta.dirname, '../runtime/node_modules/@openai/codex-security')+ : resolve(candidatePackage);const installed = JSON.parse(await readFile(join(cliPackage, 'package.json'), 'utf8'));-assert.equal(installed.version, runtimeManifest.dependencies['@openai/codex-security']);+assert.equal(installed.name, '@openai/codex-security');+assert.equal(installed.version, candidateVersion ?? runtimeManifest.dependencies['@openai/codex-security']);const cli = join(cliPackage, 'bin/codex-security.mjs');const root = await mkdtemp(join(await realpath(tmpdir()), 'codex-action-cli-test-'));try {@@ -230,7 +236,7 @@ try {assert.equal(result.policyStatus, 'not-evaluated');assert.equal(result.sarifUploadReady, false);assert.ok(result.errors.some(error => error.includes(cliError.message)));- console.log(`Pinned CLI ${installed.version}: real JSON results, severity exits, SARIF export, Deep Scan, literal-path and virtualenv preflights, sandbox readiness and filesystem enforcement, MCP runner tracking, and failures passed without model calls.`);+ console.log(`${candidatePackage === undefined ? 'Pinned' : 'Candidate'} CLI ${installed.version}: real JSON results, severity exits, SARIF export, Deep Scan, literal-path and virtualenv preflights, sandbox readiness and filesystem enforcement, MCP runner tracking, and failures passed without model calls.`);} finally {await rm(root, { recursive: true, force: true });}diff --git a/github-action/scripts/release.mjs b/github-action/scripts/release.mjsnew file mode 100644index 000000000..bcc6f2724--- /dev/null+++ b/github-action/scripts/release.mjs@@ -0,0 +1,123 @@+import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import { createHash } from 'node:crypto';+import { copyFile, readFile, writeFile } from 'node:fs/promises';+import { resolve } from 'node:path';+import { pathToFileURL } from 'node:url';++const packageName = '@openai/codex-security';+const readJson = async path => JSON.parse(await readFile(path, 'utf8'));+const writeJson = (path, value) => writeFile(path, JSON.stringify(value, null, 2) + '\n');+const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');++function releaseIdentity(version, sourceCommit, cliIntegrity, actionCommit) {+ assert.match(version, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/, 'Action releases require a stable CLI version');+ assert.match(sourceCommit, /^[a-f0-9]{40}$/, 'Action releases require the npm source commit');+ assert.match(cliIntegrity, /^sha512-\S+$/, 'Action releases require verified npm integrity');+ if (actionCommit !== undefined) assert.match(actionCommit, /^[a-f0-9]{40}$/, 'Action releases require their distribution commit');+ return { sourceCommit, ...(actionCommit === undefined ? {} : { actionCommit }), npmTag: `npm-v${version}`, actionTag: `action-v${version}`, cliIntegrity };+}++export async function updateReleaseManifests(actionRoot, version) {+ const cli = await readJson(resolve(actionRoot, '../sdk/typescript/package.json'));+ assert.equal(cli.name, packageName);+ assert.equal(cli.version, version, 'Action release must use the version of its CLI source');+ const manifestPath = resolve(actionRoot, 'package.json');+ const lockPath = resolve(actionRoot, 'package-lock.json');+ const runtimePath = resolve(actionRoot, 'runtime/package.json');+ const manifest = await readJson(manifestPath);+ const lock = await readJson(lockPath);+ const runtime = await readJson(runtimePath);+ manifest.version = version;+ lock.version = version;+ lock.packages[''].version = version;+ runtime.dependencies[packageName] = version;+ await writeJson(manifestPath, manifest);+ await writeJson(lockPath, lock);+ await writeJson(runtimePath, runtime);+}++export async function validateRelease(actionRoot, version, cliIntegrity) {+ const cli = await readJson(resolve(actionRoot, '../sdk/typescript/package.json'));+ const manifest = await readJson(resolve(actionRoot, 'package.json'));+ const lockBytes = await readFile(resolve(actionRoot, 'package-lock.json'));+ const lock = JSON.parse(lockBytes);+ const runtime = await readJson(resolve(actionRoot, 'runtime/package.json'));+ const runtimeLockBytes = await readFile(resolve(actionRoot, 'runtime/package-lock.json'));+ const runtimeLock = JSON.parse(runtimeLockBytes);+ assert.equal(cli.name, packageName);+ for (const actual of [cli.version, manifest.version, lock.version, lock.packages[''].version, runtime.dependencies[packageName], runtimeLock.packages[''].dependencies[packageName], runtimeLock.packages[`node_modules/${packageName}`].version]) {+ assert.equal(actual, version, 'Action and CLI release versions must agree');+ }+ assert.equal(runtimeLock.packages[`node_modules/${packageName}`].integrity, cliIntegrity, 'Action must install the verified npm release');+ return { actionLockSha256: sha256(lockBytes), runtimeLockSha256: sha256(runtimeLockBytes) };+}++export async function validateReleaseSource(actionRoot, sourceCommit) {+ for (const file of ['package.json', 'package-lock.json', 'runtime/package.json']) {+ const source = JSON.parse(execFileSync('git', ['show', `${sourceCommit}:github-action/${file}`], {+ cwd: actionRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],+ }));+ const distribution = await readJson(resolve(actionRoot, file));+ for (const manifest of [source, distribution]) {+ if (file === 'runtime/package.json') delete manifest.dependencies[packageName];+ else {+ delete manifest.version;+ if (file === 'package-lock.json') delete manifest.packages[''].version;+ }+ }+ assert.deepEqual(distribution, source, `${file} must preserve the reviewed release source apart from its release version`);+ }+}++export async function prepareRelease(actionRoot, version, sourceCommit, cliIntegrity) {+ releaseIdentity(version, sourceCommit, cliIntegrity);+ await updateReleaseManifests(actionRoot, version);+ execFileSync('npm', ['install', '--package-lock-only', '--ignore-scripts', '--include=optional', '--no-audit', '--no-fund', '--registry=https://registry.npmjs.org/'], {+ cwd: resolve(actionRoot, 'runtime'), stdio: 'inherit',+ });+ await validateRelease(actionRoot, version, cliIntegrity);+}++export async function stageRelease(actionRoot, version, sourceCommit, cliIntegrity, runtimeLock) {+ releaseIdentity(version, sourceCommit, cliIntegrity);+ await updateReleaseManifests(actionRoot, version);+ await copyFile(runtimeLock, resolve(actionRoot, 'runtime/package-lock.json'));+ await validateRelease(actionRoot, version, cliIntegrity);+}++export async function writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit) {+ const identity = releaseIdentity(version, sourceCommit, cliIntegrity, actionCommit);+ await validateReleaseSource(actionRoot, sourceCommit);+ const hashes = await validateRelease(actionRoot, version, cliIntegrity);+ const manifestPath = resolve(actionRoot, 'build/release-manifest.json');+ const manifest = await readJson(manifestPath);+ assert.equal(manifest.actionVersion, version, 'Rebuild the Action before publishing release metadata');+ assert.equal(manifest.cliVersion, version, 'Rebuild the Action before publishing release metadata');+ for (const [key, value] of Object.entries(hashes)) {+ assert.equal(manifest[key], value, 'Rebuild the Action after updating its locks');+ }+ for (const file of ['dist/index.cjs', 'dist/post.cjs']) {+ const bytes = await readFile(resolve(actionRoot, file));+ assert.equal(manifest.files[file].sha256, sha256(bytes), `${file} differs from the built release metadata`);+ assert.equal(manifest.files[file].bytes, bytes.length, `${file} length differs from the built release metadata`);+ }+ await writeJson(manifestPath, { ...manifest, status: 'released', ...identity });+}++if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {+ const [command, version, sourceCommit, cliIntegrity, ...rest] = process.argv.slice(2);+ if (command === 'prepare' && rest.length === 1) {+ await prepareRelease(resolve(rest[0]), version, sourceCommit, cliIntegrity);+ } else if (command === 'stage' && rest.length === 2) {+ await stageRelease(resolve(rest[1]), version, sourceCommit, cliIntegrity, resolve(rest[0]));+ } else if (command === 'verify' && rest.length === 1) {+ releaseIdentity(version, sourceCommit, cliIntegrity);+ await validateReleaseSource(resolve(rest[0]), sourceCommit);+ await validateRelease(resolve(rest[0]), version, cliIntegrity);+ } else if (command === 'metadata' && rest.length === 2) {+ await writeReleaseMetadata(resolve(rest[1]), version, sourceCommit, cliIntegrity, rest[0]);+ } else {+ throw new Error('Usage: release.mjs prepare VERSION SOURCE_SHA CLI_INTEGRITY ACTION_ROOT | stage VERSION SOURCE_SHA CLI_INTEGRITY RUNTIME_LOCK ACTION_ROOT | verify VERSION SOURCE_SHA CLI_INTEGRITY ACTION_ROOT | metadata VERSION SOURCE_SHA CLI_INTEGRITY ACTION_SHA ACTION_ROOT');+ }+}diff --git a/github-action/tests/release.test.mjs b/github-action/tests/release.test.mjsnew file mode 100644index 000000000..d7be4e54c--- /dev/null+++ b/github-action/tests/release.test.mjs@@ -0,0 +1,176 @@+import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import { createHash } from 'node:crypto';+import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { fileURLToPath } from 'node:url';+import test from 'node:test';+import { stageRelease, updateReleaseManifests, validateRelease, validateReleaseSource, writeReleaseMetadata } from '../scripts/release.mjs';++const version = '0.3.0';+const actionCommit = 'b'.repeat(40);+const cliIntegrity = 'sha512-' + Buffer.from('synthetic published CLI').toString('base64');+const packageName = '@openai/codex-security';+const writeJson = (path, data) => writeFile(path, JSON.stringify(data, null, 2) + '\n');+const readJson = async path => JSON.parse(await readFile(path, 'utf8'));+const digest = async path => createHash('sha256').update(await readFile(path)).digest('hex');++async function fixture(t) {+ const root = await mkdtemp(join(tmpdir(), 'action-release-'));+ t.after(() => rm(root, { recursive: true, force: true }));+ const actionRoot = join(root, 'github-action');+ await mkdir(join(actionRoot, 'runtime'), { recursive: true });+ await mkdir(join(actionRoot, 'build'));+ await mkdir(join(actionRoot, 'dist'));+ await writeFile(join(actionRoot, 'dist/index.cjs'), 'console.log("synthetic Action");\n');+ await writeFile(join(actionRoot, 'dist/post.cjs'), 'console.log("synthetic cleanup");\n');+ await mkdir(join(root, 'sdk/typescript'), { recursive: true });+ await writeJson(join(root, 'sdk/typescript/package.json'), { name: packageName, version });+ await writeJson(join(actionRoot, 'package.json'), { name: 'codex-security-action', version: '0.2.0', private: true, dependencies: { '@actions/core': '3.0.1' } });+ await writeJson(join(actionRoot, 'package-lock.json'), { name: 'codex-security-action', version: '0.2.0', lockfileVersion: 3, packages: { '': { name: 'codex-security-action', version: '0.2.0' }, 'node_modules/@actions/core': { version: '3.0.1', integrity: 'sha512-synthetic-action' } } });+ await writeJson(join(actionRoot, 'runtime/package.json'), { private: true, dependencies: { [packageName]: '0.2.0' } });+ await writeJson(join(actionRoot, 'runtime/package-lock.json'), { lockfileVersion: 3, packages: { '': { dependencies: { [packageName]: version } }, [`node_modules/${packageName}`]: { version, integrity: cliIntegrity } } });+ const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });+ git('init', '-b', 'main');+ git('add', '.');+ git('-c', 'user.name=Synthetic Test', '-c', '[email protected]', '-c', 'commit.gpgsign=false', 'commit', '-m', 'Synthetic release source');+ return { actionRoot, sourceCommit: git('rev-parse', 'HEAD').trim() };+}++async function buildMetadata(actionRoot) {+ const files = {};+ for (const file of ['dist/index.cjs', 'dist/post.cjs']) {+ const bytes = await readFile(join(actionRoot, file));+ files[file] = { sha256: createHash('sha256').update(bytes).digest('hex'), bytes: bytes.length };+ }+ await writeJson(join(actionRoot, 'build/release-manifest.json'), {+ actionVersion: version, cliVersion: version, status: 'unreleased',+ actionLockSha256: await digest(join(actionRoot, 'package-lock.json')),+ runtimeLockSha256: await digest(join(actionRoot, 'runtime/package-lock.json')),+ sourceSha256: 'synthetic-source-hash', files,+ });+}++test('release preparation aligns manifests without changing locked Action dependencies', async t => {+ const { actionRoot } = await fixture(t);+ const before = await readJson(join(actionRoot, 'package-lock.json'));+ await updateReleaseManifests(actionRoot, version);+ assert.equal((await readJson(join(actionRoot, 'package.json'))).version, version);+ assert.equal((await readJson(join(actionRoot, 'runtime/package.json'))).dependencies[packageName], version);+ const after = await readJson(join(actionRoot, 'package-lock.json'));+ assert.equal(after.version, version);+ assert.equal(after.packages[''].version, version);+ assert.deepEqual(after.packages['node_modules/@actions/core'], before.packages['node_modules/@actions/core']);+ await validateRelease(actionRoot, version, cliIntegrity);+ await assert.rejects(updateReleaseManifests(actionRoot, '0.3.1'), /version of its CLI source/);+ assert.equal((await readJson(join(actionRoot, 'package.json'))).version, version);+});++test('publisher stages the tested runtime lock byte-for-byte without npm on PATH', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ const runtimeLock = join(actionRoot, '../tested-runtime-lock.json');+ const tested = await readJson(join(actionRoot, 'runtime/package-lock.json'));+ const testedBytes = JSON.stringify(tested);+ await writeFile(runtimeLock, testedBytes);+ await writeJson(join(actionRoot, 'runtime/package-lock.json'), {});+ execFileSync(process.execPath, [+ fileURLToPath(new URL('../scripts/release.mjs', import.meta.url)),+ 'stage', version, sourceCommit, cliIntegrity, runtimeLock, actionRoot,+ ], { env: { ...process.env, PATH: '' }, stdio: ['ignore', 'pipe', 'pipe'] });+ assert.equal(await readFile(join(actionRoot, 'runtime/package-lock.json'), 'utf8'), testedBytes);+ await validateRelease(actionRoot, version, cliIntegrity);+ await validateReleaseSource(actionRoot, sourceCommit);+});++test('publisher rejects a tested lock for a different CLI release or npm archive', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ const runtimeLock = join(actionRoot, '../tested-runtime-lock.json');+ const tested = await readJson(join(actionRoot, 'runtime/package-lock.json'));+ tested.packages[`node_modules/${packageName}`].version = '0.2.0';+ await writeJson(runtimeLock, tested);+ await assert.rejects(stageRelease(actionRoot, version, sourceCommit, cliIntegrity, runtimeLock), /versions must agree/);+ tested.packages[`node_modules/${packageName}`].version = version;+ tested.packages[`node_modules/${packageName}`].integrity = 'sha512-other-tarball';+ await writeJson(runtimeLock, tested);+ await assert.rejects(stageRelease(actionRoot, version, sourceCommit, cliIntegrity, runtimeLock), /verified npm release/);+});++test('release metadata ties built locks to the verified CLI and immutable distribution commit', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ await updateReleaseManifests(actionRoot, version);+ await buildMetadata(actionRoot);+ await writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit);+ const metadata = await readJson(join(actionRoot, 'build/release-manifest.json'));+ assert.equal(metadata.status, 'released');+ assert.equal(metadata.actionVersion, version);+ assert.equal(metadata.cliVersion, version);+ assert.equal(metadata.sourceCommit, sourceCommit);+ assert.equal(metadata.actionCommit, actionCommit);+ assert.equal(metadata.cliIntegrity, cliIntegrity);+ assert.equal(metadata.npmTag, 'npm-v0.3.0');+ assert.equal(metadata.actionTag, 'action-v0.3.0');+ assert.equal(metadata.files['dist/index.cjs'].sha256, await digest(join(actionRoot, 'dist/index.cjs')));+ const first = await readFile(join(actionRoot, 'build/release-manifest.json'), 'utf8');+ await writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit);+ assert.equal(await readFile(join(actionRoot, 'build/release-manifest.json'), 'utf8'), first);+});++test('release metadata rejects a bundle changed or removed after the build', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ await updateReleaseManifests(actionRoot, version);+ await buildMetadata(actionRoot);+ for (const file of ['dist/index.cjs', 'dist/post.cjs']) {+ const path = join(actionRoot, file);+ const original = await readFile(path);+ const changed = Buffer.from(original);+ changed[0] ^= 1;+ await writeFile(path, changed);+ await assert.rejects(writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit), /differs from the built release metadata/);+ await rm(path);+ await assert.rejects(writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit), { code: 'ENOENT' });+ await writeFile(path, original);+ }+ const metadataPath = join(actionRoot, 'build/release-manifest.json');+ const metadata = await readJson(metadataPath);+ assert.equal(metadata.status, 'unreleased');+ metadata.files['dist/index.cjs'].bytes += 1;+ await writeJson(metadataPath, metadata);+ await assert.rejects(writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit), /length differs/);+});++test('release refuses a stale CLI lock or metadata generated before the lock changed', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ await updateReleaseManifests(actionRoot, version);+ await buildMetadata(actionRoot);+ await assert.rejects(validateRelease(actionRoot, version, 'sha512-other-tarball'), /verified npm release/);+ const runtimeLockPath = join(actionRoot, 'runtime/package-lock.json');+ const lock = await readJson(runtimeLockPath);+ lock.packages[`node_modules/${packageName}`].version = '0.2.0';+ await writeJson(runtimeLockPath, lock);+ await assert.rejects(validateRelease(actionRoot, version, cliIntegrity), /versions must agree/);+ lock.packages[`node_modules/${packageName}`].version = version;+ lock.packages['node_modules/example-dependency'] = { version: '1.0.0', integrity: 'sha512-synthetic-dependency' };+ await writeJson(runtimeLockPath, lock);+ await assert.rejects(writeReleaseMetadata(actionRoot, version, sourceCommit, cliIntegrity, actionCommit), /after updating its locks/);+ assert.equal((await readJson(join(actionRoot, 'build/release-manifest.json'))).status, 'unreleased');+});++test('distribution manifests preserve the reviewed source beyond owned version fields', async t => {+ const { actionRoot, sourceCommit } = await fixture(t);+ await updateReleaseManifests(actionRoot, version);+ await validateReleaseSource(actionRoot, sourceCommit);+ for (const [file, change] of [+ ['package.json', value => { value.dependencies['@actions/core'] = '3.0.2'; }],+ ['package-lock.json', value => { value.packages['node_modules/@actions/core'].integrity = 'sha512-changed-action'; }],+ ['runtime/package.json', value => { value.dependencies['example-package'] = '1.0.0'; }],+ ]) {+ const path = join(actionRoot, file);+ const original = await readFile(path, 'utf8');+ const value = JSON.parse(original);+ change(value);+ await writeJson(path, value);+ await assert.rejects(validateReleaseSource(actionRoot, sourceCommit), /must preserve the reviewed release source/);+ await writeFile(path, original);+ }+});diff --git a/sdk/typescript/scripts/release-pr.mjs b/sdk/typescript/scripts/release-pr.mjsindex 3d99da98f..b3732c931 100644--- a/sdk/typescript/scripts/release-pr.mjs+++ b/sdk/typescript/scripts/release-pr.mjs@@ -8,8 +8,11 @@ import { assertStableVersion, releaseVersion } from "./release-automation.mjs";import { isMain } from "./is-main.mjs";export const packagePath = "sdk/typescript/package.json";+export const actionPackagePath = "github-action/package.json";+export const actionLockPath = "github-action/package-lock.json";export const notesPath = ".github/release-notes.md";export const statePath = ".github/release-pr-state.json";+const packagePaths = [packagePath, actionPackagePath, actionLockPath];const templatePath = ".github/PULL_REQUEST_TEMPLATE.md";const sectionIds = ["highlights", "upgrades"];const releaseBranchPrefix = "release/next-";@@ -175,6 +178,23 @@ function updatePackageVersion(packageText, version) {throw new Error("Unable to update only the top-level package version.");}+function updateActionLockVersion(lockText, version) {+ const lock = JSON.parse(lockText);+ lock.version = version;+ lock.packages[""].version = version;+ return `${JSON.stringify(lock, null, 2)}\n`;+}++function packageWithoutVersion(text, path) {+ if (text === null) return null;+ const metadata = JSON.parse(text);+ delete metadata.version;+ if (path === actionLockPath && metadata.packages?.[""]) {+ delete metadata.packages[""].version;+ }+ return metadata;+}+export function createReleasePlan(history, previous = null) {const { baseVersion, baseCommit, mainSha, packageText, changes } = history;if (@@ -195,6 +215,23 @@ export function createReleasePlan(history, previous = null) {previous?.state.sections,);const state = { baseVersion, baseCommit, sections };+ const files = {+ [packagePath]: updatePackageVersion(packageText, version),+ [notesPath]: notes,+ [statePath]: `${JSON.stringify(state, null, 2)}\n`,+ };+ if (history.actionPackageText != null) {+ files[actionPackagePath] = updatePackageVersion(+ history.actionPackageText,+ version,+ );+ }+ if (history.actionLockText != null) {+ files[actionLockPath] = updateActionLockVersion(+ history.actionLockText,+ version,+ );+ }return {baseVersion,baseCommit,@@ -205,11 +242,7 @@ export function createReleasePlan(history, previous = null) {changes,generated,humanOwned: sectionIds.filter((id) => sections[id].humanOwned),- files: {- [packagePath]: updatePackageVersion(packageText, version),- [notesPath]: notes,- [statePath]: `${JSON.stringify(state, null, 2)}\n`,- },+ files,};}@@ -281,6 +314,8 @@ export async function readReleaseHistory(repo, mainSha, github) {baseCommit,mainSha,packageText,+ actionPackageText: repo.readFile(mainSha, actionPackagePath),+ actionLockText: repo.readFile(mainSha, actionLockPath),changes: [...changes.values()],};}@@ -293,22 +328,30 @@ function readReleaseBranch(repo, mainSha, headSha) {.split("\0").filter(Boolean);if (- paths.some((path) => ![packagePath, notesPath, statePath].includes(path))+ paths.some(+ (path) => ![...packagePaths, notesPath, statePath].includes(path),+ )) {return {holdReason:"The release branch has other file edits. Preserve or merge them before running the updater.",};}- const originalPackage = JSON.parse(repo.readFile(mergeBase, packagePath));- const branchPackage = JSON.parse(repo.readFile(headSha, packagePath));- delete originalPackage.version;- delete branchPackage.version;- if (!isDeepStrictEqual(originalPackage, branchPackage)) {- return {- holdReason:- "The release branch has package edits beyond its version. Preserve them before running the updater.",- };+ for (const path of packagePaths) {+ const originalPackage = packageWithoutVersion(+ repo.readFile(mergeBase, path),+ path,+ );+ const branchPackage = packageWithoutVersion(+ repo.readFile(headSha, path),+ path,+ );+ if (!isDeepStrictEqual(originalPackage, branchPackage)) {+ return {+ holdReason:+ "The release branch has package edits beyond its version. Preserve them before running the updater.",+ };+ }}const state = JSON.parse(repo.readFile(headSha, statePath));if (!state?.sections) {diff --git a/sdk/typescript/scripts/smoke-published-package.mjs b/sdk/typescript/scripts/smoke-published-package.mjsindex 1f9fd9c03..15ff6cc8d 100644--- a/sdk/typescript/scripts/smoke-published-package.mjs+++ b/sdk/typescript/scripts/smoke-published-package.mjs@@ -24,8 +24,13 @@ function run(command, args, options) {/*** @param {string} consumer* @param {NodeJS.ProcessEnv} environment+ * @param {string} expectedVersion*/-export async function verifyInstalledPackage(consumer, environment) {+export async function verifyInstalledPackage(+ consumer,+ environment,+ expectedVersion = "latest",+) {const installedRoot = join(consumer,"node_modules",@@ -35,6 +40,9 @@ export async function verifyInstalledPackage(consumer, environment) {await readFile(join(installedRoot, "package.json"), "utf8"),);assert.equal(manifest.name, packageName);+ if (expectedVersion !== "latest") {+ assert.equal(manifest.version, expectedVersion);+ }console.log(`Checking ${packageName}@${manifest.version} on ${process.platform}/${process.arch}, Node ${process.version}.`,);@@ -79,20 +87,34 @@ export async function verifyInstalledPackage(consumer, environment) {assert.match(run(codex.command, ["--version"], options), /^codex-cli\s+\d/u);const pluginRoot = join(installedRoot, "_bundled_plugin");+ await verifyInstalledPlugin(pluginRoot, environment);+ console.log(+ `Validated published ${packageName}@${manifest.version}: npm CLI shim, public SDK, bundled Codex, and plugin initialization.`,+ );+}++/**+ * @param {string} pluginRoot+ * @param {NodeJS.ProcessEnv} environment+ */+export async function verifyInstalledPlugin(pluginRoot, environment) {const configuration = JSON.parse(await readFile(join(pluginRoot, ".mcp.json"), "utf8"),);const server = configuration.mcpServers["codex-security"];- const launcher = join(pluginRoot, server.command);+ const launcher =+ server.command === "node"+ ? process.execPath+ : join(pluginRoot, server.command);+ const windowsLauncher =+ process.platform === "win32" && server.command !== "node";const initialized = run(- process.platform === "win32"- ? (environment.ComSpec ?? "cmd.exe")- : launcher,- process.platform === "win32"+ windowsLauncher ? (environment.ComSpec ?? "cmd.exe") : launcher,+ windowsLauncher? ["/d", "/s", "/c", "call", `${launcher}.cmd`, ...server.args]: server.args,{- ...options,+ env: environment,cwd: pluginRoot,input: `${JSON.stringify({jsonrpc: "2.0",@@ -109,12 +131,9 @@ export async function verifyInstalledPackage(consumer, environment) {const response = JSON.parse(initialized.trim());assert.equal(response.id, 1);assert.equal(response.result.serverInfo.name, "codex-security");- console.log(- `Validated published ${packageName}@${manifest.version}: npm CLI shim, public SDK, bundled Codex, and plugin initialization.`,- );}-async function smokePublishedPackage() {+async function smokePublishedPackage(version = "latest") {const consumer = await mkdtemp(join(tmpdir(), "codex-security-published-"));try {await writeFile(@@ -136,7 +155,7 @@ async function smokePublishedPackage() {"--no-audit","--no-fund","--registry=https://registry.npmjs.org",- `${packageName}@latest`,+ `${packageName}@${version}`,],{cwd: consumer,@@ -147,18 +166,22 @@ async function smokePublishedPackage() {const smokeHome = join(consumer, "home");await mkdir(smokeHome);- await verifyInstalledPackage(consumer, {- ...process.env,- HOME: smokeHome,- USERPROFILE: smokeHome,- XDG_CONFIG_HOME: join(smokeHome, ".config"),- XDG_CACHE_HOME: join(smokeHome, ".cache"),- APPDATA: join(smokeHome, "AppData", "Roaming"),- LOCALAPPDATA: join(smokeHome, "AppData", "Local"),- CODEX_HOME: join(smokeHome, ".codex"),- CODEX_SECURITY_STATE_DIR: join(smokeHome, ".codex-security"),- CODEX_MCP_NODE_PATH: process.execPath,- });+ await verifyInstalledPackage(+ consumer,+ {+ ...process.env,+ HOME: smokeHome,+ USERPROFILE: smokeHome,+ XDG_CONFIG_HOME: join(smokeHome, ".config"),+ XDG_CACHE_HOME: join(smokeHome, ".cache"),+ APPDATA: join(smokeHome, "AppData", "Roaming"),+ LOCALAPPDATA: join(smokeHome, "AppData", "Local"),+ CODEX_HOME: join(smokeHome, ".codex"),+ CODEX_SECURITY_STATE_DIR: join(smokeHome, ".codex-security"),+ CODEX_MCP_NODE_PATH: process.execPath,+ },+ version,+ );} finally {await rm(consumer, {recursive: true,@@ -170,5 +193,5 @@ async function smokePublishedPackage() {}if (isMain(import.meta.url)) {- await smokePublishedPackage();+ await smokePublishedPackage(process.argv[2]);}diff --git a/sdk/typescript/tests-ts/action-release-workflow.test.ts b/sdk/typescript/tests-ts/action-release-workflow.test.tsnew file mode 100644index 000000000..0d2b7ac0a--- /dev/null+++ b/sdk/typescript/tests-ts/action-release-workflow.test.ts@@ -0,0 +1,726 @@+import { afterEach, expect, test } from "bun:test";+import { execFileSync } from "node:child_process";+import {+ copyFileSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ readdirSync,+ rmSync,+ writeFileSync,+} from "node:fs";+import { tmpdir } from "node:os";+import { basename, dirname, join } from "node:path";+import { runWorkflowScript } from "./support/workflow-script.js";++type Step = {+ name: string;+ id?: string;+ run?: string;+ uses?: string;+ with?: Record<string, string | boolean>;+ if?: string;+ "continue-on-error"?: boolean;+};+type Job = {+ steps: Step[];+ permissions?: Record<string, string>;+ needs?: string[];+ outputs?: Record<string, string>;+};+const workflow = Bun.YAML.parse(+ readFileSync(+ new URL(+ "../../../.github/workflows/node-github-release.yml",+ import.meta.url,+ ),+ "utf8",+ ),+) as { jobs: Record<string, Job> };++function step(job: string, name: string) {+ const value = workflow.jobs[job]?.steps.find((step) => step.name === name);+ if (!value) throw new Error(`Missing workflow step: ${job}/${name}`);+ return value;+}++function script(job: string, name: string) {+ const value = step(job, name);+ if (!value.run) throw new Error(`Missing workflow script: ${job}/${name}`);+ return value.run;+}++const reuse = script(+ "action",+ "Reuse an existing immutable Action distribution",+);+const detect = script("release", "Detect Action release source");+const complete = script("complete", "Require completed release channels");+const publish = script("action", "Publish immutable Action tag and metadata");+const directories: string[] = [];+const version = "99.1.2";+const packageName = "@openai/codex-security";+const integrity = "sha512-synthetic-verified-integrity";++afterEach(() => {+ for (const directory of directories.splice(0)) {+ rmSync(directory, { recursive: true, force: true });+ }+});++function fixture(includeAction = true) {+ const directory = mkdtempSync(join(tmpdir(), "action release workflow "));+ directories.push(directory);+ const repository = join(directory, "release-source");+ const output = join(directory, "outputs");+ const npmMarker = join(directory, "npm-ran");+ mkdirSync(repository);+ writeFileSync(npmMarker, "");+ const helper = join(+ directory,+ "automation/github-action/scripts/release.mjs",+ );+ mkdirSync(dirname(helper), { recursive: true });+ copyFileSync(+ new URL("../../../github-action/scripts/release.mjs", import.meta.url),+ helper,+ );+ function git(...args: string[]) {+ return execFileSync(+ "git",+ [+ "-c",+ "user.name=Release Test",+ "-c",+ "[email protected]",+ "-c",+ "commit.gpgsign=false",+ ...args,+ ],+ { cwd: repository, encoding: "utf8", stdio: "pipe" },+ ).trim();+ }+ function write(path: string, value: string) {+ const destination = join(repository, path);+ mkdirSync(dirname(destination), { recursive: true });+ writeFileSync(destination, value);+ }+ function writeJson(path: string, value: unknown) {+ write(path, `${JSON.stringify(value)}\n`);+ }+ function updateJson(+ path: string,+ update: (value: Record<string, unknown>) => Record<string, unknown>,+ ) {+ writeJson(+ path,+ update(JSON.parse(readFileSync(join(repository, path), "utf8"))),+ );+ }+ function commit(message: string) {+ git("add", "--all");+ git("commit", "-m", message);+ return git("rev-parse", "HEAD");+ }+ function run(script: string, environment: Record<string, string> = {}) {+ writeFileSync(output, "");+ const result = runWorkflowScript(+ repository,+ script,+ {+ GITHUB_OUTPUT: output.replaceAll("\\", "/"),+ RELEASE_VERSION: version,+ RELEASE_SHA: source,+ CLI_INTEGRITY: integrity,+ GITHUB_WORKSPACE: directory.replaceAll("\\", "/"),+ RUNNER_TEMP: directory.replaceAll("\\", "/"),+ NPM_MARKER: npmMarker.replaceAll("\\", "/"),+ ...environment,+ },+ ["-e", "-o", "pipefail"],+ );+ return { ...result, output: readFileSync(output, "utf8") };+ }+ git("init");+ write("README.md", "Synthetic CLI source\n");+ writeJson("sdk/typescript/package.json", { name: packageName, version });+ const actionPackage = {+ name: "example-action",+ version: "99.1.1",+ scripts: { build: "node scripts/build.mjs" },+ dependencies: { "example-build": "1.2.3" },+ };+ if (includeAction) {+ write("action.yml", "name: Synthetic Action\n");+ writeJson("github-action/package.json", actionPackage);+ writeJson("github-action/package-lock.json", {+ version: actionPackage.version,+ lockfileVersion: 3,+ packages: {+ "": actionPackage,+ "node_modules/example-build": { version: "1.2.3" },+ },+ });+ writeJson("github-action/runtime/package.json", {+ private: true,+ dependencies: { [packageName]: "99.1.1" },+ });+ }+ const source = commit("Create release source");+ function distribution(change?: () => void) {+ writeJson("github-action/package.json", { ...actionPackage, version });+ writeJson("github-action/package-lock.json", {+ version,+ lockfileVersion: 3,+ packages: {+ "": { ...actionPackage, version },+ "node_modules/example-build": { version: "1.2.3" },+ },+ });+ writeJson("github-action/runtime/package.json", {+ private: true,+ dependencies: { [packageName]: version },+ });+ writeJson("github-action/runtime/package-lock.json", {+ lockfileVersion: 3,+ packages: {+ "": { dependencies: { [packageName]: version } },+ [`node_modules/${packageName}`]: { version, integrity },+ },+ });+ for (const path of [+ "github-action/dist/index.cjs",+ "github-action/dist/post.cjs",+ ]) {+ write(path, "Synthetic generated release content\n");+ }+ change?.();+ const sha = commit("Package Action release");+ git("tag", "action-v99.1.2", sha);+ git("checkout", "--detach", source);+ return sha;+ }+ return {+ directory,+ repository,+ git,+ write,+ updateJson,+ commit,+ run,+ source,+ distribution,+ npmMarker,+ };+}++test("runs CLI verification read-only and passes only its identified runtime lock to publication", () => {+ const verification = workflow.jobs["action-verify"]!;+ const publication = workflow.jobs["action"]!;+ expect(verification.permissions).toEqual({ contents: "read" });+ expect(publication.permissions).toEqual({ contents: "write" });+ expect(publication.needs).toContain("action-verify");+ expect(step("action", "Checkout verified CLI source").with).toMatchObject({+ ref: "${{ needs.release.outputs.sha }}",+ path: "release-source",+ "persist-credentials": false,+ });+ const artifacts = verification.steps.filter((step) =>+ step.uses?.startsWith("actions/upload-artifact@"),+ );+ expect(artifacts).toHaveLength(1);+ expect(artifacts[0]?.with?.["path"]).toBe(+ "release-source/github-action/runtime/package-lock.json",+ );+ expect(verification.outputs?.["runtime-lock-artifact"]).toBe(+ `\${{ steps.${artifacts[0]!.id}.outputs.artifact-id }}`,+ );+ expect(+ step("action", "Download verified CLI runtime lock").with,+ ).toMatchObject({+ "artifact-ids": "${{ needs.action-verify.outputs.runtime-lock-artifact }}",+ });+ const verificationCommands = script(+ "action-verify",+ "Validate the packaged Action",+ )+ .trim()+ .split("\n");+ expect(verificationCommands.at(-1)).toBe("npm run check-dist");+ expect(+ script("action", "Check Action distribution before publication").trim(),+ ).toBe("npm run check-dist");+ const actionPackage = JSON.parse(+ readFileSync(+ new URL("../../../github-action/package.json", import.meta.url),+ "utf8",+ ),+ ) as { scripts: Record<string, string> };+ expect(actionPackage.scripts["check-dist"]).toBeString();+ const publicationCommands = publication.steps+ .map((step) => step.run ?? "")+ .join("\n");+ expect(publicationCommands).not.toMatch(+ /test:cli|scripts\/linux-smoke\.mjs|npm ci --prefix runtime/u,+ );+});++test("stages the verified runtime lock without copying verification workspace source or bundles", () => {+ const release = fixture();+ release.write(".gitattributes", "* text eol=lf\n");+ const version = "99.1.2";+ const packageName = "@openai/codex-security";+ const integrity = "sha512-synthetic-verified-integrity";+ const writeJson = (path: string, value: unknown) =>+ release.write(path, `${JSON.stringify(value)}\n`);+ writeJson("sdk/typescript/package.json", { name: packageName, version });+ writeJson("github-action/package.json", {+ name: "example-action",+ version: "99.1.1",+ });+ writeJson("github-action/package-lock.json", {+ version: "99.1.1",+ packages: { "": { version: "99.1.1" } },+ });+ writeJson("github-action/runtime/package.json", {+ dependencies: { [packageName]: "99.1.1" },+ });+ const source = "reviewed Action source\n";+ const bundle = "reviewed Action bundle\n";+ release.write("github-action/src/index.ts", source);+ release.write("github-action/dist/index.cjs", bundle);+ release.write("github-action/dist/post.cjs", bundle);+ const sourceCommit = release.commit("Prepare reviewed Action source");+ const verification = join(release.directory, "verification");+ const publication = join(release.directory, "publication");+ mkdirSync(verification);+ mkdirSync(publication);+ for (const workspace of [verification, publication]) {+ release.git(+ "clone",+ "--local",+ release.repository,+ join(workspace, "release-source"),+ );+ }+ const verifiedAction = join(verification, "release-source", "github-action");+ for (const path of [+ "src/index.ts",+ "dist/index.cjs",+ "dist/post.cjs",+ "package.json",+ ]) {+ writeFileSync(+ join(verifiedAction, path),+ "modified by runtime verification\n",+ );+ }+ const runtimeLock = `${JSON.stringify({+ packages: {+ "": { dependencies: { [packageName]: version } },+ [`node_modules/${packageName}`]: { version, integrity },+ },+ })}\n`;+ const artifactPath = step("action-verify", "Save verified CLI runtime lock")+ .with?.["path"];+ if (typeof artifactPath !== "string")+ throw new Error("Missing runtime lock artifact path");+ writeFileSync(join(verification, artifactPath), runtimeLock);+ const runner = join(publication, "runner");+ const download = join(runner, "action-runtime-lock");+ mkdirSync(download, { recursive: true });+ copyFileSync(+ join(verification, artifactPath),+ join(download, basename(artifactPath)),+ );+ const helper = join(+ publication,+ "automation",+ "github-action",+ "scripts",+ "release.mjs",+ );+ mkdirSync(dirname(helper), { recursive: true });+ copyFileSync(+ new URL("../../../github-action/scripts/release.mjs", import.meta.url),+ helper,+ );+ const result = runWorkflowScript(+ publication,+ script("action", "Stage verified CLI runtime lock"),+ {+ RELEASE_VERSION: version,+ RELEASE_SHA: sourceCommit,+ CLI_INTEGRITY: integrity,+ RUNNER_TEMP: runner.replaceAll("\\", "/"),+ GITHUB_WORKSPACE: publication.replaceAll("\\", "/"),+ },+ ["-e", "-o", "pipefail"],+ );+ expect(result.status, result.stderr).toBe(0);+ const publishedAction = join(publication, "release-source", "github-action");+ expect(readFileSync(join(publishedAction, "src/index.ts"), "utf8")).toBe(+ source,+ );+ for (const path of ["dist/index.cjs", "dist/post.cjs"]) {+ expect(readFileSync(join(publishedAction, path), "utf8")).toBe(bundle);+ }+ expect(+ JSON.parse(readFileSync(join(publishedAction, "package.json"), "utf8")),+ ).toEqual({+ name: "example-action",+ version,+ });+ expect(+ readFileSync(join(publishedAction, "runtime/package-lock.json"), "utf8"),+ ).toBe(runtimeLock);+});++test.each([0, 42])(+ "gates runtime verification through Socket with an empty cache (exit %j)",+ (firewallExit) => {+ const verification = workflow.jobs["action-verify"]!;+ const install = step(+ "action-verify",+ "Install Action and CLI dependencies",+ );+ const validate = step("action-verify", "Validate the packaged Action");+ const upload = step("action-verify", "Save verified CLI runtime lock");+ expect(verification.steps.indexOf(install)).toBeLessThan(+ verification.steps.indexOf(validate),+ );+ expect(verification.steps.indexOf(validate)).toBeLessThan(+ verification.steps.indexOf(upload),+ );+ expect(install["continue-on-error"]).toBeUndefined();+ expect(validate.if).toBeUndefined();+ expect(upload.if).toBeUndefined();++ const directory = mkdtempSync(join(tmpdir(), "action runtime firewall "));+ directories.push(directory);+ const runner = join(directory, "runner");+ const existingCache = join(runner, "existing-cache");+ mkdirSync(existingCache, { recursive: true });+ writeFileSync(join(existingCache, "cached-package"), "cached bytes");+ mkdirSync(join(directory, "runtime"));+ const lockPath = join(directory, "runtime", "package-lock.json");+ const runtimeLock = `${JSON.stringify({+ lockfileVersion: 3,+ packages: {+ "node_modules/example-runtime": {+ version: "1.2.3",+ resolved:+ "https://registry.npmjs.org/example-runtime/-/example-runtime-1.2.3.tgz",+ integrity: "sha512-synthetic-integrity",+ },+ },+ })}\n`;+ writeFileSync(lockPath, runtimeLock);+ const events = join(directory, "events");+ const argumentsPath = join(directory, "sfw-arguments");+ const result = runWorkflowScript(+ directory,+ `npm() { printf 'npm %s\\n' "$*" >> "$EVENTS"; }+node() { printf 'node %s\\n' "$*" >> "$EVENTS"; }+sfw() {+ printf '%s\\0' "$@" > "$SFW_ARGUMENTS"+ local argument cache+ for argument in "$@"; do+ case "$argument" in --cache=*) cache="\${argument#--cache=}" ;; esac+ done+ [[ -d "$cache" && -z "$(ls -A "$cache")" ]] || return 91+ touch "$cache/downloaded-package"+ printf 'sfw\\n' >> "$EVENTS"+ return "$FIREWALL_EXIT"+}+${install.run}+${validate.run}`,+ {+ RUNNER_TEMP: runner.replaceAll("\\", "/"),+ npm_config_cache: existingCache.replaceAll("\\", "/"),+ EVENTS: events.replaceAll("\\", "/"),+ SFW_ARGUMENTS: argumentsPath.replaceAll("\\", "/"),+ FIREWALL_EXIT: String(firewallExit),+ },+ ["-e", "-o", "pipefail"],+ );+ expect(result.status, result.stderr).toBe(firewallExit);+ const args = readFileSync(argumentsPath, "utf8").split("\0").slice(0, -1);+ expect(args.slice(0, 4)).toEqual(["npm", "ci", "--prefix", "runtime"]);+ expect(args).toContain("--registry=https://registry.npmjs.org/");+ expect(args).toContain("--ignore-scripts");+ expect(readFileSync(lockPath, "utf8")).toBe(runtimeLock);+ expect(readdirSync(runner)).toEqual(["existing-cache"]);+ const commands = readFileSync(events, "utf8");+ expect(commands).toContain("sfw\n");+ if (firewallExit === 0) {+ expect(commands).toContain("npm run test:cli\n");+ expect(commands).toContain("node scripts/linux-smoke.mjs\n");+ } else {+ expect(commands).not.toContain("npm run");+ expect(commands).not.toContain("node ");+ }+ },+);++function reuseAndInstall(job: string) {+ const steps = workflow.jobs[job]!.steps;+ const reuse = step(job, "Reuse an existing immutable Action distribution");+ const install = step(+ job,+ job === "action"+ ? "Install Action build dependencies"+ : "Install Action and CLI dependencies",+ );+ expect(steps.indexOf(reuse)).toBeLessThan(steps.indexOf(install));+ return `npm() { printf 'npm\\n' >> "$NPM_MARKER"; }+sfw() { "$@"; }+${reuse.run}+cd "$GITHUB_WORKSPACE/release-source/github-action"+${install.run}`;+}++const changedDistributions: Array<{+ name: string;+ path: string;+ update: (value: Record<string, unknown>) => Record<string, unknown>;+ error: string;+}> = [+ {+ name: "Action scripts",+ path: "package.json",+ update: (value) => ({ ...value, scripts: { build: "node changed.mjs" } }),+ error: "must preserve the reviewed release source",+ },+ {+ name: "Action dependencies",+ path: "package.json",+ update: (value) => ({+ ...value,+ dependencies: { "example-build": "9.9.9" },+ }),+ error: "must preserve the reviewed release source",+ },+ {+ name: "Action lock dependencies",+ path: "package-lock.json",+ update: (value) => ({+ ...value,+ packages: {+ ...(value["packages"] as Record<string, unknown>),+ "node_modules/example-build": { version: "9.9.9" },+ },+ }),+ error: "must preserve the reviewed release source",+ },+ {+ name: "runtime scripts",+ path: "runtime/package.json",+ update: (value) => ({ ...value, scripts: { prepare: "node changed.mjs" } }),+ error: "must preserve the reviewed release source",+ },+ {+ name: "CLI version",+ path: "runtime/package.json",+ update: (value) => ({+ ...value,+ dependencies: { [packageName]: "99.1.3" },+ }),+ error: "Action and CLI release versions must agree",+ },+ {+ name: "CLI integrity",+ path: "runtime/package-lock.json",+ update: (value) => ({+ ...value,+ packages: {+ ...(value["packages"] as Record<string, unknown>),+ [`node_modules/${packageName}`]: {+ version,+ integrity: "sha512-different",+ },+ },+ }),+ error: "Action must install the verified npm release",+ },+];++for (const job of ["action-verify", "action"]) {+ test(`${job} reuses the exact CLI release before installing dependencies`, () => {+ const release = fixture();+ const distribution = release.distribution();+ const result = release.run(reuseAndInstall(job));+ expect(result.status, result.stderr).toBe(0);+ expect(result.output).toBe("existing=true\n");+ expect(readFileSync(release.npmMarker, "utf8")).toContain("npm\n");+ expect(release.git("rev-parse", "HEAD")).toBe(distribution);+ });++ test.each(changedDistributions)(+ `${job} rejects changed $name before installing dependencies`,+ ({ path, update, error }) => {+ const release = fixture();+ release.distribution(() =>+ release.updateJson(`github-action/${path}`, update),+ );+ const result = release.run(reuseAndInstall(job));+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain(error);+ expect(result.output).toBe("");+ expect(readFileSync(release.npmMarker, "utf8")).toBe("");+ },+ );+}++test("leaves the CLI source ready for first Action publication", () => {+ const release = fixture();+ const result = release.run(reuse);+ expect(result.status).toBe(0);+ expect(result.output).toBe("");+ expect(release.git("rev-parse", "HEAD")).toBe(release.source);+});++test("rejects an Action distribution derived from a different source commit", () => {+ const release = fixture();+ release.write("README.md", "Another CLI source commit\n");+ release.commit("Advance source");+ release.distribution();+ const result = release.run(reuse);+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("exact CLI source");+ expect(result.output).toBe("");+ expect(release.git("rev-parse", "HEAD")).toBe(release.source);+});++test("rejects unrelated source edits in an existing Action distribution", () => {+ const release = fixture();+ release.distribution(() =>+ release.write("github-action/src/index.ts", "Unrelated source change\n"),+ );+ const result = release.run(reuse);+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("outside release packaging");+ expect(result.output).toBe("");+ expect(release.git("rev-parse", "HEAD")).toBe(release.source);+});++test("detects Action support from the release commit during historical recovery", () => {+ const release = fixture(false);+ release.write("action.yml", "name: Synthetic Action\n");+ const newerSource = release.commit("Add Action after earlier CLI release");+ const historical = release.run(detect);+ expect(historical.status).toBe(0);+ expect(historical.output).toBe("");+ const current = release.run(detect, { RELEASE_SHA: newerSource });+ expect(current.status).toBe(0);+ expect(current.output).toBe("present=true\n");+});++function publicationFixture(existingManifest: string) {+ const release = fixture();+ const runner = join(release.directory, "runner");+ const remote = join(release.directory, "published assets");+ const uploads = join(release.directory, "uploads");+ mkdirSync(runner);+ mkdirSync(remote);+ writeFileSync(uploads, "");+ release.write(+ "github-action/build/release-manifest.json",+ "verified manifest\n",+ );+ release.write("github-action/build/sbom.cdx.json", "verified SBOM\n");+ writeFileSync(join(remote, "action-release-manifest.json"), existingManifest);+ const fakeGitHub = `gh() {+ case "$1 $2" in+ 'release view')+ for asset in "$REMOTE_ASSETS/"*; do basename "$asset"; done+ ;;+ 'release download')+ local asset destination+ while [[ $# -gt 0 ]]; do+ case "$1" in+ --pattern) asset="$2"; shift ;;+ --dir) destination="$2"; shift ;;+ esac+ shift+ done+ cp "$REMOTE_ASSETS/$asset" "$destination/$asset"+ ;;+ 'release upload')+ local asset="$(basename "\${!#}")"+ cp "\${!#}" "$REMOTE_ASSETS/$asset"+ printf '%s\\n' "$asset" >> "$UPLOADS"+ ;;+ *) return 1 ;;+ esac+}+`;+ return {+ remote,+ uploads,+ run() {+ return release.run(`${fakeGitHub}${publish}`, {+ EXISTING: "true",+ RUNNER_TEMP: runner.replaceAll("\\", "/"),+ REMOTE_ASSETS: remote.replaceAll("\\", "/"),+ UPLOADS: uploads.replaceAll("\\", "/"),+ GITHUB_REPOSITORY: "example/security-tool",+ GITHUB_STEP_SUMMARY: join(release.directory, "summary.md").replaceAll(+ "\\",+ "/",+ ),+ });+ },+ };+}++test("completes partial Action metadata publication and reuses matching assets", () => {+ const publication = publicationFixture("verified manifest\n");+ expect(publication.run().status).toBe(0);+ expect(readFileSync(publication.uploads, "utf8")).toBe(+ "action-sbom.cdx.json\n",+ );+ expect(+ readFileSync(join(publication.remote, "action-sbom.cdx.json"), "utf8"),+ ).toBe("verified SBOM\n");+ expect(publication.run().status).toBe(0);+ expect(readFileSync(publication.uploads, "utf8")).toBe(+ "action-sbom.cdx.json\n",+ );+});++test("rejects mismatched published Action metadata without replacing it", () => {+ const publication = publicationFixture("different published manifest\n");+ const result = publication.run();+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("Published Action metadata differs");+ expect(readFileSync(publication.uploads, "utf8")).toBe("");+ expect(+ readFileSync(+ join(publication.remote, "action-release-manifest.json"),+ "utf8",+ ),+ ).toBe("different published manifest\n");+});++test.each([+ ["success", "success", "success", "true", true],+ ["success", "success", "skipped", "", true],+ ["failure", "skipped", "skipped", "", false],+ ["success", "failure", "skipped", "true", false],+ ["success", "success", "failure", "true", false],+ ["success", "success", "skipped", "true", false],+ ["success", "cancelled", "skipped", "", false],+] as const)(+ "requires completed release channels: release=%s install=%s action=%s present=%s",+ (releaseResult, installResult, actionResult, hasAction, succeeds) => {+ const release = fixture();+ const result = release.run(complete, {+ RELEASE_RESULT: releaseResult,+ INSTALL_RESULT: installResult,+ ACTION_RESULT: actionResult,+ HAS_ACTION: hasAction,+ });+ expect(result.status === 0).toBe(succeeds);+ },+);diff --git a/sdk/typescript/tests-ts/published-install-smoke.test.ts b/sdk/typescript/tests-ts/published-install-smoke.test.tsindex 50e623746..e2653b9f2 100644--- a/sdk/typescript/tests-ts/published-install-smoke.test.ts+++ b/sdk/typescript/tests-ts/published-install-smoke.test.ts@@ -1,8 +1,13 @@import { afterEach, expect, test } from "bun:test";-import { chmod, mkdir, writeFile } from "node:fs/promises";+import { spawnSync } from "node:child_process";+import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";import { join } from "node:path";+import { fileURLToPath } from "node:url";-import { verifyInstalledPackage } from "../scripts/smoke-published-package.mjs";+import {+ verifyInstalledPackage,+ verifyInstalledPlugin,+} from "../scripts/smoke-published-package.mjs";import { createTemporaryDirectories } from "./support/temporary-directories.js";const directories = createTemporaryDirectories();@@ -40,6 +45,50 @@ async function installedFixture(cliVersion: string) {return { consumer, shim };}+test.each([+ { args: [], version: "latest" },+ { args: ["99.1.2"], version: "99.1.2" },+])(+ "installs the requested published package $version",+ async ({ args, version }) => {+ const directory = await directories.create("published smoke npm ");+ const npm = join(directory, "npm-cli.js");+ const capturedArgs = join(directory, "arguments.json");+ await writeFile(+ npm,+ `require("node:fs").writeFileSync(process.env.SMOKE_NPM_ARGUMENTS, JSON.stringify(process.argv.slice(2))); process.exit(7);`,+ );+ const result = spawnSync(+ process.execPath,+ [+ fileURLToPath(+ new URL("../scripts/smoke-published-package.mjs", import.meta.url),+ ),+ ...args,+ ],+ {+ env: {+ ...process.env,+ npm_execpath: npm,+ SMOKE_NPM_ARGUMENTS: capturedArgs,+ },+ encoding: "utf8",+ },+ );+ expect(result.status).not.toBe(0);+ expect(JSON.parse(await readFile(capturedArgs, "utf8"))).toContain(+ `@openai/codex-security@${version}`,+ );+ },+);++test("fails when the installed package differs from the requested release", async () => {+ const { consumer } = await installedFixture("99.1.2");+ await expect(+ verifyInstalledPackage(consumer, process.env, "99.1.3"),+ ).rejects.toThrow("99.1.3");+});+test("fails when the installed CLI reports a different package version", async () => {const { consumer } = await installedFixture("99.1.1");await expect(verifyInstalledPackage(consumer, process.env)).rejects.toThrow(@@ -59,3 +108,53 @@ test("fails when the installed CLI cannot start", async () => {"synthetic CLI startup failure",);});++test.each(["node", "./scripts/launch_codex_security_mcp"])(+ "initializes an installed plugin using %s",+ async (command) => {+ const pluginRoot = await directories.create("published plugin smoke ");+ await mkdir(join(pluginRoot, "mcp"));+ await mkdir(join(pluginRoot, "scripts"));+ await writeFile(+ join(pluginRoot, ".mcp.json"),+ JSON.stringify({+ mcpServers: {+ "codex-security": {+ command,+ args:+ command === "node"+ ? ["./mcp/server.mjs", "--stdio"]+ : ["--stdio"],+ cwd: ".",+ },+ },+ }),+ );+ await writeFile(+ join(pluginRoot, "mcp", "server.mjs"),+ `import assert from "node:assert/strict";+import { readFileSync, realpathSync } from "node:fs";+assert.equal(process.argv[2], "--stdio");+assert.equal(realpathSync(process.cwd()), realpathSync(process.env.SMOKE_PLUGIN_ROOT));+const request = JSON.parse(readFileSync(0, "utf8"));+assert.equal(request.method, "initialize");+console.log(JSON.stringify({ id: request.id, result: { serverInfo: { name: "codex-security" } } }));+`,+ );+ const launcher = join(pluginRoot, "scripts", "launch_codex_security_mcp");+ await writeFile(+ launcher,+ '#!/bin/sh\nexec "$CODEX_MCP_NODE_PATH" ./mcp/server.mjs "$@"\n',+ );+ await chmod(launcher, 0o755);+ await writeFile(+ `${launcher}.cmd`,+ '@echo off\r\n"%CODEX_MCP_NODE_PATH%" .\\mcp\\server.mjs %*\r\n',+ );+ await verifyInstalledPlugin(pluginRoot, {+ ...process.env,+ CODEX_MCP_NODE_PATH: process.execPath,+ SMOKE_PLUGIN_ROOT: pluginRoot,+ });+ },+);diff --git a/sdk/typescript/tests-ts/release-pr.test.ts b/sdk/typescript/tests-ts/release-pr.test.tsindex 515dfb1ce..caa0b936c 100644--- a/sdk/typescript/tests-ts/release-pr.test.ts+++ b/sdk/typescript/tests-ts/release-pr.test.ts@@ -24,9 +24,14 @@ type History = {baseCommit: string;mainSha: string;packageText: string;+ actionPackageText?: string | null;+ actionLockText?: string | null;changes: Change[];};-type Plan = Omit<History, "packageText"> & {+type Plan = Omit<+ History,+ "packageText" | "actionPackageText" | "actionLockText"+> & {version: string;branch: string;title: string;@@ -64,6 +69,8 @@ type Pull = {const script = new URL("../scripts/release-pr.mjs", import.meta.url);const {packagePath,+ actionPackagePath,+ actionLockPath,notesPath,statePath,isBreakingChange,@@ -75,6 +82,8 @@ const {reconcileReleasePullRequest,} = (await import(script.href)) as {packagePath: string;+ actionPackagePath: string;+ actionLockPath: string;notesPath: string;statePath: string;isBreakingChange: (change: Change) => boolean;@@ -131,6 +140,32 @@ function packageText(version = "0.1.23", dependencies = {}) {return `${JSON.stringify({ name: "@openai/codex-security", version, dependencies }, null, 2)}\n`;}+function actionFiles(dependencyVersion = "1.2.3") {+ const manifest = {+ name: "codex-security-action",+ version: "0.1.23",+ private: true,+ dependencies: { example: dependencyVersion },+ };+ const lock = {+ name: manifest.name,+ version: manifest.version,+ lockfileVersion: 3,+ packages: {+ "": manifest,+ "node_modules/example": {+ version: dependencyVersion,+ resolved: `https://registry.npmjs.org/example/-/example-${dependencyVersion}.tgz`,+ integrity: "sha512-c3ludGhldGlj",+ },+ },+ };+ return {+ [actionPackagePath]: `${JSON.stringify(manifest, null, 2)}\n`,+ [actionLockPath]: `${JSON.stringify(lock, null, 2)}\n`,+ };+}+function change(title: string,number = 1,@@ -982,6 +1017,41 @@ describe("human note ownership", () => {});describe("rolling release reconciliation", () => {+ test("aligns Action metadata when introduced and refreshed without advancing the published runtime pin", async () => {+ const fixture = new Fixture();+ fixture.merge("fix: initial fix");+ const beforeAction = await fixture.run();+ expect(beforeAction.plan.files[actionPackagePath]).toBeUndefined();+ expect(beforeAction.plan.files[actionLockPath]).toBeUndefined();++ const runtimePath = "github-action/runtime/package.json";+ const runtime = JSON.stringify({+ dependencies: { "@openai/codex-security": "0.1.23" },+ });+ for (const [title, files, version] of [+ ["feat: add Action", actionFiles(), "0.1.24"],+ ["feat!: change behavior", actionFiles("0.1.23"), "0.2.0"],+ ] as const) {+ fixture.merge(title, { ...files, [runtimePath]: runtime });+ const result = await fixture.run();+ expect(result.action).toBe("updated");+ expect(result.pull).toBe(beforeAction.pull);+ expect(JSON.parse(result.plan.files[packagePath]!).version).toBe(version);+ for (const [path, text] of Object.entries(files)) {+ const expected = JSON.parse(text);+ expected.version = version;+ if (path === actionLockPath) expected.packages[""].version = version;+ expect(JSON.parse(result.plan.files[path]!)).toEqual(expected);+ expect(fixture.repo.readFile(result.headSha!, path)).toBe(+ result.plan.files[path]!,+ );+ }+ expect(result.plan.files[runtimePath]).toBeUndefined();+ expect(fixture.repo.readFile(result.headSha!, runtimePath)).toBe(runtime);+ }+ expect((await fixture.run()).action).toBe("unchanged");+ });+test.each([true, false])("leaves an empty release cycle unchanged with dryRun=%p",async (dryRun) => {@@ -1459,6 +1529,30 @@ describe("rolling release reconciliation", () => {});describe("release proposal pauses", () => {+ test.each([+ { path: actionPackagePath, change: "dependencies" },+ { path: actionLockPath, change: "dependencies" },+ { path: actionLockPath, change: "deletion" },+ ])("preserves Action $change edits to $path", async ({ path, change }) => {+ const fixture = new Fixture();+ fixture.merge("feat: add Action", actionFiles());+ const first = await fixture.run();+ const edited = change === "deletion" ? null : actionFiles("2.0.0")[path]!;+ const humanSha = fixture.commit(+ first.plan.branch,+ { [path]: edited },+ "fix: adjust Action dependency",+ );+ fixture.merge("fix: another fix");+ const writes = fixture.github.writes.length;+ const result = await fixture.run();+ expect(result.action).toBe("held");+ expect(result.reason).toContain("package edits");+ expect(fixture.head(first.plan.branch)).toBe(humanSha);+ expect(fixture.repo.readFile(humanSha, path)).toBe(edited);+ expect(fixture.github.writes).toHaveLength(writes);+ });+test.each(["open", "closed"] as const)("keeps a retargeted %s proposal paused across workflow runs",async (state) => {diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.tsindex 21b4ee2d4..f136e01fc 100644--- a/sdk/typescript/tests-ts/skeleton.test.ts+++ b/sdk/typescript/tests-ts/skeleton.test.ts@@ -449,6 +449,13 @@ describe("TypeScript package skeleton", () => {args,});}+ for (let shard = 1; shard <= 7; shard += 1) {+ expect(runner.strategy?.matrix["include"]).toContainEqual({+ os: "windows-latest",+ mode: `isolated-${shard}`,+ args: `--isolate --shard=${shard}/7`,+ });+ }const command = runner.steps!.find((step) => step.name === "Test runner mode",)?.run;