Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
native-locks: bound every phase of the Zig setup (one download budget with a rate rule, extract and version timeouts, a step timeout)
garrytanb4a85c62b6da
diff --git a/.github/workflows/native-locks.yml b/.github/workflows/native-locks.ymlindex 6ec1d044fb..cf8ce844a9 100644--- a/.github/workflows/native-locks.yml+++ b/.github/workflows/native-locks.yml@@ -87,7 +87,12 @@ jobs:${{ runner.temp }}/gbrain-zig/zig-*.zip${{ runner.temp }}/gbrain-zig/zig-*.tar.xzkey: zig-archive-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/native/toolchain.json') }}- - run: bun scripts/native/setup-toolchain.ts --dir "${{ runner.temp }}/gbrain-zig" --github-path+ # Bounded inside: a 300 s download budget across every source with a+ # minimum-rate rule, 90 s to extract, 60 s for `zig version` (.223's+ # darwin-x64 cell sat here until the 15-minute job timeout).+ - name: Set up the pinned Zig compiler (bounded)+ timeout-minutes: 9+ run: bun scripts/native/setup-toolchain.ts --dir "${{ runner.temp }}/gbrain-zig" --github-path- run: bun scripts/native/build.ts --target ${{ matrix.target }} --output "${{ runner.temp }}/native-rebuilt"- run: bun scripts/native/verify.ts --rebuilt "${{ runner.temp }}/native-rebuilt"- name: Verify Darwin ABI against the native SDK@@ -208,7 +213,12 @@ jobs:${{ runner.temp }}/gbrain-zig/zig-*.zip${{ runner.temp }}/gbrain-zig/zig-*.tar.xzkey: zig-archive-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/native/toolchain.json') }}- - run: bun scripts/native/setup-toolchain.ts --dir "${{ runner.temp }}/gbrain-zig" --github-path+ # Bounded inside: a 300 s download budget across every source with a+ # minimum-rate rule, 90 s to extract, 60 s for `zig version` (.223's+ # darwin-x64 cell sat here until the 15-minute job timeout).+ - name: Set up the pinned Zig compiler (bounded)+ timeout-minutes: 9+ run: bun scripts/native/setup-toolchain.ts --dir "${{ runner.temp }}/gbrain-zig" --github-path- run: bun scripts/native/build.ts --target ${{ matrix.target }} --output "${{ runner.temp }}/native-rebuilt"- run: bun scripts/native/verify.ts --rebuilt "${{ runner.temp }}/native-rebuilt"- name: Execute prebuild in native musl userspacediff --git a/CHANGELOG.md b/CHANGELOG.mdindex 04319148c2..b3a62146e7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,8 @@ identifiers and attribution are available in the pre-removal Git revision**The Ubicloud gate's `verify` typecheck runs warm from a worktree whose `node_modules` is a symlink.** Verify's typecheck on #6673's gate timed out at 121 s against its 120 s cap; the rerun passed at 113 s. That gate ran from a `git worktree` whose `node_modules` is a symlink to the main checkout's, a common way to skip a `bun install` per worktree. tsc records each source file relative to the buildinfo's directory, but it records the files it reaches through node_modules by their real path: the TypeScript lib files and bun-types' globals, 990 entries in all. In that layout, those entries point out of the checkout (`../../../../../../../../workspace/gbrain/node_modules/typescript/lib/lib.es5.d.ts`). On the VM they resolve to nothing, the global declarations count as changed, and tsc rechecks every file. All four of that worktree's gates logged `verify's typecheck runs warm`, but the typecheck took 84, 85, 113 and 121 s, the same as a cold one. The 120 s cap is unchanged.+**The Zig compiler setup in the `native-locks` jobs fails with a named error instead of running into the job timeout.** On .223's master Test run, the `darwin-x64 / Bun 1.4.3` cell sat in `setup-toolchain.ts` from 15:57:37 until the 15-minute job timeout (job 115955272565; the log has expired). Its cache step restored the pinned archive (`zig-archive-macOS-X64`, cached since 2026-09-30, the same key the Bun 1.4.0 sibling restored that minute), so no download ran. The step was stuck in `tar -xf` or `zig version`, neither of which had a timeout. The download path had its own gap: a mirror trickling just above the 30 s stall rule could hold each of six sources for 240 s, 24 minutes in all. Every phase is now bounded and prints its duration, so the next hang names its phase.+### Itemized changes- **`scripts/ubicloud/typecheck-state.ts` `portableBuildInfo`** writes the uploaded copy (`<run>/typecheck.tsbuildinfo`). It moves every entry under the real path of the checkout's `node_modules` back under the checkout's own `node_modules` path, which the VM's frozen install lays out the same way. A checkout with a real `node_modules` is copied unchanged. Only the `fileNames` table carries paths; everything else in tsc 5.9's buildinfo refers to files by index. tsc still checks every file's content hash, so a wrong mapping costs time, never correctness.@@ -23,6 +25,23 @@ identifiers and attribution are available in the pre-removal Git revision- The same file re-rooted took 16 s and 15 s.- The gate's own verify step, run from that worktree. Before: the log said `runs warm` and verify's typecheck took 90 s. After: the log said `990 entries re-rooted from the symlinked node_modules; verify's typecheck runs warm`, and the typecheck took 16 s.- **`test/scripts/ubicloud-typecheck-state.test.ts`** builds a worktree with a symlinked `node_modules` and the entries tsc 5.9 wrote there. It checks that lib and bun-types entries are re-rooted, sources are kept, a path outside both is counted, a plain checkout is unchanged, and a file without `fileNames` is refused.+- **`scripts/native/setup-toolchain.ts`:**+ - The download has one 300 s budget across all sources.+ - A source is dropped when its rate over the last 15 s projects that the pinned size can't arrive before the budget ends, or when no bytes arrive for 30 s.+ - A failure lists every source with its reason: `too slow: 100 KB/s leaves 45 MB for 285.0s of the download budget`, or `not tried` once the budget is spent.+ - `tar -xf` runs under 90 s and `zig version` under 60 s, killed with SIGKILL on overrun with `<phase> did not finish within <n>s`.+ - The script prints the download, extraction and version-check times.+ - `GBRAIN_ZIG_SOURCES` and `GBRAIN_ZIG_DOWNLOAD_BUDGET_S` point it at a local mirror (and the tests).+- **`native-locks.yml`:** both Zig setup steps are named and carry `timeout-minutes: 9`, which covers the script's 450 s worst case. The job timeout stays at 15 minutes.+- **Forced probe (a loopback mirror serving the real 49 MB pinned archive, throttled):**+ - Two sources at 100 KB/s, old script: 240 s on each, failed after 480 s.+ - New script: each source dropped as too slow after 15 s, failed with the named error after 31 s.+ - A 100 KB/s source, then a 400 KB/s source: the first was dropped; the second was kept (it fits the budget) and finished in 120 s; extraction took 2.9 s.+- **`test/scripts/native-setup-toolchain.test.ts`** runs the real script against loopback mirrors:+ - trickling sources are dropped by rate and fail named inside a 10 s budget;+ - silent sources are dropped, and those past the budget are reported as not tried;+ - `runWithin` kills and names an overrun;+ - every Zig setup step's timeout covers the script's bounds and fits inside its job.## [0.60.223.0] - 2026-10-14diff --git a/scripts/native/setup-toolchain.ts b/scripts/native/setup-toolchain.tsindex 46f3ae41e6..335b3ebebb 100644--- a/scripts/native/setup-toolchain.ts+++ b/scripts/native/setup-toolchain.ts@@ -6,9 +6,22 @@* Windows archive outran the 15-minute job limit), and the Zig project asks* automated downloads to use its community mirrors instead* (https://ziglang.org/download/community-mirrors/). Sources are tried in- * order, each attempt aborts when bytes stop arriving or it runs too long,- * and every archive must match the pinned sha256, so a mirror can fail but- * never substitute bytes. ziglang.org stays the last resort.+ * order and every archive must match the pinned sha256, so a mirror can fail+ * but never substitute bytes. ziglang.org stays the last resort.+ *+ * Every phase is bounded, so a CI step fails here with a message naming the+ * phase instead of running into the job timeout (.223's darwin-x64 cell sat+ * in this step for 15 minutes with no output):+ * - The download has one budget across all sources. A source is dropped when+ * no bytes arrive for STALL_MS, or when its recent rate projects that the+ * pinned size cannot arrive before the budget ends: a trickle that never+ * stalls no longer holds a source for minutes.+ * - Extraction and the `zig version` check run under their own timeouts.+ * Each phase prints how long it took.+ *+ * GBRAIN_ZIG_SOURCES (comma-separated base URLs, replacing the mirrors and+ * ziglang.org) and GBRAIN_ZIG_DOWNLOAD_BUDGET_S exist for a local mirror and+ * for tests.*/import { createHash } from 'node:crypto';import { execFileSync } from 'node:child_process';@@ -18,32 +31,52 @@ import toolchain from './toolchain.json';const MIRRORS = ['https://pkg.hexops.org/zig', 'https://zig.linus.dev/zig', 'https://zig.squirl.dev', 'https://zigmirror.com', 'https://pkg.earth/zig'];const STALL_MS = 30_000;-const ATTEMPT_MS = 240_000;--const args = process.argv.slice(2);-const index = args.indexOf('--dir');-const directory = resolve(index < 0 ? '.context/native-toolchain' : args[index + 1]);-const platform = process.platform === 'darwin' ? 'macos' : process.platform === 'win32' ? 'windows' : process.platform;-const arch = process.arch === 'x64' ? 'x86_64' : process.arch === 'arm64' ? 'aarch64' : process.arch;-const key = `${arch}-${platform}` as keyof typeof toolchain.archives;-const archiveInfo = toolchain.archives[key];-if (!archiveInfo) throw new Error(`No pinned Zig archive for ${key}`);-mkdirSync(directory, { recursive: true });-const name = archiveInfo.tarball.split('/').at(-1)!;-const archive = join(directory, name);+const DOWNLOAD_BUDGET_MS = Number(process.env.GBRAIN_ZIG_DOWNLOAD_BUDGET_S ?? 300) * 1000;+/** A source's rate is judged over this window, starting once it has run this long. */+const RATE_WINDOW_MS = Math.min(15_000, DOWNLOAD_BUDGET_MS / 10);+const EXTRACT_MS = 90_000;+const VERSION_MS = 60_000;+const seconds = (ms: number) => `${(ms / 1000).toFixed(1)}s`;const sha256 = (file: string) => createHash('sha256').update(readFileSync(file)).digest('hex');-/** One source: stream to a temp file, abort on a stall or overrun, keep it only if the checksum matches. */-async function fetchVerified(url: string): Promise<void> {+/** Run a command to completion within `ms`, or throw naming `what`; SIGKILL on overrun. */+export function runWithin(command: string, args: string[], ms: number, what: string): string {+ try {+ return execFileSync(command, args, { encoding: 'utf8', timeout: ms, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'inherit'] });+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code === 'ETIMEDOUT') throw new Error(`${what} did not finish within ${ms / 1000}s`);+ throw error;+ }+}++/**+ * One source: stream to `archive`.partial and keep it only if the checksum+ * matches. Aborts on a stall, on a rate that cannot deliver the remaining+ * bytes before `deadline`, or at `deadline`.+ */+async function fetchVerified(url: string, archive: string, size: number, shasum: string, deadline: number): Promise<void> {const partial = `${archive}.partial`;const controller = new AbortController();let reason = '';- const abort = (why: string) => { reason = why; controller.abort(); };- const overall = setTimeout(() => abort(`exceeded ${ATTEMPT_MS / 1000}s`), ATTEMPT_MS);- let stall = setTimeout(() => abort(`no bytes for ${STALL_MS / 1000}s`), STALL_MS);+ const abort = (why: string) => { if (!reason) { reason = why; controller.abort(); } };const started = Date.now();let received = 0;+ const samples: Array<[number, number]> = [[started, 0]];+ const overall = setTimeout(() => abort('the download budget ran out'), Math.max(0, deadline - started));+ let stall = setTimeout(() => abort(`no bytes for ${STALL_MS / 1000}s`), STALL_MS);+ const pace = setInterval(() => {+ const now = Date.now();+ samples.push([now, received]);+ while (samples.length > 1 && now - samples[1]![0] >= RATE_WINDOW_MS) samples.shift();+ const [since, base] = samples[0]!;+ if (now - started < RATE_WINDOW_MS || now - since < RATE_WINDOW_MS / 2) return;+ const rate = (received - base) / ((now - since) / 1000);+ const needed = (size - received) / Math.max(rate, 1);+ if (now + needed * 1000 > deadline) {+ abort(`too slow: ${Math.round(rate / 1024)} KB/s leaves ${Math.round((size - received) / 1048576)} MB for ${seconds(deadline - now)} of the download budget`);+ }+ }, Math.max(250, RATE_WINDOW_MS / 5));try {const response = await fetch(url, { signal: controller.signal });if (!response.ok || !response.body) throw new Error(`HTTP ${response.status}`);@@ -55,42 +88,72 @@ async function fetchVerified(url: string): Promise<void> {if (!out.write(chunk)) await new Promise(r => out.once('drain', r));}await new Promise<void>((ok, fail) => out.end((error?: Error | null) => (error ? fail(error) : ok())));- if (sha256(partial) !== archiveInfo.shasum) throw new Error('checksum mismatch');+ if (sha256(partial) !== shasum) throw new Error('checksum mismatch');renameSync(partial, archive);- console.error(`zig archive: ${received} bytes in ${((Date.now() - started) / 1000).toFixed(1)}s from ${url}`);+ console.error(`zig archive: ${received} bytes in ${seconds(Date.now() - started)} from ${url}`);} catch (error) {rmSync(partial, { force: true });- throw new Error(reason ? `${reason} after ${received} bytes` : error instanceof Error ? error.message : String(error));+ throw new Error(reason ? `${reason} after ${received} bytes in ${seconds(Date.now() - started)}` : error instanceof Error ? error.message : String(error));} finally {clearTimeout(overall);clearTimeout(stall);+ clearInterval(pace);}}-if (existsSync(archive) && sha256(archive) !== archiveInfo.shasum) rmSync(archive);-if (existsSync(archive)) {- console.error(`zig archive: reusing ${archive}`);-} else {- const failures: string[] = [];- for (const url of [...MIRRORS.map(m => `${m}/${name}?source=gbrain-ci`), archiveInfo.tarball]) {- try {- await fetchVerified(url);- break;- } catch (error) {- failures.push(`${url}: ${(error as Error).message}`);- console.error(`zig archive: ${url} failed (${(error as Error).message}); trying the next source`);+if (import.meta.main) {+ const args = process.argv.slice(2);+ const index = args.indexOf('--dir');+ const directory = resolve(index < 0 ? '.context/native-toolchain' : args[index + 1]);+ const platform = process.platform === 'darwin' ? 'macos' : process.platform === 'win32' ? 'windows' : process.platform;+ const arch = process.arch === 'x64' ? 'x86_64' : process.arch === 'arm64' ? 'aarch64' : process.arch;+ const key = `${arch}-${platform}` as keyof typeof toolchain.archives;+ const archiveInfo = toolchain.archives[key];+ if (!archiveInfo) throw new Error(`No pinned Zig archive for ${key}`);+ mkdirSync(directory, { recursive: true });+ const name = archiveInfo.tarball.split('/').at(-1)!;+ const archive = join(directory, name);++ if (existsSync(archive) && sha256(archive) !== archiveInfo.shasum) rmSync(archive);+ if (existsSync(archive)) {+ console.error(`zig archive: reusing ${archive}`);+ } else {+ const sources = process.env.GBRAIN_ZIG_SOURCES+ ? process.env.GBRAIN_ZIG_SOURCES.split(',').map(base => `${base.replace(/\/$/, '')}/${name}`)+ : [...MIRRORS.map(m => `${m}/${name}?source=gbrain-ci`), archiveInfo.tarball];+ const deadline = Date.now() + DOWNLOAD_BUDGET_MS;+ const failures: string[] = [];+ for (const url of sources) {+ if (Date.now() >= deadline) {+ failures.push(`${url}: not tried`);+ continue;+ }+ try {+ await fetchVerified(url, archive, Number(archiveInfo.size), archiveInfo.shasum, deadline);+ break;+ } catch (error) {+ failures.push(`${url}: ${(error as Error).message}`);+ console.error(`zig archive: ${url} failed (${(error as Error).message}); trying the next source`);+ }+ }+ if (!existsSync(archive)) {+ throw new Error(`Compiler download failed from every source within its ${DOWNLOAD_BUDGET_MS / 1000}s budget:\n ${failures.join('\n ')}`);}}- if (!existsSync(archive)) throw new Error(`Compiler download failed from every source:\n ${failures.join('\n ')}`);-}-execFileSync('tar', ['-xf', archive, '-C', directory], { stdio: 'inherit' });-const extracted = readdirSync(directory, { withFileTypes: true }).find(entry => entry.isDirectory() && entry.name.startsWith('zig-'));-if (!extracted) throw new Error('Compiler archive did not contain Zig');-const binary = join(directory, extracted.name, process.platform === 'win32' ? 'zig.exe' : 'zig');-if (execFileSync(binary, ['version'], { encoding: 'utf8' }).trim() !== toolchain.version) throw new Error('Extracted compiler version mismatch');-if (args.includes('--github-path')) {- if (!process.env.GITHUB_PATH || !process.env.GITHUB_ENV) throw new Error('GitHub environment files are missing');- appendFileSync(process.env.GITHUB_PATH, dirname(binary) + '\n');- appendFileSync(process.env.GITHUB_ENV, `ZIG=${binary}\n`);+ let started = Date.now();+ runWithin('tar', ['-xf', archive, '-C', directory], EXTRACT_MS, `Extracting ${archive}`);+ console.error(`zig archive: extracted in ${seconds(Date.now() - started)}`);+ const extracted = readdirSync(directory, { withFileTypes: true }).find(entry => entry.isDirectory() && entry.name.startsWith('zig-'));+ if (!extracted) throw new Error('Compiler archive did not contain Zig');+ const binary = join(directory, extracted.name, process.platform === 'win32' ? 'zig.exe' : 'zig');+ started = Date.now();+ const version = runWithin(binary, ['version'], VERSION_MS, `\`${binary} version\``).trim();+ console.error(`zig: \`zig version\` answered ${version} in ${seconds(Date.now() - started)}`);+ if (version !== toolchain.version) throw new Error('Extracted compiler version mismatch');+ if (args.includes('--github-path')) {+ if (!process.env.GITHUB_PATH || !process.env.GITHUB_ENV) throw new Error('GitHub environment files are missing');+ appendFileSync(process.env.GITHUB_PATH, dirname(binary) + '\n');+ appendFileSync(process.env.GITHUB_ENV, `ZIG=${binary}\n`);+ }+ console.log(binary);}-console.log(binary);diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 92f3a7ad76..e0d449cd98 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -303,6 +303,7 @@ test/scripts/e2e-wiring.test.ts (file-level) 12 readFileSynctest/scripts/fix-wave-gate.test.ts fix-wave gate workflow 3 readFileSynctest/scripts/heavy-door-workflow.test.ts heavy door supply chain and coverage gates 8 readFileSynctest/scripts/native-lock-prebuilds.test.ts native lock distribution integrity 2 readFileSync+test/scripts/native-setup-toolchain.test.ts scripts/native/setup-toolchain.ts download budget 4 readFileSynctest/scripts/nightly-e2e.test.ts full E2E shard classification (#6040) 2 readFileSynctest/scripts/nightly-e2e.test.ts nightly E2E scheduling 4 readFileSynctest/scripts/nightly-issue.test.ts .github/nightly-known-red.tsv 2 readFileSyncdiff --git a/test/scripts/native-setup-toolchain.test.ts b/test/scripts/native-setup-toolchain.test.tsnew file mode 100644index 0000000000..204f4e5fc1--- /dev/null+++ b/test/scripts/native-setup-toolchain.test.ts@@ -0,0 +1,94 @@+/**+ * scripts/native/setup-toolchain.ts: every phase is bounded so a CI step fails+ * with a message naming the phase instead of running into the job timeout. The+ * download has one budget across sources and drops a source whose rate cannot+ * deliver the pinned size before it ends; extraction and `zig version` run+ * under timeouts. Each download case runs the real script against a loopback+ * mirror that trickles, or never answers.+ */+import { afterEach, describe, expect, test } from 'bun:test';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { createServer, type Server } from 'node:http';+import type { AddressInfo } from 'node:net';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { load } from 'js-yaml';+import { runWithin } from '../../scripts/native/setup-toolchain.ts';++const ROOT = resolve(import.meta.dir, '..', '..');+const SCRIPT = join(ROOT, 'scripts/native/setup-toolchain.ts');+const cleanup: Array<() => void> = [];+afterEach(() => { for (const step of cleanup.splice(0)) step(); });++/** A mirror whose responses trickle at `bytesPerSecond` (or never start, at 0), claiming a 50 MB archive. */+async function mirror(bytesPerSecond: number): Promise<string> {+ const server: Server = createServer((_req, res) => {+ if (bytesPerSecond === 0) return;+ res.writeHead(200, { 'content-length': String(50 * 1048576) });+ const tick = setInterval(() => res.write(Buffer.alloc(Math.ceil(bytesPerSecond / 10))), 100);+ res.on('close', () => clearInterval(tick));+ });+ await new Promise<void>(ok => server.listen(0, '127.0.0.1', ok));+ cleanup.push(() => server.closeAllConnections?.() ?? server.close());+ return `http://127.0.0.1:${(server.address() as AddressInfo).port}`;+}++async function setup(sources: string[], budgetSeconds: number) {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-zig-setup-'));+ cleanup.push(() => rmSync(dir, { recursive: true, force: true }));+ const started = Date.now();+ const proc = Bun.spawn([process.execPath, SCRIPT, '--dir', dir], {+ env: { ...process.env, GBRAIN_ZIG_SOURCES: sources.join(','), GBRAIN_ZIG_DOWNLOAD_BUDGET_S: String(budgetSeconds) },+ stdout: 'pipe',+ stderr: 'pipe',+ });+ const [stderr, exitCode] = await Promise.all([new Response(proc.stderr).text(), proc.exited]);+ return { exitCode, stderr, seconds: (Date.now() - started) / 1000 };+}++describe('scripts/native/setup-toolchain.ts download budget', () => {+ test('trickling sources are dropped by rate, and the step fails with a named error well inside the budget', async () => {+ const slow = await mirror(8 * 1024);+ const r = await setup([slow, slow], 10);+ expect(r.exitCode).not.toBe(0);+ expect(r.stderr).toContain('Compiler download failed from every source within its 10s budget');+ expect(r.stderr.match(/too slow: \d+ KB\/s leaves \d+ MB for [\d.]+s of the download budget/g)?.length).toBeGreaterThanOrEqual(2);+ expect(r.seconds).toBeLessThan(10);+ }, 30_000);++ test('a source that never answers is dropped at the rate window, and sources past the budget are reported as not tried', async () => {+ const silent = await mirror(0);+ const r = await setup(Array.from({ length: 20 }, (_, i) => `${silent}/s${i}`), 2);+ expect(r.exitCode).not.toBe(0);+ expect(r.stderr).toMatch(/s0\/\S+: too slow: 0 KB\/s/);+ expect(r.stderr).toMatch(/s19\/\S+: not tried/);+ expect(r.seconds).toBeLessThan(8);+ }, 30_000);+});++describe.skipIf(process.platform === 'win32')('runWithin', () => {+ test('a command still running at its bound is killed and named', () => {+ const started = Date.now();+ expect(() => runWithin('sleep', ['30'], 500, 'Extracting the archive')).toThrow('Extracting the archive did not finish within 0.5s');+ expect(Date.now() - started).toBeLessThan(5000);+ expect(runWithin('echo', ['0.14.1'], 5000, 'zig version').trim()).toBe('0.14.1');+ });+});++test('every Zig setup step has a step timeout that covers the script bounds and fits inside its job', () => {+ type Step = { run?: string; 'timeout-minutes'?: number };+ const doc = load(readFileSync(join(ROOT, '.github/workflows/native-locks.yml'), 'utf8')) as { jobs: Record<string, { 'timeout-minutes': number; steps: Step[] }> };+ const script = readFileSync(SCRIPT, 'utf8');+ const bound = (name: string) => Number(new RegExp(`${name} = (?:Number\\(process\\.env\\.\\w+ \\?\\? )?([\\d_]+)`).exec(script)![1]!.replace(/_/g, ''));+ const worstSeconds = bound('DOWNLOAD_BUDGET_MS') + bound('EXTRACT_MS') / 1000 + bound('VERSION_MS') / 1000;+ let steps = 0;+ for (const job of Object.values(doc.jobs)) {+ for (const step of job.steps ?? []) {+ if (!step.run?.includes('scripts/native/setup-toolchain.ts')) continue;+ steps++;+ expect(step['timeout-minutes']! * 60).toBeGreaterThan(worstSeconds);+ expect(step['timeout-minutes']!).toBeLessThan(job['timeout-minutes']);+ }+ }+ expect(steps).toBeGreaterThanOrEqual(2);+});