88 lines
8.2 KiB
Plaintext
88 lines
8.2 KiB
Plaintext
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const source = path.resolve('.qa/reliability-1.25.2'), root = path.resolve('docs/reliability-1.25.2-evidence');
|
|
const read = file => JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
|
const sha = data => createHash('sha256').update(data).digest('hex');
|
|
assert.equal(fs.existsSync(root), false, 'Never replace sealed evidence.');
|
|
for (const file of ['preinstall-review.json', 'formal/final.json', 'formal-web/result.json', 'formal-native/result.json']) assert.equal(read(path.join(source, file)).success, true, file);
|
|
const freeze = read(path.join(source, 'release-final/freeze.json')), candidate = read(path.join(source, 'release-final/candidate.json'));
|
|
assert.deepEqual(read('releases/latest.json'), candidate); assert.equal(candidate.documentation.sourceCommit, freeze.sourceCommit);
|
|
fs.mkdirSync(root); const entries = [], originals = new Set();
|
|
const supported = /\.(?:json|jsonl|log|txt|tap|png|jpe?g|md|mjs)$/;
|
|
function copy(file, relative) {
|
|
file = path.resolve(file); if (originals.has(file)) return; originals.add(file);
|
|
const stat = fs.lstatSync(file); assert.equal(stat.isSymbolicLink(), false); assert.equal(stat.isFile(), true);
|
|
const bytes = fs.readFileSync(file); relative = relative.replaceAll('\\', '/');
|
|
if (relative.endsWith('.mjs')) relative += '.txt';
|
|
const target = path.resolve(root, relative); assert.ok(target.startsWith(root + path.sep));
|
|
fs.mkdirSync(path.dirname(target), { recursive: true }); fs.writeFileSync(target, bytes, { flag: 'wx' });
|
|
entries.push({ path: relative, bytes: bytes.length, sha256: sha(bytes), source: file });
|
|
}
|
|
function top(directory, destination) {
|
|
for (const row of fs.readdirSync(directory, { withFileTypes: true })) if (row.isFile() && supported.test(row.name)) copy(path.join(directory, row.name), path.posix.join(destination, row.name));
|
|
}
|
|
function walk(directory, destination) {
|
|
for (const row of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
const file = path.join(directory, row.name), next = path.posix.join(destination, row.name);
|
|
assert.equal(fs.lstatSync(file).isSymbolicLink(), false);
|
|
if (row.isDirectory()) walk(file, next); else copy(file, next);
|
|
}
|
|
}
|
|
function ui(directory, destination) {
|
|
assert.ok(path.resolve(directory).startsWith(path.resolve('.qa') + path.sep)); top(directory, destination);
|
|
for (const folder of ['artifacts', 'snapshots']) if (fs.existsSync(path.join(directory, folder))) walk(path.join(directory, folder), destination + '/' + folder);
|
|
}
|
|
function resultFromLog(file) {
|
|
const lines = fs.readFileSync(file, 'utf8').trim().split(/\r?\n/);
|
|
const rows = lines.flatMap((line, index) => {
|
|
if (!line.startsWith('{')) return [];
|
|
try { return [JSON.parse(line)]; } catch {}
|
|
try { return [JSON.parse(lines.slice(index).join('\n'))]; } catch { return []; }
|
|
});
|
|
const summary = rows.findLast(row => row && (row.root || row.directory || row.output)); assert.ok(summary, file);
|
|
return summary.output ?? path.join(summary.directory ?? summary.root, 'result.json');
|
|
}
|
|
top(source, 'development');
|
|
for (const folder of ['release', 'release-final', 'formal', 'formal-web', 'formal-native']) walk(path.join(source, folder), folder);
|
|
const sourceUI = read(path.join(source, 'source-ui.json'));
|
|
for (const item of sourceUI.results) ui(path.dirname(item.resultFile), 'validation/source-' + item.name);
|
|
for (const name of ['reading-ui', 'release-efficiency-ui', 'source-local-files', 'source-local-files-recheck']) ui(path.dirname(resultFromLog(path.join(source, name + '.log'))), 'validation/' + name);
|
|
const receiptsRoot = path.join(source, 'release-final/receipts');
|
|
for (const file of fs.readdirSync(receiptsRoot).filter(name => name.startsWith('portable-') && name.endsWith('.json') && name !== 'portable-recheck.json')) {
|
|
const receipt = read(path.join(receiptsRoot, file)); assert.equal(receipt.success, true); ui(path.dirname(receipt.resultPath), 'validation/' + receipt.mode);
|
|
}
|
|
const build = read(path.join(receiptsRoot, 'rebuild.json')); top(build.result.root, 'validation/rebuild');
|
|
const portableFirst = path.resolve('.qa/release-8be20a04-fedb-4379-8a3b-435bdd20e391');
|
|
copy(path.join(portableFirst, 'compiled-api-failure.json'), 'validation/portable-first/compiled-api-failure.json');
|
|
copy(path.join(portableFirst, 'artifacts/99/99c30c696d5141b11228aacf953ad35cb68f446ee374b4562862bd03d03dee73.blob'), 'validation/portable-first/original-engine-report.json');
|
|
const portableSecond = path.resolve('.qa/release-bf42f32d-eeac-47aa-8fa5-5167208d9035');
|
|
copy(path.join(portableSecond, 'compiled-api-failure.json'), 'validation/portable-second/compiled-api-failure.json');
|
|
const secondRun = read(path.join(portableSecond, 'compiled-api-failure.json')).sessions.flatMap(session => session.execution.engineRuns ?? [])[0];
|
|
copy(path.join(portableSecond, 'artifacts', secondRun.reportSha256.slice(0,2), secondRun.reportSha256 + '.blob'), 'validation/portable-second/original-engine-report.json');
|
|
copy(path.join(secondRun.directory, 'ready.json'), 'validation/portable-second/late-ready.json');
|
|
for (const folder of ['startup-measure', 'startup-minimal-path', 'startup-exact-layout', 'compiled-startup-diagnostic', 'compiled-startup-detached']) top(path.join(source, folder), 'validation/' + folder);
|
|
const installation = read(path.join(receiptsRoot, 'install.json')); top(installation.result.root, 'validation/install');
|
|
for (const [index, item] of installation.result.installedUI.proofs.entries()) ui(path.dirname(resultFromLog(item.log)), 'validation/installed-' + index + '-' + path.basename(item.log, '.log'));
|
|
for (const row of freeze.inputs) { assert.equal(sha(fs.readFileSync(row.path)), row.sha256); copy(row.path, 'source-bytes/' + row.path); }
|
|
for (const row of freeze.compiled) { const file = path.join(candidate.portableRoot, row.path); assert.equal(sha(fs.readFileSync(file)), row.sha256); copy(file, 'compiled/' + row.path); }
|
|
for (const kind of ['portable', 'source']) copy(path.join(candidate[kind + 'Root'], 'MANIFEST.json'), kind + '-manifest.json');
|
|
const formal = read(path.join(source, 'formal/final.json'));
|
|
const identity = { version: '1.25.2', sourceCommit: freeze.sourceCommit, candidate: path.basename(candidate.portableRoot),
|
|
installer: candidate.installer, archives: Object.fromEntries(['portable', 'source', 'evidence'].map(kind => [kind, candidate[kind]])),
|
|
portableManifestSha256: sha(fs.readFileSync(path.join(candidate.portableRoot, 'MANIFEST.json'))),
|
|
sourceManifestSha256: sha(fs.readFileSync(path.join(candidate.sourceRoot, 'MANIFEST.json'))),
|
|
formalPid: formal.pid, runtimeRoot: formal.runtimeRoot, retention: formal.retention,
|
|
inputs: freeze.inputs.length, independentInputs: build.result.inputCount, compiled: freeze.compiled.length, fullTests: 899,
|
|
fullSuiteResult: read(path.join(source, 'full-suite-review.json')).wholeSuite, exactSupplementPassed: 1, wholeSuiteAllPass: false,
|
|
isolatedInstallGroups: 12, installedUISuites: 10, installedUIGroups: 75, realModelRequests: 0,
|
|
unresolved: ['real autonomous delivery', 'intermittent network root cause', 'real outlier exclusion boundary benefit', 'original Purge AB/BA', 'concurrent-load startup stability and first-approval timeout root cause'] };
|
|
fs.writeFileSync('docs/reliability-1.25.2-release-identity.json', JSON.stringify(identity, null, 2) + '\n', { flag: 'wx' });
|
|
copy('docs/reliability-1.25.2-release-identity.json', 'release-identity.json');
|
|
entries.sort((a, b) => a.path.localeCompare(b.path));
|
|
const manifest = { schemaVersion: 1, version: '1.25.2', sourceCommit: freeze.sourceCommit, entries, count: entries.length,
|
|
bytes: entries.reduce((sum, row) => sum + row.bytes, 0), scope: 'Original selected development failures and passes, independent immutable release, actual UI/install and retained formal state evidence. No model keys, QA Python environment, node_modules, installer binaries or unrelated project data copied.' };
|
|
fs.writeFileSync(path.join(root, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify({ success: true, count: manifest.count, bytes: manifest.bytes, manifestSha256: sha(fs.readFileSync(path.join(root, 'manifest.json'))), sourceCommit: freeze.sourceCommit }));
|