3D engine that AI agents drive
Allow 8 bytes of build noise for a goal scene over its goal
Nguyen Xuan An9bf595b553d5
diff --git a/bench/size/README.md b/bench/size/README.mdindex 8589c5bc..1f2ed917 100644--- a/bench/size/README.md+++ b/bench/size/README.md@@ -61,7 +61,7 @@ A bundle that the base does not have is reported and never fails. A bundle thatThe table in the output shows each bundle, the base size, the growth and the allowance. The release budgets in `budgets.json` are printed as a report and do not fail a pull request.-The goals in `budgets.json` (`lit-box`, `gltf-box`, `agent-scene`) also gate: a goal scene that was at or under its goal on the base and goes over it fails, even inside its allowance, because many small accepted increases otherwise add up past the goal. Only a `- goal:<scene>: <why>` line accepts that, and An approves those lines. A `scene:<name>` line does not. A scene already over its goal on the base may not grow by a single byte, even inside its allowance, until work brings it back under; the same `- goal:<scene>:` line is the only way past.+The goals in `budgets.json` (`lit-box`, `gltf-box`, `agent-scene`) also gate: a goal scene that was at or under its goal on the base and goes over it fails, even inside its allowance, because many small accepted increases otherwise add up past the goal. Only a `- goal:<scene>: <why>` line accepts that, and An approves those lines. A `scene:<name>` line does not. A scene already over its goal on the base may not grow by more than 8 bytes (two builds of the same source differ by a few bytes gzip), even inside its allowance, until work brings it back under; the same `- goal:<scene>:` line is the only way past.## When a check failsdiff --git a/changes/size-goal-gate-over-base.md b/changes/size-goal-gate-over-base.mdindex b7909399..c5599c13 100644--- a/changes/size-goal-gate-over-base.md+++ b/changes/size-goal-gate-over-base.md@@ -1 +1 @@-- A goal scene that is already over its goal on the base branch now fails `npm run size` when a pull request grows it by any byte; only a `- goal:<scene>:` line approved by An accepts it.+- A goal scene that is already over its goal on the base branch now fails `npm run size` when a pull request grows it by more than 8 bytes of build noise; only a `- goal:<scene>:` line approved by An accepts it.diff --git a/scripts/size-growth.mjs b/scripts/size-growth.mjsindex b357a346..8e13f629 100644--- a/scripts/size-growth.mjs+++ b/scripts/size-growth.mjs@@ -2,6 +2,8 @@import { signedBytes } from './size-budget.mjs';const CORE_ALLOWANCE_BYTES = 64;+// Two builds of the same source can differ by a few bytes gzip (measured +2 and -2 on 2026-11-04), so growth this small is noise.+const GOAL_NOISE_BYTES = 8;const OTHER_ALLOWANCE_FRACTION = 0.02;const OTHER_ALLOWANCE_FLOOR_BYTES = 64;export const ARCHIVE_NAME = 'archive';@@ -47,7 +49,7 @@ export function compareToBase(measured, baseMeasured, accepted = new Map()) {return { rows, problems };}-// A goal scene may not cross its goal, and a scene already over its goal on the base may not grow by a single byte.+// A goal scene may not cross its goal, and a scene already over its goal on the base may not grow beyond build noise (8 bytes).// Only a "- goal:<scene>:" line accepts either, and An approves those lines, so a bundle note for the scene does not count.export function goalProblems(measured, baseMeasured, goals, accepted = new Map()) {const problems = [];@@ -59,7 +61,7 @@ export function goalProblems(measured, baseMeasured, goals, accepted = new Map()const acceptLine = `ask An to accept it with the line "- goal:${scene}: <why>" in changes/<issue>.size.md`;if (baseSize <= goal) {problems.push(`scene:${scene} is ${size} bytes gzip, over its goal of ${goal}, which the base branch met (${baseSize}). Move code out of the core bundle, or ${acceptLine}.`);- } else if (size > baseSize) {+ } else if (size - baseSize > GOAL_NOISE_BYTES) {problems.push(`scene:${scene} grew from ${baseSize} to ${size} bytes gzip while it is over its goal of ${goal}. A scene over its goal may only shrink: move code out of the core bundle, or ${acceptLine}.`);}}diff --git a/tests/size-growth.test.js b/tests/size-growth.test.jsindex 134a0f87..f2a91fa6 100644--- a/tests/size-growth.test.js+++ b/tests/size-growth.test.js@@ -173,6 +173,7 @@ test('a goal scene over its goal on the base may shrink or stay, and one under iconst base = { 'scene:lit-box': size(50189), 'scene:gltf-box': size(77000) };assert.deepEqual(goalProblems({ 'scene:lit-box': size(50150), 'scene:gltf-box': size(79000) }, base, goals), []);assert.deepEqual(goalProblems({ 'scene:lit-box': size(50189), 'scene:gltf-box': size(77000) }, base, goals), []);+ assert.deepEqual(goalProblems({ 'scene:lit-box': size(50197), 'scene:gltf-box': size(77000) }, base, goals), [], 'eight bytes is build noise');});test('a goal scene over its goal on the base fails when it grows, unless a goal line accepts it', () => {