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.

fix(gate): the static-gate criterion counted 69 of 80 as the whole list

esengine93c1550c2440
diff --git a/tools/check-unanswered-exits.mjs b/tools/check-unanswered-exits.mjs
new file mode 100644
index 000000000..97d5b46cc
--- /dev/null
+++ b/tools/check-unanswered-exits.mjs
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file check-unanswered-exits.mjs — a checker that did nothing must not exit 0.
+ *
+ * verify-aot-native and the AOT frame bench printed "did NOT run" and exited 0.
+ * Both comments said the saying was the point — "loud, not silent" — but the
+ * release runner reads a status, so four criteria were recorded as answered on
+ * a machine that never had a runtime template to measure. 11/27 was reported as
+ * 15/27, and three compiled-system ceilings had been green for as long as the
+ * runner existed.
+ *
+ * 2 is the convention for "this machine cannot answer", which run-release-gate
+ * counts apart from a pass and apart from a failure. This refuses the shape that
+ * made the lie: a verifier a criterion depends on, announcing that it skipped,
+ * and then leaving with the status of a verifier that did the work.
+ */
+import { readFileSync, existsSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { CRITERIA } from './releaseGate.mjs';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+
+/** What a checker says when it is about to report on work it did not do. */
+const ANNOUNCES_A_SKIP = /(did NOT run|SKIP\b|— skipped|nothing was checked|was not scanned|could not configure here)/;
+
+/** Every script a criterion's command names, which is the surface this covers:
+ * a tool nothing depends on may exit however it likes. */
+const named = new Set();
+for (const c of CRITERIA) {
+ for (const m of (c.answeredBy ?? '').matchAll(/(?:^|\s)((?:tools|bench)\/[\w./-]+\.mjs)/g)) named.add(m[1]);
+}
+
+const problems = [];
+for (const rel of [...named].sort()) {
+ const abs = path.join(ROOT, rel);
+ if (!existsSync(abs)) continue;
+ const lines = readFileSync(abs, 'utf8').split('\n');
+ lines.forEach((line, i) => {
+ if (!/process\.exit\(0\)/.test(line)) return;
+ // The announcement is in the console call just above the exit it belongs to.
+ const said = lines.slice(Math.max(0, i - 8), i).join('\n');
+ if (!/console\.(log|error)/.test(said) || !ANNOUNCES_A_SKIP.test(said)) return;
+ // A skip a CALLER asked for is a different thing, and the criterion is not
+ // that caller. Declared beside the exit, so the next reader sees the reason
+ // rather than trusting that someone checked.
+ if (/caller-asked-to-skip:/.test(said)) return;
+ problems.push(`${rel}:${i + 1} — announces a skip, then exits 0 (a criterion reads that as answered)`);
+ });
+}
+
+if (!named.size) {
+ console.error('check-unanswered-exits: no criterion names a script — this scan is broken.');
+ process.exit(1);
+}
+if (problems.length) {
+ console.error('check-unanswered-exits: exit 2 means "this machine cannot answer"; 0 means answered.');
+ for (const p of problems) console.error(` ${p}`);
+ process.exit(1);
+}
+console.log(`check-unanswered-exits: ${named.size} script(s) answer criteria; none reports a skip as a pass.`);
diff --git a/tools/gates.mjs b/tools/gates.mjs
index 37fc48351..30a097706 100644
--- a/tools/gates.mjs
+++ b/tools/gates.mjs
@@ -207,6 +207,7 @@ export const GATES = [
// two releases broken because nothing did.
{ id: 'verifier-owners', run: 'node tools/check-verifier-owners.mjs' },
{ id: 'electron-preconditions', run: 'node tools/check-electron-preconditions.mjs' },
+ { id: 'unanswered-exits', run: 'node tools/check-unanswered-exits.mjs' },
{ id: 'component-reference', run: 'node tools/component-reference.mjs --check' },
{ id: 'api-stability-page', run: 'node tools/api-stability.mjs --check' },
// The per-symbol tiers say what is frozen; this says what a creator can build
diff --git a/tools/releaseGate.mjs b/tools/releaseGate.mjs
index c70cfabf6..26006d91a 100644
--- a/tools/releaseGate.mjs
+++ b/tools/releaseGate.mjs
@@ -225,7 +225,10 @@ export const CRITERIA = [
{
id: 'static-gates',
says: 'every declared contract still holds (api surface, layers, corpus, host shim…)',
- answeredBy: 'pnpm run verify',
+ // --complete, because `pnpm run verify` answers "the gates that could run
+ // are green" — which on a checkout without the editor was 69 of 80, and
+ // exited 0 all the same.
+ answeredBy: 'node tools/run-gates.mjs --scope local --complete',
needs: ['tools/check-golden.mjs', 'tools/check-minigame-host.mjs'],
},
{
diff --git a/tools/run-gates.mjs b/tools/run-gates.mjs
index bd3bcedc8..5181fbffd 100644
--- a/tools/run-gates.mjs
+++ b/tools/run-gates.mjs
@@ -37,6 +37,14 @@ const HAS_EDITOR = existsSync(path.join(ROOT, 'desktop', 'package.json'));
// that is not paying minutes right now — the pre-push hook. Everything else,
// including the builds the later gates read, still runs.
const SUITES = !argv.includes('--no-suites');
+/**
+ * Whether every DECLARED gate has to have run, not just every gate that could.
+ *
+ * The release criterion took this list's exit code for "the contracts hold", and
+ * a checkout without the editor drops eleven gates and a whole suite while still
+ * leaving 0 — so the nightly read 69/69 green as an answer about 80.
+ */
+const COMPLETE = argv.includes('--complete');
const gates = gatesFor(SCOPE, HAS_EDITOR, { suites: SUITES });
const skipped = GATES.filter((g) => g.where && g.where !== SCOPE);
/** Suites this run is not paying for — named, never silently absent. */
@@ -113,3 +121,14 @@ const dear = [...spent].sort((x, y) => y.ms - x.ms).slice(0, 5);
console.log(` costliest: ${dear.map((g) => `${g.id} ${(g.ms / 1000).toFixed(0)}s`).join(', ')}`);
reportSuites();
for (const g of skipped) console.log(` not in this scope: ${g.id} — ${g.why}`);
+
+// A gate narrowed to another scope is owned there and is not this run's hole;
+// one dropped for a missing checkout or an unpaid minute is exactly that.
+if (COMPLETE) {
+ const absent = [...noEditor, ...unpaid];
+ if (absent.length) {
+ console.error(`\n${absent.length} declared gate(s) never ran here: ${absent.map((g) => g.id).join(', ')}`);
+ console.error(' --complete was asked for, so this cannot say the list is green.');
+ process.exit(2);
+ }
+}
diff --git a/tools/verify-bootlog-crash.mjs b/tools/verify-bootlog-crash.mjs
index ad871f34a..3f6ea9860 100644
--- a/tools/verify-bootlog-crash.mjs
+++ b/tools/verify-bootlog-crash.mjs
@@ -64,10 +64,14 @@ function device(adb) {
const REQUIRE_DEVICE = process.argv.includes('--require-device');
function unavailable(why) {
if (REQUIRE_DEVICE) {
+ // 2, not 1: a release is short either way, but no phone here is not a
+ // finding about the boot record, and the two want different people.
console.error(`verify-bootlog-crash: CANNOT RUN — ${why}. This was asked for with`
- + ' --require-device, so it is a failure and not a pass.');
- process.exit(1);
+ + ' --require-device, so it is not a pass.');
+ process.exit(2);
}
+ // caller-asked-to-skip: right on a laptop; the criterion passes
+ // --require-device precisely so it never reaches here.
console.log(`verify-bootlog-crash: SKIP — ${why}`);
process.exit(0);
}
diff --git a/tools/verify-native-boot.mjs b/tools/verify-native-boot.mjs
index b8ab9f5cb..0a4f3c151 100644
--- a/tools/verify-native-boot.mjs
+++ b/tools/verify-native-boot.mjs
@@ -763,11 +763,15 @@ try {
if (!device) {
const what = `no ${driver.name} device or simulator is available`;
if (opts.allowSkip) {
+ // caller-asked-to-skip: --allow-skip is for a workflow that may have no
+ // emulator; the criterion does not pass it.
console.log(`— skipped: ${what} (nothing was checked)`);
process.exit(0);
}
+ // 2 says the machine could not answer, which is what an absent emulator is —
+ // reading it as ✗ blamed the game for a runner that never booted one.
console.error(`✗ ${what}. This check is a gate; pass --allow-skip to run it where one may be absent.`);
- process.exit(1);
+ process.exit(2);
}
console.log(`device: ${device}\n`);
driver.prepare();