102 lines
9.2 KiB
JavaScript
102 lines
9.2 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
const digest = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
const root = path.resolve('docs/release-efficiency-1.23-evidence');
|
|
assert.equal(fs.existsSync(root), false, 'An evidence seal is immutable.');
|
|
const release = read('releases/latest.json'), source = read('.qa/source-package-validation.json');
|
|
const archives = read('.qa/archives-validation.json'), portable = read('.qa/release-validation.json');
|
|
const installed = read(read('.qa/desktop-install-location.json').result);
|
|
const formal = read('.qa/release-efficiency-formal-final.json'), view = read('.qa/release-efficiency-formal-view/result.json');
|
|
const native = read('.qa/release-efficiency-native-result.json');
|
|
for (const proof of [source, archives, portable, installed, formal, view, native]) assert.equal(proof.success, true);
|
|
assert.equal(release.documentation.sourceCommit, '93e8bc27c4dee22a3b0c99a34c81f27fe6178c34');
|
|
const binding = read('.qa/release-efficiency-candidate-binding.json'); assert.equal(binding.success, true);
|
|
assert.equal(portable.appRoot, release.portableRoot); assert.equal(binding.finalSource, release.portableRoot); assert.equal(installed.packagedSource, binding.originalSource);
|
|
assert.equal(path.basename(source.sourceRoot), path.basename(release.sourceRoot)); assert.equal(source.version, '1.23.0');
|
|
assert.equal(formal.version, '1.23.0'); assert.equal(formal.pid, 36552); assert.equal(formal.inspectorClosed, true);
|
|
assert.equal(source.tests.tests, source.tests.pass); assert.equal(source.tests.fail, 0);
|
|
fs.mkdirSync(root); const entries = [], copied = new Map(), destinations = new Map();
|
|
function add(file, relative, expectedSha256 = null) {
|
|
const absolute = path.resolve(file); if (copied.has(absolute)) return;
|
|
assert.equal(fs.lstatSync(absolute).isFile(), true);
|
|
const bytes = fs.readFileSync(absolute), sha256 = digest(bytes);
|
|
if (expectedSha256) assert.equal(sha256, expectedSha256, absolute);
|
|
assert.ok(!destinations.has(relative), 'Evidence destination collision: ' + relative);
|
|
const destination = path.resolve(root, relative); assert.ok(destination.startsWith(root + path.sep));
|
|
fs.mkdirSync(path.dirname(destination), { recursive: true }); fs.writeFileSync(destination, bytes, { flag: 'wx' });
|
|
assert.ok(fs.readFileSync(destination).equals(bytes));
|
|
if (file.endsWith('.json')) JSON.parse(bytes.toString('utf8').replace(/^\uFEFF/, ''));
|
|
copied.set(absolute, relative); destinations.set(relative, absolute);
|
|
entries.push({ path: relative.replaceAll('\\', '/'), original: absolute, bytes: bytes.length, sha256 });
|
|
}
|
|
// Only this stage's explicitly named public receipts, measurement data and logs.
|
|
// Raw original state payloads and SQLite backups are never included.
|
|
for (const entry of fs.readdirSync('.qa', { withFileTypes: true })) {
|
|
if (!entry.isFile() || !entry.name.startsWith('release-efficiency-') || /private|\.sqlite/.test(entry.name)
|
|
|| !/\.(json|log|tap|png)$/.test(entry.name)) continue;
|
|
add(path.join('.qa', entry.name), 'local/' + entry.name);
|
|
}
|
|
for (const file of ['.qa/archives-validation.json', '.qa/source-package-validation.json', '.qa/release-validation.json',
|
|
'.qa/release-efficiency-formal-view/result.json', '.qa/release-efficiency-formal-view/cua-actions.json', '.qa/release-efficiency-formal-view/cua-receipt-assertion-failure.json', '.qa/desktop-f-state.mjs', '.qa/release-efficiency-formal.mjs',
|
|
'.qa/release-efficiency-formal-view.mjs', '.qa/release-efficiency-seal.mjs', '.qa/release-efficiency-source-continuation.mjs',
|
|
'.qa/release-efficiency-candidate-binding.mjs', '.qa/release-efficiency-identity.mjs', 'releases/latest.json']) {
|
|
add(file, 'receipts/' + path.basename(file));
|
|
}
|
|
for (const log of source.logs) add(log.path, 'source/' + path.basename(log.path), log.sha256);
|
|
for (const log of source.inheritedLogs ?? []) add(log.path, 'inherited-source/' + path.basename(log.path), log.sha256);
|
|
add(path.join(source.directory, 'inputs.json'), 'source/inputs.json');
|
|
add(path.join(source.directory, 'test-plan.json'), 'source/test-plan.json');
|
|
const roots = [
|
|
'.qa/desktop-install-dd2a95ff-6660-4b00-bec4-08a9053bac85',
|
|
'.qa/desktop-install-12a736b3-8ed3-4725-8435-030ff598659b',
|
|
installed.root,
|
|
];
|
|
for (const directory of roots) {
|
|
if (!fs.existsSync(directory)) continue;
|
|
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
if (entry.isFile() && /\.(json|log|txt|iss)$/.test(entry.name)) add(path.join(directory, entry.name), 'install/' + path.basename(directory) + '/' + entry.name);
|
|
}
|
|
}
|
|
const allowed = [path.resolve('.qa'), path.join(source.sourceRoot, '.qa'), ...(source.originalSourceRoot ? [path.join(source.originalSourceRoot, '.qa')] : [])];
|
|
function gatherImages(value) {
|
|
if (typeof value === 'string' && /\.png$/i.test(value) && path.isAbsolute(value) && allowed.some(directory => path.resolve(value).startsWith(directory + path.sep)) && fs.existsSync(value)) {
|
|
const hash = digest(fs.readFileSync(value)); add(value, 'screens/' + hash.slice(0, 16) + '-' + path.basename(value));
|
|
} else if (Array.isArray(value)) value.forEach(gatherImages);
|
|
else if (value && typeof value === 'object') Object.values(value).forEach(gatherImages);
|
|
}
|
|
gatherImages(source); gatherImages(view); gatherImages(native);
|
|
const sourceRoots = [source.sourceRoot, source.originalSourceRoot].filter(Boolean);
|
|
// Preserve all attempts made by the independent frozen source orchestrator.
|
|
for (const sourceDirectory of sourceRoots) for (const entry of fs.readdirSync(path.join(sourceDirectory, '.qa'), { withFileTypes: true })) {
|
|
if (!entry.isDirectory() || !/^(package-validation-|package-continuation-)/.test(entry.name)) continue;
|
|
const directory = path.join(sourceDirectory, '.qa', entry.name);
|
|
for (const file of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
if (file.isFile() && /\.(json|log|tap)$/.test(file.name)) add(path.join(directory, file.name), 'source-attempts/' + entry.name + '/' + file.name);
|
|
}
|
|
}
|
|
const operation = formal.operation;
|
|
add(operation.progressFile ?? path.join(formal.pointer ? path.dirname(path.dirname(formal.candidate)) : '', '.installation', 'progress-' + operation.id + '.json'), 'formal/original-progress.json');
|
|
if (operation.detail?.receiptFile) add(operation.detail.receiptFile, 'formal/original-operation-receipt.json');
|
|
const privateFiles = ['before', 'after-install', 'after-final'].map(name => '.qa/release-efficiency-formal-private-' + name + '.json');
|
|
const privateReceipts = privateFiles.map(file => { const bytes = fs.readFileSync(file); return { file, bytes: bytes.length, sha256: digest(bytes), committed: false }; });
|
|
const privateDestination = path.join(root, 'formal/private-state-receipts.json'); fs.mkdirSync(path.dirname(privateDestination), { recursive: true });
|
|
fs.writeFileSync(privateDestination, JSON.stringify({ scope: 'Original full state remains private and local; only raw byte count and SHA are committed.', files: privateReceipts }, null, 2) + '\n', { flag: 'wx' });
|
|
const receiptBytes = fs.readFileSync(privateDestination); entries.push({ path: 'formal/private-state-receipts.json', bytes: receiptBytes.length, sha256: digest(receiptBytes), generated: true });
|
|
entries.sort((a, b) => a.path.localeCompare(b.path));
|
|
const manifest = { schema: 1, version: '1.23.0', sealedAt: new Date().toISOString(), sourceCommit: release.documentation.sourceCommit,
|
|
implementationCommit: 'befae3313dc35279f94efb7850640d0ebf1d4756',
|
|
scope: 'Lean runtime/evidence distribution, original update stages and counters, exact final-source/archives/portable/full-install lifecycle, retained original formal host and basic web/native user flows.',
|
|
originalFailures: 'Development failures and candidate A remain original failures. native-before.png is the original occluded-window capture and is not accepted native-window evidence; native-before-raised.png is the valid recapture.',
|
|
sourceExecution: source.execution, sourceOriginalOverallSuccess: source.originalOverallSuccess, sourceChangedInputs: source.changedInputs,
|
|
lifecycleAttribution: binding.kind,
|
|
validation: { sourceTests: source.tests, fullInstallGroups: installed.results.length, formalWebGroups: view.results.length, retained: formal.retained, counts: formal.counts },
|
|
limitations: 'No real configured-model request, new iPhone flow, new engine coverage or autonomous engineering gain is inferred. Measurement rounds are single Windows observations with uncontrolled filesystem/cache state.',
|
|
originalByteHandling: '-text evidence attributes preserve raw bytes. Paths identify original sources; copied drivers retain imports for their original .qa location. Manifest excludes itself.',
|
|
realModelRequests: 0, files: entries.length, bytes: entries.reduce((sum, entry) => sum + entry.bytes, 0), entries };
|
|
fs.writeFileSync(path.join(root, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n', { flag: 'wx' });
|
|
for (const entry of entries) { const bytes = fs.readFileSync(path.join(root, entry.path)); assert.equal(bytes.length, entry.bytes); assert.equal(digest(bytes), entry.sha256); }
|
|
console.log(JSON.stringify({ success: true, root, files: entries.length, bytes: manifest.bytes, manifestSha256: digest(fs.readFileSync(path.join(root, 'manifest.json'))) }));
|