import fs from 'node:fs'; import assert from 'node:assert/strict'; import { createHash } from 'node:crypto'; import { execFileSync } from 'node:child_process'; const read = file => JSON.parse(fs.readFileSync(file, 'utf8')); const hash = bytes => createHash('sha256').update(bytes).digest('hex'); const release = read('releases/latest.json'), baseline = read('docs/task-control-release-code-baseline.json'); assert.equal(baseline.codeCommit, execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim()); assert.equal(release.installer.version, '1.20.1'); assert.notEqual(release.portableRoot, read('.qa/task-control-fifth-candidate.json').portableRoot); for (const row of [...baseline.inputs, ...baseline.builds, ...baseline.benchmarks]) { const bytes = fs.readFileSync(row.path); assert.equal(bytes.length, row.bytes); assert.equal(hash(bytes), row.sha256); } for (const name of ['portable', 'source', 'installer']) { const row = release[name], bytes = fs.readFileSync(row.path); assert.equal(bytes.length, row.bytes); assert.equal(hash(bytes), row.sha256); } const failedSource = read('.qa/task-control-i-source-original-validation.json'); assert.equal(failedSource.success, false); const failedLog = failedSource.logs.find(row => /[\\/]tests\.tap$/.test(row.path)); assert.ok(failedLog); const failedBytes = fs.readFileSync(failedLog.path); assert.equal(hash(failedBytes), failedLog.sha256); assert.equal(failedBytes.length, failedLog.bytes); const failedStats = Object.fromEntries([...failedBytes.toString('utf8').matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(match => [match[1], Number(match[2])])); assert.equal(failedStats.tests, 624); assert.equal(failedStats.pass, 617); assert.equal(failedStats.fail, 7); assert.equal(failedStats.pass + failedStats.fail, failedStats.tests); const rejectedCandidates = read('.qa/task-control-i-package-result.json').rejectedCandidates.concat([{ portableRoot: read('.qa/task-control-fifth-candidate.json').portableRoot, reason: 'Original complete source suite finished 617/624, seven failures: omitted diagnostic evidence readers, legacy taskless proposal completion, a saved-evidence read misclassified as file delivery, Python and Node workspace review fixture assumptions, repeated-read request recovery fixture assumptions and a one-second worker deadline fixture assuming two requests were already dispatched. Original complete failure retained; product defects and fixtures corrected without weakening check/no-progress/budget protection. New immutable candidate required. No formal deployment.', sourceSuite: failedStats, sourceValidation: '.qa/task-control-i-source-original-validation.json', testLogSha256: failedLog.sha256 }]); fs.writeFileSync('.qa/task-control-j-candidate.json', JSON.stringify(release, null, 2) + '\n', { flag: 'wx' }); const log = fs.readFileSync('.qa/task-control-j-package.log'); fs.writeFileSync('.qa/task-control-j-package-result.json', JSON.stringify({ success: true, release, codeCommit: baseline.codeCommit, unchangedInputs: true, rejectedCandidates, logPath: '.qa/task-control-j-package.log', logBytes: log.length, logSha256: hash(log), recordedAt: new Date().toISOString() }, null, 2) + '\n', { flag: 'wx' }); console.log(JSON.stringify({ success: true, candidate: release.installer.candidateDirectory, codeCommit: baseline.codeCommit }));