Files
Agent-Workbench/docs/delivery-reliability-g-evidence/drivers/efficiency-g-seal.mjs
T

76 lines
6.5 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
const base = path.resolve('.qa/efficiency-fixes-g');
const destination = path.resolve('docs/delivery-reliability-g-evidence');
assert.equal(fs.existsSync(destination), false, 'Preserve the original sealed evidence.');
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
const release = read('releases/latest.json');
const sourceCommit = release.documentation.sourceCommit;
assert.equal(execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(), sourceCommit);
for (const name of ['install', 'final']) assert.equal(read(path.join(base, 'formal', name + '.json')).success, true);
const installation = read('.qa/desktop-install-location.json');
const install = read(installation.result); assert.equal(install.success, true); assert.equal(install.version, '1.24.1');
const rebuild = read(path.join(base, 'rebuild-final-location.json'));
assert.equal(read(rebuild.output).success, true);
const copies = [];
function copy(source, relative) { assert.ok(fs.statSync(source).isFile()); copies.push({ source: path.resolve(source), path: relative.replaceAll('\\', '/') }); }
function folder(source, relative) { for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
const next = path.join(source, entry.name), target = path.posix.join(relative, entry.name);
if (entry.isDirectory()) folder(next, target); else copy(next, target);
} }
for (const entry of fs.readdirSync(base, { withFileTypes: true })) if (entry.isFile() && /\.(?:log|tap|json)$/.test(entry.name)) copy(path.join(base, entry.name), 'development/' + entry.name);
copy(path.join(base, 'frozen-regression.tap'), 'checks/frozen-regression.tap');
copy('docs/delivery-reliability-batch-ui-validation.json', 'ui/batch/result.json');
for (const file of read('docs/delivery-reliability-batch-ui-validation.json').screenshots) copy(file, 'ui/batch/' + path.basename(file));
for (const [source, target] of [['context-before-final', 'before'], ['context-release', 'final']]) {
for (const name of ['result.json', ...[7,8,9,10,11,12].map(index => 'request-' + index + '.json')]) copy(path.join(base, source, name), 'context/' + target + '/' + name);
}
folder(path.join(base, 'ui/source-final'), 'ui/source');
folder(path.join(base, 'ui/portable-final'), 'ui/portable');
folder(path.join(base, 'rejected-first'), 'development/rejected-first');
for (const attempt of ['source', 'source-b', 'portable', 'portable-b', 'portable-c']) if (fs.existsSync(path.join(base, 'ui', attempt))) {
for (const file of fs.readdirSync(path.join(base, 'ui', attempt))) if (/\.(?:json|png|txt)$/.test(file)) copy(path.join(base, 'ui', attempt, file), 'development/ui-' + attempt + '/' + file);
}
copy('releases/latest.json', 'release/latest.json');
copy('.qa/archives-validation.json', 'release/archives-validation.json');
copy('.qa/release-validation.json', 'release/portable-validation.json');
copy(rebuild.output, 'release/rebuild.json');
for (const item of read(rebuild.output).logs) copy(item.file, 'release/rebuild-' + item.name + '.log');
copy(installation.result, 'release/desktop-install.json');
for (const entry of fs.readdirSync(installation.root, { withFileTypes: true })) if (entry.isFile() && /\.(?:log|txt|json)$/.test(entry.name)) copy(path.join(installation.root, entry.name), 'release/installation/' + entry.name);
for (const item of install.installedUI?.proofs ?? []) {
const label = item.script.replace(/\.mjs$/, ''), proofRoot = item.proof.directory ?? item.proof.root;
copy(path.join(proofRoot, 'result.json'), 'ui/installed/' + label + '/result.json');
for (const shot of item.proof.screenshots ?? []) {
const file = typeof shot === 'string' ? shot : shot.file;
copy(file, 'ui/installed/' + label + '/' + path.basename(file));
}
}
for (const name of ['before.json', 'install.json', 'final.json', 'release.json', 'pointer-before.json', 'installer-exit.json', 'installer.log', 'installer-process.log']) copy(path.join(base, 'formal', name), 'formal/' + name);
if (fs.existsSync(path.join(base, 'formal/native'))) folder(path.join(base, 'formal/native'), 'formal/native');
for (const file of ['.qa/efficiency-g-install.mjs', '.qa/desktop-f-state.mjs', '.qa/efficiency-g-seal.mjs', '.qa/efficiency-g-index-audit.mjs']) copy(file, 'drivers/' + path.basename(file));
for (const item of read(path.join(base, 'product-freeze.json')).files) {
const raw = fs.readFileSync(item.path); assert.equal(raw.length, item.bytes); assert.equal(sha(raw), item.sha256);
copy(item.path, 'source-bytes/' + item.path);
}
const unique = new Set();
for (const item of copies) { assert.ok(!unique.has(item.path), item.path); unique.add(item.path); assert.ok(path.resolve(destination, item.path).startsWith(destination + path.sep)); }
fs.mkdirSync(destination);
const entries = copies.map(item => {
const bytes = fs.readFileSync(item.source), target = path.join(destination, item.path);
fs.mkdirSync(path.dirname(target), { recursive: true }); fs.writeFileSync(target, bytes, { flag: 'wx' });
return { path: item.path, bytes: bytes.length, sha256: sha(bytes), origin: item.source };
});
const manifest = { schemaVersion: 1, version: '1.24.1', createdAt: new Date().toISOString(), sourceCommit,
originalEManifestSha256: sha(fs.readFileSync('docs/live-original-purge-e-evidence/manifest.json')),
originalFManifestSha256: sha(fs.readFileSync('docs/original-purge-release-f-evidence/manifest.json')),
entries, checks: { regression: 'checks/frozen-regression.tap', sourceUI: 'ui/source/result.json', portableUI: 'ui/portable/result.json', release: 'release/latest.json', rebuild: 'release/rebuild.json', archives: 'release/archives-validation.json', portable: 'release/portable-validation.json', installer: 'release/desktop-install.json', formalInstall: 'formal/install.json', formalFinal: 'formal/final.json' },
scope: 'Original development failures plus final source/portable/UI/rebuild/installation receipts. No new real-model requests; prior E/Purge failures remain unchanged. Private snapshot rows and model-center object are excluded.' };
fs.writeFileSync(path.join(destination, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n', { flag: 'wx' });
console.log(JSON.stringify({ success: true, files: entries.length, bytes: entries.reduce((total, item) => total + item.bytes, 0), sourceCommit, manifestSha256: sha(fs.readFileSync(path.join(destination, 'manifest.json'))) }));