Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(gates): the golden chain weighs what it packages

esengine2f1939d01e4a
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index aed20cae9..40677b51a 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -132,9 +132,6 @@ export const KNOWN_GAPS = {
// Present in the engine and shown by non-golden samples, but never carried
// through the chain by a project the release argues from.
settings: 'Celestial Heights persists language, effects and key bindings and reads them back at boot; volume waits on the game having sound',
- // Measured: hello-world exports a 2.82MB single file, video-puzzle 3.22MB — so
- // the floor is the runtime, not the game, and no project reaches the 2MB cap.
- 'startup-size': 'the playable runtime floor (~2.8MB) exceeds the 2MB default profile cap; see REARCH_EXPORT',
};
/**
@@ -283,7 +280,14 @@ export const GOLDEN = [
},
{
id: 'video-puzzle',
- certifies: ['single-file'],
+ // `startup-size` was a declared gap until the playable transport stopped
+ // spending a third of the budget on base64: the runtime floor was 2.8MB
+ // against a 2MB cap, so no project could have carried the claim. It is
+ // 1.38MB for an empty project now, and this one packages at 1.78MB — so the
+ // claim is carried by the biggest playable in the corpus rather than the
+ // smallest thing that would pass. What JUDGES it is the `size` stage, which
+ // holds every target to the limits its own export reports.
+ certifies: ['single-file', 'startup-size'],
targets: ['playable', 'web'],
tier: 'nightly',
// Measured: this package scores 0.0763 against ITSELF — it shuffles the tiles
diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjs
index 04fa1dcac..33efdab64 100644
--- a/tools/verify-golden.mjs
+++ b/tools/verify-golden.mjs
@@ -214,6 +214,25 @@ function launchPackage(id, target, args) {
return { ...run.r, gpuDied: Boolean(run.gpuDied) };
}
+const fmtMB = (bytes) => `${(bytes / 1024 / 1024).toFixed(2)}MB`;
+
+/**
+ * The limits the export judged itself against, from the report it already
+ * writes. Read rather than recomputed: the pipeline owns what a package weighs
+ * and which limits are in force (an ad network's profile, a project's own
+ * budget), and a second opinion here is the one that drifts.
+ *
+ * An unreadable report yields nothing rather than failing — a target that
+ * declares no limit writes no verdicts, which is not the same as being over one.
+ */
+function readSizeVerdicts(reportPath) {
+ try {
+ return JSON.parse(readFileSync(reportPath, 'utf8')).size?.verdicts ?? [];
+ } catch {
+ return [];
+ }
+}
+
// Every engine build this tier's pairs will package, before any of them runs:
// finding out at pair fourteen costs the thirteen packages before it.
for (const key of new Set(pairs.map((p) => JSON.stringify(ENGINE_OF(p.target))))) {
@@ -226,9 +245,10 @@ for (const { id, target } of pairs) {
const out = path.join(WORK, `${id}-${target}`);
rmSync(out, { recursive: true, force: true });
+ const sizeReport = path.join(WORK, `${id}-${target}.size.json`);
const exported = spawnSync(process.execPath, [
path.join(ROOT, 'pipeline', 'bin', 'estella.mjs'), 'export', projectDir(id),
- '--platform', target, '--out', out,
+ '--platform', target, '--out', out, '--json', sizeReport,
], { encoding: 'utf8', cwd: ROOT });
if (exported.status !== 0) {
@@ -237,6 +257,23 @@ for (const { id, target } of pairs) {
continue;
}
+ // A package that does not fit is one nobody can ship, and until now nothing in
+ // this chain asked. The measurement existed and the CLI could already enforce
+ // it, so the limits a target declares — Meta's 2MB index.html, WeChat's 4MB
+ // main package — were judged only by whoever happened to read the output.
+ // Left as a stage rather than an export flag so a build that is over still
+ // launches and reports everything else it can, the way an over-tolerance
+ // parity does.
+ for (const verdict of readSizeVerdicts(sizeReport)) {
+ const ok = verdict.status !== 'over';
+ results.push({
+ id, target, stage: 'size', ok,
+ why: ok ? '' : `${fmtMB(verdict.measuredBytes)} against a ${fmtMB(verdict.budget.maxBytes)} limit`
+ + ` (${verdict.ratio.toFixed(2)}x) — ${verdict.budget.note ?? verdict.budget.scope}`,
+ });
+ if (!ok) console.log(`✗ ${id} ${target} — over the ${fmtMB(verdict.budget.maxBytes)} limit at ${fmtMB(verdict.measuredBytes)}`);
+ }
+
// Parity compares like for like, so the package is opened at exactly the size
// the editor's play surface came out — never a guessed one.
const golden = atTier(TIER).find((g) => g.id === id);