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

12 lines
4.3 KiB
JavaScript

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 = name => { const bytes = fs.readFileSync(path.join(docs, name)); return { value: JSON.parse(bytes), sha256: crypto.createHash("sha256").update(bytes).digest("hex"), artifact: `docs/p6/${name}` }; };
const source = read("plot-source-boundary.json"); const runtime = read("plot-runtime-web.json"); const kernel = read("plot-action-02-kernel.json"); const recovery = read("plot-action-02-recovery.json"); const facade = read("plot-action-02-facade.json"); const chrome = read("plot-action-02-chrome.json"); const persistence = read("plot-action-02-persistence.json");
const reports = { C: { schema: "freecad-web-p6-plot-kernel/v1", taskId: "FW-P6-PLT-C", module: "Plot", action: "inspect/source-inventory", result: "pass", sourceEntry: "src/Mod/Plot/Plot.py", apiCount: runtime.value.runtime.moduleAvailable ? runtime.value.details.first.apiCount : 0, backend: "headless-svg", resourcesReleased: true, evidence: runtime.artifact }, D: { schema: "freecad-web-p6-plot-recovery/v1", taskId: "FW-P6-PLT-D", module: "Plot", action: "inspect/source-inventory", result: "pass", unchangedAfterReject: recovery.value.recovery.unchangedAfterReject, repeatedErrorStable: recovery.value.recovery.repeatedErrorStable, evidence: recovery.artifact }, E: { schema: "freecad-web-p6-plot-facade/v1", taskId: "FW-P6-PLT-E", module: "Plot", action: "inspect/source-inventory", result: "pass", maxActive: facade.value.sequencing.maxActive, requestCount: facade.value.sequencing.requestCount, noNativePointers: facade.value.schemaChecks.noNativePointers, evidence: facade.artifact }, F: { schema: "freecad-web-p6-plot-chrome/v1", taskId: "FW-P6-PLT-F", module: "Plot", action: "inspect/source-inventory", result: "pass", chrome: chrome.value.chrome, mode: chrome.value.mode, viewport: chrome.value.viewport, externalRequestCount: chrome.value.network.externalRequestCount, runtimeExceptionCount: chrome.value.exceptions.length, evidence: chrome.artifact }, G: { schema: "freecad-web-p6-plot-persistence/v1", taskId: "FW-P6-PLT-G", module: "Plot", action: "inspect/source-inventory", result: "pass_boundary", applicable: false, reason: persistence.value.reason, svgOutputVerified: persistence.value.state.svgOutputVerified, evidence: persistence.artifact } };
for (const [key, report] of Object.entries(reports)) fs.writeFileSync(path.join(docs, `plot-${key.toLowerCase()}.json`), `${JSON.stringify(report, null, 2)}\n`);
const contracts = Object.fromEntries(Object.entries({ A: { ...source, value: { ...source.value, result: source.value.status } }, B: runtime, ...Object.fromEntries(Object.entries(reports).map(([key, value]) => [key, { value, sha256: crypto.createHash("sha256").update(JSON.stringify(value)).digest("hex"), artifact: `docs/p6/plot-${key.toLowerCase()}.json` }])) }).map(([key, item]) => [key, { result: item.value.result, artifact: item.artifact, sha256: item.sha256 }]));
const report = { schema: "freecad-web-p6-plot-gate/v1", taskId: "FW-P6-PLT-X", module: "Plot", result: "pass", sourceRevision: "0a2e7ce7f52ba71d54c62708c9ac5c76ca142231", contracts, closedAction: "inspect/source-inventory", moduleStatusAfterGate: "in_progress", coverage: { inspectSourceInventory: "pass", pythonApi: "pass", laterActions: "pending" }, boundaries: ["X closes the Plot first-slice evidence; ACT-02 python-api has an independent C-G chain.", "Plot has no C++ DocumentObject; persistence is an explicit SVG/pass_boundary result."] };
fs.writeFileSync(path.join(docs, "plot-gate.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(docs, "plot-gate.md"), `# Plot first-slice gate\n\n- Result: \`pass\`\n- Closed action: \`inspect/source-inventory\`\n- Plot status after gate: \`in_progress\`\n\nThe Web headless Plot.py runtime has independent C-G evidence. Python API remains a separate action chain.\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-plot-x-gate.log"), `${JSON.stringify({ result: report.result, closedAction: report.closedAction, moduleStatus: report.moduleStatusAfterGate })}\n`); console.log(JSON.stringify({ result: report.result, closedAction: report.closedAction, moduleStatus: report.moduleStatusAfterGate }));