33 lines
3.6 KiB
JavaScript
33 lines
3.6 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 directory = 'docs/project-cache-e-evidence'; assert.equal(fs.existsSync(directory), false); fs.mkdirSync(directory);
|
|
fs.writeFileSync(path.join(directory, '.gitattributes'), '* -text -whitespace\n', { flag: 'wx' });
|
|
const files = [], seen = new Set();
|
|
function copy(source, name) {
|
|
if (seen.has(source)) return; seen.add(source); const bytes = fs.readFileSync(source), file = name ?? String(files.length + 1).padStart(3, '0') + '-' + path.basename(source).replace(/\.log$/, '-log.txt');
|
|
assert.doesNotMatch(source, /\.(?:sqlite|db|pem|key|pfx|p12)$/); fs.writeFileSync(path.join(directory, file), bytes, { flag: 'wx' }); files.push({ source, file, bytes: bytes.length, sha256: hash(bytes) });
|
|
}
|
|
const seriesFile = '.qa/project-cache-e-performance-series.json', series = JSON.parse(fs.readFileSync(seriesFile)); assert.equal(series.success, true);
|
|
copy(seriesFile, 'performance-original.json');
|
|
for (const run of series.runs) { copy(run.log); copy(path.join(run.location, 'result.json')); for (const language of ['node', 'react', 'python']) copy(path.join(run.location, language + '-inputs.json')); }
|
|
// Original summary used updatedFiles-1 for the legacy parser count, yielding
|
|
// -1 for warm and zero for a one-source update. Preserve it; correct only this
|
|
// derived count from the known 72 code files and actual updated-file ledger.
|
|
const summaries = series.summaries.map(value => value.phase !== 'baseline' ? value : { ...value, parsedFiles: [...new Set(series.runs.filter(run => run.phase === value.phase)
|
|
.flatMap(run => run.result.rows.filter(row => row.language === value.language && (value.case === 'warm' ? row.case.startsWith('warm-') : row.case === value.case)))
|
|
.map(row => Math.min(row.coverage.astFiles + row.coverage.pythonCandidateFiles, row.refresh.updatedFiles)))] });
|
|
fs.writeFileSync('.qa/project-cache-e-performance-corrected.json', JSON.stringify({ ...series, summaries, correction: 'Only derived legacy parsed-file counts corrected from actual update ledger and known code-file count. Original elapsed times, source reads and reports unchanged; original receipt preserved.' }, null, 2) + '\n', { flag: 'wx' });
|
|
copy('.qa/project-cache-e-performance-corrected.json', 'performance-corrected.json');
|
|
const location = JSON.parse(fs.readFileSync('.qa/project-cache-engineering-location.json')), engineering = JSON.parse(fs.readFileSync(location.result)); assert.equal(engineering.success, true);
|
|
copy(location.result, 'engineering.json'); copy('.qa/project-cache-e-first.log', 'engineering-log.txt');
|
|
for (const language of ['node', 'react', 'python']) {
|
|
const root = path.join(location.directory, language); for (const entry of fs.readdirSync(root, { withFileTypes: true })) if (entry.isFile()) copy(path.join(root, entry.name));
|
|
const artifacts = path.join(root, 'original-fixture', 'data', 'artifacts');
|
|
const walk = folder => { if (!fs.existsSync(folder)) return; for (const entry of fs.readdirSync(folder, { withFileTypes: true })) { const source = path.join(folder, entry.name); if (entry.isDirectory()) walk(source); else if (/\.(json|txt|md)$/.test(entry.name)) copy(source); } }; walk(artifacts);
|
|
}
|
|
fs.writeFileSync(path.join(directory, 'manifest.json'), JSON.stringify({ success: true, stage: '1.19 E', files, realModelRequests: 0 }, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify({ success: true, files: files.length, engineeringCases: engineering.cases.length, summaries }));
|