31 lines
2.6 KiB
JavaScript
31 lines
2.6 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 = {
|
|
firstSlice: { taskId: "FW-P6-INS-X", artifact: "inspection-gate.json", result: read("inspection-gate.json").result },
|
|
inspect: { taskId: "FW-P6-INS-ACT-02", artifact: "inspection-action-02-persistence.json", result: read("inspection-action-02-persistence.json").result },
|
|
python: { taskId: "FW-P6-INS-ACT-03", artifact: "inspection-action-03-persistence.json", result: read("inspection-action-03-persistence.json").result },
|
|
saveReopen: { taskId: "FW-P6-INS-ACT-04", artifact: "inspection-action-04-save-reopen.json", result: read("inspection-action-04-save-reopen.json").result }
|
|
};
|
|
const status = Object.values(contracts).every((item) => item.result === "pass" || item.result === "pass_boundary") ? "pass" : "fail";
|
|
const report = {
|
|
schema: "freecad-web-p6-inspection-module-gate/v1",
|
|
taskId: "FW-P6-INS-Y",
|
|
module: "Inspection",
|
|
status,
|
|
sourceRevision: "4f4e9244e613ea2df06e70027074a562695048cb",
|
|
contracts: Object.fromEntries(Object.entries(contracts).map(([name, item]) => [name, { ...item, sha256: hash(item.artifact) }])),
|
|
moduleStatusAfterGate: status === "pass" ? "completed" : "pending",
|
|
boundaries: ["All four declared Inspection actions have independent C-G evidence.", "Only deterministic Part::Box and Inspection::Feature fixtures are covered.", "No release, legal, performance, or non-Chrome compatibility claim is made."]
|
|
};
|
|
fs.writeFileSync(path.join(docs, "inspection-module-gate.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(docs, "inspection-module-gate.md"), `# Inspection module gate\n\n- Result: \`${status}\`\n- Source revision: \`${report.sourceRevision}\`\n- Declared actions: create/recompute, inspect/source-inventory, python-api, save/reopen\n- Inspection status after gate: \`${report.moduleStatusAfterGate}\`\n\nAll four declared Inspection actions have independent C-G evidence.\n`);
|
|
fs.writeFileSync(path.join(root, "docs/freecad-p6-inspection-y-gate.log"), `${JSON.stringify({ result: status, actions: Object.keys(contracts).length, moduleStatus: report.moduleStatusAfterGate })}\n`);
|
|
console.log(JSON.stringify({ result: status, actions: Object.keys(contracts).length, moduleStatus: report.moduleStatusAfterGate }));
|