Skip to content

ci: review bundle growth after it lands on main - #1908

Merged
trueadm merged 4 commits into
mainfrom
feat/post-merge-size-review
Oct 8, 2026
Merged

trueadm merged 4 commits into
mainfrom
feat/post-merge-size-review

Conversation

@trueadm

@trueadm trueadm commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This replaces pre-merge byte budgets (removed in #1907) with a post-merge review. After each push to main, a workflow measures every production bundle before and after the push. When bytes went up, Claude reviews the landed diff and records whether the growth was earned or slop, and how the change could have been written smaller, in one rolling GitHub issue.

How it works

.github/workflows/size-review.yml runs on every push to main that touches packages/**, benchmarks/**, package.json, or pnpm-lock.yaml, and on manual dispatch with base and head inputs.

  1. Measure. It checks out the pushed commit and the commit before the push, and runs bench.mjs bundle-size bundle-reachability in both trees on one runner, as the PR bench does.
  2. Compare. size-review.mjs growth groups each changed Octane bundle's gzip, raw, and brotli deltas. The review continues only when some bundle grew by at least 32 gzip bytes. The SIZE_REVIEW_MIN_GZIP_BYTES repository variable overrides that.
  3. Review. It runs pinned Claude Code (@anthropic-ai/[email protected]) in --print mode, on claude-opus-5-5 unless the SIZE_REVIEW_MODEL variable overrides it.
    • The prompt carries the range, the landed PRs, and the growth table. It asks Claude to attribute the bytes to hunks, judge each hunk as earned or slop (duplicated logic, dead branches, dev-only strings reaching production, impossible-state checks, poorly minifying code, new helpers where one exists, untreeshakeable code), and give concrete smaller rewrites.
    • Claude gets read-only tools only: Read, Grep, Glob, and git diff/log/show. The step has no GitHub token, a 60-turn limit, a $5 spend cap, and a 20-minute timeout.
  4. Record. size-review.mjs publish keeps one rolling "Bundle size review" issue, found by a hidden marker among open issues the Actions bot created.
    • Each entry is one comment on that issue, and the issue body is a fixed header. A rerun for the same commit edits its own comment; the workflow's per-commit concurrency group serializes reruns.
    • A new issue opens only when none is open. Close it after triage to start a fresh one.
    • Concurrent pushes can't lose each other's entries, because runs only add comments. Two pushes that both find no open issue can each open one. Each attempt therefore copies any newer review issue's entries onto the oldest open issue and closes the newer one, then confirms its own entry is on the oldest, retrying if not.
    • A failed or timed-out Claude review doesn't stop the record step. analysis.md exists only after a clean exit, so the entry then records the growth alone.

Without an ANTHROPIC_API_KEY secret the workflow still runs. Each entry then records the measured growth, with a note that the review was skipped.

Setup needed

  • Add an ANTHROPIC_API_KEY repository secret. The repo has none today.
  • Optional repository variables: SIZE_REVIEW_MODEL and SIZE_REVIEW_MIN_GZIP_BYTES.

Validation

  • node --test benchmarks/size-review.test.mjs: 9 pass. It covers:
    • metric grouping and ordering, the threshold, and skipping a failed side;
    • entry rendering, the issue header, and entry recognition;
    • one comment per push, with a rerun editing its own comment.
    • two races replayed against an in-memory tracker. In the first, a publish lands between another's read of the open issue and its write, and both entries must survive. In the second, two publishes each open an issue and must converge on the oldest. The convergence test fails when the duplicate fold is removed.
    • the prompt, and the workflow contract: push-only trigger, pinned actions, and read-only Claude tools; no GitHub token in the Claude step; continue-on-error; and analysis.md written only after a clean exit.
  • pnpm ci:workflow:test: 386 pass, after merging main (ci: remove every byte and work-count budget gate #1907 removed the budget tests).
  • Dry run on real data: real bundle-reachability results with a synthetic +120 B growth on cli-spa-starter, against the real range e989adeb1b..cbc1e8e651 (perf(octane): move feature-only Block state to a lazy record #1896). growth and prompt ran, the latter resolving perf(octane): move feature-only Block state to a lazy record #1896 through gh. The rendered issue body looked right. publish was not run, to avoid creating a real issue.
  • The pinned CLI accepts --print, --model, --max-turns, --max-budget-usd, and --allowedTools. Checked locally without credentials.
  • pnpm sync: no drift. pnpm format:files:check: clean.
  • The workflow itself has not run on GitHub yet. Its first run is the push that merges this PR. That push grows no bundle, so it should end at "Compare bundle bytes" without touching any issue.
  • perf-review: not applicable (no runtime, compiler-output, or binding code)

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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


Note

Low Risk
Changes are CI/benchmark tooling and GitHub issue automation only; they do not alter runtime, compiler output, or merge gates.

Overview
Adds post-merge bundle size review on pushes to main (replacing pre-merge byte gates): a new workflow compares bundle-size and bundle-reachability on the parent commit vs the pushed commit, and when any bundle grows by ≥32 gzip bytes (configurable), it optionally runs Claude on the landed diff and records results on a rolling "Bundle size review" GitHub issue.

benchmarks/size-review.mjs implements growth (reuses compareSuite from pr-report.mjs), prompt (landed commits/PRs + review instructions), and publish (comment-per-push on one open issue, with duplicate-issue folding and same-commit reruns). The workflow runs benchmarks in parallel via a git worktree, caps Claude with read-only git tools and no GH_TOKEN, and still publishes measured growth if the API key or review step fails.

Docs in benchmarks/README.md and benchmarks/size-review.test.mjs (wired into ci:workflow:test) cover grouping, thresholds, concurrent publish behavior, and workflow security contracts.

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

Replaces pre-merge byte budgets with a post-merge review. Each push to main
builds the bundle-size and reachability scenarios before and after the push.
When a bundle grew by at least 32 gzip bytes, Claude reads the landed diff
with read-only tools and judges whether the growth is earned or slop and how
the change could have been written smaller. benchmarks/size-review.mjs records
that in one rolling "Bundle size review" issue: an open one is edited in
place, newest entry first, and a new one opens only when none is open.

Claude runs only when the ANTHROPIC_API_KEY secret is set; without it the
issue records the measured growth alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm marked this pull request as ready for review October 8, 2026 15:45
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent ci PR: CI or build pipeline labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares e29a12be0, the merge commit's first parent (main has moved 2 commit(s) past the pull request's recorded base 4224a4ab3) with 62f577045 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. 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 5.333 5.350 +9.0% −1.5% … +19.5% ⚪ within noise
octane-tsrx replace 14.125 12.492 −3.6% −13.1% … +1.4% ⚪ within noise
octane-tsrx add 4.033 4.217 +9.5% −7.9% … +30.0% ⚪ within noise
octane-tsrx update 0.218 0.209 −0.3% −7.7% … +8.7% ⚪ within noise
octane-tsrx select 0.010 0.011 +6.0% −4.4% … +13.5% ⚪ within noise
octane-tsrx swap 0.053 0.054 −5.5% −14.5% … +1.1% ⚪ within noise
octane-tsrx remove 0.027 0.029 +10.0% ±0.0% … +23.1% ⚪ within noise
octane-tsrx runlots 42.017 43.500 +1.2% −8.4% … +19.3% ⚪ within noise
octane-tsrx select_lots 0.011 0.011 −5.2% −15.1% … +6.3% ⚪ within noise
octane-tsrx clear 82.392 88.000 −3.9% −13.0% … +9.1% ⚪ within noise
octane-jsx run 8.283 8.067 +0.1% −11.5% … +11.0% ⚪ within noise
octane-jsx replace 15.983 14.875 −5.9% −14.1% … +2.7% ⚪ within noise
octane-jsx add 6.308 6.725 −3.5% −11.1% … +14.8% ⚪ within noise
octane-jsx update 0.542 0.507 +0.2% −12.5% … +8.3% ⚪ within noise
octane-jsx select 0.192 0.185 −1.4% −5.6% … +1.7% ⚪ within noise
octane-jsx swap 0.373 0.391 +2.2% −6.0% … +13.9% ⚪ within noise
octane-jsx remove 0.308 0.332 +5.1% −2.1% … +13.6% ⚪ within noise
octane-jsx runlots 55.258 49.350 −1.7% −19.9% … +7.1% ⚪ within noise
octane-jsx select_lots 2.851 2.782 −9.4% −22.7% … +11.2% ⚪ within noise
octane-jsx clear 64.808 72.067 +6.3% +0.8% … +11.6% ⚪ 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 111 measured values.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Concurrent publishes create duplicate issues
    • After creating a new issue, the code now re-checks openIssue() for a lower-numbered canonical issue and closes the duplicate before retrying, ensuring only one rolling issue exists.

Create PR

Or push these changes by commenting:

@cursor push 6a232f53ce
Preview (6a232f53ce)
diff --git a/benchmarks/size-review.mjs b/benchmarks/size-review.mjs
--- a/benchmarks/size-review.mjs
+++ b/benchmarks/size-review.mjs
@@ -305,6 +305,15 @@
 				bodyFile,
 			]).trim();
 			number = Number(url.split('/').pop());
+			// A concurrent publish may also have created an issue. The canonical
+			// issue is the lowest-numbered open one; close ours if it lost the race
+			// and retry so the next iteration merges into the winner.
+			const canonical = openIssue(repository);
+			if (canonical && canonical.number < number) {
+				run('gh', ['issue', 'close', String(number), '-R', repository]);
+				console.warn(`closed duplicate #${number}; canonical issue is #${canonical.number}`);
+				continue;
+			}
 		} else {
 			run('gh', ['issue', 'edit', String(number), '-R', repository, '--body-file', bodyFile]);
 		}

You can send follow-ups to the cloud agent here.

Comment thread benchmarks/size-review.mjs Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website ccacb2c Commit Preview URL

Branch Preview URL
Oct 08 2026, 07:23 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp ccacb2c Commit Preview URL

Branch Preview URL
Oct 08 2026, 07:25 PM

trueadm and others added 2 commits October 8, 2026 19:53
Two pushes that publish at once could each find no open review issue and
open one apiece, splitting the rolling log (Bugbot). Each publish attempt
now writes to the oldest open review issue, folds in the entries of any
newer review issue and closes it, then confirms its entry is in the oldest
open issue. An issue the run just opened stays in view even if the issue
listing lags behind.

The GitHub calls sit behind a small adapter so a test can replay the race:
one publish runs start to finish between the other's read and its create,
and both entries end up in the surviving issue.

Also drop the `*-budget` target filter: #1907 and #1910 removed those
targets, so nothing produces them any more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Concurrent edits drop review entries
    • Added a re-read and re-merge step after the initial write in publishEntry so that entries clobbered by a concurrent stale-body edit are recovered before the verification check, and late duplicate issues are also folded.
  • ✅ Fixed: Claude timeout skips growth publish
    • Changed the 'Record the review in the size issue' step's condition from if: steps.growth.outputs.grew == 'true' to if: always() && steps.growth.outputs.grew == 'true' so the step runs even when the Claude step fails due to a timeout or other step-level failure.

Create PR

Or push these changes by commenting:

@cursor push e243dbc55f
Preview (e243dbc55f)
diff --git a/.github/workflows/size-review.yml b/.github/workflows/size-review.yml
--- a/.github/workflows/size-review.yml
+++ b/.github/workflows/size-review.yml
@@ -139,7 +139,7 @@
             || { echo "::warning::Claude review failed; the issue records the growth only"; rm -f "$RESULTS/review/analysis.md"; }
 
       - name: Record the review in the size issue
-        if: steps.growth.outputs.grew == 'true'
+        if: always() && steps.growth.outputs.grew == 'true'
         env:
           GH_TOKEN: ${{ github.token }}
           RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

diff --git a/benchmarks/size-review.mjs b/benchmarks/size-review.mjs
--- a/benchmarks/size-review.mjs
+++ b/benchmarks/size-review.mjs
@@ -290,8 +290,23 @@
 		for (const duplicate of duplicates) {
 			github.close(duplicate.number, `Folded into #${number}.`);
 		}
-		const [oldest] = github.openIssues();
-		if (oldest !== undefined && github.body(oldest.number).includes(entryStart(headSha))) {
+		// Re-read and re-merge so a concurrent publish that edited from a stale
+		// body does not silently lose our entry (or we theirs).  Without a
+		// compare-and-swap API the first writer's verify can pass before the
+		// second write lands; re-merging from the post-write body recovers both.
+		const [oldest, ...lateDuplicates] = github.openIssues();
+		if (oldest === undefined) continue;
+		const current = github.body(oldest.number);
+		const settled = mergeIssueBody(
+			[...lateDuplicates.map(({ body }) => body), current],
+			entry,
+			options,
+		);
+		if (settled !== current) github.edit(oldest.number, settled);
+		for (const dup of lateDuplicates) {
+			github.close(dup.number, `Folded into #${oldest.number}.`);
+		}
+		if (settled.includes(entryStart(headSha))) {
 			return oldest.number;
 		}
 		console.warn(

diff --git a/benchmarks/size-review.test.mjs b/benchmarks/size-review.test.mjs
--- a/benchmarks/size-review.test.mjs
+++ b/benchmarks/size-review.test.mjs
@@ -256,6 +256,6 @@
 	assert.match(claude, /@anthropic-ai\/claude-code@\d+\.\d+\.\d+ /);
 	assert.doesNotMatch(claude, /GH_TOKEN|github\.token/);
 	const record = step('Record the review in the size issue');
-	assert.match(record, /if: steps\.growth\.outputs\.grew == 'true'\n/);
+	assert.match(record, /if: always\(\) && steps\.growth\.outputs\.grew == 'true'\n/);
 	assert.doesNotMatch(record, /ANTHROPIC/);
 });

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 25dae0d. Configure here.

Comment thread benchmarks/size-review.mjs Resolved
Comment thread .github/workflows/size-review.yml Resolved
…imeout

Two publishes that read the same open issue body and edited it could
overwrite each other: the later write still held its own entry and
returned, so the earlier review vanished (Bugbot). Each entry is now its
own comment on the rolling issue. Runs only add comments, so nothing a
concurrent run writes can be lost. A rerun for the same commit edits its
own comment, and the workflow's per-commit concurrency group serializes
reruns. The issue body is a fixed header. Duplicate issues from two runs
that both found none still fold into the oldest one and close.

A 20-minute timeout killed the Claude step before its `||` fallback, so the
job counted as failed and the record step was skipped (Bugbot). The step is
now `continue-on-error`. It writes to analysis.partial.md and moves that to
analysis.md only after a clean exit, so a killed review can't leak a partial
analysis into the issue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 9c440f4 into main Oct 8, 2026
35 checks passed
@trueadm
trueadm deleted the feat/post-merge-size-review branch October 8, 2026 19:33
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 ci PR: CI or build pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant