Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Notarize stable macOS releases once and name hung attempts (#5784)

Andrew Mikofalvye81c8213e2a6
diff --git a/.github/scripts/build-smoke-alert-payload.mjs b/.github/scripts/build-smoke-alert-payload.mjs
index 006745c7b..f1c0e7b9c 100644
--- a/.github/scripts/build-smoke-alert-payload.mjs
+++ b/.github/scripts/build-smoke-alert-payload.mjs
@@ -70,7 +70,8 @@ function recoveryGuidance() {
'With no newer stable release, `transient-exhausted`, `deadline`, or `signal` can re-fire the same tag; investigate a recurring deadline.',
'`unknown-exhausted` requires manual log review. `terminal` requires fixing the cause in `reason=`.',
'`reason=rule:download-integrity` is the terminal exception: re-fire once on a fresh runner, then stop and investigate upstream if the same artifact fails again.',
- '`cleanup-failure` reports its runner/tooling cause in `cleanup=`; `spawn-failure`, `attempt-timeout`, and `child-signal` are also runner/tooling failures. Confirm the runner/tooling failure is absent before re-firing.',
+ '`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.',
].join('\n');
}
diff --git a/.github/scripts/build-smoke-alert-payload.test.mjs b/.github/scripts/build-smoke-alert-payload.test.mjs
index e03d7e2d9..5872e2de6 100644
--- a/.github/scripts/build-smoke-alert-payload.test.mjs
+++ b/.github/scripts/build-smoke-alert-payload.test.mjs
@@ -79,6 +79,11 @@ describe('alert content', () => {
expect(body).toContain('stop and investigate upstream');
expect(body).toContain('`cleanup-failure` reports its runner/tooling cause in `cleanup=`');
expect(body).toContain('Confirm the runner/tooling failure is absent before re-firing');
+ expect(body).toContain('`attempt-timeout` and a mid-attempt `deadline` list the processes');
+ expect(body).toContain(
+ 'a `took no process snapshot` line, needs that failure confirmed absent',
+ );
+ 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).not.toContain('re-firing alone repairs nothing');
expect(body).not.toContain('no manual repair needed');
diff --git a/.github/scripts/package-desktop.mjs b/.github/scripts/package-desktop.mjs
index 4d5697992..5c762c6f0 100644
--- a/.github/scripts/package-desktop.mjs
+++ b/.github/scripts/package-desktop.mjs
@@ -1,10 +1,23 @@
/* biome-ignore-all lint/suspicious/noUndeclaredEnvVars: GitHub Actions supplies the packaging context. */
import { spawnSync } from 'node:child_process';
-import { existsSync } from 'node:fs';
+import { existsSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
-export function packagingInvocation({ cwd, args, variant }) {
+export const SINGLE_NOTARIZER_ARG = '--config.mac.notarize=false';
+
+function afterSignNotarizes(cwd) {
+ const afterSign = join(cwd, 'scripts', 'afterSign.mjs');
+ return existsSync(afterSign) && readFileSync(afterSign, 'utf8').includes('@electron/notarize');
+}
+
+function withSingleNotarizer(cwd, args) {
+ if (!args.includes('--mac') || args.includes(SINGLE_NOTARIZER_ARG)) return args;
+ return afterSignNotarizes(cwd) ? [...args, SINGLE_NOTARIZER_ARG] : args;
+}
+
+export function packagingInvocation({ cwd, args: requestedArgs, variant }) {
+ const args = withSingleNotarizer(cwd, requestedArgs);
const launcher = join(cwd, 'scripts', 'run-electron-builder.mjs');
if (existsSync(launcher)) return [launcher, ...args];
if (variant !== 'stable')
diff --git a/.github/scripts/package-desktop.test.mjs b/.github/scripts/package-desktop.test.mjs
index 015cf2b59..445cbea37 100644
--- a/.github/scripts/package-desktop.test.mjs
+++ b/.github/scripts/package-desktop.test.mjs
@@ -1,10 +1,11 @@
import { execFileSync, spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
import { tmpdir } from 'node:os';
-import { join } from 'node:path';
+import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect, test } from 'vitest';
-import { packagingInvocation } from './package-desktop.mjs';
+import { packagingInvocation, SINGLE_NOTARIZER_ARG } from './package-desktop.mjs';
const script = fileURLToPath(new URL('./package-desktop.mjs', import.meta.url));
@@ -127,3 +128,95 @@ test('an npm user agent is refused before the launcher runs', () => {
rmSync(cwd, { recursive: true, force: true });
}
});
+
+function sourceFixture({ launcher, afterSign }) {
+ const cwd = mkdtempSync(join(tmpdir(), 'ok-package-notarizer-'));
+ mkdirSync(join(cwd, 'scripts'), { recursive: true });
+ if (launcher) writeFileSync(join(cwd, 'scripts', 'run-electron-builder.mjs'), '');
+ if (afterSign !== undefined) writeFileSync(join(cwd, 'scripts', 'afterSign.mjs'), afterSign);
+ return cwd;
+}
+
+const NOTARIZING_AFTER_SIGN = "import { notarize } from '@electron/notarize';\n";
+
+test.each([true, false])(
+ 'a macOS package of a source whose afterSign notarizes turns off the built-in notarizer (variant launcher present=%s)',
+ (launcher) => {
+ const cwd = sourceFixture({ launcher, afterSign: NOTARIZING_AFTER_SIGN });
+ try {
+ const args = ['--mac', '--publish', 'never', '--config.extraMetadata.version=0.83.0'];
+ const invocation = packagingInvocation({ cwd, args, variant: 'stable' });
+ expect(invocation.slice(1)).toEqual([...args, SINGLE_NOTARIZER_ARG]);
+ expect(args).not.toContain(SINGLE_NOTARIZER_ARG);
+ expect(
+ packagingInvocation({ cwd, args: [...args, SINGLE_NOTARIZER_ARG], variant: 'stable' })
+ .slice(1)
+ .filter((arg) => arg === SINGLE_NOTARIZER_ARG),
+ ).toHaveLength(1);
+ } finally {
+ rmSync(cwd, { recursive: true, force: true });
+ }
+ },
+);
+
+test.each([
+ ['--win', NOTARIZING_AFTER_SIGN],
+ ['--linux', NOTARIZING_AFTER_SIGN],
+ ['--mac', "console.log('fuse verification only');\n"],
+ ['--mac', undefined],
+])(
+ 'packaging %s leaves electron-builder notarization untouched when afterSign is %j',
+ (platform, afterSign) => {
+ const cwd = sourceFixture({ launcher: true, afterSign });
+ try {
+ const args = [platform, '--publish', 'never'];
+ expect(packagingInvocation({ cwd, args, variant: 'beta' }).slice(1)).toEqual(args);
+ } finally {
+ rmSync(cwd, { recursive: true, force: true });
+ }
+ },
+);
+
+test('electron-builder reads the single-notarizer argument as notarize: false', async () => {
+ let yargs;
+ let configureBuildCommand;
+ let normalizeOptions;
+ let validateConfiguration;
+ try {
+ const desktopRequire = createRequire(
+ fileURLToPath(new URL('../../packages/desktop/package.json', import.meta.url)),
+ );
+ const builderDir = dirname(desktopRequire.resolve('electron-builder/package.json'));
+ const builderRequire = createRequire(join(builderDir, 'package.json'));
+ yargs = builderRequire('yargs');
+ ({ configureBuildCommand, normalizeOptions } = builderRequire('./out/builder.js'));
+ const appBuilderRequire = createRequire(builderRequire.resolve('app-builder-lib/package.json'));
+ ({ validateConfiguration } = appBuilderRequire('./out/util/config/config.js'));
+ for (const fn of [yargs, configureBuildCommand, normalizeOptions, validateConfiguration]) {
+ if (typeof fn !== 'function') throw new TypeError('an expected export is not a function');
+ }
+ } catch (error) {
+ throw new Error(
+ `This test proves ${SINGLE_NOTARIZER_ARG} reaches electron-builder as notarize: false, so a macOS release submits to Apple once. It reads electron-builder 26.16.1 internals that this electron-builder no longer has; re-point it at the CLI argument parser and config validator, do not delete it.`,
+ { cause: error },
+ );
+ }
+
+ const argv = configureBuildCommand(
+ yargs([
+ '--mac',
+ '--publish',
+ 'never',
+ '--config.extraMetadata.version=0.83.0',
+ SINGLE_NOTARIZER_ARG,
+ '--config',
+ '.variant-build/electron-builder.yml',
+ ]),
+ ).parseSync();
+ const { config } = normalizeOptions(argv);
+ const merged = { appId: 'ai.openknowledge.test', ...config, extends: undefined };
+ await validateConfiguration(merged, { add() {}, isEnabled: false });
+
+ expect(config.extends).toBe('.variant-build/electron-builder.yml');
+ expect(merged.mac.notarize).toBe(false);
+});
diff --git a/.github/scripts/retry-transient.mjs b/.github/scripts/retry-transient.mjs
index 558d5e8e8..59b5e2a7c 100644
--- a/.github/scripts/retry-transient.mjs
+++ b/.github/scripts/retry-transient.mjs
@@ -1,6 +1,6 @@
#!/usr/bin/env node
-import { spawn } from 'node:child_process';
+import { spawn, spawnSync } from 'node:child_process';
import { writeFileSync } from 'node:fs';
import { StringDecoder } from 'node:string_decoder';
import { pathToFileURL } from 'node:url';
@@ -228,6 +228,7 @@ class AttemptResult {
spawnError = null,
cleanup = { ok: true, reason: 'clean' },
evidence = new FailureEvidence(),
+ liveProcesses = undefined,
} = {}) {
this.code = code;
this.closeSignal = closeSignal;
@@ -238,6 +239,7 @@ class AttemptResult {
this.spawnError = spawnError;
this.cleanup = cleanup;
this.evidence = evidence;
+ this.liveProcesses = liveProcesses;
}
}
@@ -335,6 +337,20 @@ function emitDiagnostic(log, label, evidence) {
log('::endgroup::');
}
+function emitLiveProcesses(log, label, reason, snapshot) {
+ if (snapshot === undefined) return;
+ if (snapshot.unavailable) {
+ log(`${label} took no process snapshot at ${reason}: ${snapshot.unavailable}`);
+ return;
+ }
+ log(`::group::${label} processes still running at ${reason}`);
+ if (snapshot.processes.length === 0) log('| (none left in the attempt process group)');
+ for (const { pid, elapsed, program } of snapshot.processes) {
+ log(`| pid=${pid} elapsed=${elapsed} ${program.replaceAll('##[', '# #[')}`);
+ }
+ log('::endgroup::');
+}
+
function projectedAttemptMs(durationMs, attemptTimeoutMs) {
return Math.min(
attemptTimeoutMs,
@@ -429,6 +445,37 @@ function hasExited(leader) {
return leader.exitCode !== null || leader.signalCode !== null;
}
+function defaultListProcesses() {
+ const result = spawnSync('ps', ['-A', '-o', 'pgid=,pid=,etime=,comm='], {
+ encoding: 'utf8',
+ timeout: 2_000,
+ });
+ if (result.error) return { unavailable: `ps failed: ${result.error.message}` };
+ if (result.status !== 0) {
+ return { unavailable: `ps exited ${result.status ?? result.signal}` };
+ }
+ return { table: result.stdout };
+}
+
+export function processesInGroup(listing, pgid) {
+ if (typeof listing?.table !== 'string') {
+ return { unavailable: listing?.unavailable ?? 'no process table' };
+ }
+ const table = listing.table;
+ const processes = [];
+ for (const line of table.split('\n')) {
+ const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.*)$/.exec(line);
+ if (match && Number(match[1]) === pgid) {
+ processes.push({
+ pid: Number(match[2]),
+ elapsed: match[3],
+ program: match[4].trim().split('/').pop(),
+ });
+ }
+ }
+ return { processes };
+}
+
function defaultTaskkill(args) {
return new Promise((resolve) => {
const child = spawn('taskkill', args, { stdio: 'ignore', windowsHide: true });
@@ -450,6 +497,7 @@ export function createOwnedTreeController({
taskkillFn = defaultTaskkill,
sleepFn = delay,
pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,
+ listProcessesFn = defaultListProcesses,
} = {}) {
if (platform === 'win32') {
const closedOrOutlived = async (graceMs, waitForClose) =>
@@ -488,6 +536,9 @@ export function createOwnedTreeController({
: { ok: false, reason: 'close-not-observed' };
};
return {
+ describe(leader) {
+ return processesInGroup(listProcessesFn(), leader.pid);
+ },
async cleanup(leader, { graceMs, cleanupReserveMs, waitForClose }) {
const { pid } = leader;
if (hasExited(leader)) {
@@ -636,6 +687,12 @@ async function runAttempt({
cancellationSignal.removeEventListener('abort', cancelListener);
const waitForClose = (timeoutMs) => waitForPromise(closePromise, timeoutMs);
+ const liveProcesses =
+ child.pid && (outcome.kind === 'attempt-timeout' || outcome.kind === 'deadline')
+ ? (treeController.describe?.(child) ?? {
+ unavailable: `process listing is not supported on ${platform}`,
+ })
+ : undefined;
let cleanup = { ok: true, reason: 'clean' };
if (child.pid) {
cleanup = await treeController.cleanup(child, {
@@ -661,6 +718,7 @@ async function runAttempt({
spawnError,
cleanup,
evidence,
+ liveProcesses,
});
}
@@ -831,6 +889,7 @@ export async function runWithRetry({
signal: stopped.signal,
detail: stopped.reason === 'deadline' ? 'phase=mid-attempt' : undefined,
});
+ emitLiveProcesses(log, label, stopped.reason, result.liveProcesses);
return finishFailure(stopped, result);
}
if (result.code === 0) {
diff --git a/.github/scripts/retry-transient.test.mjs b/.github/scripts/retry-transient.test.mjs
index 1d7a05d66..014e1da5d 100644
--- a/.github/scripts/retry-transient.test.mjs
+++ b/.github/scripts/retry-transient.test.mjs
@@ -20,6 +20,7 @@ import {
DEFAULT_MAX_ATTEMPTS,
FailureEvidence,
parseArgs,
+ processesInGroup,
RETRY_ON_STOP_OUTCOMES,
runWithRetry,
STOP_OUTCOMES,
@@ -1222,10 +1223,65 @@ describe('deadlines and cancellation', () => {
expect(result).toMatchObject({ ok: false, reason: 'deadline', attempts: 1 });
expect(result.log).toContain('reason=control:deadline outcome=deadline');
expect(result.log).toContain('phase=mid-attempt');
+ if (process.platform !== 'win32') {
+ expect(result.log).toContain('processes still running at deadline');
+ expect(result.log).toContain(`pid=${readFileSync(pidFile, 'utf8')} elapsed=`);
+ }
live.assertSpawnedAsProductionAsked();
await assertChildRanThenDied(ctx, pidFile);
});
+ test('a tree controller that cannot list processes leaves a line saying so', async (ctx) => {
+ const pidFile = join(scratch, 'no-describe-child-pid');
+ const live = await spawnLiveChild(pidFile);
+ const owned = createOwnedTreeController();
+ const result = await run({
+ spawnFn: live.spawnFn,
+ attemptTimeoutMs: 1,
+ deadlineEpochMs: Date.now() + 5_000,
+ treeController: { cleanup: (...args) => owned.cleanup(...args) },
+ });
+ expect(result).toMatchObject({ ok: false, reason: 'attempt-timeout', attempts: 1 });
+ expect(result.log).toContain(
+ `took no process snapshot at attempt-timeout: process listing is not supported on ${process.platform}`,
+ );
+ await assertChildRanThenDied(ctx, pidFile);
+ });
+
+ test.skipIf(process.platform === 'win32')(
+ 'an attempt timeout names the processes it found still running before stopping them',
+ async (ctx) => {
+ const pidFile = join(scratch, 'timeout-snapshot-child-pid');
+ const live = await spawnLiveChild(pidFile);
+ const result = await run({
+ label: 'electron-builder (macOS)',
+ spawnFn: live.spawnFn,
+ attemptTimeoutMs: 1,
+ deadlineEpochMs: Date.now() + 5_000,
+ });
+ expect(result).toMatchObject({ ok: false, reason: 'attempt-timeout', attempts: 1 });
+ const pid = readFileSync(pidFile, 'utf8');
+ const start = result.lines.indexOf(
+ '::group::electron-builder (macOS) processes still running at attempt-timeout',
+ );
+ expect(
+ start,
+ 'a hung attempt must say what was still running when it was stopped, so the release alert can tell a codesign hang from a notarization wait',
+ ).toBeGreaterThan(
+ result.lines.findIndex((line) => line.includes('reason=control:attempt-timeout')),
+ );
+ const snapshot = result.lines.slice(start, result.lines.indexOf('::endgroup::', start));
+ expect(snapshot).toContainEqual(
+ expect.stringMatching(new RegExp(`^\\| pid=${pid} elapsed=\\S+ \\S`)),
+ );
+ expect(
+ result.log,
+ 'the snapshot reads only executable names, never argv, because notarytool carries Apple credentials on its command line',
+ ).not.toContain('const fs=');
+ await assertChildRanThenDied(ctx, pidFile);
+ },
+ );
+
test('a one-millisecond attempt timeout still stops a child that reached user code', async (ctx) => {
const pidFile = join(scratch, 'short-timeout-live-child-pid');
const live = await spawnLiveChild(pidFile);
@@ -1528,6 +1584,74 @@ describe('deadlines and cancellation', () => {
const heldLeader = () => ({ pid: 4321, exitCode: null, signalCode: null });
+describe('process-group snapshot', () => {
+ const table = [
+ ' 700 700 30:01 /bin/bash',
+ ' 700 812 29:58 /Applications/Xcode.app/Contents/Developer/usr/bin/notarytool',
+ ' 700 813 29:58 /Volumes/Build Disk/bin/codesign',
+ ' 701 900 1:00 /usr/bin/unrelated',
+ 'garbage line',
+ '',
+ ].join('\n');
+
+ test('keeps only the members of the requested process group, by program name', () => {
+ expect(processesInGroup({ table }, 700)).toEqual({
+ processes: [
+ { pid: 700, elapsed: '30:01', program: 'bash' },
+ { pid: 812, elapsed: '29:58', program: 'notarytool' },
+ { pid: 813, elapsed: '29:58', program: 'codesign' },
+ ],
+ });
+ expect(processesInGroup({ table }, 999)).toEqual({ processes: [] });
+ expect(processesInGroup({ unavailable: 'ps exited 1' }, 700)).toEqual({
+ unavailable: 'ps exited 1',
+ });
+ });
+
+ test('a stop prints each process by program name', async () => {
+ const result = await run({
+ label: 'electron-builder (macOS)',
+ attemptRunner: async () => ({
+ code: null,
+ closeSignal: 'SIGTERM',
+ cancellationSignal: null,
+ cancelled: false,
+ timedOut: true,
+ deadlineExpired: false,
+ spawnError: null,
+ cleanup: { ok: true, reason: 'clean' },
+ evidence: new FailureEvidence(),
+ liveProcesses: createOwnedTreeController({
+ platform: 'darwin',
+ listProcessesFn: () => ({ table }),
+ }).describe({ pid: 700 }),
+ }),
+ });
+ expect(result.log).toContain('| pid=812 elapsed=29:58 notarytool');
+ expect(result.log).toContain('| pid=813 elapsed=29:58 codesign');
+ });
+
+ test('a stop whose process listing failed says why', async () => {
+ const why = 'ps exited 1';
+ const result = await run({
+ attemptRunner: async () => ({
+ code: null,
+ closeSignal: 'SIGTERM',
+ cancellationSignal: null,
+ cancelled: false,
+ timedOut: true,
+ deadlineExpired: false,
+ spawnError: null,
+ cleanup: { ok: true, reason: 'clean' },
+ evidence: new FailureEvidence(),
+ liveProcesses: processesInGroup({ unavailable: why }, 700),
+ }),
+ });
+ expect(result).toMatchObject({ ok: false, reason: 'attempt-timeout' });
+ expect(result.log).toContain(`took no process snapshot at attempt-timeout: ${why}`);
+ });
+});
+
describe('POSIX owned-tree cleanup reasons', () => {
const options = { graceMs: 1, cleanupReserveMs: 1, waitForClose: async () => false };
diff --git a/knip.config.ts b/knip.config.ts
index 65f0e8807..d3638888e 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -147,11 +147,15 @@ 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 a50b00123..4549c74b3 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,3 +1,4 @@
+
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 6fcdc23f2..4fc2c11f9 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,3 +1,4 @@
+
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 40b5cdfd6..9f2f6feb6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,3 +1,4 @@
+
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 93666af70..2a085742b 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,3 +1,4 @@
+
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 867598d34..878d5196b 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,3 +1,4 @@
+
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 0970ac12f..4ada3cf26 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,3 +1,4 @@
+
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 b632185e1..cbe2b705f 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,3 +1,4 @@
+
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 c530ce4ba..89bc9b4d9 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,3 +1,4 @@
+
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 d3767adc9..a78aeb0e4 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,3 +1,4 @@
+
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 b076f955c..e7cc69c3f 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,3 +1,4 @@
+
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 7935e35f8..9ddcd0730 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,3 +1,4 @@
+
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 f4cc8a286..2a597ec3d 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,3 +1,4 @@
+
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 8fb428b90..01ef76a9f 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,3 +1,4 @@
+
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 fc267cbea..fb0ba5a7c 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,3 +1,4 @@
+
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 bfd7e3109..fa3cfcd86 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,3 +1,4 @@
+
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 4d3250d3a..8be632ba4 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,3 +1,4 @@
+
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');