Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Declare Rust 1.99.0 and the Node pin for OK builds (gate placement) (#5880)

Nick Gomez6e64dfc6c340
diff --git a/.github/composite-actions/share-contract-reader-gate/action.yml b/.github/composite-actions/share-contract-reader-gate/action.yml
index c57d2f157..158b3b504 100644
--- a/.github/composite-actions/share-contract-reader-gate/action.yml
+++ b/.github/composite-actions/share-contract-reader-gate/action.yml
@@ -19,7 +19,7 @@ runs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Probe reader compatibility
id: probe
diff --git a/.github/scripts/bug-lane-refusal-payload.mjs b/.github/scripts/bug-lane-refusal-payload.mjs
index 8e8b4689a..c4a07ab04 100644
--- a/.github/scripts/bug-lane-refusal-payload.mjs
+++ b/.github/scripts/bug-lane-refusal-payload.mjs
@@ -91,8 +91,10 @@ export function classifyRefs(refs, gitShow) {
const classifiedWithNoPaths = (r) => Array.isArray(r.files) && r.files.length === 0;
-export function reasonPhrase({ verdict, refs }) {
- if (verdict === 'could-not-verify') return 'verification timeout';
+export function reasonPhrase({ verdict, refs, cause }) {
+ if (verdict === 'could-not-verify') {
+ return cause === 'toolchain' ? 'toolchain install failure' : 'verification timeout';
+ }
if (verdict === 'fail') return 'red verification';
if (refs.length > 0 && refs.every((r) => r.inert)) return 'config drift';
if (refs.length > 0 && refs.every(classifiedWithNoPaths)) return 'unclear pick failure';
@@ -121,9 +123,9 @@ function headlineSubject({ verdict, refs }) {
return rest.length > 0 ? `${label} and ${rest.length} more` : label;
}
-export function buildHeadline({ verdict, refs, stable }) {
+export function buildHeadline({ verdict, refs, stable, cause }) {
return [
- `Bug lane: ${headlineSubject({ verdict, refs })} did not ship in the fast lane due to ${reasonPhrase({ verdict, refs })}.`,
+ `Bug lane: ${headlineSubject({ verdict, refs })} did not ship in the fast lane due to ${reasonPhrase({ verdict, refs, cause })}.`,
`Latest stable remains \`${stable}\`.`,
noActionSentence(verdict),
].join(' ');
@@ -190,8 +192,8 @@ export function actionLine({ verdict, refs }) {
return 'If it must ship sooner, the answer is a smaller self-contained commit, not a forced pick — see RELEASES.md, "When a guard refuses".';
}
-export function buildSlackPayload({ verdict, stable, refs, runUrl, failures = [] }) {
- const headline = buildHeadline({ verdict, refs, stable });
+export function buildSlackPayload({ verdict, stable, refs, runUrl, failures = [], cause }) {
+ const headline = buildHeadline({ verdict, refs, stable, cause });
const body = [
headline,
'',
@@ -236,6 +238,7 @@ export function parseArgs(argv) {
? parsed.failures.filter((entry) => typeof entry === 'string' && entry.trim() !== '')
: [],
runUrl: parsed.runUrl || '',
+ cause: parsed.cause || '',
};
}
diff --git a/.github/scripts/bug-lane-refusal-payload.test.mjs b/.github/scripts/bug-lane-refusal-payload.test.mjs
index 7e29dcda6..5555f6cab 100644
--- a/.github/scripts/bug-lane-refusal-payload.test.mjs
+++ b/.github/scripts/bug-lane-refusal-payload.test.mjs
@@ -1,8 +1,21 @@
// biome-ignore-all lint/suspicious/noTemplateCurlyInString: shell and GitHub expression fixtures must remain literal.
-import { readdirSync, readFileSync } from 'node:fs';
-import { dirname, join } from 'node:path';
+import { execFile, execFileSync } from 'node:child_process';
+import {
+ cpSync,
+ mkdirSync,
+ mkdtempSync,
+ readdirSync,
+ readFileSync,
+ rmSync,
+ writeFileSync,
+} from 'node:fs';
+import { createServer } from 'node:http';
+import { tmpdir } from 'node:os';
+import { delimiter, dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
-import { describe, expect, test } from 'vitest';
+import { afterAll, beforeAll, describe, expect, test } from 'vitest';
+import { parse } from 'yaml';
+import { gitCleanEnv } from '../../scripts/git-clean-env.mjs';
import {
actionLine,
@@ -244,6 +257,22 @@ describe('reasonPhrase and buildHeadline', () => {
expect(soaked).toMatch(/rides its cycle's stable/);
expect(retried).not.toMatch(/rides its cycle's stable/);
});
+
+ test('a failed toolchain install names the install as the reason, not a timeout', () => {
+ const install = reasonPhrase({ verdict: 'could-not-verify', refs: [], cause: 'toolchain' });
+ expect(install.split(/\s+/).length).toBeLessThanOrEqual(3);
+ expect(install).toMatch(/toolchain/);
+ expect(install).not.toBe(reasonPhrase({ verdict: 'could-not-verify', refs: [] }));
+ const headline = buildHeadline({
+ verdict: 'could-not-verify',
+ refs: [],
+ stable: 'v1',
+ cause: 'toolchain',
+ });
+ expect(headline).toContain(install);
+ expect(headline).toMatch(/retries this batch automatically/);
+ expect(headline).not.toMatch(/timeout/);
+ });
});
describe('actionLine', () => {
@@ -487,6 +516,12 @@ describe('parseArgs', () => {
test('defaults a missing refs array rather than throwing', () => {
expect(parseArgs(['node', 'x', '--input', '{"verdict":"fail"}']).refs).toEqual([]);
});
+
+ test('carries the cause the verify step recorded, and none when it recorded none', () => {
+ const input = (fields) => parseArgs(['node', 'x', '--input', JSON.stringify(fields)]);
+ expect(input({ verdict: 'could-not-verify', cause: 'toolchain' }).cause).toBe('toolchain');
+ expect(input({ verdict: 'could-not-verify' }).cause).toBe('');
+ });
});
describe('workflow wiring', () => {
@@ -695,3 +730,232 @@ describe('workflow wiring', () => {
expect(bodies[1]).toBe('echo inline');
});
});
+
+describe('the page a failed toolchain install sends', () => {
+ const TIMEOUT_CAUSE = /timeout|time budget|ran out of|did not finish within|clock/i;
+ const workflow = parse(bugLaneVerify);
+ const job = workflow.jobs['bug-lane-verify'];
+
+ const stepNamed = (prefix) => {
+ const found = job.steps.filter((step) => step.name?.startsWith(prefix));
+ if (found.length !== 1) {
+ throw new Error(`bug-lane-verify.yml has ${found.length} steps named ${prefix}`);
+ }
+ return found[0];
+ };
+
+ const runnerBashArgs = (step) => {
+ const shell = step.shell ?? job.defaults?.run?.shell ?? workflow.defaults?.run?.shell;
+ if (shell === undefined) return ['-e'];
+ if (shell === 'bash') return ['--noprofile', '--norc', '-eo', 'pipefail'];
+ throw new Error(`no runner argument format for the shell ${shell}`);
+ };
+
+ const resolveEnv = (env, context) =>
+ Object.fromEntries(
+ Object.entries(env ?? {}).map(([name, value]) => {
+ const text = String(value);
+ const expression = /^\$\{\{\s*([\w.-]+)\s*\}\}$/.exec(text);
+ if (!expression) {
+ if (text.includes('${{')) throw new Error(`${name}: cannot evaluate ${text}`);
+ return [name, text];
+ }
+ const [root, ...path] = expression[1].split('.');
+ if (!(root in context)) throw new Error(`${name}: no ${root} context for ${text}`);
+ const resolved = path.reduce((node, key) => node?.[key], context[root]);
+ return [name, resolved == null ? '' : String(resolved)];
+ }),
+ );
+
+ const readOutputs = (file) => {
+ const lines = readFileSync(file, 'utf8').split('\n');
+ const outputs = {};
+ for (let i = 0; i < lines.length; i += 1) {
+ const line = lines[i];
+ if (line === '') continue;
+ const equals = line.indexOf('=');
+ const heredoc = line.indexOf('<<');
+ if (heredoc !== -1 && (equals === -1 || heredoc < equals)) {
+ const end = lines.indexOf(line.slice(heredoc + 2), i + 1);
+ if (end === -1) throw new Error(`GITHUB_OUTPUT never closes ${line}`);
+ outputs[line.slice(0, heredoc)] = lines.slice(i + 1, end).join('\n');
+ i = end;
+ } else if (equals !== -1) {
+ outputs[line.slice(0, equals)] = line.slice(equals + 1);
+ } else {
+ throw new Error(`GITHUB_OUTPUT has an unreadable line: ${line}`);
+ }
+ }
+ return outputs;
+ };
+
+ let scratch;
+ let server;
+ let webhook;
+ const received = [];
+ beforeAll(async () => {
+ scratch = mkdtempSync(join(tmpdir(), 'bug-lane-install-page-'));
+ server = createServer(async (request, response) => {
+ let body = '';
+ for await (const chunk of request) body += chunk;
+ received.push(body);
+ response.end('ok');
+ });
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
+ webhook = `http://127.0.0.1:${server.address().port}/slack`;
+ });
+ afterAll(async () => {
+ rmSync(scratch, { recursive: true, force: true });
+ server.closeAllConnections();
+ await new Promise((resolve, reject) =>
+ server.close((error) => (error ? reject(error) : resolve())),
+ );
+ });
+
+ const runnerEnv = (dir, bin) => {
+ const {
+ SLACK_RELEASES_WEBHOOK_URL: _r,
+ SLACK_WEBHOOK_URL: _s,
+ GITHUB_OUTPUT: _o,
+ GITHUB_STEP_SUMMARY: _m,
+ NODE_OPTIONS: _n,
+ BASH_ENV: _b,
+ ...base
+ } = gitCleanEnv();
+ const home = join(dir, 'home');
+ const runnerTemp = join(dir, 'runner-temp');
+ mkdirSync(home, { recursive: true });
+ mkdirSync(runnerTemp, { recursive: true });
+ return {
+ ...base,
+ HOME: home,
+ GIT_CONFIG_NOSYSTEM: '1',
+ PATH: [bin, dirname(process.execPath), base.PATH].join(delimiter),
+ RUNNER_TEMP: runnerTemp,
+ GITHUB_STEP_SUMMARY: join(dir, 'step-summary'),
+ };
+ };
+
+ const stableWithAFix = (dir, env) => {
+ const repo = join(dir, 'repo');
+ mkdirSync(repo);
+ const git = (...args) =>
+ execFileSync(
+ 'git',
+ ['-c', 'user.name=bug-lane test', '-c', '[email protected]', ...args],
+ { cwd: repo, env, encoding: 'utf8' },
+ ).trim();
+ git('init', '-q');
+ writeFileSync(join(repo, 'stable.txt'), 'stable\n');
+ git('add', '-A');
+ git('commit', '-qm', 'stable');
+ const stable = git('rev-parse', 'HEAD');
+ for (const path of ['.github/scripts', 'scripts']) {
+ cpSync(join(REPO_ROOT, path), join(repo, path), { recursive: true });
+ }
+ git('add', '-A');
+ git('commit', '-qm', 'lane scripts');
+ const lane = git('rev-parse', 'HEAD');
+ git('checkout', '-q', '--detach', stable);
+ writeFileSync(join(repo, 'fix.txt'), 'fix\n');
+ git('add', '-A');
+ git('commit', '-qm', 'fix');
+ const fix = git('rev-parse', 'HEAD');
+ git('checkout', '-q', '--detach', stable);
+ return { repo, lane, fix };
+ };
+
+ const commandStubs = (dir, exits) => {
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ const stub = (name, body) =>
+ writeFileSync(join(bin, name), ['#!/bin/sh', ...body, ''].join('\n'), { mode: 0o755 });
+ stub('pnpm', [
+ 'if [ "$*" = "install --frozen-lockfile" ]; then exit 0; fi',
+ 'echo "pnpm stub: only install --frozen-lockfile is expected, got: pnpm $*" >&2',
+ 'exit 1',
+ ]);
+ stub('rustup', ['echo "rustup stub: $*" >&2', `exit ${exits.rustup}`]);
+ stub('rustc', ['echo "rustc stub: $*" >&2', `exit ${exits.rustc}`]);
+ return bin;
+ };
+
+ const runStep = (step, dir, { cwd, env }) => {
+ const script = join(dir, `${step.id}.sh`);
+ writeFileSync(script, step.run);
+ return new Promise((resolve) => {
+ execFile('bash', [...runnerBashArgs(step), script], { cwd, env }, (error, stdout, stderr) =>
+ resolve({ status: error ? (error.code ?? error.signal) : 0, stdout, stderr }),
+ );
+ });
+ };
+
+ test.each([
+ ['rustup cannot install the declared toolchain', { rustup: 1, rustc: 0 }],
+ ['the installed rustc does not run', { rustup: 0, rustc: 1 }],
+ ])('when %s, it names the toolchain and no timeout', async (_label, exits) => {
+ received.length = 0;
+ const dir = mkdtempSync(join(scratch, 'run-'));
+ const bin = commandStubs(dir, exits);
+ const env = runnerEnv(dir, bin);
+ const { repo, lane, fix } = stableWithAFix(dir, env);
+ const inputs = { fix_refs: fix, stable: 'v0.63.6', fix_tickets: '' };
+
+ const verifyStep = stepNamed('Verify the synthetic tree');
+ const verifyOutput = join(dir, 'verify-output');
+ writeFileSync(verifyOutput, '');
+ const verify = await runStep(verifyStep, dir, {
+ cwd: repo,
+ env: {
+ ...env,
+ ...resolveEnv(workflow.env, {}),
+ ...resolveEnv(verifyStep.env, { inputs, steps: {} }),
+ GITHUB_OUTPUT: verifyOutput,
+ },
+ });
+ expect(verify.status, verify.stderr).toBe(0);
+ const outputs = readOutputs(verifyOutput);
+ expect(outputs.verdict, 'a failed install leaves the batch unverified').toBe(
+ 'could-not-verify',
+ );
+
+ const admitted = [
+ ...stepNamed('Refusal signature').if.matchAll(
+ /steps\.verify\.outputs\.verdict == '([a-z-]+)'/g,
+ ),
+ ].map((m) => m[1]);
+ expect(admitted, 'the refusal pager does not admit the verdict this tick minted').toContain(
+ outputs.verdict,
+ );
+
+ const pageStep = stepNamed('Page on a refusal');
+ const pageOutput = join(dir, 'page-output');
+ writeFileSync(pageOutput, '');
+ const page = await runStep(pageStep, dir, {
+ cwd: repo,
+ env: {
+ ...env,
+ ...resolveEnv(workflow.env, {}),
+ ...resolveEnv(pageStep.env, {
+ inputs,
+ secrets: { SLACK_RELEASES_WEBHOOK_URL: webhook },
+ steps: { verify: { outputs } },
+ }),
+ GITHUB_OUTPUT: pageOutput,
+ GITHUB_SHA: lane,
+ GITHUB_SERVER_URL: 'https://github.com',
+ GITHUB_REPOSITORY: 'inkeep/open-knowledge',
+ GITHUB_RUN_ID: '1',
+ },
+ });
+ expect(page.status, page.stderr).toBe(0);
+ expect(received, page.stdout).toHaveLength(1);
+
+ const payload = JSON.parse(received[0]);
+ expect(payload, 'the page fell back to the plain-text message').toHaveProperty('blocks');
+ const whole = JSON.stringify(payload);
+ expect(whole).toMatch(/toolchain|\brust/i);
+ expect(payload.text).not.toMatch(TIMEOUT_CAUSE);
+ expect(whole).not.toMatch(TIMEOUT_CAUSE);
+ });
+});
diff --git a/.github/scripts/ci-files.mjs b/.github/scripts/ci-files.mjs
new file mode 100644
index 000000000..31f935c1b
--- /dev/null
+++ b/.github/scripts/ci-files.mjs
@@ -0,0 +1,19 @@
+import { readdirSync } from 'node:fs';
+import { join } from 'node:path';
+
+function actionFiles(root, dir) {
+ return readdirSync(join(root, dir), { withFileTypes: true }).flatMap((entry) => {
+ const path = `${dir}/${entry.name}`;
+ if (entry.isDirectory()) {
+ return actionFiles(root, path);
+ }
+ return entry.isFile() && /^action\.ya?ml$/.test(entry.name) ? [path] : [];
+ });
+}
+
+export function ciFiles(root) {
+ const workflows = readdirSync(join(root, '.github', 'workflows'), { withFileTypes: true })
+ .filter((entry) => entry.isFile() && /\.ya?ml$/.test(entry.name))
+ .map((entry) => `.github/workflows/${entry.name}`);
+ return [...new Set([...workflows, ...actionFiles(root, '.github')])].sort();
+}
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index 29ff406a9..edaaccc69 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -1376,6 +1376,126 @@ describe('the macOS artifact is attested signed before it can ship', () => {
expect(step).toContain('No .app found under dist-desktop to attest');
}
});
+
+ const HELPER_CHECK = 'assert-packaged-helper-runs-as-node.mjs';
+ const SHIPS_THE_APP = {
+ 'desktop-release.yml#build-macos': [
+ 'Verify a historical app can update in place',
+ 'Smoke the packaged DMG (FR5b)',
+ 'Upload macOS release assets for the fan-in publisher',
+ ],
+ 'desktop-build.yml#build-macos-dmg': ['Upload DMG artifact'],
+ };
+ const runsHelperCheck = (step) => step.run?.includes(HELPER_CHECK) ?? false;
+ const helperCheckProblems = (job) => {
+ const checks = job.steps.filter(runsHelperCheck);
+ if (checks.length === 0) return [`${job.label} has no step that runs ${HELPER_CHECK}`];
+ const attest = macStepIndex(job, ATTEST);
+ return checks.flatMap((check) => {
+ const at = job.steps.indexOf(check);
+ const placed = `${job.label}: the packaged-helper check`;
+ return [
+ ...(at > attest ? [] : [`${placed} runs before ${ATTEST}`]),
+ ...SHIPS_THE_APP[job.label]
+ .filter((name) => at > macStepIndex(job, name))
+ .map((name) => `${placed} runs after ${name}`),
+ ...(check.if === undefined ? [] : [`${placed} runs only if ${check.if}`]),
+ ...(check['continue-on-error'] === undefined ? [] : [`${placed} sets continue-on-error`]),
+ ];
+ });
+ };
+ const planted = (job, plant) => ({ ...job, steps: plant(job.steps) });
+ const moveHelperCheck = (steps, place) => {
+ const rest = steps.filter((step) => !runsHelperCheck(step));
+ const at = place(rest);
+ return [...rest.slice(0, at), ...steps.filter(runsHelperCheck), ...rest.slice(at)];
+ };
+
+ test('both workflows check the packaged helper of the attested app before it is smoked or uploaded', () => {
+ expect(macPackagingJobs.map((job) => job.label)).toEqual(Object.keys(SHIPS_THE_APP));
+ for (const job of macPackagingJobs) {
+ expect(helperCheckProblems(job), job.label).toEqual([]);
+ }
+ });
+
+ test.each([
+ [
+ 'removed',
+ (steps) => steps.filter((step) => !runsHelperCheck(step)),
+ {
+ 'desktop-release.yml#build-macos': [
+ 'desktop-release.yml#build-macos has no step that runs assert-packaged-helper-runs-as-node.mjs',
+ ],
+ 'desktop-build.yml#build-macos-dmg': [
+ 'desktop-build.yml#build-macos-dmg has no step that runs assert-packaged-helper-runs-as-node.mjs',
+ ],
+ },
+ ],
+ [
+ 'given an if:',
+ (steps) =>
+ steps.map((step) =>
+ runsHelperCheck(step) ? { ...step, if: "steps.signmode.outputs.mode == 'signed'" } : step,
+ ),
+ {
+ 'desktop-release.yml#build-macos': [
+ "desktop-release.yml#build-macos: the packaged-helper check runs only if steps.signmode.outputs.mode == 'signed'",
+ ],
+ 'desktop-build.yml#build-macos-dmg': [
+ "desktop-build.yml#build-macos-dmg: the packaged-helper check runs only if steps.signmode.outputs.mode == 'signed'",
+ ],
+ },
+ ],
+ [
+ 'allowed to fail',
+ (steps) =>
+ steps.map((step) =>
+ runsHelperCheck(step) ? { ...step, 'continue-on-error': true } : step,
+ ),
+ {
+ 'desktop-release.yml#build-macos': [
+ 'desktop-release.yml#build-macos: the packaged-helper check sets continue-on-error',
+ ],
+ 'desktop-build.yml#build-macos-dmg': [
+ 'desktop-build.yml#build-macos-dmg: the packaged-helper check sets continue-on-error',
+ ],
+ },
+ ],
+ [
+ 'moved after the upload',
+ (steps) =>
+ moveHelperCheck(
+ steps,
+ (rest) => rest.findIndex((step) => step.uses?.startsWith('actions/upload-artifact@')) + 1,
+ ),
+ {
+ 'desktop-release.yml#build-macos': [
+ 'desktop-release.yml#build-macos: the packaged-helper check runs after Verify a historical app can update in place',
+ 'desktop-release.yml#build-macos: the packaged-helper check runs after Smoke the packaged DMG (FR5b)',
+ 'desktop-release.yml#build-macos: the packaged-helper check runs after Upload macOS release assets for the fan-in publisher',
+ ],
+ 'desktop-build.yml#build-macos-dmg': [
+ 'desktop-build.yml#build-macos-dmg: the packaged-helper check runs after Upload DMG artifact',
+ ],
+ },
+ ],
+ [
+ 'moved ahead of the attestation',
+ (steps) => moveHelperCheck(steps, (rest) => rest.findIndex((step) => step.name === ATTEST)),
+ {
+ 'desktop-release.yml#build-macos': [
+ 'desktop-release.yml#build-macos: the packaged-helper check runs before Attest the signed macOS app',
+ ],
+ 'desktop-build.yml#build-macos-dmg': [
+ 'desktop-build.yml#build-macos-dmg: the packaged-helper check runs before Attest the signed macOS app',
+ ],
+ },
+ ],
+ ])('the helper check placement reds when the step is %s', (_case, plant, expected) => {
+ for (const job of macPackagingJobs) {
+ expect(helperCheckProblems(planted(job, plant)), job.label).toEqual(expected[job.label]);
+ }
+ });
});
describe('every job that reads changesets installs the Changesets reader first', () => {
diff --git a/.github/scripts/rust-toolchain-sites.test-helper.mjs b/.github/scripts/rust-toolchain-sites.test-helper.mjs
new file mode 100644
index 000000000..92e743587
--- /dev/null
+++ b/.github/scripts/rust-toolchain-sites.test-helper.mjs
@@ -0,0 +1,189 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { parse } from 'yaml';
+import { ciFiles } from './ci-files.mjs';
+
+const PROXIES = new Set([
+ 'cargo',
+ 'cargo-clippy',
+ 'cargo-fmt',
+ 'cargo-miri',
+ 'clippy-driver',
+ 'rls',
+ 'rust-analyzer',
+ 'rust-gdb',
+ 'rust-gdbgui',
+ 'rust-lldb',
+ 'rustc',
+ 'rustdoc',
+ 'rustfmt',
+ 'rustup',
+]);
+
+export function ciDocuments(root) {
+ return ciFiles(root).map((file) => ({
+ file,
+ document: parse(readFileSync(join(root, file), 'utf8')),
+ }));
+}
+
+const stepLabel = (step, index) => step.name ?? step.uses ?? `step ${index + 1}`;
+
+function* stepPlaces(file, job, steps) {
+ for (const [index, step] of (steps ?? []).entries()) {
+ yield { file, job, step: stepLabel(step, index), env: step.env, where: 'the step env', body: step };
+ }
+}
+
+function* places(file, document) {
+ if (document?.jobs !== undefined) {
+ yield { file, job: null, step: null, env: document.env, where: 'the workflow env' };
+ for (const [job, body] of Object.entries(document.jobs)) {
+ yield { file, job, step: null, env: body.env, where: 'the job env' };
+ yield { file, job, step: null, env: body.container?.env, where: "the job container's env" };
+ yield* stepPlaces(file, job, body.steps);
+ }
+ return;
+ }
+ if (document?.runs !== undefined) {
+ yield* stepPlaces(file, null, document.runs.steps);
+ return;
+ }
+ throw new Error(`${file} is neither a workflow (no jobs) nor an action (no runs)`);
+}
+
+const INSTALL_OPTIONS = ['--profile', '-c', '--component', '-t', '--target'];
+const NAMING_SUBCOMMANDS = new Map([
+ ['default', []],
+ ['install', INSTALL_OPTIONS],
+ ['override set', ['--path']],
+ ['run', []],
+ ['toolchain install', INSTALL_OPTIONS],
+ ['update', []],
+]);
+const NESTED = new Set(['override', 'toolchain']);
+const REDIRECT = /^\d*(?:[<>]|&>)/;
+const BARE_REDIRECT = /^\d*(?:>>?|<|&>>?|>\|)$/;
+
+const unquoted = (word) => word.replace(/^["']|["']$/g, '');
+const toolName = (word) =>
+ unquoted(word)
+ .split(/[\\/]/)
+ .pop()
+ .replace(/\.exe$/i, '');
+const invokesRust = (word) => PROXIES.has(toolName(word));
+const mentionsVariable = (word) => /RUSTUP_TOOLCHAIN/i.test(word);
+
+function withoutComment(line) {
+ let quote = null;
+ for (let at = 0; at < line.length; at += 1) {
+ const char = line[at];
+ if (quote !== null) {
+ if (char === quote) quote = null;
+ else if (char === '\\' && quote === '"') at += 1;
+ } else if (char === '"' || char === "'") quote = char;
+ else if (char === '\\') at += 1;
+ else if (char === '#' && (at === 0 || /[\s;&|(]/.test(line[at - 1]))) return line.slice(0, at);
+ }
+ return line;
+}
+
+function shellCommands(run) {
+ const expressions = [];
+ return run
+ .replace(/\$\{\{[\s\S]*?\}\}/g, (expression) => `\uE000${expressions.push(expression) - 1}\uE000`)
+ .split(/\r?\n/)
+ .map(withoutComment)
+ .join('\n')
+ .replace(/\\\n/g, ' ')
+ .split(/\n|&&|\|\||[;|`()]|\$\(/)
+ .map((command) =>
+ command
+ .trim()
+ .split(/\s+/)
+ .filter(Boolean)
+ .map((word) => word.replace(/\uE000(\d+)\uE000/g, (_match, index) => expressions[index])),
+ )
+ .filter((words) => words.some((word) => invokesRust(word) || mentionsVariable(word)));
+}
+
+function toolchainOption(words) {
+ const at = words.findIndex((word) => word === '--toolchain' || word.startsWith('--toolchain='));
+ if (at === -1) return undefined;
+ return words[at].includes('=') ? words[at].slice(words[at].indexOf('=') + 1) : words[at + 1];
+}
+
+function rustupNaming(words) {
+ const option = toolchainOption(words);
+ if (option !== undefined) return option;
+ let at = 0;
+ while (words[at]?.startsWith('-')) at += 1;
+ if (words[at]?.startsWith('+')) return words[at];
+ const subcommand = NESTED.has(words[at]) ? `${words[at]} ${words[at + 1]}` : words[at];
+ const valueOptions = NAMING_SUBCOMMANDS.get(subcommand);
+ if (valueOptions === undefined) return undefined;
+ const operands = words.slice(at + subcommand.split(' ').length);
+ for (let index = 0; index < operands.length; index += 1) {
+ const word = operands[index];
+ if (REDIRECT.test(word)) {
+ if (BARE_REDIRECT.test(word)) index += 1;
+ } else if (!word.startsWith('-')) return word;
+ else if (valueOptions.includes(word)) index += 1;
+ }
+ return undefined;
+}
+
+const assignsVariable = (words) =>
+ words.some(
+ (word, index) =>
+ /^(?:\$env:)?RUSTUP_TOOLCHAIN=/i.test(unquoted(word)) ||
+ (/^(?:\$env:)?RUSTUP_TOOLCHAIN$/i.test(unquoted(word)) && words[index + 1]?.startsWith('=')),
+ );
+
+function commandNaming(words) {
+ for (const [index, word] of words.entries()) {
+ if (!invokesRust(word)) continue;
+ const rest = words.slice(index + 1).map(unquoted);
+ const named =
+ toolName(word) === 'rustup' ? rustupNaming(rest) : rest[0]?.startsWith('+') ? rest[0] : undefined;
+ if (named !== undefined) return `names ${named}`;
+ }
+ return assignsVariable(words) ? 'sets RUSTUP_TOOLCHAIN' : undefined;
+}
+
+function actionNaming(step) {
+ if (typeof step.uses !== 'string') return undefined;
+ const input = Object.entries(step.with ?? {}).find(([key]) => /^toolchain$/i.test(key));
+ if (input !== undefined) return `passes ${input[0]}: ${input[1]} to ${step.uses}`;
+ return /^dtolnay\/rust-toolchain(?:[/@]|$)/i.test(step.uses) ? `uses ${step.uses}` : undefined;
+}
+
+export function rustToolchainSites(documents) {
+ if (documents.length === 0) {
+ throw new Error('no workflow or action was given, so nothing was judged');
+ }
+ const commands = [];
+ const findings = [];
+ for (const { file, document } of documents) {
+ for (const { body, env, where, ...site } of places(file, document)) {
+ const pin = Object.keys(env ?? {}).find((key) => /^RUSTUP_TOOLCHAIN$/i.test(key));
+ if (pin !== undefined) {
+ findings.push({ ...site, kind: 'env', detail: `sets ${pin}: ${env[pin]} in ${where}` });
+ }
+ if (body === undefined) continue;
+ const action = actionNaming(body);
+ if (action !== undefined) findings.push({ ...site, kind: 'action', detail: action });
+ if (typeof body.run === 'string') {
+ for (const words of shellCommands(body.run)) {
+ const command = words.join(' ');
+ commands.push({ ...site, command });
+ const naming = commandNaming(words);
+ if (naming !== undefined) {
+ findings.push({ ...site, kind: 'command', detail: `${command} ${naming}` });
+ }
+ }
+ }
+ }
+ }
+ return { commands, findings };
+}
diff --git a/.github/scripts/rust-toolchain-sites.test.mjs b/.github/scripts/rust-toolchain-sites.test.mjs
new file mode 100644
index 000000000..07f493b92
--- /dev/null
+++ b/.github/scripts/rust-toolchain-sites.test.mjs
@@ -0,0 +1,279 @@
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import { parse } from 'yaml';
+import { ciDocuments, rustToolchainSites } from './rust-toolchain-sites.test-helper.mjs';
+
+const OK_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
+const WORKFLOW = '.github/workflows/fixture.yml';
+const ACTION = '.github/composite-actions/fixture/action.yml';
+
+const inWorkflow = (fields, job) => [
+ {
+ file: WORKFLOW,
+ document: {
+ on: 'push',
+ ...fields,
+ jobs: { build: { 'runs-on': 'ubuntu-latest', steps: [{ run: 'make' }], ...job } },
+ },
+ },
+];
+const inStep = (...steps) => inWorkflow({}, { steps });
+const inAction = (step) => [
+ { file: ACTION, document: { name: 'fixture', runs: { using: 'composite', steps: [step] } } },
+];
+const PIN = { RUSTUP_TOOLCHAIN: '1.95.0' };
+
+describe('no workflow or composite action under .github names a Rust toolchain', () => {
+ const documents = ciDocuments(OK_ROOT);
+ const { commands, findings } = rustToolchainSites(documents);
+
+ test('the sweep read workflows, composite actions and a toolchain acquisition', () => {
+ expect(documents.filter(({ file }) => file.startsWith('.github/workflows/'))).not.toEqual([]);
+ expect(documents.filter(({ file }) => /\/action\.ya?ml$/.test(file))).not.toEqual([]);
+ expect(
+ commands.filter(({ command }) => /^rustup toolchain install(?: |$)/.test(command)),
+ ).not.toEqual([]);
+ });
+
+ test('a toolchain planted into a real acquisition step is reported there, once', () => {
+ const acquisition = commands.find(({ command }) =>
+ /^rustup toolchain install(?: |$)/.test(command),
+ );
+ const planted = structuredClone(documents);
+ const { document } = planted.find(({ file }) => file === acquisition.file);
+ const step = document.jobs[acquisition.job].steps.find(
+ (candidate) => candidate.name === acquisition.step,
+ );
+ step.run = step.run.replace('rustup toolchain install', 'rustup toolchain install 1.95.0');
+ expect(rustToolchainSites(planted).findings).toEqual([
+ expect.objectContaining({
+ file: acquisition.file,
+ job: acquisition.job,
+ step: acquisition.step,
+ kind: 'command',
+ detail: expect.stringContaining('names 1.95.0'),
+ }),
+ ]);
+ });
+
+ test('no workflow, job or step names one', () => {
+ expect(
+ findings,
+ 'rust-toolchain.toml at the Open Knowledge root declares the toolchain; a job acquires it with a bare `rustup toolchain install` run in the tree it builds',
+ ).toEqual([]);
+ });
+});
+
+const atStep = (kind) => ({ file: WORKFLOW, job: 'build', step: 'plant', kind });
+
+describe('the rule reports each place a CI file names a Rust toolchain, once', () => {
+ test.each([
+ [
+ 'dtolnay/rust-toolchain with no inputs',
+ inStep({ name: 'plant', uses: 'dtolnay/rust-toolchain@stable' }),
+ atStep('action'),
+ ],
+ [
+ 'dtolnay/rust-toolchain with toolchain: 1.95.0',
+ inStep({
+ name: 'plant',
+ uses: 'dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8',
+ with: { toolchain: '1.95.0' },
+ }),
+ atStep('action'),
+ ],
+ [
+ 'another action given a toolchain input',
+ inStep({
+ name: 'plant',
+ uses: 'actions-rust-lang/setup-rust-toolchain@v1',
+ with: { toolchain: '1.95.0', cache: false },
+ }),
+ atStep('action'),
+ ],
+ [
+ 'RUSTUP_TOOLCHAIN in the workflow env',
+ inWorkflow({ env: PIN }, {}),
+ { file: WORKFLOW, job: null, step: null, kind: 'env' },
+ ],
+ [
+ 'RUSTUP_TOOLCHAIN in a job env',
+ inWorkflow({}, { env: PIN }),
+ { file: WORKFLOW, job: 'build', step: null, kind: 'env' },
+ ],
+ [
+ "RUSTUP_TOOLCHAIN in a job container's env",
+ inWorkflow({}, { container: { image: 'rust:1', env: PIN } }),
+ { file: WORKFLOW, job: 'build', step: null, kind: 'env' },
+ ],
+ [
+ 'RUSTUP_TOOLCHAIN in a step env',
+ inStep({ name: 'plant', run: 'cargo build', env: PIN }),
+ atStep('env'),
+ ],
+ [
+ 'RUSTUP_TOOLCHAIN in a composite action step env',
+ inAction({ name: 'plant', shell: 'bash', run: 'cargo build', env: PIN }),
+ { file: ACTION, job: null, step: 'plant', kind: 'env' },
+ ],
+ ['cargo +1.95.0 build', inStep({ name: 'plant', run: 'cargo +1.95.0 build' }), atStep('command')],
+ [
+ 'rustup default stable',
+ inStep({ name: 'plant', run: 'rustup default stable' }),
+ atStep('command'),
+ ],
+ [
+ 'rustup toolchain install 1.95.0',
+ inStep({ name: 'plant', run: 'rustup toolchain install 1.95.0' }),
+ atStep('command'),
+ ],
+ ])('%s', (_form, documents, expected) => {
+ expect(rustToolchainSites(documents).findings).toEqual([expect.objectContaining(expected)]);
+ });
+
+ test.each([
+ ['rustup install 1.95.0', 'names 1.95.0'],
+ ['rustup update stable', 'names stable'],
+ ['rustup run 1.95.0 cargo build', 'names 1.95.0'],
+ ['rustup override set 1.95.0', 'names 1.95.0'],
+ ['rustup override set --path packages/native-config 1.95.0', 'names 1.95.0'],
+ ['rustup toolchain install --profile minimal -c rustfmt 1.95.0', 'names 1.95.0'],
+ ['rustup -q toolchain install 1.95.0', 'names 1.95.0'],
+ ['rustup +nightly show', 'names +nightly'],
+ ['rustup component add --toolchain nightly rustfmt', 'names nightly'],
+ ['rustup target add --toolchain=1.95.0 x86_64-unknown-linux-musl', 'names 1.95.0'],
+ ['rustfmt +nightly --check src/lib.rs', 'names +nightly'],
+ ['"$HOME/.cargo/bin/cargo" +1.95.0 build', 'names +1.95.0'],
+ ['cargo.exe +1.95.0 build', 'names +1.95.0'],
+ ['pnpm exec cargo +1.95.0 build', 'names +1.95.0'],
+ ['rustup toolchain install \\\n 1.95.0', 'names 1.95.0'],
+ ['rustup toolchain install ${{ matrix.rust }}', 'names ${{ matrix.rust }}'],
+ ['cargo +${{ matrix.rust }} build', 'names +${{ matrix.rust }}'],
+ ['rustup show && cargo +1.95.0 build', 'names +1.95.0'],
+ ['echo "build #1" && cargo +1.95.0 build', 'names +1.95.0'],
+ ['echo ${#PATH}; cargo +1.95.0 build', 'names +1.95.0'],
+ ['RUSTUP_TOOLCHAIN=1.95.0 cargo build', 'sets RUSTUP_TOOLCHAIN'],
+ ['export RUSTUP_TOOLCHAIN=1.95.0', 'sets RUSTUP_TOOLCHAIN'],
+ ['echo "RUSTUP_TOOLCHAIN=1.95.0" >> "$GITHUB_ENV"', 'sets RUSTUP_TOOLCHAIN'],
+ ["$env:RUSTUP_TOOLCHAIN = '1.95.0'", 'sets RUSTUP_TOOLCHAIN'],
+ ])('a run step: %s', (run, naming) => {
+ expect(rustToolchainSites(inStep({ name: 'plant', run })).findings).toEqual([
+ expect.objectContaining({ ...atStep('command'), detail: expect.stringContaining(naming) }),
+ ]);
+ });
+});
+
+describe('the rule stays quiet where a CI file names no toolchain', () => {
+ test('an action input named tool, and a step named for a toolchain', () => {
+ const documents = [
+ {
+ file: WORKFLOW,
+ document: {
+ on: 'push',
+ jobs: {
+ build: {
+ 'runs-on': 'ubuntu-latest',
+ steps: [
+ {
+ name: 'Install cargo-zigbuild',
+ uses: 'taiki-e/install-action@v2',
+ with: { tool: 'cargo-zigbuild' },
+ },
+ { name: 'Cache Corepack toolchain', uses: 'actions/cache@v4', with: { path: 'p' } },
+ ],
+ },
+ },
+ },
+ },
+ ];
+ expect(rustToolchainSites(documents).findings).toEqual([]);
+ });
+
+ test('an acquisition step, Rust commands that select nothing, and comments that mention dtolnay', () => {
+ const documents = [
+ {
+ file: WORKFLOW,
+ document: parse(`
+on: push
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ # dtolnay/rust-toolchain@stable installed the toolchain here
+ - name: Install the declared Rust toolchain
+ run: |
+ # dtolnay/rust-toolchain ran rustup default stable, then cargo +stable build
+ rustup toolchain install
+ rustup toolchain install --no-self-update
+ rustup toolchain install --no-self-update --profile minimal -c rustfmt -t x86_64-unknown-linux-musl
+ rustup target add x86_64-unknown-linux-musl
+ rustup show
+ rustc -vV
+ cargo test --manifest-path packages/native-config/Cargo.toml
+`),
+ },
+ ];
+ const { commands, findings } = rustToolchainSites(documents);
+ expect(commands.map(({ command }) => command)).toEqual([
+ 'rustup toolchain install',
+ 'rustup toolchain install --no-self-update',
+ 'rustup toolchain install --no-self-update --profile minimal -c rustfmt -t x86_64-unknown-linux-musl',
+ 'rustup target add x86_64-unknown-linux-musl',
+ 'rustup show',
+ 'rustc -vV',
+ 'cargo test --manifest-path packages/native-config/Cargo.toml',
+ ]);
+ expect(findings).toEqual([]);
+ });
+
+ test('run steps that redirect, clear or read the toolchain variable, and bare rustup commands', () => {
+ const runs = [
+ 'rustup toolchain install --no-self-update 2>&1 | tee install.log',
+ 'rustup toolchain install --no-self-update > install.log',
+ 'rustup toolchain install --no-self-update && rustc -vV',
+ 'rustup toolchain install --default --no-self-update',
+ 'rustup update',
+ 'rustup update --no-self-update',
+ 'rustup default',
+ 'unset RUSTUP_TOOLCHAIN',
+ 'env -u RUSTUP_TOOLCHAIN cargo build',
+ 'test -z "$RUSTUP_TOOLCHAIN" && rustc -vV',
+ ];
+ const { commands, findings } = rustToolchainSites(
+ inStep(...runs.map((run, index) => ({ name: `quiet ${index + 1}`, run }))),
+ );
+ expect(new Set(commands.map(({ step }) => step))).toEqual(
+ new Set(runs.map((_run, index) => `quiet ${index + 1}`)),
+ );
+ expect(findings).toEqual([]);
+ });
+
+ test('env maps that set other Rust variables', () => {
+ const others = { RUSTUP_HOME: '/opt/rustup', CARGO_INCREMENTAL: '0', RUSTUP_TOOLCHAIN_X: '1' };
+ const documents = [
+ ...inWorkflow(
+ { env: others },
+ {
+ env: others,
+ container: { image: 'rust:1', env: others },
+ steps: [{ name: 'build', run: 'cargo build', env: others }],
+ },
+ ),
+ ...inAction({ name: 'build', shell: 'bash', run: 'cargo build', env: others }),
+ ];
+ expect(rustToolchainSites(documents).findings).toEqual([]);
+ });
+});
+
+describe('the rule refuses input it cannot judge', () => {
+ test('an empty file list', () => {
+ expect(() => rustToolchainSites([])).toThrow(/no workflow or action was given/);
+ });
+
+ test('a file that is neither a workflow nor an action', () => {
+ expect(() =>
+ rustToolchainSites([{ file: '.github/workflows/empty.yml', document: null }]),
+ ).toThrow(/\.github\/workflows\/empty\.yml is neither a workflow \(no jobs\) nor an action/);
+ });
+});
diff --git a/.github/workflows/bug-lane-verify.yml b/.github/workflows/bug-lane-verify.yml
index a85962a54..b03b8641a 100644
--- a/.github/workflows/bug-lane-verify.yml
+++ b/.github/workflows/bug-lane-verify.yml
@@ -136,7 +136,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
@@ -277,6 +277,17 @@ jobs:
echo "::warning::bug-lane: pnpm install --frozen-lockfile failed on the synthetic tree (${STABLE} + ${SURVIVING_REFS}); treated as a red verification."
exit 0
fi
+ if ! { rustup toolchain install --no-self-update && rustc -vV; }; then
+ {
+ echo "verdict=could-not-verify"
+ echo "cause=toolchain"
+ echo "failures<<FAILURES_EOF"
+ echo '["the declared Rust toolchain could not be installed"]'
+ echo "FAILURES_EOF"
+ } >> "$GITHUB_OUTPUT"
+ echo "::warning::bug-lane: the declared Rust toolchain could not be installed for ${STABLE} + ${SURVIVING_REFS}. COULD NOT VERIFY, which is not a verdict on the batch."
+ exit 0
+ fi
# ONE flake retry, matching the stance the PR tier already applies to
# this same suite. Single-shot would hold the synthetic tree to a
# STRICTER bar than the tree that gates main, and these tiers include
@@ -606,7 +617,7 @@ jobs:
# one skips all of it: a bad stable ref, a checkout or setup step dying,
# or the job's own ceiling reached while the cherry-pick loop or install
# runs, none of which are inside the tiers' budget. (A failed install is
- # NOT one of these -- the guard above mints `fail` for it explicitly.)
+ # NOT one of these -- the guards above mint a verdict for it explicitly.)
# The tier wrapper closes the commonest door. This leaves a trace for the
# rest of the class -- but only in the run log, and this workflow's whole
# argument for a `could-not-verify` VERDICT is that the run log is not a
@@ -623,10 +634,10 @@ jobs:
echo "::warning::bug-lane: verify produced no verdict for ${STABLE} — COULD NOT VERIFY. Nothing here is evidence about the queued fixes; read the run log for where it stopped."
# `could-not-verify` is enrolled here too, and it is the one verdict that
- # is NOT a standing answer: it is a fact about one runner's clock. The
- # trade is deliberate and bounded -- the batch churns as new fixes
- # qualify, so the signature moves and the lane re-pages -- and the page
- # itself tells the reader to check recent runs rather than wait.
+ # is NOT a standing answer. The trade is deliberate and bounded -- the
+ # batch churns as new fixes qualify, so the signature moves and the lane
+ # re-pages -- and the page itself tells the reader to check recent runs
+ # rather than wait.
#
- name: Refusal signature
id: refusal
@@ -671,7 +682,7 @@ jobs:
{
echo "### Bug lane — refusal still standing, page suppressed"
echo "Verdict \`${VERDICT}\`, signature \`${SIG}\`, already paged on an earlier tick."
- echo "For named verification failures, grouping is per stable and failing suite for the UTC day. Conflicts, timeouts and unnamed failures use verdict and batch identity. Batch details remain in each run."
+ echo "For named verification failures, grouping is per stable and failing suite for the UTC day. Conflicts, could-not-verify ticks and unnamed failures use verdict and batch identity. Batch details remain in each run."
} >> "$GITHUB_STEP_SUMMARY"
echo "::notice::bug-lane: refusal ${SIG} already paged; suppressing the duplicate page."
@@ -687,6 +698,7 @@ jobs:
FAILURES: ${{ steps.verify.outputs.failures }}
STABLE: ${{ inputs.stable }}
VERDICT: ${{ steps.verify.outputs.verdict }}
+ CAUSE: ${{ steps.verify.outputs.cause }}
run: |
set -uo pipefail
# `delivered` is the ONLY thing the marker may key on. The step's own
@@ -728,12 +740,13 @@ jobs:
# page names the bug rather than only a SHA.
INPUT="$(jq -nc \
--arg verdict "$VERDICT" \
+ --arg cause "${CAUSE:-}" \
--arg stable "$STABLE" \
--arg runUrl "$RUN_URL" \
--argjson conflicts "$CONFLICTS_JSON" \
--argjson failures "$FAILURES_JSON" \
--argjson tickets "$TICKETS_JSON" \
- '{verdict: $verdict, stable: $stable, runUrl: $runUrl, failures: $failures,
+ '{verdict: $verdict, cause: $cause, stable: $stable, runUrl: $runUrl, failures: $failures,
refs: [$conflicts[] | . + {tickets: ($tickets[.ref] // [])}]}')"
# A page that cannot be composed must not become silence: fall back
# to the bare facts rather than skipping the POST, and leave the
diff --git a/.github/workflows/bug-lane.yml b/.github/workflows/bug-lane.yml
index d11faaa80..4035f6b31 100644
--- a/.github/workflows/bug-lane.yml
+++ b/.github/workflows/bug-lane.yml
@@ -90,7 +90,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Install root dependencies for the Changesets reader
run: |
@@ -119,7 +119,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- name: Evaluate qualifying fixes
diff --git a/.github/workflows/desktop-build-win-linux.yml b/.github/workflows/desktop-build-win-linux.yml
index 15412667e..9362ae0d9 100644
--- a/.github/workflows/desktop-build-win-linux.yml
+++ b/.github/workflows/desktop-build-win-linux.yml
@@ -78,7 +78,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
@@ -128,13 +128,10 @@ jobs:
echo "staged $count native-config prebuilt binaries from run $run_id"
judge_staging "staged $count native-config binaries from run $run_id"
- # The workspace build produces native-config's host `.node` via `napi
- # build` (turbo dep of the cli build), which needs a Rust toolchain —
- # mirror release.yml's explicit pin.
- - name: Setup Rust toolchain for the native-config build
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- with:
- toolchain: stable
+ - name: Install the declared Rust toolchain
+ run: |
+ rustup toolchain install --no-self-update
+ rustc -vV
- name: Build workspace (produces packages/cli/dist for extraResources)
run: |
@@ -190,7 +187,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
@@ -440,7 +437,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml
index a98038046..83b1af5e1 100644
--- a/.github/workflows/desktop-build.yml
+++ b/.github/workflows/desktop-build.yml
@@ -91,12 +91,9 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- # Node 24 matches the existing ci.yml / release.yml pattern —
- # turbo's `^build` pulls in the app via workspace deps that resolve
- # to `.ts` sources; Node 22.6+ strips TypeScript types natively.
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
@@ -112,6 +109,11 @@ jobs:
ELECTRON_SKIP_REBUILD: "0"
run: pnpm install --frozen-lockfile
+ - name: Install the declared Rust toolchain
+ run: |
+ rustup toolchain install --no-self-update
+ rustc -vV
+
- name: Build workspace (produces packages/cli/dist/public for extraResources)
run: |
pnpm exec turbo run build --filter=@inkeep/open-knowledge --cache=local:,remote:
@@ -391,6 +393,10 @@ jobs:
fi
echo "Attested $FOUND signed, notarized, stapled app bundle(s)."
+ - name: Assert the packaged server helper runs as Node
+ working-directory: packages/desktop
+ run: node scripts/assert-packaged-helper-runs-as-node.mjs dist-desktop "desktop-build (macOS .app)"
+
# Gate on success() — on build failure, there is no DMG, so running
# the upload step would stack a second "no files found" error on top
# of the real build error and dilute CI signal. The GHA run log
diff --git a/.github/workflows/desktop-release-draft-janitor.yml b/.github/workflows/desktop-release-draft-janitor.yml
index 0961477b3..8586e9e44 100644
--- a/.github/workflows/desktop-release-draft-janitor.yml
+++ b/.github/workflows/desktop-release-draft-janitor.yml
@@ -70,7 +70,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Delete superseded stuck draft releases
env:
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 1cd74a780..0703f2f22 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -286,7 +286,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
@@ -390,13 +390,10 @@ jobs:
echo "staged $count native-config prebuilt binaries from run $run_id (commit $head_sha)"
judge_staging "staged $count native-config binaries from run $run_id (commit $head_sha)"
- # The workspace build produces native-config's host `.node` via `napi
- # build` (turbo dep of the cli build), which needs a Rust toolchain —
- # mirror release.yml's explicit pin.
- - name: Setup Rust toolchain for the native-config build
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- with:
- toolchain: stable
+ - name: Install the declared Rust toolchain
+ run: |
+ rustup toolchain install --no-self-update
+ rustc -vV
# PRD-6650: under the zero-commit-bump cadence (release.yml header
# lines 7-10), workspace package.json files on disk at the tagged SHA
@@ -549,7 +546,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
@@ -584,6 +581,11 @@ jobs:
done
echo "All fixed-group package.json files + both skill bundles' metadata.version now at ${VERSION} (in-memory only)."
+ - name: Install the declared Rust toolchain
+ run: |
+ rustup toolchain install --no-self-update
+ rustc -vV
+
- name: Build workspace (produces packages/cli/dist/public for extraResources)
run: |
pnpm exec turbo run build --filter=@inkeep/open-knowledge --cache=local:,remote:
@@ -920,6 +922,10 @@ jobs:
fi
echo "Attested $FOUND signed, notarized, stapled app bundle(s)."
+ - name: Assert the packaged server helper runs as Node
+ working-directory: packages/desktop
+ run: node scripts/assert-packaged-helper-runs-as-node.mjs dist-desktop "desktop-release (signed macOS .app)"
+
- name: Verify a historical app can update in place
if: matrix.variant != 'beta'
env:
@@ -1054,7 +1060,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
@@ -1392,7 +1398,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
diff --git a/.github/workflows/linear-release.yml b/.github/workflows/linear-release.yml
index b39e8d4c5..322e5a191 100644
--- a/.github/workflows/linear-release.yml
+++ b/.github/workflows/linear-release.yml
@@ -120,7 +120,7 @@ jobs:
if: env.HAS_KEY == 'true'
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
# The script has no dependencies beyond node: builtins, so there is
# nothing to install between setup and this call.
diff --git a/.github/workflows/monorepo-pr-bridge.yml b/.github/workflows/monorepo-pr-bridge.yml
index 28b36964d..0c1d60e92 100644
--- a/.github/workflows/monorepo-pr-bridge.yml
+++ b/.github/workflows/monorepo-pr-bridge.yml
@@ -41,7 +41,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: 22
+ node-version-file: .node-version
- name: Acknowledge public PR
env:
@@ -73,7 +73,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: 22
+ node-version-file: .node-version
- name: Generate inkeep-oss-sync App token
id: app-token
@@ -150,7 +150,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: 22
+ node-version-file: .node-version
- name: Generate inkeep-oss-sync App token
id: app-token
@@ -189,7 +189,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: 22
+ node-version-file: .node-version
- name: Generate inkeep-oss-sync App token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
diff --git a/.github/workflows/native-config-prebuild.yml b/.github/workflows/native-config-prebuild.yml
index e58d36920..53a21543e 100644
--- a/.github/workflows/native-config-prebuild.yml
+++ b/.github/workflows/native-config-prebuild.yml
@@ -22,14 +22,16 @@ on:
# unconditionally — the full 8-target matrix re-ran on every release
# regardless of whether native-config changed. A branch filter excludes
# tag refs (tags never match `branches`), keeping this scoped to actual
- # native-config source changes on main.
+ # native-config changes on main.
branches: [main]
paths:
- "packages/native-config/**"
+ - "rust-toolchain.toml"
- ".github/workflows/native-config-prebuild.yml"
pull_request:
paths:
- "packages/native-config/**"
+ - "rust-toolchain.toml"
- ".github/workflows/native-config-prebuild.yml"
# Per-ref isolation — a new push to the same branch cancels the in-flight run.
@@ -93,14 +95,15 @@ jobs:
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- - name: Setup Rust toolchain
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- with:
- toolchain: stable
- targets: ${{ matrix.settings.target }}
+ - name: Install the declared Rust toolchain and the matrix target
+ shell: bash
+ run: |
+ rustup toolchain install --no-self-update
+ rustup target add ${{ matrix.settings.target }}
+ rustc -vV
- name: Install Zig 0.14.1 from a mirror, checked against its sha256 (musl targets only)
if: contains(matrix.settings.target, 'musl')
@@ -168,6 +171,8 @@ jobs:
if: matrix.settings.target == 'x86_64-pc-windows-msvc'
working-directory: packages/native-config
shell: bash
+ env:
+ CARGO_INCREMENTAL: '0'
run: cargo test
- name: Upload binding
diff --git a/.github/workflows/point-release.yml b/.github/workflows/point-release.yml
index 0a12e81fe..96c1e9bce 100644
--- a/.github/workflows/point-release.yml
+++ b/.github/workflows/point-release.yml
@@ -128,7 +128,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Install root dependencies for the Changesets reader
run: |
@@ -177,7 +177,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Prepare git for the synthetic commit
run: |
diff --git a/.github/workflows/promote-stable.yml b/.github/workflows/promote-stable.yml
index ad18358a0..5b55e2c55 100644
--- a/.github/workflows/promote-stable.yml
+++ b/.github/workflows/promote-stable.yml
@@ -158,7 +158,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Install root dependencies for the Changesets reader
run: |
@@ -286,7 +286,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Compute stable version from beta tag
id: ver
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5f003fc74..07dd93e0f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -201,7 +201,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- name: Ensure npm 11 for the cli's package surface check
@@ -301,15 +301,10 @@ jobs:
echo "staged $count native-config prebuilt binaries from run $run_id (commit $head_sha)"
judge_staging "staged $count native-config binaries from run $run_id (commit $head_sha)"
- # The workspace build produces native-config's host `.node` via `napi
- # build` (turbo dep of the cli build), which needs a Rust toolchain.
- # Pin it explicitly rather than relying on whatever `ubuntu-latest`
- # preinstalls, so an image change can't silently break the whole publish at
- # the unguarded cargo invocation. Mirrors native-config-prebuild.yml.
- - name: Setup Rust toolchain for the native-config build
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- with:
- toolchain: stable
+ - name: Install the declared Rust toolchain
+ run: |
+ rustup toolchain install --no-self-update
+ rustc -vV
- name: Build packages
run: |
@@ -713,7 +708,7 @@ jobs:
- name: Setup Node for npm OIDC publish
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version: "24.21.0"
registry-url: "https://registry.npmjs.org"
# UPSTREAM(npm/cli#9722): npm 12.0.0 shipped without the sigstore module libnpmpublish loads for provenance.
diff --git a/.github/workflows/select-beta-to-promote.yml b/.github/workflows/select-beta-to-promote.yml
index cfa966c91..0471866ba 100644
--- a/.github/workflows/select-beta-to-promote.yml
+++ b/.github/workflows/select-beta-to-promote.yml
@@ -168,7 +168,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Install root dependencies for the Changesets reader
run: |
@@ -238,7 +238,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- name: Select the beta to promote
@@ -390,7 +390,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Install dependencies
run: |
@@ -523,7 +523,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- name: Evaluate the aggregate alarm
@@ -590,7 +590,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
package-manager-cache: false
- name: Write the handed-over acknowledgement
diff --git a/.github/workflows/share-contract-monitor.yml b/.github/workflows/share-contract-monitor.yml
index 6e46bb100..c90a4607f 100644
--- a/.github/workflows/share-contract-monitor.yml
+++ b/.github/workflows/share-contract-monitor.yml
@@ -27,7 +27,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Probe production reader contract
id: probe
diff --git a/.github/workflows/write-back.yml b/.github/workflows/write-back.yml
index 2c7aec6a8..5f94f9bf9 100644
--- a/.github/workflows/write-back.yml
+++ b/.github/workflows/write-back.yml
@@ -88,7 +88,7 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
- node-version: "24"
+ node-version-file: .node-version
- name: Resolve published release for reconciliation
id: tag
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2e6a55085..eb7f7a4f9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -35,6 +35,8 @@ See `.env.example` for optional settings (OpenTelemetry, a custom dev port).
The repo pins **Node.js 24.21.0** in `.node-version` and in `package.json`'s `devEngines.runtime`, and the `packageManager` field selects the exact **pnpm 12** version. `pnpm install` downloads that Node.js into the pnpm store the first time, from the per-platform archives `pnpm-lock.yaml` pins by checksum, so the first install needs network access. After that, every command started through `pnpm run`, `pnpm exec` or a package script runs on it, whichever `node` is on your `PATH`, and `engineStrict` in `pnpm-workspace.yaml` checks the `engines.node` range against it. Keep the two pins equal, and run `pnpm install` after changing them so the commands, and the Turbo cache key the install writes, pick up the new version. Corepack and npm both need a Node.js to provide pnpm, so install the `.node-version` release first with your Node version manager (for example `fnm install`), then run `corepack enable pnpm` once so the `pnpm` commands below use Corepack's shim, or install pnpm 12 with `npm install -g pnpm@12`. The standalone installer from [pnpm.io/installation](https://pnpm.io/installation) needs no Node.js. A pnpm 10 on your `PATH` cannot switch itself to pnpm 12, so upgrade it or use Corepack. For a script you start with `node` directly, select `.node-version` first with your Node version manager, for example `fnm use`.
+Rust is pinned to one exact release. `rust-toolchain.toml` at the repo root declares it, and rustup applies it to every `cargo` and `rustc` call inside the repository and installs that release on the first build, so that build needs network access once. Install rustup from [rustup.rs](https://rustup.rs). The native-config package's build script refuses any other compiler: a `RUSTUP_TOOLCHAIN` variable, a `+toolchain` argument, a `rustup override` set on the directory, or a `cargo` or `rustc` earlier on your `PATH` that rustup does not manage (a Homebrew, distribution or Nix install, for example). Its error names the compiler it found and the release the file declares.
+
TypeScript is pinned twice on purpose. `@typescript/native` is this repo's alias for `typescript@~7.0.2`, the Go compiler the gates run; it owns the `tsc` binary, so `node_modules/.bin/tsc --version` at the root reports 7. The root's own `typescript` stays on `~6.0.3` only to supply tsserver to your editor, because TypeScript 7 ships none — that is an API resolution, not the compiler. The split means 7.0-only lib typings or an unchecked side-effect import can red a gate your editor calls clean. Open your editor at the repo root, not inside a package, or its language server falls back to a machine-global TypeScript. Any package that runs `tsc` in a script declares `"typescript": "~7.0.2"` of its own; `node scripts/check-typescript-resolution.mjs`, which `pnpm run check:drift:guards` runs, enforces the *resolved* 7.0 line rather than the declared range; the range is a tilde for that reason, because a caret installs clean today and reds once 7.1 ships. Its errors say why.
The base `tsconfig.json` carries three settings that red a first build. `erasableSyntaxOnly: true` makes constructor parameter properties (`constructor(private foo: string)`) an error; write the assignment out. `verbatimModuleSyntax: true` makes a plain `import { SomeType }` an error; write `import type`. `types: []` turns off automatic `@types/*` inclusion, so a package that uses Node globals lists `"types": ["node"]` in its own `tsconfig.json` and `@types/node` in its own `package.json`.
diff --git a/knip.config.ts b/knip.config.ts
index 65f0e8807..c33b744b2 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -40,6 +40,7 @@ export default {
'xdg-mime', // Linux default-app query — desktop ipc-handlers.ts
'ssh-keygen', // ephemeral VM keypair — lume-qa lume-orchestrator.ts
'zsh', // the executor's `.private.` test also runs the printed Biome fix under zsh -c
+ 'rustup',
],
ignoreIssues: {
'test-support/vitest.base.ts': ['exports'],
@@ -147,11 +148,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('|');
diff --git a/packages/native-config/build.rs b/packages/native-config/build.rs
index e4d638e97..3080ac308 100644
--- a/packages/native-config/build.rs
+++ b/packages/native-config/build.rs
@@ -1,4 +1,7 @@
+mod toolchain_guard;
+
fn main() {
+ toolchain_guard::require_declared_rustc();
napi_build::setup();
// `napi_build::setup()` only applies `-undefined dynamic_lookup` to the
diff --git a/packages/native-config/package.json b/packages/native-config/package.json
index 41e61653a..bea806938 100644
--- a/packages/native-config/package.json
+++ b/packages/native-config/package.json
@@ -27,7 +27,7 @@
"scripts": {
"build": "node scripts/build.mjs --release",
"build:debug": "node scripts/build.mjs",
- "test": "cargo test && node --test scripts/build.test.mjs"
+ "test": "cargo test && node --test scripts/build.test.mjs && node --test scripts/toolchain-guard.test.mjs"
},
"devDependencies": {
"@napi-rs/cli": "^3.7.2"
diff --git a/packages/native-config/scripts/toolchain-guard.test.mjs b/packages/native-config/scripts/toolchain-guard.test.mjs
new file mode 100644
index 000000000..e8922732b
--- /dev/null
+++ b/packages/native-config/scripts/toolchain-guard.test.mjs
@@ -0,0 +1,164 @@
+import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join } from 'node:path';
+import { after, before, describe, test } from 'node:test';
+import { fileURLToPath } from 'node:url';
+
+const packageDir = dirname(dirname(fileURLToPath(import.meta.url)));
+const guardModule = join(packageDir, 'toolchain_guard.rs');
+
+function toolchainBinary(name) {
+ const which = spawnSync('rustup', ['which', name], { cwd: packageDir, encoding: 'utf8' });
+ if (which.error?.code === 'ENOENT') return name;
+ assert.equal(which.status, 0, `rustup which ${name} failed: ${which.stderr}`);
+ return which.stdout.trim();
+}
+
+function declaration(channel) {
+ return `[toolchain]\nchannel = "${channel}"\nprofile = "minimal"\n`;
+}
+
+describe('the declared Rust toolchain guard', () => {
+ let root;
+ let cargo;
+ let rustc;
+ let release;
+
+ before(() => {
+ root = mkdtempSync(join(tmpdir(), 'native-config-toolchain-guard-'));
+ cargo = toolchainBinary('cargo');
+ rustc = toolchainBinary('rustc');
+ const version = spawnSync(rustc, ['-vV'], { encoding: 'utf8' });
+ assert.equal(version.status, 0, `${rustc} -vV failed: ${version.stderr}`);
+ release = version.stdout.match(/^release: (\S+)$/m)?.[1];
+ assert.match(release ?? '', /^\d+\.\d+\.\d+$/, `${rustc} is not a stable release`);
+ });
+
+ after(() => {
+ rmSync(root, { recursive: true, force: true });
+ });
+
+ function guardedCrate(declared) {
+ const workspace = mkdtempSync(join(root, 'workspace-'));
+ if (declared !== null) writeFileSync(join(workspace, 'rust-toolchain.toml'), declared);
+ const crate = join(workspace, 'packages', 'guarded');
+ mkdirSync(join(crate, 'src'), { recursive: true });
+ writeFileSync(
+ join(crate, 'Cargo.toml'),
+ '[package]\nname = "guarded"\nversion = "0.0.0"\nedition = "2021"\npublish = false\n\n[workspace]\n',
+ );
+ writeFileSync(join(crate, 'src', 'lib.rs'), '');
+ writeFileSync(
+ join(crate, 'build.rs'),
+ `#[path = ${JSON.stringify(guardModule)}]\nmod toolchain_guard;\n\nfn main() {\n toolchain_guard::require_declared_rustc();\n}\n`,
+ );
+ return { workspace, crate };
+ }
+
+ function build({ workspace, crate }, ...flags) {
+ const result = spawnSync(
+ cargo,
+ [
+ 'build',
+ '--offline',
+ '--color',
+ 'never',
+ '--target-dir',
+ join(workspace, 'target'),
+ ...flags,
+ ],
+ { cwd: crate, encoding: 'utf8', env: { ...process.env, RUSTC: rustc } },
+ );
+ assert.equal(result.error, undefined, `${cargo} build did not run: ${result.error}`);
+ return result;
+ }
+
+ function assertRefused(result, ...reasons) {
+ assert.equal(
+ typeof result.status,
+ 'number',
+ `cargo build ended without a status: ${result.signal}`,
+ );
+ assert.notEqual(result.status, 0, `cargo build passed:\n${result.stderr}`);
+ for (const reason of reasons)
+ assert.ok(
+ result.stderr.includes(reason),
+ `missing ${JSON.stringify(reason)} in:\n${result.stderr}`,
+ );
+ }
+
+ function anotherRelease() {
+ const [major, minor, patch] = release.split('.');
+ return `${major}.${minor}.${Number(patch) + 1}`;
+ }
+
+ test('refuses a compiler whose release differs from the declared channel, naming both', () => {
+ const other = anotherRelease();
+ const result = build(guardedCrate(declaration(other)));
+ assertRefused(result, `rustc ${release} is not the declared Rust release ${other}`);
+ });
+
+ test('builds when the declared channel is the compiler release, and asks cargo to re-check', () => {
+ const result = build(guardedCrate(declaration(release)), '-vv');
+ assert.equal(result.status, 0, result.stderr);
+ const directives = `${result.stdout}${result.stderr}`.split('\n').flatMap((line) => {
+ const at = line.indexOf('cargo:');
+ return at === -1 ? [] : [line.slice(at).trimEnd()];
+ });
+ assert.equal(
+ directives.filter((directive) =>
+ /^cargo:rerun-if-changed=.*rust-toolchain\.toml$/.test(directive),
+ ).length,
+ 1,
+ directives.join('\n'),
+ );
+ assert.ok(
+ directives.includes('cargo:rerun-if-env-changed=RUSTUP_TOOLCHAIN'),
+ directives.join('\n'),
+ );
+ });
+
+ test('refuses the stable channel, which names no exact release', () => {
+ const result = build(guardedCrate(declaration('stable')));
+ assertRefused(
+ result,
+ 'the declared channel "stable" is not an exact MAJOR.MINOR.PATCH release',
+ );
+ });
+
+ test('refuses a channel that names only a minor release', () => {
+ const minorOnly = release.split('.').slice(0, 2).join('.');
+ const result = build(guardedCrate(declaration(minorOnly)));
+ assertRefused(
+ result,
+ `the declared channel "${minorOnly}" is not an exact MAJOR.MINOR.PATCH release`,
+ );
+ });
+
+ test('refuses a build with no declaration, naming the file it looked for', () => {
+ const result = build(guardedCrate(null));
+ assertRefused(result, 'cannot read the Rust toolchain declaration', 'declared channel: none');
+ assert.match(result.stderr, /^\s*declaration: .*rust-toolchain\.toml$/m);
+ });
+
+ test('reads the channel only from the toolchain table', () => {
+ const result = build(guardedCrate(`[profile]\nchannel = "${release}"\n`));
+ assertRefused(result, 'the Rust toolchain declaration names no channel under [toolchain]');
+ });
+
+ test('reads a declaration checked out with CRLF line endings', () => {
+ const result = build(guardedCrate(declaration(release).replaceAll('\n', '\r\n')));
+ assert.equal(result.status, 0, result.stderr);
+ });
+
+ test('checks the declaration again when it changes after a green build', () => {
+ const crate = guardedCrate(declaration(release));
+ const first = build(crate);
+ assert.equal(first.status, 0, first.stderr);
+ const other = anotherRelease();
+ writeFileSync(join(crate.workspace, 'rust-toolchain.toml'), declaration(other));
+ assertRefused(build(crate), `rustc ${release} is not the declared Rust release ${other}`);
+ });
+});
diff --git a/packages/native-config/toolchain_guard.rs b/packages/native-config/toolchain_guard.rs
new file mode 100644
index 000000000..6a39cf273
--- /dev/null
+++ b/packages/native-config/toolchain_guard.rs
@@ -0,0 +1,101 @@
+use std::env;
+use std::fs;
+use std::path::PathBuf;
+use std::process::Command;
+
+pub fn require_declared_rustc() {
+ let manifest_dir = PathBuf::from(
+ env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR for build scripts"),
+ );
+ let declaration = manifest_dir
+ .join("..")
+ .join("..")
+ .join("rust-toolchain.toml");
+ println!("cargo:rerun-if-changed={}", declaration.display());
+ println!("cargo:rerun-if-env-changed=RUSTUP_TOOLCHAIN");
+ let release = compiler_release();
+ let channel = fs::read_to_string(&declaration).map(|text| declared_channel(&text));
+ let problem = match &channel {
+ Err(error) => format!("cannot read the Rust toolchain declaration: {}", error),
+ Ok(None) => "the Rust toolchain declaration names no channel under [toolchain]".to_string(),
+ Ok(Some(channel)) if !is_exact_release(channel) => format!(
+ "the declared channel \"{}\" is not an exact MAJOR.MINOR.PATCH release",
+ channel
+ ),
+ Ok(Some(channel)) if *channel != release => {
+ format!(
+ "rustc {} is not the declared Rust release {}",
+ release, channel
+ )
+ }
+ Ok(Some(_)) => return,
+ };
+ let declared = match &channel {
+ Ok(Some(channel)) => channel.as_str(),
+ _ => "none",
+ };
+ let shown = fs::canonicalize(&declaration).unwrap_or_else(|_| declaration.clone());
+ eprintln!(
+ "error: {}\n compiler release: {}\n declared channel: {}\n declaration: {}\nhelp: build with rustup (https://rustup.rs) from the directory that holds the declaration, or one below it, so rustup installs and selects the declared toolchain. Any of these selects another compiler and must go: a RUSTUP_TOOLCHAIN variable, a +toolchain argument, a `rustup override` set on that directory, or a cargo or rustc earlier on PATH that rustup does not manage (such as a Homebrew, distribution or Nix install). The declaration names one exact release as channel = \"MAJOR.MINOR.PATCH\" under [toolchain]",
+ problem,
+ release,
+ declared,
+ shown.display()
+ );
+ std::process::exit(1);
+}
+
+fn compiler_release() -> String {
+ let rustc = env::var_os("RUSTC").expect("cargo sets RUSTC for build scripts");
+ let output = Command::new(&rustc)
+ .arg("-vV")
+ .output()
+ .expect("cargo runs $RUSTC -vV before any build script");
+ String::from_utf8_lossy(&output.stdout)
+ .lines()
+ .find_map(|line| line.strip_prefix("release: "))
+ .expect("cargo requires a release line from $RUSTC -vV")
+ .trim()
+ .to_string()
+}
+
+fn declared_channel(text: &str) -> Option<String> {
+ let mut in_toolchain_table = false;
+ for line in text.lines() {
+ let line = line.trim();
+ if line.starts_with('[') {
+ in_toolchain_table = table_name(line) == Some("toolchain");
+ } else if in_toolchain_table {
+ if let Some((key, value)) = line.split_once('=') {
+ if key.trim() == "channel" {
+ return Some(string_value(value.trim()));
+ }
+ }
+ }
+ }
+ None
+}
+
+fn table_name(header: &str) -> Option<&str> {
+ let inner = header.strip_prefix('[')?;
+ let end = inner.find(']')?;
+ Some(inner[..end].trim())
+}
+
+fn string_value(raw: &str) -> String {
+ let mut characters = raw.chars();
+ match characters.next() {
+ Some(quote) if quote == '"' || quote == '\'' => characters
+ .take_while(|character| *character != quote)
+ .collect(),
+ _ => raw.to_string(),
+ }
+}
+
+fn is_exact_release(channel: &str) -> bool {
+ let parts: Vec<&str> = channel.split('.').collect();
+ parts.len() == 3
+ && parts
+ .iter()
+ .all(|part| !part.is_empty() && part.bytes().all(|byte| byte.is_ascii_digit()))
+}
diff --git a/packages/native-config/turbo.json b/packages/native-config/turbo.json
index ecb409a08..586059a96 100644
--- a/packages/native-config/turbo.json
+++ b/packages/native-config/turbo.json
@@ -6,15 +6,17 @@
"Cargo.toml",
"Cargo.lock",
"build.rs",
+ "toolchain_guard.rs",
"src/**/*.rs",
"package.json",
- "scripts/build.mjs"
+ "scripts/build.mjs",
+ "$TURBO_ROOT$/rust-toolchain.toml"
],
"outputs": ["index.js", "index.d.ts", "*.node"]
},
"test": {
- "dependsOn": [],
- "inputs": ["$TURBO_DEFAULT$", "!README.md"],
+ "dependsOn": ["build"],
+ "inputs": ["$TURBO_DEFAULT$", "!README.md", "$TURBO_ROOT$/rust-toolchain.toml"],
"outputs": []
}
}
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
new file mode 100644
index 000000000..2b3f5d7dc
--- /dev/null
+++ b/rust-toolchain.toml
@@ -0,0 +1,3 @@
+[toolchain]
+channel = "1.99.0"
+profile = "minimal"