From 903bb37aa0cbb299f2323c98ff3a1ad0774925f9 Mon Sep 17 00:00:00 2001 From: Alejandro Daniel Di Stefano Date: Tue, 10 Nov 2026 15:14:58 -0300 Subject: [PATCH] fix(release): recognize approved CI after GitHub clears merged PR associations GitHub Actions can return workflow_run.pull_requests=[] once a pull request has merged. Preserve strict release provenance without falsely rejecting successful exact-head CI: require merged PR identity, the expected SHA and repository, the CI workflow and event, pre-merge completion, successful status, matching Git tree, artifact manifest, version and VSIX SHA-256. Reject unrelated nonempty PR associations. Add regression coverage reproducing PR #4 -> CI #42871117473 and document the single-validation policy. Keep v0.2.0 because no 0.2.0 release was published. --- docs/RELEASE.md | 7 +++++++ scripts/release-provenance.mjs | 8 +++++++- test/release-provenance.test.cjs | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/RELEASE.md b/docs/RELEASE.md index e238b6a..1d48f6c 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -45,6 +45,13 @@ The flag was removed in the `0.1.1` release commit. `publish.yml` still fails in To prevent a single long mutation worker from exceeding runner availability, the PR CI executes the unchanged mutation sample in five independent jobs (11 ordinary targets plus four non-overlapping 10-mutant write-plan shards). The required `Verify (ubuntu-latest)` gate aggregates the complete sample and enforces all original score floors, including write-plan's 90%. Windows and macOS checks remain required, and package-preview waits for all three. No checks rerun after the merge. + +### GitHub Actions PR associations after merge + +GitHub can report `workflow_run.pull_requests: []` for a previously successful PR-triggered CI run **after** that PR is merged. This is a GitHub API metadata behavior, not a loss of the original CI result. The release provenance resolver accepts an empty association array **only after** it has independently identified the one merged PR for the actual `main` commit, and verified the run's exact PR head SHA, repository, `CI` workflow path, `pull_request` event, successful completion and pre-merge timestamp. A non-empty association array for another PR is rejected. The downloaded VSIX's manifest must then match the PR number, run ID, head SHA, merged Git tree, version and SHA-256. Missing fields, other repositories, stale runs or altered bytes continue to block publishing. + +This allows safe recovery from the failed 0.2.0 publish after PR #4 without re-running any tests on `main`. If 0.2.0 has not yet been published, an ordinary new PR containing only the provenance fix may keep the version at 0.2.0; merging the successful follow-up PR starts the publish workflow using its own validated VSIX. Do **not** bump to 0.2.1 solely to repair a release that was never shipped. + ## Release checklist 1. Feature, security, privacy, accessibility and i18n acceptance complete (`ENTERPRISE_AAAA_STATUS.md`). diff --git a/scripts/release-provenance.mjs b/scripts/release-provenance.mjs index 756ac2f..0fa579d 100644 --- a/scripts/release-provenance.mjs +++ b/scripts/release-provenance.mjs @@ -22,10 +22,16 @@ export function selectMergedPr(prs, sha) { } export function selectSuccessfulRun(runs, pr) { + // GitHub can clear workflow_run.pull_requests after the PR is merged. An empty array + // is NOT proof that a run was unrelated: the authoritative link is the merged PR's + // exact head SHA, verified repository, workflow, event and pre-merge timestamp. + // A non-empty association MUST still contain the expected PR number. + const associated = (run) => Array.isArray(run.pull_requests) && + (run.pull_requests.length === 0 || run.pull_requests.some((p) => p.number === pr.number)); const matches = runs.filter((r) => r.status === 'completed' && r.conclusion === 'success' && r.event === 'pull_request' && r.path === '.github/workflows/ci.yml' && r.head_sha === pr.head.sha && r.head_repository?.full_name === pr.base.repo.full_name && - r.pull_requests?.some((p) => p.number === pr.number) && + associated(r) && new Date(r.created_at).getTime() <= new Date(pr.merged_at).getTime() && numberId(r.id)); matches.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); assert(matches.length, 'no successful pre-merge PR CI for the exact head'); diff --git a/test/release-provenance.test.cjs b/test/release-provenance.test.cjs index adce477..ee655b1 100644 --- a/test/release-provenance.test.cjs +++ b/test/release-provenance.test.cjs @@ -16,10 +16,14 @@ test('release: only actual merged PR and successful pre-merge exact-head CI qual const { selectMergedPr, selectSuccessfulRun } = await load(); assert.equal(selectMergedPr([pr], sha('a')).number, 4); assert.equal(selectSuccessfulRun([run], pr).id, 123); + // Real GitHub Actions behavior after closing PR #4: pull_requests becomes []. + // That does not invalidate the successful exact-head run (run #42871117473). + assert.equal(selectSuccessfulRun([{ ...run, pull_requests: [] }], pr).id, 123); for (const change of [ { conclusion: 'failure' }, { conclusion: 'cancelled' }, { event: 'push' }, { head_sha: sha('c') }, { path: '.github/workflows/publish.yml' }, - { pull_requests: [{ number: 99 }] }, { created_at: '2026-11-10T20:00:00Z' }, + { pull_requests: [{ number: 99 }] }, { pull_requests: undefined }, + { created_at: '2026-11-10T20:00:00Z' }, ]) assert.throws(() => selectSuccessfulRun([{ ...run, ...change }], pr)); assert.throws(() => selectMergedPr([{ ...pr, base: { ref: 'develop' } }], sha('a'))); assert.throws(() => selectMergedPr([{ ...pr, merge_commit_sha: sha('c') }], sha('a')));