diff --git a/.github/scripts/check-lockfile-release-age.mjs b/.github/scripts/check-lockfile-release-age.mjs index ac718d922ea..0a37cf255df 100644 --- a/.github/scripts/check-lockfile-release-age.mjs +++ b/.github/scripts/check-lockfile-release-age.mjs @@ -2,9 +2,8 @@ /** * check-lockfile-release-age.mjs * Decides whether the lockfile bot may merge refreshed pnpm lockfiles without review. - * Every package version that the refresh adds must be published on npm for at least - * the minimum age. A version that is too new, or that cannot be verified, holds the - * PR for a human. + * Every added version must have a verified npm publish time. Versions outside + * the harness allowlist must also meet the minimum age. * * Exports: parseLockfilePackages(text), addedPackageVersions(baseText, headText), * addedPackageVersionsAcross(pairs), @@ -28,6 +27,36 @@ const RESOLUTION = /^ {4}resolution: (.+?)\s*$/; // directory resolution names its own source and needs a human. const REGISTRY_RESOLUTION = /^\{integrity: [^,{}]+\}$/; const DAY_MS = 24 * 60 * 60 * 1000; +const HARNESS_PACKAGES = new Set([ + '@agentclientprotocol/claude-agent-acp', + '@agentclientprotocol/codex-acp', + '@anthropic-ai/claude-agent-sdk', + '@anthropic-ai/claude-agent-sdk-darwin-arm64', + '@anthropic-ai/claude-agent-sdk-darwin-x64', + '@anthropic-ai/claude-agent-sdk-linux-arm64', + '@anthropic-ai/claude-agent-sdk-linux-arm64-musl', + '@anthropic-ai/claude-agent-sdk-linux-x64', + '@anthropic-ai/claude-agent-sdk-linux-x64-musl', + '@anthropic-ai/claude-agent-sdk-win32-arm64', + '@anthropic-ai/claude-agent-sdk-win32-x64', + '@github/copilot-darwin-arm64', + '@github/copilot-darwin-x64', + '@github/copilot-linux-x64', + '@openai/codex', + 'opencode-ai', + 'opencode-darwin-arm64', + 'opencode-darwin-x64', + 'opencode-darwin-x64-baseline', + 'opencode-linux-arm64', + 'opencode-linux-arm64-musl', + 'opencode-linux-x64', + 'opencode-linux-x64-baseline', + 'opencode-linux-x64-baseline-musl', + 'opencode-linux-x64-musl', + 'opencode-windows-arm64', + 'opencode-windows-x64', + 'opencode-windows-x64-baseline', +]); /** Maps each key of the lockfile's top-level `packages:` section to its resolution. */ export function parseLockfilePackages(text) { @@ -122,7 +151,7 @@ async function holdReason({ name, version, resolution }, fetchPublishTime, now, } if (!published || Number.isNaN(published.getTime())) return 'no publish time on npm'; const ageMs = now.getTime() - published.getTime(); - if (ageMs < minAgeMs) { + if (ageMs < minAgeMs && !HARNESS_PACKAGES.has(name)) { return `published ${published.toISOString()} (${(ageMs / DAY_MS).toFixed(1)} days ago)`; } return null; @@ -131,14 +160,14 @@ async function holdReason({ name, version, resolution }, fetchPublishTime, now, export function formatReport(result, minAgeDays) { const lines = ['']; if (result.eligible) { - lines.push(`All ${result.checked} added package versions are at least ${minAgeDays} days old. The lockfile bot merges this PR.`); + lines.push(`All ${result.checked} added package versions passed the release-age gate. The lockfile bot merges this PR.`); } else { lines.push( `The lockfile bot did not merge this PR. These added package versions are newer than ${minAgeDays} days or could not be verified:`, '', ...result.held.map(({ key, reason }) => `- \`${key}\`: ${reason}`), '', - 'A maintainer can review and merge this PR. If no one does, the daily refresh tries again and merges it when every version is old enough.', + 'A maintainer can review and merge this PR. If no one does, the daily refresh tries again and merges it once the refresh passes the gate.', ); } return `${lines.join('\n')}\n`; diff --git a/.github/scripts/tests/check-lockfile-release-age.test.mjs b/.github/scripts/tests/check-lockfile-release-age.test.mjs index 0a79599c237..542ac325e44 100644 --- a/.github/scripts/tests/check-lockfile-release-age.test.mjs +++ b/.github/scripts/tests/check-lockfile-release-age.test.mjs @@ -150,6 +150,56 @@ test('holds a version newer than the minimum age', async () => { assert.match(result.held[0].reason, /0\.5 days ago/); }); +test('gives only named harness releases an exception to the minimum age', async () => { + const harnessKeys = [ + '@agentclientprotocol/claude-agent-acp@0.73.0', + '@agentclientprotocol/codex-acp@1.6.2', + '@anthropic-ai/claude-agent-sdk@0.3.328', + '@anthropic-ai/claude-agent-sdk-linux-x64-musl@0.3.328', + '@github/copilot-darwin-arm64@1.0.88', + '@openai/codex@0.170.0', + '@openai/codex@0.170.0-win32-arm64', + 'opencode-ai@1.18.34', + 'opencode-linux-x64-baseline-musl@1.18.34', + ]; + const harnesses = addedPackageVersions(lockfile([]), lockfile(harnessKeys)); + const other = addedPackageVersions(lockfile([]), lockfile([ + '@agentclientprotocol/sdk@1.9.0', + '@anthropic-ai/claude-agent-sdk-lookalike@1.0.0', + 'fresh@1.0.1', + ])); + const options = { fetchPublishTime: async () => daysAgo(0.5), now, minAgeMs: 3 * DAY_MS }; + + const result = await checkReleaseAge(harnesses, options); + assert.deepEqual(result, { eligible: true, checked: harnessKeys.length, held: [] }); + assert.match(formatReport(result, 3), /passed the release-age gate/); + + const mixed = await checkReleaseAge([...harnesses, ...other], options); + assert.equal(mixed.eligible, false); + assert.deepEqual(mixed.held.map(h => h.key), other.map(h => h.key)); +}); + +test('still requires a verified npm release for allowlisted names', async () => { + const entries = addedPackageVersions(lockfile([]), lockfile([ + '@openai/codex@0.170.0', + '@openai/codex@0.171.0', + ['@openai/codex@0.172.0', '{tarball: https://example.com/codex.tgz}'], + '@openai/codex@https://example.com/codex.tgz', + ])); + const result = await checkReleaseAge(entries, { + fetchPublishTime: timesFrom({ '@openai/codex@0.170.0': new Error('npm registry returned 503') }), + now, + minAgeMs: 3 * DAY_MS, + }); + assert.equal(result.eligible, false); + assert.deepEqual(result.held.map(h => h.reason), [ + 'registry lookup failed: npm registry returned 503', + 'no publish time on npm', + 'not a registry resolution: {tarball: https://example.com/codex.tgz}', + 'not a registry version', + ]); +}); + test('fails closed on lookup errors, missing publish times and non-registry versions', async () => { const entries = addedPackageVersions( lockfile([]), diff --git a/.github/workflows/refresh-lockfile.yml b/.github/workflows/refresh-lockfile.yml index c0c38edb5fd..e794d1d3bd4 100644 --- a/.github/workflows/refresh-lockfile.yml +++ b/.github/workflows/refresh-lockfile.yml @@ -206,7 +206,7 @@ jobs: ## Risks - The lockfile bot merges this PR without CI or review when every added package version is at least 3 days old on npm. Otherwise the PR waits for a maintainer, and the daily refresh tries again. The bot merges only the exact commit this workflow generated from manifests already reviewed on master. Unknown report lock baselines remain blocked. This update changes no permissions or paid enable gates. + The lockfile bot merges this PR without CI or review when it verifies every added version on npm and all versions outside the harness allowlist are at least 3 days old. Otherwise the PR waits for a maintainer, and the daily refresh tries again. The bot merges only the exact commit this workflow generated from manifests already reviewed on master. Unknown report lock baselines remain blocked. This update changes no permissions or paid enable gates. ## Model Used @@ -230,8 +230,8 @@ jobs: echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" # Resolution picks the newest matching version for any added or widened - # dependency. Merge without review only when every added version has been - # on npm long enough for a hijacked release to be caught and pulled. + # dependency. The gate verifies every added version on npm and enforces + # the age requirement outside the harness allowlist. - name: Check release age of added package versions id: release-age if: steps.upsert-pr.outputs.pr_url != '' diff --git a/doc/RELEASE-AUTOMATION-SETUP.md b/doc/RELEASE-AUTOMATION-SETUP.md index 9ea3f95fe4a..521b8ac2ea7 100644 --- a/doc/RELEASE-AUTOMATION-SETUP.md +++ b/doc/RELEASE-AUTOMATION-SETUP.md @@ -232,7 +232,9 @@ The reporting-lock proof (`tests/runner-e2e/report-lock.json` and `report-lock.p After a Dependabot lockfile merges, this workflow renews the proof. It first confirms three things: GitHub signed the merge commit, Dependabot opened the pull request, and the lockfile at the pull request head matches a verified Dependabot commit. It then records the merged lockfile in the proof and merges the refresh like any other. Paid evaluation jobs refuse the new lockfile until that refresh merges. -Resolution keeps locked versions, but it picks the newest matching version for an added or widened dependency. A release-age gate (`.github/scripts/check-lockfile-release-age.mjs`) therefore checks every package version that the refresh adds to any of the lockfiles. The bot merges only when each one has been on npm for at least 3 days. If any version is newer, or the gate cannot verify it, the bot leaves a comment on the PR and does not merge. A maintainer can review and merge it, or the daily scheduled refresh merges it after the versions are old enough. A held run saves its lockfiles, and the hashes of the `master` lockfiles it started from, as an artifact. The next run resolves from those lockfiles only while `master` still has every one of them unchanged. Held versions therefore stay put while their manifests are unchanged, even when newer releases appear, and a lockfile change on `master` replaces them. The gate also holds any added entry whose resolution is not a plain npm registry tarball. Change the age with `--min-age-days` in the workflow. +Resolution keeps locked versions, but it picks the newest matching version for an added or widened dependency. A release-age gate (`.github/scripts/check-lockfile-release-age.mjs`) therefore checks every package version that the refresh adds to any of the lockfiles. The gate requires a verified npm publish time for each added version. Versions outside the exact-name harness allowlist must also be at least 3 days old. If a version fails either requirement, the bot holds the PR and posts a comment. A maintainer can review and merge it, or the daily scheduled refresh can merge it once it passes the gate. A held run saves its lockfiles, and the hashes of the `master` lockfiles it started from, as an artifact. The next run resolves from those lockfiles only while `master` still has every one of them unchanged. Held versions therefore stay put while their manifests are unchanged, even when newer releases appear, and a lockfile change on `master` replaces them. The gate also holds any added entry whose resolution is not a plain npm registry tarball. Change the age with `--min-age-days` in the workflow. + +The allowlist covers the Codex CLI and Claude Agent SDK, their provider-specific ACP bridges, the OpenCode CLI, and the Copilot binaries pinned in the Runner manifest. Claude and OpenCode publish separate npm names for their platform binaries. Codex publishes its locked binaries under the `@openai/codex` name with platform suffixes on the versions. When a harness adds a platform package to a managed lockfile, review its exact npm name for inclusion in the allowlist. Pi and Kimi use separate npm lockfiles. The Gemini CLI package, Grok downloads, Cursor, and Antigravity use separate install paths outside the managed pnpm lockfiles. The merge uses a dedicated GitHub App. Do not reuse `commitperclip` or bypass the built-in `github-actions` app. Those identities are available to other workflows, including release jobs that run dependency install scripts, so a bypass for them would let any of those workflows land code on `master`.