#!/usr/bin/env node import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { audit64Satisfied } from "./audit64.mjs"; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const docs = path.join(root, "docs"); const dir = path.join(docs, "current", "business-evidence", "desktop-test-cam-testpathlanguage-20261030"); const desktop = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-language-chrome.json"), "utf8")); const mobile = JSON.parse(fs.readFileSync(path.join(docs, "p6", "cam-language-chrome-mobile.json"), "utf8")); const caseId = "desktop-test.Mod.CAM.CAMTests.TestPathLanguage"; const EXPECTED = 7; const contract = { schema: "freecad-web-official-case-acceptance-contract/v1", caseId, source: "freecad-source/src/Mod/CAM/CAMTests/TestPathLanguage.py", enabledOfficialMethods: EXPECTED, prerequisites: [ "absolute TestPathLanguage.py and Path/Base/Language.py paths", "MNVR/INSTR helpers parse g-code into Maneuver and MoveStraight/MoveArcCW/MoveArcCCW instructions", "Qt Signal/QT_TRANSLATE_NOOP shims and stdlib numpy/tsp_solver bridges", "shared Units.Velocity and headless worker isolation", ], passConditions: [ "all 7 official methods pass", "G1 X3 Y4 path length is 5 and G2 X2 Y0 I1 J0 arc length is pi", "toCommand() emits G1 X3.000000 Y4.000000 and maneuver toPath() emits both G0 and G1 moves", "document count returns 0 to 0", "desktop and mobile have no page errors, overflow or external requests", "64-record workbench audit passes on each host", ], failureClassification: { prerequisite: "source paths, Language import or g-code parsing fail before methods", product: "official instruction, length, tangent or conversion assertion fails", presentation: "viewport, network or console failure", audit: "workbench audit failure", }, persistence: { applicable: false, reason: "Language works on in-memory maneuvers and instructions", database: "not used; SQLite WASM/OPFS is the project persistence standard when needed", }, }; function complete(report) { const result = report.cases.centroid.state.response?.result; const pre = result?.preflight; const probe = pre?.probe; return ( report.result === "pass" && result?.schema === "freecad-web-cam/test-path-language/v1" && result.tests?.length === EXPECTED && result.tests.every((t) => t.passed === true) && result.guiUp?.[0] === "bool" && result.guiUp?.[1] === false && pre?.passed === true && probe?.instructionCount === 2 && Math.abs((probe?.lineLength ?? 0) - 5) < 1e-6 && Math.abs((probe?.arcLength ?? 0) - Math.PI) < 1e-6 && probe?.toGCode === "G1 X3.000000 Y4.000000" && typeof probe?.maneuverGCode === "string" && probe.maneuverGCode.includes("G0") && probe.maneuverGCode.includes("G1") && result.documentCountBefore === 0 && result.documentCountAfter === 0 && report.cases.layout.state.crossOriginIsolated === true && report.cases.layout.state.bodyOverflow === false && report.cases.layout.state.propertiesInViewport === true && report.network.externalRequestCount === 0 && report.network.httpFailures.length === 0 && report.exceptions.length === 0 && report.audit64.status === "passed" && audit64Satisfied(report.audit64) && report.audit64.failures === 0 ); } const passed = complete(desktop) && complete(mobile); const profile = { schema: "freecad-web-official-case-profile/v1", caseId, status: passed ? "passed" : "incomplete", sourceMapped: true, implementationStatus: "native_web_owner_ready", integrationStatus: passed ? "passed" : "integration_pending", acceptancePassed: passed, preflight: desktop.cases.centroid.state.response.result.preflight, officialMethods: { expected: EXPECTED, desktop: desktop.cases.centroid.state.response.result.tests, mobile: mobile.cases.centroid.state.response.result.tests, }, viewports: { desktop: { viewport: desktop.viewport, layout: desktop.cases.layout.state, pageErrors: desktop.exceptions, overflow: desktop.cases.layout.state.bodyOverflow }, mobile: { viewport: mobile.viewport, layout: mobile.cases.layout.state, pageErrors: mobile.exceptions, overflow: mobile.cases.layout.state.bodyOverflow }, }, audit64: { desktop: desktop.audit64, mobile: mobile.audit64 }, persistence: contract.persistence, evidence: [ "acceptance-contract.json", "cam-language-native-desktop.json", "cam-language-native-mobile.json", "cam-language-browser-desktop.json", "cam-language-browser-mobile.json", "workbench-surface-audit-desktop.json", "workbench-surface-audit-mobile.json", "cam-language-desktop.png", "cam-language-mobile.png", ].map((file) => `docs/current/business-evidence/desktop-test-cam-testpathlanguage-20261030/${file}`), }; fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(path.join(dir, "acceptance-contract.json"), `${JSON.stringify(contract, null, 2)}\n`); fs.writeFileSync(path.join(dir, "desktop-test-cam-language-profile.json"), `${JSON.stringify(profile, null, 2)}\n`); console.log(JSON.stringify({ status: profile.status, methods: EXPECTED, instructions: profile.preflight.probe.instructionCount, lineLength: profile.preflight.probe.lineLength, arcLength: profile.preflight.probe.arcLength, audits: [profile.audit64.desktop.records, profile.audit64.mobile.records], })); process.exitCode = passed ? 0 : 1;