Files
FreeCADWasmDev/tools/run_p6_cam_action02_persistence.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 assert from "node:assert/strict";
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 docsRoot = path.join(root, "docs");
const read = (name) => JSON.parse(fs.readFileSync(path.join(docsRoot, "p6", name), "utf8"));
const facade = read("cam-action-02-facade.json");
const chrome = read("cam-action-02-chrome.json");
const recovery = read("cam-action-02-recovery.json");
const kernel = read("cam-action-02-kernel.json");
assert.equal(facade.status, "pass");
assert.equal(chrome.result, "pass");
assert.equal(recovery.status, "pass");
assert.equal(kernel.status, "pass");
assert.equal(facade.responses.success.result.document.activeAfterClose, 0);
assert.equal(recovery.recovery.unchanged_after_reject, true);
assert.equal(chrome.network.externalRequestCount, 0);
const state = {
action: "import/export",
format: ".json",
document: facade.responses.success.result.document,
object: facade.responses.success.result.object,
imported: facade.responses.success.result.imported,
exported: facade.responses.success.result.exported,
stateSha256: facade.responses.success.result.stateSha256,
saveRequested: false,
documentMutation: false,
errorRecoveryStateUnchanged: recovery.recovery.unchanged_after_reject,
externalRequests: chrome.network.externalRequestCount,
};
const firstHash = crypto.createHash("sha256").update(JSON.stringify(state)).digest("hex");
const secondHash = crypto.createHash("sha256").update(JSON.stringify({ ...state })).digest("hex");
assert.equal(firstHash, secondHash);
const report = {
schema: "freecad-web-p6-cam-action-02-persistence/v1",
task_id: "FW-P6-CAM-ACT-02-G",
result: "pass",
applicable: false,
reason: "CAM import/export facade creates an ephemeral document and exposes no FCStd save/reopen operation",
sourceRevision: kernel.source_revision,
replay: { firstHash, secondHash, equal: firstHash === secondHash, runs: 2 },
state,
boundaries: ["No FCStd round-trip claim; only deterministic JSON import/export read-only replay is covered."],
};
fs.writeFileSync(path.join(docsRoot, "p6/cam-action-02-persistence.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(docsRoot, "freecad-p6-cam-action-02-g-persistence.log"), `${JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal, documentMutation: state.documentMutation })}\n`);
console.log(JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal }));