From 7f4ea7d003b84a46b1fa9ad4ef90a5dc2b5ec497 Mon Sep 17 00:00:00 2001 From: Nathaniel Pawelczyk Date: Wed, 2 Dec 2026 18:26:05 -0600 Subject: [PATCH] Fix: CI's module scope rule lets a base/-next promotion into main carry the base and modules together Co-Authored-By: Claude Opus 5.5 --- changelog/2026-12-02-base-next-promotion-scope.md | 1 + scripts/check.mjs | 5 +++-- scripts/pr-ready.mjs | 10 +++++++--- scripts/pr-ready.test.mjs | 8 +++++++- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 changelog/2026-12-02-base-next-promotion-scope.md diff --git a/changelog/2026-12-02-base-next-promotion-scope.md b/changelog/2026-12-02-base-next-promotion-scope.md new file mode 100644 index 0000000000..b3d33411b3 --- /dev/null +++ b/changelog/2026-12-02-base-next-promotion-scope.md @@ -0,0 +1 @@ +CI: a machine's cumulative base pull request (base/-next into main) is no longer refused for changing the base and a module together. Each change on that branch already passed the rule in its own pull request into it. A check that judges modules is still refused there. diff --git a/scripts/check.mjs b/scripts/check.mjs index 96d721c20e..d29b207232 100644 --- a/scripts/check.mjs +++ b/scripts/check.mjs @@ -13,7 +13,7 @@ import { checkDocs } from './docs.mjs' import { appStagesFit, takeSlot, vitestWorkerBytes, workersFor } from './machine-slots.mjs' import { m68kToolchainProblem } from './m68k-preflight.mjs' import { checkModuleChangelogs } from './module-changelogs.mjs' -import { localPythonProblem, moduleScopeProblems } from './pr-ready.mjs' +import { BASE_NEXT, localPythonProblem, moduleScopeProblems } from './pr-ready.mjs' const root = fileURLToPath(new URL('../', import.meta.url)) const npmCli = process.env.npm_execpath @@ -193,7 +193,8 @@ if (passed && !suiteOnly) passed = await changelogs() if (passed && !suiteOnly && base && process.env.GITHUB_EVENT_PATH) { const pull = (() => { try { return JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')).pull_request ?? null } catch { return null } })() const files = execFileSync('git', ['diff', '--name-only', '--no-renames', base + '...HEAD'], { cwd: root, encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 }).split('\n').filter(Boolean) - const problems = pull ? moduleScopeProblems(files, { author: pull.user?.login, owner: process.env.GITHUB_REPOSITORY_OWNER, openedAt: pull.created_at }) : [] + const problems = pull ? moduleScopeProblems(files, { author: pull.user?.login, owner: process.env.GITHUB_REPOSITORY_OWNER, openedAt: pull.created_at, + promotion: pull.base?.ref === 'main' && BASE_NEXT.test(pull.head?.ref ?? '') && pull.head?.repo?.full_name === pull.base?.repo?.full_name }) : [] for (const line of problems) problem('Module scope', 'Module scope: ' + line) if (problems.length) passed = false } diff --git a/scripts/pr-ready.mjs b/scripts/pr-ready.mjs index f21487e1bd..4539325d3c 100644 --- a/scripts/pr-ready.mjs +++ b/scripts/pr-ready.mjs @@ -44,10 +44,14 @@ export function baseEdits(files) { // CI refuses both in contributors' module pull requests opened from this day; earlier ones and the owner's are judged in review. export const MODULE_SCOPE_REQUIRED_FROM = '2026-11-09' -/** CI's refusals for one pull request: [] for the owner's, for one opened before MODULE_SCOPE_REQUIRED_FROM, or for one in scope. */ -export function moduleScopeProblems(files, { author = null, owner = null, openedAt = null } = {}) { +/** A machine's cumulative base branch, base/-next. */ +export const BASE_NEXT = /^base\/[^/]+-next$/ +/** CI's refusals for one pull request: [] for the owner's, for one opened before MODULE_SCOPE_REQUIRED_FROM, or for one in scope. + * `promotion` marks the cumulative pull request from base/-next in the same repository into main: every base and module + * change on that branch passed this rule in its own pull request into it, so together they are not refused for touching both. */ +export function moduleScopeProblems(files, { author = null, owner = null, openedAt = null, promotion = false } = {}) { if (!author || author.toLowerCase() === owner?.toLowerCase() || (openedAt ?? '').slice(0, 10) < MODULE_SCOPE_REQUIRED_FROM) return [] - const problems = [], gates = gateEdits(files), base = baseEdits(files) + const problems = [], gates = gateEdits(files), base = promotion ? [] : baseEdits(files) if (gates.length) problems.push(gateProblem(gates)) if (base.length) problems.push(baseProblem(base)) return problems diff --git a/scripts/pr-ready.test.mjs b/scripts/pr-ready.test.mjs index 6edcc669f2..b11ec17f69 100644 --- a/scripts/pr-ready.test.mjs +++ b/scripts/pr-ready.test.mjs @@ -3,7 +3,7 @@ import { execFileSync, spawnSync } from 'node:child_process' import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' -import { MODULE_SCOPE_REQUIRED_FROM, baseEdits, checkAndCommit, forkVisibilityNote, gateEdits, mergeMain, moduleScopeProblems, pythonProblem, readiness, releaseBranchNotes, targetBranch, PACKAGE_ONLY } from './pr-ready.mjs' +import { BASE_NEXT, MODULE_SCOPE_REQUIRED_FROM, baseEdits, checkAndCommit, forkVisibilityNote, gateEdits, mergeMain, moduleScopeProblems, pythonProblem, readiness, releaseBranchNotes, targetBranch, PACKAGE_ONLY } from './pr-ready.mjs' describe('pr:ready verdict', () => { it('merges a clean main itself and leaves a conflicting one untouched, naming its files', () => { @@ -222,6 +222,12 @@ describe('pr:ready verdict', () => { expect(moduleScopeProblems(files, { ...contributor, openedAt: '2026-11-07T10:00:00Z' })).toEqual([]) expect(moduleScopeProblems(files, { ...contributor, author: null })).toEqual([]) expect(moduleScopeProblems(['sdk/drafts/threshold-slices/README.md'], contributor)).toEqual([]) + // A base/-next promotion into main carries modules and the base together; a check that judges modules is still refused. + expect(moduleScopeProblems(files, { ...contributor, promotion: true })).toEqual([moduleScopeProblems(files.filter(file => file !== 'sdk/machines/octatrack/events.json'), contributor)[0]]) + expect(moduleScopeProblems(files.slice(0, 2), { ...contributor, promotion: true })).toEqual([]) + expect(BASE_NEXT.test('base/analog-rytm-mkii-next')).toBe(true) + expect(BASE_NEXT.test('base/analog-rytm-mkii-next/topic')).toBe(false) + expect(BASE_NEXT.test('claude/base-next')).toBe(false) }) it('says which packages CI rebuilds and how to reproduce them before the push', () => { expect(readiness({ compiled: { octatrack: true, elemod: false } }).notes.some(note => note.includes('build-modules-isolated.sh'))).toBe(true)