breakage 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{breakage-DIY49fzP.js → breakage-DJiIiLzL.js} +632 -9
- package/dist/breakage-DJiIiLzL.js.map +1 -0
- package/dist/breakage.d.ts +198 -86
- package/dist/breakage.d.ts.map +1 -1
- package/dist/breakage.js +2 -2
- package/dist/breakage.x.js +142 -3
- package/dist/breakage.x.js.map +1 -1
- package/npm.md +144 -12
- package/package.json +1 -1
- package/src/breakage.ts +17 -0
- package/src/breakage.x.ts +26 -0
- package/src/config.ts +3 -0
- package/src/npm/check.ts +19 -0
- package/src/npm/cli.ts +4 -0
- package/src/npm/matrix-cli.ts +170 -0
- package/src/npm/matrix-model.ts +395 -0
- package/src/npm/matrix.ts +657 -0
- package/dist/breakage-DIY49fzP.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breakage-DJiIiLzL.js","names":["latestReleaseTag","selectLatestReleaseTag"],"sources":["../src/task.ts","../src/npm/manifest.ts","../src/directory-lock.ts","../src/release-tag.ts","../src/baseline.ts","../src/test-file-state.ts","../src/npm/config.ts","../src/npm/matrix-model.ts","../src/config.ts","../src/npm/release.ts","../src/npm/environment.ts","../src/npm/check.ts","../src/npm/matrix.ts","../src/breakage.ts"],"sourcesContent":["import { spawn } from \"node:child_process\"\nimport path from \"node:path\"\n\nexport type CommandResult = { code: number; output: string }\n\n/** Capture output per environment so parallel runs cannot interleave their reports. */\nexport async function command(\n\tcommandLine: string,\n\tcwd: string,\n): Promise<CommandResult> {\n\tif (typeof commandLine !== `string` || !commandLine.trim())\n\t\tthrow new Error(`Commands must be nonempty shell strings.`)\n\treturn await new Promise((resolve, reject) => {\n\t\tconst child = spawn(commandLine, {\n\t\t\tcwd,\n\t\t\tshell: true,\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\tNODE_PATH: ``,\n\t\t\t\tPATH: [\n\t\t\t\t\tpath.join(cwd, `node_modules/.bin`),\n\t\t\t\t\tpath.join(cwd, `../node_modules/.bin`),\n\t\t\t\t\tprocess.env.PATH,\n\t\t\t\t].join(path.delimiter),\n\t\t\t},\n\t\t\tstdio: [`ignore`, `pipe`, `pipe`],\n\t\t})\n\t\tlet output = ``\n\t\tconst collect = (chunk: Buffer): void => {\n\t\t\t// Bound diagnostics without interrupting a command that emits lots of output.\n\t\t\toutput = (output + chunk.toString()).slice(-1_000_000)\n\t\t}\n\t\tchild.stdout.on(`data`, collect)\n\t\tchild.stderr.on(`data`, collect)\n\t\tchild.on(`error`, reject)\n\t\tchild.on(`close`, (code, signal) =>\n\t\t\tresolve({ code: signal ? 2 : (code ?? 2), output }),\n\t\t)\n\t})\n}\n\nexport async function prepare(commandLine: string, cwd: string): Promise<void> {\n\tconst result = await command(commandLine, cwd)\n\tif (result.code !== 0)\n\t\tthrow new Error(\n\t\t\t`Command failed (${result.code}) in ${cwd}: ${commandLine}\\n${result.output}`,\n\t\t)\n}\n\nexport function errorMessage(error: unknown): string {\n\treturn error instanceof Error\n\t\t? `${error.message}${error.cause ? `\\n${errorMessage(error.cause)}` : ``}`\n\t\t: String(error)\n}\n","import { readFile } from \"node:fs/promises\"\n\nimport semver from \"semver\"\n\nexport type Manifest = {\n\tname: string\n\tversion: string\n\ttype?: string\n\tdependencies?: Record<string, string>\n\toptionalDependencies?: Record<string, string>\n\tdevDependencies?: Record<string, string>\n\tpeerDependencies?: Record<string, string>\n\tpeerDependenciesMeta?: Record<string, { optional?: boolean }>\n\tbreakage?: { candidates?: string[] }\n}\n\nexport function record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === `object` && value !== null && !Array.isArray(value)\n}\n\nexport function packageName(value: string): boolean {\n\treturn /^(?:@[a-z0-9._-]+\\/)?[a-z0-9][a-z0-9._-]*$/.test(value)\n}\n\nexport function parseManifest(value: unknown, label: string): Manifest {\n\tif (\n\t\t!record(value) ||\n\t\ttypeof value.name !== `string` ||\n\t\t!packageName(value.name) ||\n\t\ttypeof value.version !== `string` ||\n\t\t!semver.valid(value.version)\n\t) {\n\t\tthrow new Error(`Invalid package identity in ${label}.`)\n\t}\n\tif (\n\t\tvalue.peerDependenciesMeta !== undefined &&\n\t\t(!record(value.peerDependenciesMeta) ||\n\t\t\tObject.values(value.peerDependenciesMeta).some(\n\t\t\t\t(entry) =>\n\t\t\t\t\t!record(entry) ||\n\t\t\t\t\t(entry.optional !== undefined && typeof entry.optional !== `boolean`),\n\t\t\t))\n\t) {\n\t\tthrow new Error(`Invalid peerDependenciesMeta in ${label}.`)\n\t}\n\tfor (const field of [\n\t\t`dependencies`,\n\t\t`optionalDependencies`,\n\t\t`devDependencies`,\n\t\t`peerDependencies`,\n\t] as const) {\n\t\tconst entries = value[field]\n\t\tif (\n\t\t\tentries !== undefined &&\n\t\t\t(!record(entries) ||\n\t\t\t\tObject.entries(entries).some(\n\t\t\t\t\t([name, spec]) => !packageName(name) || typeof spec !== `string`,\n\t\t\t\t))\n\t\t) {\n\t\t\tthrow new Error(`Invalid ${field} in ${label}.`)\n\t\t}\n\t}\n\tif (\n\t\tvalue.breakage !== undefined &&\n\t\t(!record(value.breakage) ||\n\t\t\t(value.breakage.candidates !== undefined &&\n\t\t\t\t(!Array.isArray(value.breakage.candidates) ||\n\t\t\t\t\tvalue.breakage.candidates.some(\n\t\t\t\t\t\t(name: unknown) => typeof name !== `string` || !packageName(name),\n\t\t\t\t\t))))\n\t) {\n\t\tthrow new Error(`Invalid candidate peers in ${label}.`)\n\t}\n\treturn value as Manifest\n}\n\nexport async function readManifest(filename: string): Promise<Manifest> {\n\treturn parseManifest(JSON.parse(await readFile(filename, `utf8`)), filename)\n}\n\n/** Current support is authored explicitly; only historical shorthand is resolved. */\nexport async function normalizeWorkspacePeers(\n\tmanifest: Manifest,\n\tversionAtBaseline?: (peer: string) => Promise<string>,\n): Promise<Manifest> {\n\tif (!manifest.peerDependencies) return manifest\n\tconst entries = await Promise.all(\n\t\tObject.entries(manifest.peerDependencies).map(async ([peer, range]) => {\n\t\t\tif (!range.startsWith(`workspace:`)) return [peer, range] as const\n\t\t\tconst requested = range.slice(`workspace:`.length)\n\t\t\tif ([``, `*`, `^`, `~`].includes(requested)) {\n\t\t\t\tif (!versionAtBaseline)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Moving workspace peer range ${peer}: ${range} in ${manifest.name}. Declare explicit support eras, for example ^1.0.0 || ^2.0.0, so local version changes cannot change the support promise.`,\n\t\t\t\t\t)\n\t\t\t\tconst version = await versionAtBaseline(peer)\n\t\t\t\tif (!semver.valid(version))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Invalid historical workspace version for ${peer}: ${version}.`,\n\t\t\t\t\t)\n\t\t\t\treturn [\n\t\t\t\t\tpeer,\n\t\t\t\t\t`${requested === `^` || requested === `~` ? requested : ``}${version}`,\n\t\t\t\t] as const\n\t\t\t}\n\t\t\ttry {\n\t\t\t\teras(requested)\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unsupported workspace peer range for ${peer}: ${range}.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn [peer, requested] as const\n\t\t}),\n\t)\n\treturn { ...manifest, peerDependencies: Object.fromEntries(entries) }\n}\n\nexport function eras(range: string): string[] {\n\tconst parts = range.split(`||`).map((part) => part.trim())\n\tif (parts.some((part) => !part || semver.validRange(part) === null)) {\n\t\tthrow new Error(`Invalid peer range: ${range}.`)\n\t}\n\treturn parts\n}\n\n/** Previews only represent an explicitly enrolled exact preview. */\nexport function matches(version: string, range: string): boolean {\n\treturn eras(range).some((era) =>\n\t\tsemver.prerelease(version)\n\t\t\t? semver.valid(era.replace(/^=\\s*/, ``)) === semver.valid(version)\n\t\t\t: semver.satisfies(version, era),\n\t)\n}\n","import { mkdir, rmdir } from \"node:fs/promises\"\nimport { setTimeout } from \"node:timers/promises\"\n\nexport async function withDirectoryLock<T>(\n\tlock: string,\n\taction: () => Promise<T>,\n\twaitForCleanup = false,\n): Promise<T> {\n\tconst deadline = Date.now() + 60_000\n\tfor (;;) {\n\t\ttry {\n\t\t\tawait mkdir(lock)\n\t\t\tbreak\n\t\t} catch (thrown) {\n\t\t\tif ((thrown as NodeJS.ErrnoException).code !== `EEXIST`) throw thrown\n\t\t\tif (!waitForCleanup && Date.now() >= deadline) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Timed out waiting for ${lock}. Check for an interrupted operation before removing this lock.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tawait setTimeout(20)\n\t\t}\n\t}\n\ttry {\n\t\treturn await action()\n\t} finally {\n\t\tawait rmdir(lock)\n\t}\n}\n","type Release = { ref: string; core: string[]; prerelease: string[] }\n\nfunction compareInteger(a: string, b: string): number {\n\treturn a.length - b.length || (a > b ? 1 : a < b ? -1 : 0)\n}\n\nfunction compareRelease(a: Release, b: Release): number {\n\tfor (let index = 0; index < 3; index++) {\n\t\tconst difference = compareInteger(a.core[index]!, b.core[index]!)\n\t\tif (difference) return difference\n\t}\n\tif (!a.prerelease.length || !b.prerelease.length) {\n\t\treturn Number(!a.prerelease.length) - Number(!b.prerelease.length)\n\t}\n\tfor (\n\t\tlet index = 0;\n\t\tindex < Math.min(a.prerelease.length, b.prerelease.length);\n\t\tindex++\n\t) {\n\t\tconst left = a.prerelease[index]!\n\t\tconst right = b.prerelease[index]!\n\t\tconst leftNumeric = /^\\d+$/.test(left)\n\t\tconst rightNumeric = /^\\d+$/.test(right)\n\t\tconst difference =\n\t\t\tleftNumeric && rightNumeric\n\t\t\t\t? compareInteger(left, right)\n\t\t\t\t: leftNumeric !== rightNumeric\n\t\t\t\t\t? Number(rightNumeric) - Number(leftNumeric)\n\t\t\t\t\t: left > right\n\t\t\t\t\t\t? 1\n\t\t\t\t\t\t: left < right\n\t\t\t\t\t\t\t? -1\n\t\t\t\t\t\t\t: 0\n\t\tif (difference) return difference\n\t}\n\treturn a.prerelease.length - b.prerelease.length\n}\n\nexport function latestReleaseTag(\n\tremoteTags: string,\n\ttagPattern?: string,\n): string | undefined {\n\tconst pattern = tagPattern ? new RegExp(tagPattern) : undefined\n\tlet latest: Release | undefined\n\tfor (const line of remoteTags.split(`\\n`)) {\n\t\tif (pattern && !pattern.test(line)) continue\n\t\tconst ref = line.split(`\\t`)[1]?.replace(/\\^\\{\\}$/, ``)\n\t\tif (!ref?.startsWith(`refs/tags/`)) continue\n\t\tconst name = ref.slice(`refs/tags/`.length)\n\t\tconst version = name.slice(name.lastIndexOf(`@`) + 1)\n\t\tconst match =\n\t\t\t/^v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/.exec(\n\t\t\t\tversion,\n\t\t\t)\n\t\tif (!match) continue\n\t\tconst prerelease = match[4]?.split(`.`) ?? []\n\t\tif (prerelease.some((identifier) => /^0\\d+$/.test(identifier))) continue\n\t\tconst release: Release = { ref, core: match.slice(1, 4), prerelease }\n\t\tif (!latest || compareRelease(release, latest) > 0) latest = release\n\t}\n\treturn latest?.ref\n}\n","import { randomUUID } from \"node:crypto\"\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport type { SimpleGit } from \"simple-git\"\nimport { simpleGit } from \"simple-git\"\n\nimport { withDirectoryLock } from \"./directory-lock.ts\"\nimport { latestReleaseTag } from \"./release-tag.ts\"\n\nexport type BaselineOptions = {\n\ttagPattern?: string | undefined\n\tbaseDirname?: string\n}\n\nexport type BreakagePreludeOptions = BaselineOptions & { out: string }\n\nexport type BreakageBaseline = {\n\tversion: 1\n\ttagPattern: string | null\n\tpackageDirectory: string\n\tref: string\n\tcommit: string\n}\n\nconst objectId = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/\n\nfunction isBaseline(value: unknown): value is BreakageBaseline {\n\tif (typeof value !== `object` || value === null) return false\n\tconst record = value as Partial<BreakageBaseline>\n\treturn (\n\t\trecord.version === 1 &&\n\t\t(record.tagPattern === null || typeof record.tagPattern === `string`) &&\n\t\ttypeof record.packageDirectory === `string` &&\n\t\ttypeof record.ref === `string` &&\n\t\trecord.ref.startsWith(`refs/tags/`) &&\n\t\ttypeof record.commit === `string` &&\n\t\tobjectId.test(record.commit)\n\t)\n}\n\n/** Resolve and fetch a release without running tests or changing the worktree. */\nexport async function breakagePrelude({\n\tout,\n\ttagPattern,\n\tbaseDirname = process.cwd(),\n}: BreakagePreludeOptions): Promise<BreakageBaseline> {\n\tconst filename = path.resolve(baseDirname, out)\n\tconst temporaryPath = `${filename}.${randomUUID()}.tmp`\n\tlet canInvalidate = false\n\ttry {\n\t\tconst git = simpleGit(baseDirname)\n\t\t// An ignored, untracked snapshot cannot make the compatibility check dirty.\n\t\tif (!(await git.raw([`check-ignore`, `--`, filename])).trim()) {\n\t\t\tthrow new Error(`Baseline output must be gitignored: ${filename}.`)\n\t\t}\n\t\tcanInvalidate = true\n\t\tconst remoteTags = await git.listRemote([`--tags`, `origin`])\n\t\tconst ref = latestReleaseTag(remoteTags, tagPattern)\n\t\tif (!ref) {\n\t\t\tthrow new Error(`No tags found matching the pattern \"${tagPattern}\".`)\n\t\t}\n\t\tconst refs = new Map(\n\t\t\tremoteTags\n\t\t\t\t.trim()\n\t\t\t\t.split(`\\n`)\n\t\t\t\t.map((line) => {\n\t\t\t\t\tconst [sha, name] = line.split(`\\t`)\n\t\t\t\t\treturn [name, sha]\n\t\t\t\t}),\n\t\t)\n\t\t// ls-remote supplies the peeled commit for annotated tags.\n\t\tconst commit = refs.get(`${ref}^{}`) ?? refs.get(ref)\n\t\tif (!commit || !objectId.test(commit)) {\n\t\t\tthrow new Error(`Could not resolve the release commit for ${ref}.`)\n\t\t}\n\t\tconst commonGitDirectory = await git.revparse([\n\t\t\t`--path-format=absolute`,\n\t\t\t`--git-common-dir`,\n\t\t])\n\t\tawait withDirectoryLock(\n\t\t\tpath.join(commonGitDirectory, `breakage-fetch.lock`),\n\t\t\t() => git.fetch([`origin`, commit, `--no-tags`, `--no-write-fetch-head`]),\n\t\t)\n\t\tif ((await git.raw([`cat-file`, `-t`, commit])).trim() !== `commit`) {\n\t\t\tthrow new Error(`Release ${ref} does not resolve to a commit.`)\n\t\t}\n\t\tconst baseline: BreakageBaseline = {\n\t\t\tversion: 1,\n\t\t\ttagPattern: tagPattern ?? null,\n\t\t\tpackageDirectory: await git.revparse([`--show-prefix`]),\n\t\t\tref,\n\t\t\tcommit,\n\t\t}\n\t\tawait mkdir(path.dirname(filename), { recursive: true })\n\t\tawait writeFile(temporaryPath, `${JSON.stringify(baseline, null, 2)}\\n`, {\n\t\t\tflag: `wx`,\n\t\t})\n\t\tawait rename(temporaryPath, filename)\n\t\treturn baseline\n\t} catch (cause) {\n\t\t// A failed refresh must never leave an older snapshot available as fallback.\n\t\tif (canInvalidate) await rm(filename, { force: true })\n\t\tthrow new Error(`Failed to prepare baseline ${filename}.`, { cause })\n\t} finally {\n\t\tawait rm(temporaryPath, { force: true })\n\t}\n}\n\nexport async function readBaseline(\n\tgit: SimpleGit,\n\tfilename: string,\n\t{ tagPattern }: BaselineOptions,\n): Promise<BreakageBaseline> {\n\ttry {\n\t\tconst baseline: unknown = JSON.parse(await readFile(filename, `utf8`))\n\t\tif (!isBaseline(baseline)) throw new Error(`Invalid baseline fields.`)\n\t\tif (\n\t\t\tbaseline.tagPattern !== (tagPattern ?? null) ||\n\t\t\tbaseline.packageDirectory !== (await git.revparse([`--show-prefix`]))\n\t\t) {\n\t\t\tthrow new Error(`Baseline belongs to a different package or tag pattern.`)\n\t\t}\n\t\tif (\n\t\t\t(\n\t\t\t\tawait git.raw([`check-ref-format`, `--normalize`, baseline.ref])\n\t\t\t).trim() !== baseline.ref\n\t\t) {\n\t\t\tthrow new Error(`Invalid release ref.`)\n\t\t}\n\t\tif (\n\t\t\t(await git.raw([`cat-file`, `-t`, baseline.commit])).trim() !== `commit`\n\t\t) {\n\t\t\tthrow new Error(`Pinned object is not a locally available commit.`)\n\t\t}\n\t\treturn baseline\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`Missing, invalid, or unusable baseline ${filename}. Run breakage prelude again.`,\n\t\t\t{ cause },\n\t\t)\n\t}\n}\n","import { randomUUID } from \"node:crypto\"\nimport {\n\tchmod,\n\tlstat,\n\tmkdir,\n\treaddir,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport type { SimpleGit } from \"simple-git\"\nimport { simpleGit } from \"simple-git\"\n\nimport { withDirectoryLock } from \"./directory-lock.ts\"\n\ntype ActiveCheck = {\n\tpid: number\n\tpaths: string[]\n\thead: string\n\trecoveryRequired?: boolean\n}\n\nfunction isActiveCheck(value: unknown): value is ActiveCheck {\n\tif (typeof value !== `object` || value === null) return false\n\tconst record = value as Partial<ActiveCheck>\n\treturn (\n\t\ttypeof record.pid === `number` &&\n\t\tNumber.isSafeInteger(record.pid) &&\n\t\trecord.pid > 0 &&\n\t\ttypeof record.head === `string` &&\n\t\t/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(record.head) &&\n\t\t(record.recoveryRequired === undefined ||\n\t\t\ttypeof record.recoveryRequired === `boolean`) &&\n\t\tArray.isArray(record.paths) &&\n\t\trecord.paths.length > 0 &&\n\t\trecord.paths.every(\n\t\t\t(file) =>\n\t\t\t\ttypeof file === `string` &&\n\t\t\t\t!path.isAbsolute(file) &&\n\t\t\t\t!path.win32.isAbsolute(file) &&\n\t\t\t\tfile\n\t\t\t\t\t.split(`/`)\n\t\t\t\t\t.every((part) => part !== `` && part !== `.` && part !== `..`),\n\t\t)\n\t)\n}\n\nasync function readRecoveryRecord(recordPath: string): Promise<ActiveCheck> {\n\ttry {\n\t\tconst record: unknown = JSON.parse(await readFile(recordPath, `utf8`))\n\t\tif (!isActiveCheck(record))\n\t\t\tthrow new TypeError(`Invalid recovery record fields`)\n\t\treturn record\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`A breakage run needs recovery. The record ${recordPath} is unreadable or invalid. Verify no check is running and recover its test files before removing this record.`,\n\t\t\t{ cause },\n\t\t)\n\t}\n}\n\nasync function writeRecoveryRecord(\n\trecordPath: string,\n\trecord: ActiveCheck,\n): Promise<void> {\n\tconst temporaryPath = `${recordPath}.${randomUUID()}.tmp`\n\ttry {\n\t\tawait writeFile(temporaryPath, JSON.stringify(record), { flag: `wx` })\n\t\tawait rename(temporaryPath, recordPath)\n\t} finally {\n\t\tawait rm(temporaryPath, { force: true })\n\t}\n}\n\ntype TestFileState = {\n\tisClean: () => Promise<boolean>\n\treplaceTests: (\n\t\trelease: string,\n\t\tfiles: string[],\n\t) => Promise<() => Promise<void>>\n}\n\nfunction assertContained(root: string, filename: string): void {\n\tconst relative = path.relative(root, filename)\n\tif (\n\t\trelative === `..` ||\n\t\trelative.startsWith(`..${path.sep}`) ||\n\t\tpath.isAbsolute(relative)\n\t) {\n\t\tthrow new Error(`Cannot replace tests outside the worktree: ${filename}.`)\n\t}\n}\n\nasync function validateParents(\n\troot: string,\n\tfilenames: string[],\n): Promise<void> {\n\tconst checked = new Set<string>()\n\tfor (const filename of filenames) {\n\t\tassertContained(root, filename)\n\t\tfor (let parent = path.dirname(filename); ; parent = path.dirname(parent)) {\n\t\t\tif (checked.has(parent)) break\n\t\t\tconst stats = await lstat(parent).catch(\n\t\t\t\t(thrown: NodeJS.ErrnoException) => {\n\t\t\t\t\tif (thrown.code !== `ENOENT`) throw thrown\n\t\t\t\t},\n\t\t\t)\n\t\t\tif (stats && !stats.isDirectory())\n\t\t\t\tthrow new Error(`Cannot replace tests through ${parent}.`)\n\t\t\tchecked.add(parent)\n\t\t\tif (parent === root) break\n\t\t}\n\t}\n}\n\n// This lock covers Git setup and restoration only. Commands run after it is released.\nexport async function withTestFileState<T>(\n\tgit: SimpleGit,\n\tbaseDirname: string,\n\taction: (state: TestFileState) => Promise<T>,\n): Promise<T> {\n\tconst root = await realpath(await git.revparse([`--show-toplevel`]))\n\tbaseDirname = await realpath(baseDirname)\n\tassertContained(root, baseDirname)\n\tconst stateDirectory = path.join(\n\t\tawait git.revparse([`--absolute-git-dir`]),\n\t\t`breakage`,\n\t)\n\tawait mkdir(stateDirectory, { recursive: true })\n\tconst lock = path.join(stateDirectory, `lock`)\n\treturn withDirectoryLock(lock, async () => {\n\t\tconst activeChecks: ActiveCheck[] = []\n\t\tfor (const entry of await readdir(stateDirectory)) {\n\t\t\tif (!entry.endsWith(`.json`)) continue\n\t\t\tconst recordPath = path.join(stateDirectory, entry)\n\t\t\tconst record = await readRecoveryRecord(recordPath)\n\t\t\tlet interrupted = record.recoveryRequired\n\t\t\ttry {\n\t\t\t\tprocess.kill(record.pid, 0)\n\t\t\t} catch (thrown) {\n\t\t\t\tif ((thrown as NodeJS.ErrnoException).code !== `EPERM`)\n\t\t\t\t\tinterrupted = true\n\t\t\t}\n\t\t\tif (interrupted)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`A breakage run needs recovery. Restore the test paths recorded in ${recordPath} before removing that record.`,\n\t\t\t\t)\n\t\t\tactiveChecks.push(record)\n\t\t}\n\t\tconst activePaths = activeChecks.flatMap((record) => record.paths)\n\t\treturn action({\n\t\t\tisClean: async () =>\n\t\t\t\t!(await simpleGit(root).raw([\n\t\t\t\t\t`--no-optional-locks`,\n\t\t\t\t\t`status`,\n\t\t\t\t\t`--porcelain`,\n\t\t\t\t\t`--untracked-files=all`,\n\t\t\t\t\t`--`,\n\t\t\t\t\t`.`,\n\t\t\t\t\t...activePaths.map((file) => `:(top,literal,exclude)${file}`),\n\t\t\t\t])),\n\t\t\treplaceTests: async (release, files) => {\n\t\t\t\tconst paths = files.map((file) =>\n\t\t\t\t\tpath\n\t\t\t\t\t\t.relative(root, path.resolve(baseDirname, file))\n\t\t\t\t\t\t.split(path.sep)\n\t\t\t\t\t\t.join(`/`),\n\t\t\t\t)\n\t\t\t\tfor (const file of paths) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tactivePaths.some(\n\t\t\t\t\t\t\t(active) =>\n\t\t\t\t\t\t\t\tfile === active ||\n\t\t\t\t\t\t\t\tfile.startsWith(`${active}/`) ||\n\t\t\t\t\t\t\t\tactive.startsWith(`${file}/`),\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Another breakage run is using ${file}. Concurrent checks must use disjoint test paths.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst head = await git.revparse([`HEAD`])\n\t\t\t\tconst currentFiles = new Set(\n\t\t\t\t\t(await git.raw([`ls-tree`, `-r`, `--name-only`, `-z`, head]))\n\t\t\t\t\t\t.split(`\\0`)\n\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t)\n\t\t\t\tconst existing = files.filter((file) => currentFiles.has(file))\n\t\t\t\tconst absent = files.filter((file) => !currentFiles.has(file))\n\t\t\t\tconst modes = new Map<string, number>()\n\t\t\t\tconst filenames = files.map((file) => path.resolve(baseDirname, file))\n\t\t\t\tawait validateParents(root, filenames)\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tconst filename = path.resolve(baseDirname, file)\n\n\t\t\t\t\tconst stats = await lstat(filename).catch(\n\t\t\t\t\t\t(thrown: NodeJS.ErrnoException) => {\n\t\t\t\t\t\t\tif (thrown.code !== `ENOENT`) throw thrown\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\tif (!currentFiles.has(file) && stats)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Cannot overwrite the existing untracked path ${filename}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\tif (stats?.isFile()) modes.set(filename, stats.mode)\n\t\t\t\t}\n\t\t\t\tconst recordPath = path.join(stateDirectory, `${randomUUID()}.json`)\n\t\t\t\tconst record: ActiveCheck = { pid: process.pid, paths, head }\n\t\t\t\tawait writeRecoveryRecord(recordPath, record)\n\t\t\t\tconst restore = async () => {\n\t\t\t\t\tawait writeRecoveryRecord(recordPath, {\n\t\t\t\t\t\t...record,\n\t\t\t\t\t\trecoveryRequired: true,\n\t\t\t\t\t})\n\t\t\t\t\tawait validateParents(root, filenames)\n\t\t\t\t\tif (existing.length)\n\t\t\t\t\t\tawait git.raw([\n\t\t\t\t\t\t\t`--literal-pathspecs`,\n\t\t\t\t\t\t\t`restore`,\n\t\t\t\t\t\t\t`--source=${head}`,\n\t\t\t\t\t\t\t`--worktree`,\n\t\t\t\t\t\t\t`--`,\n\t\t\t\t\t\t\t...existing,\n\t\t\t\t\t\t])\n\t\t\t\t\tfor (const file of absent)\n\t\t\t\t\t\tawait rm(path.resolve(baseDirname, file), { force: true })\n\t\t\t\t\tfor (const [filename, mode] of modes) await chmod(filename, mode)\n\t\t\t\t\tawait rm(recordPath)\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait git.raw([\n\t\t\t\t\t\t`--literal-pathspecs`,\n\t\t\t\t\t\t`restore`,\n\t\t\t\t\t\t`--source=${release}`,\n\t\t\t\t\t\t`--worktree`,\n\t\t\t\t\t\t`--`,\n\t\t\t\t\t\t...files,\n\t\t\t\t\t])\n\t\t\t\t} catch (thrown) {\n\t\t\t\t\tawait restore()\n\t\t\t\t\tthrow thrown\n\t\t\t\t}\n\t\t\t\treturn () => withDirectoryLock(lock, restore, true)\n\t\t\t},\n\t\t})\n\t})\n}\n","import path from \"node:path\"\nimport { type } from \"arktype\"\n\nimport { releaseSchema, rejectCertificationOptions } from \"../release.ts\"\n\nimport { eras, packageName, record } from \"./manifest.ts\"\nimport type { NpmConfig } from \"./types.ts\"\n\nexport const npmSuiteSchema = type({\n\t\"+\": `reject`,\n\tfiles: `string[]`,\n\tcommand: `string`,\n})\nexport const npmConfigSchema = type({\n\t\"+\": `reject`,\n\t\"release?\": releaseSchema,\n\t\"packageDirectory?\": `string`,\n\tartifact: `string`,\n\trepresentatives: `string | string[]`,\n\tlockfile: `string`,\n\tprepareCommand: `string`,\n\t\"installCommand?\": `string`,\n\tsuites: { \"[string]\": npmSuiteSchema },\n\t\"localPeers?\": {\n\t\t\"[string]\": { \"+\": `reject`, directory: `string`, artifact: `string` },\n\t},\n\tbaseline: type({ \"+\": `reject`, firstRelease: `true` }).or({\n\t\t\"+\": `reject`,\n\t\t\"tagPattern?\": `string`,\n\t\t\"baselineFile?\": `string`,\n\t}),\n})\n\nfunction nonempty(value: unknown): value is string {\n\treturn typeof value === `string` && value.trim().length > 0\n}\n\nexport function validateConfig(value: unknown): asserts value is NpmConfig {\n\tif (!record(value)) throw new Error(`Configuration must have an npm object.`)\n\trejectCertificationOptions(value)\n\tnpmConfigSchema.assert(value)\n\tfor (const key of [`artifact`, `lockfile`] as const) {\n\t\tif (!nonempty(value[key]))\n\t\t\tthrow new Error(`npm.${key} must be a nonempty string.`)\n\t}\n\tif (\n\t\tpath.isAbsolute(value.lockfile as string) ||\n\t\t(value.lockfile as string).split(/[\\\\/]/).includes(`..`)\n\t) {\n\t\tthrow new Error(`npm.lockfile must stay inside each representative.`)\n\t}\n\tif (!nonempty(value.prepareCommand))\n\t\tthrow new Error(\n\t\t\t`npm.prepareCommand must be a nonempty shell command string.`,\n\t\t)\n\tif (value.installCommand !== undefined && !nonempty(value.installCommand))\n\t\tthrow new Error(`Invalid npm.installCommand.`)\n\tfor (const key of [`packageDirectory`] as const) {\n\t\tif (value[key] !== undefined && !nonempty(value[key]))\n\t\t\tthrow new Error(`Invalid npm.${key}.`)\n\t}\n\tconst globs =\n\t\ttypeof value.representatives === `string`\n\t\t\t? [value.representatives]\n\t\t\t: value.representatives\n\tif (\n\t\t!Array.isArray(globs) ||\n\t\t!globs.length ||\n\t\tglobs.some((glob: unknown) => !nonempty(glob))\n\t) {\n\t\tthrow new Error(`npm.representatives must contain directory globs.`)\n\t}\n\tif (!record(value.suites) || !Object.keys(value.suites).length)\n\t\tthrow new Error(`Configure at least one npm peer suite.`)\n\tfor (const [peer, suite] of Object.entries(value.suites)) {\n\t\tif (\n\t\t\t!packageName(peer) ||\n\t\t\t!record(suite) ||\n\t\t\t!nonempty(suite.command) ||\n\t\t\t!Array.isArray(suite.files) ||\n\t\t\t!suite.files.length ||\n\t\t\tsuite.files.some((file: unknown) => !nonempty(file))\n\t\t) {\n\t\t\tthrow new Error(`Invalid npm suite for ${peer}.`)\n\t\t}\n\t}\n\tif (\n\t\t!record(value.baseline) ||\n\t\t(`firstRelease` in value.baseline\n\t\t\t? value.baseline.firstRelease !== true ||\n\t\t\t\tObject.keys(value.baseline).length !== 1\n\t\t\t: Object.entries(value.baseline).some(\n\t\t\t\t\t([key, item]) =>\n\t\t\t\t\t\t![`tagPattern`, `baselineFile`].includes(key) || !nonempty(item),\n\t\t\t\t))\n\t) {\n\t\tthrow new Error(\n\t\t\t`Configure npm.baseline with tagPattern/baselineFile or { firstRelease: true }.`,\n\t\t)\n\t}\n\tif (value.localPeers !== undefined) {\n\t\tif (!record(value.localPeers)) throw new Error(`Invalid npm.localPeers.`)\n\t\tfor (const [peer, local] of Object.entries(value.localPeers)) {\n\t\t\tif (\n\t\t\t\t!packageName(peer) ||\n\t\t\t\t!record(local) ||\n\t\t\t\t!nonempty(local.directory) ||\n\t\t\t\t!nonempty(local.artifact)\n\t\t\t) {\n\t\t\t\tthrow new Error(`Invalid local peer ${peer}.`)\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function validatePeerRanges(peers: Record<string, string>): void {\n\tfor (const range of Object.values(peers)) eras(range)\n}\n","// cspell:words premajor preminor prepatch\nimport { createHash } from \"node:crypto\"\nimport { type } from \"arktype\"\nimport type { NpmPeerEvidence, NpmReport } from \"./types.ts\"\n\nexport type NpmArchiveRequest = {\n\tpackageName: string\n\tdirectory: string\n\tartifact: string\n}\nexport type NpmPrepareContext = {\n\trootDirectory: string\n\tarchives: NpmArchiveRequest[]\n}\nexport type NpmMatrixLabelContext = {\n\tpackageName: string\n\trepresentative: string\n\tdescription?: string\n\tpeers: Record<string, NpmPeerEvidence>\n}\nexport const npmMatrixConfigSchema = type({\n\t\"+\": `reject`,\n\tconfigs: `string | string[]`,\n\tprepare: type(`string`).or(\n\t\ttype(`Function`).as<(context: NpmPrepareContext) => void | Promise<void>>(),\n\t),\n\t\"label?\": type(`Function`).as<(context: NpmMatrixLabelContext) => string>(),\n})\nexport type NpmMatrixConfig = typeof npmMatrixConfigSchema.infer\n\nconst transition = type({\n\tpreviousVersion: `string`,\n\tversion: `string`,\n\tdelta: `'major' | 'premajor' | 'minor' | 'preminor' | 'patch' | 'prepatch' | 'prerelease' | 'release' | 'none'`,\n})\nconst identity = type({\n\tversion: `string`,\n\tsource: `'installed' | 'candidate'`,\n})\nconst reportSchema = type({\n\tpackage: { name: `string`, version: `string` },\n\tmode: `'check' | 'test' | 'coverage-only'`,\n\texitCode: `0 | 1 | 2`,\n\terrors: `string[]`,\n\tcoverage: type({\n\t\tpeer: `string`,\n\t\tera: `string`,\n\t\trepresentatives: `string[]`,\n\t}).array(),\n\tsupport: {\n\t\tstatus: `'unchanged' | 'breaking-release' | 'end-of-support' | 'first-release' | 'not-checked' | 'setup-error'`,\n\t\tchanges: type({\n\t\t\tpeer: `string`,\n\t\t\treason: `'narrowed-range' | 'required-peer'`,\n\t\t\tprevious: `string | null`,\n\t\t\tcurrent: `string | null`,\n\t\t}).array(),\n\t\t\"previousVersion?\": `string`,\n\t\t\"release?\": transition.and({ breaking: `boolean` }),\n\t\t\"error?\": `string`,\n\t},\n\trepresentatives: type({\n\t\tpath: `string`,\n\t\tstatus: `'passed' | 'audited' | 'skipped' | 'compatibility-failure' | 'setup-error'`,\n\t\tpeers: {\n\t\t\t\"[string]\": identity.and({ path: `string`, \"archiveVersion?\": `string` }),\n\t\t},\n\t\tsuites: type({\n\t\t\tpeer: `string`,\n\t\t\tstatus: `'passed' | 'compatibility-failure' | 'setup-error' | 'not-run'`,\n\t\t\t\"output?\": `string`,\n\t\t}).array(),\n\t\twarnings: `string[]`,\n\t\t\"error?\": `string`,\n\t}).array(),\n}).as<NpmReport>()\n\nexport const npmPlanSchema = type({\n\t\"+\": `reject`,\n\tformatVersion: `1`,\n\tid: `string`,\n\trunId: `string`,\n\tcommit: `string`,\n\tconfigs: `string[]`,\n\tpackages: type({\n\t\tconfig: `string`,\n\t\tdirectory: `string`,\n\t\tname: `string`,\n\t\tconfigDigest: `string`,\n\t\tinputDigest: `string`,\n\t\taudit: reportSchema,\n\t\treleases: type({\n\t\t\tcontext: {\n\t\t\t\tpackageName: `string`,\n\t\t\t\tpackageDirectory: `string`,\n\t\t\t\tcurrentVersion: `string`,\n\t\t\t\t\"baseline?\": {\n\t\t\t\t\tversion: `string`,\n\t\t\t\t\t\"ref?\": `string`,\n\t\t\t\t\t\"commit?\": `string`,\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"transition?\": transition,\n\t\t}).array(),\n\t}).array(),\n\tenvironments: type({\n\t\tid: `string`,\n\t\tlabel: `string`,\n\t\tpackageName: `string`,\n\t\trepresentative: `string`,\n\t\tsuites: `string[]`,\n\t\tpeers: { \"[string]\": identity },\n\t}).array(),\n\tarchives: type({ path: `string`, file: `string`, sha256: `string` }).array(),\n})\nexport type NpmPlan = typeof npmPlanSchema.infer\nexport const npmReceiptSchema = type({\n\t\"+\": `reject`,\n\tformatVersion: `1`,\n\tplanId: `string`,\n\tid: `string`,\n\texitCode: `0 | 1 | 2`,\n\t\"report?\": reportSchema,\n\t\"error?\": `string`,\n})\nexport type NpmReceipt = typeof npmReceiptSchema.infer\nexport type NpmVerification = {\n\texitCode: 0 | 1 | 2\n\terrors: string[]\n\tenvironments: number\n}\n\n/** Stable object ordering; arrays retain their semantic order. */\nexport function canonical(value: unknown): string {\n\tif (Array.isArray(value)) return `[${value.map(canonical).join(`,`)}]`\n\tif (value && typeof value === `object`)\n\t\treturn `{${Object.entries(value)\n\t\t\t.filter(([, v]) => v !== undefined)\n\t\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\t\t\t.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`)\n\t\t\t.join(`,`)}}`\n\treturn JSON.stringify(value) ?? `undefined`\n}\nexport function digest(value: string | Uint8Array): string {\n\treturn createHash(`sha256`).update(value).digest(`hex`)\n}\nexport function planDigest(plan: Omit<NpmPlan, `id`>): string {\n\treturn digest(canonical(plan))\n}\nexport function peerIdentities(\n\tpeers: Record<string, NpmPeerEvidence>,\n): Record<string, { version: string; source: `installed` | `candidate` }> {\n\treturn Object.fromEntries(\n\t\tObject.entries(peers).map(([name, { version, source }]) => [\n\t\t\tname,\n\t\t\t{ version, source },\n\t\t]),\n\t)\n}\nexport function requireMatrix(\n\tcondition: unknown,\n\tmessage: string,\n): asserts condition {\n\tif (!condition) throw new Error(message)\n}\nfunction sameNames(\n\tactual: string[],\n\texpected: string[],\n\tmessage: string,\n): void {\n\tconst counts = (names: string[]): Map<string, number> => {\n\t\tconst result = new Map<string, number>()\n\t\tfor (const name of names) result.set(name, (result.get(name) ?? 0) + 1)\n\t\treturn result\n\t}\n\tconst actualCounts = counts(actual)\n\tconst expectedCounts = counts(expected)\n\tconst missing = [...expectedCounts]\n\t\t.filter(([name, count]) => (actualCounts.get(name) ?? 0) < count)\n\t\t.map(([name]) => name)\n\tconst extra = [...actualCounts]\n\t\t.filter(([name, count]) => count > (expectedCounts.get(name) ?? 0))\n\t\t.map(([name]) => name)\n\trequireMatrix(\n\t\t!missing.length && !extra.length,\n\t\t`${message}${missing.length ? ` Missing: ${missing.join(`, `)}.` : ``}${extra.length ? ` Unexpected or duplicated: ${extra.join(`, `)}.` : ``}`,\n\t)\n}\n\n/** Validate the audit as well as the plan envelope; empty or partial plans never pass. */\nexport function validateNpmPlan(value: unknown): NpmPlan {\n\tconst plan = npmPlanSchema.assert(value)\n\tconst { id, ...payload } = plan\n\trequireMatrix(\n\t\tid === planDigest(payload),\n\t\t`Plan digest does not match its contents.`,\n\t)\n\trequireMatrix(\n\t\tplan.runId.length > 0 && /^[a-f0-9]{40,64}$/.test(plan.commit),\n\t\t`Invalid plan source identity.`,\n\t)\n\trequireMatrix(\n\t\tplan.configs.length &&\n\t\t\tplan.packages.length &&\n\t\t\tplan.environments.length &&\n\t\t\tplan.archives.length,\n\t\t`Plan must contain packages, environments, and archives.`,\n\t)\n\tfor (const [name, values] of [\n\t\t[`package`, plan.packages.map((p) => p.name)],\n\t\t[`configuration`, plan.packages.map((p) => p.config)],\n\t\t[`environment`, plan.environments.map((e) => e.id)],\n\t\t[`archive`, plan.archives.map((a) => a.path)],\n\t] as const)\n\t\trequireMatrix(\n\t\t\tnew Set(values).size === values.length,\n\t\t\t`Duplicate ${name} identities in plan.`,\n\t\t)\n\tfor (const archive of plan.archives)\n\t\trequireMatrix(\n\t\t\t/^[a-f0-9]{64}$/.test(archive.sha256) &&\n\t\t\t\tarchive.file === `archives/${archive.sha256}.tgz`,\n\t\t\t`Invalid archive digest or bundle path: ${archive.path}.`,\n\t\t)\n\tsameNames(\n\t\t[...new Set(plan.environments.map((e) => e.packageName))],\n\t\tplan.packages.map((p) => p.name),\n\t\t`Plan environments do not match package audits.`,\n\t)\n\tfor (const pkg of plan.packages) {\n\t\tconst audit = pkg.audit\n\t\trequireMatrix(\n\t\t\taudit.package.name === pkg.name &&\n\t\t\t\taudit.mode === `coverage-only` &&\n\t\t\t\taudit.exitCode === 0 &&\n\t\t\t\taudit.errors.length === 0 &&\n\t\t\t\t!audit.support.error,\n\t\t\t`Coverage audit failed for ${pkg.name}.`,\n\t\t)\n\t\trequireMatrix(\n\t\t\t[`unchanged`, `breaking-release`, `first-release`].includes(\n\t\t\t\taudit.support.status,\n\t\t\t),\n\t\t\t`Support audit did not pass for ${pkg.name}.`,\n\t\t)\n\t\trequireMatrix(\n\t\t\taudit.coverage.length &&\n\t\t\t\taudit.coverage.every((c) => c.representatives.length),\n\t\t\t`Uncovered peer era for ${pkg.name}.`,\n\t\t)\n\t\tconst expected = plan.environments.filter((e) => e.packageName === pkg.name)\n\t\trequireMatrix(\n\t\t\tnew Set(expected.map((e) => e.representative)).size === expected.length,\n\t\t\t`Duplicate representative paths for ${pkg.name}.`,\n\t\t)\n\t\tsameNames(\n\t\t\taudit.representatives.map((r) => r.path),\n\t\t\texpected.map((e) => e.representative),\n\t\t\t`Missing or duplicate audited environments for ${pkg.name}.`,\n\t\t)\n\t\tfor (const env of expected) {\n\t\t\tconst result = audit.representatives.find(\n\t\t\t\t(r) => r.path === env.representative,\n\t\t\t)!\n\t\t\trequireMatrix(\n\t\t\t\tresult.status === `audited` && !result.error && env.suites.length,\n\t\t\t\t`Environment was not audited: ${pkg.name} / ${env.representative}.`,\n\t\t\t)\n\t\t\tsameNames(\n\t\t\t\tresult.suites.map((s) => s.peer),\n\t\t\t\tenv.suites,\n\t\t\t\t`Audited suites differ: ${env.id}.`,\n\t\t\t)\n\t\t\trequireMatrix(\n\t\t\t\tnew Set(env.suites).size === env.suites.length &&\n\t\t\t\t\tresult.suites.every((s) => s.status === `not-run`),\n\t\t\t\t`Invalid audited suites: ${env.id}.`,\n\t\t\t)\n\t\t\trequireMatrix(\n\t\t\t\tcanonical(peerIdentities(result.peers)) === canonical(env.peers),\n\t\t\t\t`Audited peer identities differ: ${env.id}.`,\n\t\t\t)\n\t\t}\n\t\tfor (const coverage of audit.coverage)\n\t\t\tfor (const name of coverage.representatives)\n\t\t\t\trequireMatrix(\n\t\t\t\t\texpected.some(\n\t\t\t\t\t\t(e) =>\n\t\t\t\t\t\t\te.representative === name && e.suites.includes(coverage.peer),\n\t\t\t\t\t),\n\t\t\t\t\t`Coverage references an unplanned suite: ${pkg.name} / ${name} / ${coverage.peer}.`,\n\t\t\t\t)\n\t}\n\treturn plan\n}\n\n/** Pure receipt verification; runner-local installation paths are diagnostic only. */\nexport function verifyNpmReceipts(\n\tvalue: unknown,\n\treceipts: readonly unknown[],\n): NpmVerification {\n\tconst errors: string[] = []\n\tlet environments = 0\n\ttry {\n\t\tconst plan = validateNpmPlan(value)\n\t\tenvironments = plan.environments.length\n\t\tconst parsed = receipts.map((r, i) => {\n\t\t\ttry {\n\t\t\t\treturn npmReceiptSchema.assert(r)\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Malformed receipt ${i + 1}: ${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t\t\t\t{ cause },\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\t\tconst environmentName = (id: string): string => {\n\t\t\tconst env = plan.environments.find((e) => e.id === id)\n\t\t\treturn env ? `${env.packageName} / ${env.representative} (${id})` : id\n\t\t}\n\t\tsameNames(\n\t\t\tparsed.map((r) => environmentName(r.id)),\n\t\t\tplan.environments.map((e) => environmentName(e.id)),\n\t\t\t`Missing, duplicate, or unexpected environment receipts.`,\n\t\t)\n\t\tfor (const env of plan.environments) {\n\t\t\ttry {\n\t\t\t\tconst receipt = parsed.find((r) => r.id === env.id)!\n\t\t\t\trequireMatrix(\n\t\t\t\t\treceipt.planId === plan.id,\n\t\t\t\t\t`Receipt belongs to a different plan.`,\n\t\t\t\t)\n\t\t\t\trequireMatrix(\n\t\t\t\t\treceipt.exitCode === 0 && !receipt.error && receipt.report,\n\t\t\t\t\treceipt.error ?? `Environment execution failed.`,\n\t\t\t\t)\n\t\t\t\tconst report = receipt.report\n\t\t\t\tconst pkg = plan.packages.find((p) => p.name === env.packageName)!\n\t\t\t\trequireMatrix(\n\t\t\t\t\tcanonical(report.package) === canonical(pkg.audit.package),\n\t\t\t\t\t`Wrong package identity.`,\n\t\t\t\t)\n\t\t\t\trequireMatrix(\n\t\t\t\t\treport.mode === `test` &&\n\t\t\t\t\t\treport.exitCode === 0 &&\n\t\t\t\t\t\treport.errors.length === 0 &&\n\t\t\t\t\t\treport.support.status === `not-checked` &&\n\t\t\t\t\t\t!report.support.error,\n\t\t\t\t\t`Receipt does not contain a successful execution report.`,\n\t\t\t\t)\n\t\t\t\tsameNames(\n\t\t\t\t\treport.representatives.map((r) => r.path),\n\t\t\t\t\tpkg.audit.representatives.map((r) => r.path),\n\t\t\t\t\t`Missing or duplicate representatives in execution report.`,\n\t\t\t\t)\n\t\t\t\tfor (const result of report.representatives) {\n\t\t\t\t\tif (result.path !== env.representative) {\n\t\t\t\t\t\trequireMatrix(\n\t\t\t\t\t\t\tresult.status === `skipped` &&\n\t\t\t\t\t\t\t\tresult.suites.length === 0 &&\n\t\t\t\t\t\t\t\t!result.error,\n\t\t\t\t\t\t\t`Unexpected execution: ${result.path}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\trequireMatrix(\n\t\t\t\t\t\tresult.status === `passed` && !result.error,\n\t\t\t\t\t\t`Environment did not execute successfully.`,\n\t\t\t\t\t)\n\t\t\t\t\tsameNames(\n\t\t\t\t\t\tresult.suites.map((s) => s.peer),\n\t\t\t\t\t\tenv.suites,\n\t\t\t\t\t\t`Missing, duplicate, or unexpected relationship suites.`,\n\t\t\t\t\t)\n\t\t\t\t\tfor (const suite of result.suites)\n\t\t\t\t\t\trequireMatrix(\n\t\t\t\t\t\t\tsuite.status === `passed`,\n\t\t\t\t\t\t\t`Suite did not pass: ${suite.peer}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\trequireMatrix(\n\t\t\t\t\t\tcanonical(peerIdentities(result.peers)) === canonical(env.peers),\n\t\t\t\t\t\t`Installed peer identities differ from the audit.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`${env.packageName} / ${env.representative}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\terrors.push(error instanceof Error ? error.message : String(error))\n\t}\n\treturn { exitCode: errors.length ? 2 : 0, errors, environments }\n}\n","import { existsSync } from \"node:fs\"\nimport path from \"node:path\"\n\nimport { type } from \"arktype\"\nimport { cli, options, type ConfigInput } from \"comline\"\n\nimport { npmConfigSchema } from \"./npm/config.ts\"\nimport { npmMatrixConfigSchema } from \"./npm/matrix-model.ts\"\nimport {\n\treleaseSchema,\n\tvalidateRelease,\n\trejectCertificationOptions,\n} from \"./release.ts\"\n\n// Reuse these field schemas for CLI metadata even though hooks cannot become JSON Schema.\nexport const configFields = {\n\ttagPattern: type(`string`),\n\tbaselineFile: type(`string`),\n\ttestPattern: type(`string`),\n\ttestCommand: type(`string`),\n\ttest: type(`string`),\n\tbaseDirname: type(`string`),\n\tverbose: type(`boolean`),\n\tout: type(`string`),\n}\nexport const configSchema = type({\n\t\"+\": `reject`,\n\t\"tagPattern?\": configFields.tagPattern.or(`undefined`),\n\t\"baselineFile?\": configFields.baselineFile.or(`undefined`),\n\t\"testPattern?\": configFields.testPattern,\n\t\"testCommand?\": configFields.testCommand,\n\t\"test?\": configFields.test,\n\t\"baseDirname?\": configFields.baseDirname,\n\t\"verbose?\": configFields.verbose.or(`undefined`),\n\t\"out?\": configFields.out,\n\t\"release?\": releaseSchema,\n\t\"npm?\": npmConfigSchema,\n\t\"npmMatrix?\": npmMatrixConfigSchema,\n})\n\n/** The complete config, with no fields exposed to argv by this loader. */\nexport const configOptions = options(`Breakage configuration`, configSchema, {\n\ttagPattern: { configOnly: true },\n\tbaselineFile: { configOnly: true },\n\ttestPattern: { configOnly: true },\n\ttestCommand: { configOnly: true },\n\ttest: { configOnly: true },\n\tbaseDirname: { configOnly: true },\n\tverbose: { configOnly: true },\n\tout: { configOnly: true },\n\trelease: { configOnly: true },\n\tnpm: { configOnly: true },\n\tnpmMatrix: { configOnly: true },\n})\nexport type BreakageConfig = ConfigInput<typeof configOptions>\n\n/** Share the root release model with npm checks unless they supply their own. */\nexport function defineConfig(config: BreakageConfig): BreakageConfig {\n\tif (config && typeof config === `object`) {\n\t\trejectCertificationOptions(config)\n\t\tif (config.npm) rejectCertificationOptions(config.npm)\n\t\tif (config.release !== undefined) validateRelease(config.release)\n\t\tif (config.npm?.release !== undefined) validateRelease(config.npm.release)\n\t}\n\tconfigSchema.assert(config)\n\treturn {\n\t\t...config,\n\t\t...(config.npm\n\t\t\t? {\n\t\t\t\t\tnpm: {\n\t\t\t\t\t\t...config.npm,\n\t\t\t\t\t\t...(config.release && config.npm.release === undefined\n\t\t\t\t\t\t\t? { release: config.release }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n}\n\nexport function defaultConfig(directory: string): string {\n\tconst filename = path.join(directory, `breakage.config.ts`)\n\tif (\n\t\t!existsSync(filename) &&\n\t\texistsSync(path.join(directory, `breakage.config.json`))\n\t)\n\t\tthrow new Error(\n\t\t\t`JSON configuration was removed. Migrate breakage.config.json to breakage.config.ts.`,\n\t\t)\n\treturn filename\n}\n\n/** Comline ignores absent discovered files; explicit paths must exist. */\nexport function configPath(filename: string, required = true): string {\n\tconst absolute = path.resolve(filename)\n\tif (path.extname(absolute) !== `.ts`)\n\t\tthrow new Error(\n\t\t\t`Configuration must be a .ts module with a default export; JSON configuration was removed.`,\n\t\t)\n\tif (required && !existsSync(absolute))\n\t\tthrow new Error(`Configuration file does not exist: ${absolute}`)\n\treturn absolute\n}\n\n/** Apply application semantics after Comline validates and merges configuration. */\nexport function resolveConfig(\n\tconfig: BreakageConfig,\n\tfilename?: string,\n): BreakageConfig {\n\treturn {\n\t\t...defineConfig(config),\n\t\tbaseDirname: path.resolve(\n\t\t\tfilename ? path.dirname(filename) : process.cwd(),\n\t\t\tconfig.baseDirname ?? `.`,\n\t\t),\n\t}\n}\n\n/** Use Comline's module loading and full-schema validation for programmatic and npm consumers. */\nexport async function loadConfig(filename: string): Promise<BreakageConfig> {\n\tconst absolute = configPath(filename)\n\tconst parse = cli({\n\t\tcliName: `breakage`,\n\t\trouteOptions: { \"\": configOptions },\n\t\tdiscoverConfigPath: () => absolute,\n\t})\n\treturn resolveConfig(\n\t\t(await parse.async([process.execPath, `breakage`])).inputs.opts,\n\t\tabsolute,\n\t)\n}\n","import path from \"node:path\"\n\nimport semver from \"semver\"\nimport { simpleGit } from \"simple-git\"\n\nimport { resolveReleaseDelta, type ReleaseDeltaContext } from \"../release.ts\"\nimport { readBaseline } from \"../baseline.ts\"\nimport { withDirectoryLock } from \"../directory-lock.ts\"\nimport { latestReleaseTag } from \"../release-tag.ts\"\nimport { validatePeerRanges } from \"./config.ts\"\nimport type { Manifest } from \"./manifest.ts\"\nimport { normalizeWorkspacePeers, parseManifest } from \"./manifest.ts\"\nimport type { NpmConfig, SupportChange } from \"./types.ts\"\n\nexport async function releaseVersion(\n\tconfig: NpmConfig,\n\tcontext: ReleaseDeltaContext,\n): Promise<string | undefined> {\n\treturn config.release\n\t\t? (await resolveReleaseDelta(config.release, context))?.version\n\t\t: undefined\n}\n\n/**\n * Compare the union, including adjacent alternatives. semver.subset compares each\n * conjunction to a single conjunction and cannot prove coverage by their union.\n * Membership can change only at comparator boundaries or prerelease tuple gates.\n */\nexport function includesRange(current: string, previous: string): boolean {\n\tconst ranges = [new semver.Range(previous), new semver.Range(current)]\n\tconst samples = new Set<string>([`0.0.0`, `0.0.0-0`])\n\tfor (const range of ranges) {\n\t\tfor (const conjunction of range.set) {\n\t\t\tfor (const comparator of conjunction) {\n\t\t\t\tconst version = comparator.semver\n\t\t\t\tif (typeof version === `symbol`) continue\n\t\t\t\tconst base = `${version.major}.${version.minor}.${version.patch}`\n\t\t\t\tsamples.add(version.version)\n\t\t\t\tsamples.add(base)\n\t\t\t\tsamples.add(`${base}-0`)\n\t\t\t\t// The immediate successor in a prerelease sequence appends numeric zero.\n\t\t\t\tif (version.prerelease.length) samples.add(`${version.version}.0`)\n\t\t\t\t// Stable versions are discrete; the next patch starts another tuple gate.\n\t\t\t\tconst next = semver.inc(base, `patch`)\n\t\t\t\tif (next) {\n\t\t\t\t\tsamples.add(next)\n\t\t\t\t\tsamples.add(`${next}-0`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn [...samples].every(\n\t\t(version) =>\n\t\t\t!semver.satisfies(version, previous) ||\n\t\t\tsemver.satisfies(version, current),\n\t)\n}\n\nexport function supportChanges(\n\tprevious: Manifest,\n\tcurrent: Manifest,\n): SupportChange[] {\n\tconst before = previous.peerDependencies ?? {}\n\tconst after = current.peerDependencies ?? {}\n\tvalidatePeerRanges(before)\n\tvalidatePeerRanges(after)\n\treturn Object.entries(after).flatMap(([peer, range]) => {\n\t\tconst old = before[peer]\n\t\tconst wasOptional = previous.peerDependenciesMeta?.[peer]?.optional === true\n\t\tconst isOptional = current.peerDependenciesMeta?.[peer]?.optional === true\n\t\t// Absence scenarios are not generated, but making an optional peer required\n\t\t// still changes the installation contract for existing consumers.\n\t\treturn (old === undefined && isOptional) ||\n\t\t\t(old !== undefined &&\n\t\t\t\tincludesRange(range, old) &&\n\t\t\t\t!(wasOptional && !isOptional))\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tpeer,\n\t\t\t\t\t\treason:\n\t\t\t\t\t\t\told === undefined || (wasOptional && !isOptional)\n\t\t\t\t\t\t\t\t? (`required-peer` as const)\n\t\t\t\t\t\t\t\t: (`narrowed-range` as const),\n\t\t\t\t\t\tprevious: old ?? null,\n\t\t\t\t\t\tcurrent: range,\n\t\t\t\t\t},\n\t\t\t\t]\n\t})\n}\n\nexport async function previousManifest(\n\tconfig: NpmConfig,\n\tdirectory: string,\n): Promise<Manifest | undefined> {\n\tif (`firstRelease` in config.baseline) return undefined\n\tconst git = simpleGit(directory)\n\tlet commit: string\n\tif (config.baseline.baselineFile) {\n\t\tcommit = (\n\t\t\tawait readBaseline(\n\t\t\t\tgit,\n\t\t\t\tpath.resolve(directory, config.baseline.baselineFile),\n\t\t\t\tconfig.baseline,\n\t\t\t)\n\t\t).commit\n\t} else {\n\t\tconst tags = await git.listRemote([`--tags`, `origin`])\n\t\tconst ref = latestReleaseTag(tags, config.baseline.tagPattern)\n\t\tif (!ref)\n\t\t\tthrow new Error(\n\t\t\t\t`No npm release baseline found; configure a tag pattern or explicitly declare firstRelease.`,\n\t\t\t)\n\t\tconst refs = new Map(\n\t\t\ttags\n\t\t\t\t.trim()\n\t\t\t\t.split(`\\n`)\n\t\t\t\t.map((line) => {\n\t\t\t\t\tconst [sha, name] = line.split(`\\t`)\n\t\t\t\t\treturn [name, sha]\n\t\t\t\t}),\n\t\t)\n\t\tconst resolved = refs.get(`${ref}^{}`) ?? refs.get(ref)\n\t\tif (!resolved || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(resolved))\n\t\t\tthrow new Error(`Invalid release commit for ${ref}.`)\n\t\tcommit = resolved\n\t\tconst common = await git.revparse([\n\t\t\t`--path-format=absolute`,\n\t\t\t`--git-common-dir`,\n\t\t])\n\t\tawait withDirectoryLock(path.join(common, `breakage-fetch.lock`), () =>\n\t\t\tgit.fetch([`origin`, commit, `--no-tags`, `--no-write-fetch-head`]),\n\t\t)\n\t}\n\tconst prefix = await git.revparse([`--show-prefix`])\n\tconst manifest = parseManifest(\n\t\tJSON.parse(await git.show([`${commit}:${prefix}package.json`])),\n\t\t`release ${commit}`,\n\t)\n\treturn await normalizeWorkspacePeers(manifest, async (peer) => {\n\t\tconst local = config.localPeers?.[peer]\n\t\tif (!local)\n\t\t\tthrow new Error(\n\t\t\t\t`Historical workspace peer ${peer} needs a localPeers directory to resolve release ${commit}.`,\n\t\t\t)\n\t\tconst root = await git.revparse([`--show-toplevel`])\n\t\tconst relative = path.relative(\n\t\t\troot,\n\t\t\tpath.resolve(directory, local.directory),\n\t\t)\n\t\tif (\n\t\t\trelative === `..` ||\n\t\t\trelative.startsWith(`..${path.sep}`) ||\n\t\t\tpath.isAbsolute(relative)\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t`Historical workspace peer ${peer} escapes the release repository.`,\n\t\t\t)\n\t\tconst filename = path\n\t\t\t.join(relative, `package.json`)\n\t\t\t.split(path.sep)\n\t\t\t.join(`/`)\n\t\tconst historical = parseManifest(\n\t\t\tJSON.parse(await git.show([`${commit}:${filename}`])),\n\t\t\t`release ${commit}:${filename}`,\n\t\t)\n\t\tif (historical.name !== peer)\n\t\t\tthrow new Error(\n\t\t\t\t`Historical workspace peer identity mismatch for ${peer}.`,\n\t\t\t)\n\t\treturn historical.version\n\t})\n}\n","import { randomUUID } from \"node:crypto\"\nimport * as fs from \"node:fs/promises\"\nimport {\n\tcopyFile,\n\tlstat,\n\tmkdir,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\"\nimport { createRequire } from \"node:module\"\nimport path from \"node:path\"\n\nimport semver from \"semver\"\nimport { simpleGit } from \"simple-git\"\n\nimport { prepare } from \"../task.ts\"\nimport { validatePeerRanges } from \"./config.ts\"\nimport type { Manifest } from \"./manifest.ts\"\nimport { matches, normalizeWorkspacePeers, readManifest } from \"./manifest.ts\"\nimport { releaseVersion } from \"./release.ts\"\nimport type { NpmConfig, NpmPeerEvidence, NpmSuite } from \"./types.ts\"\n\nexport type Environment = {\n\tdirectory: string\n\tstage: string\n\tmanifest: Manifest\n\tpeers: Record<string, NpmPeerEvidence>\n\tcandidates: Record<\n\t\tstring,\n\t\t{\n\t\t\tdirectory: string\n\t\t\tartifact: string\n\t\t\tcurrentVersion: string\n\t\t\tversion: string\n\t\t\tmanifest: Manifest\n\t\t}\n\t>\n}\n\nexport function within(parent: string, child: string): boolean {\n\tconst relative = path.relative(parent, child)\n\treturn (\n\t\trelative === `` ||\n\t\t(!relative.startsWith(`..${path.sep}`) &&\n\t\t\trelative !== `..` &&\n\t\t\t!path.isAbsolute(relative))\n\t)\n}\n\nasync function exists(filename: string): Promise<boolean> {\n\ttry {\n\t\tawait lstat(filename)\n\t\treturn true\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === `ENOENT`) return false\n\t\tthrow error\n\t}\n}\n\nexport async function discover(\n\tconfig: NpmConfig,\n\tbase: string,\n): Promise<string[]> {\n\tconst found = new Set<string>()\n\tfor await (const name of fs.glob(config.representatives, {\n\t\tcwd: base,\n\t\texclude: [`**/node_modules/**`, `**/test/**`, `**/.git/**`],\n\t})) {\n\t\tconst directory = path.resolve(base, name)\n\t\tif (!(await lstat(directory)).isDirectory())\n\t\t\tthrow new Error(`Representative is not a directory: ${name}.`)\n\t\tfound.add(directory)\n\t}\n\tif (!found.size)\n\t\tthrow new Error(\n\t\t\t`No representative directories matched the configured globs.`,\n\t\t)\n\treturn [...found].sort()\n}\n\n/** A freshly created ignored stage is also the exclusive ownership lock. */\nexport async function withStage<T>(\n\tdirectory: string,\n\taction: (stage: string) => Promise<T>,\n): Promise<T> {\n\tconst stage = path.join(directory, `test`)\n\tconst git = simpleGit(directory)\n\tconst root = await git.revparse([`--show-toplevel`])\n\tif (!within(await realpath(root), await realpath(directory)))\n\t\tthrow new Error(`Representative escapes the repository: ${directory}.`)\n\tif (\n\t\t!(await git.raw([`check-ignore`, `--`, `${stage}/`])).trim() ||\n\t\t(await git.raw([`ls-files`, `--`, stage])).trim()\n\t) {\n\t\tthrow new Error(\n\t\t\t`Representative test/ must be gitignored and contain no tracked files: ${stage}.`,\n\t\t)\n\t}\n\ttry {\n\t\tawait mkdir(stage)\n\t} catch (cause) {\n\t\tthrow new Error(\n\t\t\t`Cannot own ${stage}; another run or preexisting files may be present. Remove it only after checking ownership.`,\n\t\t\t{ cause },\n\t\t)\n\t}\n\ttry {\n\t\treturn await action(stage)\n\t} finally {\n\t\tawait rm(stage, { recursive: true, force: true })\n\t}\n}\n\nasync function installed(\n\tdirectory: string,\n\tpeer: string,\n): Promise<NpmPeerEvidence> {\n\tconst location = path.join(directory, `node_modules`, peer)\n\tconst physical = await realpath(location)\n\t// Support pnpm's store links, while rejecting arbitrary workspace source links.\n\tif (!physical.split(path.sep).includes(`node_modules`))\n\t\tthrow new Error(`Peer ${peer} resolves to workspace source: ${physical}.`)\n\tconst manifest = await readManifest(path.join(physical, `package.json`))\n\tif (manifest.name !== peer)\n\t\tthrow new Error(`Expected ${peer}, found ${manifest.name} in ${location}.`)\n\treturn { version: manifest.version, path: physical, source: `installed` }\n}\n\nfunction representativeDeclarations(\n\tmanifest: Manifest,\n): Record<string, string> {\n\tfor (const field of [\n\t\t`dependencies`,\n\t\t`devDependencies`,\n\t\t`optionalDependencies`,\n\t\t`peerDependencies`,\n\t] as const) {\n\t\tfor (const [name, specifier] of Object.entries(manifest[field] ?? {})) {\n\t\t\tconst version = semver.parse(specifier)\n\t\t\t// Semver's normalized version omits build metadata; exact pins retain it.\n\t\t\tconst exact =\n\t\t\t\tversion &&\n\t\t\t\t`${version.version}${version.build.length ? `+${version.build.join(`.`)}` : ``}`\n\t\t\tif (!exact || specifier !== exact)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Representative ${manifest.name} must pin ${field}.${name} to an exact version, such as 1.0.0; received ${JSON.stringify(specifier)}. Declare support ranges in the package under test, and use breakage.candidates for coordinated local releases.`,\n\t\t\t\t)\n\t\t}\n\t}\n\tfor (const [peer, development] of Object.entries(\n\t\tmanifest.devDependencies ?? {},\n\t)) {\n\t\tfor (const field of [`dependencies`, `optionalDependencies`] as const) {\n\t\t\tconst runtime = manifest[field]?.[peer]\n\t\t\tif (runtime !== undefined && runtime !== development)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Conflicting representative declarations for ${peer}: devDependencies has ${development}, but ${field} has ${runtime}. Use one consistent requirement.`,\n\t\t\t\t)\n\t\t}\n\t}\n\t// Optional runtime declarations retain npm's override of required ones.\n\treturn {\n\t\t...manifest.devDependencies,\n\t\t...manifest.dependencies,\n\t\t...manifest.optionalDependencies,\n\t}\n}\n\n/** Select exact pins without acquiring or preparing their stages. */\nexport async function maySelectEnvironment(\n\tconfig: NpmConfig,\n\tbase: string,\n\tdirectory: string,\n\tpackageManifest: Manifest,\n\tselection: { peer: string; range: string },\n): Promise<boolean> {\n\tconst manifest = await readManifest(path.join(directory, `package.json`))\n\tconst declarations = representativeDeclarations(manifest)\n\tconst { peer, range } = selection\n\tif (peer === packageManifest.name)\n\t\treturn matches(packageManifest.version, range)\n\tif (manifest.breakage?.candidates?.includes(peer)) {\n\t\tconst local = config.localPeers?.[peer]\n\t\tif (!local)\n\t\t\tthrow new Error(`Candidate ${peer} has no localPeers configuration.`)\n\t\tconst packageDirectory = path.resolve(base, local.directory)\n\t\tconst current = await readManifest(\n\t\t\tpath.join(packageDirectory, `package.json`),\n\t\t)\n\t\tif (current.name !== peer)\n\t\t\tthrow new Error(`Local peer identity mismatch for ${peer}.`)\n\t\tconst release = await releaseVersion(config, {\n\t\t\tpackageName: peer,\n\t\t\tpackageDirectory,\n\t\t\tcurrentVersion: current.version,\n\t\t})\n\t\tif (release === undefined)\n\t\t\tthrow new Error(`Candidate ${peer} has no release version.`)\n\t\treturn matches(release, range)\n\t}\n\tconst declared = declarations[peer]\n\treturn declared !== undefined && matches(declared, range)\n}\n\nexport async function prepareEnvironment(\n\tconfig: NpmConfig,\n\tbase: string,\n\tdirectory: string,\n\tstage: string,\n\tpackageManifest: Manifest,\n): Promise<Environment> {\n\tconst peerNames = Object.keys(packageManifest.peerDependencies ?? {})\n\tconst filename = path.join(directory, `package.json`)\n\tconst lockfile = path.join(directory, config.lockfile)\n\tfor (const input of [filename, lockfile]) {\n\t\tif (\n\t\t\t!(await lstat(input)).isFile() ||\n\t\t\t!within(directory, await realpath(input))\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t`Installation inputs must be regular files inside the representative: ${input}.`,\n\t\t\t)\n\t}\n\tconst inputs = await Promise.all([readFile(filename), readFile(lockfile)])\n\tconst manifest = await readManifest(filename)\n\tconst declarations = representativeDeclarations(manifest)\n\tconst candidates: Environment[`candidates`] = {}\n\tfor (const peer of manifest.breakage?.candidates ?? []) {\n\t\tif (!peerNames.includes(peer))\n\t\t\tthrow new Error(\n\t\t\t\t`Candidate ${peer} is not a declared peer of the package under test.`,\n\t\t\t)\n\t\tconst local = config.localPeers?.[peer]\n\t\tif (!local)\n\t\t\tthrow new Error(`Candidate ${peer} has no localPeers configuration.`)\n\t\tconst localDirectory = path.resolve(base, local.directory)\n\t\tconst localManifest = await normalizeWorkspacePeers(\n\t\t\tawait readManifest(path.join(localDirectory, `package.json`)),\n\t\t)\n\t\tif (localManifest.name !== peer)\n\t\t\tthrow new Error(`Local peer identity mismatch for ${peer}.`)\n\t\tvalidatePeerRanges(localManifest.peerDependencies ?? {})\n\t\tconst evidence = await releaseVersion(config, {\n\t\t\tpackageName: peer,\n\t\t\tpackageDirectory: localDirectory,\n\t\t\tcurrentVersion: localManifest.version,\n\t\t})\n\t\tif (evidence === undefined)\n\t\t\tthrow new Error(`Candidate ${peer} has no release version.`)\n\t\tcandidates[peer] = {\n\t\t\tdirectory: localDirectory,\n\t\t\tartifact: path.resolve(base, local.artifact),\n\t\t\tcurrentVersion: localManifest.version,\n\t\t\tversion: evidence,\n\t\t\tmanifest: localManifest,\n\t\t}\n\t}\n\tconst relevant = [\n\t\t...new Set([\n\t\t\t...peerNames,\n\t\t\t...Object.values(candidates).flatMap((candidate) =>\n\t\t\t\tObject.keys(candidate.manifest.peerDependencies ?? {}),\n\t\t\t),\n\t\t]),\n\t].filter(\n\t\t(peer) =>\n\t\t\tpeer === packageManifest.name ||\n\t\t\tdeclarations[peer] !== undefined ||\n\t\t\tcandidates[peer] !== undefined,\n\t)\n\tconst before: Record<string, string> = {}\n\tfor (const peer of relevant) {\n\t\tif (\n\t\t\tpeer !== packageManifest.name &&\n\t\t\t!candidates[peer] &&\n\t\t\t(await exists(path.join(directory, `node_modules`, peer)))\n\t\t)\n\t\t\tbefore[peer] = (await installed(directory, peer)).version\n\t}\n\tconst preparation = await prepare(config.prepareCommand, directory).then(\n\t\t() => ({ ok: true as const }),\n\t\t(error: unknown) => ({ ok: false as const, error }),\n\t)\n\tconst after = await Promise.all(\n\t\t[filename, lockfile].map((input) =>\n\t\t\treadFile(input).catch(() => Buffer.alloc(0)),\n\t\t),\n\t)\n\tif (inputs.some((input, index) => !input.equals(after[index]!))) {\n\t\tawait Promise.all(\n\t\t\t[filename, lockfile].map(async (input, index) => {\n\t\t\t\t// Recreate an input rather than writing through a link introduced by a command.\n\t\t\t\tawait rm(input, { force: true })\n\t\t\t\tawait writeFile(input, inputs[index]!, { flag: `wx` })\n\t\t\t}),\n\t\t)\n\t\tthrow new Error(\n\t\t\t`Frozen preparation changed the manifest or lockfile in ${directory}; restored the original inputs.`,\n\t\t\t{ cause: preparation.ok ? undefined : preparation.error },\n\t\t)\n\t}\n\tif (!preparation.ok) throw preparation.error\n\tconst peers: Environment[`peers`] = {}\n\tfor (const peer of relevant) {\n\t\tconst candidate = candidates[peer]\n\t\tconst staged = candidate !== undefined || peer === packageManifest.name\n\t\tif (\n\t\t\t!staged &&\n\t\t\tObject.hasOwn(manifest.optionalDependencies ?? {}, peer) &&\n\t\t\t!(await exists(path.join(directory, `node_modules`, peer)))\n\t\t)\n\t\t\tcontinue\n\t\tconst evidence: NpmPeerEvidence = staged\n\t\t\t? {\n\t\t\t\t\tversion: candidate?.version ?? packageManifest.version,\n\t\t\t\t\tpath: path.join(stage, `node_modules`, peer),\n\t\t\t\t\tsource: `candidate`,\n\t\t\t\t}\n\t\t\t: await installed(directory, peer)\n\t\tconst specifier = declarations[peer]\n\t\tif (\n\t\t\t!(staged && specifier === undefined) &&\n\t\t\tevidence.version !== specifier\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Representative ${peer}@${evidence.version} does not match its manifest pin ${specifier ?? `(missing)`}.`,\n\t\t\t)\n\t\t}\n\t\tif (before[peer] && before[peer] !== evidence.version)\n\t\t\tthrow new Error(\n\t\t\t\t`Stale installed ${peer}: frozen preparation changed ${before[peer]} to ${evidence.version}.`,\n\t\t\t)\n\t\tfor (const [localPeer, local] of Object.entries(config.localPeers ?? {})) {\n\t\t\tif (staged) continue\n\t\t\tconst localDirectory = path.resolve(base, local.directory)\n\t\t\t// Historical-only registrations need not exist in today's checkout.\n\t\t\tif (\n\t\t\t\t!peerNames.includes(localPeer) &&\n\t\t\t\t!relevant.includes(localPeer) &&\n\t\t\t\t!(await exists(localDirectory))\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tif (within(await realpath(localDirectory), evidence.path))\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Released peer ${peer} resolves into a local workspace package.`,\n\t\t\t\t)\n\t\t}\n\t\tpeers[peer] = evidence\n\t}\n\treturn { directory, stage, manifest, peers, candidates }\n}\n\n/** Validate the complete coordinated formulation before an audit or execution. */\nexport function checkCandidatePeers(\n\tenvironment: Environment,\n\tfocused: boolean,\n): string[] {\n\tconst conflicts: string[] = []\n\tfor (const [name, candidate] of Object.entries(environment.candidates)) {\n\t\tfor (const [peer, range] of Object.entries(\n\t\t\tcandidate.manifest.peerDependencies ?? {},\n\t\t)) {\n\t\t\tconst evidence = environment.peers[peer]\n\t\t\tif (!evidence) {\n\t\t\t\tif (candidate.manifest.peerDependenciesMeta?.[peer]?.optional) continue\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Complete representative is missing required peer ${peer}: ${range} of coordinated candidate ${name}@${candidate.version}.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\t// This is declaration membership; exact-preview coverage is audited separately.\n\t\t\tif (!semver.satisfies(evidence.version, range))\n\t\t\t\tconflicts.push(\n\t\t\t\t\t`Coordinated candidate ${name}@${candidate.version} requires ${peer}: ${range}, but the representative provides ${peer}@${evidence.version}.`,\n\t\t\t\t)\n\t\t}\n\t}\n\tif (conflicts.length && !focused) throw new Error(conflicts.join(`\\n`))\n\treturn conflicts.map(\n\t\t(conflict) =>\n\t\t\t`${conflict} Running focused exploration outside declared support.`,\n\t)\n}\n\nasync function copySuite(\n\tbase: string,\n\tstage: string,\n\tsuite: NpmSuite,\n): Promise<void> {\n\tfor (const pattern of suite.files) {\n\t\tif (path.isAbsolute(pattern) || pattern.split(/[\\\\/]/).includes(`..`))\n\t\t\tthrow new Error(`Suite pattern must stay inside the package: ${pattern}.`)\n\t\tlet count = 0\n\t\tfor await (const filename of fs.glob(pattern, {\n\t\t\tcwd: base,\n\t\t\texclude: [\n\t\t\t\t`**/node_modules/**`,\n\t\t\t\t`**/.git/**`,\n\t\t\t\tpath.relative(base, stage),\n\t\t\t\t`${path.relative(base, stage)}/**`,\n\t\t\t],\n\t\t})) {\n\t\t\tconst source = path.resolve(base, filename)\n\t\t\tconst stat = await lstat(source)\n\t\t\tif (stat.isDirectory()) continue\n\t\t\tif (\n\t\t\t\t!stat.isFile() ||\n\t\t\t\t!within(await realpath(base), await realpath(source))\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Suite inputs must be regular package files: ${filename}.`,\n\t\t\t\t)\n\t\t\t// Refuse a symlink anywhere in the source path, even if its target is internal.\n\t\t\tlet segment = base\n\t\t\tfor (const part of filename.split(path.sep)) {\n\t\t\t\tsegment = path.join(segment, part)\n\t\t\t\tif ((await lstat(segment)).isSymbolicLink())\n\t\t\t\t\tthrow new Error(`Suite inputs cannot follow symlinks: ${filename}.`)\n\t\t\t}\n\t\t\tif (\n\t\t\t\t[\n\t\t\t\t\t`package.json`,\n\t\t\t\t\t`package-lock.json`,\n\t\t\t\t\t`npm-shrinkwrap.json`,\n\t\t\t\t\t`.npmrc`,\n\t\t\t\t].includes(filename) ||\n\t\t\t\tfilename.split(path.sep).includes(`node_modules`)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Suite input collides with the consumer installation: ${filename}.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst destination = path.resolve(stage, filename)\n\t\t\tif (!within(stage, destination))\n\t\t\t\tthrow new Error(`Suite path escapes its stage: ${filename}.`)\n\t\t\tawait mkdir(path.dirname(destination), { recursive: true })\n\t\t\tawait copyFile(source, destination)\n\t\t\tcount++\n\t\t}\n\t\tif (!count) throw new Error(`Suite pattern matched no files: ${pattern}.`)\n\t}\n}\n\nasync function findPackage(\n\tfrom: string,\n\tname: string,\n\tinstallation: string,\n): Promise<string | undefined> {\n\tconst origin = await realpath(from)\n\t// A linked store package may resolve siblings in its own installation namespace.\n\t// Never grant access to the store's or checkout's unrelated ancestor installs.\n\tconst parts = origin.split(path.sep)\n\tconst modules = parts.lastIndexOf(`node_modules`)\n\tconst boundary = within(installation, origin)\n\t\t? installation\n\t\t: modules < 0\n\t\t\t? origin\n\t\t\t: parts.slice(0, modules + 1).join(path.sep)\n\tconst lookup =\n\t\tcreateRequire(path.join(origin, `__breakage_probe__.ts`)).resolve.paths(\n\t\t\tname,\n\t\t) ?? []\n\tfor (const directory of lookup) {\n\t\tconst location = path.join(directory, name)\n\t\t// An installed but broken package must fail verification, not look absent.\n\t\tif (await exists(location)) {\n\t\t\tif (!within(installation, directory) && !within(boundary, directory))\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Dependency ${name} resolves outside the representative installation: ${location}.`,\n\t\t\t\t)\n\t\t\treturn await realpath(location)\n\t\t}\n\t}\n\treturn undefined\n}\n\nasync function resolvePackage(\n\tfrom: string,\n\tname: string,\n\tinstallation: string,\n): Promise<string> {\n\tconst location = await findPackage(from, name, installation)\n\tif (location !== undefined) return location\n\tthrow new Error(`Cannot resolve ${name} from ${from}.`)\n}\n\nexport async function stageCandidate(\n\tconfig: NpmConfig,\n\tbase: string,\n\tmanifest: Manifest,\n\tenvironment: Environment,\n\tsuites: NpmSuite[],\n): Promise<void> {\n\tconst { stage, candidates } = environment\n\tconst artifacts = {\n\t\t[manifest.name]: path.resolve(base, config.artifact),\n\t\t...Object.fromEntries(\n\t\t\tObject.entries(candidates).map(([name, entry]) => [name, entry.artifact]),\n\t\t),\n\t}\n\tif (candidates[manifest.name])\n\t\tthrow new Error(\n\t\t\t`The package under test cannot also be its own candidate peer.`,\n\t\t)\n\tfor (const artifact of Object.values(artifacts)) {\n\t\tif (!(await lstat(artifact)).isFile())\n\t\t\tthrow new Error(`Candidate artifact must be a packed file: ${artifact}.`)\n\t}\n\tawait writeFile(\n\t\tpath.join(stage, `package.json`),\n\t\tJSON.stringify({\n\t\t\tname: `breakage-consumer`,\n\t\t\tversion: `0.0.0`,\n\t\t\tprivate: true,\n\t\t\ttype: environment.manifest.type ?? `module`,\n\t\t\tdependencies: Object.fromEntries(\n\t\t\t\tObject.entries(artifacts).map(([name, artifact]) => [\n\t\t\t\t\tname,\n\t\t\t\t\t`file:${artifact}`,\n\t\t\t\t]),\n\t\t\t),\n\t\t}),\n\t)\n\tawait prepare(\n\t\tconfig.installCommand ??\n\t\t\t`npm install --prefix . --workspaces=false --ignore-scripts --legacy-peer-deps --package-lock=false --no-audit --no-fund`,\n\t\tstage,\n\t)\n\tfor (const [name] of Object.entries(artifacts)) {\n\t\tconst directory = path.join(stage, `node_modules`, name)\n\t\tif (!within(stage, await realpath(directory)))\n\t\t\tthrow new Error(\n\t\t\t\t`Candidate ${name} must be installed inside the test stage.`,\n\t\t\t)\n\t\tconst filename = path.join(directory, `package.json`)\n\t\tconst packed = await readManifest(filename)\n\t\tconst candidate = candidates[name]\n\t\tif (\n\t\t\tpacked.name !== name ||\n\t\t\t(candidate\n\t\t\t\t? ![candidate.currentVersion, candidate.version].includes(\n\t\t\t\t\t\tpacked.version,\n\t\t\t\t\t)\n\t\t\t\t: packed.version !== manifest.version)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Candidate archive identity/version mismatch for ${name}@${packed.version}.`,\n\t\t\t)\n\t\t}\n\t\tconst expectedManifest = candidate?.manifest ?? manifest\n\t\tif (\n\t\t\tObject.keys({\n\t\t\t\t...packed.peerDependencies,\n\t\t\t\t...expectedManifest.peerDependencies,\n\t\t\t}).some(\n\t\t\t\t(peer) =>\n\t\t\t\t\tpacked.peerDependencies?.[peer] !==\n\t\t\t\t\t\texpectedManifest.peerDependencies?.[peer] ||\n\t\t\t\t\tBoolean(packed.peerDependenciesMeta?.[peer]?.optional) !==\n\t\t\t\t\t\tBoolean(expectedManifest.peerDependenciesMeta?.[peer]?.optional),\n\t\t\t)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Candidate archive has stale peer declarations; rebuild and pack ${name}.`,\n\t\t\t)\n\t\t}\n\t\tif (candidate) {\n\t\t\tconst evidence = environment.peers[name]\n\t\t\tif (evidence) evidence.archiveVersion = packed.version\n\t\t\tif (packed.version !== candidate.version) {\n\t\t\t\t// Replace the entry: installed files may share an inode with a cache.\n\t\t\t\tconst raw = JSON.parse(await readFile(filename, `utf8`)) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>\n\t\t\t\tconst temporary = path.join(\n\t\t\t\t\tpath.dirname(filename),\n\t\t\t\t\t`.breakage-${randomUUID()}.json`,\n\t\t\t\t)\n\t\t\t\tawait writeFile(\n\t\t\t\t\ttemporary,\n\t\t\t\t\tJSON.stringify({ ...raw, version: candidate.version }),\n\t\t\t\t\t{ flag: `wx` },\n\t\t\t\t)\n\t\t\t\ttry {\n\t\t\t\t\tawait rename(temporary, filename)\n\t\t\t\t} finally {\n\t\t\t\t\tawait rm(temporary, { force: true })\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (const suite of suites) await copySuite(base, stage, suite)\n\tawait verifyResolution(manifest, environment)\n}\n\nexport async function verifyResolution(\n\tmanifest: Manifest,\n\tenvironment: Environment,\n): Promise<void> {\n\tconst { stage, peers } = environment\n\tconst installation = await realpath(environment.directory)\n\tconst packages = [manifest.name, ...Object.keys(environment.candidates)]\n\tfor (const [peer, evidence] of Object.entries(peers)) {\n\t\tconst expected = await realpath(evidence.path)\n\t\tif ((await resolvePackage(stage, peer, installation)) !== expected)\n\t\t\tthrow new Error(`Tests resolve a shadow copy of ${peer}.`)\n\t\tfor (const name of packages) {\n\t\t\tif (name === peer) continue\n\t\t\tconst origin = path.join(stage, `node_modules`, name)\n\t\t\tif ((await resolvePackage(origin, peer, installation)) !== expected)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Candidate ${name} resolves a different instance of ${peer} than its tests.`,\n\t\t\t\t)\n\t\t}\n\t\tconst actual = await readManifest(path.join(expected, `package.json`))\n\t\tif (actual.name !== peer || actual.version !== evidence.version)\n\t\t\tthrow new Error(`Peer identity changed during execution: ${peer}.`)\n\t}\n\t// Runtime dependency peers can be singletons too (for example a React helper).\n\tconst visited = new Set<string>()\n\tconst pending = packages.map((name) => path.join(stage, `node_modules`, name))\n\twhile (pending.length) {\n\t\tconst directory = await realpath(pending.pop()!)\n\t\tif (visited.has(directory)) continue\n\t\tif (!directory.split(path.sep).includes(`node_modules`))\n\t\t\tthrow new Error(\n\t\t\t\t`Runtime dependency resolves to workspace source: ${directory}.`,\n\t\t\t)\n\t\tvisited.add(directory)\n\t\tconst installedManifest = await readManifest(\n\t\t\tpath.join(directory, `package.json`),\n\t\t)\n\t\tfor (const peer of Object.keys(installedManifest.peerDependencies ?? {})) {\n\t\t\tconst evidence = peers[peer]\n\t\t\tif (\n\t\t\t\tevidence &&\n\t\t\t\t(await resolvePackage(directory, peer, installation)) !==\n\t\t\t\t\t(await realpath(evidence.path))\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Runtime dependency ${installedManifest.name} resolves a different instance of ${peer}.`,\n\t\t\t\t)\n\t\t}\n\t\tconst optional = installedManifest.optionalDependencies ?? {}\n\t\tfor (const dependency of Object.keys({\n\t\t\t...installedManifest.dependencies,\n\t\t\t...optional,\n\t\t})) {\n\t\t\t// npm lets optionalDependencies override dependencies of the same name.\n\t\t\tif (Object.hasOwn(optional, dependency)) {\n\t\t\t\tconst location = await findPackage(directory, dependency, installation)\n\t\t\t\tif (location !== undefined) pending.push(location)\n\t\t\t} else {\n\t\t\t\tpending.push(await resolvePackage(directory, dependency, installation))\n\t\t\t}\n\t\t}\n\t}\n}\n","import path from \"node:path\"\n\nimport {\n\tresolveReleaseDelta,\n\tversionDelta,\n\ttype ReleaseDeltaContext,\n\ttype VersionTransition,\n} from \"../release.ts\"\nimport { command, errorMessage } from \"../task.ts\"\nimport { validateConfig, validatePeerRanges } from \"./config.ts\"\nimport {\n\tcheckCandidatePeers,\n\tdiscover,\n\tmaySelectEnvironment,\n\tprepareEnvironment,\n\tstageCandidate,\n\tverifyResolution,\n\twithStage,\n} from \"./environment.ts\"\nimport type { Manifest } from \"./manifest.ts\"\nimport {\n\teras,\n\tmatches,\n\tnormalizeWorkspacePeers,\n\treadManifest,\n} from \"./manifest.ts\"\nimport { releaseVersion, previousManifest, supportChanges } from \"./release.ts\"\nimport type {\n\tNpmConfig,\n\tNpmReport,\n\tNpmRepresentativeResult,\n\tNpmTestSelection,\n} from \"./types.ts\"\n\nasync function checkSupport(\n\tconfig: NpmConfig,\n\tbase: string,\n\tmanifest: Manifest,\n): Promise<NpmReport[`support`]> {\n\ttry {\n\t\tconst previous = await previousManifest(config, base)\n\t\tif (!previous) return { status: `first-release`, changes: [] }\n\t\tif (previous.name !== manifest.name)\n\t\t\tthrow new Error(\n\t\t\t\t`Release baseline belongs to ${previous.name}, not ${manifest.name}.`,\n\t\t\t)\n\t\tconst changes = supportChanges(previous, manifest)\n\t\tif (!changes.length)\n\t\t\treturn { status: `unchanged`, previousVersion: previous.version, changes }\n\t\tconst evidence = config.release\n\t\t\t? await resolveReleaseDelta(config.release, {\n\t\t\t\t\tpackageName: manifest.name,\n\t\t\t\t\tpackageDirectory: base,\n\t\t\t\t\tcurrentVersion: manifest.version,\n\t\t\t\t\tbaseline: { version: previous.version },\n\t\t\t\t})\n\t\t\t: undefined\n\t\tif (evidence === undefined)\n\t\t\treturn {\n\t\t\t\tstatus: `end-of-support`,\n\t\t\t\tpreviousVersion: previous.version,\n\t\t\t\tchanges,\n\t\t\t}\n\t\tconst release = versionDelta(\n\t\t\tevidence.previousVersion,\n\t\t\tevidence.version,\n\t\t\tconfig.release?.policy,\n\t\t)\n\n\t\treturn {\n\t\t\tstatus: release.breaking ? `breaking-release` : `end-of-support`,\n\t\t\tpreviousVersion: previous.version,\n\t\t\tchanges,\n\t\t\trelease,\n\t\t}\n\t} catch (error) {\n\t\treturn { status: `setup-error`, changes: [], error: errorMessage(error) }\n\t}\n}\n\nasync function checkLocalReleases(\n\tconfig: NpmConfig,\n\tbase: string,\n\tmanifest: Manifest,\n\trepresentatives: NpmRepresentativeResult[],\n): Promise<string[]> {\n\tconst findings = await Promise.all(\n\t\tObject.entries(config.localPeers ?? {}).map(async ([peer, local]) => {\n\t\t\tconst range = manifest.peerDependencies?.[peer]\n\t\t\t// A registration may be retained solely to resolve an older baseline.\n\t\t\tif (range === undefined) return []\n\t\t\ttry {\n\t\t\t\tconst directory = path.resolve(base, local.directory)\n\t\t\t\tconst current = await readManifest(path.join(directory, `package.json`))\n\t\t\t\tif (current.name !== peer)\n\t\t\t\t\tthrow new Error(`Local peer identity mismatch for ${peer}.`)\n\t\t\t\tconst release = await releaseVersion(config, {\n\t\t\t\t\tpackageName: peer,\n\t\t\t\t\tpackageDirectory: directory,\n\t\t\t\t\tcurrentVersion: current.version,\n\t\t\t\t})\n\t\t\t\tif (release === undefined) return []\n\t\t\t\tif (!matches(release, range))\n\t\t\t\t\treturn [\n\t\t\t\t\t\t`Declared support for ${peer}: ${range} does not include its planned local release ${release}. Update the peer range to include the intended version.`,\n\t\t\t\t\t]\n\t\t\t\tif (\n\t\t\t\t\t!representatives.some(\n\t\t\t\t\t\t(result) =>\n\t\t\t\t\t\t\tresult.peers[peer]?.source === `candidate` &&\n\t\t\t\t\t\t\tresult.peers[peer]?.version === release &&\n\t\t\t\t\t\t\tresult.suites.some((suite) => suite.peer === peer),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn [\n\t\t\t\t\t\t`No coordinated representative covers planned local peer ${peer}@${release}. Enroll ${peer} with breakage.candidates and configure its relationship suite.`,\n\t\t\t\t\t]\n\t\t\t\treturn []\n\t\t\t} catch (error) {\n\t\t\t\treturn [\n\t\t\t\t\t`Cannot inspect planned local release for ${peer}: ${errorMessage(error)}`,\n\t\t\t\t]\n\t\t\t}\n\t\t}),\n\t)\n\treturn findings.flat()\n}\n\nasync function runRepresentative(\n\tconfig: NpmConfig,\n\tbase: string,\n\tmanifest: Manifest,\n\tdirectory: string,\n\tcoverageOnly: boolean,\n\tselection?: NpmTestSelection,\n\tplannedSuites?: readonly string[],\n): Promise<NpmRepresentativeResult> {\n\tconst label = path.relative(base, directory).split(path.sep).join(`/`)\n\tconst result: NpmRepresentativeResult = {\n\t\tpath: label,\n\t\tstatus: `skipped`,\n\t\tpeers: {},\n\t\tsuites: [],\n\t\twarnings: [],\n\t}\n\tif (\n\t\tselection &&\n\t\t`representative` in selection &&\n\t\tpath.resolve(base, selection.representative) !== directory\n\t)\n\t\treturn result\n\ttry {\n\t\tif (\n\t\t\tselection &&\n\t\t\t`peer` in selection &&\n\t\t\t!(await maySelectEnvironment(\n\t\t\t\tconfig,\n\t\t\t\tbase,\n\t\t\t\tdirectory,\n\t\t\t\tmanifest,\n\t\t\t\tselection,\n\t\t\t))\n\t\t)\n\t\t\treturn result\n\t\treturn await withStage(directory, async (stage) => {\n\t\t\tconst environment = await prepareEnvironment(\n\t\t\t\tconfig,\n\t\t\t\tbase,\n\t\t\t\tdirectory,\n\t\t\t\tstage,\n\t\t\t\tmanifest,\n\t\t\t)\n\t\t\tresult.peers = environment.peers\n\t\t\tfor (const peer of Object.keys(manifest.peerDependencies ?? {})) {\n\t\t\t\tif (\n\t\t\t\t\t!result.peers[peer] &&\n\t\t\t\t\t!manifest.peerDependenciesMeta?.[peer]?.optional\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Complete representative is missing required peer ${peer}.`,\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const [peer, evidence] of Object.entries(result.peers)) {\n\t\t\t\tconst range = manifest.peerDependencies?.[peer]\n\t\t\t\tif (range !== undefined && !matches(evidence.version, range))\n\t\t\t\t\tresult.warnings.push(\n\t\t\t\t\t\t`${peer}@${evidence.version} is outside declared support.`,\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselection &&\n\t\t\t\t`peer` in selection &&\n\t\t\t\t(!result.peers[selection.peer] ||\n\t\t\t\t\t!matches(result.peers[selection.peer]!.version, selection.range))\n\t\t\t)\n\t\t\t\treturn result\n\t\t\tconst peers = Object.keys(config.suites).filter((peer) => {\n\t\t\t\tconst evidence = result.peers[peer]\n\t\t\t\tif (!evidence) return false\n\t\t\t\tif (plannedSuites !== undefined) return plannedSuites.includes(peer)\n\t\t\t\tif (selection && `peer` in selection) return peer === selection.peer\n\t\t\t\tif (selection && `representative` in selection) return true\n\t\t\t\treturn matches(evidence.version, manifest.peerDependencies![peer]!)\n\t\t\t})\n\t\t\tresult.suites = peers.map((peer) => ({ peer, status: `not-run` }))\n\t\t\tif (!peers.length) return result\n\t\t\tresult.warnings.push(...checkCandidatePeers(environment, !!selection))\n\t\t\tif (coverageOnly) {\n\t\t\t\tresult.status = `audited`\n\t\t\t\treturn result\n\t\t\t}\n\t\t\tawait stageCandidate(\n\t\t\t\tconfig,\n\t\t\t\tbase,\n\t\t\t\tmanifest,\n\t\t\t\tenvironment,\n\t\t\t\tpeers.map((peer) => config.suites[peer]!),\n\t\t\t)\n\t\t\tfor (const suite of result.suites) {\n\t\t\t\ttry {\n\t\t\t\t\tawait verifyResolution(manifest, environment)\n\t\t\t\t\tconst execution = await command(\n\t\t\t\t\t\tconfig.suites[suite.peer]!.command,\n\t\t\t\t\t\tstage,\n\t\t\t\t\t)\n\t\t\t\t\tawait verifyResolution(manifest, environment)\n\t\t\t\t\tsuite.status =\n\t\t\t\t\t\texecution.code === 0\n\t\t\t\t\t\t\t? `passed`\n\t\t\t\t\t\t\t: execution.code === 1\n\t\t\t\t\t\t\t\t? `compatibility-failure`\n\t\t\t\t\t\t\t\t: `setup-error`\n\t\t\t\t\tif (execution.output) suite.output = execution.output\n\t\t\t\t} catch (error) {\n\t\t\t\t\tsuite.status = `setup-error`\n\t\t\t\t\tsuite.output = errorMessage(error)\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult.status = result.suites.some(\n\t\t\t\t(suite) => suite.status === `setup-error`,\n\t\t\t)\n\t\t\t\t? `setup-error`\n\t\t\t\t: result.suites.some(\n\t\t\t\t\t\t\t(suite) => suite.status === `compatibility-failure`,\n\t\t\t\t\t )\n\t\t\t\t\t? `compatibility-failure`\n\t\t\t\t\t: `passed`\n\t\t\treturn result\n\t\t})\n\t} catch (error) {\n\t\tresult.status = `setup-error`\n\t\tresult.error = errorMessage(error)\n\t\treturn result\n\t}\n}\n\nasync function run(\n\tconfig: NpmConfig,\n\tbaseDirectory: string,\n\tcoverageOnly: boolean,\n\tselection?: NpmTestSelection,\n\tplannedSuites?: readonly string[],\n): Promise<NpmReport> {\n\tconst report: NpmReport = {\n\t\tpackage: { name: `(unresolved)`, version: `(unresolved)` },\n\t\tmode: selection ? `test` : coverageOnly ? `coverage-only` : `check`,\n\t\texitCode: 0,\n\t\trepresentatives: [],\n\t\tcoverage: [],\n\t\tsupport: { status: `not-checked`, changes: [] },\n\t\terrors: [],\n\t}\n\ttry {\n\t\tvalidateConfig(config)\n\t\tconst base = path.resolve(baseDirectory, config.packageDirectory ?? `.`)\n\t\tconst manifest = await normalizeWorkspacePeers(\n\t\t\tawait readManifest(path.join(base, `package.json`)),\n\t\t)\n\t\treport.package = { name: manifest.name, version: manifest.version }\n\t\tvalidatePeerRanges(manifest.peerDependencies ?? {})\n\t\tfor (const peer of Object.keys(config.suites)) {\n\t\t\tif (!manifest.peerDependencies?.[peer])\n\t\t\t\tthrow new Error(`Suite ${peer} has no peerDependencies declaration.`)\n\t\t}\n\t\tfor (const peer of Object.keys(config.localPeers ?? {})) {\n\t\t\tif (manifest.peerDependencies?.[peer] && !config.suites[peer])\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Declared local peer ${peer} needs a relationship suite.`,\n\t\t\t\t)\n\t\t}\n\t\tif (selection && `peer` in selection) {\n\t\t\tif (!config.suites[selection.peer])\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No relationship suite configured for ${selection.peer}.`,\n\t\t\t\t)\n\t\t\teras(selection.range)\n\t\t}\n\t\t// One piece of release evidence per package and baseline per invocation, including failures.\n\t\tconst releases = new Map<string, Promise<VersionTransition | undefined>>()\n\t\tconst resolveDelta = (\n\t\t\tcontext: ReleaseDeltaContext,\n\t\t): Promise<VersionTransition | undefined> => {\n\t\t\tconst key = JSON.stringify([\n\t\t\t\tcontext.packageDirectory,\n\t\t\t\tcontext.currentVersion,\n\t\t\t\tcontext.baseline,\n\t\t\t])\n\t\t\tlet pending = releases.get(key)\n\t\t\tif (!pending) {\n\t\t\t\tpending = resolveReleaseDelta(config.release!, context)\n\t\t\t\treleases.set(key, pending)\n\t\t\t}\n\t\t\treturn pending\n\t\t}\n\t\tconst effective: NpmConfig = {\n\t\t\t...config,\n\t\t\t...(config.release\n\t\t\t\t? { release: { ...config.release, resolveDelta } }\n\t\t\t\t: {}),\n\t\t}\n\n\t\tconst directories = await discover(config, base)\n\t\tconst [support, representatives] = await Promise.all([\n\t\t\tselection\n\t\t\t\t? Promise.resolve(report.support)\n\t\t\t\t: checkSupport(effective, base, manifest),\n\t\t\tPromise.all(\n\t\t\t\tdirectories.map((directory) =>\n\t\t\t\t\trunRepresentative(\n\t\t\t\t\t\teffective,\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\tdirectory,\n\t\t\t\t\t\tcoverageOnly,\n\t\t\t\t\t\tselection,\n\t\t\t\t\t\tplannedSuites,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t])\n\t\treport.support = support\n\t\treport.representatives = representatives\n\t\tif (!selection) {\n\t\t\treport.errors.push(\n\t\t\t\t...(await checkLocalReleases(\n\t\t\t\t\teffective,\n\t\t\t\t\tbase,\n\t\t\t\t\tmanifest,\n\t\t\t\t\trepresentatives,\n\t\t\t\t)),\n\t\t\t)\n\t\t\tfor (const peer of Object.keys(config.suites)) {\n\t\t\t\tfor (const era of eras(manifest.peerDependencies![peer]!)) {\n\t\t\t\t\tconst matching = representatives\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(representative) =>\n\t\t\t\t\t\t\t\trepresentative.peers[peer] &&\n\t\t\t\t\t\t\t\tmatches(representative.peers[peer]!.version, era),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((representative) => representative.path)\n\t\t\t\t\treport.coverage.push({ peer, era, representatives: matching })\n\t\t\t\t\tif (!matching.length)\n\t\t\t\t\t\treport.errors.push(`No representative covers ${peer}: ${era}.`)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\t!representatives.some(\n\t\t\t\t(representative) => representative.suites.length > 0,\n\t\t\t)\n\t\t) {\n\t\t\treport.errors.push(\n\t\t\t\t`No representative matched the requested test selection.`,\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tsupport.status === `setup-error` ||\n\t\t\treport.errors.length ||\n\t\t\trepresentatives.some((result) => result.status === `setup-error`)\n\t\t)\n\t\t\treport.exitCode = 2\n\t\telse if (\n\t\t\tsupport.status === `end-of-support` ||\n\t\t\trepresentatives.some(\n\t\t\t\t(result) => result.status === `compatibility-failure`,\n\t\t\t)\n\t\t)\n\t\t\treport.exitCode = 1\n\t} catch (error) {\n\t\treport.errors.push(errorMessage(error))\n\t\treport.exitCode = 2\n\t}\n\treturn report\n}\n\nexport async function npmCheck(\n\tconfig: NpmConfig,\n\toptions: { baseDirectory?: string; coverageOnly?: boolean } = {},\n): Promise<NpmReport> {\n\treturn await run(\n\t\tconfig,\n\t\toptions.baseDirectory ?? process.cwd(),\n\t\toptions.coverageOnly ?? false,\n\t)\n}\n\nexport async function npmTest(\n\tconfig: NpmConfig,\n\tselection: NpmTestSelection,\n\toptions: { baseDirectory?: string } = {},\n): Promise<NpmReport> {\n\treturn await run(\n\t\tconfig,\n\t\toptions.baseDirectory ?? process.cwd(),\n\t\tfalse,\n\t\tselection,\n\t)\n}\n\n/** Internal matrix entrypoint: keep the full config for validation and peer identity checks. */\nexport async function npmTestPlanned(\n\tconfig: NpmConfig,\n\tselection: { representative: string; suites: readonly string[] },\n\toptions: { baseDirectory?: string } = {},\n): Promise<NpmReport> {\n\treturn await run(\n\t\tconfig,\n\t\toptions.baseDirectory ?? process.cwd(),\n\t\tfalse,\n\t\t{ representative: selection.representative },\n\t\tselection.suites,\n\t)\n}\n\nexport function formatNpmReport(report: NpmReport): string {\n\tconst lines = [\n\t\t`${report.package.name}@${report.package.version} — npm ${report.mode}`,\n\t]\n\tfor (const result of report.representatives) {\n\t\tlines.push(`${result.path}: ${result.status}`)\n\t\tfor (const [peer, evidence] of Object.entries(result.peers)) {\n\t\t\tlines.push(\n\t\t\t\t` ${peer}@${evidence.version}${evidence.source === `candidate` ? ` (conditional on publication)` : ` (installed)`}`,\n\t\t\t)\n\t\t}\n\t\tfor (const suite of result.suites) {\n\t\t\tlines.push(` ${suite.peer}: ${suite.status}`)\n\t\t\tif (suite.status !== `passed` && suite.output) lines.push(suite.output)\n\t\t}\n\t\tfor (const warning of result.warnings) lines.push(` Warning: ${warning}`)\n\t\tif (result.error) lines.push(` ${result.error}`)\n\t}\n\tlines.push(`Support: ${report.support.status}`)\n\tfor (const change of report.support.changes)\n\t\tlines.push(\n\t\t\t` ${change.peer}: ${change.previous ?? `(unrestricted)`} → ${change.current ?? `(unrestricted)`} (${change.reason})`,\n\t\t)\n\tif (report.support.release)\n\t\tlines.push(\n\t\t\t` Intended release: ${report.support.release.version} (${report.support.release.delta})`,\n\t\t)\n\tif (report.support.error) lines.push(report.support.error)\n\tlines.push(...report.errors)\n\tif (report.mode === `coverage-only`)\n\t\tlines.push(\n\t\t\t`Coverage audit only; compatibility assertions were not executed.`,\n\t\t)\n\treturn `${lines.join(`\\n`)}\\n`\n}\n","import { randomUUID } from \"node:crypto\"\nimport {\n\tcopyFile,\n\tglob,\n\tlstat,\n\tmkdir,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { simpleGit } from \"simple-git\"\nimport { loadConfig } from \"../config.ts\"\nimport { withDirectoryLock } from \"../directory-lock.ts\"\nimport {\n\tresolveReleaseDelta,\n\tversionDelta,\n\ttype ReleaseDeltaContext,\n} from \"../release.ts\"\nimport { prepare, errorMessage } from \"../task.ts\"\nimport { npmCheck, npmTestPlanned, formatNpmReport } from \"./check.ts\"\nimport { validateConfig } from \"./config.ts\"\nimport { discover, within } from \"./environment.ts\"\nimport { readManifest } from \"./manifest.ts\"\nimport type { NpmConfig } from \"./types.ts\"\nimport {\n\tcanonical,\n\tdigest,\n\tnpmMatrixConfigSchema,\n\tpeerIdentities,\n\tplanDigest,\n\trequireMatrix,\n\tvalidateNpmPlan,\n\tverifyNpmReceipts,\n\ttype NpmArchiveRequest,\n\ttype NpmMatrixConfig,\n\ttype NpmPlan,\n\ttype NpmReceipt,\n\ttype NpmVerification,\n} from \"./matrix-model.ts\"\n\nexport { verifyNpmReceipts } from \"./matrix-model.ts\"\nexport type {\n\tNpmMatrixConfig,\n\tNpmMatrixLabelContext,\n\tNpmPrepareContext,\n\tNpmArchiveRequest,\n\tNpmPlan,\n\tNpmReceipt,\n\tNpmVerification,\n} from \"./matrix-model.ts\"\nexport type NpmMatrixLocation = {\n\trootDirectory?: string\n\tbundleDirectory?: string\n}\n\nfunction relative(root: string, filename: string): string {\n\tconst result =\n\t\tpath.relative(root, path.resolve(filename)).split(path.sep).join(`/`) || `.`\n\trequireMatrix(\n\t\t!result.startsWith(`../`) && result !== `..` && !path.isAbsolute(result),\n\t\t`Matrix input escapes the source checkout: ${filename}.`,\n\t)\n\treturn result\n}\nfunction portablePath(value: string): void {\n\trequireMatrix(\n\t\tvalue.length &&\n\t\t\t!value.includes(`\\\\`) &&\n\t\t\t!path.posix.isAbsolute(value) &&\n\t\t\t!/^[A-Za-z]:/.test(value) &&\n\t\t\t!value.split(`/`).includes(`..`),\n\t\t`Invalid portable path: ${value}.`,\n\t)\n}\nasync function contained(root: string, filename: string): Promise<string> {\n\tportablePath(filename)\n\tconst absolute = path.resolve(root, filename)\n\t// Check the nearest existing ancestor as well as the final path.\n\tlet ancestor = absolute\n\tfor (;;) {\n\t\ttry {\n\t\t\tawait lstat(ancestor)\n\t\t\tbreak\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== `ENOENT`) throw error\n\t\t\tancestor = path.dirname(ancestor)\n\t\t}\n\t}\n\trequireMatrix(\n\t\twithin(await realpath(root), await realpath(ancestor)),\n\t\t`Path escapes its root through a symlink: ${filename}.`,\n\t)\n\treturn absolute\n}\nasync function fileDigest(filename: string): Promise<string> {\n\trequireMatrix(\n\t\t(await lstat(filename)).isFile(),\n\t\t`Expected a regular file: ${filename}.`,\n\t)\n\treturn digest(await readFile(filename))\n}\nasync function sourceIdentity(root: string): Promise<string> {\n\tconst git = simpleGit(root)\n\trequireMatrix(\n\t\t(await realpath(await git.revparse([`--show-toplevel`]))) ===\n\t\t\t(await realpath(root)),\n\t\t`Matrix rootDirectory must be the Git checkout root.`,\n\t)\n\trequireMatrix(\n\t\t!(await git.status()).files.length,\n\t\t`Matrix planning and execution require a clean checkout, including untracked files. Ignore generated archives, bundles, and receipts.`,\n\t)\n\treturn await git.revparse([`HEAD`])\n}\nasync function ignoredOutput(root: string, filename: string): Promise<void> {\n\tconst git = simpleGit(root)\n\trequireMatrix(\n\t\t!(await git.raw([`ls-files`, `--`, filename])).trim() &&\n\t\t\t(await git.raw([`check-ignore`, `--`, filename])).trim(),\n\t\t`Matrix output must be gitignored and untracked: ${filename}.`,\n\t)\n}\n\nasync function discoverConfigs(\n\troot: string,\n\tpatterns: string[],\n): Promise<string[]> {\n\tconst files = new Set<string>()\n\tfor (const pattern of patterns) portablePath(pattern)\n\tfor await (const filename of glob(patterns, {\n\t\tcwd: root,\n\t\texclude: [`**/node_modules/**`, `**/.git/**`, `**/test/**`],\n\t})) {\n\t\tconst name = relative(root, path.resolve(root, filename))\n\t\tconst config = await loadConfig(await contained(root, name))\n\t\tif (config.npm) files.add(name)\n\t}\n\trequireMatrix(files.size, `No npm configurations matched the matrix configs.`)\n\treturn [...files].sort()\n}\nfunction configDigest(config: NpmConfig, root: string, base: string): string {\n\treturn digest(\n\t\tcanonical({\n\t\t\t...config,\n\t\t\tpackageDirectory: relative(root, base),\n\t\t\tartifact: relative(root, path.resolve(base, config.artifact)),\n\t\t\tbaseline:\n\t\t\t\t`baselineFile` in config.baseline && config.baseline.baselineFile\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...config.baseline,\n\t\t\t\t\t\t\tbaselineFile: relative(\n\t\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\t\tpath.resolve(base, config.baseline.baselineFile),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t: config.baseline,\n\t\t\tlocalPeers: Object.fromEntries(\n\t\t\t\tObject.entries(config.localPeers ?? {}).map(([name, peer]) => [\n\t\t\t\t\tname,\n\t\t\t\t\t{\n\t\t\t\t\t\tdirectory: relative(root, path.resolve(base, peer.directory)),\n\t\t\t\t\t\tartifact: relative(root, path.resolve(base, peer.artifact)),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t),\n\t\t\trelease: config.release\n\t\t\t\t? {\n\t\t\t\t\t\tresolveDelta: !!config.release.resolveDelta,\n\t\t\t\t\t\tpolicy: !!config.release.policy,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t}),\n\t)\n}\nasync function packageConfig(root: string, filename: string) {\n\tconst config = (await loadConfig(await contained(root, filename))).npm\n\tvalidateConfig(config)\n\tconst baseDirectory = path.dirname(path.resolve(root, filename))\n\tconst base = path.resolve(baseDirectory, config.packageDirectory ?? `.`)\n\tawait contained(root, relative(root, base))\n\treturn { config, base, baseDirectory }\n}\nfunction portableContext(\n\troot: string,\n\tcontext: ReleaseDeltaContext,\n): ReleaseDeltaContext {\n\treturn {\n\t\t...context,\n\t\tpackageDirectory: relative(root, context.packageDirectory),\n\t}\n}\n\nasync function archiveRequests(\n\troot: string,\n\tconfig: NpmConfig,\n\tbase: string,\n): Promise<NpmArchiveRequest[]> {\n\tconst manifest = await readManifest(path.join(base, `package.json`))\n\tconst requests: NpmArchiveRequest[] = [\n\t\t{\n\t\t\tpackageName: manifest.name,\n\t\t\tdirectory: relative(root, base),\n\t\t\tartifact: relative(root, path.resolve(base, config.artifact)),\n\t\t},\n\t]\n\tfor (const [packageName, peer] of Object.entries(config.localPeers ?? {})) {\n\t\tconst directory = relative(root, path.resolve(base, peer.directory))\n\t\ttry {\n\t\t\tawait lstat(await contained(root, directory))\n\t\t} catch (error) {\n\t\t\t// Preserve registrations needed only to interpret a removed historical peer.\n\t\t\tif (\n\t\t\t\t(error as NodeJS.ErrnoException).code === `ENOENT` &&\n\t\t\t\t!manifest.peerDependencies?.[packageName]\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tthrow error\n\t\t}\n\t\trequests.push({\n\t\t\tpackageName,\n\t\t\tdirectory,\n\t\t\tartifact: relative(root, path.resolve(base, peer.artifact)),\n\t\t})\n\t}\n\treturn requests\n}\n\n// Include ignored/generated contracts and frozen inputs: a clean Git tree alone\n// cannot bind them to the coverage audit. File discovery is part of the digest.\nasync function inputDigest(\n\troot: string,\n\tfilename: string,\n\tconfig: NpmConfig,\n\tbase: string,\n): Promise<string> {\n\tconst files = new Set([\n\t\tfilename,\n\t\trelative(root, path.join(base, `package.json`)),\n\t])\n\tconst directories = await discover(config, base)\n\tfor (const directory of directories)\n\t\tfor (const name of [`package.json`, config.lockfile])\n\t\t\tfiles.add(relative(root, path.join(directory, name)))\n\tfor (const request of await archiveRequests(root, config, base))\n\t\tfiles.add(\n\t\t\trelative(root, path.resolve(root, request.directory, `package.json`)),\n\t\t)\n\tif (`baselineFile` in config.baseline && config.baseline.baselineFile)\n\t\tfiles.add(relative(root, path.resolve(base, config.baseline.baselineFile)))\n\tconst exclude = [\n\t\t`**/node_modules/**`,\n\t\t`**/.git/**`,\n\t\t...directories.flatMap((directory) => {\n\t\t\tconst stage = relative(base, path.join(directory, `test`))\n\t\t\treturn [stage, `${stage}/**`]\n\t\t}),\n\t]\n\tfor (const suite of Object.values(config.suites)) {\n\t\tfor (const pattern of suite.files) {\n\t\t\tportablePath(pattern)\n\t\t\tlet count = 0\n\t\t\tfor await (const file of glob(pattern, { cwd: base, exclude })) {\n\t\t\t\tconst absolute = path.resolve(base, file)\n\t\t\t\tif ((await lstat(absolute)).isDirectory()) continue\n\t\t\t\tfiles.add(relative(root, absolute))\n\t\t\t\tcount++\n\t\t\t}\n\t\t\trequireMatrix(count, `Suite pattern matched no files: ${pattern}.`)\n\t\t}\n\t}\n\tconst inputs = await Promise.all(\n\t\t[...files]\n\t\t\t.sort()\n\t\t\t.map(async (file) => [\n\t\t\t\tfile,\n\t\t\t\tawait fileDigest(await contained(root, file)),\n\t\t\t]),\n\t)\n\treturn digest(canonical(inputs))\n}\n\n/** Audit all configured packages and prepare one immutable, portable archive bundle. */\nexport async function npmPlan(\n\tconfig: NpmMatrixConfig,\n\toptions: NpmMatrixLocation = {},\n): Promise<NpmPlan> {\n\tnpmMatrixConfigSchema.assert(config)\n\tconst root = path.resolve(options.rootDirectory ?? process.cwd())\n\tconst output = options.bundleDirectory ?? `.breakage/npm-plan`\n\tconst bundle = await contained(\n\t\troot,\n\t\trelative(root, path.resolve(root, output)),\n\t)\n\tawait ignoredOutput(root, path.join(bundle, `plan.json`))\n\tawait mkdir(bundle, { recursive: true })\n\treturn await withDirectoryLock(path.join(bundle, `.lock`), async () => {\n\t\t// A failed re-plan must not leave yesterday's successful plan available.\n\t\tawait rm(path.join(bundle, `plan.json`), { force: true })\n\t\tconst commit = await sourceIdentity(root)\n\t\tconst patterns =\n\t\t\ttypeof config.configs === `string` ? [config.configs] : config.configs\n\t\tconst files = await discoverConfigs(root, patterns)\n\t\tconst packages: NpmPlan[`packages`] = []\n\t\tconst environments: NpmPlan[`environments`] = []\n\t\tconst requests = new Map<string, NpmArchiveRequest>()\n\t\tfor (const filename of files) {\n\t\t\tconst {\n\t\t\t\tconfig: npm,\n\t\t\t\tbase,\n\t\t\t\tbaseDirectory,\n\t\t\t} = await packageConfig(root, filename)\n\t\t\tconst manifest = await readManifest(path.join(base, `package.json`))\n\t\t\tfor (const peer of Object.keys(manifest.peerDependencies ?? {}))\n\t\t\t\trequireMatrix(\n\t\t\t\t\tnpm.suites[peer] || manifest.peerDependenciesMeta?.[peer]?.optional,\n\t\t\t\t\t`Missing relationship suite for ${manifest.name}: ${peer}.`,\n\t\t\t\t)\n\t\t\tconst releases: NpmPlan[`packages`][number][`releases`] = []\n\t\t\tconst effective: NpmConfig = {\n\t\t\t\t...npm,\n\t\t\t\t...(npm.release\n\t\t\t\t\t? {\n\t\t\t\t\t\t\trelease: {\n\t\t\t\t\t\t\t\t...npm.release,\n\t\t\t\t\t\t\t\tresolveDelta: async (context) => {\n\t\t\t\t\t\t\t\t\tconst transition = await resolveReleaseDelta(\n\t\t\t\t\t\t\t\t\t\tnpm.release!,\n\t\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\treleases.push({\n\t\t\t\t\t\t\t\t\t\tcontext: portableContext(root, context),\n\t\t\t\t\t\t\t\t\t\t...(transition ? { transition } : {}),\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\treturn transition\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t\tconst audit = await npmCheck(effective, {\n\t\t\t\tbaseDirectory,\n\t\t\t\tcoverageOnly: true,\n\t\t\t})\n\t\t\trequireMatrix(\n\t\t\t\taudit.exitCode === 0,\n\t\t\t\t`Cannot plan ${manifest.name}:\\n${formatNpmReport(audit)}`,\n\t\t\t)\n\t\t\tfor (const result of audit.representatives) {\n\t\t\t\trequireMatrix(\n\t\t\t\t\tresult.status === `audited` && result.suites.length,\n\t\t\t\t\t`Environment has no executable audited suites: ${manifest.name} / ${result.path}.`,\n\t\t\t\t)\n\t\t\t\tconst environment = JSON.parse(\n\t\t\t\t\tawait readFile(path.join(base, result.path, `package.json`), `utf8`),\n\t\t\t\t) as { description?: unknown }\n\t\t\t\tconst label =\n\t\t\t\t\tconfig.label?.({\n\t\t\t\t\t\tpackageName: manifest.name,\n\t\t\t\t\t\trepresentative: result.path,\n\t\t\t\t\t\tpeers: result.peers,\n\t\t\t\t\t\t...(typeof environment.description === `string`\n\t\t\t\t\t\t\t? { description: environment.description }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}) ?? `${manifest.name}: ${result.path}`\n\t\t\t\trequireMatrix(\n\t\t\t\t\ttypeof label === `string` && label.trim(),\n\t\t\t\t\t`Invalid label for ${manifest.name} / ${result.path}.`,\n\t\t\t\t)\n\t\t\t\tenvironments.push({\n\t\t\t\t\tid: digest(`${filename}\\0${result.path}`).slice(0, 24),\n\t\t\t\t\tlabel,\n\t\t\t\t\tpackageName: manifest.name,\n\t\t\t\t\trepresentative: result.path,\n\t\t\t\t\tsuites: result.suites.map((s) => s.peer).sort(),\n\t\t\t\t\tpeers: peerIdentities(result.peers),\n\t\t\t\t})\n\t\t\t\t// Store portable identities; execution paths belong to each receipt's runner.\n\t\t\t\tfor (const peer of Object.values(result.peers))\n\t\t\t\t\tpeer.path = `(runner-local)`\n\t\t\t}\n\t\t\tpackages.push({\n\t\t\t\tconfig: filename,\n\t\t\t\tdirectory: relative(root, base),\n\t\t\t\tname: manifest.name,\n\t\t\t\tconfigDigest: configDigest(npm, root, base),\n\t\t\t\tinputDigest: await inputDigest(root, filename, npm, base),\n\t\t\t\taudit,\n\t\t\t\treleases: releases.sort((a, b) =>\n\t\t\t\t\tcanonical(a.context).localeCompare(canonical(b.context)),\n\t\t\t\t),\n\t\t\t})\n\t\t\tfor (const request of await archiveRequests(root, npm, base)) {\n\t\t\t\tconst previous = requests.get(request.artifact)\n\t\t\t\trequireMatrix(\n\t\t\t\t\t!previous || canonical(previous) === canonical(request),\n\t\t\t\t\t`Conflicting archive requests: ${request.artifact}.`,\n\t\t\t\t)\n\t\t\t\trequests.set(request.artifact, request)\n\t\t\t}\n\t\t}\n\t\tconst archives = [...requests.values()].sort((a, b) =>\n\t\t\ta.artifact.localeCompare(b.artifact),\n\t\t)\n\t\tfor (const request of archives) {\n\t\t\tawait contained(root, request.directory)\n\t\t\tawait contained(root, request.artifact)\n\t\t\tawait ignoredOutput(root, path.resolve(root, request.artifact))\n\t\t}\n\t\tif (typeof config.prepare === `string`) await prepare(config.prepare, root)\n\t\telse await config.prepare({ rootDirectory: root, archives })\n\t\tconst packed: NpmPlan[`archives`] = []\n\t\tfor (const archive of archives) {\n\t\t\tconst filename = await contained(root, archive.artifact)\n\t\t\tconst sha256 = await fileDigest(filename)\n\t\t\tconst file = `archives/${sha256}.tgz`\n\t\t\tawait mkdir(path.join(bundle, `archives`), { recursive: true })\n\t\t\tawait copyFile(filename, await contained(bundle, file))\n\t\t\tpacked.push({ path: archive.artifact, file, sha256 })\n\t\t}\n\t\trequireMatrix(\n\t\t\t(await sourceIdentity(root)) === commit,\n\t\t\t`Source changed while preparing the matrix.`,\n\t\t)\n\t\tconst payload = {\n\t\t\tformatVersion: 1 as const,\n\t\t\trunId: randomUUID(),\n\t\t\tcommit,\n\t\t\tconfigs: patterns,\n\t\t\tpackages,\n\t\t\tenvironments,\n\t\t\tarchives: packed,\n\t\t}\n\t\tconst plan = validateNpmPlan({ ...payload, id: planDigest(payload) })\n\t\tawait validateWorkspace(plan, {\n\t\t\trootDirectory: root,\n\t\t\tbundleDirectory: bundle,\n\t\t})\n\t\tawait writeMatrixJson(path.join(bundle, `plan.json`), plan)\n\t\treturn plan\n\t})\n}\n\nasync function validateWorkspace(plan: NpmPlan, options: NpmMatrixLocation) {\n\tconst root = path.resolve(options.rootDirectory ?? process.cwd())\n\tconst bundle = path.resolve(\n\t\troot,\n\t\toptions.bundleDirectory ?? `.breakage/npm-plan`,\n\t)\n\trequireMatrix(\n\t\t(await sourceIdentity(root)) === plan.commit,\n\t\t`Plan belongs to a different source commit.`,\n\t)\n\trequireMatrix(\n\t\tcanonical(await discoverConfigs(root, plan.configs)) ===\n\t\t\tcanonical(plan.packages.map((p) => p.config).sort()),\n\t\t`Plan no longer enumerates every configured npm package.`,\n\t)\n\tconst configs = new Map<string, Awaited<ReturnType<typeof packageConfig>>>()\n\tconst requiredArchives = new Set<string>()\n\tfor (const pkg of plan.packages) {\n\t\tconst loaded = await packageConfig(root, pkg.config)\n\t\tconst { config, base } = loaded\n\t\tfor (const request of await archiveRequests(root, config, base))\n\t\t\trequiredArchives.add(request.artifact)\n\t\trequireMatrix(\n\t\t\trelative(root, base) === pkg.directory &&\n\t\t\t\tconfigDigest(config, root, base) === pkg.configDigest,\n\t\t\t`Configuration changed for ${pkg.name}.`,\n\t\t)\n\t\trequireMatrix(\n\t\t\t(await inputDigest(root, pkg.config, config, base)) === pkg.inputDigest,\n\t\t\t`Contract, manifest, or lockfile inputs changed for ${pkg.name}.`,\n\t\t)\n\t\tconst representatives = (await discover(config, base))\n\t\t\t.map((d) => relative(base, d))\n\t\t\t.sort()\n\t\trequireMatrix(\n\t\t\tcanonical(representatives) ===\n\t\t\t\tcanonical(pkg.audit.representatives.map((r) => r.path).sort()),\n\t\t\t`Representative discovery changed for ${pkg.name}.`,\n\t\t)\n\t\tfor (const release of pkg.releases) {\n\t\t\trequireMatrix(\n\t\t\t\tconfig.release,\n\t\t\t\t`Release configuration disappeared for ${pkg.name}.`,\n\t\t\t)\n\t\t\tconst actual = await resolveReleaseDelta(config.release, {\n\t\t\t\t...release.context,\n\t\t\t\tpackageDirectory: await contained(\n\t\t\t\t\troot,\n\t\t\t\t\trelease.context.packageDirectory,\n\t\t\t\t),\n\t\t\t})\n\t\t\trequireMatrix(\n\t\t\t\tcanonical(actual) === canonical(release.transition),\n\t\t\t\t`Release evidence changed for ${pkg.name} / ${release.context.packageName}.`,\n\t\t\t)\n\t\t}\n\t\tif (pkg.audit.support.release) {\n\t\t\tconst expected = pkg.audit.support.release\n\t\t\trequireMatrix(\n\t\t\t\tcanonical(\n\t\t\t\t\tversionDelta(\n\t\t\t\t\t\texpected.previousVersion,\n\t\t\t\t\t\texpected.version,\n\t\t\t\t\t\tconfig.release?.policy,\n\t\t\t\t\t),\n\t\t\t\t) === canonical(expected),\n\t\t\t\t`Release policy changed for ${pkg.name}.`,\n\t\t\t)\n\t\t}\n\t\tconfigs.set(pkg.name, loaded)\n\t}\n\trequireMatrix(\n\t\tcanonical([...requiredArchives].sort()) ===\n\t\t\tcanonical(plan.archives.map((a) => a.path).sort()),\n\t\t`Planned archives do not match the configured packages and local peers.`,\n\t)\n\tfor (const archive of plan.archives) {\n\t\tportablePath(archive.path)\n\t\trequireMatrix(\n\t\t\tarchive.file === `archives/${archive.sha256}.tgz`,\n\t\t\t`Invalid bundled archive path: ${archive.file}.`,\n\t\t)\n\t\trequireMatrix(\n\t\t\t(await fileDigest(await contained(bundle, archive.file))) ===\n\t\t\t\tarchive.sha256,\n\t\t\t`Candidate archive changed: ${archive.path}.`,\n\t\t)\n\t}\n\treturn { root, bundle, configs }\n}\n\n/** Execute exactly one audited environment, producing failure evidence whenever the plan is valid. */\nexport async function npmExecute(\n\tvalue: unknown,\n\tid: string,\n\toptions: NpmMatrixLocation = {},\n): Promise<NpmReceipt> {\n\tconst plan = validateNpmPlan(value)\n\tconst receipt: NpmReceipt = {\n\t\tformatVersion: 1,\n\t\tplanId: plan.id,\n\t\tid,\n\t\texitCode: 2,\n\t}\n\ttry {\n\t\tconst env = plan.environments.find((e) => e.id === id)\n\t\trequireMatrix(env, `Unknown planned environment: ${id}.`)\n\t\tconst { root, bundle, configs } = await validateWorkspace(plan, options)\n\t\tconst { config, baseDirectory } = configs.get(env.packageName)!\n\t\t// Use the immutable bundle directly: no archive installation into the checkout.\n\t\tconst byPath = new Map(\n\t\t\tplan.archives.map((a) => [a.path, path.join(bundle, a.file)]),\n\t\t)\n\t\tconst base = path.resolve(baseDirectory, config.packageDirectory ?? `.`)\n\t\tconst artifactFor = (filename: string): string => {\n\t\t\tconst archive = byPath.get(relative(root, path.resolve(base, filename)))\n\t\t\trequireMatrix(archive, `Plan is missing archive: ${filename}.`)\n\t\t\treturn archive\n\t\t}\n\t\tconst effective: NpmConfig = {\n\t\t\t...config,\n\t\t\tartifact: artifactFor(config.artifact),\n\t\t\tlocalPeers: Object.fromEntries(\n\t\t\t\tObject.entries(config.localPeers ?? {}).map(([name, peer]) => [\n\t\t\t\t\tname,\n\t\t\t\t\t{\n\t\t\t\t\t\t...peer,\n\t\t\t\t\t\tartifact:\n\t\t\t\t\t\t\tbyPath.get(relative(root, path.resolve(base, peer.artifact))) ??\n\t\t\t\t\t\t\tpeer.artifact,\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t),\n\t\t}\n\t\treceipt.report = await npmTestPlanned(\n\t\t\teffective,\n\t\t\t{ representative: env.representative, suites: env.suites },\n\t\t\t{ baseDirectory },\n\t\t)\n\t\treceipt.exitCode = receipt.report.exitCode\n\t\t// Tests/preparation cannot rewrite inputs or bundled artifacts and still attest success.\n\t\tawait validateWorkspace(plan, options)\n\t\tif (receipt.exitCode === 0) {\n\t\t\tconst result = receipt.report.representatives.find(\n\t\t\t\t(r) => r.path === env.representative,\n\t\t\t)\n\t\t\trequireMatrix(\n\t\t\t\tresult?.status === `passed` &&\n\t\t\t\t\tcanonical(result.suites.map((s) => s.peer).sort()) ===\n\t\t\t\t\t\tcanonical(env.suites) &&\n\t\t\t\t\tresult.suites.every((s) => s.status === `passed`) &&\n\t\t\t\t\tcanonical(peerIdentities(result.peers)) === canonical(env.peers),\n\t\t\t\t`Execution differs from the planned suites or peer identities: ${env.label}.`,\n\t\t\t)\n\t\t}\n\t} catch (error) {\n\t\treceipt.exitCode = 2\n\t\treceipt.error = errorMessage(error)\n\t}\n\treturn receipt\n}\n\n/** Verify source/config/archive identities and then require all planned execution receipts. */\nexport async function npmVerify(\n\tvalue: unknown,\n\treceipts: readonly unknown[],\n\toptions: NpmMatrixLocation = {},\n): Promise<NpmVerification> {\n\ttry {\n\t\tconst plan = validateNpmPlan(value)\n\t\tawait validateWorkspace(plan, options)\n\t\treturn verifyNpmReceipts(plan, receipts)\n\t} catch (error) {\n\t\treturn { exitCode: 2, errors: [errorMessage(error)], environments: 0 }\n\t}\n}\n\nexport function npmMatrix(value: unknown): {\n\tinclude: {\n\t\tid: string\n\t\tlabel: string\n\t\tpackageName: string\n\t\trepresentative: string\n\t}[]\n} {\n\treturn {\n\t\tinclude: validateNpmPlan(value).environments.map(\n\t\t\t({ id, label, packageName, representative }) => ({\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tpackageName,\n\t\t\t\trepresentative,\n\t\t\t}),\n\t\t),\n\t}\n}\n\nexport async function writeMatrixJson(\n\tfilename: string,\n\tvalue: unknown,\n): Promise<void> {\n\tawait mkdir(path.dirname(filename), { recursive: true })\n\tconst temporary = `${filename}.${randomUUID()}.tmp`\n\ttry {\n\t\tawait writeFile(temporary, `${JSON.stringify(value, null, 2)}\\n`, {\n\t\t\tflag: `wx`,\n\t\t})\n\t\tawait rename(temporary, filename)\n\t} finally {\n\t\tawait rm(temporary, { force: true })\n\t}\n}\n","import path from \"node:path\"\n\nimport { minimatch } from \"minimatch\"\nimport { simpleGit } from \"simple-git\"\nimport type { Chronicle } from \"takua\"\nimport logger from \"takua\"\n\nimport { command, errorMessage } from \"./task.ts\"\nimport { readManifest, parseManifest } from \"./npm/manifest.ts\"\nimport {\n\tresolveReleaseDelta,\n\tversionDelta,\n\tvalidateRelease,\n\trejectCertificationOptions,\n} from \"./release.ts\"\nimport type { ReleaseConfig, VersionDelta } from \"./release.ts\"\nimport { readBaseline } from \"./baseline.ts\"\nimport { withDirectoryLock } from \"./directory-lock.ts\"\nimport { latestReleaseTag as selectLatestReleaseTag } from \"./release-tag.ts\"\nimport { withTestFileState } from \"./test-file-state.ts\"\n\nexport { defineConfig, loadConfig } from \"./config.ts\"\nexport type { BreakageConfig } from \"./config.ts\"\nexport {\n\tsemverPolicy,\n\tversionTransition,\n\tversionDelta,\n\tresolveReleaseDelta,\n} from \"./release.ts\"\nexport type {\n\tReleaseConfig,\n\tReleasePolicy,\n\tReleasePolicyFunction,\n\tSemverPolicyOptions,\n\tVersionTransition,\n\tReleaseDeltaResolver,\n\tReleaseDeltaContext,\n\tVersionDelta,\n} from \"./release.ts\"\nexport type { CommandResult } from \"./task.ts\"\n\nexport type { BreakageBaseline, BreakagePreludeOptions } from \"./baseline.ts\"\nexport { breakagePrelude } from \"./baseline.ts\"\nexport { formatNpmReport, npmCheck, npmTest } from \"./npm/check.ts\"\nexport {\n\tnpmPlan,\n\tnpmExecute,\n\tnpmVerify,\n\tnpmMatrix,\n\tverifyNpmReceipts,\n} from \"./npm/matrix.ts\"\nexport type {\n\tNpmMatrixConfig,\n\tNpmMatrixLabelContext,\n\tNpmPrepareContext,\n\tNpmArchiveRequest,\n\tNpmPlan,\n\tNpmReceipt,\n\tNpmVerification,\n\tNpmMatrixLocation,\n} from \"./npm/matrix.ts\"\nexport type {\n\tNpmConfig,\n\tNpmPeerEvidence,\n\tNpmReport,\n\tNpmRepresentativeResult,\n\tNpmSuite,\n\tNpmSuiteResult,\n\tNpmTestSelection,\n\tSupportChange,\n} from \"./npm/types.ts\"\n\nexport type BreakageOptions = {\n\ttagPattern?: string | undefined\n\tbaselineFile?: string | undefined\n\ttestPattern: string\n\ttestCommand?: string\n\t/** Shell command. Do not combine with testCommand. */\n\ttest?: string\n\trelease?: ReleaseConfig\n\tbaseDirname?: string\n\tverbose?: boolean | undefined\n}\n\nexport type BreakageOutcome =\n\t| { gitWasClean: false }\n\t| { gitWasClean: true; setupError: string }\n\t| {\n\t\t\tgitWasClean: true\n\t\t\tlastReleaseFound: false\n\t }\n\t| {\n\t\t\tgitWasClean: true\n\t\t\tlastReleaseFound: true\n\t\t\tlastReleaseTag: string\n\t\t\ttestsWereFound: false\n\t }\n\t| {\n\t\t\tgitWasClean: true\n\t\t\tlastReleaseFound: true\n\t\t\tlastReleaseTag: string\n\t\t\ttestsWereFound: true\n\t\t\ttestsFound: string[]\n\t\t\tbreakingChangesFound: false\n\t\t\trelease?: VersionDelta\n\t }\n\t| {\n\t\t\tgitWasClean: true\n\t\t\tlastReleaseFound: true\n\t\t\tlastReleaseTag: string\n\t\t\ttestsWereFound: true\n\t\t\ttestsFound: string[]\n\t\t\tbreakingChangesFound: true\n\t\t\ttestResult: string\n\t\t\trelease?: VersionDelta\n\t }\n\nexport async function breakage(\n\toptions: BreakageOptions,\n): Promise<BreakageOutcome & { summary: string }> {\n\trejectCertificationOptions(options)\n\tconst {\n\t\ttagPattern,\n\t\tbaselineFile,\n\t\ttestPattern,\n\t\ttestCommand,\n\t\ttest,\n\t\trelease,\n\t\tbaseDirname = process.cwd(),\n\t\tverbose = false,\n\t} = options\n\tif (!testPattern || (!test && !testCommand))\n\t\tthrow new Error(\n\t\t\t`required arguments were not provided: testPattern and test or testCommand.`,\n\t\t)\n\tif (test !== undefined && testCommand !== undefined)\n\t\tthrow new Error(`Choose test or testCommand, not both.`)\n\tif (\n\t\ttypeof (test ?? testCommand) !== `string` ||\n\t\t!(test ?? testCommand)!.trim()\n\t)\n\t\tthrow new Error(`test must be a nonempty shell command string.`)\n\tif (release !== undefined) validateRelease(release)\n\tlet mark: Chronicle[`mark`] | undefined\n\tlet logMarks: Chronicle[`logMarks`] | undefined\n\tif (verbose) {\n\t\tconst chronicle = logger.makeChronicle()\n\t\tmark = chronicle.mark\n\t\tlogMarks = chronicle.logMarks\n\t}\n\tmark?.(`breakage`)\n\tconst git = simpleGit(baseDirname)\n\tmark?.(`spawn git`)\n\tconst isGitRepo = await git.checkIsRepo()\n\tmark?.(`is git repository`)\n\tif (!isGitRepo) {\n\t\treturn {\n\t\t\tsummary: `The git repository must be clean to run this command.`,\n\t\t\tgitWasClean: false,\n\t\t}\n\t}\n\tif (\n\t\t!(await withTestFileState(git, baseDirname, (state) => state.isClean()))\n\t) {\n\t\treturn {\n\t\t\tsummary: `The git repository must be clean to run this command.`,\n\t\t\tgitWasClean: false,\n\t\t}\n\t}\n\tlet latestReleaseTag: string | undefined\n\tlet releaseCommit: string\n\tif (baselineFile !== undefined) {\n\t\tconst baseline = await readBaseline(\n\t\t\tgit,\n\t\t\tpath.resolve(baseDirname, baselineFile),\n\t\t\t{ tagPattern },\n\t\t)\n\t\tlatestReleaseTag = baseline.ref\n\t\treleaseCommit = baseline.commit\n\t\tmark?.(`read pinned release baseline`)\n\t} else {\n\t\tconst tagsRemote = await git.listRemote([`--tags`, `origin`])\n\n\t\tmark?.(`list remote tags`)\n\t\tlatestReleaseTag = selectLatestReleaseTag(tagsRemote, tagPattern)\n\t\tmark?.(`found latest release tag`)\n\t\tif (!latestReleaseTag) {\n\t\t\treturn {\n\t\t\t\tsummary: `No tags found matching the pattern \"${tagPattern}\".`,\n\t\t\t\tgitWasClean: true,\n\t\t\t\tlastReleaseFound: false,\n\t\t\t} as const\n\t\t}\n\t\tconst commonGitDirectory = await git.revparse([\n\t\t\t`--path-format=absolute`,\n\t\t\t`--git-common-dir`,\n\t\t])\n\t\tawait withDirectoryLock(\n\t\t\tpath.join(commonGitDirectory, `breakage-fetch.lock`),\n\t\t\t() =>\n\t\t\t\tgit.fetch([\n\t\t\t\t\t`origin`,\n\t\t\t\t\t`${latestReleaseTag}:${latestReleaseTag}`,\n\t\t\t\t\t`--no-tags`,\n\t\t\t\t\t`--no-write-fetch-head`,\n\t\t\t\t]),\n\t\t)\n\n\t\treleaseCommit = await git.revparse([`${latestReleaseTag}^{commit}`])\n\t\tmark?.(`fetched latest release tag`)\n\t}\n\n\tlet productionFiles: string[]\n\ttry {\n\t\tproductionFiles = (\n\t\t\tawait git.raw([`ls-tree`, `-r`, `--name-only`, `-z`, releaseCommit])\n\t\t)\n\t\t\t.split(`\\0`)\n\t\t\t.filter(Boolean)\n\t} catch (thrown) {\n\t\tmark?.(`failed to list production files`)\n\t\tconst message =\n\t\t\tthrown instanceof Error\n\t\t\t\t? thrown.message\n\t\t\t\t: typeof thrown === `string`\n\t\t\t\t\t? thrown\n\t\t\t\t\t: undefined\n\t\tconst summary = `Failed to list production files${\n\t\t\tmessage ? `: ${message}` : `.`\n\t\t}`\n\t\treturn {\n\t\t\tsummary,\n\t\t\tgitWasClean: true,\n\t\t\tlastReleaseFound: true,\n\t\t\tlastReleaseTag: latestReleaseTag,\n\t\t\ttestsWereFound: false,\n\t\t} as const\n\t}\n\tmark?.(`listed all files checked into git`)\n\tconst productionTestFiles = productionFiles.filter((file) =>\n\t\tminimatch(file, testPattern),\n\t)\n\tmark?.(`filtered to public test files`)\n\n\tlet releaseEvidence: VersionDelta | undefined\n\tif (release) {\n\t\tconst current = await readManifest(path.join(baseDirname, `package.json`))\n\t\tconst prefix = await git.revparse([`--show-prefix`])\n\t\tconst previous = parseManifest(\n\t\t\tJSON.parse(await git.show([`${releaseCommit}:${prefix}package.json`])),\n\t\t\t`baseline`,\n\t\t)\n\t\tif (previous.name !== current.name)\n\t\t\tthrow new Error(`Release baseline belongs to another package.`)\n\t\tconst transition = await resolveReleaseDelta(release, {\n\t\t\tpackageName: current.name,\n\t\t\tpackageDirectory: path.resolve(baseDirname),\n\t\t\tcurrentVersion: current.version,\n\t\t\tbaseline: {\n\t\t\t\tversion: previous.version,\n\t\t\t\tref: latestReleaseTag,\n\t\t\t\tcommit: releaseCommit,\n\t\t\t},\n\t\t})\n\t\tif (transition !== undefined)\n\t\t\treleaseEvidence = versionDelta(\n\t\t\t\ttransition.previousVersion,\n\t\t\t\ttransition.version,\n\t\t\t\trelease.policy,\n\t\t\t)\n\t}\n\n\tconst prepared = await withTestFileState(git, baseDirname, async (state) => {\n\t\tif (!(await state.isClean())) {\n\t\t\treturn {\n\t\t\t\tsummary: `The git repository must be clean to run this command.`,\n\t\t\t\tgitWasClean: false,\n\t\t\t} as const\n\t\t}\n\n\t\tif (productionTestFiles.length === 0) {\n\t\t\treturn {\n\t\t\t\tsummary: `No tests were found matching the pattern \"${testPattern}\".`,\n\t\t\t\tgitWasClean: true,\n\t\t\t\tlastReleaseFound: true,\n\t\t\t\tlastReleaseTag: latestReleaseTag,\n\t\t\t\ttestsWereFound: false,\n\t\t\t} as const\n\t\t}\n\t\tconst restore = await state.replaceTests(releaseCommit, productionTestFiles)\n\t\tmark?.(`restored public tests from latest release tag`)\n\t\treturn { latestReleaseTag, productionTestFiles, restore }\n\t})\n\tif (prepared.summary !== undefined) return prepared\n\tconst { restore } = prepared\n\n\ttry {\n\t\tconst result = await command(test ?? testCommand!, baseDirname)\n\t\tif (result.code > 1)\n\t\t\treturn {\n\t\t\t\tgitWasClean: true,\n\t\t\t\tsetupError: result.output,\n\t\t\t\tsummary: `Public test setup failed (${result.code}).`,\n\t\t\t}\n\t\tconst common = {\n\t\t\tgitWasClean: true as const,\n\t\t\tlastReleaseFound: true as const,\n\t\t\tlastReleaseTag: latestReleaseTag,\n\t\t\ttestsWereFound: true as const,\n\t\t\ttestsFound: productionTestFiles,\n\t\t\t...(releaseEvidence ? { release: releaseEvidence } : {}),\n\t\t}\n\t\tif (result.code === 0)\n\t\t\treturn {\n\t\t\t\t...common,\n\t\t\t\tbreakingChangesFound: false,\n\t\t\t\tsummary: `No breaking changes were detected.`,\n\t\t\t}\n\t\treturn {\n\t\t\t...common,\n\t\t\tbreakingChangesFound: true,\n\t\t\ttestResult: result.output,\n\t\t\tsummary: releaseEvidence?.breaking\n\t\t\t\t? `Breaking changes are covered by release ${releaseEvidence.previousVersion} → ${releaseEvidence.version}.`\n\t\t\t\t: `Breaking changes require a breaking release.`,\n\t\t}\n\t} catch (error) {\n\t\treturn {\n\t\t\tgitWasClean: true,\n\t\t\tsetupError: errorMessage(error),\n\t\t\tsummary: `Public test setup failed: ${errorMessage(error)}`,\n\t\t}\n\t} finally {\n\t\tawait restore()\n\t\tmark?.(`restored original public tests`)\n\t\tlogMarks?.()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,eAAsB,QACrB,aACA,KACyB;CACzB,IAAI,OAAO,gBAAgB,YAAY,CAAC,YAAY,KAAK,GACxD,MAAM,IAAI,MAAM,0CAA0C;CAC3D,OAAO,MAAM,IAAI,SAAS,SAAS,WAAW;EAC7C,MAAM,QAAQ,MAAM,aAAa;GAChC;GACA,OAAO;GACP,KAAK;IACJ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