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(gates): a gate that could not answer is not a gate that passed

esengine01f0bff386ad
diff --git a/tools/check-native-build.mjs b/tools/check-native-build.mjs
index 72fd41a34..060cc244b 100644
--- a/tools/check-native-build.mjs
+++ b/tools/check-native-build.mjs
@@ -27,9 +27,12 @@ import { DESKTOP_BUILD_DIR } from '../build-tools/tasks/native.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const HOST = { darwin: 'macos', linux: 'linux', win32: 'windows' }[process.platform];
+/** 2, not 0: the file header already says a machine that has never built native
+ * gets "a note, not a green light", and the note was the only thing saying it —
+ * run-gates read the status and counted this toward 118/118. */
const skip = (why) => {
console.log(`check-native-build: ${why} — skipped (CI still builds every native target).`);
- process.exit(0);
+ process.exit(2);
};
if (!HOST) skip(`no native desktop target for ${process.platform}`);
diff --git a/tools/check-project-health.mjs b/tools/check-project-health.mjs
index 992784acb..217a6c1c3 100644
--- a/tools/check-project-health.mjs
+++ b/tools/check-project-health.mjs
@@ -29,9 +29,11 @@ const CONSUMERS = {
const problems = [];
const say = (file, what) => problems.push(`${file}: ${what}`);
+// Every check below reads the editor, so without it this judges nothing — and 2
+// is what makes the runner count a hole rather than a pass.
if (!has(CHECKS)) {
- console.log('check-project-health: no editor checkout — skipped.');
- process.exit(0);
+ console.log('check-project-health: no editor checkout — nothing was judged.');
+ process.exit(2);
}
const checks = read(CHECKS);
diff --git a/tools/check-residency-authority.mjs b/tools/check-residency-authority.mjs
index 6a1a4c056..b9f280b50 100644
--- a/tools/check-residency-authority.mjs
+++ b/tools/check-residency-authority.mjs
@@ -84,7 +84,11 @@ if (installs.length !== 1) {
const DERIVES = /\b(residentCells|preparedCells|loadingCells|unloadingCells)\b/;
const DECIDES = /\b(desiredResidency|distanceToCell)\b/;
const EDITOR_STATE_AUTHOR = 'desktop/src/engine/worldRuntimeStore.ts';
-if (existsSync(path.join(ROOT, 'desktop', 'src'))) {
+/** Whether the editor half of the rule was read at all. The editor is an
+ * optional submodule, and without it this scanned nothing and still printed
+ * "one reader names it" — a claim about a directory it never opened. */
+const editorRead = existsSync(path.join(ROOT, 'desktop', 'src'));
+if (editorRead) {
for (const file of walk(path.join(ROOT, 'desktop', 'src'), /\.tsx?$/)) {
const rel = path.relative(ROOT, file).split(path.sep).join('/');
const text = readFileSync(file, 'utf8');
@@ -128,4 +132,9 @@ if (problems.length > 0) {
console.error(`check-residency-authority: ${problems.length} finding(s).`);
process.exit(1);
}
+if (!editorRead) {
+ console.log('check-residency-authority: no editor checkout — desktop/src was not scanned,'
+ + ' so nothing was judged about who reads the report. The runtime half holds.');
+ process.exit(2);
+}
console.log('check-residency-authority: one author decides what exists, one reader names it, and unloading destroys.');
diff --git a/tools/check-workspace-continuity.mjs b/tools/check-workspace-continuity.mjs
index 61c31abd7..2250d3bf7 100644
--- a/tools/check-workspace-continuity.mjs
+++ b/tools/check-workspace-continuity.mjs
@@ -34,6 +34,18 @@ const RUNTIME_WORDS = [
const problems = [];
const say = (file, what) => problems.push(`${file}: ${what}`);
+/**
+ * Files this run could not read, and so did not judge. Three of the four claims
+ * below live in the editor, which is an optional submodule — and without it this
+ * printed its closing sentence, which is a verdict, having checked one of them.
+ */
+const unread = [];
+const reads = (rel) => {
+ if (existsSync(path.join(ROOT, rel))) return true;
+ unread.push(rel);
+ return false;
+};
+
// 1. The declared shape carries no runtime fact.
const format = read(FORMAT);
const shape = /export interface WorkspaceState \{([\s\S]*?)\n\}/.exec(format);
@@ -53,7 +65,7 @@ if (!shape) {
// 2. …and neither does what the editor puts in it. A field can be spelled
// innocently and still be filled from the runtime.
-if (existsSync(path.join(ROOT, CAPTURE))) {
+if (reads(CAPTURE)) {
const capture = read(CAPTURE);
const body = /export function captureWorkspace\([\s\S]*?\n\}/.exec(capture);
if (!body) {
@@ -73,7 +85,7 @@ if (existsSync(path.join(ROOT, CAPTURE))) {
// it writes a blank editor over what it was about to restore. Checked here
// because reaching that race depends on how slowly a project opens.
const STORE = 'desktop/src/project/ProjectStore.ts';
-if (existsSync(path.join(ROOT, STORE))) {
+if (reads(STORE)) {
const store = read(STORE);
for (const fn of ['saveWorkspaceSession', 'flushWorkspaceSession']) {
// Anchored at the DECLARATION: an unanchored name also matches the call
@@ -89,7 +101,7 @@ if (existsSync(path.join(ROOT, STORE))) {
// 4. A project keeps its session out of source control. Without this the
// zero-diff claim holds only for whoever wrote their own .gitignore.
-if (existsSync(path.join(ROOT, SCAFFOLD))) {
+if (reads(SCAFFOLD)) {
const scaffold = read(SCAFFOLD);
const ignore = /export const PROJECT_GITIGNORE = `([\s\S]*?)`;/.exec(scaffold);
if (!ignore) say(SCAFFOLD, 'no PROJECT_GITIGNORE — a new project would commit its workspace');
@@ -103,4 +115,13 @@ if (problems.length > 0) {
console.error(`check-workspace-continuity: ${problems.length} finding(s).`);
process.exit(1);
}
+// A finding beats a hole: what was read and is wrong is still wrong. But with
+// nothing wrong and part of the subject unread, the closing sentence would be a
+// claim about files this run never opened.
+if (unread.length) {
+ console.log(`check-workspace-continuity: ${unread.length} of the subject was not read`
+ + ` — ${unread.join(', ')}. Nothing was judged about the capture, the write gate`
+ + ' or the scaffold; the authored-format half holds.');
+ process.exit(2);
+}
console.log('check-workspace-continuity: the session remembers an author, not a play session.');
diff --git a/tools/gates.mjs b/tools/gates.mjs
index 0e8f5125b..c97fa0b48 100644
--- a/tools/gates.mjs
+++ b/tools/gates.mjs
@@ -196,7 +196,7 @@ export const GATES = [
{ id: 'native-script-modules', run: 'node tools/check-native-script-modules.mjs' },
// …and that a packaged game really receives them: the table above is a
// promise, this exports a project and reads what its scripts bind to.
- { id: 'native-subpath-imports', run: 'node tools/check-native-subpath-imports.mjs || [ $? -eq 2 ]' },
+ { id: 'native-subpath-imports', run: 'node tools/check-native-subpath-imports.mjs' },
{ id: 'shader-blocks', run: 'node tools/check-shader-blocks.mjs' },
{ id: 'wgsl-twin', run: 'node tools/check-wgsl-twin.mjs' },
{
diff --git a/tools/run-gates.mjs b/tools/run-gates.mjs
index 3ba686ef6..959342cb8 100644
--- a/tools/run-gates.mjs
+++ b/tools/run-gates.mjs
@@ -213,6 +213,14 @@ function reportSuites() {
* hunch — this list is ordered by hand and nothing was timing it. */
const spent = [];
+/**
+ * A gate that exits 2 said it could not answer, which is the runner's problem
+ * and not the engine's — counted apart from a failure, and never as a pass.
+ */
+const CANNOT_ANSWER = 2;
+/** Gates that answered nothing here. A hole, so `--complete` refuses on them. */
+const unanswered = [];
+
/**
* The line a reader wants out of a red gate's output. Gates print their own
* verdict in their own shape, so this is a net over the shapes they use rather
@@ -264,7 +272,7 @@ for (const gate of gates) {
// report a missing toolchain as a broken subject.
: r.status === 2 ? 'unanswered'
: r.status === 0 ? 'pass' : 'fail';
- if (status !== 'pass' && !firstRed) firstRed = gate.id;
+ if (status !== 'pass' && status !== 'unanswered' && !firstRed) firstRed = gate.id;
matrix.push({
id: gate.id,
run: gate.run,
@@ -274,12 +282,23 @@ for (const gate of gates) {
suite: !!gate.covers?.length,
// Ordering is load-bearing here, so a red behind another red is a
// candidate for the invented problem the short-circuit exists to avoid.
- afterRed: status !== 'pass' && firstRed !== gate.id,
+ afterRed: status !== 'pass' && status !== 'unanswered' && firstRed !== gate.id,
firstFailingLine: status === 'pass' ? null
: r.error ? r.error.message : firstFailingLine(out),
});
console.log(status === 'pass' ? `✓ ${gate.id} (${(ms / 1000).toFixed(0)}s)`
- : `✗ ${gate.id} — ${status} (${(ms / 1000).toFixed(0)}s)`);
+ // Three marks for three states: a gate that could not answer is not a red
+ // one, and a scan that draws them the same makes the survey unreadable.
+ : status === 'unanswered' ? `— ${gate.id} — answered nothing (${(ms / 1000).toFixed(0)}s)`
+ : `✗ ${gate.id} — ${status} (${(ms / 1000).toFixed(0)}s)`);
+ continue;
+ }
+ // Eight gates already exit 2 for "could not answer" and this runner heard it as
+ // "the subject is broken", reporting a missing Python as a red gate and
+ // stopping the sixty behind it. run-release-gate's convention, here too.
+ if (r.status === CANNOT_ANSWER) {
+ console.error(`\n— ${gate.id} UNANSWERED — nothing here could answer it (see its output above)`);
+ unanswered.push(gate.id);
continue;
}
if (r.status !== 0) {
@@ -293,14 +312,21 @@ for (const gate of gates) {
}
if (SCAN) {
- const red = matrix.filter((m) => m.status !== 'pass');
- console.log(`\ngates ${SCOPE} SCAN: ${matrix.length - red.length}/${matrix.length} green`
+ // Unanswered is neither: counted apart so a survey does not read a missing
+ // toolchain as a broken subject, and never folded into the green count.
+ const blank = matrix.filter((m) => m.status === 'unanswered');
+ const red = matrix.filter((m) => m.status !== 'pass' && m.status !== 'unanswered');
+ console.log(`\ngates ${SCOPE} SCAN: ${matrix.length - red.length - blank.length}/${matrix.length} green`
+ ` in ${(spent.reduce((t, g) => t + g.ms, 0) / 1000).toFixed(0)}s`);
for (const m of red) {
console.log(` ✗ ${m.id} — ${m.status}${m.exit === null ? '' : ` (exit ${m.exit})`}`
+ `${m.afterRed ? ' [after-red: may be downstream]' : ''}`);
console.log(` ${m.firstFailingLine}`);
}
+ for (const m of blank) {
+ console.log(` — ${m.id} — answered nothing here`);
+ console.log(` ${m.firstFailingLine}`);
+ }
if (noEditor.length) {
console.log(` ${noEditor.length} editor gate(s) had no checkout: ${noEditor.map((g) => g.id).join(', ')}`);
}
@@ -322,12 +348,19 @@ if (SCAN) {
}, null, 2)}\n`);
console.log(` matrix written to ${MATRIX}`);
}
- process.exit(red.length ? 1 : 0);
+ // A survey that could not answer some of the list has not said the list is
+ // green; 2 rather than 1, because the fix is the runner's and not the engine's.
+ process.exit(red.length ? 1 : blank.length ? CANNOT_ANSWER : 0);
}
-console.log(`\ngates ${SCOPE}: ${gates.length}/${gates.length} green`
+console.log(`\ngates ${SCOPE}: ${gates.length - unanswered.length}/${gates.length} green`
+ ` in ${(spent.reduce((t, g) => t + g.ms, 0) / 1000).toFixed(0)}s`
+ (noEditor.length ? ` (${noEditor.length} editor gate(s) had no checkout to run against)` : ''));
+// Said at the top of the summary, not buried: a count that reads as the whole
+// list is exactly how a skip becomes a green light.
+if (unanswered.length) {
+ console.log(` ${unanswered.length} gate(s) answered nothing here: ${unanswered.join(', ')}`);
+}
// Name the costliest: "the gates are slow" is not something anyone can act on,
// and "sdk-tests took 78 of the 210 seconds" is.
const dear = [...spent].sort((x, y) => y.ms - x.ms).slice(0, 5);
@@ -344,6 +377,10 @@ if (COMPLETE) {
const holes = [
...[...noEditor, ...unpaid].map((g) => g.id),
...declared.map((g) => `${g.env}=${g.value}`),
+ // A gate that ran and could not answer is the same hole as one that never
+ // ran. `static-gates` read 118/118 green while check-native-build built
+ // nothing, because only the text said so.
+ ...unanswered,
];
if (holes.length) {
console.error(`\n${holes.length} declared gate(s) or capability gap(s) never ran here: ${holes.join(', ')}`);