chore(size): fail only on brotli-over-cap with minified growth past a 20 B allowance; lower-only ratchet - #3821
Conversation
…r-only ratchet A scenario now fails only when it is over its brotli cap AND grew more than MINIFIED_ALLOWANCE (20 B) minified over the PR's base; over the cap within the allowance passes with a layout-noise warning. The base measurement moves from the informational compare job (which ran after check) into a parallel base job that check waits on; pushes to next compare against the previous commit. ratchet.mjs re-bases caps to measured + 10 B, lower only, floors listed apart. Co-authored-by: Claude via Cursor <noreply@cursor.com>
|
Size (brotli, eager entry chunk)
Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and grew more than 20 B minified over the base; over the cap within that allowance is brotli layout noise and passes with a warning. Caps in |
Coverage Report for CI Build 37422687576Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Warning No base build found for commit Coverage: 75.991%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Merging this PR will improve performance by 8.74%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | memo + sync render effect only (reference) |
29.4 ms | 27.1 ms | +8.74% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing size-gate-minified-allowance (b651365) with next (79df376)
Problem
Scenario caps are brotli bytes at CI-measured + 10 B, and brotli's layout is not monotonic: a few minified bytes swing a scenario's brotli by ±50–90 B. PRs fail on noise, and each fix is either a cap raise (a permanent ratchet upward) or golfing the code until the layout comes out lucky. Examples from one day:
nextmoved. ThesetLookupvariant (+61 B minified) measured +3 / −54 B.+ createStoreand +56 B onapp: compiled CSR.Size-Exception:to get through.The rule
Caps stay in brotli (frozen floors and hello world included). Per scenario, in
scripts/size/gate.mjs:MINIFIED_ALLOWANCE(20 B)MINIFIED_ALLOWANCE. A scenario can override it with an optionalminifiedAllowancefield inscenarios.js; no scenario sets one.Size-Exception:works exactly as before. It is still the override for raising a frozen floor cap (check-floor-caps.mjsis unchanged). Real growth still means lowering the bytes or raising the cap in the PR.cd scripts/size && npm run ratchet -- --from size-head.json --note "RC.x, next @ sha" [--dry-run]. It re-bases every cap to measured + 10 B rounded up to 0.01 KB, and only ever lowers a cap.scenarios.jsand frozen floors infloor-caps.json, writing a datedRatchetledger line above each cap it lowers.--from, it measures the local checkout.Workflow restructure (why)
check(the required status onnext) measured only the head and decided on its own. The base numbers lived incompare, which ran aftercheck(needs: check) and wascontinue-on-error. So the gate had no base numbers at decision time. Now:headbuilds and measures the commit under test withsize.mjs --no-gate, then uploadssize-head. It also uploads on pushes, so the ratchet can use a push's numbers.basebuilds and measures the base with the head's harness, exactly ascomparedid, then uploadssize-base. It runs in parallel withheadand iscontinue-on-error. If the base can't be measured, the caps stay absolute (fail-safe).check(same name, so branch protection is untouched) needs both. It runs the gate tests, renders the comment and summary, posts the comment (same-repo PRs only, as before), runsgate.mjs, and runs the floor-freeze check.Two consequences:
nextnow compare againstgithub.event.beforeinstead of the absolute cap. Otherwise, a merge that passed with a noise warning would leavenextred on the next push check.checktakes ~2–2.5 min andcompareadds ~2.5 min after it. Nowheadandbaserun in parallel andcheckis about +30 s on top. The required check is roughly +0.5–1 min slower, and the whole workflow is ~1.5 min faster.base.shais verified to be the first parent of therefs/pull/N/mergecommit CI measures as the head, so the minified delta is the PR's own change.Dry run
These are the actual CI numbers from each run's
checklog (head) andcomparelog (base, measured with the head's harness), fed throughgate.mjs. Only rows that were over cap, or are otherwise relevant, are shown. The cap is the head harness's cap in that run.For #3800, 13 of 17 scenarios are over their cap at +164 to +179 B minified, and all 13 still fail. For #3811, all four
Size-Exceptioncap raises in 896a85e would have been unnecessary.Ratchet dry run on today's
next(076a250, CI-measured):+ createStore14.56 → 14.54 KB,hydrating + every store primitive family28.87 → 28.82 KB,CSR12.86 → 12.84 KB,CSR, observe tier14.46 → 14.40 KB.hydrating (no stores)17.71 → 17.69 KB,page: base44.84 → 44.82 KB.This PR changes no caps.
Open questions for the maintainer
--rebase-overflag that raises a still-over cap to measured + 10 B, printed in its own table;Public API changes
None. This touches only
scripts/size/and.github/workflows/size.yml, with no changes underpackages/*/src, so there is no changeset. The new internal tooling surface isgate.mjs,ratchet.mjs,size.mjs --no-gate, the optionalminifiedAllowancescenario field, and thenpm run gate/ratchet/testscripts inscripts/size.🤖 Generated with Claude via Cursor