size budgets drift up to the 2% ratchet before anything re-records them
Problem
pnpm size:check fails a move past max(2%, 256 B), and pnpm size:update only re-records the entries of packages the current branch changed. Nothing re-records an entry that grew but stayed under the threshold, so a package's recorded budget drifts away from what main actually builds, one sub-threshold PR at a time. The next branch that crosses the line then inherits the whole accumulated delta as if it were its own.
Measured on #7700, building from main's own sources in the PR's tree:
| entry | recorded budget | main builds |
drift |
|---|---|---|---|
@assistant-ui/core ./react |
81344 | 82715 | +1371 B (1.69%) |
That 1.69% had accumulated silently. #7700 adds 370 B of its own, crosses 2%, and its size budget commit reads as a 1741 B regression unless a reviewer knows to subtract the pre-existing part.
Effect
Two things degrade. The budget stops being a description of main, so a diff on size-budgets.json no longer tells a reviewer what a PR cost. And the real per-PR headroom shrinks toward zero as drift accumulates, so an unrelated change eventually fails the gate for reasons that have nothing to do with it.
Options
- Run
pnpm size:update:allonmainon a schedule (the nightly performance workflow already runs there) and commit the result, so the recorded budget tracksmainand each PR's diff shows only its own cost. - Or report drift without failing: have the nightly run compare
main's build against the recorded budget and open or update an issue when an entry has drifted past some fraction of the threshold.
The first keeps the gate meaningful with no new machinery. Either way the ratchet should not be the only thing that ever writes the file.
Source: assistant-ui/assistant-ui