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

The signed-out webspec walk is three tests under the 2 s CPU budget, its warm-up paid by the file #17514

opened this

Merged 17h 59m ago, live in production

fix/webspec-cpu-split → main 0 commits

  • Merged. fix/webspec-cpu-split was merged into main as d0c3744.

Review

Sign in to review this change.
2 files changed +48 −6
scripts/gate.ts −1
@@ -51,7 +51,6 @@ export const EXCLUDED: readonly Exclusion[] = [];
5151 * short: an entry is a debt with an owner, not a home.
5252 */
5353 export const SLOW: readonly Exclusion[] = [
54 { file: "test/forge-webspec.test.ts", reason: "audits every public page of a real forge through webspec in one test; 2.6 s of CPU under full-suite load", issue: 17510 },
5554 { file: "test/talk-phone.test.ts", reason: "21 s of CPU a file under full-suite load, over the 20 s file budget", issue: 17361 },
5655 { file: "test/route-marks.test.ts", reason: "its every-admin-route test calls each route twice; 2.4 s under full-suite load", issue: 17361 },
5756 { file: "test/api-hints.test.ts", reason: "its test calls every OpenAPI route badly; 2.8 s under full-suite load", issue: 17361 },
test/forge-webspec.test.ts +48 −5
@@ -84,6 +84,10 @@ beforeAll(async () => {
8484 const pull = await openPull(app, made.value, repo.value, { title: "Feature", baseBranch: "main", headBranch: "feature" });
8585 if (!pull.ok) throw new Error("pull");
8686 cookie = `forge_session=${createSession(app.db, made.value.id).token}`;
87 // The first request of a process loads the page modules and fills the caches every later one
88 // reads: a cost of the file, paid here, not by whichever walk runs first (each test is held to
89 // the 2 s CPU budget, its hooks are the file's).
90 for (const path of ["/", "/signin", "/llms.txt"]) await (await through(false)(`http://forge.test${path}`)).text();
8791 });
8892
8993 afterAll(async () => {
@@ -107,15 +111,54 @@ const through = (signedIn: boolean) => async (input: string, init?: RequestInit)
107111 return new Response(plain, response);
108112 };
109113
110 test("the forge's signed-out pages raise exactly the findings named in KNOWN", async () => {
111 const found = await webspec("http://forge.test", PATHS, through(false), { site: true });
114 /**
115 * The signed-out walk, in three parts that each fit the 2 s per-test CPU budget (#17310): it took
116 * 2.57 s of CPU as one test on a check runner (2026-12-02). Each part names its own share of KNOWN:
117 * an entry for a walked path belongs to the part that walks it, any other (a page the site-wide
118 * checks reach, as the commit page) to the site part, so no part depends on another having run.
119 */
120 const SIGNED_OUT_FIRST: readonly string[] = ["/signin", "/apps", "/explore?kind=people"];
121 /**
122 * The rest of PATHS: home, explore and the repository's pages, with the commit page `beforeAll`
123 * adds.
124 */
125 const signedOutRest = (): string[] => PATHS.filter((p) => !SIGNED_OUT_FIRST.includes(p));
126 /** A path as KNOWN keys it: a full commit id as `<sha>`. */
127 const keyedPath = (path: string): string => path.replace(/\/commit\/[0-9a-f]{40}$/, "/commit/<sha>");
128
129 /**
130 * Walk `paths` (and the site-wide checks, with `site`) and hold the findings to KNOWN's share of
131 * them.
132 */
133 async function walkSignedOut(paths: readonly string[], site: boolean): Promise<void> {
134 const found = await webspec("http://forge.test", [...paths], through(false), { site });
112135 // #8129: a page at a full commit id names bytes that never change, so the edge may keep it (#8016); the id differs per run, so the path is keyed as `<sha>`.
113 const keyOf = (f: { check: string; path: string }) => `${f.check} ${f.path.replace(/\/commit\/[0-9a-f]{40}$/, "/commit/<sha>")}`;
136 const keyOf = (f: { check: string; path: string }) => `${f.check} ${keyedPath(f.path)}`;
114137 // New: not named, or citing another section than the one named.
115138 expect(found.filter((f) => KNOWN[keyOf(f)]?.[0] !== f.section).map((f) => `${keyOf(f)}: ${f.message}`)).toEqual([]);
116 // Fixed: named but no longer found, so the entry must go.
139 // Fixed: named but no longer found, so the entry must go. Only this part's share is asked of it.
117140 const seen = new Set(found.map(keyOf));
118 expect(Object.keys(KNOWN).filter((k) => !seen.has(k))).toEqual([]);
141 const share = (k: string) => {
142 const path = k.slice(k.indexOf(" ") + 1);
143 return PATHS.map(keyedPath).includes(path) ? paths.map(keyedPath).includes(path) : site;
144 };
145 expect(Object.keys(KNOWN).filter((k) => share(k) && !seen.has(k))).toEqual([]);
146 }
147
148 test("the first part of the signed-out walk is all in PATHS", () => {
149 expect(SIGNED_OUT_FIRST.filter((p) => !PATHS.includes(p))).toEqual([]);
150 });
151
152 test("the forge's signed-out pages raise exactly the findings named in KNOWN: sign-in, apps and lists", async () => {
153 await walkSignedOut(SIGNED_OUT_FIRST, false);
154 });
155
156 test("the forge's signed-out pages raise exactly the findings named in KNOWN: home, explore and a repository", async () => {
157 await walkSignedOut(signedOutRest(), false);
158 });
159
160 test("the forge's site-wide files and error pages raise exactly the findings named in KNOWN", async () => {
161 await walkSignedOut([], true);
119162 });
120163
121164 test("the owner's signed-in pages raise exactly the findings named in KNOWN_SIGNED_IN", async () => {

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs