Merge remote-tracking branch 'origin/main' into garrytan/reliability-followups-oct4

# Conflicts:
#	.github/workflows/evals-periodic.yml
#	CHANGELOG.md
#	CONTRIBUTING.md
#	TODOS.md
#	docs/TESTING_INTERNALS.md
#	scripts/eval-flake-rank.ts
#	scripts/lib/paid-report.ts
#	scripts/paid-test-durations.json
#	scripts/test-paid-shards.ts
#	test/eng-finding-retry-budget.test.ts
#	test/fixtures/module-size-ratchet.json
#	test/helpers/carve-guards.ts
#	test/helpers/touchfiles-data.ts
#	test/paid-retry-supervision.test.ts
#	test/qa-probe-gates.test.ts
#	test/review-workflow-clarity.test.ts
#	test/ship-control-flow.test.ts
This commit is contained in:
garrytan committed 2026-10-05 01:42:55 +00:00
commit 0647fd2c32
280 files changed
+13376 -10128

No files matched your search

+11 -6
View File
@@ -49,8 +49,12 @@ import { randomBytes } from 'node:crypto';
export const RENDER_SENTINEL = 'GSTACK_RENDER_OK';
const DEFAULT_TIMEOUT_MS = 120_000;
/** Slack over the script budget so the `aside repl` process can wind down before we kill it. */
const ASIDE_PROCESS_SLACK_MS = 10_000;
/** Slack over the script budget so the `aside repl` process can wind down before we kill it;
* it also scales runProc's kill and give-up allowances. GSTACK_RENDER_SLACK_MS lets tests shrink it. */
function processSlackMs(): number {
const ms = Number(process.env.GSTACK_RENDER_SLACK_MS);
return Number.isInteger(ms) && ms > 0 ? ms : 10_000;
}
/** Default budget for a waitFor selector/expression, on either engine. */
const DEFAULT_WAIT_MS = 30_000;
/** Default cap (chars) on an inline eval result. */
@@ -313,18 +317,19 @@ async function runProc(cmd: string, args: string[], timeoutMs: number): Promise<
// for up to timeoutMs after printing its result.
const timers: ReturnType<typeof setTimeout>[] = [];
const after = (ms: number, fn: () => void) => { timers.push(setTimeout(fn, ms)); };
const slackMs = processSlackMs();
after(timeoutMs, () => { timedOut = true; try { child.kill(); } catch {} });
// A child that ignores SIGTERM (a CLI blocked on its app) gets SIGKILL; a
// grandchild holding the pipes open must not hang the render either.
after(timeoutMs + 5_000, () => { try { child.kill('SIGKILL'); } catch {} });
after(timeoutMs + slackMs / 2, () => { try { child.kill('SIGKILL'); } catch {} });
const read = Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text()]);
const giveUp = new Promise<[string, string]>((resolve) => after(timeoutMs + 10_000, () => resolve(['', ''])));
const giveUp = new Promise<[string, string]>((resolve) => after(timeoutMs + slackMs, () => resolve(['', ''])));
const [stdout, stderr] = await Promise.race([read, giveUp]);
// Pipes at EOF means the child is exiting; wait for the exit code until the
// SIGKILL above has had its turn. A flat 5s bound here once failed a CI render
// whose fake had already written its artifact — under a 6-shard load the
// reaper needed longer than that, and a null code reads as a failed command.
const code = await Promise.race([child.exited, new Promise<null>((resolve) => after(timeoutMs + 6_000, () => resolve(null)))]);
const code = await Promise.race([child.exited, new Promise<null>((resolve) => after(timeoutMs + slackMs * 3 / 5, () => resolve(null)))]);
for (const t of timers) clearTimeout(t);
return { code, stdout, stderr, error: timedOut ? `timed out after ${timeoutMs}ms` : undefined };
}
@@ -348,7 +353,7 @@ async function asideRender(spec: RenderSpec): Promise<RenderResult> {
const script = buildRenderScript(url, spec);
// Async spawn: a synchronous wait would block this event loop, and the
// loopback server above runs on it — Page.navigate would then time out.
const proc = await runProc('aside', ['repl', script], (spec.timeoutMs ?? DEFAULT_TIMEOUT_MS) + ASIDE_PROCESS_SLACK_MS);
const proc = await runProc('aside', ['repl', script], (spec.timeoutMs ?? DEFAULT_TIMEOUT_MS) + processSlackMs());
const stdout = `${proc.stdout}${proc.stderr}`.replace(/\x1b\[[0-9;]*m/g, '');
const evals: Record<number, string> = {};
for (const m of stdout.matchAll(/^EVAL (\d+) ([A-Za-z0-9+/=]*)$/gm)) evals[Number(m[1])] = Buffer.from(m[2], 'base64').toString('utf8');