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 abs = (file) => path.join(root, file); const readJson = (file) => JSON.parse(fs.readFileSync(abs(file), "utf8")); const writeJson = (file, value) => fs.writeFileSync(abs(file), `${JSON.stringify(value, null, 2)}\n`); const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex"); const planPath = "tests/golden/WBV2-P1100-000/module-execution-plan.json"; const p1128Path = "tests/golden/WBV2-P1128-000/manifest.json"; const p1128StatusPath = "docs/status/WBV2-P1128-000.md"; const rootPath = "tests/golden/WBV2-P1129-000/manifest.json"; const rootReportPath = "tests/golden/WBV2-P1129-000/successor-authorization-report.json"; const modulePath = "tests/golden/WBV2-P1129-001/manifest.json"; const p1128 = readJson(p1128Path); p1128.artifacts.plan.sha256 = sha(planPath); p1128.artifacts.status.sha256 = sha(p1128StatusPath); writeJson(p1128Path, p1128); const rootReport = readJson(rootReportPath); rootReport.parent.manifestSha256 = sha(p1128Path); writeJson(rootReportPath, rootReport); const authorization = readJson(rootPath); authorization.artifacts.parentManifest.sha256 = sha(p1128Path); authorization.artifacts.plan.sha256 = sha(planPath); authorization.artifacts.report.sha256 = sha(rootReportPath); writeJson(rootPath, authorization); const module = readJson(modulePath); module.artifacts.parentManifest.sha256 = sha(rootPath); module.artifacts.plan.sha256 = sha(planPath); writeJson(modulePath, module); process.stdout.write(`wbv2-handoff-hashes-repaired plan=${sha(planPath)} p1128=${sha(p1128Path)} root=${sha(rootPath)} module=${sha(modulePath)}\n`);