Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): retry transient packaging flakes on every platform (PRD-7991) (#3449)

Andrew Mikofalvy3a94f36a044e
diff --git a/.github/scripts/build-smoke-alert-payload.mjs b/.github/scripts/build-smoke-alert-payload.mjs
index 85c72749e..2023c5702 100644
--- a/.github/scripts/build-smoke-alert-payload.mjs
+++ b/.github/scripts/build-smoke-alert-payload.mjs
@@ -18,7 +18,12 @@
*
* Usage:
* node build-smoke-alert-payload.mjs \
- * --tag vX.Y.Z --verdict fail|error --reason "…" --run-url "…" [--repo owner/name]
+ * --tag vX.Y.Z --verdict pass|fail|error --reason "…" --run-url "…" \
+ * [--blocked-by "Linux packaging"] [--repo owner/name]
+ *
+ * `--verdict` is the SMOKE's verdict; `--blocked-by` names the jobs that
+ * actually failed. They differ whenever a non-mac packaging job fails while the
+ * smoke passes, and conflating them mislabels the page.
*
* Emits the payload as JSON on stdout. Everything is assembled through
* JSON.stringify, so an interpolated tag or reason containing quotes cannot
@@ -31,9 +36,12 @@ const ALERT_HEADLINE = 'RELEASE BLOCKED';
const DEFAULT_REPO = 'inkeep/open-knowledge';
/**
- * A `fail` means the app itself misbehaved; an `error` means the gate could not
- * reach a verdict. The responder does different things in each case, so the
- * two must never read the same.
+ * The smoke's own view of itself: a `fail` means the app misbehaved, anything
+ * else means it could not reach a verdict. The responder does different things
+ * in each case, so the two must never read the same.
+ *
+ * This describes the SMOKE only. What blocked the RELEASE is a wider question —
+ * see describeBlock, which is what the headline is built from.
*/
export function describeVerdict(verdict) {
if (verdict === 'fail') {
@@ -49,6 +57,56 @@ export function describeVerdict(verdict) {
};
}
+/**
+ * What actually blocked the release, which is NOT always the smoke.
+ *
+ * The packaging jobs are independent: Linux or Windows can fail while the mac
+ * job runs the smoke to a clean PASS. Attributing every blocked release to the
+ * smoke produced pages reading "DMG smoke ERRORED — all 13 executed smoke tests
+ * passed", which sent responders hunting a regression that did not exist. A
+ * passing smoke must never be rendered as a smoke failure or a smoke error.
+ */
+export function describeBlock({ verdict, blockedBy = '' } = {}) {
+ const other = String(blockedBy ?? '').trim();
+
+ // A genuine smoke failure IS the story, so it keeps the headline even when a
+ // blocking stage is known — naming a job there would dilute a real product
+ // regression into a pipeline complaint.
+ if (verdict === 'fail') {
+ const { short, detail } = describeVerdict('fail');
+ return { subject: `DMG smoke ${short}`, detail, smokePassed: false };
+ }
+
+ const smokePassed = verdict === 'pass';
+
+ // Whenever the workflow knows which job failed, say so. This covers the
+ // pass case AND the no-verdict case: when build-macos dies before the smoke
+ // runs, the verdict is empty but the failing job is known, and describing
+ // that as an error "inside the gate" points the responder at a gate that
+ // never ran — while the annotation and jq fallback name the job correctly.
+ if (other) {
+ return {
+ subject: `blocked by ${other}`,
+ detail: smokePassed
+ ? `the DMG smoke PASSED — this is NOT an app regression. ${other} failed; check that job before re-running.`
+ : `${other} failed; the DMG smoke never reached a verdict. Check that job before re-running.`,
+ smokePassed,
+ };
+ }
+
+ if (smokePassed) {
+ return {
+ subject: 'blocked after the smoke passed',
+ detail:
+ 'the DMG smoke PASSED — this is NOT an app regression; a later stage of the release pipeline failed. See the run.',
+ smokePassed: true,
+ };
+ }
+
+ const { short, detail } = describeVerdict(verdict);
+ return { subject: `DMG smoke ${short}`, detail, smokePassed: false };
+}
+
/** Re-firing the two dispatch events is the whole recovery; nothing needs repair by hand. */
export function recoveryCommand(tag, repo = DEFAULT_REPO) {
return [
@@ -57,37 +115,54 @@ export function recoveryCommand(tag, repo = DEFAULT_REPO) {
].join(' ');
}
-function summaryLine(tag, verdict) {
- const { short } = describeVerdict(verdict);
- return `🚨 ${ALERT_HEADLINE}: ${tag} DMG smoke ${short} — nothing shipped`;
+function summaryLine(tag, verdict, blockedBy) {
+ const { subject } = describeBlock({ verdict, blockedBy });
+ return `🚨 ${ALERT_HEADLINE}: ${tag} ${subject} — nothing shipped`;
}
-function bodyLines({ tag, verdict, reason, runUrl, repo }) {
- const { detail } = describeVerdict(verdict);
+function bodyLines({ tag, verdict, reason, runUrl, repo, blockedBy }) {
+ const { detail, smokePassed } = describeBlock({ verdict, blockedBy });
+ const other = String(blockedBy ?? '').trim();
return [
`*Tag:* \`${tag}\``,
- `*Verdict:* \`${verdict}\` — ${detail}`,
- `*Why:* ${reason}`,
+ // Labelled as the SMOKE's verdict, not the release's: on a Linux or Windows
+ // packaging failure the smoke can legitimately read `pass` on a blocked release.
+ `*Smoke verdict:* \`${verdict}\` — ${detail}`,
+ // Leading with the smoke's own reason is what made the page
+ // self-contradictory, so a known blocking stage always comes first — on the
+ // no-verdict path too, where the reason describes a gate that never ran.
+ other
+ ? smokePassed
+ ? `*Why:* ${other} failed. The DMG smoke itself passed (${reason}).`
+ : `*Why:* ${other} failed (${reason}).`
+ : `*Why:* ${reason}`,
'*State:* the GitHub Release is still a DRAFT and npm `latest` has NOT moved.',
`*Recovery (re-fire the cascade; no manual repair needed):*\n\`${recoveryCommand(tag, repo)}\``,
`*Run:* ${runUrl}`,
];
}
-export function buildSlackPayload({ tag, verdict, reason, runUrl, repo = DEFAULT_REPO }) {
+export function buildSlackPayload({
+ tag,
+ verdict,
+ reason,
+ runUrl,
+ repo = DEFAULT_REPO,
+ blockedBy = '',
+}) {
return {
// `text` is the notification / a11y fallback Slack recommends alongside blocks.
- text: summaryLine(tag, verdict),
+ text: summaryLine(tag, verdict, blockedBy),
blocks: [
{
type: 'header',
- text: { type: 'plain_text', text: summaryLine(tag, verdict), emoji: true },
+ text: { type: 'plain_text', text: summaryLine(tag, verdict, blockedBy), emoji: true },
},
{
type: 'section',
text: {
type: 'mrkdwn',
- text: bodyLines({ tag, verdict, reason, runUrl, repo }).join('\n'),
+ text: bodyLines({ tag, verdict, reason, runUrl, repo, blockedBy }).join('\n'),
},
},
],
@@ -110,6 +185,9 @@ export function parseArgs(argv) {
reason: args.reason || '(no reason recorded)',
runUrl: args['run-url'] || '',
repo: args.repo || DEFAULT_REPO,
+ // Human-readable names of the jobs that actually failed, when the caller
+ // knows them. Absent, the alert falls back to describing the smoke alone.
+ blockedBy: args['blocked-by'] || '',
};
}
diff --git a/.github/scripts/build-smoke-alert-payload.test.mjs b/.github/scripts/build-smoke-alert-payload.test.mjs
index ff2d4d500..fdcb27dea 100644
--- a/.github/scripts/build-smoke-alert-payload.test.mjs
+++ b/.github/scripts/build-smoke-alert-payload.test.mjs
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
buildSlackPayload,
+ describeBlock,
describeVerdict,
parseArgs,
recoveryCommand,
@@ -67,6 +68,90 @@ describe('alert content', () => {
});
});
+describe('a passing smoke is never rendered as a smoke failure', () => {
+ // The v0.52.2 / v0.52.3 pages: Linux packaging died on a dropped download
+ // while the mac job ran the smoke to a clean pass, and the alert coerced that
+ // pass into `error`, producing "DMG smoke ERRORED — all 13 tests passed".
+ const linuxBlocked = {
+ ...base,
+ verdict: 'pass',
+ reason: 'all 13 executed smoke tests passed against the packaged app (0 flaky, 3 skipped)',
+ blockedBy: 'Linux packaging',
+ };
+
+ test('the headline names the failing stage, not the smoke', () => {
+ const text = buildSlackPayload(linuxBlocked).text;
+ expect(text).toContain('Linux packaging');
+ expect(text).not.toContain('DMG smoke ERRORED');
+ expect(text).not.toContain('DMG smoke FAILED');
+ // It is still unmistakably a blocked release.
+ expect(text).toContain('RELEASE BLOCKED');
+ expect(text).toContain('nothing shipped');
+ });
+
+ test('the body does not pair an error verdict with a passing reason', () => {
+ const body = buildSlackPayload(linuxBlocked).blocks[1].text.text;
+ expect(body).toContain('Linux packaging failed');
+ expect(body).toContain('NOT an app regression');
+ // The smoke result is still reported, just not as the cause.
+ expect(body).toContain('smoke itself passed');
+ });
+
+ test('the verdict line is labelled as the smoke’s, not the release’s', () => {
+ const body = buildSlackPayload(linuxBlocked).blocks[1].text.text;
+ expect(body).toContain('*Smoke verdict:*');
+ });
+
+ test('a genuine smoke failure is unaffected by the blocking-stage plumbing', () => {
+ // Regression guard: the fix must not soften a real product regression.
+ const failed = buildSlackPayload({ ...base, verdict: 'fail', blockedBy: 'macOS packaging' });
+ expect(failed.text).toContain('DMG smoke FAILED');
+ expect(JSON.stringify(failed)).toContain('real product regression');
+ });
+
+ test('a pass with no known blocking stage still reads as blocked, not as a pass', () => {
+ const vague = buildSlackPayload({ ...base, verdict: 'pass', blockedBy: '' });
+ expect(vague.text).toContain('RELEASE BLOCKED');
+ expect(vague.text).toContain('nothing shipped');
+ expect(JSON.stringify(vague)).toContain('NOT an app regression');
+ });
+
+ test('a no-verdict blocked release still names the job that failed', () => {
+ // The uncovered branch: build-macos dies BEFORE the smoke runs, so the
+ // verdict is empty and the step coerces it to `error` — but the workflow
+ // does know which job failed. Describing that as an error inside the gate
+ // points the responder at a gate that never ran, and disagrees with the
+ // annotation and jq fallback, which both name the job.
+ const noVerdict = buildSlackPayload({
+ ...base,
+ verdict: 'error',
+ reason: 'the release pipeline failed before completing — see the run',
+ blockedBy: 'macOS packaging',
+ });
+ expect(noVerdict.text).toContain('macOS packaging');
+ expect(noVerdict.text).not.toContain('DMG smoke ERRORED');
+ const body = noVerdict.blocks[1].text.text;
+ expect(body).toContain('macOS packaging failed');
+ // Still honest that the smoke produced nothing, rather than claiming a pass.
+ expect(body).toContain('never reached a verdict');
+ expect(body).not.toContain('smoke itself passed');
+ });
+
+ test('an error with no known stage keeps the original gate wording', () => {
+ const vague = buildSlackPayload({ ...base, verdict: 'error', blockedBy: '' });
+ expect(vague.text).toContain('DMG smoke ERRORED');
+ });
+
+ test('describeBlock separates the smoke verdict from the release outcome', () => {
+ expect(describeBlock({ verdict: 'pass', blockedBy: 'Linux packaging' }).smokePassed).toBe(true);
+ expect(describeBlock({ verdict: 'fail' }).smokePassed).toBe(false);
+ expect(describeBlock({ verdict: 'error' }).smokePassed).toBe(false);
+ // An absent verdict must not be mistaken for a pass.
+ expect(describeBlock({}).smokePassed).toBe(false);
+ expect(describeBlock({}).subject).toContain('ERRORED');
+ });
+});
+
describe('distinctness from the routine release announcement', () => {
test('does not reuse the celebratory headline', () => {
const slack = JSON.stringify(buildSlackPayload(base));
@@ -117,9 +202,15 @@ describe('parseArgs', () => {
reason: 'mount failed',
runUrl: 'https://example.test/run',
repo: 'inkeep/open-knowledge',
+ blockedBy: '',
});
});
+ test('reads the blocking-stage list', () => {
+ const parsed = parseArgs(argv('--tag', 'v1', '--blocked-by', 'Linux packaging'));
+ expect(parsed.blockedBy).toBe('Linux packaging');
+ });
+
test('rejects a missing tag', () => {
expect(() => parseArgs(argv('--verdict', 'fail'))).toThrow(/--tag/);
});
@@ -192,6 +283,52 @@ describe('workflow wiring', () => {
expect(step).toContain('post "${SLACK_RELEASES_WEBHOOK_URL:-${SLACK_WEBHOOK_URL:-}}" Slack');
});
+ test('a passing smoke verdict is not coerced into an error', () => {
+ // The coercion this replaces was `if [[ "$VERDICT" != "fail" ]]; then
+ // VERDICT="error"; fi`, which relabelled a clean pass as an infra error.
+ const step = alertStep();
+ expect(step).not.toMatch(/if \[\[ "\$VERDICT" != "fail" \]\]/);
+ // Only a genuinely absent or skipped verdict becomes `error`.
+ expect(step).toContain('VERDICT="${SMOKE_VERDICT:-error}"');
+ expect(step).toMatch(/skipped.*\]\]; then\s*\n\s*VERDICT="error"/);
+ });
+
+ test('the alert tells the payload builder which jobs actually failed', () => {
+ const step = alertStep();
+ expect(step).toContain('--blocked-by "$BLOCKED_BY"');
+ // Derived from job results, not from the smoke verdict.
+ for (const src of ['RESULT_LINUX', 'RESULT_WINDOWS', 'RESULT_MACOS', 'RESULT_PUBLISH']) {
+ expect(step).toContain(src);
+ }
+ // A skipped downstream job is a consequence, not a cause.
+ expect(step).toContain('== "failure"');
+ });
+
+ test('only REQUIRED platforms count as blockers', () => {
+ // Under the DESKTOP_RELEASE_REQUIRED_PLATFORMS escape valve a non-required
+ // platform can fail while publish-assets and finalize still run. Naming it
+ // would send the responder to a job deliberately excluded from the publish
+ // decision, and would mask a genuine finalize failure behind it.
+ const step = alertStep();
+ expect(step).toContain('REQUIRED_PLATFORMS');
+ expect(step).toContain('is_required()');
+ for (const platform of ['mac', 'windows', 'linux']) {
+ expect(step).toContain(`is_required ${platform}`);
+ }
+ // prepare + publish-assets are never platform-gated; they always block.
+ expect(step).toMatch(/RESULT_PREPARE.*==\s*"failure".*\]\]\s*&&\s*blocked\+=/);
+ });
+
+ test('the alert job can see every packaging job it reports on', () => {
+ const alertJob = desktopRelease.slice(
+ desktopRelease.indexOf('\n alert:'),
+ desktopRelease.indexOf('- name: Alert on a blocked release'),
+ );
+ for (const job of ['build-macos', 'build-windows', 'build-linux', 'publish-assets']) {
+ expect(alertJob).toContain(job);
+ }
+ });
+
test('a blocked release never pages Discord', () => {
// Rationale: this module's docstring. This test is the ratchet for it.
const step = alertStep();
diff --git a/.github/scripts/retry-transient.mjs b/.github/scripts/retry-transient.mjs
new file mode 100644
index 000000000..1d9d1cb64
--- /dev/null
+++ b/.github/scripts/retry-transient.mjs
@@ -0,0 +1,210 @@
+#!/usr/bin/env node
+/**
+ * Bounded, allowlist-gated retry for the release packaging invocations.
+ *
+ * electron-builder shells out to signing, notarization, and tool-download
+ * steps that it will not retry itself: each `codesign --timestamp` is a single
+ * un-retried call, and app-builder's download path aborts on one dropped
+ * connection. A dropped response therefore aborts the whole build, leaving no
+ * durable artifact and stranding the release as a draft. The only lever
+ * available is re-running the whole invocation.
+ *
+ * CRITICAL: retry is gated on a transient-signature allowlist matched against
+ * the captured output. Anything NOT on the allowlist — an expired or invalid
+ * cert, a notarization REJECTION, an entitlements error, a developer-agreement
+ * 403, or a real build/compile error — fails LOUD on the first attempt and is
+ * never masked by a blind retry. A retry that can hide a real failure is worse
+ * than no retry at all, because it converts a clear red into a slow flake.
+ *
+ * Usage:
+ * node retry-transient.mjs --label "electron-builder (linux)" -- pnpm exec electron-builder --linux
+ * node retry-transient.mjs --label "…" --shell -- 'pnpm run build && pnpm exec electron-builder --mac'
+ *
+ * Exit code is the command's own on success, or 1 when retries are refused or
+ * exhausted.
+ */
+
+import { spawn } from 'node:child_process';
+import { pathToFileURL } from 'node:url';
+
+export const DEFAULT_MAX_ATTEMPTS = 3;
+
+/**
+ * Extended-regex allowlist of transient infra-flake signatures, matched
+ * case-insensitively against combined stdout+stderr. Keep this list narrow:
+ * every entry must be an out-of-our-control infra flake, never a signature a
+ * real cert/notary/entitlements/build error could emit.
+ *
+ * The signing/notarization entries are macOS-only in practice but stay in the
+ * shared list — a signature that cannot match on a platform costs nothing, and
+ * per-platform lists would drift.
+ */
+export const TRANSIENT_SIGNATURES = [
+ // Apple TSA + notarization round-trips.
+ 'A timestamp was expected but was not found',
+ 'The timestamp service is not available',
+ 'HTTPError\\(statusCode: nil',
+ 'The request timed out',
+ 'NSURLErrorDomain Code=-100[13459]',
+ 'kCFErrorDomainCFNetwork',
+ // Generic transport failures, including the dropped tool/runtime downloads
+ // that abort packaging on every platform.
+ 'The network connection was lost',
+ 'Could not connect to the server',
+ 'ECONNRESET',
+ 'ETIMEDOUT',
+ 'EPIPE',
+ 'socket hang up',
+ 'Client network socket disconnected',
+ 'unexpected EOF',
+ // Upstream service degradation (GitHub asset hosts, Azure signing endpoint).
+ '502 Bad Gateway',
+ '503 Service Unavailable',
+ '504 Gateway Time-?out',
+ 'You have exceeded a secondary rate limit',
+ 'abuse detection mechanism',
+ 'was submitted too quickly',
+];
+
+const TRANSIENT_RE = new RegExp(TRANSIENT_SIGNATURES.join('|'), 'i');
+
+/** True when the captured output carries a known infra-flake signature. */
+export function isTransient(output) {
+ return TRANSIENT_RE.test(String(output ?? ''));
+}
+
+/** Matches the previous in-workflow behavior: 30s, then 60s. */
+export function backoffSeconds(attempt) {
+ return attempt * 30;
+}
+
+/**
+ * Cap on retained output. electron-builder is verbose and the whole point of
+ * retaining anything is the classification grep, which only ever needs the
+ * failure text near the end.
+ */
+const MAX_CAPTURE_BYTES = 2_000_000;
+
+function appendCapped(buffer, chunk) {
+ const next = buffer + chunk;
+ return next.length > MAX_CAPTURE_BYTES ? next.slice(next.length - MAX_CAPTURE_BYTES) : next;
+}
+
+/**
+ * Run once, streaming output to this process's stdout/stderr while capturing
+ * it for classification. Streaming is not optional: a packaging build that
+ * only surfaced its log after exiting would make a hung build undebuggable.
+ */
+function runOnce(command, { shell = false, spawnFn = spawn } = {}) {
+ return new Promise((resolve) => {
+ const child = shell
+ ? spawnFn('bash', ['-c', command[0]], { stdio: ['inherit', 'pipe', 'pipe'] })
+ : spawnFn(command[0], command.slice(1), { stdio: ['inherit', 'pipe', 'pipe'] });
+
+ let captured = '';
+ child.stdout?.on('data', (d) => {
+ const text = d.toString();
+ captured = appendCapped(captured, text);
+ process.stdout.write(text);
+ });
+ child.stderr?.on('data', (d) => {
+ const text = d.toString();
+ captured = appendCapped(captured, text);
+ process.stderr.write(text);
+ });
+
+ child.on('error', (err) => {
+ const text = `${err.message}\n`;
+ captured = appendCapped(captured, text);
+ process.stderr.write(text);
+ resolve({ code: 1, output: captured });
+ });
+ child.on('close', (code) => resolve({ code: code ?? 1, output: captured }));
+ });
+}
+
+/**
+ * Outcome shapes, all reported to the caller rather than thrown, so the CLI
+ * layer owns process exit and the tests can assert without catching:
+ * { ok: true, attempts } — succeeded
+ * { ok: false, reason: 'non-transient', … } — refused to retry
+ * { ok: false, reason: 'exhausted', … } — retried and still failed
+ */
+export async function runWithRetry({
+ command,
+ label = 'command',
+ shell = false,
+ maxAttempts = DEFAULT_MAX_ATTEMPTS,
+ spawnFn = spawn,
+ sleepFn = (s) => new Promise((r) => setTimeout(r, s * 1000)),
+ log = console.log,
+} = {}) {
+ for (let attempt = 1; ; attempt += 1) {
+ log(`::group::${label} attempt ${attempt}/${maxAttempts}`);
+ const { code, output } = await runOnce(command, { shell, spawnFn });
+ log('::endgroup::');
+
+ if (code === 0) {
+ log(`${label} succeeded on attempt ${attempt}.`);
+ return { ok: true, attempts: attempt };
+ }
+
+ if (!isTransient(output)) {
+ log(
+ `::error::${label} failed on attempt ${attempt} with a NON-transient error (no known infra-flake signature matched). Not retrying — a real signing/notarize/cert/entitlements/build failure must fail loud, not be masked. See the log above.`,
+ );
+ return { ok: false, reason: 'non-transient', attempts: attempt, code };
+ }
+
+ if (attempt >= maxAttempts) {
+ log(
+ `::error::${label} failed after ${maxAttempts} attempts; the last failure matched a transient infra signature but retries are exhausted.`,
+ );
+ return { ok: false, reason: 'exhausted', attempts: attempt, code };
+ }
+
+ const backoff = backoffSeconds(attempt);
+ log(
+ `::warning::${label} attempt ${attempt} failed with a transient infra signature; retrying in ${backoff}s (bounded transient-only retry).`,
+ );
+ await sleepFn(backoff);
+ }
+}
+
+export function parseArgs(argv) {
+ const rest = argv.slice(2);
+ const sep = rest.indexOf('--');
+ if (sep === -1) throw new Error('a `--` separator followed by the command is required');
+ const flags = rest.slice(0, sep);
+ const command = rest.slice(sep + 1);
+ if (command.length === 0) throw new Error('no command given after `--`');
+
+ const shell = flags.includes('--shell');
+ if (shell && command.length !== 1) {
+ throw new Error('--shell takes exactly one command string');
+ }
+
+ const labelIdx = flags.indexOf('--label');
+ const attemptsIdx = flags.indexOf('--max-attempts');
+ return {
+ label: labelIdx === -1 ? 'command' : (flags[labelIdx + 1] ?? 'command'),
+ maxAttempts:
+ attemptsIdx === -1 ? DEFAULT_MAX_ATTEMPTS : Number(flags[attemptsIdx + 1]) || DEFAULT_MAX_ATTEMPTS,
+ shell,
+ command,
+ };
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ // `process.exitCode`, never `process.exit()`: the latter discards whatever is
+ // still queued on stdout when stdout is a pipe, which is exactly how Actions
+ // captures step output. This module streams the whole packaging log, so a
+ // truncated tail would drop the failure text a reader needs most.
+ try {
+ const result = await runWithRetry(parseArgs(process.argv));
+ process.exitCode = result.ok ? 0 : 1;
+ } catch (err) {
+ process.stderr.write(`${err.message}\n`);
+ process.exitCode = 1;
+ }
+}
diff --git a/.github/scripts/retry-transient.test.mjs b/.github/scripts/retry-transient.test.mjs
new file mode 100644
index 000000000..f3b4811a6
--- /dev/null
+++ b/.github/scripts/retry-transient.test.mjs
@@ -0,0 +1,310 @@
+/**
+ * Behavioral proof that the retry wrapper retries the right failures and
+ * refuses the wrong ones.
+ *
+ * These drive REAL child processes rather than a stubbed spawn: the value of
+ * this wrapper is entirely in what it decides after a real command exits
+ * non-zero, and a fake spawn would let the classification pass while the
+ * process plumbing was broken.
+ */
+
+import { spawnSync } from 'node:child_process';
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { afterAll, beforeEach, describe, expect, test, vi } from 'vitest';
+import {
+ backoffSeconds,
+ DEFAULT_MAX_ATTEMPTS,
+ isTransient,
+ parseArgs,
+ runWithRetry,
+ TRANSIENT_SIGNATURES,
+} from './retry-transient.mjs';
+
+const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
+const desktopRelease = readFileSync(
+ join(REPO_ROOT, '.github', 'workflows', 'desktop-release.yml'),
+ 'utf8',
+);
+
+const scratch = mkdtempSync(join(tmpdir(), 'retry-transient-'));
+afterAll(() => rmSync(scratch, { recursive: true, force: true }));
+
+/** Silence the streamed child output; the assertions read the log lines instead. */
+beforeEach(() => {
+ vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
+ vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
+ return () => vi.restoreAllMocks();
+});
+
+const nodeCmd = (src) => ['node', '-e', src];
+
+/** Retry without the real 30s/60s waits. */
+const run = (overrides) => {
+ const lines = [];
+ return runWithRetry({
+ sleepFn: () => Promise.resolve(),
+ log: (l) => lines.push(l),
+ ...overrides,
+ }).then((result) => ({ ...result, lines, log: lines.join('\n') }));
+};
+
+describe('the retry decision', () => {
+ test('a command that succeeds runs exactly once', async () => {
+ const r = await run({ command: nodeCmd('console.log("built")') });
+ expect(r.ok).toBe(true);
+ expect(r.attempts).toBe(1);
+ });
+
+ test('a NON-transient failure fails loud on the first attempt', async () => {
+ // The whole safety property: a real signing/build error must not be
+ // retried into looking like a flake.
+ const r = await run({
+ command: nodeCmd('console.error("notarization status: Invalid");process.exit(1)'),
+ });
+ expect(r.ok).toBe(false);
+ expect(r.reason).toBe('non-transient');
+ expect(r.attempts).toBe(1);
+ expect(r.log).toContain('NON-transient');
+ });
+
+ test('a transient failure is retried and can succeed', async () => {
+ // A real counter file, so "it failed then it passed" is genuinely
+ // exercised across two separate processes.
+ const counter = join(scratch, 'flaky-count');
+ writeFileSync(counter, '0');
+ const r = await run({
+ command: nodeCmd(
+ `const fs=require('fs');const p=${JSON.stringify(counter)};` +
+ `const n=Number(fs.readFileSync(p,'utf8'))+1;fs.writeFileSync(p,String(n));` +
+ `if(n<2){console.error('⨯ socket hang up failedTask=build');process.exit(1)}` +
+ `console.log('packaged')`,
+ ),
+ });
+ expect(r.ok).toBe(true);
+ expect(r.attempts).toBe(2);
+ expect(readFileSync(counter, 'utf8')).toBe('2');
+ });
+
+ test('a permanently transient failure stops at the attempt bound', async () => {
+ const r = await run({
+ command: nodeCmd('console.error("socket hang up");process.exit(1)'),
+ maxAttempts: 3,
+ });
+ expect(r.ok).toBe(false);
+ expect(r.reason).toBe('exhausted');
+ expect(r.attempts).toBe(3);
+ expect(r.log).toContain('retries are exhausted');
+ });
+
+ test('a command that cannot be spawned at all is not retried forever', async () => {
+ const r = await run({ command: ['definitely-not-a-real-binary-xyz'], maxAttempts: 2 });
+ expect(r.ok).toBe(false);
+ // ENOENT is not an infra flake — it is a broken invocation.
+ expect(r.reason).toBe('non-transient');
+ });
+
+ test('--shell mode runs a compound command', async () => {
+ const r = await run({ command: ['true && echo composed'], shell: true });
+ expect(r.ok).toBe(true);
+ });
+});
+
+describe('the transient allowlist', () => {
+ test('matches the signature that blocked the 0.52.2 and 0.52.3 cuts', () => {
+ // Verbatim from the failed Linux packaging step.
+ expect(isTransient('⨯ socket hang up failedTask=build stackTrace=RequestError: socket hang up')).toBe(
+ true,
+ );
+ });
+
+ test('matches case-insensitively and mid-line', () => {
+ expect(isTransient('...Socket Hang Up...')).toBe(true);
+ expect(isTransient('fetch failed: ECONNRESET')).toBe(true);
+ });
+
+ test('does NOT match real build, cert, or notarization failures', () => {
+ // Each of these must fail the release loudly rather than be retried.
+ for (const real of [
+ 'error TS2345: Argument of type string is not assignable',
+ 'The specified item could not be found in the keychain',
+ 'certificate has expired',
+ 'notarization failed with status: Invalid',
+ 'Command failed with exit code 1: tsc --noEmit',
+ 'Error: Cannot find module ./missing',
+ 'ENOSPC: no space left on device',
+ ]) {
+ expect(isTransient(real), `${real} must not be treated as transient`).toBe(false);
+ }
+ });
+
+ test('handles empty and nullish output without throwing', () => {
+ expect(isTransient('')).toBe(false);
+ expect(isTransient(undefined)).toBe(false);
+ expect(isTransient(null)).toBe(false);
+ });
+
+ test('every signature is a real regex and none is so broad it matches bare text', () => {
+ for (const sig of TRANSIENT_SIGNATURES) {
+ expect(() => new RegExp(sig)).not.toThrow();
+ // A signature matching an ordinary build line would defeat the gate.
+ expect(new RegExp(sig, 'i').test('Building desktop app')).toBe(false);
+ }
+ });
+});
+
+describe('backoff', () => {
+ test('grows between attempts and stays bounded for the default attempt count', () => {
+ expect(backoffSeconds(1)).toBe(30);
+ expect(backoffSeconds(2)).toBeGreaterThan(backoffSeconds(1));
+ const total = [...Array(DEFAULT_MAX_ATTEMPTS - 1).keys()]
+ .map((i) => backoffSeconds(i + 1))
+ .reduce((a, b) => a + b, 0);
+ // Must stay well inside the packaging jobs' timeout-minutes budget.
+ expect(total).toBeLessThan(10 * 60);
+ });
+});
+
+describe('parseArgs', () => {
+ const argv = (...rest) => ['node', 'x', ...rest];
+
+ test('splits flags from the command at `--`', () => {
+ const p = parseArgs(argv('--label', 'pkg (linux)', '--', 'pnpm', 'exec', 'electron-builder'));
+ expect(p.label).toBe('pkg (linux)');
+ expect(p.command).toEqual(['pnpm', 'exec', 'electron-builder']);
+ expect(p.shell).toBe(false);
+ expect(p.maxAttempts).toBe(DEFAULT_MAX_ATTEMPTS);
+ });
+
+ test('a flag-looking token after `--` belongs to the command', () => {
+ const p = parseArgs(argv('--', 'pnpm', 'exec', 'electron-builder', '--linux', '--publish', 'never'));
+ expect(p.command).toContain('--linux');
+ expect(p.command).toContain('never');
+ });
+
+ test('requires a separator and a command', () => {
+ expect(() => parseArgs(argv('--label', 'x'))).toThrow(/--/);
+ expect(() => parseArgs(argv('--label', 'x', '--'))).toThrow(/no command/);
+ });
+
+ test('--shell demands exactly one command string', () => {
+ expect(() => parseArgs(argv('--shell', '--', 'a', 'b'))).toThrow(/exactly one/);
+ expect(parseArgs(argv('--shell', '--', 'a && b')).shell).toBe(true);
+ });
+});
+
+describe('workflow wiring', () => {
+ /** The `- name:` block of a step, up to the next sibling step. */
+ const step = (needle) => {
+ const rest = desktopRelease.slice(desktopRelease.indexOf(`- name: ${needle}`));
+ const end = rest.indexOf('\n - name: ');
+ return end === -1 ? rest : rest.slice(0, end);
+ };
+
+ // Every platform that packages an installer. The 0.52.2/0.52.3 incident was
+ // Linux; the same un-retried exposure existed on Windows.
+ const PACKAGING_STEPS = [
+ 'Build + sign + notarize DMG/ZIP',
+ 'Package NSIS installers',
+ 'Package ${{ matrix.targets }}',
+ ];
+
+ test.each(PACKAGING_STEPS)('%s routes through the shared retry wrapper', (name) => {
+ expect(step(name)).toContain('.github/scripts/retry-transient.mjs');
+ });
+
+ test.each(PACKAGING_STEPS)('%s defines its packaging command exactly once', (name) => {
+ // One definition, executed either through the wrapper or through the
+ // explicit no-retry fallback. A second `pnpm exec electron-builder` line
+ // would be an un-wrapped invocation reopening the gap for that platform.
+ const invocations = step(name)
+ .split('\n')
+ .filter((l) => !/^\s*#/.test(l))
+ .filter((l) => l.includes('pnpm exec electron-builder'));
+ expect(invocations).toHaveLength(1);
+ expect(invocations[0]).toMatch(/^\s*PKG_CMD=/);
+ });
+
+ test.each(PACKAGING_STEPS)('%s runs that command through the wrapper', (name) => {
+ const body = step(name);
+ expect(body).toContain('node "$WRAPPER"');
+ expect(body).toContain('--shell -- "$PKG_CMD"');
+ });
+
+ test.each(PACKAGING_STEPS)('%s still packages when the wrapper is absent', (name) => {
+ // The packaging jobs check out the RELEASE TAG, which can predate this
+ // wrapper — promote-stable tags stable at the soaked beta's SHA. Blocking
+ // on a missing CI helper would make every already-cut tag unreleasable.
+ const body = step(name);
+ expect(body).toContain('git -C "${GITHUB_WORKSPACE}" fetch --depth=1 origin "$GITHUB_SHA"');
+ expect(body).toContain('bash -c "$PKG_CMD"');
+ expect(body).toContain('::warning::Retry wrapper absent');
+ });
+
+ test('the retry allowlist is not duplicated back into the workflow', () => {
+ // The point of extracting it is one source of truth; an inline copy would
+ // drift from the tested one.
+ expect(desktopRelease).not.toContain('transient_signatures=');
+ });
+
+ /**
+ * The assertions above read YAML TEXT, so they pass whether or not the
+ * fallback is reachable. Actions runs every step under errexit, and bash
+ * exempts only the NON-final commands of an `&&` list — so a failing
+ * `git checkout` at the end of one exits the shell before the fallback runs,
+ * silently (the checkout is `2>/dev/null`). These execute the real snippet.
+ */
+ const preamble = (name) => {
+ const body = step(name);
+ const start = body.indexOf('WRAPPER="');
+ const end = body.indexOf('PKG_CMD=');
+ expect(start, `${name}: WRAPPER= not found`).toBeGreaterThan(-1);
+ expect(end, `${name}: PKG_CMD= not found`).toBeGreaterThan(start);
+ return body.slice(start, end);
+ };
+
+ /** Runs a snippet the way Actions does, with git stubbed to the failure shape. */
+ let snippetSeq = 0;
+ const runUnderErrexit = (snippet) => {
+ const file = join(scratch, `preamble-${(snippetSeq += 1)}.sh`);
+ writeFileSync(
+ file,
+ [
+ // The reachable real-world shape: on a rebuild of an old tag the commit
+ // is already present so `fetch` succeeds, while `checkout` fails because
+ // the path does not exist at that ref.
+ 'git() { case "$*" in *checkout*) return 1 ;; *) return 0 ;; esac; }',
+ 'GITHUB_WORKSPACE=/nonexistent-workspace',
+ 'GITHUB_SHA=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
+ snippet,
+ 'echo REACHED_FALLBACK',
+ ].join('\n'),
+ );
+ return spawnSync('bash', ['--noprofile', '--norc', '-eo', 'pipefail', file], {
+ encoding: 'utf8',
+ });
+ };
+
+ test.each(PACKAGING_STEPS)('%s reaches its fallback when sourcing fails', (name) => {
+ const r = runUnderErrexit(preamble(name));
+ expect(r.status, `sourcing failure must not abort the step:\n${r.stderr}`).toBe(0);
+ expect(r.stdout).toContain('REACHED_FALLBACK');
+ });
+
+ test('the errexit harness actually discriminates (mutation control)', () => {
+ // The pre-fix shape, inline. If this passed, the tests above would prove
+ // nothing — they would be satisfied by a snippet that aborts the step.
+ const unExempt = [
+ 'WRAPPER="/nonexistent/retry-transient.mjs"',
+ 'if [[ ! -f "$WRAPPER" ]]; then',
+ ' git fetch --depth=1 origin "$GITHUB_SHA" >/dev/null 2>&1 &&',
+ ' git checkout "$GITHUB_SHA" -- .github/scripts/retry-transient.mjs 2>/dev/null',
+ 'fi',
+ ].join('\n');
+ const r = runUnderErrexit(unExempt);
+ expect(r.status).not.toBe(0);
+ expect(r.stdout).not.toContain('REACHED_FALLBACK');
+ });
+});
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index ad0c8bc91..964d44095 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -698,70 +698,52 @@ jobs:
# the workspace-wide on-disk override step above is what makes
# them match the tag. See PRD-6650.
#
- # Retry the build on TRANSIENT signing/notarize/download failures
- # only. All of these are infrastructure flakes outside our control
- # that leave no durable artifact and clear on a re-run:
- # - codesign's timestamp step calling Apple's TSA (timestamp.apple.com)
- # returning "A timestamp was expected but was not found" or the TSA
- # being unavailable. This is the class that stuck v0.30.2 as a draft
- # (run 29445364406): each `codesign --timestamp` is a single, un-retried
- # shell-out inside electron-builder, so a dropped TSA response aborts
- # the whole build. electron-builder has NO knob to retry it — the only
- # lever we have is re-running the whole invocation.
+ # Packaging is retried on TRANSIENT signing/notarize/download failures
+ # only, through the shared wrapper. The macOS-specific classes it
+ # covers, none of which electron-builder will retry itself:
+ # - codesign's timestamp step calling Apple's TSA (timestamp.apple.com).
+ # Each `codesign --timestamp` is a single un-retried shell-out, so a
+ # dropped TSA response aborts the whole build. This is the class that
+ # stuck v0.30.2 as a draft (run 29445364406).
# - @electron/notarize's notarytool HTTP round-trip to
# appstoreconnect.apple.com timing out (NSURLError -1001 /
- # HTTPError(statusCode: nil)). This is what failed attempt 1 of the
- # same run before the TSA flake killed attempt 2.
+ # HTTPError(statusCode: nil)), which failed attempt 1 of that same run.
# - a bare EOF fetching the Electron runtime zip during packaging
# (app-builder's DownloadNoRetry path aborts on one dropped connection).
- # (The GitHub-upload signatures that used to sit alongside these are
- # kept in the allowlist for the day uploads ever return here, but
- # can no longer match — this invocation performs no uploads; the
- # fan-in publish-assets job owns upload retries now.)
- #
- # CRITICAL: retry is gated on a transient-signature allowlist matched
- # against the captured build output. Anything NOT on the allowlist — an
- # expired/invalid cert, a notarization REJECTION (status Invalid), an
- # entitlements error, an Apple developer-agreement 403, or a real
- # build/compile error — is a hard failure that fails LOUD on the first
- # attempt and is never masked by a blind retry.
+ # Re-running the whole invocation is the only lever available. The
+ # allowlist that gates the retry — and the guarantee that a real
+ # cert/notary/entitlements/build failure fails LOUD on the first attempt
+ # rather than being masked — lives in the wrapper.
set -uo pipefail
- # Extended-regex allowlist of transient infra-flake signatures (matched
- # case-insensitively against combined stdout+stderr). Keep this list
- # narrow: every entry must be an out-of-our-control infra flake, never a
- # signature a real cert/notary/entitlements/build error could emit.
- transient_signatures='A timestamp was expected but was not found|The timestamp service is not available|HTTPError\(statusCode: nil|The request timed out|NSURLErrorDomain Code=-100[13459]|kCFErrorDomainCFNetwork|The network connection was lost|Could not connect to the server|ECONNRESET|ETIMEDOUT|EPIPE|socket hang up|Client network socket disconnected|unexpected EOF|502 Bad Gateway|503 Service Unavailable|504 Gateway Time-?out|You have exceeded a secondary rate limit|abuse detection mechanism|was submitted too quickly'
- attempt=1
- max_attempts=3
- while true; do
- echo "::group::electron-builder attempt ${attempt}/${max_attempts}"
- attempt_log="${RUNNER_TEMP:-/tmp}/electron-builder-attempt-${attempt}.log"
- # `pipefail` (set above) makes the `if` see the electron-builder exit
- # code through `tee`; tee mirrors output to the CI log AND captures it
- # for the transient-vs-real classification below.
- if { pnpm run build:desktop && pnpm exec electron-builder --mac --publish never \
- --config.extraMetadata.version="${BUILD_VERSION}" \
- --config.publish.channel="${BUILD_CHANNEL}" ; } 2>&1 | tee "${attempt_log}"; then
- echo "::endgroup::"
- echo "electron-builder succeeded on attempt ${attempt}."
- break
+ # The wrapper is CI tooling, not release content, so take it from the
+ # workflow's own SHA when the release checkout predates it — same
+ # reasoning as the smoke harness below. This is not a rare path:
+ # promote-stable tags the stable at the soaked beta's SHA, which is by
+ # definition older than any fix landed since. Best-effort: if it cannot
+ # be obtained, package WITHOUT retry rather than block the release.
+ WRAPPER="${GITHUB_WORKSPACE}/.github/scripts/retry-transient.mjs"
+ if [[ ! -f "$WRAPPER" ]]; then
+ # The fetch/checkout pair sits in an `if` CONDITION deliberately.
+ # Steps run under errexit, and bash exempts only the NON-final
+ # commands of an `&&` list — so a bare failing checkout would exit
+ # the shell before reaching the fallback below, defeating the
+ # best-effort behavior this exists for. A condition is exempt.
+ if git -C "${GITHUB_WORKSPACE}" fetch --depth=1 origin "$GITHUB_SHA" >/dev/null 2>&1 &&
+ git -C "${GITHUB_WORKSPACE}" checkout "$GITHUB_SHA" -- .github/scripts/retry-transient.mjs 2>/dev/null; then
+ echo "::notice::Retry wrapper taken from ${GITHUB_SHA} rather than the release ref."
fi
- echo "::endgroup::"
- # Fail hard on anything that is NOT a known transient infra flake so a
- # real cert/notary/entitlements/build failure is never hidden by a retry.
- if ! grep -qiE "${transient_signatures}" "${attempt_log}"; then
- echo "::error::electron-builder failed on attempt ${attempt} with a NON-transient error (no known infra-flake signature matched). Not retrying — a real signing/notarize/cert/entitlements/build failure must fail loud, not be masked. See the log above."
- exit 1
- fi
- if [ "${attempt}" -ge "${max_attempts}" ]; then
- echo "::error::electron-builder failed after ${max_attempts} attempts; the last failure matched a transient signing/notarize signature but retries are exhausted."
- exit 1
- fi
- backoff=$((attempt * 30))
- echo "::warning::electron-builder attempt ${attempt} failed with a transient infra signature; retrying in ${backoff}s (bounded transient-only retry)."
- sleep "${backoff}"
- attempt=$((attempt + 1))
- done
+ fi
+ # Defined once, single-quoted ON PURPOSE: it is handed to the wrapper as
+ # a literal string and expanded by the inner shell, which inherits this
+ # step's env. Expanding here would bake attempt 1's values into retries.
+ # shellcheck disable=SC2016
+ PKG_CMD='pnpm run build:desktop && pnpm exec electron-builder --mac --publish never --config.extraMetadata.version="${BUILD_VERSION}" --config.publish.channel="${BUILD_CHANNEL}"'
+ if [[ -f "$WRAPPER" ]]; then
+ node "$WRAPPER" --label "electron-builder (macOS)" --shell -- "$PKG_CMD"
+ else
+ echo "::warning::Retry wrapper absent at this ref; packaging without transient retry."
+ bash -c "$PKG_CMD"
+ fi
# FR5b — smoke the signed DMG before anything about this release becomes
# visible or installable. Under the fan-in topology this job failing on
@@ -979,13 +961,31 @@ jobs:
exit 1
fi
echo "::notice::Azure Trusted Signing credentials present — building SIGNED installers."
- pnpm exec electron-builder --win --publish never \
- --config.extraMetadata.version="${BUILD_VERSION}" \
- --config.publish.channel="${BUILD_CHANNEL}" \
- --config.win.azureSignOptions.endpoint="${AZURE_SIGNING_ENDPOINT}" \
- --config.win.azureSignOptions.codeSigningAccountName="${AZURE_SIGNING_ACCOUNT}" \
- --config.win.azureSignOptions.certificateProfileName="${AZURE_SIGNING_PROFILE}" \
- --config.win.azureSignOptions.publisherName="${AZURE_SIGNING_PUBLISHER}"
+ # Signing here is a network round-trip to the Azure Trusted Signing
+ # endpoint, so this invocation carries the same transient exposure the
+ # macOS job does. The wrapper still fails loud on a real signing
+ # rejection or build error — only allowlisted infra flakes retry.
+ # Wrapper sourcing + single-quoting rationale: see the macOS step.
+ WRAPPER="${GITHUB_WORKSPACE}/.github/scripts/retry-transient.mjs"
+ if [[ ! -f "$WRAPPER" ]]; then
+ # The fetch/checkout pair sits in an `if` CONDITION deliberately.
+ # Steps run under errexit, and bash exempts only the NON-final
+ # commands of an `&&` list — so a bare failing checkout would exit
+ # the shell before reaching the fallback below, defeating the
+ # best-effort behavior this exists for. A condition is exempt.
+ if git -C "${GITHUB_WORKSPACE}" fetch --depth=1 origin "$GITHUB_SHA" >/dev/null 2>&1 &&
+ git -C "${GITHUB_WORKSPACE}" checkout "$GITHUB_SHA" -- .github/scripts/retry-transient.mjs 2>/dev/null; then
+ echo "::notice::Retry wrapper taken from ${GITHUB_SHA} rather than the release ref."
+ fi
+ fi
+ # shellcheck disable=SC2016
+ PKG_CMD='pnpm exec electron-builder --win --publish never --config.extraMetadata.version="${BUILD_VERSION}" --config.publish.channel="${BUILD_CHANNEL}" --config.win.azureSignOptions.endpoint="${AZURE_SIGNING_ENDPOINT}" --config.win.azureSignOptions.codeSigningAccountName="${AZURE_SIGNING_ACCOUNT}" --config.win.azureSignOptions.certificateProfileName="${AZURE_SIGNING_PROFILE}" --config.win.azureSignOptions.publisherName="${AZURE_SIGNING_PUBLISHER}"'
+ if [[ -f "$WRAPPER" ]]; then
+ node "$WRAPPER" --label "electron-builder (Windows)" --shell -- "$PKG_CMD"
+ else
+ echo "::warning::Retry wrapper absent at this ref; packaging without transient retry."
+ bash -c "$PKG_CMD"
+ fi
# Fail before staging an installer that cannot start. An asar packed
# without `node_modules` produces a binary that dies on its first bare
@@ -1193,9 +1193,35 @@ jobs:
# emulation or system fpm is involved.
- name: Package ${{ matrix.targets }}
working-directory: packages/desktop
+ env:
+ LINUX_TARGETS: ${{ matrix.targets }}
run: |
- pnpm exec electron-builder --linux ${{ matrix.targets }} --publish never \
- --config electron-builder.release-linux.yml
+ # electron-builder downloads its fpm packaging backend on first use,
+ # and a dropped connection there aborts the whole build. That is what
+ # blocked the v0.52.2 and v0.52.3 cuts, on a step that had no retry
+ # while the macOS job had carried one for months.
+ set -uo pipefail
+ # Wrapper sourcing + single-quoting rationale: see the macOS step.
+ WRAPPER="${GITHUB_WORKSPACE}/.github/scripts/retry-transient.mjs"
+ if [[ ! -f "$WRAPPER" ]]; then
+ # The fetch/checkout pair sits in an `if` CONDITION deliberately.
+ # Steps run under errexit, and bash exempts only the NON-final
+ # commands of an `&&` list — so a bare failing checkout would exit
+ # the shell before reaching the fallback below, defeating the
+ # best-effort behavior this exists for. A condition is exempt.
+ if git -C "${GITHUB_WORKSPACE}" fetch --depth=1 origin "$GITHUB_SHA" >/dev/null 2>&1 &&
+ git -C "${GITHUB_WORKSPACE}" checkout "$GITHUB_SHA" -- .github/scripts/retry-transient.mjs 2>/dev/null; then
+ echo "::notice::Retry wrapper taken from ${GITHUB_SHA} rather than the release ref."
+ fi
+ fi
+ # shellcheck disable=SC2016
+ PKG_CMD='pnpm exec electron-builder --linux ${LINUX_TARGETS} --publish never --config electron-builder.release-linux.yml'
+ if [[ -f "$WRAPPER" ]]; then
+ node "$WRAPPER" --label "electron-builder (Linux ${LINUX_TARGETS})" --shell -- "$PKG_CMD"
+ else
+ echo "::warning::Retry wrapper absent at this ref; packaging without transient retry."
+ bash -c "$PKG_CMD"
+ fi
# Fail before staging an installer that cannot start (see the Windows
# step for the full rationale). This is the control that would have
@@ -1805,18 +1831,62 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SMOKE_VERDICT: ${{ needs.build-macos.outputs.smoke_verdict }}
SMOKE_REASON: ${{ needs.build-macos.outputs.smoke_reason }}
+ RESULT_PREPARE: ${{ needs.prepare.result }}
+ RESULT_MACOS: ${{ needs.build-macos.result }}
+ RESULT_WINDOWS: ${{ needs.build-windows.result }}
+ RESULT_LINUX: ${{ needs.build-linux.result }}
+ RESULT_PUBLISH: ${{ needs.publish-assets.result }}
+ RESULT_FINALIZE: ${{ needs.finalize.result }}
+ # Under the escape valve a NON-required platform can fail while
+ # publish-assets and finalize still run, so platform failures are only
+ # blockers when the platform is actually required.
+ REQUIRED_PLATFORMS: ${{ needs.prepare.outputs.required }}
run: |
set -uo pipefail
# A skipped gate (ref predates the harness) is not a blocked release,
- # and neither is a failure before the DMG was even built — or a
- # Windows/Linux packaging failure, where the smoke never speaks at
- # all. All of those leave the verdict empty or 'skipped'; report
- # them as `error` so the message never implies the app itself
- # failed a test it never ran.
- VERDICT="${SMOKE_VERDICT:-}"
- if [[ "$VERDICT" != "fail" ]]; then
+ # and neither is a failure before the DMG was even built. Both leave
+ # the verdict empty or 'skipped'; report those as `error` so the
+ # message never implies the app failed a test it never ran.
+ #
+ # A PASS is passed through untouched. The packaging jobs are
+ # independent, so Linux or Windows can fail while the smoke runs to a
+ # clean pass — coercing that to `error` is what produced pages reading
+ # "DMG smoke ERRORED — all 13 executed smoke tests passed".
+ VERDICT="${SMOKE_VERDICT:-error}"
+ if [[ "$VERDICT" == "skipped" || -z "$VERDICT" ]]; then
VERDICT="error"
fi
+ # Name the jobs that actually FAILED. Downstream jobs that merely
+ # skipped are consequences, not causes, so they are not listed.
+ #
+ # A platform counts only when it is REQUIRED for this cut: under the
+ # escape valve a non-required platform can fail while publish-assets
+ # and finalize still run, and naming it would send the responder to a
+ # job that was correctly excluded from the publish decision — and
+ # would mask a genuine finalize failure behind it.
+ REQUIRED="${REQUIRED_PLATFORMS:-mac,windows,linux}"
+ is_required() { case ",${REQUIRED}," in *",$1,"*) return 0 ;; *) return 1 ;; esac; }
+ blocked=()
+ [[ "${RESULT_PREPARE}" == "failure" ]] && blocked+=("release preparation")
+ if [[ "${RESULT_MACOS}" == "failure" ]] && is_required mac; then
+ blocked+=("macOS packaging")
+ fi
+ if [[ "${RESULT_WINDOWS}" == "failure" ]] && is_required windows; then
+ blocked+=("Windows packaging")
+ fi
+ if [[ "${RESULT_LINUX}" == "failure" ]] && is_required linux; then
+ blocked+=("Linux packaging")
+ fi
+ [[ "${RESULT_PUBLISH}" == "failure" ]] && blocked+=("asset publication")
+ # finalize is the alert's own trigger, so it is only worth naming when
+ # nothing blocking upstream failed — otherwise every page would list it.
+ if [[ ${#blocked[@]} -eq 0 && "${RESULT_FINALIZE}" == "failure" ]]; then
+ blocked+=("finalize")
+ fi
+ BLOCKED_BY=""
+ for b in ${blocked[@]+"${blocked[@]}"}; do
+ BLOCKED_BY="${BLOCKED_BY:+${BLOCKED_BY}, }${b}"
+ done
REASON="${SMOKE_REASON:-the release pipeline failed before completing — see the run}"
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
post() {
@@ -1830,13 +1900,14 @@ jobs:
# workflow's own copy when it exists at all.
if [[ -f .github/scripts/build-smoke-alert-payload.mjs ]]; then
payload="$(node .github/scripts/build-smoke-alert-payload.mjs --tag "$RELEASE_TAG" \
- --verdict "$VERDICT" --reason "$REASON" --run-url "$RUN_URL" || true)"
+ --verdict "$VERDICT" --reason "$REASON" --run-url "$RUN_URL" \
+ --blocked-by "$BLOCKED_BY" || true)"
fi
if [[ -z "$payload" ]]; then
# Never go silent. Losing the formatting is a degradation; losing
# the page is the outage this step exists to prevent.
echo "::warning::Smoke-alert payload builder unavailable for ${RELEASE_TAG}; sending the plain-text alert."
- payload="$(jq -nc --arg t "🚨 RELEASE BLOCKED: ${RELEASE_TAG} pipeline ${VERDICT} — nothing shipped. ${REASON} ${RUN_URL}" '{text: $t}')"
+ payload="$(jq -nc --arg t "🚨 RELEASE BLOCKED: ${RELEASE_TAG} — ${BLOCKED_BY:-pipeline ${VERDICT}} — nothing shipped. ${REASON} ${RUN_URL}" '{text: $t}')"
fi
# The failing curl sits in an `if` condition, so a webhook outage
# routes to the warning instead of masking the failure.
@@ -1850,7 +1921,7 @@ jobs:
post "${SLACK_RELEASES_WEBHOOK_URL:-${SLACK_WEBHOOK_URL:-}}" Slack
# The annotation is emitted IN ADDITION to the page, so the run page
# tells the same story as the channel.
- echo "::error::RELEASE BLOCKED: ${RELEASE_TAG} pipeline ${VERDICT} — ${REASON}. The Release stays a draft and npm latest is untouched."
+ echo "::error::RELEASE BLOCKED: ${RELEASE_TAG} — ${BLOCKED_BY:-pipeline ${VERDICT}} — ${REASON}. The Release stays a draft and npm latest is untouched."
# Lightweight discoverability for stuck-draft state. NOT a substitute
# for full paging observability — this is a zero-cost log marker that
diff --git a/knip.config.ts b/knip.config.ts
index f9179f2d4..78162ec09 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -123,9 +123,7 @@ 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'],
diff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.ts
index dfd95ef49..d7a845280 100644
--- a/packages/core/src/bridge/bind-frontmatter-doc.ts
+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts
@@ -1,4 +1,3 @@
-
import type * as Y from 'yjs';
import type { Err, Ok, Result } from '../config/result.ts';
import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';
diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.ts
index 8bfdb40cd..005627195 100644
--- a/packages/core/src/bridge/bridge-invariant.ts
+++ b/packages/core/src/bridge/bridge-invariant.ts
@@ -1,4 +1,3 @@
-
import { fnv1aDigest } from './hash-util.ts';
export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';
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 01ef76a9f..8fb428b90 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/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.ts
index 463e89595..9d9c244b0 100644
--- a/packages/core/src/bridge/growth-detect.ts
+++ b/packages/core/src/bridge/growth-detect.ts
@@ -1,4 +1,3 @@
-
const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;
export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;
diff --git a/packages/core/src/bridge/intraline-predicate.ts b/packages/core/src/bridge/intraline-predicate.ts
index 0939885bb..c43fdd7e7 100644
--- a/packages/core/src/bridge/intraline-predicate.ts
+++ b/packages/core/src/bridge/intraline-predicate.ts
@@ -1,4 +1,3 @@
-
export function rawLineCounts(doc: string): Map<string, number> {
const counts = new Map<string, number>();
for (const line of doc.split('\n')) {
diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.ts
index c0dc65705..251560a35 100644
--- a/packages/core/src/bridge/merge-three-way.ts
+++ b/packages/core/src/bridge/merge-three-way.ts
@@ -65,7 +65,6 @@ export function tryLineLevelCombine(
return { clean: true, merged };
}
-
export type BridgeMergeContentLossSide = 'user' | 'agent';
export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';
diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.ts
index dcc5b0690..01ac80099 100644
--- a/packages/core/src/bridge/normalize.ts
+++ b/packages/core/src/bridge/normalize.ts
@@ -1,4 +1,3 @@
-
import { stripFrontmatter } from '../extensions/frontmatter.ts';
import { bodyEdgeEmpties } from './doc-boundary-space.ts';
diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.ts
index 0be5203e4..754dc5cc2 100644
--- a/packages/core/src/bridge/pm-structural-equivalence.ts
+++ b/packages/core/src/bridge/pm-structural-equivalence.ts
@@ -32,7 +32,6 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };
const BR_LITERAL_RE = /^<br\s*\/?>$/i;
-
interface DegradeEntry {
readonly label: string;
readonly severity: ToleranceClassSeverity;
@@ -128,7 +127,6 @@ export interface ComparePmStructuralOptions {
ignoreAttrs?: (attrKey: string) => boolean;
}
-
/** Rebuild a node with `fn` applied to each child; identity when childless.
* Shared by the degrade canonicalizers so none re-implements the walk. */
function mapChildren(
@@ -250,7 +248,6 @@ function applyDegrades(tree: PmStructuralNode): {
return { normalized: current, fired };
}
-
export function comparePmStructural(
expected: PmStructuralNode,
actual: PmStructuralNode,
diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.ts
index dca644141..af20de1e2 100644
--- a/packages/core/src/bridge/subsequence.ts
+++ b/packages/core/src/bridge/subsequence.ts
@@ -1,4 +1,3 @@
-
/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):
* insertions in `haystack` are free; any dropped or substituted `needle` byte
* fails. */
diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.ts
index a363dfd54..83d47404a 100644
--- a/packages/core/src/markdown/callout-transformer.ts
+++ b/packages/core/src/markdown/callout-transformer.ts
@@ -1,4 +1,3 @@
-
import type { Blockquote, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/code-fence.ts b/packages/core/src/markdown/code-fence.ts
index 4499dbc92..9807a7e82 100644
--- a/packages/core/src/markdown/code-fence.ts
+++ b/packages/core/src/markdown/code-fence.ts
@@ -1,4 +1,3 @@
-
export function selectFenceChar(info: string): '`' | '~' {
return info.includes('`') ? '~' : '`';
}
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index 34704165b..7415c474a 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/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.ts
index b6299a948..ece5c02a1 100644
--- a/packages/core/src/markdown/dedent-block-jsx-close.ts
+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts
@@ -1,4 +1,3 @@
-
import { findFencedRegions, isInsideFence } from './fence-regions.ts';
const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;
diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.ts
index acd398aa6..54774764a 100644
--- a/packages/core/src/markdown/details-accordion-promoter.ts
+++ b/packages/core/src/markdown/details-accordion-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/div-align-promoter.ts b/packages/core/src/markdown/div-align-promoter.ts
index ba9b56384..43ecdc709 100644
--- a/packages/core/src/markdown/div-align-promoter.ts
+++ b/packages/core/src/markdown/div-align-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';
import type { MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.ts
index 4513da9bb..6d3f3643e 100644
--- a/packages/core/src/markdown/fence-regions.ts
+++ b/packages/core/src/markdown/fence-regions.ts
@@ -1,4 +1,3 @@
-
const FENCE_RE = /^(`{3,}|~{3,})/gm;
export function findFencedRegions(src: string): Array<[number, number]> {
diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.ts
index 6931623c7..00f5771ee 100644
--- a/packages/core/src/markdown/fixtures/index.ts
+++ b/packages/core/src/markdown/fixtures/index.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -9,7 +8,6 @@ function fixturePath(...segments: string[]): string {
return resolve(FIXTURES_DIR, ...segments);
}
-
interface GfmExample {
section: string;
markdown: string;
@@ -19,7 +17,6 @@ export function loadGfmExamples(): GfmExample[] {
return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];
}
-
interface MdxCrashEntry {
id: string;
input: string;
@@ -71,7 +68,6 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {
) as LargeEmbedFixture[];
}
-
export function loadPrd6955Before(): string {
return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');
}
@@ -80,7 +76,6 @@ export function loadPrd6955CorruptedTriplicated(): string {
return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');
}
-
export interface NgPinnedCase {
id: string;
name: string;
@@ -97,7 +92,6 @@ export function loadNgPinnedCases(): NgPinnedCase[] {
) as NgPinnedCase[];
}
-
export function loadLargeRealistic(): string {
return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');
}
diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.ts
index daa3ef82b..8b1eb8519 100644
--- a/packages/core/src/markdown/fixtures/perf/generate.ts
+++ b/packages/core/src/markdown/fixtures/perf/generate.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -11,7 +10,6 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;
const SEED = 0xf1de1117;
-
function mulberry32(seed: number): () => number {
let a = seed >>> 0;
return () => {
@@ -38,7 +36,6 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {
return items[items.length - 1][0];
}
-
const WORDS = [
'lorem',
'ipsum',
@@ -156,7 +153,6 @@ function mdxBlock(rand: () => number): string {
return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;
}
-
type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';
const MIX: readonly [BlockKind, number][] = [
@@ -195,7 +191,6 @@ function generateDocument(blockCount: number, seed: number): string {
return `${blocks.join('\n\n')}\n`;
}
-
function main(): void {
for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {
const doc = generateDocument(count, SEED);
diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.ts
index 32c055c5b..420dc0fe5 100644
--- a/packages/core/src/markdown/guard-flanking-matrix.ts
+++ b/packages/core/src/markdown/guard-flanking-matrix.ts
@@ -7,7 +7,6 @@ import {
import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';
import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';
-
export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;
export type FlankClass = 'whitespace' | 'punctuation' | 'other';
diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.ts
index 283913255..2653473da 100644
--- a/packages/core/src/markdown/handler-shadow-audit.ts
+++ b/packages/core/src/markdown/handler-shadow-audit.ts
@@ -1,4 +1,3 @@
-
export interface HandlerShadowWitness {
input: string;
expect: 'byte' | 'byte-and-reparse-type';
diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.ts
index 5d1000cc4..da0a81d23 100644
--- a/packages/core/src/markdown/highlight-promoter.ts
+++ b/packages/core/src/markdown/highlight-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.ts
index 9681c0056..787315157 100644
--- a/packages/core/src/markdown/html-to-mdast.ts
+++ b/packages/core/src/markdown/html-to-mdast.ts
@@ -1,4 +1,3 @@
-
import type { Element as HastElement, Root as HastRoot } from 'hast';
import type { List, Nodes as MdastNodes, Root as MdastRoot } from 'mdast';
import rehypeParse from 'rehype-parse';
@@ -129,8 +128,7 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRo
throw new HtmlPayloadTooLargeError(html.length, maxBytes);
}
- const processor = unified()
- .use(rehypeParse, { fragment: true });
+ const processor = unified().use(rehypeParse, { fragment: true });
for (const plugin of cleanupPlugins) {
processor.use(plugin);
diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.ts
index 994eb6917..706fa9afb 100644
--- a/packages/core/src/markdown/image-promoter.ts
+++ b/packages/core/src/markdown/image-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Image, Paragraph, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.ts
index ec1ac1b7e..779e27500 100644
--- a/packages/core/src/markdown/index.ts
+++ b/packages/core/src/markdown/index.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromPmMark,
@@ -207,7 +206,6 @@ export class MarkdownManager {
}
}
-
const registry = createRegistry();
function destructureAttrs(
@@ -256,7 +254,6 @@ function destructureAttrs(
return result;
}
-
function hasDirtyDescendant(node: PmNode): boolean {
let found = false;
node.descendants((child) => {
@@ -279,7 +276,6 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChec
return freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;
}
-
function isEmptyMdastParagraph(node: MdastNodes): boolean {
if (node.type !== 'paragraph') return false;
const children = node.children ?? [];
@@ -348,7 +344,6 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {
return out;
}
-
import {
AUDIO_EXTENSIONS,
FILE_ATTACHMENT_EXTENSIONS,
@@ -601,7 +596,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.emphasis) {
handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({
sourceDelimiter: node.data?.sourceDelimiter ?? '*',
@@ -682,7 +676,6 @@ function buildMdastToPmHandlers(
}));
}
-
if (m.link) {
const sourceLiteralMark = m.sourceLiteral;
handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {
@@ -980,7 +973,6 @@ function buildMdastToPmHandlers(
};
}
-
const blockUnknownHandler = (node: {
type: string;
position?: { start: { offset: number }; end: { offset: number } };
@@ -1106,7 +1098,6 @@ function buildMdastToPmHandlers(
return handlers as RemarkProseMirrorOptions['handlers'];
}
-
function buildPmToMdastHandlers(
schema: Schema,
freshness: FreshnessCheckerHolder,
diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.ts
index b79e9aef7..fa0be9e86 100644
--- a/packages/core/src/markdown/lint/applies-to.ts
+++ b/packages/core/src/markdown/lint/applies-to.ts
@@ -1,4 +1,3 @@
-
import picomatch from 'picomatch';
import { SUPPORTED_DOC_EXTENSIONS } from '../../constants/doc-extensions.ts';
diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.ts
index 94b34dee1..312c9c74b 100644
--- a/packages/core/src/markdown/lint/config-files.ts
+++ b/packages/core/src/markdown/lint/config-files.ts
@@ -1,4 +1,3 @@
-
const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set([
'.markdownlint.json',
'.markdownlint.jsonc',
diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.ts
index 1e3ad29c6..c400441b2 100644
--- a/packages/core/src/markdown/lint/config-schemas.ts
+++ b/packages/core/src/markdown/lint/config-schemas.ts
@@ -39,7 +39,6 @@ const fullPluginShape = Object.fromEntries(
LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),
) as z.ZodRawShape;
-
export const LinterConfigSchema = z.object({
enabled: z.boolean(),
plugins: z.object(fullPluginShape),
diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.ts
index a51f2ffb0..d48eea5e4 100644
--- a/packages/core/src/markdown/lint/default-config.ts
+++ b/packages/core/src/markdown/lint/default-config.ts
@@ -6,7 +6,6 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSetting
MD013: false,
};
-
export function resolveMarkdownlintConfig(
rules: Record<string, MarkdownlintRuleSetting> | undefined,
): Configuration {
diff --git a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
index 9c9542661..ef478e268 100644
--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts
@@ -1,4 +1,3 @@
-
import { CANONICAL_SCHEMA_DIALECT_URIS, DEFAULT_SCHEMA_DIALECT } from './frontmatter-validate.ts';
export interface FrontmatterFieldConstraint {
diff --git a/packages/core/src/markdown/lint/frontmatter-validate.ts b/packages/core/src/markdown/lint/frontmatter-validate.ts
index b96d19182..0d4c9a0df 100644
--- a/packages/core/src/markdown/lint/frontmatter-validate.ts
+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts
@@ -1,4 +1,3 @@
-
import Ajv, { type ValidateFunction } from 'ajv';
import Ajv2019 from 'ajv/dist/2019.js';
import Ajv2020 from 'ajv/dist/2020.js';
diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.ts
index 1ca263610..af38c2ae2 100644
--- a/packages/core/src/markdown/lint/index.ts
+++ b/packages/core/src/markdown/lint/index.ts
@@ -1,4 +1,3 @@
-
import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';
import type { LintDiagnostic } from './types.ts';
diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.ts
index be5871ed9..5e832aa19 100644
--- a/packages/core/src/markdown/lint/plugins.ts
+++ b/packages/core/src/markdown/lint/plugins.ts
@@ -1,4 +1,3 @@
-
import { z } from 'zod';
import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';
import {
@@ -14,7 +13,6 @@ import {
type MarkdownlintSlice,
} from './types.ts';
-
const MarkdownlintRuleSettingSchema = z.union([
z.boolean(),
z.enum(MARKDOWNLINT_RULE_SEVERITIES),
diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.ts
index 3dae5c031..01ce4a5af 100644
--- a/packages/core/src/markdown/lint/types.ts
+++ b/packages/core/src/markdown/lint/types.ts
@@ -1,4 +1,3 @@
-
import type { BrokenLinkReason } from '../../schemas/api/agent-write.ts';
export const LINT_PLUGIN_IDS = ['markdownlint', 'frontmatter'] as const;
@@ -99,7 +98,6 @@ export interface FrontmatterSlice {
schemas: ResolvedFrontmatterSchemaEntry[];
}
-
interface RuleOptionSpecBase {
key: string;
description: string;
diff --git a/packages/core/src/markdown/lint/validation-counts.ts b/packages/core/src/markdown/lint/validation-counts.ts
index 437cc539a..98238656e 100644
--- a/packages/core/src/markdown/lint/validation-counts.ts
+++ b/packages/core/src/markdown/lint/validation-counts.ts
@@ -1,4 +1,3 @@
-
export interface ValidationSourceCounts {
errorCount: number;
warningCount: number;
diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.ts
index bd79424c7..a5b511f25 100644
--- a/packages/core/src/markdown/math-promoter.ts
+++ b/packages/core/src/markdown/math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { Math as MdastMath } from 'mdast-util-math';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.ts
index 00fbc0035..ed89371d0 100644
--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts
+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Properties } from 'hast';
import type { FootnoteDefinition, FootnoteReference } from 'mdast';
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';
diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.ts
index df788a80d..8ce2b2492 100644
--- a/packages/core/src/markdown/mdast-to-html.ts
+++ b/packages/core/src/markdown/mdast-to-html.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root as HastRoot, Text as HastText } from 'hast';
import type { Root as MdastRoot, Text as MdastText } from 'mdast';
import type { Handler } from 'mdast-util-to-hast';
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/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.ts
index 17ed2b829..1a897fca8 100644
--- a/packages/core/src/markdown/mermaid-promoter.ts
+++ b/packages/core/src/markdown/mermaid-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Code, Root } from 'mdast';
import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.ts
index 4aa0490c4..d988f4b8b 100644
--- a/packages/core/src/markdown/parse-with-fallback.ts
+++ b/packages/core/src/markdown/parse-with-fallback.ts
@@ -168,7 +168,6 @@ export function parseRecursive(
}
}
-
interface VFilePlace {
offset?: number;
start?: { offset?: number };
@@ -187,7 +186,6 @@ function extractErrorOffset(err: unknown): number | undefined {
return undefined;
}
-
interface Region {
start: number;
end: number;
@@ -211,7 +209,6 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {
return null;
}
-
export interface TagEvent {
kind: 'open' | 'close' | 'self-close';
name: string;
@@ -358,7 +355,6 @@ function findFallbackRegion(src: string, errorOffset: number): Region {
return { start: blockStart, end: blockEnd };
}
-
interface SourceBlock {
src: string;
start: number;
@@ -456,7 +452,6 @@ function tryPerBlockFallback(
};
}
-
function wholeDocRawText(source: string): JSONContent {
return {
type: 'doc',
diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.ts
index 43d420187..e6ab4fd57 100644
--- a/packages/core/src/markdown/parser-drop-closure.ts
+++ b/packages/core/src/markdown/parser-drop-closure.ts
@@ -1,4 +1,3 @@
-
export type DroppedTokenAdjudication =
| {
kind: 'format-dof-axis';
diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.ts
index 55736041c..0e3224206 100644
--- a/packages/core/src/markdown/pipeline.ts
+++ b/packages/core/src/markdown/pipeline.ts
@@ -1,4 +1,3 @@
-
import {
type FromProseMirrorOptions,
fromProseMirror,
diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.ts
index ccf06e94d..91cdf658f 100644
--- a/packages/core/src/markdown/position-aware-join.ts
+++ b/packages/core/src/markdown/position-aware-join.ts
@@ -1,4 +1,3 @@
-
import type { Join } from 'mdast-util-to-markdown';
import type { Position } from 'unist';
import { isBlankLineParagraph } from './zero-emission-blocks.ts';
diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.ts
index e5b4c9eba..0f399d34c 100644
--- a/packages/core/src/markdown/position-slice.ts
+++ b/packages/core/src/markdown/position-slice.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Root } from 'mdast';
import { visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
@@ -477,8 +476,7 @@ export function applyPositionSliceToNode(
const first = source[startOff];
if (first !== '[' && first !== '<' && !node.title) {
node.data.sourceStyle = 'gfm-autolink';
- }
- else if (first === '[') {
+ } else if (first === '[') {
const slice = source.slice(startOff, endOff);
const closeBracketIdx = slice.lastIndexOf('](');
if (closeBracketIdx !== -1) {
diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
index ca225ce9b..db10fa54b 100644
--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, Root, Text } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
index 3a2524a9a..34068d103 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
index 2279a0189..93151d43b 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
index a0f467c42..188f02d83 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
index 4e8542a21..4ba2c3418 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
index a3c96b24a..1a74b1272 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
index e95cf43d6..de35e7b79 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts
@@ -1,4 +1,3 @@
-
import type { Comment, Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
index ffdb4d5b5..b4be1b2ea 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts
@@ -1,4 +1,3 @@
-
import type { Element, ElementContent, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
index e2a96d1a7..3c8d88b7c 100644
--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts
@@ -1,4 +1,3 @@
-
import type { Element, Root } from 'hast';
import type { Plugin } from 'unified';
diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.ts
index 0389575ac..cf2c9da8e 100644
--- a/packages/core/src/markdown/resolve-image-url.ts
+++ b/packages/core/src/markdown/resolve-image-url.ts
@@ -1,4 +1,3 @@
-
import { isRelativeUrl } from './safe-url.ts';
function isDevDiagnosticContext(): boolean {
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('|');
diff --git a/packages/core/src/markdown/serialize-fidelity.test-helper.ts b/packages/core/src/markdown/serialize-fidelity.test-helper.ts
index 96304e7a5..0dd54070e 100644
--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts
+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts
@@ -1,4 +1,3 @@
-
import type { JSONContent } from '@tiptap/core';
import type { Nodes } from 'mdast';
import { expect } from 'vitest';
diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.ts
index 93798cf83..7cac5b042 100644
--- a/packages/core/src/markdown/serialize-helpers.ts
+++ b/packages/core/src/markdown/serialize-helpers.ts
@@ -1,4 +1,3 @@
-
import type { Node as PmNode } from '@tiptap/pm/model';
import type {
MdxJsxAttribute,
diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.ts
index 8c08b7a04..b012a5aff 100644
--- a/packages/core/src/markdown/single-dollar-math-promoter.ts
+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts
@@ -1,4 +1,3 @@
-
import type { PhrasingContent, Root, Text } from 'mdast';
import type { InlineMath } from 'mdast-util-math';
import { SKIP, visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.ts
index 959cc0bd2..3e79f8cb6 100644
--- a/packages/core/src/markdown/to-markdown-handlers.ts
+++ b/packages/core/src/markdown/to-markdown-handlers.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parents } from 'mdast';
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';
import type { Handle, Info, State } from 'mdast-util-to-markdown';
diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.ts
index 6e6d73400..0f1b0f27d 100644
--- a/packages/core/src/markdown/underline-promoter.ts
+++ b/packages/core/src/markdown/underline-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import type { MdxJsxTextElement } from 'mdast-util-mdx';
import { visit } from 'unist-util-visit';
diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.ts
index 932d7d2a8..1a082bda7 100644
--- a/packages/core/src/markdown/unknown-mdast-guard.ts
+++ b/packages/core/src/markdown/unknown-mdast-guard.ts
@@ -1,4 +1,3 @@
-
import type { Root as MdastRoot } from 'mdast';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.ts
index ac9f5239b..d578476a7 100644
--- a/packages/core/src/markdown/whitespace-char-ref.ts
+++ b/packages/core/src/markdown/whitespace-char-ref.ts
@@ -1,4 +1,3 @@
-
const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([
[0x20, ' '],
[0x09, '\t'],
diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.ts
index afd9936fe..6dad26200 100644
--- a/packages/core/src/markdown/wiki-link-micromark.ts
+++ b/packages/core/src/markdown/wiki-link-micromark.ts
@@ -17,7 +17,6 @@ declare module 'micromark-util-types' {
}
}
-
const CODE_BANG = 33; // !
const CODE_LBRACKET = 91; // [
const CODE_RBRACKET = 93; // ]
@@ -261,7 +260,6 @@ export function wikiLinkSyntax(): Extension {
};
}
-
function enterWikiLink(this: CompileContext, token: Token) {
this.enter(
{
@@ -387,7 +385,6 @@ export const wikiLinkToMarkdown: {
unsafe: [{ character: '[', inConstruct: ['phrasing'] }],
};
-
const MICROMARK_EXT = wikiLinkSyntax();
export function remarkWikiLink(this: Processor) {