import fs from 'node:fs'; import assert from 'node:assert/strict'; import { createHash } from 'node:crypto'; const read = file => JSON.parse(fs.readFileSync(file)); const baseline = read('.qa/embedded-browser-d-code-baseline.json'); const originalRoot = '.qa/embedded-browser-c84756dc-2f5a-4517-8ad0-accd26f68424'; const original = read(originalRoot + '/inputs.json'); const runtime = row => /^(?:src|dist-client|dist-server|dist-desktop)\//.test(row.path); const historical = original.inputs.filter(runtime), frozen = [...baseline.inputs, ...baseline.builds].filter(runtime); const byPath = new Map(historical.map(row => [row.path, row])); const differences = frozen.flatMap(row => { const before = byPath.get(row.path); return before?.sha256 === row.sha256 && before?.bytes === row.bytes ? [] : [{ path: row.path, before: before ?? null, frozen: row }]; }); for (const row of historical) if (!frozen.some(item => item.path === row.path)) differences.push({ path: row.path, reason: 'Missing from frozen set' }); const screenshots = ['windows-native-desktop.jpg', 'windows-native-mobile.jpg'].map(file => { const bytes = fs.readFileSync(originalRoot + '/' + file); return { path: originalRoot + '/' + file, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') }; }); const result = { success: differences.length === 0, sourceCommit: baseline.codeCommit, originalInputs: originalRoot + '/inputs.json', originalVerifierState: original.verifierSourceState, exactRuntimeFiles: frozen.length, screenshots, differences, scope: 'Bind already observed Windows native complete-window development screenshots to exact original source and compiled runtime bytes of the frozen release; verifier scripts and deployment remain separate checks.' }; fs.writeFileSync('.qa/embedded-browser-d-native-input-binding.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' }); assert.equal(differences.length, 0, JSON.stringify(differences)); console.log(JSON.stringify({ success: result.success, exactRuntimeFiles: result.exactRuntimeFiles, screenshots: screenshots.length, sourceCommit: result.sourceCommit }));