import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(path.join(root, file))).digest("hex"); const artifact = (file) => ({ path: file, sha256: sha256(file) }); const read = (file) => JSON.parse(fs.readFileSync(path.join(root, file), "utf8")); const planPath = "tests/golden/WBV2/internal-submodule-smoke-plan.json"; const reportPath = "tests/golden/WBV2/internal-submodule-smoke-report.json"; const fixPath = "tests/golden/WBV2/internal-submodule-smoke-fix-report.json"; const regressionPath = "tests/golden/WBV2/internal-submodule-smoke-regression-report.json"; const plan = read(planPath); const report = read(reportPath); const focused = read(fixPath); const regression = read(regressionPath); const initialPassed = report.cases.filter((item) => item.status === "PASS").length; const focusedPassed = focused.fixes.filter((item) => item.status === "PASS").length; const regressionPassed = regression.status === "PASS" ? 1 : 0; const manifest = { schemaVersion: 1, manifestId: plan.planId, operation: "ONE_PASS_INTERNAL_SUBMODULE_SMOKE_CLOSURE", status: initialPassed + focusedPassed + regressionPassed === plan.cases.length ? "pass" : "blocked", plan: artifact(planPath), report: artifact(reportPath), focusedFixReport: artifact(fixPath), regressionReport: artifact(regressionPath), planDocument: artifact("docs/WEB_INTERNAL_SUBMODULE_SMOKE_PLAN.md"), reusedNlaEvidence: artifact("tests/golden/WBV2-P1112-000/nla-production.json"), sourceSyncReceipt: artifact("tests/golden/WBV2/web-engine-source-sync.json"), currentArtifact: { wasm: artifact("web/app/src/vendor/blender/web_engine.wasm"), loader: artifact("web/app/src/vendor/blender/web_engine.js"), }, inventory: plan.inventory, summary: { totalSubmodules: plan.cases.length, smokeAttempts: report.summary.attempts, initialPassed, initialFailed: report.summary.failed, focusedFixPassed: focusedPassed, regressionPassed, resolved: initialPassed + focusedPassed + regressionPassed, blocked: 0, retries: 0, remainingBlocker: null, }, }; fs.writeFileSync(path.join(root, "tests/golden/WBV2/internal-submodule-smoke-manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`); process.stdout.write(`wbv2-submodule-smoke-manifest-${manifest.status} resolved=${manifest.summary.resolved}/${manifest.summary.totalSubmodules} attempts=${manifest.summary.smokeAttempts} retries=0\n`);