Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Refuse stables that lack a fix a published stable shipped (#5851)

Nick Gomez7eefcb975011
diff --git a/.github/scripts/bug-lane.mjs b/.github/scripts/bug-lane.mjs
index de088dfc8..ab284ec95 100644
--- a/.github/scripts/bug-lane.mjs
+++ b/.github/scripts/bug-lane.mjs
@@ -10,6 +10,11 @@ import {
} from '../../scripts/compute-stable-version.mjs';
import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
import { makeResolveChangesetPrUrl, makeResolveIssuesForUrl } from './select-beta-to-promote.mjs';
+import {
+ createShippedFixCheck,
+ refusalHeadline,
+ unpublishedBaseReason,
+} from './shipped-fix-containment.mjs';
const STABLE_TAG_RE = /^v\d+\.\d+\.\d+$/;
const DEFAULT_LINK_REPO = 'inkeep/agents-private';
@@ -121,6 +126,17 @@ export async function evaluateBugLane({
};
}
+export function holdBugLaneBatch({ stable, check }) {
+ const unpublished = unpublishedBaseReason({
+ latestStableTag: stable,
+ publishedTags: check.publishedStableTags(),
+ });
+ if (unpublished !== null) return unpublished;
+ const verdict = check.evaluate(`refs/tags/${stable}`);
+ if (verdict.ok) return null;
+ return `${refusalHeadline(verdict, stable)} point-release.yml refuses a point release over ${stable} unless its batch also carries those fixes.`;
+}
+
export function ticketsByRef(result) {
const out = {};
for (const c of result.perCommit) {
@@ -231,13 +247,21 @@ async function main() {
: `::notice::bug-lane: no qualifying fixes this tick (${result.reason}).`,
);
+ const held =
+ result.fixRefs.length > 0 ? holdBugLaneBatch({ stable, check: createShippedFixCheck() }) : null;
+ if (held !== null) {
+ console.log(
+ `::notice::bug-lane: holding ${result.fixRefs.length} qualifying fix(es) this tick, so no point release is attempted. ${held}`,
+ );
+ }
+
if (process.env.GITHUB_OUTPUT) {
appendFileSync(
process.env.GITHUB_OUTPUT,
[
- `fix_refs=${result.fixRefs.join(',')}`,
+ `fix_refs=${held === null ? result.fixRefs.join(',') : ''}`,
`stable=${stable}`,
- `fix_tickets=${JSON.stringify(ticketsByRef(result))}`,
+ `fix_tickets=${held === null ? JSON.stringify(ticketsByRef(result)) : '{}'}`,
'',
].join('\n'),
);
diff --git a/.github/scripts/bug-lane.test.mjs b/.github/scripts/bug-lane.test.mjs
index 4d96241fb..efc9ec036 100644
--- a/.github/scripts/bug-lane.test.mjs
+++ b/.github/scripts/bug-lane.test.mjs
@@ -1,11 +1,11 @@
import { execFileSync, spawnSync } from 'node:child_process';
import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
-import { dirname, join } from 'node:path';
+import { delimiter, dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
-import { evaluateBugLane, makeIsInStable, readPendingBumps } from './bug-lane.mjs';
+import { evaluateBugLane, holdBugLaneBatch, makeIsInStable, readPendingBumps } from './bug-lane.mjs';
const FIX_A = 'a'.repeat(40);
const FIX_B = 'b'.repeat(40);
@@ -133,6 +133,54 @@ describe('evaluateBugLane', () => {
});
});
+describe('holdBugLaneBatch (no batch a point release would refuse)', () => {
+ const check = ({ published = ['v0.32.0'], verdict = { ok: true, uncovered: [] } } = {}) => {
+ const asked = [];
+ return {
+ asked,
+ publishedStableTags: () => {
+ if (published instanceof Error) throw published;
+ return published;
+ },
+ evaluate: (candidate) => {
+ asked.push(candidate);
+ return verdict;
+ },
+ };
+ };
+
+ test('lets the batch through when the newest stable is published and keeps every shipped fix', () => {
+ const fake = check();
+ expect(holdBugLaneBatch({ stable: 'v0.32.0', check: fake })).toBeNull();
+ expect(fake.asked).toEqual(['refs/tags/v0.32.0']);
+ });
+
+ test('holds it while the newest stable tag has no published Release, without evaluating it', () => {
+ const fake = check({ published: ['v0.31.9'] });
+ expect(holdBugLaneBatch({ stable: 'v0.32.0', check: fake })).toMatch(
+ /^The newest stable tag v0\.32\.0 has no published Release \(the newest published stable is v0\.31\.9\)/,
+ );
+ expect(fake.asked).toEqual([]);
+ });
+
+ test('holds it while the newest stable lacks a fix a published stable shipped', () => {
+ const verdict = {
+ ok: false,
+ uncovered: [{ sha: 'a'.repeat(40), subject: 'fix: the notice (#5610)', pr: '5610', stables: ['v0.31.4'] }],
+ };
+ expect(holdBugLaneBatch({ stable: 'v0.32.0', check: check({ verdict }) })).toBe(
+ 'v0.32.0 lacks 1 fix that a published stable already shipped: #5610 (v0.31.4). ' +
+ 'point-release.yml refuses a point release over v0.32.0 unless its batch also carries those fixes.',
+ );
+ });
+
+ test('an unreadable listing fails the tick rather than reading as nothing shipped', () => {
+ expect(() =>
+ holdBugLaneBatch({ stable: 'v0.32.0', check: check({ published: new Error('HTTP 502') }) }),
+ ).toThrow('HTTP 502');
+ });
+});
+
describe('makeIsInStable', () => {
let dir;
let fixOnMain;
@@ -238,6 +286,7 @@ describe('the bug-lane entry points the two jobs run', () => {
const COPIED = [
'.github/scripts/bug-lane.mjs',
'.github/scripts/select-beta-to-promote.mjs',
+ '.github/scripts/shipped-fix-containment.mjs',
'scripts/compute-stable-version.mjs',
'scripts/compute-next-beta.mjs',
'scripts/git-clean-env.mjs',
@@ -310,13 +359,23 @@ describe('the bug-lane entry points the two jobs run', () => {
writeFileSync(calls, '');
return { preload, calls, read: () => readFileSync(calls, 'utf8').split('\n').filter(Boolean).map((line) => JSON.parse(line)) };
};
- const run = (script, cwd, { args = [], env = {}, preload } = {}) => {
+ const releasesGh = (listing = [{ tag_name: 'v1.0.0', draft: false, body: '' }]) => {
+ const bin = scratch('bug-lane-gh-');
+ const listed = listing.map((release) => `'${JSON.stringify(release)}'`).join(' ');
+ writeFileSync(
+ join(bin, 'gh'),
+ `#!/bin/sh\nif [ "$1" = api ]; then printf '%s\\n' ${listed}; exit 0; fi\necho "unexpected gh call: $*" >&2\nexit 97\n`,
+ { mode: 0o755 },
+ );
+ return bin;
+ };
+ const run = (script, cwd, { args = [], env = {}, preload, bin = releasesGh() } = {}) => {
const output = join(scratch('bug-lane-output-'), 'github-output');
writeFileSync(output, '');
const res = spawnSync(process.execPath, [...(preload ? ['--import', preload] : []), script, ...args], {
cwd,
encoding: 'utf8',
- env: { ...cleanEnv, GITHUB_OUTPUT: output, ...env },
+ env: { ...cleanEnv, GITHUB_OUTPUT: output, PATH: `${bin}${delimiter}${cleanEnv.PATH}`, ...env },
});
return { ...res, output: readFileSync(output, 'utf8') };
};
@@ -391,4 +450,20 @@ describe('the bug-lane entry points the two jobs run', () => {
expect(res.stderr).toMatch(/BUMP_VERDICTS is empty: the read-bumps job wrote no bump_verdicts output/);
expect(res.output).toBe('');
});
+
+ test('holds a qualifying batch, handing nothing to verify, while the newest stable has no published Release', () => {
+ const { root } = pendingRepo();
+ const verdicts = run(SCRIPT, root, { args: ['--read-bumps'] }).output.trim().slice('bump_verdicts='.length);
+ const linear = linearStub();
+ const res = run(isolatedScript(), root, {
+ env: { LINEAR_API_KEY: 'placeholder-linear-key', LINEAR_CALLS: linear.calls, BUMP_VERDICTS: verdicts },
+ preload: linear.preload,
+ bin: releasesGh([{ tag_name: 'v1.0.0', draft: true, body: '' }]),
+ });
+ expect(res.status, res.stderr).toBe(0);
+ expect(res.output).toBe('fix_refs=\nstable=v1.0.0\nfix_tickets={}\n');
+ expect(res.stdout).toContain(
+ '::notice::bug-lane: holding 1 qualifying fix(es) this tick, so no point release is attempted. The newest stable tag v1.0.0 has no published Release',
+ );
+ });
});
diff --git a/.github/scripts/build-smoke-alert-payload.mjs b/.github/scripts/build-smoke-alert-payload.mjs
index f1c0e7b9c..6f9103736 100644
--- a/.github/scripts/build-smoke-alert-payload.mjs
+++ b/.github/scripts/build-smoke-alert-payload.mjs
@@ -64,7 +64,7 @@ function summaryLine(tag, verdict, blockedBy) {
return `🚨 ${ALERT_HEADLINE}: ${tag} ${subject} — nothing shipped`;
}
-function recoveryGuidance() {
+function recoveryGuidance(tag) {
return [
"*Recovery guidance:* Inspect the failed packaging job's final `outcome=`.",
'With no newer stable release, `transient-exhausted`, `deadline`, or `signal` can re-fire the same tag; investigate a recurring deadline.',
@@ -73,6 +73,7 @@ function recoveryGuidance() {
'`cleanup-failure` reports its runner/tooling cause in `cleanup=`; `spawn-failure` and `child-signal` are also runner/tooling failures. Confirm the runner/tooling failure is absent before re-firing.',
"`attempt-timeout` and a mid-attempt `deadline` list the processes still running under the stop line: a long `notarytool` wait is Apple's queue and can re-fire; a long `codesign`, or a `took no process snapshot` line, needs that failure confirmed absent first.",
'Never re-fire a tag once a newer stable release has shipped; cut a new release from `main` instead.',
+ `Before any re-fire, run the shipped-fix check on the tag from a full clone: \`node .github/scripts/shipped-fix-containment.mjs --candidate ${tag}\`. Never re-fire a tag it refuses; the re-fired run refuses it too.`,
].join('\n');
}
@@ -88,7 +89,7 @@ function bodyLines({ tag, verdict, reason, runUrl, repo, blockedBy }) {
: `*Why:* ${other} failed (${reason}).`
: `*Why:* ${reason}`,
'*State:* the GitHub Release is still a DRAFT and npm `latest` has NOT moved.',
- recoveryGuidance(),
+ recoveryGuidance(tag),
`*Recovery command:*\n\`${recoveryCommand(tag, repo)}\``,
`*Run:* ${runUrl}`,
];
diff --git a/.github/scripts/build-smoke-alert-payload.test.mjs b/.github/scripts/build-smoke-alert-payload.test.mjs
index 5872e2de6..a41aca690 100644
--- a/.github/scripts/build-smoke-alert-payload.test.mjs
+++ b/.github/scripts/build-smoke-alert-payload.test.mjs
@@ -85,6 +85,9 @@ describe('alert content', () => {
);
expect(body).toContain("a long `notarytool` wait is Apple's queue and can re-fire");
expect(body).toContain('Never re-fire a tag once a newer stable release has shipped');
+ expect(body).toContain(
+ 'Before any re-fire, run the shipped-fix check on the tag from a full clone: `node .github/scripts/shipped-fix-containment.mjs --candidate v1.2.3`. Never re-fire a tag it refuses',
+ );
expect(body).not.toContain('re-firing alone repairs nothing');
expect(body).not.toContain('no manual repair needed');
});
diff --git a/.github/scripts/decide-release-retry.test.mjs b/.github/scripts/decide-release-retry.test.mjs
index 55dabb9e4..5c758b625 100644
--- a/.github/scripts/decide-release-retry.test.mjs
+++ b/.github/scripts/decide-release-retry.test.mjs
@@ -7,6 +7,7 @@ import { afterAll, describe, expect, test } from 'vitest';
import { parse } from 'yaml';
import { classifyFailedJob, decideRetry, RETRYABLE_OUTCOMES } from './decide-release-retry.mjs';
import { STOP_OUTCOMES } from './retry-transient.mjs';
+import { refusalHeadline } from './shipped-fix-containment.mjs';
const failure = (message) => ({ level: 'failure', message });
const notice = (message) => ({ level: 'notice', message });
@@ -223,6 +224,62 @@ describe('decideRetry', () => {
});
});
+describe('a stable the shipped-fix check refused is paged, never re-run', () => {
+ const headline = refusalHeadline(
+ {
+ uncovered: [
+ {
+ sha: 'a66f9e77679cb6fad68eb0b8bdd8ff5b54edca49',
+ subject: 'fix(ok): keep the update-ready notice reachable (#5610)',
+ pr: '5610',
+ stables: ['v0.82.3'],
+ },
+ ],
+ },
+ 'v0.83.0',
+ );
+
+ test('a prepare refusal is not a retryable cause, even beside a retryable packaging stop', () => {
+ const jobs = [
+ {
+ name: 'prepare',
+ conclusion: 'failure',
+ annotations: [failure(headline), failure('Process completed with exit code 2.')],
+ },
+ {
+ name: 'build-macos (stable)',
+ conclusion: 'failure',
+ annotations: [EXIT_1, stop('attempt-timeout', 'control:attempt-timeout')],
+ },
+ { name: 'publish-assets', conclusion: 'skipped', annotations: [] },
+ ];
+ expect(classifyFailedJob(jobs[0].annotations)).toEqual({ retryable: false, cause: headline });
+ expect(decideRetry({ ...stable, jobs })).toEqual({
+ action: 'page',
+ reason:
+ 'prepare: v0.83.0 lacks 1 fix that a published stable already shipped: #5610 (v0.82.3).',
+ });
+ });
+
+ test('a finalize refusal right before publishing is paged too', () => {
+ const jobs = [
+ { name: 'prepare', conclusion: 'success', annotations: [] },
+ { name: 'build-macos (stable)', conclusion: 'success', annotations: [] },
+ { name: 'publish-assets', conclusion: 'success', annotations: [] },
+ {
+ name: 'finalize',
+ conclusion: 'failure',
+ annotations: [failure(headline), failure('Process completed with exit code 2.')],
+ },
+ ];
+ expect(decideRetry({ ...stable, jobs })).toEqual({
+ action: 'page',
+ reason:
+ 'finalize: v0.83.0 lacks 1 fix that a published stable already shipped: #5610 (v0.82.3).',
+ });
+ });
+});
+
describe('finalize refuses to promote a superseded stable on a re-run', () => {
const finalize = parse(
readFileSync(
diff --git a/.github/scripts/point-release-plan.mjs b/.github/scripts/point-release-plan.mjs
index 5b092f421..a9f77c927 100644
--- a/.github/scripts/point-release-plan.mjs
+++ b/.github/scripts/point-release-plan.mjs
@@ -20,6 +20,12 @@ import {
makeTreeAt,
selectPrebuildRun,
} from './select-native-config-prebuild.mjs';
+import {
+ createShippedFixCheck,
+ describeVerdict,
+ refusalHeadline,
+ unpublishedBaseReason,
+} from './shipped-fix-containment.mjs';
import { parseChangeset } from './write-back.mjs';
function refuse(code, message) {
@@ -303,6 +309,24 @@ export function verifyWorkspaceMatchesLockfile({ resolved, readWorktreeFile }) {
return `agrees with the lockfile on ${notes.join(' and ')}.`;
}
+export function guardBasePublished({ latestStableTag, publishedTags }) {
+ const reason = unpublishedBaseReason({ latestStableTag, publishedTags });
+ if (reason !== null) return refuse('base-unpublished', reason);
+ return pass(`The newest stable tag ${latestStableTag} is published, so the point release builds on it.`);
+}
+
+export function guardShipsPublishedFixes({ verdict, latestStableTag }) {
+ const label = `${latestStableTag} plus the applied fixes`;
+ if (verdict.ok) return pass(describeVerdict(verdict, label)[0]);
+ return refuse(
+ 'drops-shipped-fix',
+ [
+ `${refusalHeadline(verdict, label)} Add those fixes to fix_refs, or ship through a promotion whose beta contains them.`,
+ ...describeVerdict(verdict, label).slice(1),
+ ].join('\n'),
+ );
+}
+
export function guardRefsOnMain({ fixRefs, isOnMain }) {
const offenders = fixRefs.filter((ref) => !isOnMain(ref));
if (offenders.length > 0) {
@@ -469,6 +493,10 @@ export function runPointRelease(opts, io) {
}
const latestStableSha = io.git.revParse(latestStableTag);
+ checkGuard(
+ guards,
+ guardBasePublished({ latestStableTag, publishedTags: io.containment.publishedStableTags() }),
+ );
checkGuard(guards, guardAnchor({ anchorVersion: io.readAnchorVersion(), latestStableTag }));
checkGuard(guards, guardRefsOnMain({ fixRefs, isOnMain: io.git.isOnMain }));
checkGuard(guards, guardResolvePathsAllowlisted({ resolvePaths }));
@@ -511,6 +539,12 @@ export function runPointRelease(opts, io) {
selection: io.gh.selectNativeConfigPrebuild(syntheticSha),
}),
);
+ checkGuard(
+ guards,
+ guardShipsPublishedFixes({ verdict: io.containment.evaluate(syntheticSha), latestStableTag }),
+ );
+
+ if (mode === 'revert') warnings.push(revertFollowUpWarning(version.removedIds));
const mainReset = decideMainReset({ anchorDeltaIds, addedIds: version.addedIds, bridgeConfigured, guards, warnings });
@@ -666,6 +700,24 @@ function changesetsIntroducedBy(resolvedRefs, io) {
return introduced;
}
+function revertFollowUpWarning(removedIds) {
+ if (removedIds.length > 0) {
+ return (
+ `This revert deletes ${removedIds.map((id) => `.changeset/${id}.md`).join(', ')}. ` +
+ 'If main-reset has already consumed these files on main, an ordinary code-only revert there cannot ' +
+ 'reproduce the shipped patch. The shipped-fix check will refuse that later main promotion even when ' +
+ 'the rollback code is correct; putting its changeset in a separate PR does not resolve this mismatch. ' +
+ 'Unless the revert cannot wait for main, land it on main and ship it in cherry-pick mode instead, ' +
+ 'provided it picks cleanly; otherwise use the normal promotion path.'
+ );
+ }
+ return (
+ 'A revert has no PR number of its own, so the shipped-fix check will refuse every later promotion until ' +
+ 'main holds a commit with exactly the patch this release ships. Land the revert on main in a PR that ' +
+ 'changes nothing else, and put its changeset in a separate PR.'
+ );
+}
+
function decideMainReset({ anchorDeltaIds, addedIds, bridgeConfigured, guards, warnings }) {
const named = String(anchorDeltaIds ?? '').trim() !== '';
const deltaIds = named ? parseDeltaIds(anchorDeltaIds) : addedIds;
@@ -719,6 +771,7 @@ export function formatReleaseNotes(plan) {
export function realIo() {
return {
readAnchorVersion,
+ containment: createShippedFixCheck(),
fs: {
readWorktreeFile: (path) => readFileSync(path, 'utf8'),
writeWorktreeFile: (path, content) => writeFileSync(path, content),
diff --git a/.github/scripts/point-release-plan.test.mjs b/.github/scripts/point-release-plan.test.mjs
index bb412bebf..764aeedcd 100644
--- a/.github/scripts/point-release-plan.test.mjs
+++ b/.github/scripts/point-release-plan.test.mjs
@@ -12,21 +12,25 @@ import {
deriveEntryLevelResolution,
formatReleaseNotes,
guardAnchor,
+ guardBasePublished,
guardDeltaMatchesFix,
guardMainResetDeltaIds,
guardNativeConfigProvenance,
guardPatchOnly,
guardRefsOnMain,
guardResolvePathsAllowlisted,
+ guardShipsPublishedFixes,
guardTagFree,
parseFixRefs,
parseResolvePaths,
pushTagArgs,
RESOLVABLE_PATHS,
readFixBumps,
+ realIo,
runPointRelease,
verifyWorkspaceMatchesLockfile,
} from './point-release-plan.mjs';
+import { appliedOrigins } from './shipped-fix-containment.mjs';
function inspectGitEscapes(source) {
const project = new Project({ useInMemoryFileSystem: true, skipLoadingLibFiles: true });
@@ -68,6 +72,37 @@ const membership = (...members) => {
};
};
+const containedVerdict = (candidateSha = 'synthetic-sha') => ({
+ ok: true,
+ candidate: candidateSha,
+ candidateSha: candidateSha.padEnd(40, '0'),
+ published: 3,
+ checked: ['v0.31.4'],
+ records: 1,
+ plusRecords: 1,
+ plusCommits: 1,
+ coveredByProvenance: 1,
+ coveredByPrNumber: 0,
+ commits: [],
+ uncovered: [],
+});
+
+const droppedFixVerdict = () => ({
+ ...containedVerdict(),
+ ok: false,
+ coveredByProvenance: 0,
+ uncovered: [
+ {
+ sha: 'a66f9e77679cb6fad68eb0b8bdd8ff5b54edca49',
+ subject: 'fix(ok): keep the update-ready notice reachable (#5610)',
+ pr: '5610',
+ origin: null,
+ coverage: null,
+ stables: ['v0.31.4'],
+ },
+ ],
+});
+
describe('guardAnchor', () => {
test('refuses while a stable tag is ahead of the changeset anchor', () => {
const r = guardAnchor({ anchorVersion: '0.32.0', latestStableTag: 'v0.32.1' });
@@ -557,6 +592,8 @@ describe('guard codes', () => {
guardPatchOnly({ bump: 'major' }),
guardNativeConfigProvenance({ selection: { headSha: '', reason: 'nothing qualified' } }),
guardMainResetDeltaIds({ deltaIds: [] }),
+ guardBasePublished({ latestStableTag: 'v0.32.1', publishedTags: ['v0.32.0'] }),
+ guardShipsPublishedFixes({ verdict: droppedFixVerdict(), latestStableTag: 'v0.32.0' }),
];
expect(refusals.every((r) => r.ok === false)).toBe(true);
const codes = refusals.map((r) => r.code);
@@ -581,9 +618,12 @@ function makeIo(overrides = {}) {
conflicts = [],
files = {},
worktree = {},
+ publishedTags = [stableTag],
+ containmentVerdict = containedVerdict,
} = overrides;
const calls = { tag: 0, pushTag: 0, createRelease: 0, dispatch: 0 };
+ const evaluated = [];
const dispatches = [];
const releases = [];
const applied = [];
@@ -604,6 +644,15 @@ function makeIo(overrides = {}) {
written,
reads,
worktree,
+ evaluated,
+ containment: {
+ publishedStableTags: () =>
+ typeof publishedTags === 'function' ? publishedTags() : [...publishedTags],
+ evaluate: (sha) => {
+ evaluated.push(sha);
+ return containmentVerdict(sha);
+ },
+ },
fs: {
readWorktreeFile: (path) => {
if (!(path in worktree)) throw new Error(`no worktree file ${path}`);
@@ -894,6 +943,37 @@ describe('runPointRelease cascade', () => {
expect(mainReset.clientPayload.delta_ids).toEqual(['undo-bad']);
});
+ test('revert mode warns that main must carry the same patch before the next promotion', () => {
+ const plan = runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: true }, makeIo());
+ expect(plan.removedIds).toEqual([]);
+ expect(plan.warnings.join(' ')).toContain(
+ 'the shipped-fix check will refuse every later promotion until main holds a commit with exactly the patch this release ships',
+ );
+ });
+
+ test('revert mode warns that an ordinary main follow-up cannot match a consumed changeset deletion', () => {
+ const io = makeIo({
+ changesets: { 'stable-sha': ['keep-a', 'bad-change'], 'synthetic-sha': ['keep-a'] },
+ });
+ const plan = runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: true }, io);
+ expect(plan.removedIds).toEqual(['bad-change']);
+ const warning = plan.warnings.join(' ');
+ expect(warning).toContain('This revert deletes .changeset/bad-change.md');
+ expect(warning).toContain('If main-reset has already consumed these files on main');
+ expect(warning).toContain('an ordinary code-only revert there cannot reproduce the shipped patch');
+ expect(warning).toContain('putting its changeset in a separate PR does not resolve this mismatch');
+ expect(warning).toContain('ship it in cherry-pick mode instead');
+ expect(warning).not.toContain('exactly the patch this release ships');
+ });
+
+ test('cherry-pick mode gives no revert warning', () => {
+ const plan = runPointRelease(
+ { mode: 'cherry-pick', fixRefs: ['fix1'], dryRun: true },
+ cherryPickIo(),
+ );
+ expect(plan.warnings.join(' ')).not.toContain('shipped-fix check will refuse');
+ });
+
test('refuses when the operator names a delta that parses to nothing', () => {
const io = makeIo();
let refusal;
@@ -968,6 +1048,12 @@ describe('runPointRelease refusals', () => {
{ nativeConfigSelection: { headSha: '', reason: 'newest green run 42 @ abc123 does not' } },
{ mode: 'revert', fixRefs: ['bad1'] },
],
+ ['base-unpublished', { publishedTags: ['v0.31.9'] }, { mode: 'revert', fixRefs: ['bad1'] }],
+ [
+ 'drops-shipped-fix',
+ { containmentVerdict: droppedFixVerdict },
+ { mode: 'revert', fixRefs: ['bad1'] },
+ ],
];
test.each(cases)(
@@ -1112,6 +1198,76 @@ describe('runPointRelease refusals', () => {
});
});
+describe('runPointRelease keeps every fix a published stable shipped', () => {
+ test('builds only over the newest stable tag when its Release is published', () => {
+ const io = makeIo({ stableTag: 'v0.32.1', publishedTags: ['v0.31.9', 'v0.32.0'] });
+ let refusal;
+ try {
+ runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: true }, io);
+ } catch (err) {
+ refusal = err;
+ }
+ expect(refusal?.code).toBe('base-unpublished');
+ expect(refusal?.message).toContain('The newest stable tag v0.32.1 has no published Release');
+ expect(refusal?.message).toContain('the newest published stable is v0.32.0');
+ expect(io.checkedOut).toEqual([]);
+ expect(io.applied).toEqual([]);
+ expect(io.evaluated).toEqual([]);
+ });
+
+ test('checks the synthetic commit, not the base, and records the verdict in the guard trail', () => {
+ const io = makeIo();
+ const plan = runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: true }, io);
+ expect(io.evaluated).toEqual(['synthetic-sha']);
+ expect(plan.guards.map((g) => g.message)).toEqual(
+ expect.arrayContaining([
+ 'The newest stable tag v0.32.0 is published, so the point release builds on it.',
+ expect.stringContaining('v0.32.0 plus the applied fixes'),
+ ]),
+ );
+ });
+
+ test('refuses a synthetic commit that lacks a shipped fix, naming it, in a dry run too', () => {
+ const io = makeIo({ containmentVerdict: droppedFixVerdict });
+ let refusal;
+ try {
+ runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: true }, io);
+ } catch (err) {
+ refusal = err;
+ }
+ expect(refusal?.code).toBe('drops-shipped-fix');
+ expect(refusal?.message.split('\n')[0]).toBe(
+ 'v0.32.0 plus the applied fixes lacks 1 fix that a published stable already shipped: #5610 ' +
+ '(v0.31.4). Add those fixes to fix_refs, or ship through a promotion whose beta contains them.',
+ );
+ expect(refusal?.message).toContain('a66f9e77679c fix(ok): keep the update-ready notice reachable (#5610)');
+ expect(io.calls).toEqual({ tag: 0, pushTag: 0, createRelease: 0, dispatch: 0 });
+ });
+
+ test('an unreadable release listing is an infra failure, never a pass', () => {
+ const io = makeIo({
+ publishedTags: () => {
+ throw new Error('listing the releases of inkeep/open-knowledge failed: HTTP 502');
+ },
+ });
+ let thrown;
+ try {
+ runPointRelease({ mode: 'revert', fixRefs: ['bad1'], dryRun: false }, io);
+ } catch (err) {
+ thrown = err;
+ }
+ expect(thrown?.message).toMatch(/HTTP 502/);
+ expect(thrown?.code).toBeUndefined();
+ expect(io.calls).toEqual({ tag: 0, pushTag: 0, createRelease: 0, dispatch: 0 });
+ });
+
+ test('the production io answers both questions from the published Releases', () => {
+ const { containment } = realIo();
+ expect(typeof containment.publishedStableTags).toBe('function');
+ expect(typeof containment.evaluate).toBe('function');
+ });
+});
+
describe('runPointRelease with an authorized config path', () => {
const authorized = ['pnpm-workspace.yaml'];
@@ -1468,6 +1624,22 @@ describe('formatReleaseNotes "Applied" line', () => {
]),
).toBe(`Applied: ${SHA}, hotfix-tag (${other})`);
});
+
+ test('the shipped-fix check reads back every origin these notes record', () => {
+ const other = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef';
+ const notes = formatReleaseNotes({
+ latestStableTag: 'v0.48.2',
+ mode: 'cherry-pick',
+ fixRefs: [
+ { ref: SHA, sha: SHA },
+ { ref: 'deadbeef', sha: other },
+ ],
+ changesetEntries: [],
+ addedIds: [],
+ removedIds: [],
+ });
+ expect(appliedOrigins(notes)).toEqual([SHA, other]);
+ });
});
describe('git escape rule self-test', () => {
diff --git a/.github/scripts/select-beta-to-promote.mjs b/.github/scripts/select-beta-to-promote.mjs
index 1079ec228..b7f5262b7 100644
--- a/.github/scripts/select-beta-to-promote.mjs
+++ b/.github/scripts/select-beta-to-promote.mjs
@@ -10,6 +10,7 @@ import {
withBumpVerdicts,
} from '../../scripts/compute-stable-version.mjs';
import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
+import { createShippedFixCheck, refusalHeadline } from './shipped-fix-containment.mjs';
const BETA_TAG_RE = /^v\d+\.\d+\.\d+-beta\.\d+$/;
const STABLE_TAG_RE = /^v\d+\.\d+\.\d+$/;
@@ -171,6 +172,54 @@ export function resolveTier({ armed, verdict, standardTarget, fastTarget }) {
return { tier, target: standardTarget, candidate: tier === 'fast' ? fastTarget : '' };
}
+export function screenShippedFixes({
+ target,
+ fastTierCandidate,
+ dispatchWindowOpen,
+ evaluate,
+ log = () => {},
+}) {
+ let screenedTarget = target;
+ let screenedFast = fastTierCandidate;
+ if (target && dispatchWindowOpen) {
+ const verdict = evaluate(target);
+ if (!verdict.ok) {
+ log(
+ `::warning::Not dispatching ${target}: ${refusalHeadline(verdict, target)} ` +
+ 'promote-stable would refuse it, and every older beta lacks the same fixes, so this tick dispatches nothing.',
+ );
+ screenedTarget = '';
+ }
+ }
+ if (fastTierCandidate) {
+ let verdict;
+ try {
+ verdict = evaluate(fastTierCandidate);
+ } catch (err) {
+ log(
+ `::warning::Fast tier REFUSED for ${fastTierCandidate}: the shipped-fix check could not decide (${err.message}). Falling back to the 24h tier.`,
+ );
+ return { target: screenedTarget, fastTierCandidate: '' };
+ }
+ if (!verdict.ok) {
+ log(
+ `::warning::Fast tier REFUSED for ${fastTierCandidate}: ${refusalHeadline(verdict, fastTierCandidate)} ` +
+ 'promote-stable would refuse it, so it is not smoked.',
+ );
+ screenedFast = '';
+ }
+ }
+ return { target: screenedTarget, fastTierCandidate: screenedFast };
+}
+
+export function memoizeVerdicts(evaluate) {
+ const verdicts = new Map();
+ return (tag) => {
+ if (!verdicts.has(tag)) verdicts.set(tag, evaluate(tag));
+ return verdicts.get(tag);
+ };
+}
+
function resolveLatestStableSha() {
const out = execFileSync('git', ['tag', '--list', 'v*', '--sort=-version:refname'], {
encoding: 'utf8',
@@ -398,12 +447,21 @@ async function main() {
};
}
- const { tier: soakTier, target, candidate: fastTierCandidate } = resolveTier({
+ const resolved = resolveTier({
armed,
verdict,
standardTarget,
fastTarget,
});
+ const soakTier = resolved.tier;
+ const shippedFixCheck = createShippedFixCheck();
+ const { target, fastTierCandidate } = screenShippedFixes({
+ target: resolved.target,
+ fastTierCandidate: resolved.candidate,
+ dispatchWindowOpen: process.env.DISPATCH_WINDOW_OPEN !== 'false',
+ evaluate: memoizeVerdicts((tag) => shippedFixCheck.evaluate(tag)),
+ log: console.log,
+ });
if (fastTierCandidate) {
console.log(
`::notice::Fast tier: nominating ${fastTierCandidate} for the DMG-smoke leg (patch-only + bug-linked, >=1h soak). ` +
@@ -428,7 +486,7 @@ async function main() {
process.env.GITHUB_OUTPUT,
[
`target=${target}`,
- `tier=${selectionTier}`,
+ `tier=${target ? selectionTier : ''}`,
`fast_tier_candidate=${fastTierCandidate}`,
`soak_tier=${soakTier}`,
`fast_armed=${armed}`,
diff --git a/.github/scripts/select-beta-to-promote.test.mjs b/.github/scripts/select-beta-to-promote.test.mjs
index 0bb59f26a..c8557b4fb 100644
--- a/.github/scripts/select-beta-to-promote.test.mjs
+++ b/.github/scripts/select-beta-to-promote.test.mjs
@@ -10,9 +10,11 @@ import {
evaluateFastTier,
makeResolveChangesetPrUrl,
makeResolveIssuesForUrl,
+ memoizeVerdicts,
parseBetaTags,
readUnshippedBumps,
resolveTier,
+ screenShippedFixes,
selectPromotion,
} from './select-beta-to-promote.mjs';
@@ -593,6 +595,120 @@ function makeRepoWithChangesets(commits) {
return dir;
}
+describe('screenShippedFixes (no dispatch promote-stable would refuse)', () => {
+ const refused = (candidate) => ({
+ ok: false,
+ candidate,
+ uncovered: [{ sha: 'a'.repeat(40), subject: 'fix: shipped on stable (#300)', pr: '300', stables: ['v1.0.1'] }],
+ });
+ const admitted = (candidate) => ({ ok: true, candidate, uncovered: [] });
+ const recorder = (verdicts) => {
+ const asked = [];
+ return {
+ asked,
+ evaluate: (tag) => {
+ asked.push(tag);
+ const verdict = verdicts[tag];
+ if (verdict instanceof Error) throw verdict;
+ return verdict(tag);
+ },
+ };
+ };
+
+ test('inside the window a refused 24h selection is not dispatched, and the warning names the fix', () => {
+ const check = recorder({ 'v1.0.1-beta.0': refused });
+ const lines = [];
+ const result = screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: '',
+ dispatchWindowOpen: true,
+ evaluate: check.evaluate,
+ log: (line) => lines.push(line),
+ });
+ expect(result).toEqual({ target: '', fastTierCandidate: '' });
+ expect(lines).toEqual([
+ expect.stringMatching(
+ /^::warning::Not dispatching v1\.0\.1-beta\.0: v1\.0\.1-beta\.0 lacks 1 fix that a published stable already shipped: #300 \(v1\.0\.1\)\. /,
+ ),
+ ]);
+ });
+
+ test('outside the window the 24h selection is left alone and costs no check', () => {
+ const check = recorder({});
+ const result = screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: '',
+ dispatchWindowOpen: false,
+ evaluate: check.evaluate,
+ });
+ expect(result.target).toBe('v1.0.1-beta.0');
+ expect(check.asked).toEqual([]);
+ });
+
+ test('an admitted selection and candidate pass through unchanged', () => {
+ const check = recorder({ 'v1.0.1-beta.0': admitted, 'v1.1.0-beta.0': admitted });
+ expect(
+ screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: 'v1.1.0-beta.0',
+ dispatchWindowOpen: true,
+ evaluate: check.evaluate,
+ }),
+ ).toEqual({ target: 'v1.0.1-beta.0', fastTierCandidate: 'v1.1.0-beta.0' });
+ });
+
+ test('a refused fast-tier candidate is not nominated for the smoke', () => {
+ const check = recorder({ 'v1.1.0-beta.0': refused });
+ const lines = [];
+ const result = screenShippedFixes({
+ target: '',
+ fastTierCandidate: 'v1.1.0-beta.0',
+ dispatchWindowOpen: false,
+ evaluate: check.evaluate,
+ log: (line) => lines.push(line),
+ });
+ expect(result.fastTierCandidate).toBe('');
+ expect(lines[0]).toMatch(/^::warning::Fast tier REFUSED for v1\.1\.0-beta\.0: .*#300 \(v1\.0\.1\)/);
+ });
+
+ test('a check that cannot decide fails the 24h selection loudly and declines the fast tier', () => {
+ const broken = new Error('listing the releases of inkeep/open-knowledge failed: HTTP 502');
+ expect(() =>
+ screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: '',
+ dispatchWindowOpen: true,
+ evaluate: recorder({ 'v1.0.1-beta.0': broken }).evaluate,
+ }),
+ ).toThrow(/HTTP 502/);
+ const lines = [];
+ const result = screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: 'v1.1.0-beta.0',
+ dispatchWindowOpen: false,
+ evaluate: recorder({ 'v1.1.0-beta.0': broken }).evaluate,
+ log: (line) => lines.push(line),
+ });
+ expect(result).toEqual({ target: 'v1.0.1-beta.0', fastTierCandidate: '' });
+ expect(lines[0]).toMatch(/could not decide \(listing the releases .*HTTP 502\)\. Falling back to the 24h tier\./);
+ });
+
+ test('a beta that is both the selection and the candidate is checked once', () => {
+ let calls = 0;
+ const evaluate = memoizeVerdicts((tag) => {
+ calls += 1;
+ return admitted(tag);
+ });
+ screenShippedFixes({
+ target: 'v1.0.1-beta.0',
+ fastTierCandidate: 'v1.0.1-beta.0',
+ dispatchWindowOpen: true,
+ evaluate,
+ });
+ expect(calls).toBe(1);
+ });
+});
+
describe('makeResolveChangesetPrUrl (real git)', () => {
test('resolves a changeset to the pull request named by its adding commit', () => {
const dir = makeRepoWithChangesets([
@@ -830,6 +946,7 @@ describe('the selector entry points the two jobs run', () => {
const OK_ROOT = join(dirname(SCRIPT), '..', '..');
const COPIED = [
'.github/scripts/select-beta-to-promote.mjs',
+ '.github/scripts/shipped-fix-containment.mjs',
'scripts/compute-stable-version.mjs',
'scripts/compute-next-beta.mjs',
'scripts/git-clean-env.mjs',
@@ -883,19 +1000,23 @@ describe('the selector entry points the two jobs run', () => {
writeFileSync(join(bin, 'gh'), script, { mode: 0o755 });
return bin;
};
- const releaseGh = () => {
+ const releaseGh = ({
+ listing = [{ tag_name: 'v1.0.0', draft: false, body: '' }],
+ ages = { 'v1.1.0-beta.0': 10, 'v1.0.1-beta.0': 120 },
+ } = {}) => {
const meta = (minutesAgo) =>
JSON.stringify({
isDraft: false,
publishedAt: new Date(Date.now() - minutesAgo * 60_000).toISOString(),
assets: [{ name: 'OpenKnowledge-Beta-universal.dmg' }, { name: 'beta-mac.yml' }],
});
+ const listed = listing.map((release) => `'${JSON.stringify(release)}'`).join(' ');
return ghBin(
[
'#!/bin/sh',
+ `if [ "$1" = api ]; then printf '%s\\n' ${listed}; exit 0; fi`,
'case "$3" in',
- ` v1.1.0-beta.0) printf '%s' '${meta(10)}' ;;`,
- ` v1.0.1-beta.0) printf '%s' '${meta(120)}' ;;`,
+ ...Object.entries(ages).map(([tag, minutes]) => ` ${tag}) printf '%s' '${meta(minutes)}' ;;`),
' *) echo "release not found" >&2; exit 1 ;;',
'esac',
'',
@@ -1008,4 +1129,35 @@ describe('the selector entry points the two jobs run', () => {
expect(res.stderr).toMatch(/BUMP_VERDICTS is empty: the read-bumps job wrote no bump_verdicts output/);
expect(res.output).toBe('');
});
+
+ test('inside the window it does not dispatch a soaked beta that lacks a fix a published stable shipped', () => {
+ const { root } = betaRepo();
+ git(root, 'switch', '-q', '--detach', 'v1.0.0');
+ writeFileSync(join(root, 'hotfix.txt'), 'shipped only on the stable line\n');
+ git(root, 'add', '-A');
+ git(root, 'commit', '-q', '-m', 'fix: ship the hotfix on the stable line (#300)');
+ git(root, 'tag', 'v1.0.1');
+ git(root, 'switch', '-q', 'main');
+ const verdicts = readBumps(root).output.trim().slice('bump_verdicts='.length);
+ const bin = releaseGh({
+ listing: [
+ { tag_name: 'v1.0.0', draft: false, body: '' },
+ { tag_name: 'v1.0.1', draft: false, body: '' },
+ ],
+ ages: { 'v1.1.0-beta.0': 10, 'v1.0.1-beta.0': 60 * 25 },
+ });
+ const env = { BUMP_VERDICTS: verdicts, SOAK_SECONDS: '86400', FAST_TIER_ARMED: 'false' };
+
+ const open = run(isolatedScript(), root, { env: { ...env, DISPATCH_WINDOW_OPEN: 'true' }, bin });
+ expect(open.status, open.stderr).toBe(0);
+ expect(open.output).toContain('target=\ntier=\n');
+ expect(open.stdout).toContain(
+ '::warning::Not dispatching v1.0.1-beta.0: v1.0.1-beta.0 lacks 1 fix that a published stable already shipped: #300 (v1.0.1).',
+ );
+
+ const closed = run(isolatedScript(), root, { env: { ...env, DISPATCH_WINDOW_OPEN: 'false' }, bin });
+ expect(closed.status, closed.stderr).toBe(0);
+ expect(closed.output).toContain('target=v1.0.1-beta.0\ntier=soak\n');
+ expect(closed.stdout).not.toContain('Not dispatching');
+ });
});
diff --git a/.github/scripts/shipped-fix-containment-shape.test.mjs b/.github/scripts/shipped-fix-containment-shape.test.mjs
new file mode 100644
index 000000000..485cba234
--- /dev/null
+++ b/.github/scripts/shipped-fix-containment-shape.test.mjs
@@ -0,0 +1,321 @@
+// biome-ignore-all lint/suspicious/noTemplateCurlyInString: shell and GitHub expression fixtures must remain literal.
+import { execFileSync, spawnSync } from 'node:child_process';
+import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { delimiter, dirname, join, posix } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { afterAll, describe, expect, test } from 'vitest';
+import { parse } from 'yaml';
+import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
+
+const SCRIPTS = dirname(fileURLToPath(import.meta.url));
+const OK_ROOT = join(SCRIPTS, '..', '..');
+const GUARD = '.github/scripts/shipped-fix-containment.mjs';
+const workflow = (name) => parse(readFileSync(join(OK_ROOT, '.github', 'workflows', name), 'utf8'));
+const stepsOf = (file, job) => {
+ const steps = workflow(file).jobs?.[job]?.steps;
+ if (!Array.isArray(steps) || steps.length < 3) {
+ throw new Error(`${file} job ${job} has no step list to inspect`);
+ }
+ return steps;
+};
+const guardSteps = (steps) => steps.filter((step) => String(step.run ?? '').includes(GUARD));
+const indexWhere = (steps, predicate, what) => {
+ const index = steps.findIndex(predicate);
+ if (index === -1) throw new Error(`no step ${what}`);
+ return index;
+};
+
+const scratch = [];
+afterAll(() => {
+ while (scratch.length > 0) rmSync(scratch.pop(), { recursive: true, force: true });
+});
+
+describe('promotion: promote-stable refuses before it tags', () => {
+ const steps = stepsOf('promote-stable.yml', 'promote');
+ const [guard] = guardSteps(steps);
+
+ test('the promote job runs the guard on the beta it computed the version for', () => {
+ expect(guardSteps(steps)).toHaveLength(1);
+ expect(guard.run).toContain('--candidate "$BETA_SHA"');
+ expect(guard.env).toMatchObject({
+ GH_TOKEN: '${{ steps.app-token.outputs.token }}',
+ BETA_SHA: '${{ steps.ver.outputs.beta_sha }}',
+ });
+ expect(guard['continue-on-error']).toBeUndefined();
+ });
+
+ test('it runs whenever the promotion would tag, after the version is computed', () => {
+ const compute = indexWhere(steps, (step) => step.id === 'ver', 'with id ver');
+ const tag = indexWhere(steps, (step) => step.name === 'Tag stable at beta SHA', 'that tags');
+ const index = steps.indexOf(guard);
+ expect(index).toBeGreaterThan(compute);
+ expect(index).toBeLessThan(tag);
+ expect(guard.if).toBe(steps[tag].if);
+ expect(guard.if).toBe("steps.ver.outputs.skip != 'true'");
+ const mutating = steps.filter((step) =>
+ /git tag "|push origin|gh release (create|edit) |\/dispatches/.test(String(step.run ?? '')),
+ );
+ expect(mutating.length).toBeGreaterThanOrEqual(3);
+ for (const step of mutating) expect(steps.indexOf(step)).toBeGreaterThan(index);
+ });
+});
+
+describe('point releases: the planner holds the guards', () => {
+ const steps = stepsOf('point-release.yml', 'point-release');
+
+ test('the release job runs the planner with a token that can list Releases', () => {
+ const plan = steps.find((step) => step.id === 'plan');
+ expect(plan.run).toBe('node .github/scripts/point-release-plan.mjs');
+ expect(plan.env.GH_TOKEN).toBe('${{ steps.app-token.outputs.token }}');
+ expect(plan['continue-on-error']).toBeUndefined();
+ });
+});
+
+describe('direct recovery: desktop-release refuses a stable in prepare', () => {
+ const release = workflow('desktop-release.yml');
+ const steps = stepsOf('desktop-release.yml', 'prepare');
+ const [guard] = guardSteps(steps);
+
+ test('prepare runs the guard for the stable channel only, against the release tag', () => {
+ expect(guardSteps(steps)).toHaveLength(1);
+ expect(guard.if).toBe("steps.channel.outputs.channel == 'latest'");
+ expect(guard.run).toContain('--candidate "refs/tags/${RELEASE_TAG}"');
+ expect(guard.env.RELEASE_TAG).toBe(
+ '${{ github.event.client_payload.release_tag || inputs.release_tag }}',
+ );
+ expect(guard.env.GH_TOKEN).toContain('github.token');
+ expect(guard['continue-on-error']).toBeUndefined();
+ const channel = indexWhere(steps, (step) => step.id === 'channel', 'with id channel');
+ expect(steps.indexOf(guard)).toBeGreaterThan(channel);
+ });
+
+ test('the guard comes from the workflow revision, not from the tag being rebuilt', () => {
+ expect(guard.run).toMatch(
+ /git archive "\$GITHUB_SHA" [^\n]*\.github\/scripts\/shipped-fix-containment\.mjs/,
+ );
+ expect(guard.run).toMatch(/node "\$guard\/\.github\/scripts\/shipped-fix-containment\.mjs"/);
+ });
+
+ test('the archive carries every module the guard imports', () => {
+ const archived = /git archive "\$GITHUB_SHA" ([^|]+)\|/.exec(guard.run)[1].trim().split(/\s+/);
+ const pending = [GUARD];
+ const needed = new Set();
+ while (pending.length > 0) {
+ const file = pending.pop();
+ if (needed.has(file)) continue;
+ needed.add(file);
+ const source = readFileSync(join(OK_ROOT, file), 'utf8');
+ for (const [, specifier] of source.matchAll(/^import [^;]*? from '(\.{1,2}\/[^']+)';$/gms)) {
+ pending.push(posix.normalize(posix.join(posix.dirname(file), specifier)));
+ }
+ }
+ expect([...needed].sort()).toEqual([...archived].sort());
+ });
+
+ test('publication needs prepare to have succeeded', () => {
+ const publish = release.jobs['publish-assets'];
+ const finalize = release.jobs.finalize;
+ expect(publish.needs).toContain('prepare');
+ expect(publish.if).toContain("needs.prepare.result == 'success'");
+ expect(finalize.needs).toEqual(expect.arrayContaining(['prepare', 'publish-assets']));
+ expect(finalize.if).toContain("needs.publish-assets.result == 'success'");
+ expect(release.jobs['release-consumers'].needs).toBe('finalize');
+ });
+
+ test('the archived guard runs on its own against a tag checkout that predates it', () => {
+ const root = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-archive-')));
+ scratch.push(root);
+ const git = (...args) =>
+ execFileSync(
+ 'git',
+ [
+ '-c',
+ 'user.name=t',
+ '-c',
+ '-c',
+ 'commit.gpgsign=false',
+ ...args,
+ ],
+ { cwd: join(root, 'checkout'), env: gitCleanEnv(), encoding: 'utf8' },
+ ).trim();
+ mkdirSync(join(root, 'checkout'));
+ git('init', '-q', '-b', 'main');
+ writeFileSync(join(root, 'checkout', 'notes.txt'), 'first\n');
+ git('add', '-A');
+ git('commit', '-q', '-m', 'Initial (#1)');
+ git('tag', 'v1.0.0');
+ writeFileSync(join(root, 'checkout', 'notes.txt'), 'second\n');
+ git('commit', '-q', '-am', 'Second (#2)');
+ git('tag', 'v1.0.1');
+ const guardDir = join(root, 'guard');
+ for (const file of [GUARD, 'scripts/git-clean-env.mjs']) {
+ mkdirSync(dirname(join(guardDir, file)), { recursive: true });
+ writeFileSync(join(guardDir, file), readFileSync(join(OK_ROOT, file)));
+ }
+ const listing = join(root, 'releases.json');
+ writeFileSync(
+ listing,
+ JSON.stringify([
+ { tag_name: 'v1.0.0', draft: false, body: '' },
+ { tag_name: 'v1.0.1', draft: false, body: '' },
+ ]),
+ );
+ const run = (candidate) =>
+ spawnSync(
+ process.execPath,
+ [join(guardDir, GUARD), '--candidate', candidate, '--releases', listing],
+ { cwd: join(root, 'checkout'), encoding: 'utf8', env: gitCleanEnv() },
+ );
+ const admitted = run('refs/tags/v1.0.1');
+ expect(admitted.status, admitted.stderr).toBe(0);
+ const refused = run('refs/tags/v1.0.0');
+ expect(refused.status).toBe(2);
+ expect(refused.stdout).toContain(
+ '::error::refs/tags/v1.0.0 lacks 1 fix that a published stable already shipped: #2 (v1.0.1).',
+ );
+ });
+});
+
+describe('direct recovery and re-runs: desktop-release checks again right before it publishes', () => {
+ const release = workflow('desktop-release.yml');
+ const steps = stepsOf('desktop-release.yml', 'finalize');
+ const [guard] = guardSteps(steps);
+
+ test('finalize runs the guard on the stable channel, from a checkout of the workflow revision with every tag', () => {
+ expect(guardSteps(steps)).toHaveLength(1);
+ expect(guard.if).toBe("success() && needs.prepare.outputs.channel == 'latest'");
+ expect(guard.run).toContain('node .github/scripts/shipped-fix-containment.mjs "${args[@]}"');
+ expect(guard.run).toContain('--candidate "refs/tags/${RELEASE_TAG}"');
+ expect(guard.env.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
+ expect(guard['continue-on-error']).toBeUndefined();
+ expect(release.jobs.finalize.env.RELEASE_TAG).toBe(
+ '${{ github.event.client_payload.release_tag || inputs.release_tag }}',
+ );
+ const checkout = steps.filter((step) => step.uses?.startsWith('actions/checkout@'));
+ expect(checkout).toHaveLength(1);
+ expect(checkout[0].with?.['fetch-depth']).toBe(0);
+ expect(checkout[0].with?.ref).toBeUndefined();
+ expect(steps.indexOf(checkout[0])).toBeLessThan(steps.indexOf(guard));
+ });
+
+ test('it is the step right before the draft flip, ahead of every step that publishes, dispatches or announces', () => {
+ const publish = indexWhere(steps, (step) => step.id === 'publish', 'that publishes the draft');
+ expect(steps[publish].run).toContain('gh release edit "$RELEASE_TAG" --draft=false');
+ expect(steps.indexOf(guard)).toBe(publish - 1);
+ const shipping = steps.filter((step) =>
+ /--draft=false|\/dispatches|curl /.test(String(step.run ?? '')),
+ );
+ expect(shipping.map((step) => step.name)).toEqual(
+ expect.arrayContaining([
+ 'Promote draft release to published',
+ 'Trigger release.yml to publish stable to npm',
+ 'Announce stable release to Slack',
+ 'Announce stable release to Discord',
+ ]),
+ );
+ for (const step of shipping) expect(steps.indexOf(step)).toBeGreaterThan(steps.indexOf(guard));
+ });
+});
+
+describe('an asset repair of an already published stable is the one run the guard lets through', () => {
+ const prepareGuard = guardSteps(stepsOf('desktop-release.yml', 'prepare'))[0];
+ const finalizeGuard = guardSteps(stepsOf('desktop-release.yml', 'finalize'))[0];
+ const runStep = (step, event, nodeExit = 0) => {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-step-')));
+ scratch.push(dir);
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ const argv = join(dir, 'node-argv');
+ writeFileSync(
+ join(bin, 'node'),
+ `#!/bin/sh\nprintf '%s\\n' "$@" > "${argv}"\nexit ${nodeExit}\n`,
+ {
+ mode: 0o755,
+ },
+ );
+ writeFileSync(join(bin, 'git'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
+ writeFileSync(join(bin, 'tar'), '#!/bin/sh\ncat > /dev/null\nexit 0\n', { mode: 0o755 });
+ const script = join(dir, 'step.sh');
+ writeFileSync(script, step.run);
+ const res = spawnSync('bash', ['--noprofile', '--norc', '-eo', 'pipefail', script], {
+ cwd: dir,
+ encoding: 'utf8',
+ env: {
+ PATH: `${bin}${delimiter}${process.env.PATH}`,
+ GITHUB_EVENT_NAME: event,
+ GITHUB_SHA: 'f'.repeat(40),
+ RUNNER_TEMP: dir,
+ RELEASE_TAG: 'v9.9.9',
+ },
+ });
+ let args = [];
+ try {
+ args = readFileSync(argv, 'utf8').split('\n').filter(Boolean);
+ } catch {
+ args = [];
+ }
+ return { status: res.status, stderr: res.stderr, args: args.slice(1) };
+ };
+
+ test.each([
+ ['prepare', prepareGuard],
+ ['finalize', finalizeGuard],
+ ])('%s passes the exemption on workflow_dispatch and on no other event', (_job, step) => {
+ const checked = ['--candidate', 'refs/tags/v9.9.9', '--label', 'v9.9.9'];
+ const dispatched = runStep(step, 'repository_dispatch');
+ expect(dispatched.status, dispatched.stderr).toBe(0);
+ expect(dispatched.args).toEqual(checked);
+ const manual = runStep(step, 'workflow_dispatch');
+ expect(manual.status, manual.stderr).toBe(0);
+ expect(manual.args).toEqual([...checked, '--allow-published-repair', 'v9.9.9']);
+ });
+
+ test.each([
+ ['prepare', prepareGuard],
+ ['finalize', finalizeGuard],
+ ])('%s fails when the guard refuses or cannot decide', (_job, step) => {
+ expect(runStep(step, 'repository_dispatch', 2).status).toBe(2);
+ expect(runStep(step, 'workflow_dispatch', 1).status).toBe(1);
+ });
+});
+
+describe('the selector does not dispatch what promote-stable would refuse', () => {
+ const steps = stepsOf('select-beta-to-promote.yml', 'evaluate');
+
+ test('the select step knows whether this tick may dispatch, and can list Releases', () => {
+ const hours = indexWhere(steps, (step) => step.id === 'hours', 'with id hours');
+ const select = indexWhere(steps, (step) => step.id === 'select', 'with id select');
+ expect(select).toBeGreaterThan(hours);
+ expect(steps[select].run).toBe('node .github/scripts/select-beta-to-promote.mjs');
+ expect(steps[select].env).toMatchObject({
+ DISPATCH_WINDOW_OPEN: '${{ steps.hours.outputs.open }}',
+ GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}',
+ });
+ });
+
+ test('both dispatch paths read only the screened outputs', () => {
+ const dispatch = steps.find((step) =>
+ String(step.run ?? '').includes('gh workflow run promote-stable.yml'),
+ );
+ expect(dispatch.if).toContain("steps.select.outputs.target != ''");
+ expect(dispatch.env.TARGET).toBe('${{ steps.select.outputs.target }}');
+ const nominate = steps.find((step) => step.id === 'nominate');
+ expect(nominate.env.CANDIDATE).toBe('${{ steps.select.outputs.fast_tier_candidate }}');
+ });
+});
+
+describe('the bug lane does not hand over a batch a point release would refuse', () => {
+ const steps = stepsOf('bug-lane.yml', 'bug-lane');
+
+ test('the evaluator can list Releases and gates the handoff on its fix_refs output', () => {
+ const evaluate = steps.find((step) => step.id === 'evaluate');
+ expect(evaluate.run).toBe('node .github/scripts/bug-lane.mjs');
+ expect(evaluate.env.GH_TOKEN).toBe('${{ secrets.GITHUB_TOKEN }}');
+ const handoff = steps.find((step) =>
+ String(step.run ?? '').includes('gh workflow run bug-lane-verify.yml'),
+ );
+ expect(handoff.if).toContain("steps.evaluate.outputs.fix_refs != ''");
+ });
+});
diff --git a/.github/scripts/shipped-fix-containment.mjs b/.github/scripts/shipped-fix-containment.mjs
new file mode 100644
index 000000000..409fce65b
--- /dev/null
+++ b/.github/scripts/shipped-fix-containment.mjs
@@ -0,0 +1,597 @@
+/* biome-ignore-all lint/suspicious/noUndeclaredEnvVars: GitHub Actions invokes this entrypoint directly, outside Turbo. */
+import { spawnSync } from 'node:child_process';
+import { appendFileSync, readFileSync } from 'node:fs';
+import { pathToFileURL } from 'node:url';
+import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
+
+export const STABLE_TAG_RE = /^v(\d+)\.(\d+)\.(\d+)$/;
+const TERMINAL_PR_RE = /\(#(\d+)\)\s*$/;
+const FULL_SHA_RE = /\b[0-9a-f]{40}\b/g;
+const APPLIED_LINE_RE = /^Applied:(.*)$/gm;
+const CHERRY_LINE_RE = /^([+-]) ([0-9a-f]{40})$/;
+const ANNOTATION_LIMIT = 10;
+const DEFAULT_REPO = 'inkeep/open-knowledge';
+
+export const REFUSED_EXIT = 2;
+
+export const COVERAGE = Object.freeze({
+ PROVENANCE: 'provenance',
+ PR_NUMBER: 'pr-number',
+});
+
+function stableVersion(tag) {
+ const match = STABLE_TAG_RE.exec(tag);
+ if (!match) throw new Error(`${tag} is not a vX.Y.Z stable tag`);
+ return match.slice(1).map(Number);
+}
+
+export function compareStableTags(a, b) {
+ const left = stableVersion(a);
+ const right = stableVersion(b);
+ for (let i = 0; i < 3; i += 1) {
+ if (left[i] !== right[i]) return left[i] - right[i];
+ }
+ return 0;
+}
+
+export function publishedStableReleases(releases) {
+ if (!Array.isArray(releases)) throw new Error('the release listing is not an array');
+ const published = new Map();
+ for (const release of releases) {
+ if (typeof release?.tag_name !== 'string' || typeof release?.draft !== 'boolean') {
+ throw new Error(
+ `the release listing holds an entry without a tag name and a draft flag: ${JSON.stringify(release).slice(0, 200)}`,
+ );
+ }
+ if (release.draft || !STABLE_TAG_RE.test(release.tag_name)) continue;
+ published.set(release.tag_name, {
+ tag: release.tag_name,
+ body: typeof release.body === 'string' ? release.body : '',
+ });
+ }
+ return [...published.values()].sort((a, b) => compareStableTags(a.tag, b.tag));
+}
+
+export function parseReleaseListing(text) {
+ const trimmed = String(text ?? '').trim();
+ if (trimmed === '') return [];
+ if (trimmed.startsWith('[')) return JSON.parse(trimmed).flat();
+ return trimmed
+ .split('\n')
+ .filter((line) => line.trim() !== '')
+ .map((line) => JSON.parse(line));
+}
+
+export function appliedOrigins(body) {
+ const origins = [];
+ for (const [, rest] of String(body ?? '').matchAll(APPLIED_LINE_RE)) {
+ for (const [sha] of rest.matchAll(FULL_SHA_RE)) {
+ if (!origins.includes(sha)) origins.push(sha);
+ }
+ }
+ return origins;
+}
+
+export function terminalPrNumber(subject) {
+ return TERMINAL_PR_RE.exec(String(subject ?? ''))?.[1] ?? null;
+}
+
+export function gitRepo(cwd = process.cwd()) {
+ const run = (args, input) => {
+ const res = spawnSync('git', args, {
+ cwd,
+ env: gitCleanEnv(),
+ encoding: 'utf8',
+ input,
+ maxBuffer: 512 * 1024 * 1024,
+ });
+ if (res.error) throw new Error(`git ${args[0]} could not run: ${res.error.message}`);
+ return res;
+ };
+ const failed = (args, res) =>
+ new Error(
+ `git ${args.join(' ')} failed (exit ${res.status ?? res.signal}): ${String(res.stderr || '').trim()}`,
+ );
+ const read = (args, input) => {
+ const res = run(args, input);
+ if (res.status !== 0) throw failed(args, res);
+ return res.stdout;
+ };
+ const lines = (text) =>
+ text
+ .split('\n')
+ .map((line) => line.trim())
+ .filter((line) => line !== '');
+
+ return {
+ resolveCommit(ref) {
+ const args = ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`];
+ const res = run(args);
+ if (res.status === 0) return res.stdout.trim();
+ if (res.status !== 1) throw failed(args, res);
+ const detail = String(res.stderr || '').trim();
+ throw new Error(
+ `${ref} does not resolve to a commit in this checkout${detail === '' ? '' : `: ${detail}`}`,
+ );
+ },
+ stableTags() {
+ return new Set(
+ lines(read(['for-each-ref', '--format=%(refname:strip=2)', 'refs/tags/'])).filter((tag) =>
+ STABLE_TAG_RE.test(tag),
+ ),
+ );
+ },
+ tagsMergedInto(sha) {
+ return new Set(lines(read(['tag', '--list', '--merged', sha])));
+ },
+ history(sha) {
+ const shas = new Set();
+ const prNumbers = new Set();
+ for (const line of read(['log', '--format=%H %s', sha]).split('\n')) {
+ if (line === '') continue;
+ const space = line.indexOf(' ');
+ shas.add(space === -1 ? line : line.slice(0, space));
+ const pr = space === -1 ? null : terminalPrNumber(line.slice(space + 1));
+ if (pr !== null) prNumbers.add(pr);
+ }
+ return { shas, prNumbers };
+ },
+ cherry(upstream, head) {
+ return lines(read(['cherry', upstream, head])).map((line) => {
+ const match = CHERRY_LINE_RE.exec(line);
+ if (!match)
+ throw new Error(`git cherry ${upstream} ${head} printed an unreadable line: ${line}`);
+ return { mark: match[1], sha: match[2] };
+ });
+ },
+ commits(shas) {
+ const wanted = [...new Set(shas)];
+ const found = new Map();
+ if (wanted.length === 0) return found;
+ const present = lines(
+ read(['cat-file', '--batch-check=%(objectname) %(objecttype)'], `${wanted.join('\n')}\n`),
+ )
+ .map((line) => line.split(' '))
+ .filter(([, type]) => type === 'commit')
+ .map(([sha]) => sha);
+ if (present.length === 0) return found;
+ const output = read([
+ 'log',
+ '--no-walk=unsorted',
+ '-z',
+ '--date=raw',
+ '--format=%H%n%an%n%ae%n%ad%n%B',
+ ...present,
+ ]);
+ for (const record of output.split('\0')) {
+ const fields = record.replace(/^\n+/, '').split('\n');
+ if (fields.length < 5 || !/^[0-9a-f]{40}$/.test(fields[0])) continue;
+ const [sha, name, email, date, ...message] = fields;
+ const text = message.join('\n').trimEnd();
+ found.set(sha, {
+ subject: message[0] ?? '',
+ identity: [name, email, date, text].join('\n'),
+ });
+ }
+ return found;
+ },
+ };
+}
+
+export function evaluateShippedFixContainment({ candidate, published, git }) {
+ const candidateSha = git.resolveCommit(candidate);
+ const localTags = git.stableTags();
+ const untagged = published.filter((release) => !localTags.has(release.tag)).map((r) => r.tag);
+ if (untagged.length > 0) {
+ throw new Error(
+ `published stable Release(s) with no tag in this checkout: ${untagged.join(', ')}. ` +
+ 'Fetch every tag with full history (fetch-depth: 0) and run the check again.',
+ );
+ }
+
+ const contained = git.tagsMergedInto(candidateSha);
+ const unmerged = published.filter((release) => !contained.has(release.tag));
+ const entries = new Map();
+ let records = 0;
+ let plusRecords = 0;
+ for (const release of unmerged) {
+ for (const { mark, sha } of git.cherry(candidateSha, `refs/tags/${release.tag}`)) {
+ records += 1;
+ let entry = entries.get(sha);
+ if (!entry) {
+ entry = { sha, patchEquivalent: false, stables: [] };
+ entries.set(sha, entry);
+ }
+ if (mark === '-') {
+ entry.patchEquivalent = true;
+ } else {
+ plusRecords += 1;
+ entry.stables.push(release);
+ }
+ }
+ }
+
+ const plusCommits = [...entries.values()].filter((entry) => entry.stables.length > 0).length;
+ const pending = [...entries.values()].filter((entry) => !entry.patchEquivalent);
+ const commits = [];
+ if (pending.length > 0) {
+ const history = git.history(candidateSha);
+ const originsOf = (entry) => [
+ ...new Set(entry.stables.flatMap((release) => appliedOrigins(release.body))),
+ ];
+ const info = git.commits([...pending.map((e) => e.sha), ...pending.flatMap(originsOf)]);
+ for (const entry of pending) {
+ const self = info.get(entry.sha);
+ if (!self) throw new Error(`could not read commit ${entry.sha}, which git cherry listed`);
+ const pr = terminalPrNumber(self.subject);
+ const origin = originsOf(entry).find(
+ (sha) => info.get(sha)?.identity === self.identity && history.shas.has(sha),
+ );
+ let coverage = null;
+ if (origin) coverage = COVERAGE.PROVENANCE;
+ else if (pr !== null && history.prNumbers.has(pr)) coverage = COVERAGE.PR_NUMBER;
+ commits.push({
+ sha: entry.sha,
+ subject: self.subject,
+ pr,
+ origin: origin ?? null,
+ coverage,
+ stables: entry.stables.map((release) => release.tag).sort(compareStableTags),
+ });
+ }
+ }
+
+ const uncovered = commits
+ .filter((commit) => commit.coverage === null)
+ .sort((a, b) => compareStableTags(a.stables[0], b.stables[0]) || a.sha.localeCompare(b.sha));
+ const count = (coverage) => commits.filter((commit) => commit.coverage === coverage).length;
+ return {
+ ok: uncovered.length === 0,
+ candidate,
+ candidateSha,
+ published: published.length,
+ checked: unmerged.map((release) => release.tag),
+ records,
+ plusRecords,
+ plusCommits,
+ coveredByProvenance: count(COVERAGE.PROVENANCE),
+ coveredByPrNumber: count(COVERAGE.PR_NUMBER),
+ commits,
+ uncovered,
+ };
+}
+
+const shortSha = (sha) => sha.slice(0, 12);
+const prLabel = (commit) => (commit.pr === null ? 'no PR number' : `PR #${commit.pr}`);
+const plural = (count, one, many) => `${count} ${count === 1 ? one : many}`;
+const shippedIn = (commit) =>
+ commit.stables.length === 1
+ ? commit.stables[0]
+ : `${commit.stables[0]} and ${plural(commit.stables.length - 1, 'later stable', 'later stables')}`;
+
+export function refusalHeadline(verdict, label = verdict.candidate) {
+ const listed = verdict.uncovered
+ .slice(0, ANNOTATION_LIMIT)
+ .map(
+ (commit) =>
+ `${commit.pr === null ? shortSha(commit.sha) : `#${commit.pr}`} (${shippedIn(commit)})`,
+ )
+ .join(', ');
+ const more =
+ verdict.uncovered.length > ANNOTATION_LIMIT
+ ? ` and ${verdict.uncovered.length - ANNOTATION_LIMIT} more`
+ : '';
+ return `${label} lacks ${plural(verdict.uncovered.length, 'fix', 'fixes')} that a published stable already shipped: ${listed}${more}.`;
+}
+
+export function describeVerdict(verdict, label = verdict.candidate) {
+ const where = `${label} (${shortSha(verdict.candidateSha)})`;
+ const tally =
+ `Checked ${plural(verdict.published, 'published stable Release', 'published stable Releases')}, ` +
+ `${verdict.checked.length} of them not ancestors of it: ${plural(verdict.records, 'commit record', 'commit records')}, ` +
+ `${plural(verdict.plusCommits, 'commit', 'commits')} that git cherry marks +, ` +
+ `${verdict.coveredByProvenance} matched to the origin a Release recorded as Applied, ` +
+ `${verdict.coveredByPrNumber} matched by terminal PR number.`;
+ if (verdict.ok) {
+ return [`${where} contains every fix the published stables shipped. ${tally}`];
+ }
+ return [
+ `${where} lacks ${plural(verdict.uncovered.length, 'fix', 'fixes')} that published stables already shipped. ${tally}`,
+ ...verdict.uncovered.map(
+ (commit) =>
+ ` ${shortSha(commit.sha)} ${commit.subject} [${prLabel(commit)}; shipped in ${commit.stables.join(', ')}]`,
+ ),
+ 'A stable must contain every commit a published stable shipped: the same patch, the origin the ' +
+ "point release's notes record as Applied, or a commit with the same terminal PR number. Release " +
+ 'from a commit that contains these, or ship them together with it.',
+ ];
+}
+
+export function summaryMarkdown(verdict, label = verdict.candidate) {
+ if (verdict.ok) {
+ return `### Shipped-fix containment: ${label} contains every published fix\n\n${describeVerdict(verdict, label)[0]}\n`;
+ }
+ const escapePipes = (text) => text.replaceAll('|', '\\|');
+ return [
+ `### Shipped-fix containment: ${label} refused`,
+ '',
+ refusalHeadline(verdict, label),
+ '',
+ '| Commit | Subject | PR | Shipped in |',
+ '| --- | --- | --- | --- |',
+ ...verdict.uncovered.map(
+ (commit) =>
+ `| \`${shortSha(commit.sha)}\` | ${escapePipes(commit.subject)} | ${commit.pr === null ? 'none' : `#${commit.pr}`} | ${commit.stables.join(', ')} |`,
+ ),
+ '',
+ ].join('\n');
+}
+
+export function unpublishedBaseReason({ latestStableTag, publishedTags }) {
+ if (publishedTags.includes(latestStableTag)) return null;
+ const newestPublished = [...publishedTags].sort(compareStableTags).at(-1);
+ return (
+ `The newest stable tag ${latestStableTag} has no published Release (the newest published stable is ` +
+ `${newestPublished ?? 'none'}). A point release adds fixes to the stable users already have, and its ` +
+ `version follows the newest tag, so it cannot be built over ${latestStableTag}. Publish ${latestStableTag} ` +
+ 'if its release build can still pass, or let a newer stable supersede it, then run again. A tag the ' +
+ 'shipped-fix check refused never passes it.'
+ );
+}
+
+export function fetchReleaseListing(repo) {
+ const res = spawnSync(
+ 'gh',
+ [
+ 'api',
+ '-X',
+ 'GET',
+ `repos/${repo}/releases?per_page=100`,
+ '--paginate',
+ '--jq',
+ '.[] | select(.tag_name | test("^v[0-9]+[.][0-9]+[.][0-9]+$")) | {tag_name, draft, body}',
+ ],
+ { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024, timeout: 300_000 },
+ );
+ if (res.error || res.status !== 0) {
+ throw new Error(
+ `listing the releases of ${repo} failed: ${res.error?.message ?? String(res.stderr || res.stdout || '').trim()}`,
+ );
+ }
+ return parseReleaseListing(res.stdout);
+}
+
+export function createShippedFixCheck({
+ cwd = process.cwd(),
+ repo = process.env.GITHUB_REPOSITORY || DEFAULT_REPO,
+ listReleases = () => fetchReleaseListing(repo),
+ git = gitRepo(cwd),
+} = {}) {
+ let published;
+ const load = () => {
+ if (published === undefined) {
+ const listing = listReleases();
+ const stableEntries = listing.filter((release) =>
+ STABLE_TAG_RE.test(release?.tag_name ?? ''),
+ );
+ if (stableEntries.length === 0 && git.stableTags().size > 0) {
+ throw new Error(
+ `the release listing for ${repo} holds no stable Release although this checkout has stable tags; ` +
+ 'refusing to read that as nothing shipped.',
+ );
+ }
+ published = publishedStableReleases(listing);
+ }
+ return published;
+ };
+ return {
+ publishedStableTags: () => load().map((release) => release.tag),
+ resolveCommit: (ref) => git.resolveCommit(ref),
+ evaluate: (candidate) => evaluateShippedFixContainment({ candidate, published: load(), git }),
+ };
+}
+
+export function publishedRepairExemption({ candidate, tag, check }) {
+ if (!STABLE_TAG_RE.test(tag)) {
+ throw new Error(
+ `--allow-published-repair takes a vX.Y.Z stable tag, not ${JSON.stringify(tag)}`,
+ );
+ }
+ const tagSha = check.resolveCommit(`refs/tags/${tag}`);
+ const candidateSha = check.resolveCommit(candidate);
+ if (tagSha !== candidateSha) {
+ throw new Error(
+ `--allow-published-repair names ${tag} (${shortSha(tagSha)}), but the candidate ${candidate} is ` +
+ `${shortSha(candidateSha)}; the exemption covers only the tag being checked`,
+ );
+ }
+ return check.publishedStableTags().includes(tag);
+}
+
+function splitList(raw) {
+ return String(raw ?? '')
+ .split(/[\s,]+/)
+ .map((item) => item.trim())
+ .filter((item) => item !== '');
+}
+
+const VALUE_FLAGS = new Set([
+ '--candidate',
+ '--label',
+ '--allow-published-repair',
+ '--matrix',
+ '--expect-refuse',
+ '--expect-admit',
+ '--releases',
+ '--repo',
+ '-C',
+]);
+
+export function parseArgs(argv) {
+ const options = {};
+ for (let i = 0; i < argv.length; i += 1) {
+ const flag = argv[i];
+ if (!VALUE_FLAGS.has(flag)) throw new Error(`unrecognized argument: ${flag}`);
+ const value = argv[i + 1];
+ if (value === undefined || VALUE_FLAGS.has(value)) throw new Error(`${flag} needs a value`);
+ if (flag in options) throw new Error(`${flag} was given twice`);
+ options[flag] = value;
+ i += 1;
+ }
+ if ('--candidate' in options === '--matrix' in options) {
+ throw new Error('give exactly one of --candidate <ref> or --matrix <refs>');
+ }
+ if ('--allow-published-repair' in options && !('--candidate' in options)) {
+ throw new Error('--allow-published-repair goes with --candidate, not --matrix');
+ }
+ return {
+ candidate: options['--candidate'] ?? null,
+ label: options['--label'] ?? null,
+ allowPublishedRepair: options['--allow-published-repair'] ?? null,
+ matrix: '--matrix' in options ? splitList(options['--matrix']) : null,
+ expectRefuse: splitList(options['--expect-refuse']),
+ expectAdmit: splitList(options['--expect-admit']),
+ releases: options['--releases'] ?? null,
+ repo: options['--repo'] ?? null,
+ cwd: options['-C'] ?? null,
+ };
+}
+
+export function runMatrix({ candidates, expectRefuse = [], expectAdmit = [], check }) {
+ const rows = candidates.map((candidate) => ({ candidate, verdict: check.evaluate(candidate) }));
+ const mismatches = rows.flatMap(({ candidate, verdict }) => {
+ if (expectRefuse.includes(candidate) && verdict.ok)
+ return [`${candidate}: admitted, expected a refusal`];
+ if (expectAdmit.includes(candidate) && !verdict.ok)
+ return [`${candidate}: refused, expected admission`];
+ return [];
+ });
+ const unknown = [...expectRefuse, ...expectAdmit].filter((ref) => !candidates.includes(ref));
+ for (const ref of unknown)
+ mismatches.push(`${ref}: expected a verdict but it is not in --matrix`);
+ const totals = rows.reduce(
+ (sum, { verdict }) => ({
+ pairs: sum.pairs + verdict.checked.length,
+ records: sum.records + verdict.records,
+ plusRecords: sum.plusRecords + verdict.plusRecords,
+ }),
+ { pairs: 0, records: 0, plusRecords: 0 },
+ );
+ return { rows, mismatches, totals };
+}
+
+function matrixReport({ rows, mismatches, totals }) {
+ const published = rows[0]?.verdict.published ?? 0;
+ const out = [
+ '| Candidate | Commit | Non-ancestor stables | Cherry records | Raw + records | + commits | By provenance | By PR number | Uncovered | Verdict |',
+ '| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- |',
+ ...rows.map(
+ ({ candidate, verdict }) =>
+ `| ${candidate} | ${shortSha(verdict.candidateSha)} | ${verdict.checked.length} | ${verdict.records} | ` +
+ `${verdict.plusRecords} | ${verdict.plusCommits} | ${verdict.coveredByProvenance} | ` +
+ `${verdict.coveredByPrNumber} | ${verdict.uncovered.length} | ${verdict.ok ? 'ADMIT' : 'REFUSE'} |`,
+ ),
+ '',
+ `Published stable Releases: ${published}. Candidates: ${rows.length}. git cherry pairs: ${totals.pairs}. ` +
+ `Commit records: ${totals.records}, of which ${totals.plusRecords} raw + records.`,
+ ];
+ for (const { candidate, verdict } of rows) {
+ if (verdict.ok) continue;
+ out.push('', `${candidate} uncovered:`);
+ for (const commit of verdict.uncovered) {
+ out.push(
+ ` ${shortSha(commit.sha)} ${commit.subject} [${prLabel(commit)}; shipped in ${commit.stables.join(', ')}]`,
+ );
+ }
+ }
+ out.push(
+ '',
+ mismatches.length === 0
+ ? 'Expected verdicts: all matched.'
+ : `Expected verdicts: ${mismatches.length} mismatch(es):\n${mismatches.map((m) => ` ${m}`).join('\n')}`,
+ );
+ return out.join('\n');
+}
+
+function main() {
+ let options;
+ try {
+ options = parseArgs(process.argv.slice(2));
+ } catch (err) {
+ console.error(
+ `::error::shipped-fix-containment: ${err.message}. Usage: --candidate <ref> [--label <name>] ` +
+ '[--allow-published-repair <tag>] | --matrix <refs> [--expect-refuse <refs>] [--expect-admit <refs>]; ' +
+ 'with optional --releases <file>, --repo <owner/name>, -C <git dir>.',
+ );
+ process.exit(1);
+ }
+
+ let check;
+ let verdict;
+ let matrix;
+ let repairOnly = false;
+ try {
+ check = createShippedFixCheck({
+ cwd: options.cwd ?? process.cwd(),
+ ...(options.repo ? { repo: options.repo } : {}),
+ ...(options.releases
+ ? { listReleases: () => parseReleaseListing(readFileSync(options.releases, 'utf8')) }
+ : {}),
+ });
+ if (options.matrix) {
+ matrix = runMatrix({
+ candidates: options.matrix,
+ expectRefuse: options.expectRefuse,
+ expectAdmit: options.expectAdmit,
+ check,
+ });
+ } else {
+ repairOnly =
+ options.allowPublishedRepair !== null &&
+ publishedRepairExemption({
+ candidate: options.candidate,
+ tag: options.allowPublishedRepair,
+ check,
+ });
+ if (!repairOnly) verdict = check.evaluate(options.candidate);
+ }
+ } catch (err) {
+ console.error(`::error::shipped-fix-containment could not decide: ${err.message}`);
+ process.exit(1);
+ }
+
+ if (matrix) {
+ console.log(matrixReport(matrix));
+ process.exit(matrix.mismatches.length === 0 ? 0 : 1);
+ }
+
+ if (repairOnly) {
+ const tag = options.allowPublishedRepair;
+ console.log(
+ `::notice::${tag} already has a published Release; this repair may update assets and release metadata ` +
+ 'and dispatch desktop-release-published to release consumers for reconciliation, without explicitly requesting Latest or dispatching npm ' +
+ 'publication. The shipped-fix check is skipped for this published-tag repair.',
+ );
+ if (process.env.GITHUB_STEP_SUMMARY) {
+ appendFileSync(
+ process.env.GITHUB_STEP_SUMMARY,
+ `### Shipped-fix containment: ${tag} not checked\n\n${tag} is already published; this repair may update assets and release metadata and dispatch desktop-release-published to release consumers for reconciliation, without explicitly requesting Latest or dispatching npm publication.\n`,
+ );
+ }
+ return;
+ }
+
+ const label = options.label ?? options.candidate;
+ for (const line of describeVerdict(verdict, label)) console.log(line);
+ if (process.env.GITHUB_STEP_SUMMARY) {
+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, summaryMarkdown(verdict, label));
+ }
+ if (!verdict.ok) {
+ console.log(`::error::${refusalHeadline(verdict, label)}`);
+ process.exit(REFUSED_EXIT);
+ }
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ main();
+}
diff --git a/.github/scripts/shipped-fix-containment.test.mjs b/.github/scripts/shipped-fix-containment.test.mjs
new file mode 100644
index 000000000..a40413fc9
--- /dev/null
+++ b/.github/scripts/shipped-fix-containment.test.mjs
@@ -0,0 +1,657 @@
+import { execFileSync, spawnSync } from 'node:child_process';
+import { mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { delimiter, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { afterAll, beforeAll, describe, expect, test } from 'vitest';
+import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
+import {
+ appliedOrigins,
+ COVERAGE,
+ createShippedFixCheck,
+ describeVerdict,
+ evaluateShippedFixContainment,
+ gitRepo,
+ parseArgs,
+ parseReleaseListing,
+ publishedRepairExemption,
+ publishedStableReleases,
+ REFUSED_EXIT,
+ refusalHeadline,
+ runMatrix,
+ summaryMarkdown,
+ terminalPrNumber,
+} from './shipped-fix-containment.mjs';
+
+const SCRIPT = fileURLToPath(new URL('./shipped-fix-containment.mjs', import.meta.url));
+const scratch = [];
+
+afterAll(() => {
+ while (scratch.length > 0) rmSync(scratch.pop(), { recursive: true, force: true });
+});
+
+function makeRepo() {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-')));
+ scratch.push(dir);
+ const git = (args, { env = {}, input } = {}) =>
+ execFileSync(
+ 'git',
+ [
+ '-c',
+ 'user.name=Release Bot',
+ '-c',
+ '-c',
+ 'commit.gpgsign=false',
+ '-c',
+ 'tag.gpgsign=false',
+ ...args,
+ ],
+ { cwd: dir, env: { ...gitCleanEnv(), ...env }, encoding: 'utf8', input, stdio: 'pipe' },
+ ).trim();
+ git(['init', '--quiet', '--initial-branch=main']);
+ const commit = ({
+ files = {},
+ message,
+ author = 'Dev <[email protected]>',
+ date = '1700000000 +0000',
+ }) => {
+ for (const [path, content] of Object.entries(files)) writeFileSync(join(dir, path), content);
+ git(['add', '-A']);
+ const [, name, email] = /^(.*) <(.*)>$/.exec(author);
+ git(['commit', '--quiet', '--allow-empty', '-F', '-'], {
+ input: message,
+ env: {
+ GIT_AUTHOR_NAME: name,
+ GIT_AUTHOR_EMAIL: email,
+ GIT_AUTHOR_DATE: date,
+ GIT_COMMITTER_DATE: date,
+ },
+ });
+ return git(['rev-parse', 'HEAD']);
+ };
+ return { dir, git, commit };
+}
+
+const AUTOSAVE = {
+ message: 'fix: keep autosave working (#11)\n\nBody one.',
+ author: 'Alice <[email protected]>',
+ date: '1700000100 +0000',
+};
+const NOTICE = {
+ author: 'Bob <[email protected]>',
+ date: '1700000200 +0000',
+};
+const IDENTICAL = {
+ message: 'fix: pick that applies byte for byte (#33)',
+ author: 'Carol <[email protected]>',
+ date: '1700000300 +0000',
+};
+
+let fixture;
+
+beforeAll(() => {
+ const repo = makeRepo();
+ const { commit, git } = repo;
+ commit({
+ files: { 'a.txt': 'a0\n', 'b.txt': 'b0\n', 'c.txt': 'c0\n', 'd.txt': 'd0\n', 'e.txt': 'e0\n' },
+ message: 'Initial import',
+ });
+ git(['tag', 'v1.0.0']);
+ const m1 = commit({ files: { 'e.txt': 'e1\n' }, message: 'Unrelated work (#10)' });
+ git(['tag', 'v1.1.0-beta.0']);
+ const o1 = commit({ files: { 'a.txt': 'a1\n', 'b.txt': 'b1\n' }, ...AUTOSAVE });
+ const m2 = commit({ files: { 'e.txt': 'e2\n' }, message: 'More unrelated work (#12)' });
+ git(['tag', 'v1.1.0']);
+ const o2 = commit({
+ files: { 'c.txt': 'c1\n' },
+ message: 'fix: keep the notice reachable (#22)\n\nOriginal body.',
+ ...NOTICE,
+ });
+ const o3 = commit({ files: { 'd.txt': 'd1\n' }, ...IDENTICAL });
+ const head = commit({ files: { 'e.txt': 'e3\n' }, message: 'Later work (#40)' });
+
+ git(['checkout', '--quiet', '--detach', 'v1.0.0']);
+ const x1 = commit({ files: { 'a.txt': 'a1\n' }, ...AUTOSAVE });
+ const x2 = commit({
+ files: { 'c.txt': 'c1-picked\n' },
+ message: 'fix: keep the notice reachable (#22)\n\nReworded while picking.',
+ ...NOTICE,
+ });
+ const x3 = commit({ files: { 'd.txt': 'd1\n' }, ...IDENTICAL });
+ git(['tag', 'v1.0.1']);
+ const x4 = commit({
+ files: { 'f.txt': 'f\n' },
+ message: `Revert "fix: something old (#5)"\n\nThis reverts commit ${'1'.repeat(40)}.`,
+ });
+ git(['tag', 'v1.0.2']);
+
+ git(['checkout', '--quiet', '--detach', 'v1.0.0']);
+ const sideAutosave = commit({
+ files: { 'a.txt': 'a1-relanded\n' },
+ message: 'fix: keep autosave working, landed again (#11)',
+ author: 'Dana <[email protected]>',
+ });
+ git(['checkout', '--quiet', 'main']);
+
+ fixture = {
+ ...repo,
+ shas: { m1, o1, m2, o2, o3, head, x1, x2, x3, x4, sideAutosave },
+ };
+});
+
+function releases({ publishRevert = false, extra = [] } = {}) {
+ const { o1, o2, o3 } = fixture.shas;
+ return [
+ { tag_name: 'v1.0.0', draft: false, prerelease: false, body: 'First stable.' },
+ { tag_name: 'v1.1.0-beta.0', draft: false, prerelease: true, body: 'A beta.' },
+ {
+ tag_name: 'v1.0.1',
+ draft: false,
+ prerelease: false,
+ body: `Point release over v1.0.0: the current stable plus 3 applied commit(s).\n\nApplied: ${o1}, ${o2.slice(0, 9)} (${o2}), ${o3}\n`,
+ },
+ { tag_name: 'v1.1.0', draft: false, prerelease: false, body: 'Promoted from a beta.' },
+ {
+ tag_name: 'v1.0.2',
+ draft: !publishRevert,
+ prerelease: false,
+ body: `Applied: ${'1'.repeat(40)}`,
+ },
+ ...extra,
+ ];
+}
+
+const evaluate = (candidate, listing = releases()) =>
+ evaluateShippedFixContainment({
+ candidate,
+ published: publishedStableReleases(listing),
+ git: gitRepo(fixture.dir),
+ });
+
+describe('the published-stable set', () => {
+ test('keeps non-draft vX.Y.Z Releases, sorted numerically, and drops betas and drafts', () => {
+ const published = publishedStableReleases([
+ { tag_name: 'v0.10.0', draft: false, body: 'ten' },
+ { tag_name: 'v0.9.1', draft: false, body: null },
+ { tag_name: 'v0.10.0-beta.3', draft: false, body: 'beta' },
+ { tag_name: 'v0.11.0', draft: true, body: 'draft' },
+ { tag_name: 'v0.2.0', draft: false, prerelease: true, body: 'demoted' },
+ ]);
+ expect(published.map((r) => r.tag)).toEqual(['v0.2.0', 'v0.9.1', 'v0.10.0']);
+ expect(published[1].body).toBe('');
+ });
+
+ test('refuses a listing entry it cannot read rather than guessing that it is unpublished', () => {
+ expect(() => publishedStableReleases([{ tag_name: 'v1.0.0' }])).toThrow(/draft flag/);
+ expect(() => publishedStableReleases({ tag_name: 'v1.0.0' })).toThrow(/not an array/);
+ });
+
+ test('reads a JSON array, a slurped page list, and the JSON lines gh --jq prints', () => {
+ const one = { tag_name: 'v1.0.0', draft: false };
+ const two = { tag_name: 'v1.0.1', draft: true };
+ expect(parseReleaseListing(JSON.stringify([one, two]))).toEqual([one, two]);
+ expect(parseReleaseListing(JSON.stringify([[one], [two]]))).toEqual([one, two]);
+ expect(parseReleaseListing(`${JSON.stringify(one)}\n${JSON.stringify(two)}\n`)).toEqual([
+ one,
+ two,
+ ]);
+ expect(parseReleaseListing(' ')).toEqual([]);
+ });
+});
+
+describe('recorded provenance and PR numbers', () => {
+ test('reads every full origin SHA from the Applied lines a point release writes', () => {
+ const a = 'a'.repeat(40);
+ const b = 'b'.repeat(40);
+ expect(
+ appliedOrigins(`Point release over v1.0.0.\n\nApplied: ${a}, ${b}\n\n### Patch Changes`),
+ ).toEqual([a, b]);
+ expect(appliedOrigins(`Applied: 496a4be01 (${a})`)).toEqual([a]);
+ expect(appliedOrigins(`Applied: ${a}\r\nlater\nApplied: ${b}, ${a}`)).toEqual([a, b]);
+ expect(appliedOrigins(`Notes mention ${a} but record nothing as applied.`)).toEqual([]);
+ expect(appliedOrigins(null)).toEqual([]);
+ });
+
+ test('takes only the PR number that ends the subject', () => {
+ expect(
+ terminalPrNumber('fix(ok): keep the update-ready notice reachable (PRD-9007) (#5610)'),
+ ).toBe('5610');
+ expect(terminalPrNumber('Follow up on (#12) and land it (#13) ')).toBe('13');
+ expect(terminalPrNumber('Revert "fix: tidy (#5)"')).toBeNull();
+ expect(terminalPrNumber('main reset: post-stable v0.82.2')).toBeNull();
+ });
+});
+
+describe('evaluating a candidate against the published stables', () => {
+ test('refuses a candidate older than a published stable, naming every commit it lacks', () => {
+ const { m1, x1, x2, x3, o1, m2 } = fixture.shas;
+ const verdict = evaluate(m1);
+ expect(verdict.ok).toBe(false);
+ expect(verdict.checked).toEqual(['v1.0.1', 'v1.1.0']);
+ expect(verdict.uncovered.map((c) => c.sha)).toEqual([
+ ...[x1, x2, x3].sort(),
+ ...[o1, m2].sort(),
+ ]);
+ const byPr = Object.fromEntries(verdict.uncovered.map((c) => [c.sha, [c.pr, c.stables]]));
+ expect(byPr[x1]).toEqual(['11', ['v1.0.1']]);
+ expect(byPr[m2]).toEqual(['12', ['v1.1.0']]);
+ });
+
+ test('refuses a beta that lacks two of a point release three fixes, naming each with its PR and stable', () => {
+ const { m2, x1, x2, x3, o1 } = fixture.shas;
+ const verdict = evaluate(m2);
+ expect(verdict.ok).toBe(false);
+ expect(verdict.checked).toEqual(['v1.0.1']);
+ expect(verdict.records).toBe(3);
+ expect(verdict.plusRecords).toBe(3);
+ expect(verdict.uncovered.map((c) => [c.sha, c.pr])).toEqual(
+ [
+ [x2, '22'],
+ [x3, '33'],
+ ].sort(([a], [b]) => a.localeCompare(b)),
+ );
+ expect(verdict.commits.find((c) => c.sha === x1)).toMatchObject({
+ coverage: COVERAGE.PROVENANCE,
+ origin: o1,
+ });
+ const listed = verdict.uncovered.map((c) => `#${c.pr} (v1.0.1)`).join(', ');
+ expect(refusalHeadline(verdict, 'v1.1.0')).toBe(
+ `v1.1.0 lacks 2 fixes that a published stable already shipped: ${listed}.`,
+ );
+ });
+
+ test('admits a candidate holding every fix by patch, by recorded origin, or by PR number', () => {
+ const { head, x1, x2, o1 } = fixture.shas;
+ const verdict = evaluate(head);
+ expect(verdict).toMatchObject({
+ ok: true,
+ checked: ['v1.0.1'],
+ records: 3,
+ plusRecords: 2,
+ plusCommits: 2,
+ coveredByProvenance: 1,
+ coveredByPrNumber: 1,
+ uncovered: [],
+ });
+ expect(verdict.commits).toEqual([
+ expect.objectContaining({ sha: x1, coverage: COVERAGE.PROVENANCE, origin: o1, pr: '11' }),
+ expect.objectContaining({ sha: x2, coverage: COVERAGE.PR_NUMBER, origin: null, pr: '22' }),
+ ]);
+ expect(describeVerdict(verdict, 'v1.2.0')).toEqual([
+ expect.stringContaining('contains every fix the published stables shipped'),
+ ]);
+ expect(summaryMarkdown(verdict, 'v1.2.0')).toContain('contains every published fix');
+ });
+
+ test('ignores a draft stable, and refuses once the same Release is published', () => {
+ const { head, x4 } = fixture.shas;
+ expect(evaluate(head).ok).toBe(true);
+ const verdict = evaluate(head, releases({ publishRevert: true }));
+ expect(verdict.ok).toBe(false);
+ expect(verdict.checked).toEqual(['v1.0.1', 'v1.0.2']);
+ expect(verdict.uncovered).toEqual([
+ expect.objectContaining({ sha: x4, pr: null, coverage: null, stables: ['v1.0.2'] }),
+ ]);
+ expect(refusalHeadline(verdict, 'v1.2.0')).toBe(
+ `v1.2.0 lacks 1 fix that a published stable already shipped: ${x4.slice(0, 12)} (v1.0.2).`,
+ );
+ expect(describeVerdict(verdict, 'v1.2.0').join('\n')).toContain(
+ 'no PR number; shipped in v1.0.2',
+ );
+ expect(summaryMarkdown(verdict, 'v1.2.0')).toContain(`| \`${x4.slice(0, 12)}\` |`);
+ });
+
+ test('credits a recorded origin only when that origin is in the candidate history', () => {
+ const { sideAutosave, x1, x2, x3 } = fixture.shas;
+ const verdict = evaluate(sideAutosave);
+ expect(verdict.ok).toBe(false);
+ expect(verdict.commits.find((c) => c.sha === x1)).toMatchObject({
+ coverage: COVERAGE.PR_NUMBER,
+ origin: null,
+ });
+ expect(verdict.uncovered.map((c) => c.sha)).toEqual(expect.arrayContaining([x2, x3]));
+ expect(verdict.uncovered.map((c) => c.sha)).not.toContain(x1);
+ });
+
+ test('credits a recorded origin only when the pick carries its author, date and message', () => {
+ const { head, x2, o2 } = fixture.shas;
+ const real = gitRepo(fixture.dir);
+ const withoutPrNumbers = {
+ ...real,
+ history: (sha) => ({ shas: real.history(sha).shas, prNumbers: new Set() }),
+ };
+ const verdict = evaluateShippedFixContainment({
+ candidate: head,
+ published: publishedStableReleases(releases()),
+ git: withoutPrNumbers,
+ });
+ expect(appliedOrigins(releases()[2].body)).toContain(o2);
+ expect(verdict.ok).toBe(false);
+ expect(verdict.uncovered).toEqual([expect.objectContaining({ sha: x2, coverage: null })]);
+ expect(verdict.coveredByProvenance).toBe(1);
+ });
+
+ test('fails closed when a published Release has no tag in the checkout', () => {
+ expect(() =>
+ evaluate(
+ fixture.shas.head,
+ releases({ extra: [{ tag_name: 'v9.9.9', draft: false, body: '' }] }),
+ ),
+ ).toThrow(/no tag in this checkout: v9\.9\.9/);
+ });
+
+ test('fails closed on a candidate that does not resolve to a commit', () => {
+ expect(() => evaluate('v7.7.7')).toThrow(/does not resolve to a commit/);
+ });
+
+ test('tells a ref the checkout lacks apart from a git that cannot read the checkout', () => {
+ expect(() => gitRepo(fixture.dir).resolveCommit('refs/tags/v7.7.7')).toThrow(
+ 'refs/tags/v7.7.7 does not resolve to a commit in this checkout',
+ );
+ expect(() => gitRepo(fixture.dir).resolveCommit(`${fixture.shas.head}^{tree}`)).toThrow(
+ /^\S+ does not resolve to a commit in this checkout: \S/,
+ );
+ const broken = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-broken-')));
+ scratch.push(broken);
+ writeFileSync(join(broken, '.git'), `gitdir: ${join(broken, 'missing')}\n`);
+ let failure;
+ try {
+ gitRepo(broken).resolveCommit('HEAD');
+ } catch (err) {
+ failure = err;
+ }
+ expect(failure?.message).toMatch(
+ /^git rev-parse --verify --quiet HEAD\^\{commit\} failed \(exit 128\): \S/,
+ );
+ expect(failure.message).not.toContain('does not resolve');
+ });
+});
+
+describe('the reusable check', () => {
+ test('lists the Releases once however many questions it answers', () => {
+ let listings = 0;
+ const check = createShippedFixCheck({
+ cwd: fixture.dir,
+ listReleases: () => {
+ listings += 1;
+ return releases();
+ },
+ });
+ expect(check.publishedStableTags()).toEqual(['v1.0.0', 'v1.0.1', 'v1.1.0']);
+ expect(check.evaluate(fixture.shas.head).ok).toBe(true);
+ expect(check.evaluate(fixture.shas.m2).ok).toBe(false);
+ expect(listings).toBe(1);
+ });
+
+ test('refuses a listing with no stable Release while the checkout has stable tags', () => {
+ const check = createShippedFixCheck({ cwd: fixture.dir, listReleases: () => [] });
+ expect(() => check.publishedStableTags()).toThrow(/holds no stable Release/);
+ });
+
+ test('a listing with only draft stables is a real answer, not a broken listing', () => {
+ const check = createShippedFixCheck({
+ cwd: fixture.dir,
+ listReleases: () => [{ tag_name: 'v1.0.1', draft: true, body: '' }],
+ });
+ expect(check.publishedStableTags()).toEqual([]);
+ expect(check.evaluate(fixture.shas.m1).ok).toBe(true);
+ });
+});
+
+describe('the Release listing', () => {
+ test('reads every page, so a stable listed past the first still refuses a candidate that lacks its fixes', () => {
+ const bin = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-gh-')));
+ scratch.push(bin);
+ const byTag = new Map(releases().map((release) => [release.tag_name, release]));
+ const page = (name, tags) => {
+ const lines = tags.map((tag) => {
+ const { tag_name, draft, body } = byTag.get(tag);
+ return JSON.stringify({ tag_name, draft, body });
+ });
+ writeFileSync(join(bin, name), `${lines.join('\n')}\n`);
+ return join(bin, name);
+ };
+ const first = page('page-1.jsonl', ['v1.0.2', 'v1.1.0']);
+ const second = page('page-2.jsonl', ['v1.0.1', 'v1.0.0']);
+ writeFileSync(
+ join(bin, 'gh'),
+ [
+ '#!/bin/sh',
+ 'listing=no',
+ 'for arg in "$@"; do',
+ ' case "$arg" in repos/inkeep/fixture/releases|repos/inkeep/fixture/releases\\?*) listing=yes ;; esac',
+ 'done',
+ 'if [ "$1" != api ] || [ "$listing" != yes ]; then echo "unexpected gh call: $*" >&2; exit 97; fi',
+ `cat '${first}'`,
+ 'for arg in "$@"; do',
+ ` if [ "$arg" = --paginate ]; then cat '${second}'; fi`,
+ 'done',
+ 'exit 0',
+ '',
+ ].join('\n'),
+ { mode: 0o755 },
+ );
+ const summary = join(bin, 'summary');
+ writeFileSync(summary, '');
+ const run = spawnSync(
+ process.execPath,
+ [SCRIPT, '-C', fixture.dir, '--repo', 'inkeep/fixture', '--candidate', fixture.shas.m2],
+ {
+ encoding: 'utf8',
+ env: {
+ ...gitCleanEnv(),
+ GITHUB_STEP_SUMMARY: summary,
+ PATH: `${bin}${delimiter}${process.env.PATH}`,
+ },
+ },
+ );
+ expect(run.stderr).not.toContain('unexpected gh call');
+ expect(run.status, run.stderr).toBe(REFUSED_EXIT);
+ expect(run.stdout).toContain('#22 (v1.0.1)');
+ expect(run.stdout).toContain('#33 (v1.0.1)');
+ expect(readFileSync(summary, 'utf8')).toContain('fix: keep the notice reachable (#22)');
+ });
+});
+
+describe('the command line', () => {
+ const listingFile = (listing) => {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-cli-')));
+ scratch.push(dir);
+ const path = join(dir, 'releases.json');
+ writeFileSync(path, JSON.stringify(listing));
+ return { dir, path };
+ };
+ const cli = (args, listing = releases()) => {
+ const { dir, path } = listingFile(listing);
+ const summary = join(dir, 'summary');
+ writeFileSync(summary, '');
+ const res = spawnSync(
+ process.execPath,
+ [SCRIPT, '-C', fixture.dir, '--releases', path, ...args],
+ {
+ encoding: 'utf8',
+ env: {
+ ...gitCleanEnv(),
+ GIT_DIR: join(dir, 'leaked-git-dir'),
+ GITHUB_STEP_SUMMARY: summary,
+ },
+ },
+ );
+ return {
+ status: res.status,
+ stdout: res.stdout,
+ stderr: res.stderr,
+ summary: readFileSync(summary, 'utf8'),
+ };
+ };
+
+ test('exits 2 with an error annotation and a summary table when the candidate lacks a shipped fix', () => {
+ const run = cli(['--candidate', fixture.shas.m2, '--label', 'v1.1.0']);
+ expect(run.status).toBe(REFUSED_EXIT);
+ expect(run.stdout).toMatch(
+ /^::error::v1\.1\.0 lacks 2 fixes that a published stable already shipped: /m,
+ );
+ expect(run.summary).toContain('| Commit | Subject | PR | Shipped in |');
+ expect(run.summary).toContain('fix: keep the notice reachable (#22)');
+ });
+
+ test('exits 0 and records the verdict when the candidate contains every shipped fix', () => {
+ const run = cli(['--candidate', fixture.shas.head]);
+ expect(run.status).toBe(0);
+ expect(run.stdout).toContain('contains every fix the published stables shipped');
+ expect(run.summary).toContain('contains every published fix');
+ expect(run.stdout).not.toContain('::error::');
+ });
+
+ test('exits 1, never 0, when it cannot decide', () => {
+ const missing = cli(['--candidate', 'v7.7.7']);
+ expect(missing.status).toBe(1);
+ expect(missing.stderr).toContain(
+ 'could not decide: v7.7.7 does not resolve to a commit in this checkout',
+ );
+ const untagged = cli(
+ ['--candidate', fixture.shas.head],
+ releases({ extra: [{ tag_name: 'v9.9.9', draft: false }] }),
+ );
+ expect(untagged.status).toBe(1);
+ });
+
+ test('refuses arguments it does not understand', () => {
+ expect(() => parseArgs(['--candidate', 'v1', '--frobnicate', 'x'])).toThrow(/unrecognized/);
+ expect(() => parseArgs(['--candidate'])).toThrow(/needs a value/);
+ expect(() => parseArgs(['--candidate', 'a', '--candidate', 'b'])).toThrow(/twice/);
+ expect(() => parseArgs(['--releases', 'f'])).toThrow(/exactly one/);
+ expect(cli(['--frobnicate', 'x']).status).toBe(1);
+ });
+
+ test('the matrix mode reports every pair and fails on a verdict it did not expect', () => {
+ const { m1, m2, head } = fixture.shas;
+ const good = cli([
+ '--matrix',
+ `${m1},${m2},${head}`,
+ '--expect-refuse',
+ `${m1} ${m2}`,
+ '--expect-admit',
+ head,
+ ]);
+ expect(good.status).toBe(0);
+ expect(good.stdout).toContain(
+ 'Published stable Releases: 3. Candidates: 3. git cherry pairs: 4.',
+ );
+ expect(good.stdout).toContain('Expected verdicts: all matched.');
+ const bad = cli(['--matrix', `${m2},${head}`, '--expect-admit', m2]);
+ expect(bad.status).toBe(1);
+ expect(bad.stdout).toContain(`${m2}: refused, expected admission`);
+ });
+});
+
+describe('an asset repair of a stable that is already published', () => {
+ const listingFile = (listing) => {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-shipped-fix-repair-')));
+ scratch.push(dir);
+ const path = join(dir, 'releases.json');
+ writeFileSync(path, JSON.stringify(listing));
+ return { dir, path };
+ };
+ const cli = (args, listing = releases()) => {
+ const { dir, path } = listingFile(listing);
+ const summary = join(dir, 'summary');
+ writeFileSync(summary, '');
+ const res = spawnSync(
+ process.execPath,
+ [SCRIPT, '-C', fixture.dir, '--releases', path, ...args],
+ {
+ encoding: 'utf8',
+ env: { ...gitCleanEnv(), GITHUB_STEP_SUMMARY: summary },
+ },
+ );
+ return {
+ status: res.status,
+ stdout: res.stdout,
+ stderr: res.stderr,
+ summary: readFileSync(summary, 'utf8'),
+ };
+ };
+ const repairOf = (tag) => [
+ '--candidate',
+ `refs/tags/${tag}`,
+ '--label',
+ tag,
+ '--allow-published-repair',
+ tag,
+ ];
+
+ test('skips the check for a tag whose Release is published, which the same check otherwise refuses', () => {
+ const checked = cli(['--candidate', 'refs/tags/v1.1.0', '--label', 'v1.1.0']);
+ expect(checked.status).toBe(REFUSED_EXIT);
+ const repair = cli(repairOf('v1.1.0'));
+ expect(repair.status, repair.stderr).toBe(0);
+ expect(repair.stdout).toContain(
+ '::notice::v1.1.0 already has a published Release; this repair may update assets and release metadata',
+ );
+ expect(repair.stdout).toContain('dispatch desktop-release-published to release consumers for reconciliation');
+ expect(repair.stdout).toContain('without explicitly requesting Latest or dispatching npm publication');
+ expect(repair.stdout).not.toContain('::error::');
+ expect(repair.summary).toContain('### Shipped-fix containment: v1.1.0 not checked');
+ });
+
+ test('still checks a tag whose Release is a draft, because finishing it publishes', () => {
+ const run = cli(repairOf('v1.0.2'));
+ expect(run.status).toBe(REFUSED_EXIT);
+ const refusal = run.stdout.split('\n').filter((line) => line.startsWith('::error::'));
+ expect(refusal).toEqual([
+ expect.stringMatching(
+ /^::error::v1\.0\.2 lacks 2 fixes that a published stable already shipped: /,
+ ),
+ ]);
+ expect(refusal[0]).toContain('#10 (v1.1.0)');
+ expect(refusal[0]).toContain('#12 (v1.1.0)');
+ });
+
+ test('covers only the tag being checked, and only a stable tag', () => {
+ const other = cli(['--candidate', fixture.shas.head, '--allow-published-repair', 'v1.1.0']);
+ expect(other.status).toBe(1);
+ expect(other.stderr).toContain('the exemption covers only the tag being checked');
+ const notStable = cli([
+ '--candidate',
+ 'refs/tags/v1.1.0-beta.0',
+ '--allow-published-repair',
+ 'v1.1.0-beta.0',
+ ]);
+ expect(notStable.status).toBe(1);
+ expect(notStable.stderr).toContain('takes a vX.Y.Z stable tag');
+ expect(() => parseArgs(['--matrix', 'v1.1.0', '--allow-published-repair', 'v1.1.0'])).toThrow(
+ /goes with --candidate/,
+ );
+ });
+
+ test('asks the listing and git, and never evaluates the candidate', () => {
+ let evaluated = 0;
+ const check = {
+ publishedStableTags: () => ['v1.0.0', 'v1.1.0'],
+ resolveCommit: (ref) =>
+ ref === 'refs/tags/v1.1.0' || ref === 'cand' ? 'a'.repeat(40) : 'b'.repeat(40),
+ evaluate: () => {
+ evaluated += 1;
+ },
+ };
+ expect(publishedRepairExemption({ candidate: 'cand', tag: 'v1.1.0', check })).toBe(true);
+ expect(
+ publishedRepairExemption({
+ candidate: 'cand',
+ tag: 'v1.1.0',
+ check: { ...check, publishedStableTags: () => ['v1.0.0'] },
+ }),
+ ).toBe(false);
+ expect(evaluated).toBe(0);
+ });
+});
+
+describe('the matrix runner', () => {
+ test('names a candidate it expected a verdict for but never evaluated', () => {
+ const check = { evaluate: () => ({ ok: true, checked: [], records: 0, plusRecords: 0 }) };
+ const result = runMatrix({ candidates: ['a'], expectAdmit: ['a', 'b'], check });
+ expect(result.mismatches).toEqual(['b: expected a verdict but it is not in --matrix']);
+ });
+});
diff --git a/.github/workflows/bug-lane.yml b/.github/workflows/bug-lane.yml
index 7c931905f..af0a0cda1 100644
--- a/.github/workflows/bug-lane.yml
+++ b/.github/workflows/bug-lane.yml
@@ -129,6 +129,7 @@ jobs:
# "not bug-linked" and the lane is inert rather than wrong.
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
BUMP_VERDICTS: ${{ needs.read-bumps.outputs.bump_verdicts }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Writes fix_refs (comma-joined), stable and fix_tickets to
# GITHUB_OUTPUT; per-commit verdicts land as notices. Logic + tests:
# .github/scripts/bug-lane.{mjs,test.mjs}.
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 14461e5dc..86cb0fbdd 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -289,6 +289,24 @@ jobs:
node-version-file: .node-version
package-manager-cache: false
+ - name: Refuse a stable that lacks a fix a published stable shipped
+ if: steps.channel.outputs.channel == 'latest'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RELEASE_TAG: ${{ github.event.client_payload.release_tag || inputs.release_tag }}
+ run: |
+ set -euo pipefail
+ git cat-file -e "$GITHUB_SHA^{commit}" 2>/dev/null || git fetch --no-tags origin "$GITHUB_SHA"
+ guard="$RUNNER_TEMP/shipped-fix-containment"
+ rm -rf "$guard"
+ mkdir -p "$guard"
+ git archive "$GITHUB_SHA" .github/scripts/shipped-fix-containment.mjs scripts/git-clean-env.mjs | tar -x -C "$guard"
+ args=(--candidate "refs/tags/${RELEASE_TAG}" --label "$RELEASE_TAG")
+ if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
+ args+=(--allow-published-repair "$RELEASE_TAG")
+ fi
+ node "$guard/.github/scripts/shipped-fix-containment.mjs" "${args[@]}"
+
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
cache: false
@@ -1818,6 +1836,8 @@ jobs:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
- name: Refuse to promote a superseded stable on a re-run
if: success() && needs.prepare.outputs.channel == 'latest' && github.run_attempt != '1' && github.event_name != 'workflow_dispatch'
@@ -1873,6 +1893,18 @@ jobs:
echo "::warning::render-release-downloads.mjs failed for ${RELEASE_TAG}; the release keeps its previous body."
fi
+ - name: Refuse a stable that lacks a fix a published stable shipped
+ if: success() && needs.prepare.outputs.channel == 'latest'
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ args=(--candidate "refs/tags/${RELEASE_TAG}" --label "$RELEASE_TAG")
+ if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
+ args+=(--allow-published-repair "$RELEASE_TAG")
+ fi
+ node .github/scripts/shipped-fix-containment.mjs "${args[@]}"
+
# Closes the publish-window race: release.yml / promote-stable.yml
# create the GitHub Release as --draft so it stays out of the .atom
# feed until every installer + channel manifest is attached. This step
@@ -2323,7 +2355,7 @@ jobs:
# (--draft=false [--latest]) — empirically atomic per GitHub's
# post-state evaluation of make_latest.
if [[ "$CHANNEL" == "latest" ]]; then
- RECOVERY="gh release edit ${RELEASE_TAG} --draft=false --latest"
+ RECOVERY="gh release edit ${RELEASE_TAG} --draft=false --latest (never for a tag the shipped-fix check refused)"
else
RECOVERY="gh release edit ${RELEASE_TAG} --draft=false"
fi
diff --git a/.github/workflows/promote-stable.yml b/.github/workflows/promote-stable.yml
index 7409eb048..ea5312800 100644
--- a/.github/workflows/promote-stable.yml
+++ b/.github/workflows/promote-stable.yml
@@ -306,6 +306,15 @@ jobs:
# shipped, or adds no changesets) and gates every step below.
node scripts/compute-stable-version.mjs "$BETA_TAG"
+ - name: Refuse a stable that lacks a fix a published stable shipped
+ if: steps.ver.outputs.skip != 'true'
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ BETA_TAG: ${{ steps.resolve.outputs.beta_tag }}
+ BETA_SHA: ${{ steps.ver.outputs.beta_sha }}
+ STABLE_TAG: ${{ steps.ver.outputs.stable_tag }}
+ run: node .github/scripts/shipped-fix-containment.mjs --candidate "$BETA_SHA" --label "${STABLE_TAG} from ${BETA_TAG}"
+
- name: Link to triggering run
# Back-link: who dispatched this promotion. Present on the automated path
# (select-beta-to-promote passes its run URL); blank on manual / external
diff --git a/.github/workflows/select-beta-to-promote.yml b/.github/workflows/select-beta-to-promote.yml
index af87f35a7..2695e910e 100644
--- a/.github/workflows/select-beta-to-promote.yml
+++ b/.github/workflows/select-beta-to-promote.yml
@@ -259,6 +259,7 @@ jobs:
# expected steady state until an operator provisions the secret.
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
BUMP_VERDICTS: ${{ needs.read-bumps.outputs.bump_verdicts }}
+ DISPATCH_WINDOW_OPEN: ${{ steps.hours.outputs.open }}
# Writes target=, tier=, soak_tier= (plus the predicate inputs) to
# GITHUB_OUTPUT; an empty target => no-op. Exits non-zero (fails the job)
# on any non-404 gh/git infra error — a fail-loud retry-next-tick, never
diff --git a/knip.config.ts b/knip.config.ts
index 0004a763a..69344114d 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -149,15 +149,11 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: [
- '@types/shell-quote',
- ],
+ ignoreDependencies: ['@types/shell-quote'],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
- ignoreDependencies: [
- 'yjs',
- ],
+ ignoreDependencies: ['yjs'],
},
'packages/desktop': {
entry: [
diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
index 4549c74b3..a50b00123 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
index 4fc2c11f9..6fcdc23f2 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { normalizeBridge } from '@inkeep/open-knowledge-core';
import { updateYFragment } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.ts
index 9f2f6feb6..40b5cdfd6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
index 2a085742b..93666af70 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.ts
index 878d5196b..867598d34 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
index 4ada3cf26..0970ac12f 100644
--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterEach, describe, expect, test } from 'vitest';
import { agentWriteMd, createTestServer, type TestServer } from './test-harness';
diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
index cbe2b705f..b632185e1 100644
--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
@@ -1,4 +1,3 @@
-
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
index 89bc9b4d9..c530ce4ba 100644
--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import type * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.ts
index a78aeb0e4..d3767adc9 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,4 +1,3 @@
-
import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.ts
index e7cc69c3f..b076f955c 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.ts
index 9ddcd0730..7935e35f8 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter } from '@inkeep/open-knowledge-core';
import { Plugin, PluginKey } from '@tiptap/pm/state';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index 2a597ec3d..f4cc8a286 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index ffd8fce06..e7e63f43d 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,4 +1,3 @@
-
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fb0ba5a7c..fc267cbea 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index fa3cfcd86..bfd7e3109 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 8be632ba4..4d3250d3a 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,4 +1,3 @@
-
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');