import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import { createHash } from 'node:crypto'; const read = file => JSON.parse(fs.readFileSync(file)); const hash = bytes => createHash('sha256').update(bytes).digest('hex'); const original = read('.qa/embedded-browser-b-code-baseline.json'), current = read('.qa/embedded-browser-d-code-baseline.json'); const root = 'docs/embedded-browser-b-rejected-candidate-evidence', manifest = read(root + '/manifest.json'); assert.equal(manifest.sourceCommit, original.codeCommit); assert.equal(manifest.sourceOverallSuccess,false); const byPath = new Map(current.inputs.map(row => [row.path,row])); assert.equal(byPath.size,original.inputs.length); const changed = original.inputs.filter(row => { const next = byPath.get(row.path); assert.ok(next); return next.sha256 !== row.sha256 || next.bytes !== row.bytes; }).map(row => row.path).sort(); assert.deepEqual(changed,['.gitattributes','scripts/desktop-project-qa.mjs','tests/workers-http.test.mjs']); assert.deepEqual(current.builds, original.builds); for (const row of current.inputs.concat(current.builds)) assert.equal(hash(fs.readFileSync(row.path)),row.sha256,row.path); const allUiBytes = fs.readFileSync('.qa/embedded-browser-b-all-ui-original-result.json'); assert.deepEqual(allUiBytes,fs.readFileSync('.qa/embedded-browser-all-ui-validation.json')); const allUi = JSON.parse(allUiBytes); assert.equal(allUi.success,true); assert.equal(allUi.results.length,33); assert.equal(allUi.groups,250); const sealed = new Map(manifest.files.map(row => [row.path,row])); for (const row of allUi.results) { for (const [file,target] of [[row.evidence,'all-ui/' + path.basename(row.script,'.mjs') + '.json'],[row.log,'all-ui/' + path.basename(row.script,'.mjs') + '.log']]) { const declaration = sealed.get(target); assert.ok(declaration,target); assert.equal(hash(fs.readFileSync(file)),declaration.sha256,file); assert.equal(hash(fs.readFileSync(path.join(root,target))),declaration.sha256,target); } } const payload = read(path.join(read(root+'/release.json').portableRoot,'MANIFEST.json')); const help = ['docs/RESEARCH.md','docs/research/CURSOR-MECHANISMS.md','docs/research/CONTEXT-RECOVERY.md','docs/research/TOOL-LOOP.md']; for (const file of help) assert.equal(hash(fs.readFileSync(file)),payload.files.find(row => row.path === file).sha256,file); const runtimeFiles = current.inputs.concat(current.builds).filter(row => /^(src|dist-client|dist-server|dist-desktop)\//.test(row.path)).length; const result = { success:true,sourceCommit:current.codeCommit,inheritedSourceCommit:original.codeCommit,changedInputs:changed,exactRuntimeFiles:runtimeFiles, scripts:33,groups:250,originalResultSha256:hash(allUiBytes),rejectedManifestSha256:hash(fs.readFileSync(root+'/manifest.json')), scope:'Reuse the original B serial UI run after exact identity checks for every product/runtime/script/fixture/public/example input and four directly served reports. Only HTTP test synchronization, desktop acceptance helper and evidence Git attributes changed. Product runtime inputs remain exact. The failed B source test is not inherited as passing; the new source suite must run in full.' }; fs.writeFileSync('.qa/embedded-browser-d-inherited-ui.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'}); console.log(JSON.stringify(result));