43 lines
4.0 KiB
JavaScript
43 lines
4.0 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
const read = file => JSON.parse(fs.readFileSync(file));
|
|
const beforeFile = 'docs/embedded-browser-b-rejected-candidate-evidence/portable-manifest.json';
|
|
const release = read('releases/latest.json'), afterFile = path.join(release.portableRoot, 'MANIFEST.json');
|
|
const before = read(beforeFile), after = read(afterFile);
|
|
assert.equal(before.version, '1.22.0'); assert.equal(after.version, before.version);
|
|
assert.equal(read('.qa/embedded-browser-d-archives-original-result.json').success, true);
|
|
const retained = row => /^(?:dist-client|dist-server|dist-desktop|runtime|desktop|scripts|public|examples|benchmarks|research|licenses)\//.test(row.path)
|
|
|| ['package.json', 'THIRD_PARTY_NOTICES.txt'].includes(row.path);
|
|
const previous = before.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
|
const current = after.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
|
const differences = current.filter(row => {
|
|
const old = previous.find(value => value.path === row.path);
|
|
return !old || old.sha256 !== row.sha256 || old.bytes !== row.bytes;
|
|
}).map(row => ({ before: previous.find(old => old.path === row.path), after: row }));
|
|
assert.equal(current.length, previous.length);
|
|
fs.writeFileSync('.qa/embedded-browser-d-vendor-runtime-initial-review.json', JSON.stringify({
|
|
originalExactComparisonPassed: false, inheritedInitialComparison: true, differences,
|
|
originalVerifierSha256: hash(fs.readFileSync('.qa/embedded-browser-c-bind-vendor-runtime.before-timestamp-review.mjs')),
|
|
scope: 'Additional verifier first rejected raw manifests because the REA descriptor differs. Original B source failure and C independent suite are unaffected. Narrow field analysis follows; no formal phase ran.'
|
|
}, null, 2) + '\n', { flag: 'wx' });
|
|
assert.deepEqual(differences.map(row => row.after.path), ['runtime/REA-RUNTIME.json']);
|
|
const oldRelease = read('docs/embedded-browser-b-rejected-candidate-evidence/release.json');
|
|
const beforeDescriptor = path.join(oldRelease.portableRoot, 'runtime/REA-RUNTIME.json');
|
|
const afterDescriptor = path.join(release.portableRoot, 'runtime/REA-RUNTIME.json');
|
|
const oldBytes = fs.readFileSync(beforeDescriptor), newBytes = fs.readFileSync(afterDescriptor);
|
|
assert.equal(hash(oldBytes), differences[0].before.sha256); assert.equal(hash(newBytes), differences[0].after.sha256);
|
|
const oldValue = JSON.parse(oldBytes), newValue = JSON.parse(newBytes);
|
|
assert.match(oldValue.builtAt, /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/); assert.match(newValue.builtAt, /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/);
|
|
assert.notEqual(oldValue.builtAt, newValue.builtAt);
|
|
assert.equal(oldBytes.toString('utf8').split(oldValue.builtAt).length, 2);
|
|
assert.equal(oldBytes.toString('utf8').replace(oldValue.builtAt, newValue.builtAt), newBytes.toString('utf8'), 'Only exact REA descriptor builtAt bytes may differ');
|
|
const result = { success: true, files: current.length, bytes: current.reduce((total, row) => total + row.bytes, 0),
|
|
beforeManifestSha256: hash(fs.readFileSync(beforeFile)), afterManifestSha256: hash(fs.readFileSync(afterFile)),
|
|
exactFiles: current.length - 1, onlyDescriptorDifference: { path: 'runtime/REA-RUNTIME.json', field: 'builtAt', before: oldValue.builtAt, after: newValue.builtAt, beforeSha256: hash(oldBytes), afterSha256: hash(newBytes) },
|
|
scope: 'B and C validated portable manifests declare identical runtime/vendor, compiled, script, asset, example, benchmark, research and license files except the exact builtAt timestamp bytes of the REA descriptor. All other descriptor bytes, including every dependency hash, are identical. This supplements input/UI binding, not B source failure. Changed milestone documents/evidence are outside the comparison.' };
|
|
fs.writeFileSync('.qa/embedded-browser-d-vendor-runtime-binding.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify(result));
|