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

The scans' budget is their planned wall time over the check's shards, and the scans carry their measured times #17321

opened this

Merged 33h 37m ago, live in production

fix/scan-budget-per-shard → main 0 commits

  • Merged. fix/scan-budget-per-shard was merged into main as dd898c7.

Review

Sign in to review this change.
3 files changed +157 −5
scripts/shards.ts +13
@@ -204,6 +204,19 @@ export function splitCapped(
204204 );
205205 }
206206
207 /**
208 * The wall seconds `slices` take on `width` workers that each take the next slice as they free
209 * (`test-shards.ts`'s `pool`): the last worker's end, each slice weighing its files' seconds.
210 */
211 export function plannedWall(slices: readonly (readonly string[])[], width: number, weight: (file: string) => number): number {
212 const free = Array.from({ length: Math.max(1, Math.min(Math.floor(width), slices.length)) }, () => 0);
213 for (const slice of slices) {
214 const at = free.indexOf(Math.min(...free));
215 free[at]! += slice.reduce((sum, file) => sum + weight(file), 0);
216 }
217 return Math.max(0, ...free);
218 }
219
207220 /** A test's short name after `--`: `crew-wrapup` is `test/crew-wrapup.test.ts`. */
208221 const TEST_NAME = /^[a-z0-9][a-z0-9-]{0,99}$/;
209222
scripts/test-times.json +125
@@ -1,4 +1,129 @@
11 {
2 "test/agent-runner-seam.test.ts": 0.8,
3 "test/apps-runtime-split.test.ts": 1.1,
4 "test/arg-words.test.ts": 1.7,
5 "test/billing-never-deletes.test.ts": 4.8,
6 "test/board-words.test.ts": 0.7,
7 "test/boot-idle-memory.test.ts": 10.3,
8 "test/boot-production.test.ts": 10.5,
9 "test/bundle-boot.test.ts": 2.3,
10 "test/button-rest.test.ts": 0.8,
11 "test/calm-banners.test.ts": 2,
12 "test/check-allow-lists.test.ts": 1.3,
13 "test/check-list.test.ts": 0.6,
14 "test/check-script-readers.test.ts": 1.5,
15 "test/checks-service-split.test.ts": 2.1,
16 "test/cli-commands.test.ts": 1.8,
17 "test/client-size.test.ts": 2.6,
18 "test/cookie-flags.test.ts": 3.7,
19 "test/cookie-floor.test.ts": 1.2,
20 "test/crew-pin-hook.test.ts": 2.1,
21 "test/danger-buttons.test.ts": 0.7,
22 "test/data-query-limits.test.ts": 1.9,
23 "test/design-audit.test.ts": 0.6,
24 "test/design-lint-motion.test.ts": 1.6,
25 "test/design-lint-ring.test.ts": 1.7,
26 "test/design-lint-width.test.ts": 0.7,
27 "test/design-lint.test.ts": 2.7,
28 "test/design-spine.test.ts": 2.3,
29 "test/disclosure.test.ts": 1.3,
30 "test/doorless.test.ts": 0.9,
31 "test/dup-imports.test.ts": 1.3,
32 "test/dupes.test.ts": 2.2,
33 "test/duty-roster.test.ts": 0.7,
34 "test/egress-literals.test.ts": 1.5,
35 "test/empty-notes.test.ts": 1,
36 "test/empty-words-all.test.ts": 2.1,
37 "test/engine-crossing.test.ts": 1.2,
38 "test/event-audience-coverage.test.ts": 1.3,
39 "test/family-words.test.ts": 1.6,
40 "test/feature-doors.test.ts": 0.9,
41 "test/feature-front-matter.test.ts": 0.8,
42 "test/feature-orphans.test.ts": 0.9,
43 "test/features-index-script.test.ts": 0.8,
44 "test/fetch-timeout.test.ts": 2.1,
45 "test/flags.test.ts": 0.7,
46 "test/flake.test.ts": 2.5,
47 "test/flow-clock.test.ts": 0.7,
48 "test/forge-first-wave.test.ts": 1,
49 "test/gate-stray-test.test.ts": 0.8,
50 "test/global-spies-restored.test.ts": 1.8,
51 "test/hollow.test.ts": 12.6,
52 "test/hotkey-hints.test.ts": 1.3,
53 "test/img-size.test.ts": 0.7,
54 "test/index-use.test.ts": 0.8,
55 "test/job-slices.test.ts": 3.6,
56 "test/journey-walk.test.ts": 1.3,
57 "test/kernel-boundary.test.ts": 1.4,
58 "test/label-words.test.ts": 1.6,
59 "test/landing-doors-review.test.ts": 4.6,
60 "test/launch-no-tla.test.ts": 1.1,
61 "test/look-browser-start.test.ts": 1.6,
62 "test/mcp-table.test.ts": 2.7,
63 "test/mcp-tools.test.ts": 0.9,
64 "test/module-state.test.ts": 0.9,
65 "test/no-polling.test.ts": 2.2,
66 "test/no-secrets-tracked.test.ts": 3.8,
67 "test/openapi-routes.test.ts": 0.8,
68 "test/openapi.test.ts": 3.7,
69 "test/origin-app-words.test.ts": 0.8,
70 "test/outbound-guard.test.ts": 1.2,
71 "test/outbound-sweep.test.ts": 1.2,
72 "test/own-source.test.ts": 1.5,
73 "test/page-budget-files.test.ts": 1.4,
74 "test/page-budget-roster.test.ts": 0.7,
75 "test/plugin-routes.test.ts": 1.5,
76 "test/popout-new-tab.test.ts": 2.1,
77 "test/readme-cap.test.ts": 0.8,
78 "test/readme-front-door.test.ts": 0.8,
79 "test/red-has-action.test.ts": 0.7,
80 "test/reduced-motion.test.ts": 0.8,
81 "test/refusals-lead-somewhere.test.ts": 1.4,
82 "test/release-boot.test.ts": 5.7,
83 "test/release-gate.test.ts": 0.8,
84 "test/release-keeper-rollback-named.test.ts": 0.8,
85 "test/report-words.test.ts": 1.3,
86 "test/retry-after.test.ts": 4.1,
87 "test/review-dangling-else.test.ts": 0.8,
88 "test/review-rules.test.ts": 2.3,
89 "test/review-words.test.ts": 1.9,
90 "test/roll.test.ts": 0.8,
91 "test/route-marks-roster.test.ts": 0.8,
92 "test/rule-tests-always.test.ts": 0.8,
93 "test/runner-env-confined.test.ts": 1.1,
94 "test/schema-additive.test.ts": 0.8,
95 "test/schema-migrations.test.ts": 3.1,
96 "test/scripts-fast.test.ts": 3.9,
97 "test/security-floor-doors.test.ts": 2.1,
98 "test/session-rotation.test.ts": 2.4,
99 "test/setting-words.test.ts": 1.5,
100 "test/shared-red.test.ts": 2,
101 "test/signin-password-doors.test.ts": 1.4,
102 "test/signup-gate-parent.test.ts": 1.6,
103 "test/spawn-argv.test.ts": 1.3,
104 "test/spawn-pipes.test.ts": 0.7,
105 "test/spawn-sites.test.ts": 1.7,
106 "test/spend-words.test.ts": 2.5,
107 "test/src-imports.test.ts": 2.2,
108 "test/talk-voice.test.ts": 1.6,
109 "test/templates-boot.test.ts": 1.6,
110 "test/templates-readme.test.ts": 0.7,
111 "test/test-honesty.test.ts": 0.9,
112 "test/thoughts.test.ts": 1.1,
113 "test/threats-sections-linked.test.ts": 1.3,
114 "test/time-element.test.ts": 1.5,
115 "test/timers-named.test.ts": 1.4,
116 "test/tree-scans.test.ts": 3.9,
117 "test/tree.test.ts": 1.9,
118 "test/tui-asks-first.test.ts": 2.3,
119 "test/unreached.test.ts": 1,
120 "test/unread-tables.test.ts": 4.8,
121 "test/unused-exports.test.ts": 2.1,
122 "test/username-pattern.test.ts": 1,
123 "test/vendor-names.test.ts": 1.1,
124 "test/version.test.ts": 2.3,
125 "test/waves-lint.test.ts": 0.8,
126 "test/worker-database-opens.test.ts": 1.9,
2127 "test/apps-adversarial-grants.test.ts": 2.5,
3128 "test/apps-adversarial-rules.test.ts": 2.3,
4129 "test/apps-adversarial-teardown.test.ts": 3,
test/tree-scans.test.ts +19 −5
@@ -6,10 +6,13 @@
66 import { describe, expect, test } from "bun:test";
77 import { readFileSync } from "node:fs";
88 import { gateFiles } from "../scripts/gate.ts";
9 import { parseTimes } from "../scripts/shards.ts";
9 import { parseTimes, plannedWall, splitCapped } from "../scripts/shards.ts";
1010 import { importsReader, scansIn } from "../scripts/tier-input.ts";
1111 import { declaresNoScan, declaresScan, SCAN_BUDGET_SECONDS, scanSeconds, treeScans, walksTree } from "../src/checks/scans.ts";
12 import { fastSet, RULE_TESTS } from "../src/checks/tiers.ts";
12 import { fastSet, QUICK_SECONDS, RULE_TESTS } from "../src/checks/tiers.ts";
13
14 /** Production's `checks.shards`: its checks say "8 shards (checks.shards setting)". */
15 const CHECK_SHARDS = 8;
1316
1417 describe("what a scan reads", () => {
1518 test("a glob or git ls-files lists the tree", () => {
@@ -103,10 +106,21 @@ describe("this repository's scans", () => {
103106 for (const rule of RULE_TESTS) expect([rule, scans.has(rule)]).toEqual([rule, true]);
104107 });
105108
106 test("cost together no more than their share of the fast tier's budget", () => {
107 const all = new Set([...scans.keys(), ...RULE_TESTS]);
109 // The scans' cost is their wall time as the fast tier runs them: first, on their own, sliced and
110 // pooled over the check's shards (`test-shards.ts`: `splitCapped`, `pool`). Their summed seconds
111 // were held to the wall budget once, and passed only on 1 s placeholders: 149.1 s of
112 // placeholders, 258.4 s summed once measured (2026-12-01), 32.7 s planned on eight shards.
113 // Not in the forge's kept times, so weighed at QUICK_SECONDS: bundle-boot-time, bundle-workers,
114 // import-all, keymap-terminal.
115 test("cost no more than their share of the fast tier's budget, in wall time over the check's shards", () => {
116 const all = [...new Set([...scans.keys(), ...RULE_TESTS])].sort();
108117 const times = parseTimes(readFileSync(new URL("../scripts/test-times.json", import.meta.url), "utf8"));
109118 expect(times.ok).toBe(true);
110 expect(scanSeconds(all, times.ok ? times.value : new Map())).toBeLessThanOrEqual(SCAN_BUDGET_SECONDS);
119 const known = times.ok ? times.value : new Map<string, number>();
120 const weight = (file: string): number => known.get(file) ?? QUICK_SECONDS;
121 const wall = plannedWall(splitCapped(all, CHECK_SHARDS, weight), CHECK_SHARDS, weight);
122 expect(wall, `planned ${wall.toFixed(1)} s on ${CHECK_SHARDS} shards; summed ${scanSeconds(all, known).toFixed(1)} s`).toBeLessThanOrEqual(
123 SCAN_BUDGET_SECONDS,
124 );
111125 });
112126 });

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

Keyboard shortcuts

Docs