Improve execution preflight diagnostics
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-24 17:04:16 -04:00
parent 5c8cfd1a8c
commit 603a5a92f2
6 changed files with 240 additions and 3 deletions

View File

@@ -0,0 +1,45 @@
import fs from "node:fs";
import path from "node:path";
const TASK_ID = /^M\d+-GAP-\d{5}$/u;
function add(issues, code, detail) {
issues.push({ code, detail });
}
/**
* Validate the cheap, deterministic inputs before a generated-gap checker
* loads the WASM module or starts Blender. This is intentionally independent
* of the task-specific assertions in check-generated-gap.mjs.
*/
export function collectGeneratedGapPreflight({ root, task, entry }) {
const issues = [];
if (typeof task !== "string" || !TASK_ID.test(task)) {
add(issues, "TASK_ARGUMENT_INVALID", "use --task Mxx-GAP-nnnnn");
return issues;
}
if (!entry) {
add(issues, "TASK_NOT_INDEXED", task);
return issues;
}
if (!["active", "completed"].includes(entry.state)) {
add(issues, "TASK_NOT_RUNNABLE", `${task} state=${entry.state}; expected active or completed`);
}
const required = [];
if (entry.fixture?.path) required.push(["fixture", entry.fixture.path]);
const generator = typeof entry.desktopCommand === "string"
? entry.desktopCommand.match(/\s--python\s+(\S+)/u)?.[1]
: undefined;
if (generator) required.push(["generator", generator]);
for (const [role, relativePath] of required) {
const resolved = path.resolve(root, relativePath);
if (!fs.existsSync(resolved)) add(issues, "INPUT_MISSING", `${role}=${relativePath}`);
else if (!fs.statSync(resolved).isFile()) add(issues, "INPUT_NOT_FILE", `${role}=${relativePath}`);
}
return issues;
}
export function formatGeneratedGapPreflight(task, issues) {
return `generated-gap-preflight-failed task=${task ?? "MISSING"} issues=${issues.map((issue) => `${issue.code}:${issue.detail}`).join(",")}`;
}