- Reader: real blend block bases win over synthesized interior array addresses, fixing post-detect track truncation (19 exported vs 60 in Main). - Track color reads DNA float[3] with an alpha pad; bpy writes 3 components because RNA PROP_COLOR_GAMMA has no alpha. - Clamp track weight and weight_stab to the RNA 0..1 factor range. - Read the scene frame range from scenes[0].renderSettings. - Mask status phases poll with a stall-tolerant loop instead of expect.poll, which fails the whole run when one DOM query stalls during engine persist. - Continuation and module coverage record the 24/24 PASS receipt (tests/golden/CLIP-HEADED-20261204-052513); acceptance stays NOT_CLAIMED. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
96 lines
5.7 KiB
JavaScript
96 lines
5.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Validate a headed Clip receipt.
|
|
*
|
|
* node tools/web/check-clip-headed.mjs [--dir <abs report dir>] [--report <abs report.json>] [--allow-headless]
|
|
*
|
|
* Without arguments the newest tests/golden/CLIP-HEADED-* directory that
|
|
* contains a report.json is validated. Prints {status, cases, artifacts} on PASS,
|
|
* {status:"FAIL", errors} on stderr and exits 1 otherwise.
|
|
*/
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const EXPECTED_CASES = ["clip-read-web", "clip-frame-web", "clip-missing-web", "clip-reopen-web", "clip-edit-web", "clip-solve-web", "clip-track-web", "clip-solve-command-web", "clip-proxy-web", "clip-plane-web", "clip-plane-drag-web", "clip-wiring", "clip-track-lifecycle", "clip-boxes-settings", "clip-detect", "clip-solve-settings", "clip-plane-complete", "clip-stab", "clip-source", "clip-dopesheet", "clip-graph", "clip-mask-edit"];
|
|
const errors = [];
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
|
|
|
function parseArgs(argv) {
|
|
const take = (name) => { const index = argv.indexOf(`--${name}`); return index >= 0 && argv[index + 1] ? argv[index + 1] : null; };
|
|
return { dir: take("dir"), report: take("report"), allowHeadless: argv.includes("--allow-headless") };
|
|
}
|
|
|
|
function newestReportDir(root) {
|
|
if (!fs.existsSync(root)) return null;
|
|
return fs.readdirSync(root)
|
|
.filter((name) => name.startsWith("CLIP-HEADED-"))
|
|
.map((name) => path.join(root, name))
|
|
.filter((dir) => fs.existsSync(path.join(dir, "report.json")))
|
|
.sort((a, b) => fs.statSync(path.join(b, "report.json")).mtimeMs - fs.statSync(path.join(a, "report.json")).mtimeMs)[0] ?? null;
|
|
}
|
|
|
|
const args = parseArgs(process.argv.slice(2));
|
|
const reportDir = args.report ? path.dirname(path.resolve(args.report)) : args.dir ? path.resolve(args.dir) : newestReportDir(path.join(REPO_ROOT, "tests/golden"));
|
|
const reportFile = args.report ? path.resolve(args.report) : reportDir ? path.join(reportDir, "report.json") : null;
|
|
if (!reportFile || !fs.existsSync(reportFile)) {
|
|
console.error(`no headed receipt found${reportDir ? `: ${reportFile ?? reportDir}` : " under tests/golden/CLIP-HEADED-*"}`);
|
|
process.exit(1);
|
|
}
|
|
let report;
|
|
try { report = JSON.parse(fs.readFileSync(reportFile, "utf8")); }
|
|
catch (error) { console.error(`report.json is not valid JSON: ${error.message}`); process.exit(1); }
|
|
|
|
if (report.schemaVersion !== 1) errors.push(`schemaVersion is ${report.schemaVersion}, expected 1`);
|
|
if (report.status !== "PASS") errors.push(`status is ${report.status}, expected PASS`);
|
|
if (report.acceptance !== "NOT_CLAIMED") errors.push(`acceptance is ${report.acceptance}, expected NOT_CLAIMED`);
|
|
if (!Array.isArray(report.errors) || report.errors.length > 0) errors.push(`errors is not empty: ${JSON.stringify(report.errors)}`);
|
|
const environment = report.environment ?? {};
|
|
if (environment.browser !== "chromium-headed" && !args.allowHeadless) errors.push(`environment.browser is ${environment.browser}, expected chromium-headed`);
|
|
if (environment.gpuMode !== "hardware" && !args.allowHeadless) errors.push(`environment.gpuMode is ${environment.gpuMode}, expected hardware`);
|
|
if (!environment.display && !args.allowHeadless) errors.push("environment.display is empty (headed runs need X11)");
|
|
if (typeof environment.chrome !== "string" || environment.chrome.length === 0) errors.push("environment.chrome is missing");
|
|
|
|
const release = report.release ?? {};
|
|
if (typeof release.wasmSha256 !== "string" || !/^[0-9a-f]{64}$/.test(release.wasmSha256)) errors.push("release.wasmSha256 is missing or not a sha256");
|
|
if (release.engineHasClipFrame !== true) errors.push("release.engineHasClipFrame is not true");
|
|
if (release.bundleHasClipEditor !== true) errors.push("release.bundleHasClipEditor is not true");
|
|
|
|
const fixtures = report.fixtures ?? {};
|
|
const blend = fixtures.blend ?? {};
|
|
const footage = fixtures.footage ?? {};
|
|
if (!blend.path || !blend.sha256) errors.push("fixtures.blend is missing a path or sha256");
|
|
else if (!fs.existsSync(blend.path)) errors.push(`fixtures.blend is missing on disk: ${blend.path}`);
|
|
else if (sha256(blend.path) !== blend.sha256) errors.push("fixtures.blend sha256 does not match disk");
|
|
if (!footage.path || !footage.sha256) errors.push("fixtures.footage is missing a path or sha256");
|
|
else if (!fs.existsSync(footage.path)) errors.push(`fixtures.footage is missing on disk: ${footage.path}`);
|
|
else if (sha256(footage.path) !== footage.sha256) errors.push("fixtures.footage sha256 does not match disk");
|
|
|
|
const cases = Array.isArray(report.cases) ? report.cases : [];
|
|
const ids = new Set(cases.filter((item) => item.status !== "SKIP").map((item) => item.caseId));
|
|
for (const id of EXPECTED_CASES) if (!ids.has(id)) errors.push(`missing expected case: ${id}`);
|
|
for (const item of cases) {
|
|
if (item.status === "FAIL") errors.push(`case ${item.caseId} failed: ${item.error ?? "no error message"}`);
|
|
for (const artifact of item.artifacts ?? []) {
|
|
const file = path.join(reportDir, artifact.path);
|
|
if (!fs.existsSync(file)) { errors.push(`artifact missing: ${artifact.path}`); continue; }
|
|
if (sha256(file) !== artifact.sha256) errors.push(`artifact sha256 mismatch: ${artifact.path}`);
|
|
}
|
|
}
|
|
|
|
if (errors.length) {
|
|
console.error(JSON.stringify({ status: "FAIL", report: reportFile, errors }, null, 2));
|
|
process.exit(1);
|
|
}
|
|
console.log(JSON.stringify({
|
|
status: "PASS",
|
|
report: reportFile,
|
|
acceptance: report.acceptance,
|
|
candidate: report.candidate,
|
|
wasmSha256: release.wasmSha256,
|
|
cases: cases.map((item) => ({ caseId: item.caseId, status: item.status })),
|
|
artifacts: cases.reduce((count, item) => count + (item.artifacts ?? []).length, 0),
|
|
}, null, 2));
|