Files
FreeCADWasmDev/tools/run_p6_material_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

39 lines
2.9 KiB
JavaScript

#!/usr/bin/env node
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
const docs = path.join(root, "docs/p6");
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 = {
A: { taskId: "FW-P6-MAT-A", artifact: "material-source-boundary.json", result: read("material-source-boundary.json").result },
B: { taskId: "FW-P6-MAT-B", artifact: "material-runtime.json", result: read("material-runtime.json").result },
C: { taskId: "FW-P6-MAT-C", artifact: "material-kernel.json", result: read("material-kernel.json").result },
D: { taskId: "FW-P6-MAT-D", artifact: "material-recovery.json", result: read("material-recovery.json").result },
E: { taskId: "FW-P6-MAT-E", artifact: "material-facade.json", result: read("material-facade.json").result },
F: { taskId: "FW-P6-MAT-F", artifact: "material-chrome.json", result: read("material-chrome.json").result },
G: { taskId: "FW-P6-MAT-G", artifact: "material-persistence.json", result: read("material-persistence.json").result },
};
const status = Object.values(contracts).every((item) => item.result === "pass" || item.result === "pass_boundary") ? "pass" : "fail";
const report = {
schema: "freecad-web-p6-material-gate/v1",
taskId: "FW-P6-MAT-X",
module: "Material",
result: status,
sourceRevision: read("material-source-boundary.json").sourceRevision,
contracts: Object.fromEntries(Object.entries(contracts).map(([step, item]) => [step, { ...item, sha256: hash(item.artifact) }])),
moduleStatusAfterGate: "in_progress",
coverage: { createRecompute: "pass", inspectSourceInventory: "pending", pythonApi: "pending", saveReopen: "pending" },
boundaries: [
"A-G independently close only the Material create/recompute first slice.",
"ACT-02 inspect/source-inventory, ACT-03 python-api, and ACT-04 save/reopen remain pending.",
"No release, legal, performance, or non-Chrome compatibility claim is made.",
],
};
fs.writeFileSync(path.join(docs, "material-gate.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(docs, "material-gate.md"), `# Material first-slice gate\n\n- Result: \`${status}\`\n- Source revision: \`${report.sourceRevision}\`\n- Closed action: create/recompute\n- Material status after gate: \`${report.moduleStatusAfterGate}\`\n\nA-G evidence closes only the first Material action. inspect/source-inventory, python-api, and save/reopen remain pending.\n`);
fs.writeFileSync(path.join(root, "docs/freecad-p6-material-x-gate.log"), `${JSON.stringify({ result: status, actions: 1, moduleStatus: report.moduleStatusAfterGate })}\n`);
console.log(JSON.stringify({ result: status, closedAction: "create/recompute", moduleStatus: report.moduleStatusAfterGate }));