Public: anyone can read this; the crew can change it.

Main's full check still runs 40+ minutes after #16613 landed #16623

opened this in answer to

Check · Review · Land · Live — Its check is running. Next: reviewer, no review yet.

Ready to land

mason/forge:mason/16622-main-s-full-check-still-runs-40-minutes → main 6 commits fork

  • Ready to merge — no conflicts with main. 6 commits will land on main.

    Check running · Check of dfcd612checked against main at f411bbefast tier: running · full gate runs on land

    You need write access to merge.

Review

Sign in to review this change.
17 files changed +107 −61
scripts/unused-exports-allow.json +1 −2
@@ -162,18 +162,17 @@
162162 "src/snapshot/drill_job.ts markerLeft",
163163 "src/spawn/births.ts provideHoldForTest",
164164 "src/spawn/births.ts provideMemoryForTest",
165 "src/spawn/door.ts useWatchProbeByDefault",
166165 "src/spawn/child-apps.ts childRuntime",
167166 "src/spawn/child_db.ts childDbReaders",
168167 "src/spawn/clients.ts monthsSettled",
169168 "src/spawn/clients.ts useChildFetch",
170169 "src/spawn/door.ts usePlacement",
170 "src/spawn/door.ts useProbe",
171171 "src/spawn/host.ts provideCellsForTest",
172172 "src/spawn/included_credit.ts worstCaseDailyUsd",
173173 "src/spawn/parent_credential.ts keepParentCredential",
174174 "src/spawn/pod.ts renderPod",
175175 "src/spawn/rate.ts resetAnonSpawns",
176 "src/spawn/reach.ts useReachByDefault",
177176 "src/spawn/usage.ts forgetSelfCpu",
178177 "src/story/records.ts isKnownRecord",
179178 "src/story/records.ts parseRecords",
src/checks/red_main.ts +13 −3
@@ -34,6 +34,8 @@ export interface RedMain {
3434 readonly branch: string;
3535 /** The check was stopped by its cell's limit or its budget, not by a test: no pull shares it. */
3636 readonly limit: boolean;
37 /** Every failing file passed when re-run alone: load tripped it, no landing broke it (#16622). */
38 readonly flaky: boolean;
3739 readonly since: string;
3840 }
3941
@@ -93,10 +95,17 @@ const LIMIT = /^(?:check failed: )?(?:stopped: |budget:|check stalled:|the forge
9395 function toRed(row: Row): RedMain | undefined {
9496 if (row.state !== "failed") return undefined;
9597 let failing: string[] = [];
98 let flaky = false;
9699 try {
97 const detail = row.check_detail ? (JSON.parse(row.check_detail) as { names?: unknown }) : {};
98 if (Array.isArray(detail.names))
99 failing = detail.names.filter((n): n is string => typeof n === "string");
100 const detail = row.check_detail
101 ? (JSON.parse(row.check_detail) as { names?: unknown; files?: unknown; flakyUnderLoad?: unknown })
102 : {};
103 const strings = (v: unknown): string[] =>
104 Array.isArray(v) ? v.filter((n): n is string => typeof n === "string") : [];
105 failing = strings(detail.names);
106 const files = strings(detail.files);
107 const green = strings(detail.flakyUnderLoad);
108 flaky = files.length > 0 && files.every((f) => green.includes(f));
100109 } catch {
101110 failing = [];
102111 }
@@ -109,6 +118,7 @@ function toRed(row: Row): RedMain | undefined {
109118 summary: row.summary,
110119 branch: row.branch,
111120 limit: LIMIT.test(row.summary),
121 flaky,
112122 since: row.finished_at ?? row.created_at,
113123 };
114124 }
src/checks/revert_red.ts +3 −2
@@ -5,7 +5,8 @@
55 * for the pull it takes back and naming the failing test. It is only ever
66 * proposed — a person lands it. A red that spans more than one landing (or a
77 * push no pull carried) is the alarm's, not this module's, and a landing
8 * already reverted, open or shipped or closed, is never proposed twice.
8 * already reverted, open or shipped or closed, is never proposed twice. A red
9 * the machine caused (a limit, a stall, or files that pass alone) proposes none.
910 */
1011
1112 import type { App } from "../app.ts";
@@ -88,7 +89,7 @@ export async function proposeRevert(app: App, repoId: string): Promise<Pull | un
8889 working.add(repoId);
8990 try {
9091 const red = redMain(app.db, repoId);
91 if (red === undefined || red.limit || manifestError(red) !== undefined) return undefined;
92 if (red === undefined || red.limit || red.flaky || manifestError(red) !== undefined) return undefined;
9293 const green = greenBefore(app, repoId, red.branch, red.runId);
9394 if (green === undefined) return undefined;
9495 const landed = await soleLanding(app, red, green);
src/git/env.ts +7 −4
@@ -368,6 +368,12 @@ export async function runGitRaw(
368368 // Timed from before the gate: a wait for a permit is the queue #8158 names.
369369 const start = performance.now();
370370 return gitGate.runUnless(options.signal, async () => {
371 // No time at all never starts a git: killing one right after its spawn
372 // loses the race when the machine is loaded and a small git is already done.
373 if ((options.timeoutMs ?? 30_000) <= 0) {
374 noteGit(gitRecord, args, start);
375 return err({ code: 137, stderr: "", args });
376 }
371377 let proc: Bun.Subprocess<"pipe" | "ignore", "pipe", "pipe">;
372378 try {
373379 proc = Bun.spawn(["git", ...args], {
@@ -388,10 +394,7 @@ export async function runGitRaw(
388394 const timer = setTimeout(() => proc.kill("SIGKILL"), timeoutMs);
389395 const stop = () => proc.kill("SIGKILL");
390396 let over = false;
391 // No time at all is killed now, not on the next turn of the event loop: a
392 // timer of 0 fires only once the loop is free, and a busy one lets a small
393 // git finish first and succeed past its deadline.
394 if (options.signal?.aborted || timeoutMs <= 0) stop();
397 if (options.signal?.aborted) stop();
395398 options.signal?.addEventListener("abort", stop, { once: true });
396399 try {
397400 const [stdout, stderr, code] = await Promise.all([
src/spawn/clients.ts +2 −1
@@ -39,6 +39,7 @@ import { billTo, personReading } from "./person_activity.ts";
3939 import { archiveProposal, type ArchiveProposal } from "./archive_proposal.ts";
4040 import { appLinkLines, type AppLinkLine } from "./app_links.ts";
4141 import { madeFromOf, type MadeFrom } from "./template_record.ts";
42 import { servedWindow } from "./suite_defaults.ts";
4243 import { NO_KEY_HELD, NO_KEY_HOST_LINE } from "../crew/no_key.ts";
4344
4445 /** What a spawned forge says about itself to anyone: nothing more. */
@@ -580,7 +581,7 @@ const building = new WeakMap<App, Promise<ClientRow[]>>();
580581 * (the suite's setting) a read waits for a fresh one: a test changes a forge and reads the list at
581582 * once.
582583 */
583 export const servedWindow = { ms: 15_000 };
584 export { servedWindow };
584585
585586 /**
586587 * Read every row now, off the request: what `servedRows` answers from. One at a time; a caller
src/spawn/door.ts +2 −11
@@ -12,6 +12,7 @@ import { contributeAnswer, wantsToContribute } from "./contribute_words.ts";
1212 import { nameShapeVerdict } from "./name_verdict.ts";
1313 import { linkRequestVisitor } from "../perf/visitor_link.ts";
1414 import { templateOfInput } from "../actions/template_timing.ts";
15 import { watchProbeDefault } from "./suite_defaults.ts";
1516 import { startWatch, probeOf, type Probe } from "./live.ts";
1617 import { firstProof, homeBudgetOf, proves, reachWords, settleChild, type ChildReach } from "./reach.ts";
1718 import {
@@ -92,16 +93,6 @@ export function probeFor(app: App, url: string, timeoutMs: number): Probe {
9293 return swapped ? swapped(url) : probeOf(url, timeoutMs);
9394 }
9495
95 let watchProbe: (url: string) => Probe = probeOf;
96 /**
97 * Tests: how a new child is asked whether it is live, for every forge, unless `useProbe` gave one.
98 * The suite's children answer nowhere, so each would keep its place among the births for the whole
99 * cap; `test/helpers/preload.ts` has them answer at once.
100 */
101 export function useWatchProbeByDefault(probe: ((url: string) => Probe) | undefined): void {
102 watchProbe = probe ?? probeOf;
103 }
104
10596 /** Tests swap how a new child is asked whether it is live. */
10697 export function useProbe(app: App, probe: (url: string) => Probe): void {
10798 probes.set(app, probe);
@@ -587,7 +578,7 @@ export async function spawnDoor(
587578 let watching = false;
588579 try {
589580 up = bootHostedChild(ctx.app, made.value.name);
590 watching = startWatch(ctx.app, { name: made.value.name, startedAt, ...templateOfInput(raw["template"]), probe: (probes.get(ctx.app) ?? watchProbe)(made.value.url), onSettled: place.release });
581 watching = startWatch(ctx.app, { name: made.value.name, startedAt, ...templateOfInput(raw["template"]), probe: (probes.get(ctx.app) ?? watchProbeDefault.probe ?? probeOf)(made.value.url), onSettled: place.release });
591582 } finally {
592583 if (!watching) place.release();
593584 }
src/spawn/reach.ts +2 −8
@@ -30,6 +30,7 @@ import { uncleanInFirstMinutes } from "../kernel/boots.ts";
3030 import { lastStop, stoppedMark } from "./stopped.ts";
3131 import { readRecord } from "./cell_record.ts";
3232 import { during } from "../perf/jobs.ts";
33 import { reachDefault } from "./suite_defaults.ts";
3334
3435 export const APP_HEADER = "x-forge-app";
3536
@@ -102,14 +103,7 @@ export function useReach(app: App, o: Options): void {
102103 options.set(app, o);
103104 }
104105
105 let fallback: Options = {};
106
107 /** What every app without its own `useReach` does; the test preload turns proving off. */
108 export function useReachByDefault(o: Options): void {
109 fallback = o;
110 }
111
112 const optionsOf = (app: App): Options => options.get(app) ?? fallback;
106 const optionsOf = (app: App): Options => options.get(app) ?? reachDefault;
113107 /** The most a spawn holds its reply for the new forge to come up and answer. */
114108 export const homeBudgetOf = (app: App): number => optionsOf(app).homeWaitMs ?? HOME_WAIT_MS;
115109 const off = (app: App): boolean => optionsOf(app).fetch === undefined && optionsOf(app).off === true;
src/spawn/suite_defaults.ts added +23
@@ -0,0 +1,23 @@
1 /**
2 * What the test suite sets for every forge before any test file loads (`test/helpers/preload.ts`).
3 * Plain state with no imports of the spawn modules that read it: the preload touches only this
4 * file, so a test file that never reaches the spawn door does not pay to load it (#16622).
5 */
6
7 import type { Probe } from "./live.ts";
8
9 /** How long a served list of children stays fresh; see `servedWindow` in `clients.ts`. */
10 export const servedWindow = { ms: 15_000 };
11
12 /** What every app without its own `useReach` does; see `useReachByDefault` in `reach.ts`. */
13 export const reachDefault: {
14 off?: boolean;
15 fetch?: (url: string, init?: RequestInit) => Promise<Response>;
16 settleMs?: number;
17 homeWaitMs?: number;
18 pollMs?: number;
19 confirmMs?: number;
20 } = {};
21
22 /** How a new child is asked whether it is live, when set; see `door.ts`. */
23 export const watchProbeDefault: { probe?: (url: string) => Probe } = {};
src/tui/screens/entries.ts +16 −8
@@ -47,20 +47,28 @@ export function entryFiles(dir: string = import.meta.dir): [string, string[]][]
4747 });
4848 }
4949
50 /** Every entry the files declare, by rank, then file name, then export name. */
51 export const ENTRIES: readonly PaletteEntry[] = entryFiles()
52 .flatMap(([f, names]) => {
53 const mod = require(join(import.meta.dir, f)) as Record<string, PaletteEntry>;
54 return [...names].sort().map((k) => mod[k]!);
55 })
56 .sort((a, b) => a.rank - b.rank);
50 let entries: readonly PaletteEntry[] | undefined;
51
52 /**
53 * Every entry the files declare, by rank, then file name, then export name. Read on first use, not
54 * at load: the screen files import modules that may still be loading when this one is.
55 */
56 export function allEntries(): readonly PaletteEntry[] {
57 entries ??= entryFiles()
58 .flatMap(([f, names]) => {
59 const mod = require(join(import.meta.dir, f)) as Record<string, PaletteEntry>;
60 return [...names].sort().map((k) => mod[k]!);
61 })
62 .sort((a, b) => a.rank - b.rank);
63 return entries;
64 }
5765
5866 /**
5967 * Put each entry the session is offered into `commands`, after the command it names or at the end.
6068 */
6169 export function addEntries(commands: Command[], session: Session, ctx: Ctx): void {
6270 const placed = new Map<string, number>();
63 for (const e of ENTRIES) {
71 for (const e of allEntries()) {
6472 if (!e.offered(session)) continue;
6573 const command: Command = { id: e.id, title: e.title, hint: e.hint, run: () => e.run(session, ctx) };
6674 const anchor = e.after?.find((id) => commands.some((c) => c.id === id));
test/combined-check.test.ts +2 −2
@@ -225,7 +225,7 @@ describe("a kept fork's pull is checked on its combined commit (#9932)", () => {
225225 await git(["push", "origin", "main"], b);
226226 const head = await git(["rev-parse", "HEAD"], b);
227227 let combined = await readCombined(bare, number, head);
228 for (let i = 0; i < 200 && combined?.baseOid !== builtOn; i++) {
228 for (let i = 0; i < 600 && combined?.baseOid !== builtOn; i++) {
229229 await Bun.sleep(50);
230230 combined = await readCombined(bare, number, head);
231231 }
@@ -246,5 +246,5 @@ describe("a kept fork's pull is checked on its combined commit (#9932)", () => {
246246 expect(run.log).toContain(`fast base ${builtOn}`);
247247 expect(run.log).toContain("changed bob2.txt");
248248 expect(run.log).not.toContain("changed late.txt");
249 }, 60_000);
249 }, 120_000);
250250 });
test/displays-list.test.ts +2 −2
@@ -21,7 +21,7 @@ import { serve, type Servers } from "../src/http/server.ts";
2121 import { createForgeApp } from "../src/tui/forge.ts";
2222 import { DISPLAYS_SENTENCE } from "../src/display/known.ts";
2323 import { entry as displaysEntry, displaysScreen } from "../src/tui/screens/displays.ts";
24 import { ENTRIES } from "../src/tui/screens/entries.ts";
24 import { allEntries } from "../src/tui/screens/entries.ts";
2525 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2626 import { settleApp } from "./helpers/tui.ts";
2727 import { statements } from "./helpers/statements.ts";
@@ -198,7 +198,7 @@ describe("the displays list, page and terminal screen", () => {
198198 expect(mine).toContain("display.json is invalid");
199199 expect(mine).toContain("alice/hidden");
200200 expect(await screenText(bob)).not.toContain("alice/hidden");
201 expect(ENTRIES).toContain(displaysEntry);
201 expect(allEntries()).toContain(displaysEntry);
202202 });
203203
204204 test("a stranger is sent to sign in", async () => {
test/helpers/preload.ts +3 −5
@@ -7,8 +7,7 @@ import "../../src/kernel/bun_guard.ts";
77 import { provideCpusForTest } from "../../src/core/capacity.ts";
88 import { provideMirrorOutboundForTest } from "../../src/origins/git-mirror.ts";
99 import { installCheapHash } from "./cheap-hash.ts";
10 import { useReachByDefault } from "../../src/spawn/reach.ts";
11 import { servedWindow } from "../../src/spawn/clients.ts";
10 import { reachDefault, servedWindow, watchProbeDefault } from "../../src/spawn/suite_defaults.ts";
1211 import "./roomy-disk.ts";
1312 import { provideEmptyImagesForTest } from "../../src/kernel/db.ts";
1413 import { emptyImagesIn } from "./empty-images.ts";
@@ -31,7 +30,7 @@ provideEmptyImagesForTest(emptyImagesIn(join(SCRATCH_ROOT, "empty-db")));
3130 process.env.FORGE_DEV = "1";
3231
3332 // A suite has no public network to prove a child through (`spawn/reach.ts`); a test of reach injects its own fetch.
34 useReachByDefault({ off: true });
33 reachDefault.off = true;
3534
3635 // The /forges list is served from memory in production; a test reads what it just changed (`spawn/clients.ts`).
3736 servedWindow.ms = 0;
@@ -57,5 +56,4 @@ const { provideMemoryForTest } = await import("../../src/spawn/births.ts");
5756 provideMemoryForTest(() => 64 * 1024 ** 3);
5857
5958 // A new child of the suite answers its first look, so its place among the births is given back.
60 const { useWatchProbeByDefault } = await import("../../src/spawn/door.ts");
61 useWatchProbeByDefault(() => async () => true);
59 watchProbeDefault.probe = () => async () => true;
test/palette-entries.test.ts +6 −6
@@ -1,6 +1,6 @@
11 import { expect, test } from "bun:test";
22 import type { Command } from "../src/tui/app/palette.ts";
3 import { addEntries, ENTRIES, entryFiles, type PaletteEntry } from "../src/tui/screens/entries.ts";
3 import { addEntries, allEntries, entryFiles, type PaletteEntry } from "../src/tui/screens/entries.ts";
44 import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
55 import { tmpdir } from "node:os";
66 import { join } from "node:path";
@@ -10,12 +10,12 @@ const stub = (id: string, after?: string[], rank = 0): PaletteEntry => ({
1010 id, rank, title: id, hint: "", ...(after ? { after } : {}), offered: () => true, run: () => undefined,
1111 });
1212 const place = (commands: Command[], entries: PaletteEntry[]): string[] => {
13 const saved = [...ENTRIES];
14 (ENTRIES as PaletteEntry[]).splice(0, ENTRIES.length, ...entries);
13 const saved = [...allEntries()];
14 (allEntries() as PaletteEntry[]).splice(0, allEntries().length, ...entries);
1515 try {
1616 addEntries(commands, {} as never, {} as never);
1717 } finally {
18 (ENTRIES as PaletteEntry[]).splice(0, ENTRIES.length, ...saved);
18 (allEntries() as PaletteEntry[]).splice(0, allEntries().length, ...saved);
1919 }
2020 return commands.map((c) => c.id);
2121 };
@@ -40,7 +40,7 @@ test("an entry the session is not offered is left out", () => {
4040 // The roster is built from the directory, not listed: these are known to be in it, including the
4141 // entries a file exports under another name than `entry`, in the order the palette has always had.
4242 test("the palette roster holds the known entries in their pinned order", () => {
43 const ids = ENTRIES.map((e) => e.id);
43 const ids = allEntries().map((e) => e.id);
4444 expect(ids.length).toBeGreaterThan(100);
4545 const known = ["bills", "payments", "sentinel", "boards", "drift", "model-grant", "model-ceiling", "claim-start", "claim-link", "recovery-link", "new-issue-anywhere"];
4646 expect(ids.filter((id) => known.includes(id))).toEqual(known.filter((id) => ids.includes(id)));
@@ -55,7 +55,7 @@ test("entries sort by rank, then by file name", () => {
5555 });
5656
5757 test("no two entries share an id", () => {
58 const ids = ENTRIES.map((e) => e.id);
58 const ids = allEntries().map((e) => e.id);
5959 expect(new Set(ids).size).toBe(ids.length);
6060 });
6161
test/red-main-line.test.ts +1 −1
@@ -4,7 +4,7 @@ import { mainLineFor, redMainLine, redOnMain } from "../src/checks/red_main_line
44
55 const red = (over: Partial<RedMain> = {}): RedMain => ({
66 repoId: "r", repo: "a/forge", runId: "x", commitOid: "abcdef0123456789", failing: ["sizes hold"],
7 summary: "check failed: 1 failed", branch: "main", limit: false, since: "2026-11-16T00:00:00Z", ...over,
7 summary: "check failed: 1 failed", branch: "main", limit: false, flaky: false, since: "2026-11-16T00:00:00Z", ...over,
88 });
99 const failed = (names: string[]) => ({ state: "failed" as const, checkDetail: { passed: 1, failed: names.length, names } });
1010
test/revert-red.test.ts +17 −2
@@ -42,7 +42,12 @@ describe("a red main after one landing proposes its revert", () => {
4242 return getPull(app.db, repo.id, opened.value.number)!;
4343 };
4444
45 const mainCheck = async (state: "ok" | "failed", names: string[] = [], summary?: string): Promise<void> => {
45 const mainCheck = async (
46 state: "ok" | "failed",
47 names: string[] = [],
48 summary?: string,
49 detail: object = {},
50 ): Promise<void> => {
4651 const oid = await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), "refs/heads/main");
4752 const run = createRun(app.db, { repoId: repo.id, kind: "check", env: "main", commitOid: oid ?? "" });
4853 app.db
@@ -51,7 +56,7 @@ describe("a red main after one landing proposes its revert", () => {
5156 run.id,
5257 state,
5358 summary ?? (state === "ok" ? "check passed in 1s" : "check failed: 1 test failed"),
54 state === "ok" ? "" : JSON.stringify({ names }),
59 state === "ok" ? "" : JSON.stringify({ names, ...detail }),
5560 new Date().toISOString(),
5661 );
5762 };
@@ -128,6 +133,16 @@ describe("a red main after one landing proposes its revert", () => {
128133 expect(reverts()).toHaveLength(0);
129134 });
130135
136 test("a red whose every failing file passes alone opens none (#16622)", async () => {
137 await mainCheck("ok");
138 await land("loaded", "load\n");
139 await mainCheck("failed", ["t"], undefined, { files: ["test/a.test.ts"], flakyUnderLoad: ["test/a.test.ts"] });
140 expect(await proposeRevert(app, repo.id)).toBeUndefined();
141 // one file red alone besides: that one is a test's failure, and the landing is proposed
142 await mainCheck("failed", ["t"], undefined, { files: ["test/a.test.ts", "test/b.test.ts"], flakyUnderLoad: ["test/a.test.ts"] });
143 expect(await proposeRevert(app, repo.id)).toBeDefined();
144 });
145
131146 test("a green main opens none", async () => {
132147 await mainCheck("ok");
133148 await land("one", "beta\n");
test/tui-drift.test.ts +2 −2
@@ -10,7 +10,7 @@ import { createApp, type App } from "../src/app.ts";
1010 import { createUser, type User } from "../src/core/users.ts";
1111 import type { Repo } from "../src/core/repos.ts";
1212 import { createForgeApp } from "../src/tui/forge.ts";
13 import { ENTRIES } from "../src/tui/screens/entries.ts";
13 import { allEntries } from "../src/tui/screens/entries.ts";
1414 import { askUpdate, driftRows, driftScreen, entry } from "../src/tui/screens/drift.ts";
1515 import { headlessTerminal } from "../src/tui/term/terminal.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
@@ -49,7 +49,7 @@ afterAll(async () => {
4949 });
5050
5151 test("the entry is in the palette list and offered to a person admin alone", () => {
52 expect(ENTRIES).toContain(entry);
52 expect(allEntries()).toContain(entry);
5353 const a = open(alice);
5454 const b = open(bob);
5555 expect(entry.offered(a.session)).toBe(true);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs