Skip to content

fix(ci): enforce the downward bundle budget ratchet - #1771

Merged
domgan-oai merged 10 commits into
octanejs:mainfrom
openai-oss-forks:fix/bundle-budget-downward-ratchet
Oct 6, 2026
Merged

domgan-oai merged 10 commits into
octanejs:mainfrom
openai-oss-forks:fix/bundle-budget-downward-ratchet

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enforce the documented downward bundle-budget ratchet. A bundle reduction must update its ceiling so the savings cannot be silently spent by subsequent features. Both runners use the existing ratchet calculation in --budgets --ratchet mode. Absolute caps continue to apply; the exception for an isolated budget-only raise is classified against the CI base, and a source change mixed with a raise does not get it. Only the budget shard fetches the history it needs.

Integrates the hydration/Suspense stack and the Vite 8 Oxc minifier from #1792. Vite scenarios and their import ceilings use Oxc; esbuild scenarios retain esbuild. Re-measured against landed main at 087cd77. Of 159 byte metrics, 86 ceilings decrease (minimal: 58, app: 24, jsx: 4), none increase. The ratchet retains any existing tighter cap and otherwise allows 32 bytes raw/gzip and 256 bytes Brotli.

Validation

  • Full current-head CI (format, typecheck, tests, browser/parity suites and the complete strict minimal/app/JSX budget gate).
  • Focused Node 24 gate tests: 16/16, including temporary Git fixtures for mixed-source raises, isolated raises, savings, and absolute caps. The original unused-headroom regressions fail without the gate.
  • Complete 159-metric Oxc/esbuild measurement from paired CI benchmark, against base 087cd77 and its merge with this PR. Local staged source and all tracked files matched GitHub's synthetic tree exactly before copying the caps. All scenario keys and their budget peers were checked.
  • CLI starter strict ratchet reproduced the original CI failure: 100461 → 100379 raw; measured bytes + 32.
  • The repository's budget-raises guard, whitespace, and pnpm sync passed. Full frozen install uses CI's pinned pnpm; local sync used a cached pnpm fallback.
  • Independent complexity review of the ratchet control flow and exception.

Risk / follow-ups

This enforces the reviewed policy only. Any future feature exceeding its cap still needs an isolated budget prerequisite. No runtime or compiler changes originate in this PR.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · host com-79386


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Changes merge-blocking CI for all bundle budgets and new Git-dependent ratchet rules; mis-recorded budgets or missing BUDGET_BASE can fail unrelated PRs, but no runtime or security surface.

Overview
CI and the bundle-size runners now enforce a downward ratchet on committed byte budgets, not just “measured + 32” growth limits.

Shard 1/4 runs run-minimal.mjs and run.mjs with --budgets --ratchet, sets BUDGET_BASE from the PR parent or previous push commit, and uses full fetch-depth only on that shard so Git can classify budget-only raises. In ratchet mode, verifyByteBudget also requires caps to be at or below ratchetBudget(measured, budget)—so a shrink that fits an old ceiling still fails until someone runs --write-budgets. requireBudgetRatchet turns that strict check off only when the diff vs BUDGET_BASE is a budget-only raise; absolute ceilings still apply.

The three budget JSON files are lowered to match recorded savings (not raised). Docs, budget-raises.mjs refactors, expanded tests (including temp Git repos), and ci-workflow.test.mjs assertions track the new workflow.

Reviewed by Cursor Bugbot for commit ca03f14. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 5, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 5, 2026 12:36
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No budget breaches, no added work, and no timing changes beyond ±3%.

Compares ed57b1ea5, the merge commit's first parent (main has moved 3 commit(s) past the pull request's recorded base 087cd7775) with 3622e64ad on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.900 2.917 +3.0% −0.0% … +3.5% ⚪ within noise
octane-tsrx replace 6.658 6.892 +1.5% −0.0% … +5.5% ⚪ within noise
octane-tsrx add 2.742 2.858 ±0.0% −1.8% … +3.7% ⚪ within noise
octane-tsrx update 0.202 0.176 −3.5% −11.2% … +1.2% ⚪ within noise
octane-tsrx select 0.006 0.006 −0.0% −2.1% … +1.3% ⚪ within noise
octane-tsrx swap 0.040 0.041 +0.9% −1.2% … +4.3% ⚪ within noise
octane-tsrx remove 0.023 0.024 ±0.0% −4.1% … +2.4% ⚪ within noise
octane-tsrx runlots 29.925 28.950 −2.2% −9.2% … +1.9% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −1.8% −3.8% … −0.5% ⚪ within noise
octane-tsrx clear 59.500 62.983 +2.2% −1.4% … +7.9% ⚪ within noise
octane-jsx run 6.033 5.450 −6.5% −24.6% … +3.1% ⚪ within noise
octane-jsx replace 12.633 11.867 −5.5% −10.5% … +6.3% ⚪ within noise
octane-jsx add 4.417 4.600 +0.8% −5.1% … +23.6% ⚪ within noise
octane-jsx update 0.410 0.364 −2.5% −6.3% … +2.0% ⚪ within noise
octane-jsx select 0.187 0.191 +3.1% +0.5% … +7.5% ⚪ within noise
octane-jsx swap 0.325 0.312 +0.3% −6.1% … +5.3% ⚪ within noise
octane-jsx remove 0.190 0.191 +0.9% ±0.0% … +1.8% ⚪ within noise
octane-jsx runlots 31.733 32.733 +0.6% −1.2% … +2.0% ⚪ within noise
octane-jsx select_lots 1.698 1.739 −0.6% −4.7% … +3.9% ⚪ within noise
octane-jsx clear 54.792 54.250 −3.9% −5.6% … −0.9% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

@trueadm

trueadm commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

This PR now conflicts with main in benchmarks/bundle-size/app-budgets.json and minimal-budgets.json. Maintainers can't push to this org-owned fork (403), so here is what it needs.

Why it conflicts: today's merges changed the budget values this branch rewrites:

The values in this branch were measured against an older main, so neither side is right any more.

Please:

  1. Merge origin/main (octanejs/octane) into fix/bundle-budget-downward-ratchet.
  2. Resolve both budget files by taking main's values, not this branch's.
  3. Leave the gate and tooling changes (budget-raises.mjs, minimal-gates.mjs, run-minimal.mjs, ci.yml, README) as they are. They don't conflict.
  4. Don't regenerate the ratchet values yet. Several fixes are about to merge on budgets sized for them: fix(octane): resolve a component's signal handles from the children it passes #1774, ci(bench): raise the deferred-hydration budget for Hydrate children signal owners #1780/fix(octane): resolve a component's signal handles from its Hydrate children #1781, fix(octane): abort pending queries whose owner a retried attempt replaces #1783 and fix(octane): handle hydration mismatches like React 19 (boundary/root client-render fallback) #1784. Returning the slack now would fail all of them, as perf(octane): stop shipping the signal binding runtime in apps without signals #1762's lowering did today. Once that queue has landed, re-measure on the new main and lower to measured + 32 raw/gzip (256 brotli) in one pass.
  5. Push. Merging waits on a maintainer decision about the ratchet policy itself.

@trueadm

trueadm commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Update: the budget queue I mentioned earlier has landed: #1784, #1806 and #1807 are merged. This PR's shard 1 now fails on its own rule, which is working as intended: root-static: ratchet raw budget 202951 to 202904 (main's value has 47 bytes of slack).

Please wait for #1792 (bench sizes measured with Vite 8's default minifier), which is about to re-cut every budget. After it merges:

  1. Merge origin/main into this branch.
  2. Run node benchmarks/bundle-size/run-minimal.mjs --write-budgets and node benchmarks/bundle-size/run.mjs --write-budgets octane-tsrx octane-jsx, so every budget is exactly measured plus headroom.
  3. Push.

Then the ratchet passes on its own head. It's approved to merge once CI is green.

🤖 Addressed by Claude Code

@domgan-oai
domgan-oai merged commit a8ed699 into octanejs:main Oct 6, 2026
32 checks passed
trueadm added a commit that referenced this pull request Oct 6, 2026
…main (#1819)

- weather framework (raw 132,546 -> 132,761, gzip 42,262 -> 42,381) and
  total (raw 154,697 -> 154,915, gzip 50,131 -> 50,253): #1818 makes
  inferred method-call dependencies track the receiver of a shared own
  method (#1788). `__methodDep` now reads an own function's source text to
  tell an arrow, which cannot see `this`, from a method; the weather app
  ships that helper. Measured: framework 132,729 raw / 42,349 gzip, total
  154,883 raw / 50,221 gzip. Brotli and app budgets still fit.
- deferred-hydration (raw 230,898 -> 230,880, gzip 72,349 -> 72,342): main
  measures 230,848 raw / 72,310 gzip, so #1771's downward ratchet fails test
  shard 1/4 on main and on every pull request based on it.

Values are measured + 32.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants