Files
FreeCADWasmDev/tools/run_p6_sandbox_gate.mjs
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

51 lines
2.6 KiB
JavaScript

#!/usr/bin/env node
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const docs = path.join(root, "docs/p6");
const files = {
A: "sandbox-source-boundary.json",
B: "sandbox-runtime.json",
C: "sandbox-kernel.json",
D: "sandbox-recovery.json",
E: "sandbox-facade.json",
F: "sandbox-chrome.json",
G: "sandbox-persistence.json",
};
const read = (file) => JSON.parse(fs.readFileSync(path.join(docs, file), "utf8"));
const hash = (file) => crypto.createHash("sha256").update(fs.readFileSync(path.join(docs, file))).digest("hex");
const contracts = Object.fromEntries(Object.entries(files).map(([step, file]) => {
const report = read(file);
return [step, { artifact: `docs/p6/${file}`, result: report.result, sha256: hash(file), taskId: report.taskId }];
}));
const result = Object.values(contracts).every((entry) => entry.result === "pass" || entry.result === "pass_boundary") ? "pass" : "fail";
const report = {
schema: "freecad-web-p6-sandbox-gate/v1",
taskId: "FW-P6-SDB-X",
module: "Sandbox",
result,
sourceRevision: read(files.A).sourceRevision,
contracts,
closedAction: "create/recompute",
moduleStatusAfterGate: "in_progress",
coverage: {
createRecompute: "pass",
inspectSourceInventory: "pending",
pythonApi: "pending",
saveReopen: "pending",
},
boundaries: [
"A-G independently close the Sandbox create/recompute first slice and its native recovery/Facade/Chrome/persistence evidence.",
"This X gate does not mark the complete Sandbox module completed; inspect/source-inventory, python-api, action-level save/reopen and Y remain pending.",
"No release, legal, performance, cross-browser, GUI, or cross-version compatibility claim is made.",
],
};
fs.writeFileSync(path.join(docs, "sandbox-gate.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(docs, "sandbox-gate.md"), `# Sandbox first-slice gate\n\n- Result: \`${result}\`\n- Closed action: \`create/recompute\`\n- Sandbox status after gate: \`${report.moduleStatusAfterGate}\`\n\nA-G evidence is independent. inspect/source-inventory, python-api, action-level save/reopen, and Y remain pending.\n`);
fs.writeFileSync(path.join(root, "docs/freecad-p6-sandbox-x-gate.log"), `${JSON.stringify({ result, closedAction: report.closedAction, moduleStatus: report.moduleStatusAfterGate })}\n`);
console.log(JSON.stringify({ result, contracts: Object.keys(contracts).length, closedAction: report.closedAction, moduleStatus: report.moduleStatusAfterGate }));
if (result !== "pass") process.exitCode = 1;