Repository navigation
ci: enforce every byte budget on pull requests and keep raises out of feature changes - #1639
Conversation
Every reachability scenario (minimal-budgets.json) and every complete Octane application (app-budgets.json, jsx-budgets.json) now has a budget of exactly its production bytes on main plus 32, for raw, gzip and brotli. Twenty-one budgets had been exceeded with no pull request failing, because pull request CI enforced only five scenarios. Others had 4-30% slack that no change could breach. As ratchets, each budget now fails on more than 32 bytes of growth once CI enforces all of them (the follow-up pull request), and a raise lands on its own with the bytes and the reason, as this one does. Measured on main 11a9da9 with Node 24. Local and CI reachability bytes matched exactly on all 105 values compared. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… feature changes PR CI now checks every committed byte budget, in one step in test shard 1/4: `run-minimal.mjs --budgets` covers all 35 public-import reachability builds, and `run.mjs --budgets octane-tsrx octane-jsx` covers every complete Octane application. Before this, PR CI enforced five scenarios. Twenty-one budgets had been exceeded on main with no pull request failing. These builds also run each scenario's executable and reachability gates, including the behavior-only and Apollo tree-shaking checks that had their own steps. - run-minimal.mjs and run.mjs gain `--write-budgets`, which records measured + 32 bytes for what they built. run.mjs also gains target selection and `--budgets`. - A new lint step, benchmarks/bundle-size/budget-raises.mjs, fails a change that raises any committed budget while also changing anything other than budget files and prose. It compares a pull request with its merge commit's first parent, and a push with the previous commit. Feature changes may lower budgets, never raise them. - bundle-size gains an Octane-only bindings application that renders Radix, Base UI, React Aria, Mantine hooks, usehooks-ts, Floating UI and Motion. The bindings ship source, so its `bindings_app_*` bytes move with compiler output for plain `.ts` binding hooks, which no other row contained. - The weekly guards cover the bindings set and the Apollo reachability scenarios, which had no guards. - CONTRIBUTING.md, the performance-audit skill and the benchmarks README document the policy and the commands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
45 other measured values are unchanged. Public-import reachability bundles (bytes)No changes across 105 measured values. |
Brotli is not monotonic in code size. #1634 removes code and shrinks raw and gzip on every reachability row, yet raises brotli on three: +120 B on binding-apollo-client-vite and +28/+18 B on the usehooks-ts rows. The two changes that cause the apollo-vite rise each move brotli by single or double digits on their own; only their combination gives +120. A measured + 32 brotli budget would fail a change that strictly removes code, and under the budget-raise rule that change would need a separate raise. Raw and gzip stay at measured + 32 and remain the growth gate. Brotli becomes measured + 256, about twice the largest swing observed, so it still catches real compressed growth without blocking reductions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brotli is not monotonic in code size. #1634 removes code and shrinks raw and gzip on every reachability row, yet raises brotli by up to 120 B, so a measured + 32 brotli budget would fail a pure reduction and force a raise. Budgets keep 32 bytes of headroom for raw and gzip, which remain the growth gate, and get 256 for brotli: `ratchetBudget` writes that, and the docs say which metric judges growth. The bindings application's brotli budgets move with the rest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Brotli raises fail isolation gate
- Made findBudgetRaises gate only on raw and gzip leaves (via a GATED_FORMATS set), excluding brotli which is non-monotonic and has intentionally wide 256-byte headroom, so brotli increases no longer trigger the isolation rule that requires raises to land alone.
Or push these changes by commenting:
@cursor push d3170d3811
Preview (d3170d3811)
diff --git a/benchmarks/bundle-size/budget-raises.mjs b/benchmarks/bundle-size/budget-raises.mjs
--- a/benchmarks/bundle-size/budget-raises.mjs
+++ b/benchmarks/bundle-size/budget-raises.mjs
@@ -20,12 +20,17 @@
];
const PROSE = /\.mdx?$/;
+// Brotli is non-monotonic in code size (a strict removal can raise brotli on
+// some rows), so only raw and gzip growth triggers the isolation rule.
+const GATED_FORMATS = new Set(['raw', 'gzip']);
+
// Every numeric leaf that exists on both sides and grew, as `file: a.b.c`.
+// Only leaves whose immediate key is in GATED_FORMATS count as raises.
export function findBudgetRaises(file, before, after) {
const raises = [];
const walk = (left, right, trail) => {
if (typeof right === 'number') {
- if (typeof left === 'number' && right > left) {
+ if (typeof left === 'number' && right > left && GATED_FORMATS.has(trail[trail.length - 1])) {
raises.push({ budget: `${file}: ${trail.join('.')}`, before: left, after: right });
}
return;
diff --git a/benchmarks/bundle-size/budget-raises.test.mjs b/benchmarks/bundle-size/budget-raises.test.mjs
--- a/benchmarks/bundle-size/budget-raises.test.mjs
+++ b/benchmarks/bundle-size/budget-raises.test.mjs
@@ -5,13 +5,13 @@
const MINIMAL = 'benchmarks/bundle-size/minimal-budgets.json';
const APP = 'benchmarks/bundle-size/app-budgets.json';
-test('only grown values that exist on both sides are raises', () => {
+test('only grown raw and gzip values that exist on both sides are raises', () => {
const before = {
context: { raw: 100, gzip: 50, brotli: 40 },
rows: { app: { gzip: 10 }, total: { gzip: 20 } },
};
const after = {
- context: { raw: 90, gzip: 51, brotli: 40 },
+ context: { raw: 90, gzip: 51, brotli: 45 },
rows: { app: { gzip: 10 }, total: { gzip: 21 } },
added: { raw: 999, gzip: 999, brotli: 999 },
};
@@ -22,6 +22,12 @@
assert.deepEqual(findBudgetRaises(MINIMAL, null, after), []);
});
+test('brotli raises are excluded because brotli is non-monotonic', () => {
+ const before = { context: { raw: 100, gzip: 50, brotli: 40 } };
+ const after = { context: { raw: 100, gzip: 50, brotli: 60 } };
+ assert.deepEqual(findBudgetRaises(MINIMAL, before, after), []);
+});
+
test('a raise alone, with prose, is allowed', () => {
const raises = [{ budget: `${MINIMAL}: context.gzip`, before: 50, after: 51 }];
assert.deepEqual(You can send follow-ups to the cloud agent here.
# Conflicts: # benchmarks/bundle-size/minimal-budgets.json
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Brotli raises fail isolation gate
- Excluded brotli keys from the findBudgetRaises walk so only raw and gzip (the actual growth gate) can trigger the isolation check, matching the documented policy that brotli is not monotonic and not part of the growth gate.
Or push these changes by commenting:
@cursor push df7b7d7912
Preview (df7b7d7912)
diff --git a/benchmarks/bundle-size/budget-raises.mjs b/benchmarks/bundle-size/budget-raises.mjs
--- a/benchmarks/bundle-size/budget-raises.mjs
+++ b/benchmarks/bundle-size/budget-raises.mjs
@@ -20,7 +20,9 @@
];
const PROSE = /\.mdx?$/;
-// Every numeric leaf that exists on both sides and grew, as `file: a.b.c`.
+// Every non-brotli numeric leaf that exists on both sides and grew, as
+// `file: a.b.c`. Brotli is excluded because it is not monotonic in code size
+// (removing code can raise brotli), so it is not part of the growth gate.
export function findBudgetRaises(file, before, after) {
const raises = [];
const walk = (left, right, trail) => {
@@ -31,7 +33,10 @@
return;
}
if (right && typeof right === 'object' && left && typeof left === 'object') {
- for (const key of Object.keys(right)) walk(left[key], right[key], [...trail, key]);
+ for (const key of Object.keys(right)) {
+ if (key === 'brotli') continue;
+ walk(left[key], right[key], [...trail, key]);
+ }
}
};
walk(before, after, []);
diff --git a/benchmarks/bundle-size/budget-raises.test.mjs b/benchmarks/bundle-size/budget-raises.test.mjs
--- a/benchmarks/bundle-size/budget-raises.test.mjs
+++ b/benchmarks/bundle-size/budget-raises.test.mjs
@@ -22,6 +22,12 @@
assert.deepEqual(findBudgetRaises(MINIMAL, null, after), []);
});
+test('brotli growth is excluded from raises because it is not monotonic', () => {
+ const before = { context: { raw: 100, gzip: 50, brotli: 40 } };
+ const after = { context: { raw: 100, gzip: 50, brotli: 296 } };
+ assert.deepEqual(findBudgetRaises(MINIMAL, before, after), []);
+});
+
test('a raise alone, with prose, is allowed', () => {
const raises = [{ budget: `${MINIMAL}: context.gzip`, before: 50, after: 51 }];
assert.deepEqual(You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 6c52af2. Configure here.
…d metric `--write-budgets` set every metric to measured + headroom. After a change that saved bytes, that could lift a brotli budget, since brotli can grow when code is removed, so the change would trip the budget-raise gate it was meant to satisfy. Each metric now drops to measured + headroom when that is lower, stays where the measurement still fits, and rises only when the measurement exceeds it. A raise therefore comes only from a real breach, and the gate stays strict for all three metrics. Rewriting unchanged bytes is a no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # package.json
Main moved while budgets were unenforced: 70 values shrank and are lowered; 30 grew past the reset values and are raised to measured + headroom by the ratchet writer (largest: hydrate-root +88 gzip, octane-jsx rows framework +100 gzip). The same values go to the budget pull request, #1638. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main moved while budgets were unenforced: 70 values shrank and are lowered to measured + headroom; 30 grew past the reset values and are raised to measured + headroom (largest: hydrate-root +88 gzip, octane-jsx rows framework +100 gzip). Identical to the values in #1639. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # package.json
Main grew again while budgets were unenforced: most bundles gained 37-68 raw bytes, and the todo framework gained 34 B gzip. The ratchet writer raises the breached metrics (cli-spa-starter tripped this branch's gate by 13 raw bytes) and lowers the ones that shrank. The same values go to #1638. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main grew again while budgets were unenforced (most bundles +37-68 raw bytes, todo framework +34 B gzip). Breached metrics are raised to measured + headroom, shrunk ones lowered. Identical to the values in #1639. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
* ci(bench): re-set every byte budget to measured + 32 bytes Every reachability scenario (minimal-budgets.json) and every complete Octane application (app-budgets.json, jsx-budgets.json) now has a budget of exactly its production bytes on main plus 32, for raw, gzip and brotli. Twenty-one budgets had been exceeded with no pull request failing, because pull request CI enforced only five scenarios. Others had 4-30% slack that no change could breach. As ratchets, each budget now fails on more than 32 bytes of growth once CI enforces all of them (the follow-up pull request), and a raise lands on its own with the bytes and the reason, as this one does. Measured on main 11a9da9 with Node 24. Local and CI reachability bytes matched exactly on all 105 values compared. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): give brotli budgets 256 bytes of headroom Brotli is not monotonic in code size. #1634 removes code and shrinks raw and gzip on every reachability row, yet raises brotli on three: +120 B on binding-apollo-client-vite and +28/+18 B on the usehooks-ts rows. The two changes that cause the apollo-vite rise each move brotli by single or double digits on their own; only their combination gives +120. A measured + 32 brotli budget would fail a change that strictly removes code, and under the budget-raise rule that change would need a separate raise. Raw and gzip stay at measured + 32 and remain the growth gate. Brotli becomes measured + 256, about twice the largest swing observed, so it still catches real compressed growth without blocking reductions. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-measure budgets on main bc6761f Main moved while budgets were unenforced: 70 values shrank and are lowered to measured + headroom; 30 grew past the reset values and are raised to measured + headroom (largest: hydrate-root +88 gzip, octane-jsx rows framework +100 gzip). Identical to the values in #1639. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-measure budgets on main ac729dc Main grew again while budgets were unenforced (most bundles +37-68 raw bytes, todo framework +34 B gzip). Breached metrics are raised to measured + headroom, shrunk ones lowered. Identical to the values in #1639. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…orce-size-budgets # Conflicts: # benchmarks/bundle-size/app-budgets.json
…nd warm-plan perf PRs (#1687) Three open runtime perf pull requests fail the PR bench byte gate on main 12c32ec, and landing any two of them stacks past the 32-byte headroom: - #1664 (de-opt survivor fast path): +809 raw / +290 gzip in the bindings app framework chunk, which #1676 did not raise because #1639 added that budget key first; +20 raw in every compiled-only app. - #1666 (warm-plan length guard): +17 raw in every client bundle, two `!==` guards. - #1663 (scoped-value read-once): +2 raw / +30-70 gzip in descriptor-renderer bundles, a compression shift from the restructured childSlot reads. Main had already spent part of the headroom: bindings framework gzip measured exactly its budget and deferred-hydration raw had 8 bytes left. Each budget is set to the largest value measured across each PR merged alone with main and all of them merged together (plus #1665, which moves none of these values), plus 32 for raw and gzip and 256 for brotli. Only values one of those trees exceeds change. Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
Makes every committed byte budget a gate on every pull request, and keeps budget raises out of feature changes. This addresses review finding A4 ("size gating is effectively off") plus the binding-heavy bench row from F4.
Depends on #1638, which re-sets every budget to measured + 32 B for raw and gzip, and measured + 256 B for brotli. This branch carries that commit so its budget step can pass. One check is expected to fail until #1638 merges: the new lint step "Check that byte budget raises land alone", because this branch both raises budgets (via #1638's commit) and changes other files. That failure is the rule working. Once #1638 merges and main is merged in here, the raise is in the base and the step passes.
Changes
run-minimal.mjs --budgetschecks all 35 reachability builds; before, it checked 5 scenarios.run.mjs --budgets octane-tsrx octane-jsxchecks every complete Octane application.--write-budgets, which ratchets each metric of what they built and leaves other budgets untouched. A metric drops to measured + 32 B (raw and gzip) or measured + 256 B (brotli) when that is lower, stays where the measurement still fits, and rises only when it is breached. So rewriting after a change that saved bytes never produces a raise, and a raise only ever comes from a real breach.run.mjsgains positional target selection and--budgets.ratchetBudgetlives inminimal-gates.mjs, with tests.benchmarks/bundle-size/budget-raises.mjsruns in lint checks.minimal-budgets.json,app-budgets.jsonorjsx-budgets.jsonand also changes any file that is not a budget file or prose.HEAD^1); pushes compare against the previous commit.benchmarks/bundle-size/apps/bindings/octane-tsrxis a settings app built from@octanejs/radix,base-ui,aria(+aria/stately),mantine-hooks,usehooks-ts,floating-uiandmotion, all existing deps of the bundle-size package.bindings_app_*moves with compiler output for plain.tshooks. fix(compiler): inline plain-module memos beside parent-printed syntax #1577's +14.5 KB gz across 125 binding modules was invisible to every existing row.useButtonand usehooks-tsuseStepinteractions work.bindings_appby 773 B gz.ratios.jsongains guards for the 9bindings_*ops and the 6 Apollo reachability builds, which had none. Notes no longer claim 32-byte alignment..rulesyncsource plus generated copies) andbenchmarks/README.md(new "Size budgets" section) describe the policy and commands.Validation
node benchmarks/bundle-size/run-minimal.mjs --budgetsandnode benchmarks/bundle-size/run.mjs --budgets octane-tsrx octane-jsxpass on main11a9da935awith ci(bench): re-set every byte budget to measured + 32 bytes #1638's values..tsrxmoved its brotli by 72 B and--budgetsfailed until the values were re-recorded.node --test scripts/ci-workflow.test.mjs benchmarks/bundle-size/minimal-gates.test.mjs benchmarks/bundle-size/budget-raises.test.mjs: 82/82 pass.pnpm sync,pnpm rules:check,pnpm context:budget:check, andpnpm format:files:checkon changed files.pnpm format:check,pnpm typecheck,pnpm test: left to CI.Risk / follow-ups
--write-budgetsafter this lands.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes CI merge gates and will fail open PRs that grow bundles by more than 32 raw/gzip bytes; policy is documented but adoption cost is real for in-flight work.
Overview
Turns all committed bundle byte budgets into pull-request gates and formalizes how budgets move up or down.
CI replaces three partial bundle checks with one step that runs
run-minimal.mjs --budgets(every reachability scenario) andrun.mjs --budgets octane-tsrx octane-jsx(every complete Octane app). Reachability builds still run behavior and Apollo tree-shaking gates as part of that suite. Lint addsbudget-raises.mjs, which fails if any budget number increases alongside changes outside budget JSON or markdown prose.Harness adds shared
ratchetBudget(measured + 32 B raw/gzip, + 256 B brotli),--write-budgetson both runners, and--budgetsenforcement onrun.mjs. New binding-heavy TSRX app underbenchmarks/bundle-size/apps/bindingsexercises Radix, Base UI, Aria, Mantine hooks, usehooks-ts, floating-ui, and Motion so compiler output for plain.tsbinding hooks is capped viabindings_*ops andapp-budgets.json. Weeklyratios.jsonpicks up those ops plus Apollo Client reachability budgets.Docs (CONTRIBUTING, benchmarks README, performance-audit skills) describe the ratchet policy and commands.
Reviewed by Cursor Bugbot for commit f6c9eb7. Bugbot is set up for automated code reviews on this repo. Configure here.