import assert from "node:assert/strict"; 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 reportPath = path.join(root, "tests/golden/M13-01E/script-save-reopen-report.json"); const manifestPath = path.join(root, "tests/golden/M13-01E/manifest.json"); const report = JSON.parse(fs.readFileSync(reportPath, "utf8")); const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); assert.deepEqual({ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask }, { schemaVersion: 1, task: "M13-01E", parentTask: "M13-01D", nextTask: "M13-01F" }); assert.deepEqual({ schemaVersion: report.schemaVersion, task: report.task, operation: report.operation, nextTask: report.nextTask }, { schemaVersion: 1, task: "M13-01E", operation: "SCRIPT_TEXT_SAVE_REOPEN", nextTask: "M13-01F" }); assert.equal(report.exact, true); assert.equal(report.before.sources.length, 3); assert.deepEqual(report.after, report.before); assert.ok(report.savedBytes > 0); for (const source of report.after.sources) assert.equal(source.executionStatus, "BLOCKED"); for (const artifact of Object.values(manifest.artifacts)) assert.equal(crypto.createHash("sha256").update(fs.readFileSync(path.join(root, artifact.path))).digest("hex"), artifact.sha256, `artifact hash mismatch ${artifact.path}`); process.stdout.write(`script-save-reopen-ok sources=${report.after.sources.length} exact=true blocked=true savedBytes=${report.savedBytes} next=${manifest.nextTask}\n`);