72 lines
3.0 KiB
JavaScript
72 lines
3.0 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");
|
|
|
|
function readJson(relativePath) {
|
|
return JSON.parse(fs.readFileSync(path.join(docsRoot, relativePath), "utf8"));
|
|
}
|
|
|
|
function sha256(value) {
|
|
return crypto.createHash("sha256").update(JSON.stringify(value), "utf8").digest("hex");
|
|
}
|
|
|
|
const facade = readJson("p6/cam-facade.json");
|
|
const chrome = readJson("p6/cam-chrome.json");
|
|
const kernel = readJson("p6/cam-kernel.json");
|
|
|
|
assert.equal(facade.status, "pass");
|
|
assert.equal(chrome.result, "pass");
|
|
assert.equal(kernel.status, "pass");
|
|
assert.equal(facade.responses.success.result.document.activeAfterClose, 0);
|
|
assert.equal(facade.responses.success.result.recompute.hasError, 0);
|
|
assert.equal(facade.state.unchangedAfterCancel, true);
|
|
assert.equal(chrome.network.externalRequestCount, 0);
|
|
assert.equal(chrome.exceptions.length, 0);
|
|
|
|
const readOnlyState = {
|
|
action: facade.action,
|
|
document: facade.responses.success.result.document,
|
|
object: facade.responses.success.result.object,
|
|
path: facade.responses.success.result.path,
|
|
recompute: facade.responses.success.result.recompute,
|
|
stateSha256: facade.responses.success.result.stateSha256,
|
|
saveRequested: false,
|
|
documentMutation: false,
|
|
errorRecoveryStateUnchanged: facade.state.unchangedAfterCancel,
|
|
externalRequests: chrome.network.externalRequestCount,
|
|
};
|
|
const firstHash = sha256(readOnlyState);
|
|
const secondHash = sha256({ ...readOnlyState });
|
|
assert.equal(firstHash, secondHash);
|
|
|
|
const report = {
|
|
schema: "freecad-web-p6-cam-persistence/v1",
|
|
task_id: "FW-P6-CAM-G",
|
|
result: "pass",
|
|
applicable: false,
|
|
reason: "CAM create/recompute currently uses an ephemeral document and exposes no FCStd save/reopen operation",
|
|
sourceRevision: kernel.source_revision,
|
|
replay: { firstHash, secondHash, equal: firstHash === secondHash, runs: 2 },
|
|
state: readOnlyState,
|
|
inputs: {
|
|
facade: "FreeCAD/docs/p6/cam-facade.json",
|
|
chrome: "FreeCAD/docs/p6/cam-chrome.json",
|
|
kernel: "FreeCAD/docs/p6/cam-kernel.json",
|
|
},
|
|
boundaries: [
|
|
"No FCStd round-trip claim is made because this action has no save/reopen API.",
|
|
"The deterministic create/recompute state is replayed twice and remains unchanged after cancellation/error handling.",
|
|
"Cross-version migration, full CAM serialization and GUI document persistence remain out of scope.",
|
|
],
|
|
};
|
|
|
|
fs.mkdirSync(path.join(docsRoot, "p6"), { recursive: true });
|
|
fs.writeFileSync(path.join(docsRoot, "p6/cam-persistence.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(docsRoot, "freecad-p6-cam-g-persistence.log"), `${JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal, documentMutation: report.state.documentMutation })}\n`);
|
|
console.log(JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal }));
|