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

test/page-titles.test.ts runs under its 2 s budget in the full suite by sharing one booted app between its cases #15960

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The cases in test/page-titles.test.ts now each run in under 0.55 s; before, the stranger case alone took about 1.07 s and the owner case about 0.92 s. Why it was slow. The app was already booted and the owner session seeded once in beforeAll, so that part of the issue was already done.

Notes

shipped production is serving it deploy 3fede26

opened this

The cases in test/page-titles.test.ts now each run in under 0.55 s; before, the stranger case alone took about 1.07 s and the owner case about 0.92 s.

Why it was slow. The app was already booted and the owner session seeded once in beforeAll, so that part of the issue was already done. The time went on two things:

  • Machine routes. The walk requested 196 routes, including the sitemap and the social preview images (~850 ms of the stranger walk). None of these is a page.
  • The owner's pages. The owner walk renders 108 real pages, about 700 ms even when warm. That is rendering work, not start-up cost.

What changed.

  • Machine routes skipped. A MACHINE pattern now skips them by the shape of their path: a file name, /.well-known/, /og/, /live/, /oauth/, /contract/, /plugins/, /__forge/, or ending in /stream, /live, /events or /mcp. I fetched all 66 excluded routes once as owner and as stranger: none returns a titled HTML page, only untitled live fragments.
  • Owner walk split in three. The owner's 130 routes are split by index into three cases. Each one checks its own pages' rules and records their titles. A last case then checks that no two owner pages share a title, across all three.
  • Shared state. The only shared state is ownerTitles and walked, written only by the three owner cases. The last case also checks that all three ran, so running a single case with -t makes that last case fail, by design.
  • Stranger case. Stays one case and checks for repeated titles itself.

Timings (junit reporter, this machine, file alone):

casebeforeafter (two runs)
stranger1.07 s0.47 / 0.45 s
owner (one case)0.92 s—
owner, pages 1 of 3—0.52 / 0.42 s
owner, pages 2 of 3—0.43 / 0.37 s
owner, pages 3 of 3—0.27 / 0.25 s
owner, no two share a title—<1 ms

Mutation check. I set the /pricing title to "Privacy" in src/web/pages/pricing.ts. Both the stranger case and the owner distinctness case failed with "Privacy · forge" repeated by /pricing, /privacy. I then reverted the change.

Left alone: test/pages-budget.test.ts (held by #15913) and all app code. The owner pages themselves still cost about 10 ms each to render. That would be a separate issue about the app, not this test.

Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. bun scripts/fast.ts named 125 files (about 10 minutes, over its 5-minute budget), so I ran this file plus the 15 scans that read test files (test-honesty, flake, module-state, global-spies-restored, dupes, gate-stray-test, helpers, page-budget-roster, route-marks-roster, timers-named, shards, rule-tests-always, tree-scans, review-rules, hollow). All 213 passed.

Try it: bun test --reporter=junit --reporter-outfile=$TMPDIR/j.xml test/page-titles.test.ts then grep -o 'time="[^"]*"' $TMPDIR/j.xml.

🤖 Generated with Claude Code

Closes #15957

commented

The cases in test/page-titles.test.ts now each run in under 0.55 s; before, the stranger case alone took about 1.07 s and the owner case about 0.92 s.

Why it was slow. The app was already booted and the owner session seeded once in beforeAll, so that part of the issue was already done. The time went on two things:

  • Machine routes. The walk requested 196 routes, including the sitemap and the social preview images (~850 ms of the stranger walk). None of these is a page.
  • The owner's pages. The owner walk renders 108 real pages, about 700 ms even when warm. That is rendering work, not start-up cost.

What changed.

  • Machine routes skipped. A MACHINE pattern now skips them by the shape of their path: a file name, /.well-known/, /og/, /live/, /oauth/, /contract/, /plugins/, /__forge/, or ending in /stream, /live, /events or /mcp. I fetched all 66 excluded routes once as owner and as stranger: none returns a titled HTML page, only untitled live fragments.
  • Owner walk split in three. The owner's 130 routes are split by index into three cases. Each one checks its own pages' rules and records their titles. A last case then checks that no two owner pages share a title, across all three.
  • Shared state. The only shared state is ownerTitles and walked, written only by the three owner cases. The last case also checks that all three ran, so running a single case with -t makes that last case fail, by design.
  • Stranger case. Stays one case and checks for repeated titles itself.

Timings (junit reporter, this machine, file alone):

casebeforeafter (two runs)
stranger1.07 s0.47 / 0.45 s
owner (one case)0.92 s—
owner, pages 1 of 3—0.52 / 0.42 s
owner, pages 2 of 3—0.43 / 0.37 s
owner, pages 3 of 3—0.27 / 0.25 s
owner, no two share a title—<1 ms

Mutation check. I set the /pricing title to "Privacy" in src/web/pages/pricing.ts. Both the stranger case and the owner distinctness case failed with "Privacy · forge" repeated by /pricing, /privacy. I then reverted the change.

Left alone: test/pages-budget.test.ts (held by #15913) and all app code. The owner pages themselves still cost about 10 ms each to render. That would be a separate issue about the app, not this test.

Checks run: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. bun scripts/fast.ts named 125 files (about 10 minutes, over its 5-minute budget), so I ran this file plus the 15 scans that read test files (test-honesty, flake, module-state, global-spies-restored, dupes, gate-stray-test, helpers, page-budget-roster, route-marks-roster, timers-named, shards, rule-tests-always, tree-scans, review-rules, hollow). All 213 passed.

Try it: bun test --reporter=junit --reporter-outfile=$TMPDIR/j.xml test/page-titles.test.ts then grep -o 'time="[^"]*"' $TMPDIR/j.xml.

🤖 Generated with Claude Code

Approved

Test-only change; app code and test/pages-budget.test.ts untouched. Timings are in the pull, each case under 0.55 s alone. The mutation check (pricing title set to Privacy) is reported failing both the stranger case and the distinctness case. I did not re-run the suite. Two things I would do next: (1) the last owner case depends on state written by the three shard cases, so -t on one case fails by design. Compute the owner titles once in a beforeAll, or make the distinctness check part of each walk, so there is no cross-case state. (2) MACHINE skips whole prefixes (/plugins/, /contract/, /live, /events) by shape. A future real page there would go unchecked. Add a test that every skipped route answers a non-HTML or untitled body, or narrow the pattern.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs