Files
Agent-Workbench/docs/embedded-browser-b-rejected-candidate-evidence/review/sealer.mjs
T

61 lines
5.3 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
const read = file => JSON.parse(fs.readFileSync(file));
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
const prefix = '.qa/embedded-browser-b-', root = 'docs/embedded-browser-b-rejected-candidate-evidence';
assert.equal(fs.existsSync(root), false);
const independent = read(prefix + 'independent-result.json'), source = read(prefix + 'source-original-result.json');
assert.equal(independent.success, false); assert.equal(source.success, false);
assert.equal(source.stage, 'full source tests batch 10/11');
assert.equal(read(prefix + 'promotion-result.json').success, false);
assert.equal(read(prefix + 'finalization-result.json').success, false);
const files = [], pending = [];
function copy(file, target) {
if (files.some(row => row.path === target)) return;
assert.ok(!/\.sqlite(?:-|$)/i.test(file));
const bytes = fs.readFileSync(file);
files.push({ path: target, source: file, bytes: bytes.length, sha256: hash(bytes) });
pending.push({ path: path.join(root, target), bytes });
}
for (const name of ['code-baseline','independent-result','source-original-result','source-receipt','archives-original-result','source-short-path','promotion-result','finalization-result','all-ui-original-result','legacy-report-retention','driver-path-review','http-diagnostic-result','http-diagnostic-state']) copy(prefix + name + '.json','receipts/' + name + '.json');
for (const name of ['independent-console','all-ui','source','promotion-console','finalization-console','package','archives','http-diagnostic-console']) copy(prefix + name + '.log','pipeline/' + name + '.log');
copy(prefix + 'http-diagnostic.tap','diagnostic/http.tap');
copy(path.join(source.sourceRoot, '.qa/worker-http-observer.mjs'),'diagnostic/observer.mjs');
copy(path.join(source.sourceRoot, 'tests/workers-http.test.mjs'),'review/original-workers-http.test.mjs');
copy(prefix + 'diagnose-http.mjs','diagnostic/driver.mjs');
copy('.qa/seal-embedded-browser-b-rejected.mjs','review/sealer.mjs');
for (const row of source.logs) { assert.equal(hash(fs.readFileSync(row.path)), row.sha256); copy(row.path,'source/' + path.basename(row.path)); }
copy(path.join(source.directory, 'test-plan.json'),'source/test-plan.json');
const allUi = read(prefix + 'all-ui-original-result.json'); assert.equal(allUi.success,true); assert.equal(allUi.groups,250);
for (const row of allUi.results) {
const name = path.basename(row.script, '.mjs'), value = read(row.evidence), output = fs.readFileSync(row.log,'utf8');
copy(row.evidence,'all-ui/' + name + '.json'); copy(row.log,'all-ui/' + name + '.log');
const directory = value.directory ?? [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim() ?? value.root;
if (directory && fs.existsSync(path.join(directory,'result.json'))) assert.deepEqual(read(path.join(directory,'result.json')),value);
for (const item of Array.isArray(value.screenshots) ? value.screenshots : []) {
const declared = typeof item === 'string' ? item : item.path ?? item.file ?? item.screenshot;
const file = fs.existsSync(declared) ? declared : path.join(directory,declared);
if (item.sha256 ?? item.screenshotSha256) assert.equal(hash(fs.readFileSync(file)),item.sha256 ?? item.screenshotSha256);
copy(file,'all-ui/' + name + '/' + path.basename(file));
}
}
const release = read('releases/latest.json'); assert.equal(release.installer.version,'1.22.0');
assert.equal(path.basename(release.portableRoot),'Agent-Workbench-1.22.0-win-x64-20261101210804466');
copy('releases/latest.json','release.json'); copy(path.join(release.portableRoot,'MANIFEST.json'),'portable-manifest.json'); copy(path.join(release.sourceRoot,'MANIFEST.json'),'source-manifest.json');
const stats = source.logs.filter(row => /tests-\d+\.tap$/.test(row.path)).map(row => {
const text = fs.readFileSync(row.path,'utf8');
return Object.fromEntries(['tests','pass','fail','cancelled','skipped','todo'].map(key => [key,Number(text.match(new RegExp('^# '+key+' (\\d+)\\s*$','m'))?.[1])]));
});
const tests = Object.fromEntries(['tests','pass','fail','cancelled','skipped','todo'].map(key => [key,stats.reduce((sum,row) => sum+row[key],0)]));
assert.ok(tests.fail >= 1); assert.equal(tests.tests,678);
const result = { schemaVersion:1,version:'1.22.0',kind:'rejected-candidate-B',sourceCommit:independent.codeCommit,sourceOverallSuccess:false,tests,allUiGroups:250,
unexecuted:['tests batch 11','exclusive upgrade tests','post-test desktop and engineering gates','portable acceptance','same-payload install','formal deployment'],
files,bytes:files.reduce((sum,row)=>sum+row.bytes,0),realModelRequests:0,
reason:'Original HTTP worker test timed out while waiting up to 20 seconds for ready. The original fixture was cleaned, so its terminal preparation state is unknown. Independent diagnostic and all original assertions/deadlines remain separately identifiable. No formal phase executed.' };
fs.mkdirSync(root);
for (const item of pending) { fs.mkdirSync(path.dirname(item.path),{recursive:true}); fs.writeFileSync(item.path,item.bytes,{flag:'wx'}); }
fs.writeFileSync(root+'/manifest.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});
console.log(JSON.stringify({success:true,files:files.length,tests,sourceOverallSuccess:false}));