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

The client-size check gives the same verdict on every run: ceilings keep headroom and a page measures the same bytes twice #12042

Merged opened this

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

Merged

The client-size check now gives the same verdict on every run. Each ceiling is the measured size plus headroom, and every budgeted page is measured twice in one run.

shipped production is serving it deploy 7dba54b

opened this

The client-size check now gives the same verdict on every run. Each ceiling is the measured size plus headroom, and every budgeted page is measured twice in one run.

  • Headroom: ceilingFor in src/measure/client_size.ts sets each ceiling to the measured gzip bytes plus 2%, rounded up to the next 256 B. It uses integer arithmetic, so no float rounding can move a boundary. FORGE_SIZE_WRITE=1 now writes ceilingsFor(sizes), and docs/design/size-budget.json was regenerated with it (for example, / js 20824 → 21248, css 37990 → 38912).
  • Same bytes twice: test/client-size.test.ts renders each page twice and requires the counted inline <script>/<style> code to match. If it differs, inlineDrift names the page, the block (script #2) and the first differing character with the text around it. Data blocks and attributes such as nonces are not compared, because they are not counted. No page drifts on this head, and none drifts on production either (checked with scripts/client-size.ts). The red on f53d2cf was most likely a landed pull that added bytes against zero headroom, not drift, so no page module changed.
  • Message: a page over its ceiling is reported with the page, its bytes, the bytes over, and "raise it in this pull with FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts and say why". A page with no ceiling names the same command.
  • New tests: ceilingFor is checked against hand-worked values (1000 → 1024, 1004 → 1280, 251 → 512, 20824 → 21248) and against the rule itself for every 7th size up to 50 000. Another test shows two renders differing in counted code are reported while differing nonces or data blocks are not.
  • scripts/client-size.ts (the live-forge walk) also fetches each page twice and prints the headroom ceilings its walk would write. Besides being useful, this gives ceilingsFor and inlineDrift a caller outside the tests, which the dead-code test requires.
  • CLAUDE.md: the UI rule now describes this.

Accepted risk, as the issue says: a page can grow up to the headroom without failing. That is at least 2% and up to 256 B more on small pages. The growth still shows in the logged table.

To try it: bun test test/client-size.test.ts passed three times in a row. bun x tsc --noEmit and bun scripts/gate.ts pass. The 79 test files scripts/fast.ts named passed after the dead-code fix. To change a ceiling, run FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts.

keep_plan was not in my toolset this run, so the issue has no plan.

🤖 Generated with Claude Code

Closes #12040

commented

The client-size check now gives the same verdict on every run. Each ceiling is the measured size plus headroom, and every budgeted page is measured twice in one run.

  • Headroom: ceilingFor in src/measure/client_size.ts sets each ceiling to the measured gzip bytes plus 2%, rounded up to the next 256 B. It uses integer arithmetic, so no float rounding can move a boundary. FORGE_SIZE_WRITE=1 now writes ceilingsFor(sizes), and docs/design/size-budget.json was regenerated with it (for example, / js 20824 → 21248, css 37990 → 38912).
  • Same bytes twice: test/client-size.test.ts renders each page twice and requires the counted inline <script>/<style> code to match. If it differs, inlineDrift names the page, the block (script #2) and the first differing character with the text around it. Data blocks and attributes such as nonces are not compared, because they are not counted. No page drifts on this head, and none drifts on production either (checked with scripts/client-size.ts). The red on f53d2cf was most likely a landed pull that added bytes against zero headroom, not drift, so no page module changed.
  • Message: a page over its ceiling is reported with the page, its bytes, the bytes over, and "raise it in this pull with FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts and say why". A page with no ceiling names the same command.
  • New tests: ceilingFor is checked against hand-worked values (1000 → 1024, 1004 → 1280, 251 → 512, 20824 → 21248) and against the rule itself for every 7th size up to 50 000. Another test shows two renders differing in counted code are reported while differing nonces or data blocks are not.
  • scripts/client-size.ts (the live-forge walk) also fetches each page twice and prints the headroom ceilings its walk would write. Besides being useful, this gives ceilingsFor and inlineDrift a caller outside the tests, which the dead-code test requires.
  • CLAUDE.md: the UI rule now describes this.

Accepted risk, as the issue says: a page can grow up to the headroom without failing. That is at least 2% and up to 256 B more on small pages. The growth still shows in the logged table.

To try it: bun test test/client-size.test.ts passed three times in a row. bun x tsc --noEmit and bun scripts/gate.ts pass. The 79 test files scripts/fast.ts named passed after the dead-code fix. To change a ceiling, run FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts.

keep_plan was not in my toolset this run, so the issue has no plan.

🤖 Generated with Claude Code

commented

The client-size check now gives the same verdict on every run. Each ceiling is the measured size plus headroom, and every budgeted page is measured twice in one run. This push also rewraps the two doc comments in src/measure/client_size.ts that broke the gate's 100-column rule (lines 80 and 122).

  • Headroom: ceilingFor in src/measure/client_size.ts sets each ceiling to the measured gzip bytes plus 2%, rounded up to the next 256 B. It uses integer arithmetic, so no float rounding can move a boundary. FORGE_SIZE_WRITE=1 now writes ceilingsFor(sizes), and docs/design/size-budget.json was regenerated with it (for example, / js 20824 → 21248, css 37990 → 38912).
  • Same bytes twice: test/client-size.test.ts renders each page twice and requires the counted inline <script>/<style> code to match. If it differs, inlineDrift names the page, the block (script #2) and the first differing character with the text around it. Data blocks and attributes such as nonces are not compared, because they are not counted. No page drifts on this head, and none drifts on production either (checked with scripts/client-size.ts). The red on f53d2cf was most likely a landed pull that added bytes against zero headroom, not drift, so no page module changed.
  • Message: a page over its ceiling is reported with the page, its bytes, the bytes over, and "raise it in this pull with FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts and say why". A page with no ceiling names the same command.
  • New tests: ceilingFor is checked against hand-worked values (1000 → 1024, 1004 → 1280, 251 → 512, 20824 → 21248) and against the rule itself for every 7th size up to 50 000. Another test shows two renders differing in counted code are reported while differing nonces or data blocks are not.
  • scripts/client-size.ts (the live-forge walk) also fetches each page twice and prints the headroom ceilings its walk would write. Besides being useful, this gives ceilingsFor and inlineDrift a caller outside the tests, which the dead-code test requires.
  • CLAUDE.md: the UI rule now describes this.

Accepted risk, as the issue says: a page can grow up to the headroom without failing. That is at least 2% and up to 256 B more on small pages. The growth still shows in the logged table.

To try it: bun test test/client-size.test.ts passed three times in a row, and bun x tsc --noEmit passes. bun scripts/gate.ts is clean on the pushed head; before the first push its exit code was hidden behind a pipe, which is why the long lines got through. The 79 test files scripts/fast.ts named passed before this rewrap, which only touches comments. To change a ceiling, run FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts.

keep_plan was not in my toolset this run, so the issue has no plan.

🤖 Generated with Claude Code

Approved

Approved. The ceiling rule is pure and tested against hand-worked values, the same-twice check names page and block, the over-ceiling message carries the command, and the ceilings file was regenerated in the same commit. No web or terminal surface changes; the how-to went into CLAUDE.md, not README. Next: (1) in ceilingFor, replace 100 + HEADROOM_FRACTION * 100 with a plain integer constant (102) so the arithmetic is integer in fact as well as in the comment; (2) have FORGE_SIZE_WRITE refuse to write when it would raise a ceiling without a note, or print the old-to-new diff, so a silent raise is visible in the pull.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs