diff --git a/.github/actions/publish-mcp/registry-state.mjs b/.github/actions/publish-mcp/registry-state.mjs index e3a32867b4..fe19edd30b 100644 --- a/.github/actions/publish-mcp/registry-state.mjs +++ b/.github/actions/publish-mcp/registry-state.mjs @@ -3,6 +3,24 @@ import { appendFile, readFile } from "node:fs/promises"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; +function readRegistryPage(page) { + assert(Array.isArray(page?.servers), "Registry response omitted servers"); + const { servers, metadata } = page; + assert( + metadata && typeof metadata === "object" && !Array.isArray(metadata), + "Registry response omitted or malformed metadata", + ); + if (metadata.count !== undefined) + assert.equal( + metadata.count, + servers.length, + "Registry page count does not match its server records", + ); + const cursor = metadata.nextCursor ?? ""; + assert(typeof cursor === "string", "Registry returned an invalid cursor"); + return { servers, nextCursor: cursor || undefined }; +} + /** Exact-version routes currently return false 404s; enumerate the filtered listing. */ export async function registryPublicationState(server, request = fetch) { assert.equal(typeof server?.name, "string"); @@ -26,13 +44,8 @@ export async function registryPublicationState(server, request = fetch) { }); if (!response.ok) throw new Error(`Registry lookup failed: HTTP ${response.status}`); - const page = await response.json(); - assert(Array.isArray(page?.servers), "Registry response omitted servers"); - assert( - page.metadata && typeof page.metadata === "object", - "Registry response omitted metadata", - ); - for (const entry of page.servers) { + const { servers, nextCursor } = readRegistryPage(await response.json()); + for (const entry of servers) { assert( typeof entry?.server?.name === "string" && typeof entry.server.version === "string", @@ -44,12 +57,9 @@ export async function registryPublicationState(server, request = fetch) { ) matches.push(entry); } - cursor = page.metadata.nextCursor; + cursor = nextCursor; if (cursor !== undefined) { - assert( - typeof cursor === "string" && cursor.length > 0 && !cursors.has(cursor), - "Registry returned a non-advancing cursor", - ); + assert(!cursors.has(cursor), "Registry returned a non-advancing cursor"); cursors.add(cursor); } } while (cursor !== undefined); diff --git a/scripts/ci/change-plan.mjs b/scripts/ci/change-plan.mjs index f9f9575c8f..d97f7a8397 100644 --- a/scripts/ci/change-plan.mjs +++ b/scripts/ci/change-plan.mjs @@ -304,10 +304,12 @@ export function planChanges(request, repository) { .filter(([, { paths }]) => matchesAny(file, paths)) .map(([owner]) => owner); for (const owner of owners) selected[owner] = true; + // Workflow callers can become invalid when local action inputs or outputs change. + selected.workflows ||= /^\.github\/actions\/.+\/action\.ya?ml$/u.test(file); if ( file.startsWith(".github/workflows/") || file.startsWith(".github/codeql/") || - file === ".github/actionlint.yaml" + /^\.github\/actionlint\.ya?ml$/u.test(file) ) { selected.workflows = true; if (GUARDED_WORKFLOWS.has(file) || file.startsWith(".github/codeql/")) diff --git a/scripts/ci/scopes.mjs b/scripts/ci/scopes.mjs index 1871017573..333ffa9c33 100644 --- a/scripts/ci/scopes.mjs +++ b/scripts/ci/scopes.mjs @@ -20,6 +20,8 @@ const CAPTURE_SHARED_INPUTS = [ "src/process/LinuxResourceLimits*", "scripts/ci/require-provider-tests.mjs", ]; +const UBUNTU_ARCHIVE_ACTION = + ".github/actions/ubuntu-archive/action.{yml,yaml}"; // Ownership of the native-host, real-provider and website verification lanes. // Shared build inputs are classified once in plan.mjs rather than repeated in @@ -68,8 +70,8 @@ const PATH_SCOPES = { ...CAPTURE_SHARED_INPUTS, "scripts/verify-signal-recording.mjs", ".github/workflows/real-signal-recording.yml", - ".github/actions/ubuntu-archive/action.yml", - ".github/actions/host-apt-packages/action.yml", + UBUNTU_ARCHIVE_ACTION, + ".github/actions/host-apt-packages/action.{yml,yaml}", ], readiness: [ "tests/conformance/readiness/**", @@ -249,9 +251,9 @@ const PATH_SCOPES = { "scripts/verify-package-*", "scripts/verify-packed-bridge.*", "scripts/verify-windows-*.mjs", - ".github/actions/windows-cross-compiler/action.yml", - ".github/actions/ubuntu-archive/action.yml", - ".github/actions/host-apt-packages/action.yml", + ".github/actions/windows-cross-compiler/action.{yml,yaml}", + UBUNTU_ARCHIVE_ACTION, + ".github/actions/host-apt-packages/action.{yml,yaml}", "scripts/build-windows-native.mjs", "scripts/windows-capabilities.mjs", "scripts/prepack.mjs", @@ -441,8 +443,8 @@ const PATH_SCOPES = { ], binary_layout: [ ".github/workflows/real-binary-layout.yml", - ".github/actions/ubuntu-archive/action.yml", - ".github/actions/host-apt-packages/action.yml", + UBUNTU_ARCHIVE_ACTION, + ".github/actions/host-apt-packages/action.{yml,yaml}", "bridge/pwntools/**", "src/native/pwntools/**", "src/config/pwntoolsInputLimit*.ts", diff --git a/scripts/lib/release-checkpoint.mjs b/scripts/lib/release-checkpoint.mjs index 2456b1d7b9..3bfcdcb968 100644 --- a/scripts/lib/release-checkpoint.mjs +++ b/scripts/lib/release-checkpoint.mjs @@ -1,6 +1,10 @@ import { gt, major, valid } from "semver"; import { z } from "zod"; -import { releaseSection } from "./release-markdown.mjs"; +import { + releaseBreakingFooters, + releaseMigrationWording, + releaseSection, +} from "./release-markdown.mjs"; const shaSchema = z.string().regex(/^[a-f0-9]{40}$/u); const versionSchema = z.object({ version: z.string() }); @@ -107,22 +111,15 @@ function readCommits(text) { const body = z.string().parse(fields[index + 2]); const title = conventionalTitle(subject, body); const type = /^([a-z]+)(?:\([^)]*\))?!?: /u.exec(title)?.[1]; + const breakingNotes = releaseBreakingFooters(body); commits.push({ sha, subject, ...(title !== subject ? { conventionalTitle: title } : {}), type, breaking: - /^[a-z]+(?:\([^)]*\))?!: /u.test(title) || - /^BREAKING(?: CHANGE|-CHANGE):\s*\S/mu.test(body), - breakingNotes: Array.from( - body - .replace(/\r\n/gu, "\n") - .matchAll( - /^BREAKING(?: CHANGE|-CHANGE):[ \t]*(\S[^\n]*(?:\n(?!\n|[A-Za-z-]+: )[^\n]+)*)/gmu, - ), - (match) => match[1].replace(/\s+/gu, " ").trim(), - ), + /^[a-z]+(?:\([^)]*\))?!: /u.test(title) || breakingNotes.length > 0, + breakingNotes, }); } return commits; @@ -143,17 +140,29 @@ function releaseNotes(text, expectedVersion) { const section = releaseSection(text, expectedVersion); if (section === undefined) throw new Error(`CHANGELOG.md must start with release ${expectedVersion}.`); - return section.lines.map(({ line }) => line).join("\n"); + return section.blocks; } -function breakingSection(notes) { - const heading = /^### [^\n]*BREAKING CHANGES[^\n]*\n/imu.exec(notes); - if (heading === null) return ""; - const body = notes.slice(heading.index + heading[0].length); - const end = body.search(/^### /mu); +function breakingSection(blocks) { + const start = blocks.findIndex(({ heading }) => + /^### .*BREAKING CHANGES/iu.test(heading ?? ""), + ); + if (start === -1) return []; + const body = blocks.slice(start + 1); + const end = body.findIndex(({ heading }) => heading?.startsWith("### ")); return end < 0 ? body : body.slice(0, end); } +function referenceProse(blocks) { + return blocks + .map(({ parts }) => + parts + .map(({ text, href }) => (href ? `${text} ${href} ` : text)) + .join(""), + ) + .join("\n"); +} + async function requireAncestor(git, ancestor, descendant, description) { try { await git(["merge-base", "--is-ancestor", ancestor, descendant]); @@ -304,22 +313,22 @@ async function validateCandidate(git, sha, version, commits) { version, ); const breakingNotes = breakingSection(notes); - const normalizedBreakingNotes = breakingNotes.replace(/\s+/gu, " "); + const breakingReferences = referenceProse(breakingNotes); + const containsMigrationWording = releaseMigrationWording(breakingNotes); const missingBreaking = commits.filter( (commit) => commit.breaking && - !referencesCommit(breakingNotes, commit) && + !referencesCommit(breakingReferences, commit) && (commit.breakingNotes.length === 0 || - commit.breakingNotes.some( - (note) => !normalizedBreakingNotes.includes(note), - )), + !commit.breakingNotes.every(containsMigrationWording)), ); if (missingBreaking.length > 0) { throw new Error( `Release ${version} migration notes omit unreleased breaking changes: ${missingBreaking.map((commit) => `${commit.sha} ${commit.subject}`).join("; ")}`, ); } - return commits.filter((commit) => !referencesCommit(notes, commit)); + const references = referenceProse(notes); + return commits.filter((commit) => !referencesCommit(references, commit)); } /** Validate a recorded checkpoint and optional candidate using exact Git ancestry. */ diff --git a/scripts/lib/release-markdown.mjs b/scripts/lib/release-markdown.mjs index d8f9607bcd..c5ffa07cd8 100644 --- a/scripts/lib/release-markdown.mjs +++ b/scripts/lib/release-markdown.mjs @@ -1,47 +1,259 @@ import MarkdownIt from "markdown-it"; const parser = new MarkdownIt("commonmark"); -const nonProseBlocks = new Set(["fence", "code_block", "html_block"]); +const proseSeparators = new Set([ + "softbreak", + "hardbreak", + "code_inline", + "html_inline", + "image", +]); + +function inlineFacts(tokens) { + const parts = []; + const wording = []; + let link; + for (const token of tokens) { + if (token.type === "link_open") { + link = { href: token.attrGet("href"), text: "" }; + parts.push(link); + wording.push({ kind: "link-open", content: link.href }); + } else if (token.type === "link_close") { + wording.push({ kind: "link-close" }); + link = undefined; + } else { + const text = + token.type === "text" + ? token.content + : proseSeparators.has(token.type) + ? " " + : ""; + if (link) link.text += text; + else if (text) parts.push({ text }); + if (token.type === "code_inline" || token.type === "html_inline") + wording.push({ kind: token.type, content: token.content }); + else if (text) wording.push(text); + } + } + return { parts, wording }; +} + +const breakingFooter = /^BREAKING(?: CHANGE|-CHANGE):[ \t]*(.*)$/u; +const otherTrailer = /^[A-Za-z][A-Za-z0-9-]*(?::[ \t]| #)/u; + +function literalBlockKind(type) { + if (type === "fence" || type === "code_block") return "code-block"; + if (type === "html_block") return "html-block"; +} + +function literalBlockLines(lines, start) { + const covered = new Set(); + for (const { type, map } of parser.parse(lines.slice(start).join("\n"), {})) { + if (literalBlockKind(type) === undefined) continue; + for (let line = map[0]; line < map[1]; line++) covered.add(start + line); + } + return covered; +} + +export function releaseBreakingFooters(body) { + const lines = body.split(/\r\n?|\n/u); + if (!lines.some((line) => breakingFooter.test(line))) return []; + + const footers = []; + let footer; + let literalLines = literalBlockLines(lines, 0); + for (const [index, line] of lines.entries()) { + if (!literalLines.has(index)) { + const match = breakingFooter.exec(line); + if (match !== null) { + footer = { start: index, end: index }; + footers.push(footer); + // Read the Markdown value from its first character, including a fence + // that starts on the same line as the trailer label. + lines[index] = match[1]; + literalLines = literalBlockLines(lines, index); + } else if (otherTrailer.test(line)) { + footer = undefined; + } + } + if ( + footer !== undefined && + (lines[index].trim() !== "" || literalLines.has(index)) + ) + footer.end = index + 1; + } + return footers + .map(({ start, end }) => lines.slice(start, end).join("\n")) + .filter((value) => value.trim() !== ""); +} + +function blockFacts(tokens, index) { + const { type, content } = tokens[index]; + if (type === "paragraph_open" || type === "heading_open") + return inlineFacts(tokens[index + 1].children); + const kind = literalBlockKind(type); + if (kind !== undefined) { + // HTML tokens include the line ending after the block when it is present. + const wording = + kind === "html-block" ? content.replace(/\n$/u, "") : content; + return { parts: [], wording: [{ kind, content: wording }] }; + } +} + +function releaseVersion({ type, level, tag }, source) { + if (type === "heading_open" && level === 0 && tag === "h2") + return /^## \[([^\]]+)\]/u.exec(source.line)?.[1]; +} export function releaseSection(markdown, expectedVersion) { // The parser maps block tokens to line intervals. Use the original lines // to retain source offsets and publish the selected Markdown verbatim. const lines = Array.from( markdown.matchAll(/([^\r\n]*)(?:\r\n?|\n|$)/gu), - (match, index) => ({ line: match[1], offset: match.index, index }), + (match) => ({ line: match[1], offset: match.index }), ); - const excluded = new Set(); + const blocks = []; + const tokens = parser.parse(markdown, {}); let start; - let end = lines.length; - for (const { type, level, tag, map } of parser.parse(markdown, {})) { - if (!map) continue; - const [first, limit] = map; - if (nonProseBlocks.has(type)) { - for (let index = first; index < limit; index++) excluded.add(index); + let end = markdown.length; + let item; + for (const [index, { type, level, tag, map, markup }] of tokens.entries()) { + const source = map && lines[map[0]]; + const version = releaseVersion({ type, level, tag }, source); + if (version !== undefined) { + if (start !== undefined) { + end = source.offset; + break; + } + if (version !== expectedVersion) return undefined; + start = source.offset; continue; } - if (type !== "heading_open" || level !== 0 || tag !== "h2") continue; - const version = /^## \[([^\]]+)\]/u.exec(lines[first].line)?.[1]; - if (version === undefined) continue; - if (start !== undefined) { - end = first; - break; + if (start === undefined) continue; + if (type === "list_item_open" && level === 1 && /^[-*+]$/u.test(markup)) { + item = source.offset; + } else if (type === "list_item_close" && level === 1) { + item = undefined; + } + const facts = blockFacts(tokens, index); + if (facts !== undefined) { + blocks.push({ + offset: source.offset - start, + heading: + type === "heading_open" && level === 0 ? source.line : undefined, + item: type === "paragraph_open" && level === 2 ? item : undefined, + ...facts, + }); } - if (version !== expectedVersion) return undefined; - start = first; } if (start === undefined) return undefined; - const sectionOffset = lines[start].offset; - return { - source: markdown.slice( - sectionOffset, - lines[end]?.offset ?? markdown.length, - ), - lines: lines - .slice(start, end) - .filter(({ index }) => !excluded.has(index)) - .map(({ line, offset }) => ({ line, offset: offset - sectionOffset })), + return { source: markdown.slice(start, end), blocks }; +} + +export function releaseBullets(blocks) { + const bullets = new Map(); + for (const { item, parts } of blocks) { + if (item === undefined) continue; + const bullet = bullets.get(item); + if (bullet) { + bullet.push({ text: " " }); + for (const part of parts) bullet.push(part); + } else { + bullets.set(item, [...parts]); + } + } + return bullets.values(); +} + +function migrationProjection(blocks) { + const chunks = []; + const literals = new Map(); + const links = []; + let position = 0; + let space = false; + let link; + + function append(text) { + if (space && position > 0) { + chunks.push(" "); + position++; + } + space = false; + if (link) link.start ??= position; + chunks.push(text); + position += text.length; + } + + for (const { wording } of blocks) { + for (const part of wording) { + if (typeof part === "string") { + const prose = part.replace(/\s+/gu, " "); + if (prose.startsWith(" ")) space = true; + const text = prose.trim(); + if (text) append(text); + if (prose.endsWith(" ")) space = true; + } else if (part.kind === "link-open") { + link = { href: part.content, start: undefined }; + } else if (part.kind === "link-close") { + links.push({ + href: link.href, + start: link.start ?? position, + end: position, + }); + link = undefined; + } else { + // Markdown-it replaces source NULs. Reserve one position for each + // literal and compare its kind and exact content at that position. + append("\0"); + literals.set(position - 1, part); + } + } + space = true; + } + + return { text: chunks.join(""), literals, links }; +} + +function linkKey(start, end, href) { + return JSON.stringify([start, end, href]); +} + +/** Match footer prose and literals, then verify links at their label positions. */ +export function releaseMigrationWording(blocks) { + const observed = migrationProjection(blocks); + const observedLinks = new Set( + observed.links.map(({ start, end, href }) => linkKey(start, end, href)), + ); + return (footer) => { + const tokens = parser.parse(footer, {}); + const expected = migrationProjection( + tokens + .map((_token, index) => blockFacts(tokens, index)) + .filter((facts) => facts !== undefined), + ); + if (expected.text === "" && expected.links.length === 0) return false; + + for (let from = 0; from <= observed.text.length;) { + const offset = observed.text.indexOf(expected.text, from); + if (offset === -1) return false; + const linksMatch = expected.links.every(({ start, end, href }) => + observedLinks.has(linkKey(start + offset, end + offset, href)), + ); + if (linksMatch) { + const literalsMatch = [...expected.literals].every( + ([position, part]) => { + const actual = observed.literals.get(position + offset); + return ( + actual?.kind === part.kind && actual.content === part.content + ); + }, + ); + if (literalsMatch) return true; + } + from = offset + 1; + } + return false; }; } diff --git a/scripts/lib/release-notes.mjs b/scripts/lib/release-notes.mjs index f8abf4b0cd..c72cc7f987 100644 --- a/scripts/lib/release-notes.mjs +++ b/scripts/lib/release-notes.mjs @@ -1,7 +1,7 @@ import { createRequire } from "node:module"; import { valid } from "semver"; import { z } from "zod"; -import { releaseSection } from "./release-markdown.mjs"; +import { releaseBullets, releaseSection } from "./release-markdown.mjs"; const sha = z.string().regex(/^[a-f0-9]{40}$/u); const actor = z.object({ @@ -185,23 +185,42 @@ function readReleaseSection(text, version) { return section; } -function bulletPrs(bullet, repository) { - // Resolve explicit links first so cross-repository numbers cannot acquire local credit. - const local = []; - const withoutLinks = bullet.replace( - /\[([^\]]*)\]\(https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:pull|issues)\/(\d+)\)/gu, - (_match, _label, repo, number) => { - if (repo.toLowerCase() === repository.toLowerCase()) - local.push(Number(number)); - return ""; - }, +function bulletCredits(parts, repository) { + const references = new Set(); + const links = []; + let prose = ""; + let localProse = ""; + for (const { text, href } of parts) { + prose += text; + if (href) links.push(href); + const reference = + /^https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:pull|issues)\/(\d+)$/u.exec( + href ?? "", + ); + if (reference) { + // Use the destination's repository and number instead of its display label. + if (reference[1].toLowerCase() === repository.toLowerCase()) + references.add(Number(reference[2])); + localProse += " "; + } else { + localProse += text; + } + } + for (const match of localProse.matchAll(/(? match[1].toLowerCase(), + ), ); - for (const match of withoutLinks.matchAll(/(? references.has(item.number), @@ -214,7 +233,7 @@ function requiredCredits(inventory, bullet, references) { (issue.repository.nameWithOwner.toLowerCase() === inventory.repository.toLowerCase() && references.has(issue.number)) || - bullet.includes(`](${issue.url})`); + links.includes(issue.url); const handle = human(issue.author); if (mentioned && handle) required.push({ @@ -222,9 +241,11 @@ function requiredCredits(inventory, bullet, references) { context: `issue ${issue.repository.nameWithOwner}#${issue.number}`, }); } - for (const match of bullet.matchAll( - /https:\/\/github\.com\/([^/]+\/[^/]+)\/commit\/([a-f0-9]{7,40})\b/gu, - )) { + for (const match of [prose, ...links] + .join(" ") + .matchAll( + /https:\/\/github\.com\/([^/]+\/[^/]+)\/commit\/([a-f0-9]{7,40})\b/gu, + )) { if (match[1].toLowerCase() !== inventory.repository.toLowerCase()) continue; const matches = inventory.commits.filter((item) => item.sha.startsWith(match[2]), @@ -241,7 +262,7 @@ function requiredCredits(inventory, bullet, references) { return required; } -function verifyEditorialCredits(inventory, prose) { +function verifyEditorialCredits(inventory, bullets) { const known = new Set(inventory.pullRequests.map((pr) => pr.number)); const issues = new Set( inventory.pullRequests.flatMap((pr) => @@ -265,25 +286,13 @@ function verifyEditorialCredits(inventory, prose) { const errors = []; const requiredByContext = new Map(); const thankedByContext = new Map(); - for (const bullet of prose) { - if (!/^[-*] /u.test(bullet)) continue; - const references = bulletPrs(bullet, inventory.repository); - const start = bullet.indexOf("Thanks "); - const thanked = new Set( - [ - ...bullet - .slice(start < 0 ? bullet.length : start) - .matchAll(/@([A-Za-z0-9-]+(?:\[bot\])?)/gu), - ].map((match) => match[1].toLowerCase()), - ); + for (const parts of bullets) { + const bullet = bulletCredits(parts, inventory.repository); + const { references, thanked } = bullet; for (const number of references) if (!known.has(number) && !issues.has(number)) errors.push(`Unknown release reference #${number}`); - for (const { handle, context } of requiredCredits( - inventory, - bullet, - references, - )) { + for (const { handle, context } of requiredCredits(inventory, bullet)) { const required = requiredByContext.get(context) ?? new Set(); required.add(handle); requiredByContext.set(context, required); @@ -302,26 +311,28 @@ function verifyEditorialCredits(inventory, prose) { return errors; } -function editorialReleaseLines(notes, lines, inventory) { +function editorialReleaseBlocks(notes, blocks, inventory) { const record = contributionRecord(inventory).trim(); const summary = contributionSummary(inventory).trim(); const summaryOffset = notes.length - summary.length; const expected = notes.endsWith(summary) ? summary : record; const contributionStart = expected === summary - ? lines.find(({ offset }) => offset === summaryOffset) - : lines.find(({ line }) => line === "### Complete contribution record"); + ? blocks.find(({ offset }) => offset === summaryOffset) + : blocks.find( + ({ heading }) => heading === "### Complete contribution record", + ); const start = contributionStart?.offset; if (start === undefined || notes.slice(start).trim() !== expected) throw new Error( "Contribution record differs from inventory; regenerate it with release-notes record", ); - return lines.filter(({ offset }) => offset < start).map(({ line }) => line); + return blocks.filter(({ offset }) => offset < start); } export function verifyReleaseNotes(raw, text, body) { const inventory = releaseInventorySchema.parse(raw); - const { source, lines } = readReleaseSection(text, inventory.version); + const { source, blocks } = readReleaseSection(text, inventory.version); const notes = source.trim(); // Release Please's inline issue/PR body limit (pull-request-overflow-handler). if (notes.length > 65_536 || (body !== undefined && body.length > 65_536)) @@ -332,10 +343,10 @@ export function verifyReleaseNotes(raw, text, body) { throw new Error( "Release notes exceed GitHub's body budget; shorten prose without dropping credit", ); - const prose = editorialReleaseLines(notes, lines, inventory); - const errors = verifyEditorialCredits(inventory, prose); + const editorial = editorialReleaseBlocks(notes, blocks, inventory); + const errors = verifyEditorialCredits(inventory, releaseBullets(editorial)); for (const heading of ["Highlights", "Changes", "Fixes"]) - if (!prose.includes(`### ${heading}`)) + if (!editorial.some((block) => block.heading === `### ${heading}`)) errors.push(`Missing ${heading} section`); if (body !== undefined) { // Use the publisher's parser: finding a heading alone does not establish diff --git a/tests/boundary/filesystem/ciChangeScope.test.ts b/tests/boundary/filesystem/ciChangeScope.test.ts index 99b6c9a548..8cdb9258b6 100644 --- a/tests/boundary/filesystem/ciChangeScope.test.ts +++ b/tests/boundary/filesystem/ciChangeScope.test.ts @@ -1246,6 +1246,17 @@ it.each([ ".github/actions/ubuntu-archive/action.yml", { code: true, runtime: true, package: true, binary_layout: true }, ], + [ + ".github/actions/ubuntu-archive/action.yaml", + { + code: true, + runtime: true, + package: true, + binary_layout: true, + signal_recording: true, + workflows: true, + }, + ], [ ".github/actions/host-apt-packages/action.yml", { @@ -1255,6 +1266,19 @@ it.each([ binary_layout: true, signal_recording: true, recorded_crash: false, + workflows: true, + }, + ], + [ + ".github/actions/host-apt-packages/action.yaml", + { + code: true, + runtime: true, + package: true, + binary_layout: true, + signal_recording: true, + recorded_crash: false, + workflows: true, }, ], ["src/domain/peCoffHeader.ts", { code: true, runtime: true, package: true }], @@ -1764,6 +1788,22 @@ it.each([ ".github/workflows/real-termux.yml", { workflows: true, code: false, package: false, website: false }, ], + [ + ".github/actions/npm-cache/action.yml", + { workflows: true, code: true, runtime: true, package: false }, + ], + [ + ".github/actions/example/nested/action.yaml", + { workflows: true, code: true, runtime: true, package: false }, + ], + [ + ".github/actions/publish-mcp/registry-state.mjs", + { workflows: false, code: true, runtime: true, package: true }, + ], + [ + ".github/actionlint.yml", + { workflows: true, code: false, runtime: false, package: false }, + ], [ "src/domain/javascript/example.test.ts", { code: true, runtime: false, javascript_recovery: false, package: false }, diff --git a/tests/boundary/filesystem/mcpRegistryPublication.test.ts b/tests/boundary/filesystem/mcpRegistryPublication.test.ts index 71d03f9cc1..5c5958371a 100644 --- a/tests/boundary/filesystem/mcpRegistryPublication.test.ts +++ b/tests/boundary/filesystem/mcpRegistryPublication.test.ts @@ -11,15 +11,16 @@ const record = { _meta: { "io.modelcontextprotocol.registry/official": { status: "active" } }, }; const page = (servers: unknown[], metadata = {}) => - Response.json({ servers, metadata }); + Response.json({ servers, metadata: { count: servers.length, ...metadata } }); it("finds an identical existing version after paging past substring matches", async () => { const urls: URL[] = []; + const nextCursor = " next+/="; const result = await registryPublicationState(server, async (url: URL) => { urls.push(url); return urls.length === 1 ? page([{ server: { ...server, name: `${server.name}-other` } }], { - nextCursor: "next", + nextCursor, }) : page([record]); }); @@ -27,13 +28,21 @@ it("finds an identical existing version after paging past substring matches", as expect(urls[0]?.searchParams.get("search")).toBe(server.name); expect(urls[0]?.searchParams.get("version")).toBe(server.version); expect(urls[0]?.searchParams.get("include_deleted")).toBe("true"); - expect(urls[1]?.searchParams.get("cursor")).toBe("next"); + expect(urls[1]?.searchParams.get("cursor")).toBe(nextCursor); }); -it("permits publication only after a complete successful lookup finds no exact match", async () => { - await expect( - registryPublicationState(server, async () => page([])), - ).resolves.toBe("absent"); +it.each([undefined, null, ""])( + "treats a terminal cursor of %j as the final page", + async (nextCursor) => { + await expect( + registryPublicationState(server, async () => + Response.json({ servers: [], metadata: { nextCursor } }), + ), + ).resolves.toBe("absent"); + }, +); + +it("does not establish absence when a page cannot be verified", async () => { await expect( registryPublicationState( server, @@ -52,6 +61,22 @@ it("permits publication only after a complete successful lookup finds no exact m ).rejects.toThrow("non-advancing cursor"); }); +it.each([ + { metadata: [], error: "metadata" }, + { metadata: { count: 1 }, error: "count" }, + { metadata: { count: "0" }, error: "count" }, + { metadata: { nextCursor: 0 }, error: "invalid cursor" }, +])( + "rejects a terminal page with invalid $error ($metadata)", + async ({ metadata, error }) => { + await expect( + registryPublicationState(server, async () => + Response.json({ servers: [], metadata }), + ), + ).rejects.toThrow(error); + }, +); + it("refuses changed, inactive or ambiguous published metadata", async () => { await expect( registryPublicationState(server, async () => diff --git a/tests/boundary/filesystem/releaseCheckpoint.test.ts b/tests/boundary/filesystem/releaseCheckpoint.test.ts index 478b82b094..7e07a03db6 100644 --- a/tests/boundary/filesystem/releaseCheckpoint.test.ts +++ b/tests/boundary/filesystem/releaseCheckpoint.test.ts @@ -447,6 +447,44 @@ it.each([ }, ); +it.each([ + { spacing: "adjacent", separator: "\n", includeRestart: true }, + { spacing: "separated", separator: "\n\n", includeRestart: true }, + { spacing: "separated", separator: "\n\n", includeRestart: false }, +])( + "validates $spacing list migration with restart step $includeRestart", + async ({ separator, includeRestart }) => { + const steps = + "- Set `--new-path` to an absolute path.\n- Restart the client."; + const f = await fixture( + "fix(contracts)!: change path inputs", + "BREAKING CHANGE: Migrate configuration:" + + separator + + steps + + "\n\nReviewed-by: Fixture Reviewer", + ); + const notes = includeRestart ? steps : steps.split("\n")[0]; + await candidate( + f, + "6.0.0", + "### ⚠ BREAKING CHANGES\n\nMigrate configuration:\n\n" + notes, + ); + const result = verify(f); + if (includeRestart) { + await expect(result).resolves.toMatchObject({ + stdout: expect.stringContaining('"expectedVersion": "6.0.0"'), + }); + } else { + await expect(result).rejects.toMatchObject({ + code: 1, + stderr: expect.stringContaining( + "migration notes omit unreleased breaking changes", + ), + }); + } + }, +); + it("rejects a minor when a GitHub merge commit carries its bang marker in the PR title", async () => { const f = await fixture("fix(contracts)!: require absolute paths", "", { mergePullRequest: true, @@ -489,7 +527,7 @@ it.each([ it("does not treat an ordinary body example as a merge title or breaking declaration", async () => { const f = await fixture( "fix: improve diagnostics", - "Example subject:\n\nfix(contracts)!: example only", + "Example subject:\n\nfix(contracts)!: example only\n\n~~~text\nBREAKING CHANGE: example only\n~~~", ); await candidate(f, "5.0.1", `### Bug Fixes\n\n${f.changedSha}`); await expect(verify(f, "5.0.1")).resolves.toMatchObject({ stderr: "" }); @@ -520,13 +558,19 @@ it("allows release examples with a release heading before genuine migration note await expect(verify(f)).resolves.toMatchObject({ stderr: "" }); }); -it("requires genuine migration notes outside a fenced Markdown example", async () => { +it.each([ + { + form: "a fenced example", + notes: + "### Features\n\n~~~markdown\n### ⚠ BREAKING CHANGES\n\nSee #948.\n~~~", + }, + { + form: "a wrapped inline code example", + notes: "### ⚠ BREAKING CHANGES\n\n- Syntax: `See #948\n for details.`", + }, +])("requires genuine migration notes outside $form", async ({ notes }) => { const f = await fixture(); - await candidate( - f, - "6.0.0", - "### Features\n\n~~~markdown\n### ⚠ BREAKING CHANGES\n\nSee #948.\n~~~", - ); + await candidate(f, "6.0.0", notes); await expect(verify(f)).rejects.toMatchObject({ code: 1, stderr: expect.stringContaining( @@ -535,6 +579,235 @@ it("requires genuine migration notes outside a fenced Markdown example", async ( }); }); +it.each([ + { + form: "the entire footer quoted as wrapped code", + footer: "Use absolute MCP paths. Relative paths are rejected.", + notes: "Example: `Use absolute MCP paths.\n Relative paths are rejected.`", + accepted: false, + }, + { + form: "a migration instruction with the exact inline options", + footer: "Replace `--old-path` with `--mcp-path`.", + notes: "**Replace** `--old-path` with\n `--mcp-path`.", + accepted: true, + }, + { + form: "the same instruction with a different inline option", + footer: "Replace `--old-path` with `--mcp-path`.", + notes: "**Replace** `--old-path` with\n `--mcp-paths`.", + accepted: false, + }, + { + form: "a different value inside an inline command", + footer: + 'Run `rea capture --name "two spaces"` before collecting Evidence.', + notes: 'Run `rea capture --name "two spaces"` before collecting Evidence.', + accepted: false, + }, + { + form: "a migration link with the same destination and formatted label", + footer: "Download [the replacement](https://example.com/v2).", + notes: "Download [**the replacement**](https://example.com/v2).", + accepted: true, + }, + { + form: "plain migration prose with a hyperlink added in the notes", + footer: "Download the replacement.", + notes: "Download [the replacement](https://example.com/v2).", + accepted: true, + }, + { + form: "a migration link with a different destination", + footer: "Download [the replacement](https://example.com/v2).", + notes: "Download [the replacement](https://example.com/v1).", + accepted: false, + }, + { + form: "a migration link reduced to its label", + footer: "Download [the replacement](https://example.com/v2).", + notes: "Download the replacement.", + accepted: false, + }, + { + form: "the same destination linked from different words", + footer: "Download [the replacement](https://example.com/v2) now.", + notes: "Download [the replacement now](https://example.com/v2).", + accepted: false, + }, + { + form: "a required Markdown link alongside an added link with the same destination", + footer: + "Download [the replacement](https://example.com/v2) and restart the client.", + notes: + "Download [the replacement](https://example.com/v2) and restart [the client](https://example.com/v2).", + accepted: true, + }, + { + form: "a required Markdown link whose destination appears on an added link instead", + footer: + "Download [the replacement](https://example.com/v2) and restart the client.", + notes: + "Download [the replacement](https://example.com/v1) and restart [the client](https://example.com/v2).", + accepted: false, + }, + { + form: "the same inline HTML link", + footer: 'Download the replacement.', + notes: 'Download the replacement.', + accepted: true, + }, + { + form: "an inline HTML link with a changed destination", + footer: 'Download the replacement.', + notes: 'Download the replacement.', + accepted: false, + }, + { + form: "an inline HTML link reduced to its label", + footer: 'Download the replacement.', + notes: "Download the replacement.", + accepted: false, + }, +])( + "validates migration wording from $form", + async ({ footer, notes, accepted }) => { + const f = await fixture( + "fix(contracts)!: change path inputs", + `BREAKING CHANGE: ${footer}`, + ); + await candidate(f, "6.0.0", `### ⚠ BREAKING CHANGES\n\n- ${notes}`); + const result = verify(f); + if (accepted) { + await expect(result).resolves.toHaveProperty("stdout"); + } else { + await expect(result).rejects.toMatchObject({ + code: 1, + stderr: expect.stringContaining( + "migration notes omit unreleased breaking changes", + ), + }); + } + }, +); + +const migrationCommand = 'mv "old config.json" "new config.json"'; +const fencedMigrationCommand = `~~~sh\n${migrationCommand}\n~~~`; + +it.each([ + { form: "missing command", command: "", accepted: false }, + { + form: "different command", + command: fencedMigrationCommand.replace("new config", "other config"), + accepted: false, + }, + { form: "inline code", command: `\`${migrationCommand}\``, accepted: false }, + { + form: "exact fenced command", + command: fencedMigrationCommand, + accepted: true, + }, + { + form: "exact indented command", + command: ` ${migrationCommand}`, + accepted: true, + }, +])( + "requires a literal migration block: $form", + async ({ command, accepted }) => { + const f = await fixture( + "fix(contracts)!: rename the configuration file", + `BREAKING CHANGE: Rename the configuration file.\n\n${fencedMigrationCommand}\n\nReviewed-by: Fixture Reviewer`, + ); + await candidate( + f, + "6.0.0", + `### ⚠ BREAKING CHANGES\n\nRename the configuration file.\n\n${command}`, + ); + const result = verify(f); + if (accepted) { + await expect(result).resolves.toHaveProperty("stdout"); + } else { + await expect(result).rejects.toMatchObject({ + code: 1, + stderr: expect.stringContaining( + "migration notes omit unreleased breaking changes", + ), + }); + } + }, +); + +const htmlMigrationBlock = "
\nHeader: exact value\n"; + +it.each([ + { form: "preserved", block: htmlMigrationBlock, accepted: true }, + { form: "omitted", block: "", accepted: false }, +])("keeps raw HTML migration blocks: $form", async ({ block, accepted }) => { + const f = await fixture( + "fix(contracts)!: migrate configuration", + `BREAKING CHANGE: Write the new configuration.\n\n${htmlMigrationBlock}\n\nReviewed-by: Fixture Reviewer`, + ); + await candidate( + f, + "6.0.0", + `### ⚠ BREAKING CHANGES\n\nWrite the new configuration.\n\n${block}`, + ); + const result = verify(f); + if (accepted) { + await expect(result).resolves.toHaveProperty("stdout"); + } else { + await expect(result).rejects.toMatchObject({ + code: 1, + stderr: expect.stringContaining( + "migration notes omit unreleased breaking changes", + ), + }); + } +}); + +it.each([ + { form: "preserved", command: "Header: exact value", accepted: true }, + { form: "changed", command: "Header: another value", accepted: false }, +])( + "keeps trailer-shaped text in code blocks: $form", + async ({ command, accepted }) => { + const f = await fixture( + "fix(contracts)!: migrate configuration", + "BREAKING CHANGE: Write the new configuration.\n\n~~~text\nHeader: exact value\n~~~\n\nReviewed-by: Fixture Reviewer", + ); + await candidate( + f, + "6.0.0", + `### ⚠ BREAKING CHANGES\n\nWrite the new configuration.\n\n~~~text\n${command}\n~~~`, + ); + const result = verify(f); + if (accepted) { + await expect(result).resolves.toHaveProperty("stdout"); + } else { + await expect(result).rejects.toMatchObject({ + code: 1, + stderr: expect.stringContaining( + "migration notes omit unreleased breaking changes", + ), + }); + } + }, +); + +it("accepts a code-only migration when its fence starts on the footer line", async () => { + const f = await fixture( + "fix(contracts): rename configuration", + `BREAKING CHANGE: ${fencedMigrationCommand}\n\nReviewed-by: Fixture Reviewer`, + ); + await candidate( + f, + "6.0.0", + `### ⚠ BREAKING CHANGES\n\n${fencedMigrationCommand}`, + ); + await expect(verify(f)).resolves.toHaveProperty("stdout"); +}); + it("recognizes a BREAKING CHANGE footer without a bang in the subject", async () => { const f = await fixture( "fix(contracts): change path inputs (#948)", diff --git a/tests/boundary/filesystem/releaseNotes.test.ts b/tests/boundary/filesystem/releaseNotes.test.ts index 763e995775..856ba3ab7c 100644 --- a/tests/boundary/filesystem/releaseNotes.test.ts +++ b/tests/boundary/filesystem/releaseNotes.test.ts @@ -828,6 +828,28 @@ it.each([ }, ); +it("verifies complete bullets without counting inline code as credit or references", async () => { + const f = await fixture(); + const changelog = join(f.directory, "CHANGELOG.md"); + const example = "`literal #999\n and @unverified`"; + const bullet = f.bullet + .replace( + "#101", + "[the implementation](https://github.com/fixture/rea/pull/101)", + ) + .replace("Thanks", `Example ${example}.\n Thanks`); + const notes = f.notes.replace(f.bullet, bullet); + await writeFile(changelog, notes); + await f.invoke(["check", "--manifest", f.manifest]); + + await writeFile(changelog, notes.replace(", @bob", ", `@bob`")); + await expect( + f.invoke(["check", "--manifest", f.manifest]), + ).rejects.toMatchObject({ + stderr: expect.stringContaining("Missing Thanks @bob for PR #101"), + }); +}); + it("requires editorial headings in release prose outside code fences", async () => { const f = await fixture(); const notes = f.notes.replace(