release: deliver 1.22 embedded browser and preserved-state acceptance
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
const root = 'docs/embedded-browser-b-rejected-candidate-evidence';
|
||||
const manifest = JSON.parse(fs.readFileSync(root + '/manifest.json'));
|
||||
const files = ['manifest.json', ...manifest.files.map(row => row.path)].map(file => path.posix.join(root, file));
|
||||
for (let index = 0; index < files.length; index += 16) {
|
||||
const batch = files.slice(index, index + 16);
|
||||
const output = execFileSync('git', ['cat-file', '--batch'], { input: batch.map(file => 'HEAD:' + file).join('\n') + '\n', windowsHide: true, maxBuffer: 64 * 1024 * 1024 });
|
||||
let position = 0;
|
||||
for (const file of batch) {
|
||||
const end = output.indexOf(10, position), header = output.subarray(position, end).toString('utf8');
|
||||
assert.match(header, /^[a-f0-9]+ blob \d+$/, file);
|
||||
const length = Number(header.split(' ').at(-1));
|
||||
assert.deepEqual(output.subarray(end + 1, end + 1 + length), fs.readFileSync(file), file);
|
||||
position = end + 2 + length;
|
||||
}
|
||||
assert.equal(position, output.length);
|
||||
}
|
||||
const result = { success: true, exactBlobs: files.length, manifestSha256: createHash('sha256').update(fs.readFileSync(root + '/manifest.json')).digest('hex'), scope: 'Every original rejected B evidence file and manifest is present in local Git with exact bytes, including ignored logs. Original source overall result remains failed.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-c-b-git-evidence.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,23 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
const read = file => JSON.parse(fs.readFileSync(file));
|
||||
const baseline = read('.qa/embedded-browser-d-code-baseline.json');
|
||||
const originalRoot = '.qa/embedded-browser-c84756dc-2f5a-4517-8ad0-accd26f68424';
|
||||
const original = read(originalRoot + '/inputs.json');
|
||||
const runtime = row => /^(?:src|dist-client|dist-server|dist-desktop)\//.test(row.path);
|
||||
const historical = original.inputs.filter(runtime), frozen = [...baseline.inputs, ...baseline.builds].filter(runtime);
|
||||
const byPath = new Map(historical.map(row => [row.path, row]));
|
||||
const differences = frozen.flatMap(row => {
|
||||
const before = byPath.get(row.path);
|
||||
return before?.sha256 === row.sha256 && before?.bytes === row.bytes ? [] : [{ path: row.path, before: before ?? null, frozen: row }];
|
||||
});
|
||||
for (const row of historical) if (!frozen.some(item => item.path === row.path)) differences.push({ path: row.path, reason: 'Missing from frozen set' });
|
||||
const screenshots = ['windows-native-desktop.jpg', 'windows-native-mobile.jpg'].map(file => {
|
||||
const bytes = fs.readFileSync(originalRoot + '/' + file); return { path: originalRoot + '/' + file, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
|
||||
});
|
||||
const result = { success: differences.length === 0, sourceCommit: baseline.codeCommit, originalInputs: originalRoot + '/inputs.json', originalVerifierState: original.verifierSourceState, exactRuntimeFiles: frozen.length, screenshots, differences,
|
||||
scope: 'Bind already observed Windows native complete-window development screenshots to exact original source and compiled runtime bytes of the frozen release; verifier scripts and deployment remain separate checks.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-native-input-binding.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
assert.equal(differences.length, 0, JSON.stringify(differences));
|
||||
console.log(JSON.stringify({ success: result.success, exactRuntimeFiles: result.exactRuntimeFiles, screenshots: screenshots.length, sourceCommit: result.sourceCommit }));
|
||||
@@ -0,0 +1,42 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { validateInstalledVersion } from '../src/core/desktop/install-manager.mjs';
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
const read = file => JSON.parse(fs.readFileSync(file));
|
||||
const release = read('releases/latest.json'), commit = read('.qa/embedded-browser-d-code-baseline.json').codeCommit;
|
||||
assert.equal(release.installer.version, '1.22.0'); assert.equal(release.installer.qaFixture, null);
|
||||
assert.equal(execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim(), commit);
|
||||
assert.equal(execFileSync('git', ['status', '--porcelain', '--', 'src', 'scripts', 'tests', 'package.json', 'package-lock.json'], { encoding: 'utf8', windowsHide: true }).trim(), '');
|
||||
const paths = execFileSync('git', ['ls-tree', '-r', '--name-only', commit, '--', 'src', 'scripts', 'tests', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', 'mobile.html'], { encoding: 'utf8', windowsHide: true }).trim().split('\n');
|
||||
const blobOutput = execFileSync('git', ['cat-file', '--batch'], { input: paths.map(file => commit + ':' + file).join('\n') + '\n', windowsHide: true, maxBuffer: 64 * 1024 * 1024 });
|
||||
let position = 0; const inputs = [];
|
||||
for (const file of paths) {
|
||||
const end = blobOutput.indexOf(10, position), header = blobOutput.subarray(position, end).toString(); assert.match(header, /^[a-f0-9]+ blob \d+$/);
|
||||
const length = Number(header.split(' ').at(-1)), committed = blobOutput.subarray(end + 1, end + 1 + length); position = end + 2 + length;
|
||||
const bytes = fs.readFileSync(path.join(release.sourceRoot, file));
|
||||
const equal = bytes.equals(committed), normalized = bytes.toString('utf8').replaceAll('\r\n', '\n');
|
||||
if (!equal) assert.equal(normalized, committed.toString('utf8'), 'Only CRLF normalization allowed: ' + file);
|
||||
assert.deepEqual(bytes, fs.readFileSync(file), 'Source candidate matches frozen input: ' + file);
|
||||
inputs.push({ path: file, bytes: bytes.length, sha256: hash(bytes), gitSha256: hash(committed), ...(equal ? {} : { normalization: 'Complete CRLF to LF equality' }) });
|
||||
}
|
||||
assert.equal(position, blobOutput.length);
|
||||
const compiled = [];
|
||||
for (const directory of ['dist-client', 'dist-server', 'dist-desktop']) {
|
||||
const walk = relative => { for (const entry of fs.readdirSync(path.join(directory, relative), { withFileTypes: true })) {
|
||||
const file = path.posix.join(directory, relative, entry.name); if (entry.isDirectory()) walk(path.posix.join(relative, entry.name)); else {
|
||||
const bytes = fs.readFileSync(file); assert.deepEqual(bytes, fs.readFileSync(path.join(release.portableRoot, file))); compiled.push({ path: file, bytes: bytes.length, sha256: hash(bytes) });
|
||||
}
|
||||
} }; walk('');
|
||||
}
|
||||
const identity = validateInstalledVersion(release.portableRoot), sourceManifest = read(path.join(release.sourceRoot, 'MANIFEST.json'));
|
||||
assert.equal(sourceManifest.version, '1.22.0');
|
||||
for (const artifact of [release.portable, release.source, release.installer]) { assert.equal(fs.statSync(artifact.path).size, artifact.bytes); assert.equal(hash(fs.readFileSync(artifact.path)), artifact.sha256); }
|
||||
const result = { success: true, version: '1.22.0', sourceCommit: commit, portableRoot: release.portableRoot, sourceRoot: release.sourceRoot,
|
||||
portableIdentity: identity.identitySha256, portableManifestSha256: identity.manifestSha256, sourceManifestSha256: hash(fs.readFileSync(path.join(release.sourceRoot, 'MANIFEST.json'))),
|
||||
setupSha256: release.installer.sha256, portable: release.portable, source: release.source, installer: release.installer, inputs, compiled,
|
||||
scope: 'Every committed source/test/script/build input bound to frozen Git blobs with full CRLF-only normalization; all current compiled files identical; portable full manifest validated; source/archive/installer identity checked. No model calls.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-package-binding.json', JSON.stringify(result, null, 2), { flag: 'wx' });
|
||||
console.log(JSON.stringify({ success: true, inputs: inputs.length, compiled: compiled.length, portableRoot: release.portableRoot }));
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
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 read = file => JSON.parse(fs.readFileSync(file));
|
||||
const beforeFile = 'docs/embedded-browser-b-rejected-candidate-evidence/portable-manifest.json';
|
||||
const release = read('releases/latest.json'), afterFile = path.join(release.portableRoot, 'MANIFEST.json');
|
||||
const before = read(beforeFile), after = read(afterFile);
|
||||
assert.equal(before.version, '1.22.0'); assert.equal(after.version, before.version);
|
||||
assert.equal(read('.qa/embedded-browser-c-archives-original-result.json').success, true);
|
||||
const retained = row => /^(?:dist-client|dist-server|dist-desktop|runtime|desktop|scripts|public|examples|benchmarks|research|licenses)\//.test(row.path)
|
||||
|| ['package.json', 'THIRD_PARTY_NOTICES.txt'].includes(row.path);
|
||||
const previous = before.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
||||
const current = after.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
||||
assert.deepEqual(current, previous, 'C vendor/runtime payload differs from B');
|
||||
const result = { success: true, files: current.length, bytes: current.reduce((total, row) => total + row.bytes, 0),
|
||||
beforeManifestSha256: hash(fs.readFileSync(beforeFile)), afterManifestSha256: hash(fs.readFileSync(afterFile)),
|
||||
scope: 'B and C validated portable manifests declare identical complete runtime/vendor, compiled, script, asset, example, benchmark, research and license payloads. This supplements the original input/UI binding; it does not reclassify B source failure. Changed milestone documents and evidence are outside this runtime comparison.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-c-vendor-runtime-binding.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,42 @@
|
||||
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 read = file => JSON.parse(fs.readFileSync(file));
|
||||
const beforeFile = 'docs/embedded-browser-b-rejected-candidate-evidence/portable-manifest.json';
|
||||
const release = read('releases/latest.json'), afterFile = path.join(release.portableRoot, 'MANIFEST.json');
|
||||
const before = read(beforeFile), after = read(afterFile);
|
||||
assert.equal(before.version, '1.22.0'); assert.equal(after.version, before.version);
|
||||
assert.equal(read('.qa/embedded-browser-d-archives-original-result.json').success, true);
|
||||
const retained = row => /^(?:dist-client|dist-server|dist-desktop|runtime|desktop|scripts|public|examples|benchmarks|research|licenses)\//.test(row.path)
|
||||
|| ['package.json', 'THIRD_PARTY_NOTICES.txt'].includes(row.path);
|
||||
const previous = before.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
||||
const current = after.files.filter(retained).sort((a, b) => a.path.localeCompare(b.path));
|
||||
const differences = current.filter(row => {
|
||||
const old = previous.find(value => value.path === row.path);
|
||||
return !old || old.sha256 !== row.sha256 || old.bytes !== row.bytes;
|
||||
}).map(row => ({ before: previous.find(old => old.path === row.path), after: row }));
|
||||
assert.equal(current.length, previous.length);
|
||||
fs.writeFileSync('.qa/embedded-browser-d-vendor-runtime-initial-review.json', JSON.stringify({
|
||||
originalExactComparisonPassed: false, inheritedInitialComparison: true, differences,
|
||||
originalVerifierSha256: hash(fs.readFileSync('.qa/embedded-browser-c-bind-vendor-runtime.before-timestamp-review.mjs')),
|
||||
scope: 'Additional verifier first rejected raw manifests because the REA descriptor differs. Original B source failure and C independent suite are unaffected. Narrow field analysis follows; no formal phase ran.'
|
||||
}, null, 2) + '\n', { flag: 'wx' });
|
||||
assert.deepEqual(differences.map(row => row.after.path), ['runtime/REA-RUNTIME.json']);
|
||||
const oldRelease = read('docs/embedded-browser-b-rejected-candidate-evidence/release.json');
|
||||
const beforeDescriptor = path.join(oldRelease.portableRoot, 'runtime/REA-RUNTIME.json');
|
||||
const afterDescriptor = path.join(release.portableRoot, 'runtime/REA-RUNTIME.json');
|
||||
const oldBytes = fs.readFileSync(beforeDescriptor), newBytes = fs.readFileSync(afterDescriptor);
|
||||
assert.equal(hash(oldBytes), differences[0].before.sha256); assert.equal(hash(newBytes), differences[0].after.sha256);
|
||||
const oldValue = JSON.parse(oldBytes), newValue = JSON.parse(newBytes);
|
||||
assert.match(oldValue.builtAt, /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/); assert.match(newValue.builtAt, /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/);
|
||||
assert.notEqual(oldValue.builtAt, newValue.builtAt);
|
||||
assert.equal(oldBytes.toString('utf8').split(oldValue.builtAt).length, 2);
|
||||
assert.equal(oldBytes.toString('utf8').replace(oldValue.builtAt, newValue.builtAt), newBytes.toString('utf8'), 'Only exact REA descriptor builtAt bytes may differ');
|
||||
const result = { success: true, files: current.length, bytes: current.reduce((total, row) => total + row.bytes, 0),
|
||||
beforeManifestSha256: hash(fs.readFileSync(beforeFile)), afterManifestSha256: hash(fs.readFileSync(afterFile)),
|
||||
exactFiles: current.length - 1, onlyDescriptorDifference: { path: 'runtime/REA-RUNTIME.json', field: 'builtAt', before: oldValue.builtAt, after: newValue.builtAt, beforeSha256: hash(oldBytes), afterSha256: hash(newBytes) },
|
||||
scope: 'B and C validated portable manifests declare identical runtime/vendor, compiled, script, asset, example, benchmark, research and license files except the exact builtAt timestamp bytes of the REA descriptor. All other descriptor bytes, including every dependency hash, are identical. This supplements input/UI binding, not B source failure. Changed milestone documents/evidence are outside the comparison.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-vendor-runtime-binding.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,13 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
const prefix='.qa/embedded-browser-d-',completed=[];
|
||||
for(const name of ['independent-continuation','promotion','finalization']){
|
||||
const output=prefix+name+'-console.log';assert.equal(fs.existsSync(output),false);const stream=fs.createWriteStream(output,{flags:'wx'});
|
||||
const child=spawn(process.execPath,[prefix+name+'.mjs'],{env:projectEnvironment(),windowsHide:true,stdio:['ignore','pipe','pipe']});
|
||||
child.stdout.on('data',bytes=>{stream.write(bytes);process.stdout.write(bytes);});child.stderr.on('data',bytes=>{stream.write(bytes);process.stderr.write(bytes);});
|
||||
const exitCode=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',resolve);});await new Promise(resolve=>stream.end(resolve));completed.push({name,exitCode,output});
|
||||
if(exitCode!==0){process.exitCode=1;break;}
|
||||
}
|
||||
const success=completed.length===3&&completed.every(row=>row.exitCode===0);fs.writeFileSync(prefix+'continuation-orchestration-result.json',JSON.stringify({success,completed,originalDRejectedAttemptUnchanged:true,requiresDiffReviewLocalCommitAndFinalAudit:true},null,2)+'\n',{flag:'wx'});console.log(JSON.stringify({success,completed}));
|
||||
@@ -0,0 +1,62 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { snapshotPersistentData } from '../src/core/desktop/install-manager.mjs';
|
||||
export const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
export const canonical = value => Array.isArray(value) ? value.map(canonical) : value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, canonical(value[key])])) : value;
|
||||
export const digest = value => hash(JSON.stringify(canonical(value)));
|
||||
export function databaseSnapshot(dataRoot) {
|
||||
const database = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true }); database.exec('BEGIN');
|
||||
try {
|
||||
assert.equal(database.prepare('PRAGMA quick_check').get().quick_check, 'ok');
|
||||
const tables = {};
|
||||
for (const { name, sql } of database.prepare("SELECT name,sql FROM sqlite_schema WHERE type='table' ORDER BY name").all()) {
|
||||
assert.match(name, /^[a-z_]+$/);
|
||||
const rows = database.prepare('SELECT * FROM "' + name + '" ORDER BY rowid').all().filter(row => !(name === 'metadata' && row.key === 'runtimeOwner'));
|
||||
tables[name] = { count: rows.length, schemaSha256: hash(sql), sha256: digest(rows), rows: rows.map((row, index) => ({ id: row.id ?? row.key ?? row.seq ?? index, ...(row.kind ? { kind: row.kind } : {}), sha256: digest(row) })) };
|
||||
}
|
||||
const sessionIds = database.prepare('SELECT id FROM sessions ORDER BY id').all().map(row => row.id);
|
||||
const owner = database.prepare("SELECT value FROM metadata WHERE key='runtimeOwner'").get();
|
||||
return { tables, sessionIds, ownerSha256: owner ? digest(owner) : null, scope: 'Every original table schema and row field hashed, excluding only runtimeOwner lifecycle metadata. No row payload or credential is returned.' };
|
||||
} finally { database.exec('ROLLBACK'); database.close(); }
|
||||
}
|
||||
export async function publicSnapshot(url, dataRoot) {
|
||||
const healthResponse = await fetch(url + '/api/health', { headers: { Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.equal(healthResponse.status, 200);
|
||||
const health = await healthResponse.json(), bootResponse = await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.equal(bootResponse.status, 200);
|
||||
const bootstrap = await bootResponse.json(); const token = bootstrap.token;
|
||||
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': token, Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.ok(response.ok, route + ': HTTP ' + response.status); return response.json(); };
|
||||
const database = databaseSnapshot(dataRoot), exports = [];
|
||||
for (const id of database.sessionIds) {
|
||||
const report = await api('/sessions/' + id + '/export');
|
||||
exports.push({ id, project: digest(report.project), session: digest(report.session), execution: digest(report.execution) });
|
||||
}
|
||||
const center = await api('/model-center');
|
||||
// This is the documented public model-center view; Provider's private map and
|
||||
// API key are never accessed. Only this public object is retained for schema-aware comparison.
|
||||
const modelCenter = structuredClone(center);
|
||||
return { observedAt: new Date().toISOString(), version: health.version, pid: health.pid, runtimeRoot: bootstrap.runtimeRoot,
|
||||
configSha256: digest(bootstrap.config), projectsSha256: digest(bootstrap.projects), sessionsSha256: digest(bootstrap.sessions), modelCenterSha256: digest(modelCenter), modelCenter,
|
||||
projects: bootstrap.projects.length, visibleSessions: bootstrap.sessions.length, hasKey: !!bootstrap.config.hasKey,
|
||||
active: bootstrap.sessions.filter(value => ['running', 'awaiting_approval', 'stopping'].includes(value.status)).map(value => ({ id: value.id, status: value.status })),
|
||||
storage: bootstrap.storage, eventCursor: bootstrap.eventCursor, database, exports, persistent: snapshotPersistentData(dataRoot),
|
||||
scope: 'Read-only public state, every original session export digest, original table/row/schema hashes and every original artifact byte hash. No credential extraction, model probe, execution or mutation.' };
|
||||
}
|
||||
export function compareOriginalState(before, after, { modelCenterSchemaChange = false } = {}) {
|
||||
for (const field of ['pid', 'hasKey', 'configSha256', 'projectsSha256', 'sessionsSha256', 'eventCursor']) assert.deepEqual(after[field], before[field], field);
|
||||
assert.deepEqual(canonical(after.database.tables), canonical(before.database.tables), 'All original table schemas and every persistent row');
|
||||
assert.deepEqual(after.database.sessionIds, before.database.sessionIds); assert.deepEqual(after.exports, before.exports);
|
||||
assert.deepEqual(after.persistent, before.persistent, 'Every original artifact byte, persistent row and public disk config');
|
||||
if (modelCenterSchemaChange) {
|
||||
const original = structuredClone(before.modelCenter), next = structuredClone(after.modelCenter);
|
||||
// 1.15 changes only the public explanatory text about optional DPAPI storage.
|
||||
// Existing IDs, routes, revisions, credentials-present bits and all original attempts remain exact.
|
||||
assert.match(next.storage.restart, /临时凭据.*已明确本机加密保存/);
|
||||
next.storage.restart = original.storage.restart;
|
||||
assert.deepEqual(next, original, 'Original public model center, except versioned storage explanation');
|
||||
return { modelCenterChange: { path: '/storage/restart', original: before.modelCenter.storage.restart, actual: after.modelCenter.storage.restart }, originalRows: 'exact', originalExports: 'exact', originalArtifactBytes: 'exact' };
|
||||
}
|
||||
assert.equal(after.modelCenterSha256, before.modelCenterSha256);
|
||||
return { originalRows: 'exact', originalExports: 'exact', originalArtifactBytes: 'exact', originalModelCenter: 'exact' };
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import {execFileSync} from 'node:child_process';
|
||||
import {publicSnapshot,compareOriginalState,hash} from './embedded-browser-d-state.mjs';
|
||||
const read=file=>JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
const git=args=>execFileSync('git',args,{encoding:'utf8',windowsHide:true,maxBuffer:8*1024*1024});
|
||||
assert.equal(git(['status','--porcelain']).trim(),'','Final local checkout must be clean');git(['diff','--check']);
|
||||
const identityFile='docs/embedded-browser-release-identity.json',identity=read(identityFile);
|
||||
assert.equal(identity.version,'1.22.0');git(['merge-base','--is-ancestor',identity.sourceCommit,'HEAD']);
|
||||
assert.equal(git(['diff',identity.sourceCommit,'HEAD','--','src','scripts','tests','package.json','package-lock.json','vite.config.ts','tsconfig.json','index.html','mobile.html']).trim(),'','Frozen execution inputs unchanged');
|
||||
let evidenceFiles=0,evidenceBytes=0;const committed=[identityFile];
|
||||
for(const manifestFile of [identity.evidence.manifest,'docs/embedded-browser-development-evidence/manifest.json','docs/embedded-browser-rejected-candidate-evidence/manifest.json','docs/embedded-browser-b-rejected-candidate-evidence/manifest.json','docs/embedded-browser-c-rejected-candidate-evidence/manifest.json']){
|
||||
const manifest=read(manifestFile),root=path.dirname(manifestFile);committed.push(manifestFile);
|
||||
if(manifestFile===identity.evidence.manifest){assert.equal(hash(fs.readFileSync(manifestFile)),identity.evidence.sha256);assert.equal(manifest.files.length,identity.evidence.files);}
|
||||
for(const row of manifest.files){const file=path.posix.join(root,row.path),bytes=fs.readFileSync(file);assert.equal(bytes.length,row.bytes,file);assert.equal(hash(bytes),row.sha256,file);committed.push(file);evidenceFiles++;evidenceBytes+=bytes.length;}
|
||||
}
|
||||
for(let index=0;index<committed.length;index+=16){
|
||||
const batch=committed.slice(index,index+16),output=execFileSync('git',['cat-file','--batch'],{input:batch.map(file=>'HEAD:'+file).join('\n')+'\n',windowsHide:true,maxBuffer:64*1024*1024});
|
||||
let position=0;for(const file of batch){const end=output.indexOf(10,position),header=output.subarray(position,end).toString('utf8');assert.match(header,/^[a-f0-9]+ blob \d+$/,'Missing committed evidence '+file);const length=Number(header.split(' ').at(-1)),bytes=output.subarray(end+1,end+1+length);position=end+2+length;assert.deepEqual(bytes,fs.readFileSync(file),'Exact committed evidence '+file);}assert.equal(position,output.length);
|
||||
}
|
||||
let links=0;
|
||||
for(const file of ['AGENTS.md','README.md','docs/QA-1.22.md','docs/RETROSPECTIVE-1.22.md','docs/PLAN-1.22.md','docs/PLAN-1.23.md','docs/EMBEDDED-BROWSER.md','docs/NEXT-STEPS.md','docs/CAPABILITIES.md']){
|
||||
for(const match of fs.readFileSync(file,'utf8').matchAll(/\]\(([^)]+)\)/g)){if(/^(https?:|#)/.test(match[1]))continue;assert.ok(fs.existsSync(path.resolve(path.dirname(file),match[1].split('#')[0])),'Broken local link '+file+': '+match[1]);links++;}
|
||||
}
|
||||
const before=read('.qa/embedded-browser-d-formal-after-verify.json'),after=await publicSnapshot('http://127.0.0.1:4318',identity.formal.pointer.dataRoot);
|
||||
assert.equal(after.version,'1.22.0');assert.equal(after.pid,identity.formal.pid);assert.equal(after.runtimeRoot,identity.formal.runtimeRoot);assert.deepEqual(after.active,[]);
|
||||
const retained=compareOriginalState(before,after),pointer=read('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/current.json');assert.deepEqual(pointer,identity.formal.pointer);
|
||||
const finalCommit=git(['rev-parse','HEAD']).trim(),result={schemaVersion:1,success:true,version:'1.22.0',verifiedAt:new Date().toISOString(),sourceCommit:identity.sourceCommit,finalCommit,
|
||||
identity:identityFile,identitySha256:hash(fs.readFileSync(identityFile)),evidenceFiles,evidenceBytes,exactCommittedBlobs:committed.length,localLinks:links,
|
||||
formal:{pid:after.pid,runtimeRoot:after.runtimeRoot,retained,counts:identity.formal.counts},gitClean:true,localOnly:true,realModelRequestsInitiated:0,
|
||||
scope:'Frozen implementation ancestry, exact bytes of all development/final evidence in checkout and Git, local links, installed pointer and every original row/export/config/artifact byte after final UI/native observations.'};
|
||||
const output=path.join('releases',identity.installer.candidateDirectory+'-ACCEPTANCE-FINAL.json');fs.writeFileSync(output,JSON.stringify(result,null,2)+'\n',{flag:'wx'});console.log(JSON.stringify({success:true,output,finalCommit,evidenceFiles,retained,counts:identity.formal.counts}));
|
||||
@@ -0,0 +1,34 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
const prefix = '.qa/embedded-browser-d-', completed = [];
|
||||
const read = file => JSON.parse(fs.readFileSync(file));
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
async function run(name, script) {
|
||||
const file = prefix + name + '-finalization.log';
|
||||
const stream = fs.createWriteStream(file, { flags: 'wx' });
|
||||
const child = spawn(process.execPath, [script], { windowsHide: true, env: projectEnvironment(), stdio: ['ignore','pipe','pipe'] });
|
||||
let tail = ''; const capture = bytes => { stream.write(bytes); tail = (tail + bytes.toString('utf8')).slice(-9000); };
|
||||
child.stdout.on('data', capture); child.stderr.on('data', capture);
|
||||
const exitCode = await new Promise((resolve, reject) => { child.once('error', reject); child.once('close', resolve); });
|
||||
await new Promise(resolve => stream.end(resolve));
|
||||
const row = { name, script, exitCode, log: file, logSha256: hash(fs.readFileSync(file)), finishedAt: new Date().toISOString() };
|
||||
completed.push(row); console.log(JSON.stringify(row));
|
||||
assert.equal(exitCode, 0, 'Keep original phase; do not replay: ' + tail);
|
||||
}
|
||||
let result;
|
||||
try {
|
||||
console.log('Awaiting complete D independent verification and formal promotion. No Git action will be taken.');
|
||||
while (!fs.existsSync(prefix + 'promotion-result.json')) await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
assert.equal(read(prefix + 'promotion-result.json').success, true);
|
||||
assert.equal(read(prefix + 'independent-continuation-result.json').success, true);
|
||||
await run('ui-preflight', prefix + 'ui-evidence-preflight.mjs');
|
||||
await run('review-timings', prefix + 'review-timings.mjs');
|
||||
await run('seal', '.qa/seal-embedded-browser-d-release.mjs');
|
||||
await run('finalize-docs', prefix + 'finalize-docs.mjs');
|
||||
result = { success: true, completed, finishedAt: new Date().toISOString(), requiresLocalGitDiffReviewAndCommit: true, scope: 'Seals original final evidence and updates milestone documents only after all required D verification and formal stages pass. B UI and C core tests retain their original identities and require strict input binding. No Git staging, commit, or remote push.' };
|
||||
} catch (error) { result = { success: false, completed, error: error.stack, finishedAt: new Date().toISOString() }; process.exitCode = 1; }
|
||||
fs.writeFileSync(prefix + 'finalization-result.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,28 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
const identity = read('docs/embedded-browser-release-identity.json'), v = identity.validation, c = identity.formal.counts;
|
||||
assert.equal(v.sourceTestExecution.success,true);assert.equal(v.sourceTestExecution.tests.tests,683);
|
||||
assert.equal(identity.version, '1.22.0'); assert.equal(identity.formal.currentProviderPreserved, true);
|
||||
assert.equal(v.sourceTests.tests, v.sourceTests.pass); assert.equal(v.sourceTests.fail, 0);
|
||||
const timing = read('.qa/embedded-browser-d-timing-review.json'); assert.equal(timing.success, true);
|
||||
const summary = `1.22.0已完成所属Vite预览、独立桌面浏览区、有界DOM/原截图与审批动作、独立登录资料/撤销/下载、手机原观察SHA核对的本地交付。独立源码${v.sourceTests.pass}/${v.sourceTests.tests}(C完整原轮通过,D严格绑定后沿用)、${v.historicalUiScripts}类${v.historicalUiGroups}组原B串行界面(产品输入相同,严格绑定后沿用)、源码/便携/实际安装各17组浏览流程、同载荷安装7组、正式${v.formalPanels}页及Edge/Electron两视口通过。原PID${identity.formal.pid}/Provider保持,${c.projects}项目/${c.sessions}全部会话/${c.records}记录/${c.events}事件及${identity.formal.artifactFiles}工件文件原字节保持,9229关闭。本轮验收发起真实模型请求0。`;
|
||||
const links = '见[使用说明](EMBEDDED-BROWSER.md)、[1.22验收](QA-1.22.md)、[回顾](RETROSPECTIVE-1.22.md)与[发行身份](embedded-browser-release-identity.json)。下一[1.23发行效率与更新进度](PLAN-1.23.md)仅方案;真实模型自主工程/Purge收益和新iPhone流程另验。';
|
||||
const prepend = (text, body) => text.replace(/^(#[^\r\n]+\r?\n)/, '$1\n' + body + '\n');
|
||||
const update = (file, transform) => { const old = fs.readFileSync(file, 'utf8'), next = transform(old); assert.notEqual(next, old, file); fs.writeFileSync(file, next); };
|
||||
update('AGENTS.md', text => prepend(text, summary + ' 当前身份以docs/embedded-browser-release-identity.json为准。下一1.23仅方案;历史段落按当时来源理解。\n')
|
||||
.replace('当前接续优先级:1.21工程环境与固定依赖准备已本地交付,原状态/失败保持;下一按PLAN-1.22实施内置浏览器。', '当前接续优先级:1.22内置浏览器已本地交付,原状态/失败保持;下一按PLAN-1.23研究发行效率与更新进度。')
|
||||
.replace('- 正式服务入口http://127.0.0.1:4318,当前1.21.0,沿用原PID36552与Provider;当前身份以docs/reproducible-env-release-identity.json为准。', '- 正式服务入口http://127.0.0.1:4318,当前1.22.0,沿用原PID36552与Provider;当前身份以docs/embedded-browser-release-identity.json为准。'));
|
||||
update('README.md', text => prepend(text, `1.22.0已本地上线:任务中准备Vite预览,桌面端右侧「浏览」查看真实页面并审批固定操作;原截图、动作和下载可核对,手机可观察同一原图。${v.sourceTests.pass}项核心测试沿用C完整通过原轮、${v.historicalUiGroups}组界面沿用B原轮,均已严格绑定输入;D独立重建及实际桌面、便携、安装/升级通过,原连接和全部历史保持。见[工作台](http://127.0.0.1:4318/?release=1.22.0)、[使用说明](docs/EMBEDDED-BROWSER.md)、[验收](docs/QA-1.22.md)、[回顾](docs/RETROSPECTIVE-1.22.md)和[发行身份](docs/embedded-browser-release-identity.json)。新iPhone与真实模型效果单列待验。以下为历史交付记录。\n`));
|
||||
update('CHANGELOG.md', text => prepend(text, `## 1.22.0 · 内置浏览器与所属开发预览(已本地交付)\n\n- 所属Vite预览固定工作区、实际依赖和运行器,核对监听进程/HTTP就绪,支持停止、原日志和unknown核对。\n- 真正独立的桌面浏览内容、任务标签、拖动/键盘宽度与窄屏返回;审批弹窗和拖动时隐藏原生网页。\n- 有界页面文字/控件、原PNG及SHA、原Task/Run审批后的固定动作;旧观察失效,未知提交不重放。\n- 独立临时/持久资料、显式复用、撤销清除和明确地址下载;手机核对同一原截图。\n- ${summary}\n`));
|
||||
update('task_plan.md', text => text.replace(/## 当前阶段:1\.22 内置浏览器[\s\S]*?(?=## 已完成:1\.21)/, `## 已完成:1.22 内置浏览器\n\n${summary}\n\n1. [complete] A:所属Vite计划/审批/实际就绪/原日志/停止/unknown及任务入口。\n2. [complete] B:真实独立Electron浏览内容、任务标签、拖动/键盘宽度、125%缩放、模态遮挡和390px返回。\n3. [complete] C/D:原DOM/PNG/SHA、原审批/Task/Run/输入绑定、过期观察拒绝、unknown防重放、登录资料/撤销/下载和手机原观察。\n4. [complete] E:完整冻结回归、独立源码/归档/便携/实际安装浏览流程、保留状态升级、证据封存和阶段回顾。\n\n## 下一阶段:1.23(计划)\n\n详细范围见docs/PLAN-1.23.md。先测量、再拆分运行载荷和历史证据、显示真实校验进度;保留完整性/回退/原状态门槛。尚未实现,真实模型与新iPhone继续单列。\n\n`));
|
||||
for (const file of ['progress.md', 'findings.md']) update(file, text => prepend(text, '## 1.22最终交付核对\n\n' + summary + '\n\n冻结实现' + identity.sourceCommit + ',完整原件见docs/embedded-browser-release-evidence/manifest.json;开发失败和修复轮原件另封存。下一1.23仅记录计划,未变更原用户任务或使用真实模型。\n'));
|
||||
update('docs/QA-1.22.md', text => prepend(text.replace('本阶段正在实施,正式服务保持1.21.0/PID36552。', '开发起步时正式服务保持1.21.0/PID36552;现在的发行状态以本节最终收据为准。'), summary + '\n\n' + links + '\n\n下方开发轮保持各自时间和来源,不替代本节最终结论。\n') + `\n## 最终冻结与发行\n\n执行来源${identity.sourceCommit},${v.sourceInputFiles}份输入与${v.buildMatchedFiles}份独立重建产物逐字节一致;C完整原轮中全部测试文件按有界批次恰好一次执行,升级占用的固定9229独占;D核对全部核心输入和原TAP后沿用该683项结果。${v.historicalUiScripts}类${v.historicalUiGroups}组界面沿用B的原串行结果:D产品运行输入逐字节相同,仅HTTP测试同步、桌面验收helper和Git证据属性变化,来源见原件review/inherited-ui.json。683项来自C完整原轮;D严格核对输入后沿用,具体源文件与原日志见review/source-test-inheritance.json。原A/B/C整体失败保持失败。源码、便携、实际安装载荷分别完成17组浏览流程,九类随包专项与实际旧1.21→新1.22保留Provider升级通过。\n\n正式stage/upgrade/activate/verify各阶段单次执行,原表每行、全部会话导出的已有字段、公开模型配置和全部工件原字节保持;新执行视图仅增加四个已逐会话断言为空的浏览/预览数组,完整新旧摘要分别保留。原SQLite备份和完整状态快照仅留本机忽略目录,不进入Git。完整来源、原结果与SHA见[原件清单](embedded-browser-release-evidence/manifest.json)。正式只读界面和实际安装Electron不创建Task、不发模型请求。\n\n最终能力边界:所属预览首批仅支持固定Vite声明;网页操作依赖连接中的Windows桌面窗口。手机只观察与原任务审批,本轮TLS页面验证不冒充新增iPhone实机。真实模型自主工程和Purge收益未验。\n`);
|
||||
update('docs/RETROSPECTIVE-1.22.md', text => text.replace('当前正在以该来源执行冻结回归与发行验收,尚不以开发通过代替源码、便携、安装及正式升级成功。', '候选A的源码测试通过,但总验收在桌面入口契约检查失败而被拒绝,原件保留。最终发行使用修正桌面审查同步的候选D,实际来源和结果列于下方。') + '\n## 候选B与C\n\nB原轮因HTTP测试等待ready的20秒期限失败,原件保留于embedded-browser-b-rejected-candidate-evidence。C只修正HTTP用例同步并增加原字节Git属性,产品运行输入未变;33类250组原UI在严格输入/原收据绑定后沿用,C独立源码完整重跑并683/683通过;随后桌面审查UI默认5秒等待失败,C仍整体拒绝。D只修正桌面验收helper,严格核对所有核心源码/测试/依赖/编译和实际读取脚本相同后沿用683项原TAP,重新离线安装/构建、所有前置和桌面及后续门槛。\n\n## 最终交付与测量\n\n' + summary + '\n\n执行来源' + identity.sourceCommit + '。' + links + '\n\n' + timing.formal.map(row => row.name + ' ' + (row.durationMs / 1000).toFixed(3) + '秒').join(';') + '。不可变载荷' + timing.payload.all.files + '文件/' + timing.payload.all.bytes + '字节,其中docs为' + timing.payload.docs.files + '文件/' + timing.payload.docs.bytes + '字节。以上为原阶段墙钟与文件体积,不声称已实现性能优化。来源见[测量](embedded-browser-release-evidence/review/timing-review.json)。\n');
|
||||
update('docs/PLAN-1.22.md', text => prepend(text, 'A–E已完成本地交付,实际范围、来源与限制见[1.22验收](QA-1.22.md)和[回顾](RETROSPECTIVE-1.22.md)。以下保留起步时的方案及边界。\n'));
|
||||
update('docs/NEXT-STEPS.md', text => prepend(text, '当前:' + summary + '\n\n' + links + '\n\n以下旧版接续段落保留其当时状态。\n'));
|
||||
for (const file of ['docs/CAPABILITIES.md', 'docs/MILESTONE-AUDIT.md', 'docs/VALIDATION.md']) update(file, text => prepend(text, summary + '\n\n' + links + '\n\n下方历史阶段保持当时范围与结论。\n'));
|
||||
console.log(JSON.stringify({ success: true, version: identity.version, sourceCommit: identity.sourceCommit, sourceTests: v.sourceTests.tests, uiGroups: v.historicalUiGroups, counts: c }));
|
||||
|
||||
update('docs/QA-1.22.md', value => value + '\n## 原D升级拒绝与同载荷续验\n\nD源码和便携各项通过后,首次隔离旧版升级在原execution全摘要比较被拒绝,原失败保持。新独立诊断确认仅新增browsingTabs/browsingActions/previewPlans/previewJobs四个空数组,17项比较器边界检查拒绝缺失、非空、未审查版本及其它原字段变化。同一D不可变载荷续验逐字节绑定原18个成功阶段、原日志和归档,再新执行旧版升级及全部未完成安装门槛;没有重判原失败。原件见embedded-browser-release-evidence/review/d-rejected-acceptance/manifest.json,续验身份见发行identity的acceptanceContinuation。\n');
|
||||
update('docs/RETROSPECTIVE-1.22.md', value => value + '\n## 升级视图兼容回顾\n\n首次D隔离升级被旧全摘要比较拦住:新执行视图增加四个空列表而原数据保持。不能忽略整个执行对象;最终比较器严格核对所有原字段,仅允许明确的四个新增空字段,保留完整原摘要和归一到旧字段后的摘要。17项有针对性的边界验证及新的实际旧版升级通过后,才继续同载荷安装和正式阶段。D原失败和续验驱动初次只读预检失败均保留。未来视图新增需要明确版本、字段和原值,不能把不明差异当作兼容。\n');
|
||||
@@ -0,0 +1,76 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import net from 'node:net';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import { DatabaseSync, backup } from 'node:sqlite';
|
||||
import { publicSnapshot, compareOriginalState, hash } from './embedded-browser-d-state.mjs';
|
||||
import { InstallationManager, validateInstalledVersion } from '../src/core/desktop/install-manager.mjs';
|
||||
import { inspectHostInstallation } from '../src/core/desktop/app-installation.mjs';
|
||||
import { HostController } from '../src/core/desktop/host-controller.mjs';
|
||||
import { observeWindowsProcess } from '../src/core/desktop/process-identity.mjs';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
import { upgradeRunning } from '../scripts/upgrade-running.mjs';
|
||||
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
const save = (file, value) => fs.writeFileSync(file, JSON.stringify(value, null, 2) + '\n', { flag: 'wx' });
|
||||
const mode = process.argv[2]; assert.ok(['stage', 'upgrade', 'activate', 'verify'].includes(mode));
|
||||
const release = read('releases/latest.json'); assert.equal(release.installer.version, '1.22.0'); assert.equal(release.installer.qaFixture, null);
|
||||
assert.equal(hash(fs.readFileSync(release.installer.path)), release.installer.sha256);
|
||||
const validated = read('.qa/embedded-browser-d-independent-continuation-result.json'); assert.equal(validated.success, true); assert.equal(validated.release.installer.sha256, release.installer.sha256);
|
||||
const bound = read('.qa/embedded-browser-d-package-binding.json'); assert.equal(bound.success,true); assert.equal(bound.setupSha256,release.installer.sha256);
|
||||
const installRoot = 'C:/Users/wangy/AppData/Local/Programs/AgentWorkbench', originalPointer = read(path.join(installRoot, 'current.json'));
|
||||
const dataRoot = fs.realpathSync.native(originalPointer.dataRoot), candidate = path.resolve(installRoot, 'versions', release.installer.candidateDirectory);
|
||||
const url = 'http://127.0.0.1:4318', port = 4318, expectedPid = 36552, prefix = '.qa/embedded-browser-d-formal-';
|
||||
const output = prefix + mode + '.json', beforeFile = prefix + 'before.json'; assert.equal(fs.existsSync(output), false, 'Do not repeat a sealed phase');
|
||||
const startedAt = new Date().toISOString();
|
||||
const originalProcess = () => { const value = observeWindowsProcess(expectedPid); assert.ok(value); assert.equal(value.createdAt, '2026-10-31T06:30:34.359Z'); assert.equal(hash(fs.readFileSync(value.executable)), 'd702daa815eabbff763c7d3808e235cf031cf2ca70211b56847bc72f51e240e5'); return value; };
|
||||
async function inspectorClosed() { return new Promise((resolve, reject) => { const socket = net.createConnection({ host: '127.0.0.1', port: 9229 }); socket.setTimeout(1500); socket.once('connect', () => { socket.destroy(); reject(Error('An inspector is open')); }); socket.once('timeout', () => { socket.destroy(); reject(Error('Inspector state unknown')); }); socket.once('error', error => { socket.destroy(); error.code === 'ECONNREFUSED' ? resolve(true) : reject(error); }); }); }
|
||||
let result;
|
||||
try {
|
||||
originalProcess(); await inspectorClosed();
|
||||
if (mode === 'stage') {
|
||||
assert.equal(fs.existsSync(candidate), false); assert.equal(fs.existsSync(beforeFile), false);
|
||||
const before = await publicSnapshot(url, dataRoot); assert.equal(before.version, '1.21.0'); assert.equal(before.pid, expectedPid); assert.deepEqual(before.active, []);
|
||||
const controller = new HostController({ appRoot: before.runtimeRoot, dataRoot, port, nodePath: process.execPath }); assert.ok(await controller.connect());
|
||||
const status = await controller.status(); assert.equal(status.desktopWindows.count, 0); assert.equal(status.activity.active, false);
|
||||
const gateway = await controller.api('/companion'); assert.equal(gateway.enabled, false); assert.deepEqual(gateway.devices, []);
|
||||
save(beforeFile, before); save(prefix + 'original-pointer.json', originalPointer);
|
||||
const db = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true }), backupPath = path.resolve(prefix + 'original.sqlite'); assert.equal(fs.existsSync(backupPath), false);
|
||||
try { await backup(db, backupPath); } finally { db.close(); }
|
||||
const copy = new DatabaseSync(backupPath, { readOnly: true }); try { assert.equal(copy.prepare('PRAGMA quick_check').get().quick_check, 'ok'); } finally { copy.close(); }
|
||||
save(prefix + 'private-backup-receipt.json', { path: backupPath, bytes: fs.statSync(backupPath).size, sha256: hash(fs.readFileSync(backupPath)), committed: false, credentialsExtracted: false });
|
||||
compareOriginalState(before, await publicSnapshot(url, dataRoot));
|
||||
const log = path.resolve(prefix + 'setup.log'); assert.equal(fs.existsSync(log), false);
|
||||
await promisify(execFile)(release.installer.path, ['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/TASKS=desktopicon', '/DIR=' + installRoot, '/DATA_ROOT=' + dataRoot, '/PORT=' + port, '/STAGE_ONLY=1', '/LOG=' + log], { windowsHide: true, env: projectEnvironment(), timeout: 900000, maxBuffer: 1048576 });
|
||||
const identity = validateInstalledVersion(candidate), after = await publicSnapshot(url, dataRoot), retained = compareOriginalState(before, after);
|
||||
assert.equal(after.version, '1.21.0'); assert.deepEqual(read(path.join(installRoot, 'current.json')), originalPointer);
|
||||
result = { success: true, phase: 'staged', version: '1.22.0', candidateIdentity: identity.identitySha256, manifestSha256: identity.manifestSha256, retained, setupLog: log, setupLogSha256: hash(fs.readFileSync(log)) };
|
||||
} else {
|
||||
const staged = read(prefix + 'stage.json'), before = read(beforeFile); assert.equal(staged.success, true); assert.equal(staged.setupSha256, release.installer.sha256);
|
||||
// Stage already verified every immutable candidate file; subsequent phase
|
||||
// gates bind the unchanged manifest and loaded inputs to that sealed proof.
|
||||
// Product activation still independently runs all of its full validations.
|
||||
const identity = inspectHostInstallation(candidate); assert.equal(identity.identitySha256, staged.candidateIdentity); assert.equal(identity.manifestSha256, staged.manifestSha256);
|
||||
const current = await publicSnapshot(url, dataRoot); compareOriginalState(before, current); assert.deepEqual(current.active, []);
|
||||
if (mode === 'upgrade') {
|
||||
assert.equal(current.version, '1.21.0'); const info = read(path.join(dataRoot, 'service-info.json')); assert.equal(info.pid, expectedPid);
|
||||
const upgraded = await upgradeRunning({ url, pid: expectedPid, currentRoot: info.appRoot, handlerRoot: current.runtimeRoot, newRoot: candidate }); assert.equal(upgraded.connectionPreserved, true);
|
||||
const after = await publicSnapshot(url, dataRoot), retained = compareOriginalState(before, after); assert.equal(after.version, '1.22.0'); assert.equal(after.runtimeRoot, candidate);
|
||||
await inspectorClosed(); save(prefix + 'after-upgrade.json', after);
|
||||
result = { success: true, phase: 'upgraded', version: '1.22.0', upgraded, retained, currentProviderPreserved: true };
|
||||
} else {
|
||||
assert.equal(read(prefix + 'upgrade.json').success, true); assert.equal(current.version, '1.22.0'); assert.equal(current.runtimeRoot, candidate);
|
||||
let activated = null; if (mode === 'activate') { activated = await new InstallationManager({ installRoot, dataRoot, candidateRoot: candidate, port }).activate(); assert.equal(activated.phase, 'activated'); assert.equal(activated.hostRetained, false); }
|
||||
const controller = new HostController({ appRoot: candidate, dataRoot, port, nodePath: process.execPath }); assert.ok(await controller.connect()); const status = await controller.status();
|
||||
assert.equal(status.identity.pid, expectedPid); assert.equal(status.activity.active, false);
|
||||
const gateway = await controller.api('/companion'); assert.equal(gateway.enabled, false); assert.deepEqual(gateway.devices, []); assert.equal(gateway.certificate, null);
|
||||
const pointer = read(path.join(installRoot, 'current.json')); assert.equal(pointer.active.directory, release.installer.candidateDirectory); assert.equal(pointer.active.runtimeIdentity, identity.identitySha256);
|
||||
assert.equal(fs.realpathSync.native(pointer.dataRoot), dataRoot); assert.equal(hash(fs.readFileSync(path.join(installRoot, 'AgentWorkbench.exe'))), hash(fs.readFileSync(path.join(candidate, 'AgentWorkbench.exe'))));
|
||||
const after = await publicSnapshot(url, dataRoot), retained = compareOriginalState(before, after); await inspectorClosed(); save(prefix + 'after-' + mode + '.json', after);
|
||||
result = { success: true, phase: mode, activated, identity: status.identity, pointer, retained, currentProviderPreserved: true, companion: { enabled: gateway.enabled, devices: gateway.devices.length, certificate: gateway.certificate }, counts: { projects: after.projects, visibleSessions: after.visibleSessions, sessions: after.database.sessionIds.length, records: after.database.tables.records.count, events: after.database.tables.events.count, artifacts: after.persistent.artifacts.length }, inspectorClosed: true };
|
||||
}
|
||||
}
|
||||
} catch (error) { result = { success: false, phase: mode, error: error.stack }; process.exitCode = 1; }
|
||||
save(output, { ...result, startedAt, finishedAt: new Date().toISOString(), installRoot, dataRoot, candidate, setupSha256: release.installer.sha256, originalProcess: originalProcess(), realModelRequests: 0 });
|
||||
console.log(JSON.stringify({ success: result.success, phase: result.phase, output, error: result.error }));
|
||||
@@ -0,0 +1,16 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
const prefix = '.qa/embedded-browser-c-http-fix';
|
||||
const log = prefix + '.tap', stream = fs.createWriteStream(log, { flags: 'wx' });
|
||||
const args = ['--test', '--test-reporter=tap', 'tests/workers-http.test.mjs'];
|
||||
const child = spawn(process.execPath, args, { windowsHide: true, env: projectEnvironment(), stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
child.stdout.pipe(stream, { end: false }); child.stderr.pipe(stream, { end: false });
|
||||
const exitCode = await new Promise((resolve, reject) => { child.once('error', reject); child.once('close', resolve); });
|
||||
await new Promise(resolve => stream.end(resolve));
|
||||
const bytes = fs.readFileSync(log);
|
||||
const result = { success: exitCode === 0, exitCode, args, log, logSha256: createHash('sha256').update(bytes).digest('hex'), realModelRequests: 0 };
|
||||
fs.writeFileSync(prefix + '-result.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(bytes.toString('utf8')); assert.equal(exitCode, 0);
|
||||
@@ -0,0 +1,59 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn, execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
const prefix='.qa/embedded-browser-d-',read=file=>JSON.parse(fs.readFileSync(file,'utf8')),save=(file,value)=>fs.writeFileSync(file,JSON.stringify(value,null,2)+'\n',{flag:'wx'}),hash=bytes=>createHash('sha256').update(bytes).digest('hex');
|
||||
const original=read(prefix+'independent-result.json'),baseline=read(prefix+'code-baseline.json'),release=read('releases/latest.json'),startedAt=new Date().toISOString();
|
||||
assert.equal(original.success,false);assert.equal(original.completed.length,18);assert.equal(original.completed.at(-1).name,'portable-evaluations');
|
||||
assert.equal(read(prefix+'owned-upgrade.json').success,false);assert.equal(read(prefix+'owned-upgrade-receipt.json').exitCode,1);
|
||||
assert.equal(read(prefix+'upgrade-schema-diagnostic-result.json').success,true);assert.equal(read(prefix+'state-checks.json').assertions,17);
|
||||
assert.deepEqual(read(prefix+'package.log'),release);assert.equal(baseline.codeCommit,original.codeCommit);
|
||||
const unchanged=()=>{
|
||||
assert.equal(execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8',windowsHide:true}).trim(),baseline.codeCommit);
|
||||
for(const row of [...baseline.inputs,...baseline.builds]){const bytes=fs.readFileSync(row.path);assert.equal(bytes.length,row.bytes,row.path);assert.equal(hash(bytes),row.sha256,row.path);}
|
||||
};
|
||||
unchanged();
|
||||
for(const item of [release.portable,release.source,release.installer]){const bytes=fs.readFileSync(item.path);assert.equal(bytes.length,item.bytes);assert.equal(hash(bytes),item.sha256);}
|
||||
const inherited=[];
|
||||
for(const row of original.completed){
|
||||
assert.equal(row.exitCode,0);assert.equal(hash(fs.readFileSync(row.logPath)),row.logSha256);assert.equal(fs.statSync(row.logPath).size,row.logBytes);
|
||||
assert.deepEqual(read(prefix+row.name+'-receipt.json'),row);assert.equal(row.codeCommit,baseline.codeCommit);
|
||||
if(row.evidence)assert.equal(hash(fs.readFileSync(prefix+row.name+'-original-result.json')),row.evidence.sha256);
|
||||
inherited.push({name:row.name,receiptSha256:hash(fs.readFileSync(prefix+row.name+'-receipt.json')),execution:'Original D successful stage; preserved without replay'});
|
||||
}
|
||||
const rejectedRoot=prefix+'rejected-acceptance';assert.equal(fs.existsSync(rejectedRoot),false);fs.mkdirSync(rejectedRoot);
|
||||
const rejectedNames=['independent-result.json','independent-console.log','owned-upgrade.json','owned-upgrade.log','owned-upgrade-receipt.json','orchestration-result.json','independent.mjs','owned-upgrade.mjs','upgrade-schema-diagnostic-before.json','upgrade-schema-diagnostic-after.json','upgrade-schema-diagnostic-result.json','state-checks.json'];
|
||||
const rejectedFiles=[];
|
||||
for(const name of rejectedNames){const from=prefix+name,bytes=fs.readFileSync(from);fs.writeFileSync(path.join(rejectedRoot,name),bytes,{flag:'wx'});rejectedFiles.push({path:name,source:from,bytes:bytes.length,sha256:hash(bytes)});}
|
||||
for(const from of ['.qa/desktop-f-state.mjs','.qa/diagnose-embedded-browser-d-upgrade-schema.mjs']){const bytes=fs.readFileSync(from),name=path.basename(from);fs.writeFileSync(path.join(rejectedRoot,name),bytes,{flag:'wx'});rejectedFiles.push({path:name,source:from,bytes:bytes.length,sha256:hash(bytes)});}
|
||||
save(rejectedRoot+'/manifest.json',{success:false,kind:'rejected-D-acceptance-preserved',sourceCommit:baseline.codeCommit,files:rejectedFiles,reason:'Raw execution view gained four documented empty arrays; original full-digest assertion rejected. Diagnosis and new strict original-field comparison do not rejudge the failed attempt.'});
|
||||
save(prefix+'continuation-stage-binding.json',{success:true,sourceCommit:baseline.codeCommit,release,originalRejectedResult:prefix+'independent-result.json',originalRejectedSha256:hash(fs.readFileSync(prefix+'independent-result.json')),inherited,allFrozenInputsExact:true,scope:'Only original successful stages inherited after exact current code/build/archive/log/receipt checks. Original failed upgrade remains failed. The same immutable D payload is retained; no package or product changes.'});
|
||||
const env=projectEnvironment({PATH:path.dirname(process.execPath)+path.delimiter+process.env.PATH,
|
||||
AGENT_WORKBENCH_TEST_PYTHON:path.resolve('.qa/python-qa-1.7.0/Scripts/python.exe'),AGENT_WORKBENCH_ARCHIVE_QA_ROOT:'D:/AWQA22',
|
||||
AGENT_WORKBENCH_DEEPSEEK_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/deepseek-harness',AGENT_WORKBENCH_PURGE_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/plugins/dsh-purge',
|
||||
AGENT_WORKBENCH_PURGE_178_ROOT:'D:/Ai-project/REA逆向/dsh-purge-1.1.78-windows/source/local',AGENT_WORKBENCH_PURGE_181_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/plugins/dsh-purge'});
|
||||
for(const key of ['AGENT_WORKBENCH_API_KEY','OPENAI_API_KEY','ANTHROPIC_API_KEY','DEEPSEEK_API_KEY'])delete env[key];
|
||||
const completed=[...original.completed],newlyExecuted=[];
|
||||
async function run(name,script,pointer=null){
|
||||
unchanged();console.log('START '+name+' '+new Date().toISOString());const logPath=prefix+name+'.log';assert.equal(fs.existsSync(logPath),false);
|
||||
const stream=fs.createWriteStream(logPath,{flags:'wx'}),child=spawn(process.execPath,[script],{env,windowsHide:true,stdio:['ignore','pipe','pipe']});let tail='';
|
||||
const capture=bytes=>{stream.write(bytes);tail=(tail+bytes.toString('utf8')).slice(-14000);};child.stdout.on('data',capture);child.stderr.on('data',capture);
|
||||
const exitCode=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',resolve);});await new Promise(resolve=>stream.end(resolve));unchanged();
|
||||
let evidence=null;if(pointer&&fs.existsSync(pointer)){const bytes=fs.readFileSync(pointer);evidence={path:pointer,sha256:hash(bytes)};fs.writeFileSync(prefix+name+'-original-result.json',bytes,{flag:'wx'});}
|
||||
const receipt={name,exitCode,finishedAt:new Date().toISOString(),logPath,logBytes:fs.statSync(logPath).size,logSha256:hash(fs.readFileSync(logPath)),evidence,codeCommit:baseline.codeCommit};save(prefix+name+'-receipt.json',receipt);
|
||||
assert.equal(exitCode,0,name+' failed. Keep original output; no automatic replay. '+tail);if(pointer)assert.equal(read(pointer).success,true);
|
||||
completed.push(receipt);newlyExecuted.push(name);console.log('PASS '+name);
|
||||
}
|
||||
let result;
|
||||
try{
|
||||
await run('owned-upgrade-continuation',prefix+'owned-upgrade-continuation.mjs',prefix+'owned-upgrade-continuation.json');
|
||||
await run('prepare-installer',prefix+'prepare-installer.mjs');
|
||||
await run('install','.qa/verify-embedded-browser-d-install.mjs');
|
||||
const location=read(prefix+'install-location.json'),installed=read(location.result);assert.equal(installed.success,true);assert.equal(installed.cases.length,7);
|
||||
result={success:true,version:'1.22.0',startedAt,finishedAt:new Date().toISOString(),completed,codeCommit:baseline.codeCommit,release,realModelRequests:0,
|
||||
acceptanceContinuation:{originalRejectedResult:prefix+'independent-result.json',originalSuccess:false,inheritedSuccessfulStages:inherited.length,newlyExecuted,stageBinding:prefix+'continuation-stage-binding.json',reason:'Only four empty execution-view additions allowed; every original field/row/config/artifact exact. Same frozen immutable payload; original failure unchanged.'},
|
||||
scope:'D accepted stages are explicitly inherited with full identity proof; corrected owned upgrade and all uncompleted installation gates are newly executed. Production untouched.'};
|
||||
}catch(error){result={success:false,version:'1.22.0',startedAt,finishedAt:new Date().toISOString(),completed,error:error.stack,codeCommit:baseline.codeCommit,originalRejectedResult:prefix+'independent-result.json'};process.exitCode=1;}
|
||||
save(prefix+'independent-continuation-result.json',result);console.log(JSON.stringify({success:result.success,newlyExecuted,error:result.error}));
|
||||
@@ -0,0 +1,68 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import {spawn,execFileSync} from 'node:child_process';
|
||||
import {createHash,randomUUID} from 'node:crypto';
|
||||
import {projectEnvironment} from '../src/core/process-environment.mjs';
|
||||
|
||||
const read=file=>JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
const save=(file,value)=>fs.writeFileSync(file,JSON.stringify(value,null,2)+'\n',{flag:'wx'});
|
||||
const hash=bytes=>createHash('sha256').update(bytes).digest('hex');
|
||||
const root=process.cwd(),prefix='.qa/embedded-browser-d-',completed=[],startedAt=new Date().toISOString();
|
||||
assert.equal(read('package.json').version,'1.22.0');
|
||||
const files=(directory,relative='')=>fs.readdirSync(path.join(directory,relative),{withFileTypes:true}).sort((a,b)=>a.name.localeCompare(b.name)).flatMap(entry=>entry.isDirectory()?files(directory,path.join(relative,entry.name)):[path.join(relative,entry.name)]);
|
||||
const rows=names=>names.map(file=>({path:file.replaceAll('\\','/'),bytes:fs.statSync(file).size,sha256:hash(fs.readFileSync(file))}));
|
||||
const names=[...['src','tests','scripts','benchmarks','public','examples','research'].flatMap(folder=>files(folder).map(file=>path.join(folder,file))),'package.json','package-lock.json','vite.config.ts','tsconfig.json','index.html','mobile.html','.gitattributes','.gitignore','Start-Desktop.cmd','Start-Workbench.cmd','Stop-Workbench.cmd'].sort();
|
||||
const baseline={version:'1.22.0',codeCommit:execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8',windowsHide:true}).trim(),inputs:rows(names),builds:rows(['dist-client','dist-server','dist-desktop'].flatMap(folder=>files(folder).map(file=>path.join(folder,file))))};
|
||||
save(prefix+'code-baseline.json',baseline);
|
||||
const unchanged=()=>{for(const row of [...baseline.inputs,...baseline.builds]){const bytes=fs.readFileSync(row.path);assert.equal(bytes.length,row.bytes,row.path);assert.equal(hash(bytes),row.sha256,row.path);}};
|
||||
const env=projectEnvironment({PATH:path.dirname(process.execPath)+path.delimiter+process.env.PATH,
|
||||
AGENT_WORKBENCH_TEST_PYTHON:path.join(root,'.qa/python-qa-1.7.0/Scripts/python.exe'),AGENT_WORKBENCH_ARCHIVE_QA_ROOT:'D:/AWQA22',
|
||||
AGENT_WORKBENCH_DEEPSEEK_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/deepseek-harness',
|
||||
AGENT_WORKBENCH_PURGE_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/plugins/dsh-purge',
|
||||
AGENT_WORKBENCH_PURGE_178_ROOT:'D:/Ai-project/REA逆向/dsh-purge-1.1.78-windows/source/local',
|
||||
AGENT_WORKBENCH_PURGE_181_ROOT:'D:/Ai-project/DeepSeek-Harness-Desktop/plugins/dsh-purge'});
|
||||
for(const name of ['AGENT_WORKBENCH_API_KEY','OPENAI_API_KEY','ANTHROPIC_API_KEY','DEEPSEEK_API_KEY'])delete env[name];
|
||||
async function run(name,args,{binary=process.execPath,pointer=null}={}){
|
||||
unchanged();console.log('START '+name+' '+new Date().toISOString());
|
||||
const logPath=prefix+name+'.log';assert.equal(fs.existsSync(logPath),false);
|
||||
const stream=fs.createWriteStream(logPath,{flags:'wx'}),child=spawn(binary,args,{cwd:root,env,windowsHide:true,stdio:['ignore','pipe','pipe']});
|
||||
let tail='';const capture=bytes=>{stream.write(bytes);tail=(tail+bytes.toString('utf8')).slice(-15000);};child.stdout.on('data',capture);child.stderr.on('data',capture);
|
||||
const exitCode=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',resolve);});await new Promise(resolve=>stream.end(resolve));unchanged();
|
||||
let evidence=null;if(pointer&&fs.existsSync(pointer)){const bytes=fs.readFileSync(pointer);evidence={path:pointer,sha256:hash(bytes)};fs.writeFileSync(prefix+name+'-original-result.json',bytes,{flag:'wx'});}
|
||||
const receipt={name,exitCode,finishedAt:new Date().toISOString(),logPath,logBytes:fs.statSync(logPath).size,logSha256:hash(fs.readFileSync(logPath)),evidence,codeCommit:baseline.codeCommit};save(prefix+name+'-receipt.json',receipt);
|
||||
assert.equal(exitCode,0,name+' failed; original log: '+logPath+'\n'+tail);if(pointer)assert.equal(read(pointer).success,true,name+' original result');
|
||||
completed.push(receipt);console.log('PASS '+name);return tail;
|
||||
}
|
||||
let result;
|
||||
try{
|
||||
await run('bind-native-review',['.qa/embedded-browser-d-bind-native-review.mjs']);
|
||||
await run('install-syntax-preflight',['.qa/embedded-browser-d-install-syntax-check.mjs']);
|
||||
await run('all-ui',['.qa/embedded-browser-d-inherit-ui.mjs'],{pointer:'.qa/embedded-browser-all-ui-validation.json'});
|
||||
await run('retain-legacy-report',['.qa/retain-embedded-browser-d-legacy-report.mjs']);
|
||||
await run('package',['scripts/package.mjs','--immutable']);
|
||||
await run('archives',['scripts/verify-archives.py','--extract-source'],{binary:env.AGENT_WORKBENCH_TEST_PYTHON,pointer:'.qa/archives-validation.json'});
|
||||
await run('vendor-runtime-binding',['.qa/embedded-browser-d-bind-vendor-runtime.mjs']);
|
||||
const archive=read('.qa/archives-validation.json'),source=fs.realpathSync.native(archive.extractionRoot),qaRoot=fs.realpathSync.native(env.AGENT_WORKBENCH_ARCHIVE_QA_ROOT),destination=path.join(qaRoot,'s-'+randomUUID().slice(0,8));
|
||||
assert.ok(source.startsWith(qaRoot+path.sep));assert.ok(destination.startsWith(qaRoot+path.sep));assert.equal(fs.existsSync(destination),false);
|
||||
fs.renameSync(source,destination);archive.extractionRoot=destination;archive.relocation={from:source,to:destination,reason:'Same-volume owned extraction; short Windows paths for source validation'};fs.writeFileSync('.qa/archives-validation.json',JSON.stringify(archive,null,2));save(prefix+'source-short-path.json',archive.relocation);
|
||||
await run('source',['.qa/verify-embedded-browser-d-source.mjs','--native-engines'],{pointer:'.qa/source-package-validation.json'});
|
||||
await run('portable',['scripts/verify-release.mjs','--native-engines'],{pointer:'.qa/release-validation.json'});
|
||||
const release=read('releases/latest.json');
|
||||
for(const [name,script,count,field]of [['embedded-browser','verify-embedded-browser.mjs',17,'checks'],['environment','verify-environment-ui.mjs',7,'checks'],['fidelity','verify-model-fidelity-ui.mjs',6,'checks'],['wait','verify-model-wait-ui.mjs',5,'checks'],['companion','verify-companion-ui.mjs',7,'passed'],['protocols','verify-model-protocols-ui.mjs',5,'passed'],['vision','verify-vision-ui.mjs',5,'passed'],['cache','verify-project-cache-ui.mjs',7,'passed'],['evaluations','verify-evaluations-release.mjs',5,'assertions']]){
|
||||
const output=await run('portable-'+name,['scripts/'+script,'--app-root',release.portableRoot]);
|
||||
const marker=[...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
const summaryLine=output.trim().split(/\r?\n/).findLast(line=>line.startsWith('{"success":'));
|
||||
const location=marker||(summaryLine?JSON.parse(summaryLine).directory:null);assert.ok(location);
|
||||
const relative=path.relative(path.join(root,'.qa'),location);assert.ok(relative&&!relative.startsWith('..')&&!path.isAbsolute(relative));
|
||||
const evidence=read(path.join(location,'result.json'));assert.equal(evidence.success,true);assert.equal(evidence.appRoot,release.portableRoot);assert.equal(evidence[field].length,count);
|
||||
for(const field of ['errors','pageErrors','requestFailures','failures'])assert.deepEqual(evidence[field]??[],[]);
|
||||
assert.equal(evidence.realModelRequests,0);save(prefix+'portable-'+name+'-validated.json',{success:true,directory:location,resultSha256:hash(fs.readFileSync(path.join(location,'result.json'))),groups:count,realModelRequests:0});
|
||||
}
|
||||
await run('owned-upgrade',['.qa/embedded-browser-d-owned-upgrade.mjs'],{pointer:prefix+'owned-upgrade.json'});
|
||||
await run('prepare-installer',['.qa/embedded-browser-d-prepare-installer.mjs']);
|
||||
await run('install',['.qa/verify-embedded-browser-d-install.mjs']);
|
||||
const installed=read(prefix+'install-location.json'),installation=read(installed.result);assert.equal(installation.success,true);assert.equal(installation.cases.length,7);
|
||||
result={success:true,version:'1.22.0',startedAt,finishedAt:new Date().toISOString(),completed,codeCommit:baseline.codeCommit,release,realModelRequests:0,scope:'Frozen inputs; immutable archives, independently rebuilt source/full tests with exclusive upgrade, contained portable UI and exact-payload isolated install. Production host untouched.'};
|
||||
}catch(error){result={success:false,version:'1.22.0',startedAt,finishedAt:new Date().toISOString(),completed,error:error.stack,codeCommit:baseline.codeCommit};process.exitCode=1;}
|
||||
save(prefix+'independent-result.json',result);console.log(JSON.stringify({success:result.success,completed:completed.map(value=>value.name),error:result.error}));
|
||||
@@ -0,0 +1,36 @@
|
||||
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 original = read('.qa/embedded-browser-b-code-baseline.json'), current = read('.qa/embedded-browser-d-code-baseline.json');
|
||||
const root = 'docs/embedded-browser-b-rejected-candidate-evidence', manifest = read(root + '/manifest.json');
|
||||
assert.equal(manifest.sourceCommit, original.codeCommit); assert.equal(manifest.sourceOverallSuccess,false);
|
||||
const byPath = new Map(current.inputs.map(row => [row.path,row]));
|
||||
assert.equal(byPath.size,original.inputs.length);
|
||||
const changed = original.inputs.filter(row => {
|
||||
const next = byPath.get(row.path); assert.ok(next); return next.sha256 !== row.sha256 || next.bytes !== row.bytes;
|
||||
}).map(row => row.path).sort();
|
||||
assert.deepEqual(changed,['.gitattributes','scripts/desktop-project-qa.mjs','tests/workers-http.test.mjs']);
|
||||
assert.deepEqual(current.builds, original.builds);
|
||||
for (const row of current.inputs.concat(current.builds)) assert.equal(hash(fs.readFileSync(row.path)),row.sha256,row.path);
|
||||
const allUiBytes = fs.readFileSync('.qa/embedded-browser-b-all-ui-original-result.json');
|
||||
assert.deepEqual(allUiBytes,fs.readFileSync('.qa/embedded-browser-all-ui-validation.json'));
|
||||
const allUi = JSON.parse(allUiBytes); assert.equal(allUi.success,true); assert.equal(allUi.results.length,33); assert.equal(allUi.groups,250);
|
||||
const sealed = new Map(manifest.files.map(row => [row.path,row]));
|
||||
for (const row of allUi.results) {
|
||||
for (const [file,target] of [[row.evidence,'all-ui/' + path.basename(row.script,'.mjs') + '.json'],[row.log,'all-ui/' + path.basename(row.script,'.mjs') + '.log']]) {
|
||||
const declaration = sealed.get(target); assert.ok(declaration,target);
|
||||
assert.equal(hash(fs.readFileSync(file)),declaration.sha256,file); assert.equal(hash(fs.readFileSync(path.join(root,target))),declaration.sha256,target);
|
||||
}
|
||||
}
|
||||
const payload = read(path.join(read(root+'/release.json').portableRoot,'MANIFEST.json'));
|
||||
const help = ['docs/RESEARCH.md','docs/research/CURSOR-MECHANISMS.md','docs/research/CONTEXT-RECOVERY.md','docs/research/TOOL-LOOP.md'];
|
||||
for (const file of help) assert.equal(hash(fs.readFileSync(file)),payload.files.find(row => row.path === file).sha256,file);
|
||||
const runtimeFiles = current.inputs.concat(current.builds).filter(row => /^(src|dist-client|dist-server|dist-desktop)\//.test(row.path)).length;
|
||||
const result = { success:true,sourceCommit:current.codeCommit,inheritedSourceCommit:original.codeCommit,changedInputs:changed,exactRuntimeFiles:runtimeFiles,
|
||||
scripts:33,groups:250,originalResultSha256:hash(allUiBytes),rejectedManifestSha256:hash(fs.readFileSync(root+'/manifest.json')),
|
||||
scope:'Reuse the original B serial UI run after exact identity checks for every product/runtime/script/fixture/public/example input and four directly served reports. Only HTTP test synchronization, desktop acceptance helper and evidence Git attributes changed. Product runtime inputs remain exact. The failed B source test is not inherited as passing; the new source suite must run in full.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-inherited-ui.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,17 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
const generator = fs.readFileSync('.qa/embedded-browser-d-prepare-installer.mjs', 'utf8');
|
||||
const start = generator.indexOf('let code = fs.readFileSync(');
|
||||
const end = generator.indexOf("\nfs.writeFileSync('.qa/verify-embedded-browser-d-install.mjs'", start);
|
||||
assert.ok(start > 0 && end > start);
|
||||
const code = new Function('fs', 'appId', 'assert', generator.slice(start, end) + '\nreturn code;')(fs, '00000000-0000-4000-8000-000000000022', assert);
|
||||
const destination = '.qa/embedded-browser-d-install-dryrun.mjs';
|
||||
fs.writeFileSync(destination, code, { flag: 'wx' });
|
||||
execFileSync(process.execPath, ['--check', destination], { stdio: 'pipe', windowsHide: true });
|
||||
assert.ok(code.includes('embeddedBrowser: {groups:browserProof.checks.length'));
|
||||
assert.ok(code.includes("path.join(browserProof.root,'result.json')"));
|
||||
const receipt = { success: true, scope: 'Pure string generation and syntax only; no installer built or executed', destination, sha256: createHash('sha256').update(code).digest('hex') };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-install-syntax-check.json', JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(receipt));
|
||||
@@ -0,0 +1,36 @@
|
||||
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 app = fs.readFileSync('src/server/app.mjs', 'utf8');
|
||||
const catalogStart = app.indexOf('const research = [');
|
||||
const catalogEnd = app.indexOf('\n];', catalogStart);
|
||||
assert.ok(catalogStart > 0 && catalogEnd > catalogStart);
|
||||
const reports = [...app.slice(catalogStart, catalogEnd).matchAll(/file: '([^']+)'/g)].map(match => {
|
||||
const file = 'docs/' + match[1], bytes = fs.readFileSync(file);
|
||||
return { path: file, bytes: bytes.length, sha256: hash(bytes) };
|
||||
});
|
||||
assert.equal(reports.length, 4);
|
||||
const latest = JSON.parse(fs.readFileSync('releases/latest.json'));
|
||||
const manifestFile = path.join(latest.portableRoot, 'MANIFEST.json'), bytes = fs.readFileSync(manifestFile), manifest = JSON.parse(bytes);
|
||||
const categories = new Map();
|
||||
for (const row of manifest.files) {
|
||||
const parts = row.path.replaceAll('\\', '/').split('/');
|
||||
const key = parts[0] === 'docs' ? parts.slice(0, 2).join('/') : parts[0];
|
||||
const current = categories.get(key) ?? { path: key, files: 0, bytes: 0 }; current.files++; current.bytes += row.bytes; categories.set(key, current);
|
||||
}
|
||||
const sum = rows => ({ files: rows.length, bytes: rows.reduce((total, row) => total + row.bytes, 0) });
|
||||
const result = { success: true, observedAt: new Date().toISOString(), sourceCommit: JSON.parse(fs.readFileSync('.qa/embedded-browser-b-code-baseline.json')).codeCommit,
|
||||
observedPayload: { manifestFile, manifestSha256: hash(bytes), version: manifest.version, note: 'Inventory only; this does not mean this candidate passed acceptance.' },
|
||||
all: sum(manifest.files), docs: sum(manifest.files.filter(row => row.path.startsWith('docs/'))), directlyServedResearchReports: reports,
|
||||
largestCategories: [...categories.values()].sort((a,b) => b.bytes-a.bytes).slice(0,18),
|
||||
findings: [
|
||||
'scripts/package.mjs currently copies the entire docs directory into both source and portable payloads.',
|
||||
'src/server/app.mjs directly serves four fixed research reports; this static lookup alone is insufficient to prove every other document can be omitted.',
|
||||
'src/core/initial-example-project.mjs reads examples/starter-project at initialization; keep the initial project and required build files.',
|
||||
'Installation validation enumerates and hashes every file declared in MANIFEST.json; preserve the full declared-file validation contract after splitting documentation.'
|
||||
],
|
||||
scope: 'Read-only planning inventory for PLAN-1.23. No runtime file omitted, cached verification enabled, source modified, formal credential read, or performance improvement claimed.' };
|
||||
fs.writeFileSync('.qa/embedded-browser-b-payload-analysis.json', JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
@@ -0,0 +1,24 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { fixture, launchWorkbench } from '../tests/helpers.mjs';
|
||||
import { publicSnapshot, compareOriginalState } from './embedded-browser-d-state.mjs';
|
||||
import { upgradeRunning } from '../scripts/upgrade-running.mjs';
|
||||
const read=file=>JSON.parse(fs.readFileSync(file)),prefix='.qa/embedded-browser-d-owned-upgrade-continuation';
|
||||
assert.equal(read('.qa/embedded-browser-d-upgrade-schema-diagnostic-result.json').success,true);
|
||||
assert.equal(read('.qa/embedded-browser-d-state-checks.json').success,true);
|
||||
const oldPointer=read('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/current.json');
|
||||
const oldRoot=path.join('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/versions',oldPointer.active.directory),release=read('releases/latest.json');
|
||||
const disposers=[],t={after:fn=>disposers.push(fn)},f=fixture(t);f.store.close();
|
||||
let result,before,after;
|
||||
try{
|
||||
const host=await launchWorkbench(t,f.data,{}, {appRoot:oldRoot,nodePath:path.join(oldRoot,'runtime/node.exe')});
|
||||
const member=await host.api('/model-center/connections',{name:'Owned retained credential',model:'owned-model',baseUrl:'http://127.0.0.1:1/v1',apiKey:'owned-upgrade-key',requiresKey:true});
|
||||
const pool=await host.api('/model-center/pools',{name:'Owned retained pool',members:[{connectionId:member.id}]});await host.api('/model-center/select',{type:'pool',id:pool.id});
|
||||
before=await publicSnapshot(host.url,f.data);assert.equal(before.version,'1.21.0');
|
||||
const upgraded=await upgradeRunning({url:host.url,pid:before.pid,currentRoot:oldRoot,handlerRoot:oldRoot,newRoot:release.portableRoot});assert.equal(upgraded.connectionPreserved,true);assert.equal(upgraded.verified,true);
|
||||
after=await publicSnapshot(host.url,f.data);const retained=compareOriginalState(before,after);
|
||||
assert.equal(after.version,'1.22.0');assert.equal(after.runtimeRoot,release.portableRoot);assert.equal(after.modelCenter.selected.id,pool.id);assert.equal(after.modelCenter.connections.find(row=>row.id===member.id).hasKey,true);
|
||||
result={success:true,from:'1.21.0',version:'1.22.0',retained,upgraded,before,after,realModelRequests:0,originalRejectedAttempt:'.qa/embedded-browser-d-owned-upgrade.json',scope:'New owned upgrade. Every original field/row/config/artifact is exact; only four proven empty additions to the execution view are allowed. Complete view hashes retained; original D failure unchanged. Production untouched.'};
|
||||
}catch(error){result={success:false,error:error.stack,before,after,realModelRequests:0};process.exitCode=1;}
|
||||
finally{for(const dispose of disposers.reverse())await dispose();fs.writeFileSync(prefix+'.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});console.log(JSON.stringify({success:result.success,retained:result.retained,error:result.error}));}
|
||||
@@ -0,0 +1,25 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { fixture, launchWorkbench } from '../tests/helpers.mjs';
|
||||
import { publicSnapshot, compareOriginalState } from './desktop-f-state.mjs';
|
||||
import { upgradeRunning } from '../scripts/upgrade-running.mjs';
|
||||
const oldPointer = JSON.parse(fs.readFileSync('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/current.json'));
|
||||
const oldRoot = path.join('C:/Users/wangy/AppData/Local/Programs/AgentWorkbench/versions', oldPointer.active.directory);
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json')); assert.equal(release.installer.version, '1.22.0');
|
||||
const disposers = [], t = { after: action => disposers.push(action) }, f = fixture(t); f.store.close();
|
||||
let host, result;
|
||||
try {
|
||||
host = await launchWorkbench(t, f.data, {}, { appRoot: oldRoot, nodePath: path.join(oldRoot, 'runtime/node.exe') });
|
||||
const member = await host.api('/model-center/connections', { name: 'Owned retained credential', model: 'owned-model', baseUrl: 'http://127.0.0.1:1/v1', apiKey: 'owned-upgrade-key', requiresKey: true });
|
||||
const pool = await host.api('/model-center/pools', { name: 'Owned retained pool', members: [{ connectionId: member.id }] });
|
||||
await host.api('/model-center/select', { type: 'pool', id: pool.id });
|
||||
const before = await publicSnapshot(host.url, f.data); assert.equal(before.version, '1.21.0');
|
||||
const upgraded = await upgradeRunning({ url: host.url, pid: before.pid, currentRoot: oldRoot, handlerRoot: oldRoot, newRoot: release.portableRoot });
|
||||
assert.equal(upgraded.connectionPreserved, true); assert.equal(upgraded.verified, true);
|
||||
const after = await publicSnapshot(host.url, f.data), retained = compareOriginalState(before, after);
|
||||
assert.equal(after.version, '1.22.0'); assert.equal(after.runtimeRoot, release.portableRoot);
|
||||
assert.equal(after.modelCenter.selected.id, pool.id); assert.equal(after.modelCenter.connections.find(row => row.id === member.id).hasKey, true);
|
||||
result = { success: true, from: '1.21.0', version: '1.22.0', retained, upgraded, before, after, realModelRequests: 0, scope: 'Actual old compiled host to new immutable compiled handler; own credential and pool, original PID/public config/every table/export/artifact retained. No request to model endpoint.' };
|
||||
} catch (error) { result = { success: false, error: error.stack, realModelRequests: 0 }; throw error; }
|
||||
finally { for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync('.qa/embedded-browser-d-owned-upgrade.json', JSON.stringify(result, null, 2), { flag: 'wx' }); console.log(JSON.stringify({ success: result.success, error: result.error, retained: result.retained })); }
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
const write = (file, code) => {
|
||||
fs.writeFileSync(file, code, { flag: 'wx' });
|
||||
execFileSync(process.execPath, ['--check', file], { windowsHide: true, stdio: 'pipe' });
|
||||
};
|
||||
let edge = fs.readFileSync('.qa/verify-reproducible-env-formal-ui.mjs', 'utf8')
|
||||
.replaceAll('reproducible-env', 'embedded-browser').replaceAll('1.21.0', '1.22.0');
|
||||
const edgeAnchor = " const plan = page.getByLabel('执行计划', { exact: true }); await expect(plan).toBeVisible();";
|
||||
assert.ok(edge.includes(edgeAnchor));
|
||||
edge = edge.replace(edgeAnchor, ` await page.locator('.inspector-tabs').getByRole('button', { name: '浏览', exact: true }).click();
|
||||
const browsing = page.getByRole('region', { name: '内置浏览器', exact: true });
|
||||
await expect(browsing.getByRole('heading', { name: '在任务旁核对真实页面', exact: true })).toBeVisible();
|
||||
await expect(browsing).toContainText('桌面浏览器未连接');
|
||||
await expect(browsing.getByRole('button', { name: '打开目标', exact: true })).toBeEnabled();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '内置浏览器网页只读入口及桌面连接提示', readOnly: true, ...await screenshot(page, 'browser-entry-' + width + '.png') });
|
||||
await browsing.getByRole('button', { name: '返回任务', exact: true }).click();
|
||||
` + edgeAnchor);
|
||||
edge = edge.replace('console.log(JSON.stringify({ width, passedPanels: 13 }));', 'console.log(JSON.stringify({ width, passedPanels: results.filter(row => row.width === width).length }));');
|
||||
write('.qa/verify-embedded-browser-formal-ui.mjs', edge);
|
||||
let native = fs.readFileSync('.qa/verify-reproducible-env-native-ui.mjs', 'utf8')
|
||||
.replaceAll('reproducible-env', 'embedded-browser').replaceAll('1.21.0', '1.22.0');
|
||||
const nativeAnchor = " await capture(page,label+'-environment-entry');";
|
||||
assert.ok(native.includes(nativeAnchor));
|
||||
native = native.replace(nativeAnchor, nativeAnchor + `
|
||||
await page.locator('.inspector-tabs').getByRole('button', { name: '浏览', exact: true }).click();
|
||||
const browsing = page.getByRole('region', { name: '内置浏览器', exact: true });
|
||||
await expect(browsing.getByRole('heading', { name: '在任务旁核对真实页面', exact: true })).toBeVisible();
|
||||
if (label.startsWith('electron-')) await expect(browsing).not.toContainText('桌面浏览器未连接');
|
||||
else await expect(browsing).toContainText('桌面浏览器未连接');
|
||||
await expect(browsing.getByRole('button', { name: '打开目标', exact: true })).toBeEnabled();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
await capture(page, label + '-browser-entry');
|
||||
await browsing.getByRole('button', { name: '返回任务', exact: true }).click();
|
||||
`);
|
||||
native = native.replace('saveFullyReachable: true, submitted: false', "saveFullyReachable: true, browserEntryObserved: true, desktopBrowserConnected: label.startsWith('electron-'), submitted: false");
|
||||
write('.qa/verify-embedded-browser-native-ui.mjs', native);
|
||||
console.log(JSON.stringify({ success: true, scripts: ['.qa/verify-embedded-browser-formal-ui.mjs', '.qa/verify-embedded-browser-native-ui.mjs'], executedFormalHost: false }));
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import fs from 'node:fs';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
let code = fs.readFileSync('.qa/reproducible-env-c-promotion.mjs', 'utf8')
|
||||
.replaceAll('reproducible-env-c', 'embedded-browser').replaceAll('1.21.0', '1.22.0')
|
||||
.replaceAll('candidate C', 'candidate 1.22');
|
||||
fs.writeFileSync('.qa/embedded-browser-promotion.mjs', code, { flag: 'wx' });
|
||||
execFileSync(process.execPath, ['--check', '.qa/embedded-browser-promotion.mjs'], { windowsHide: true, stdio: 'pipe' });
|
||||
console.log(JSON.stringify({ success: true, action: 'Prepared gated promotion; not executed' }));
|
||||
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { randomUUID, createHash } from 'node:crypto';
|
||||
import { buildWindowsInstaller } from '../scripts/build-installer.mjs';
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json', 'utf8')); assert.equal(release.installer.version, '1.22.0');
|
||||
const appId = randomUUID(), destination = '.qa/embedded-browser-d-qa-installer.json'; assert.equal(fs.existsSync(destination), false);
|
||||
const installer = buildWindowsInstaller({ root: process.cwd(), portableRoot: release.portableRoot, outputRoot: path.resolve('.qa'),
|
||||
name: 'embedded-browser-installer-qa-' + appId, qaFixture: { appId, fault: 'none' } });
|
||||
const source = fs.readFileSync(installer.source, 'utf8'), product = fs.readFileSync(release.installer.source, 'utf8');
|
||||
const body = value => value.split('\n').filter(line => !line.startsWith('#define OutputRoot ') && !line.startsWith('#define OutputName ')).join('\n');
|
||||
assert.equal(body(source).replaceAll(appId, 'E914E883-46F9-4B82-B27F-BDB2B40DCC90')
|
||||
.replace('DefaultGroupName=Agent Workbench QA E914E883-46F9-4B82-B27F-BDB2B40DCC90', 'DefaultGroupName=Agent Workbench'), body(product));
|
||||
fs.writeFileSync(destination, JSON.stringify({ ...installer, productSetup: release.installer,
|
||||
samePayloadManifestSha256: createHash('sha256').update(fs.readFileSync(path.join(release.portableRoot, 'MANIFEST.json'))).digest('hex'),
|
||||
sourceComparison: 'Only isolated QA AppId/group and output destination/name differ; entire product payload and installation behavior are exact. Product setup will separately stage the existing formal installation.' }, null, 2) + '\n', { flag: 'wx' });
|
||||
let code = fs.readFileSync('.qa/verify-desktop-f-canonical-storage-guard-install.mjs', 'utf8');
|
||||
for (const [before, after] of [['desktop-host-f-canonical-storage-guard-qa-installer.json', 'embedded-browser-d-qa-installer.json'],
|
||||
['desktop-host-f-canonical-storage-install-location.json', 'embedded-browser-d-install-location.json'],
|
||||
['ff4e7d22-f233-4021-829a-6f5c71933c46', appId], ['1.15.0', '1.22.0'], ['AWQA15', 'AWQA22DI'], ['timeout = 300000', 'timeout = 900000']]) {
|
||||
assert.ok(code.includes(before), before); code = code.replaceAll(before, after);
|
||||
}
|
||||
const nativeSpawn = " const chunks = [], child = spawn(binary, args, { cwd: path.dirname(binary), env, windowsHide: true, stdio: bootstrap ? 'ignore' : ['ignore', 'pipe', 'pipe'] });";
|
||||
assert.ok(code.includes(nativeSpawn));
|
||||
code = code.replace(nativeSpawn, " const nativeOutput = bootstrap ? fs.openSync(path.join(root, label + '-native-output.txt'), 'wx') : null;\n const chunks = [], child = spawn(binary, args, { cwd: path.dirname(binary), env, windowsHide: true, stdio: bootstrap ? ['ignore', nativeOutput, nativeOutput] : ['ignore', 'pipe', 'pipe'] });\n if (nativeOutput !== null) fs.closeSync(nativeOutput);");
|
||||
|
||||
const checkAnchor=" record(stage, { sessionId: session.id, originalApprovalId: approval.id, checkId, actualTests: checked.results[0].tests, originalLogArtifactId: checked.results[0].logArtifactId });";
|
||||
assert.ok(code.includes(checkAnchor));
|
||||
const installedCheck=String.raw`
|
||||
const browserLog=path.join(root,'installed-browser.log'),browserStream=fs.createWriteStream(browserLog,{flags:'wx'});
|
||||
const browserChild=spawn(process.execPath,['scripts/verify-embedded-browser.mjs','--app-root',candidate],{cwd:process.cwd(),env,windowsHide:true,stdio:['ignore','pipe','pipe']});
|
||||
browserChild.stdout.pipe(browserStream,{end:false});browserChild.stderr.pipe(browserStream,{end:false});
|
||||
const browserExit=await new Promise((resolve,reject)=>{browserChild.once('error',reject);browserChild.once('close',resolve);});await new Promise(resolve=>browserStream.end(resolve));
|
||||
assert.equal(browserExit,0,'Actual installed browser verifier failed: '+browserLog);
|
||||
const browserProof=JSON.parse(fs.readFileSync('.qa/embedded-browser-latest.json'));assert.equal(browserProof.success,true);assert.equal(browserProof.appRoot,candidate);assert.equal(browserProof.checks.length,17);assert.equal(browserProof.realModelRequests,0);
|
||||
`;
|
||||
code=code.replace(checkAnchor,installedCheck+checkAnchor.replace('actualTests: checked.results[0].tests,','actualTests: checked.results[0].tests, embeddedBrowser: {groups:browserProof.checks.length,directory:browserProof.root,resultSha256:hash(fs.readFileSync(path.join(browserProof.root,\'result.json\'))),log:browserLog,logSha256:hash(fs.readFileSync(browserLog))},'));
|
||||
|
||||
fs.writeFileSync('.qa/verify-embedded-browser-d-install.mjs', code, { flag: 'wx' });
|
||||
console.log(JSON.stringify({ success: true, appId, installerSha256: installer.sha256, productSetupSha256: release.installer.sha256, samePayload: true }));
|
||||
@@ -0,0 +1,53 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
let code=fs.readFileSync('scripts/verify-source-package.mjs','utf8').replaceAll('\r\n','\n');
|
||||
const insertion = String.raw`
|
||||
const inheritedRoot = path.join(workspace,'docs/embedded-browser-c-rejected-candidate-evidence');
|
||||
const inheritedManifest = JSON.parse(fs.readFileSync(path.join(inheritedRoot,'manifest.json')));
|
||||
const inheritedBaseline = JSON.parse(fs.readFileSync(path.join(inheritedRoot,'receipts/code-baseline.json')));
|
||||
assert.equal(inheritedManifest.sourceOverallSuccess,false);
|
||||
assert.deepEqual(inheritedManifest.tests,{tests:683,pass:683,fail:0,cancelled:0,skipped:0,todo:0});
|
||||
const originalInputs = new Map(inheritedBaseline.inputs.map(row=>[row.path,row]));
|
||||
assert.equal(inputs.length,originalInputs.size);
|
||||
const changed = inputs.filter(row=>{
|
||||
const old=originalInputs.get(row.path);assert.ok(old,row.path);return old.bytes!==row.bytes||old.sha256!==row.sha256;
|
||||
}).map(row=>row.path).sort();
|
||||
assert.deepEqual(changed,['.gitattributes','scripts/desktop-project-qa.mjs']);
|
||||
for(const row of inputs.filter(row=>row.path.startsWith('tests/'))){
|
||||
const text=fs.readFileSync(path.join(sourceRoot,row.path),'utf8');
|
||||
assert.ok(!/desktop-project-qa|verify-controlled-projects/.test(text),'Tests must not read the changed desktop QA helper: '+row.path);
|
||||
}
|
||||
const inheritedRows=[];
|
||||
const inheritance={success:false,sourceCommit:inheritedManifest.sourceCommit,sourceOverallSuccess:false,changedInputs:changed,tests:inheritedManifest.tests,originalManifestSha256:digest(path.join(inheritedRoot,'manifest.json')),logs:inheritedRows,
|
||||
scope:'Only the complete passing C source-test stage is inherited after every source/test/dependency/compiler input and test-used script is exact. C overall remains failed at a later desktop helper. D independently installs/builds and runs runtime, desktop and all engineering gates. No test result rewritten or executed twice.'};
|
||||
function inheritedTest(args,logName){
|
||||
if(!/^(?:tests-\d+|upgrade-tests)\.tap$/.test(logName))return null;
|
||||
const declared=inheritedManifest.files.find(row=>row.path==='source/'+logName);assert.ok(declared,logName);
|
||||
const original=path.join(inheritedRoot,declared.path),bytes=fs.readFileSync(original);
|
||||
assert.equal(bytes.length,declared.bytes);assert.equal(digest(original),declared.sha256);
|
||||
const text=bytes.toString('utf8');
|
||||
const counts=Object.fromEntries([...text.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(row=>[row[1],Number(row[2])]));
|
||||
assert.ok(counts.tests>0);assert.equal(counts.tests,counts.pass);for(const key of ['fail','cancelled','skipped','todo'])assert.equal(counts[key],0);
|
||||
const oldPlan=JSON.parse(fs.readFileSync(path.join(inheritedRoot,'source/test-plan.json')));
|
||||
const newPlan=JSON.parse(fs.readFileSync(path.join(directory,'test-plan.json')));assert.deepEqual(newPlan,oldPlan);
|
||||
const output=path.join(directory,logName);fs.writeFileSync(output,bytes,{flag:'wx'});
|
||||
const row={stage,path:output,sha256:declared.sha256,bytes:declared.bytes,inheritedFrom:original,sourceCommit:inheritedManifest.sourceCommit};logs.push(row);inheritedRows.push({...row,args,counts});
|
||||
console.log('Source package: '+stage+' [exact passing C log inherited; no replay]');
|
||||
if(logName==='upgrade-tests.tap'){
|
||||
assert.equal(inheritedRows.length,12);assert.equal(inheritedRows.reduce((sum,row)=>sum+row.counts.tests,0),683);inheritance.success=true;
|
||||
fs.writeFileSync(path.join(workspace,'.qa/embedded-browser-d-source-test-inheritance.json'),JSON.stringify(inheritance,null,2)+'
|
||||
',{flag:'wx'});
|
||||
}
|
||||
return text.slice(-12000);
|
||||
}
|
||||
`;
|
||||
// Keep actual newlines in the generated JS string literal escaped.
|
||||
const fixedInsertion=insertion.replace("JSON.stringify(inheritance,null,2)+'\n'", "JSON.stringify(inheritance,null,2)+'\\n'");
|
||||
assert.ok(code.includes('const logs = [];'));
|
||||
code=code.replace('const logs = [];','const logs = [];\n'+fixedInsertion);
|
||||
code=code.replace('function run(args, logName) {','function run(args, logName) {\n const inherited=inheritedTest(args,logName);if(inherited!==null)return Promise.resolve(inherited);');
|
||||
code=code.replace('tests: stats, testPlan, actualEmbeddedBrowser','tests: stats, inheritedTests: inheritance, testPlan, actualEmbeddedBrowser');
|
||||
const output='.qa/verify-embedded-browser-d-source.mjs';fs.writeFileSync(output,code,{flag:'wx'});
|
||||
execFileSync(process.execPath,['--check',output],{stdio:'pipe',windowsHide:true});
|
||||
console.log(JSON.stringify({success:true,output,scope:'Exact-input source-test inheritance only; independent install/build/runtime and repaired desktop gates remain executable.'}));
|
||||
@@ -0,0 +1,36 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import {spawn} from 'node:child_process';
|
||||
import {createHash} from 'node:crypto';
|
||||
import {projectEnvironment} from '../src/core/process-environment.mjs';
|
||||
|
||||
const prefix='.qa/embedded-browser-d-',read=file=>JSON.parse(fs.readFileSync(file,'utf8'));
|
||||
const save=(file,value)=>fs.writeFileSync(file,JSON.stringify(value,null,2)+'\n',{flag:'wx'});
|
||||
const hash=bytes=>createHash('sha256').update(bytes).digest('hex'),completed=[];
|
||||
console.log('Waiting for the immutable candidate 1.22 independent source/portable/install pipeline.');
|
||||
let result;
|
||||
async function run(name,args,proof){
|
||||
console.log('START '+name+' '+new Date().toISOString());
|
||||
const log=prefix+name+'.log';assert.equal(fs.existsSync(log),false);
|
||||
const stream=fs.createWriteStream(log,{flags:'wx'}),child=spawn(process.execPath,args,{windowsHide:true,env:projectEnvironment(),stdio:['ignore','pipe','pipe']});
|
||||
let tail='';const capture=bytes=>{stream.write(bytes);tail=(tail+bytes.toString('utf8')).slice(-12000);};child.stdout.on('data',capture);child.stderr.on('data',capture);
|
||||
const exitCode=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',resolve);});await new Promise(resolve=>stream.end(resolve));
|
||||
const receipt={name,exitCode,log,logSha256:hash(fs.readFileSync(log)),finishedAt:new Date().toISOString()};
|
||||
if(proof&&fs.existsSync(proof)){receipt.proof=proof;receipt.proofSha256=hash(fs.readFileSync(proof));}
|
||||
save(prefix+name+'-outer-receipt.json',receipt);
|
||||
assert.equal(exitCode,0,name+' failed; preserve original phase and do not replay.\n'+tail);
|
||||
if(proof)assert.equal(read(proof).success,true);completed.push(receipt);console.log('PASS '+name);
|
||||
}
|
||||
try{
|
||||
while(!fs.existsSync(prefix+'independent-continuation-result.json'))await new Promise(resolve=>setTimeout(resolve,2000));
|
||||
const verified=read(prefix+'independent-continuation-result.json');assert.equal(verified.success,true,'Independent pipeline failed. Formal deployment is forbidden.');
|
||||
assert.equal(verified.version,'1.22.0');assert.equal(verified.release.installer.sha256,read('releases/latest.json').installer.sha256);
|
||||
assert.equal(read(prefix+'vendor-runtime-binding.json').success,true);
|
||||
await run('bind-package',['.qa/embedded-browser-d-bind-package.mjs'],prefix+'package-binding.json');
|
||||
for(const phase of ['stage','upgrade','activate','verify'])await run('formal-'+phase,['.qa/embedded-browser-d-formal.mjs',phase],prefix+'formal-'+phase+'.json');
|
||||
await run('formal-full-ui',['.qa/verify-embedded-browser-d-formal-ui.mjs'],'.qa/embedded-browser-d-formal-ui-validation.json');
|
||||
await run('formal-native-ui',['.qa/verify-embedded-browser-d-native-ui.mjs'],'.qa/embedded-browser-d-native-ui.json');
|
||||
result={success:true,version:'1.22.0',completed,finishedAt:new Date().toISOString(),realModelRequests:0,
|
||||
scope:'Proceed only after complete independent source/portable/same-payload install verification. Every formal phase runs once, with original PID/Provider/state gates. UI actions are read-only.'};
|
||||
}catch(error){result={success:false,completed,error:error.stack,finishedAt:new Date().toISOString()};process.exitCode=1;}
|
||||
save(prefix+'promotion-result.json',result);console.log(JSON.stringify({success:result.success,completed:completed.map(row=>row.name),error:result.error}));
|
||||
@@ -0,0 +1,5 @@
|
||||
import fs from 'node:fs';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 old=read('.qa/embedded-browser-b-legacy-report-retention.json');assert.equal(old.success,true);assert.equal(hash(fs.readFileSync(old.file)),old.historicalSha256);
|
||||
const result={...old,inheritedReceipt:'.qa/embedded-browser-b-legacy-report-retention.json',scope:'No legacy report rewrite: C reuses the original B UI results, and the restored historical report remains exact.'};
|
||||
fs.writeFileSync('.qa/embedded-browser-d-legacy-report-retention.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});console.log(JSON.stringify(result));
|
||||
@@ -0,0 +1,31 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
const prefix='.qa/embedded-browser-d-',read=file=>JSON.parse(fs.readFileSync(file));
|
||||
const independent=read(prefix+'independent-continuation-result.json'),promotion=read(prefix+'promotion-result.json');
|
||||
assert.equal(independent.success,true);assert.equal(promotion.success,true);
|
||||
const consoleBytes=Buffer.concat([fs.readFileSync(prefix+'independent-console.log'),Buffer.from('\n'),fs.readFileSync(prefix+'independent-continuation-console.log')]);
|
||||
const consoleEncoding=consoleBytes[0]===0xff&&consoleBytes[1]===0xfe?'utf16le':'utf8';
|
||||
const consoleLines=(consoleEncoding==='utf16le'?consoleBytes.subarray(2):consoleBytes).toString(consoleEncoding).replace(/^\uFEFF/,'').split(/\r?\n/);
|
||||
const pipeline=independent.completed.map(row=>{
|
||||
const start=consoleLines.find(line=>line.startsWith('START '+row.name+' '));assert.ok(start);
|
||||
const startedAt=start.slice(('START '+row.name+' ').length),durationMs=Date.parse(row.finishedAt)-Date.parse(startedAt);assert.ok(durationMs>=0);
|
||||
return {name:row.name,startedAt,finishedAt:row.finishedAt,durationMs};
|
||||
});
|
||||
const formal=['stage','upgrade','activate','verify'].map(name=>{
|
||||
const row=read(prefix+'formal-'+name+'.json');assert.equal(row.success,true);
|
||||
return {name,startedAt:row.startedAt,finishedAt:row.finishedAt,durationMs:Date.parse(row.finishedAt)-Date.parse(row.startedAt)};
|
||||
});
|
||||
const manifestFile=path.join(independent.release.portableRoot,'MANIFEST.json'),manifestBytes=fs.readFileSync(manifestFile),manifest=JSON.parse(manifestBytes);
|
||||
const sum=rows=>({files:rows.length,bytes:rows.reduce((total,row)=>total+row.bytes,0)});
|
||||
const source=read(prefix+'source-original-result.json');
|
||||
const testBatches=source.logs.filter(row=>/\b(?:tests-\d+|upgrade-tests)\.tap$/.test(row.path)).map(row=>{
|
||||
const text=fs.readFileSync(row.path,'utf8'),duration=Number(text.match(/^# duration_ms ([\d.]+)\s*$/m)?.[1]);assert.ok(Number.isFinite(duration));
|
||||
return {log:row.path,durationMs:duration,tests:Number(text.match(/^# tests (\d+)\s*$/m)?.[1]),pass:Number(text.match(/^# pass (\d+)\s*$/m)?.[1])};
|
||||
});
|
||||
const result={success:true,version:'1.22.0',createdAt:new Date().toISOString(),consoleEncoding,pipeline,formal,testBatches,
|
||||
payload:{manifestSha256:createHash('sha256').update(manifestBytes).digest('hex'),all:sum(manifest.files),docs:sum(manifest.files.filter(row=>row.path.startsWith('docs/')))},
|
||||
scope:'Observed phase wall-clock times, original TAP durations and immutable manifest byte totals. No directory-level runtime attribution or claimed performance improvement; original development failures remain separate.'};
|
||||
fs.writeFileSync(prefix+'timing-review.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'});
|
||||
console.log(JSON.stringify({success:true,formal,payload:result.payload,testBatches:testBatches.length}));
|
||||
@@ -0,0 +1,187 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash } from 'node:crypto';
|
||||
const prefix = '.qa/embedded-browser-d-', root = 'docs/embedded-browser-release-evidence';
|
||||
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
const independent = read(prefix + 'independent-continuation-result.json'), binding = read(prefix + 'package-binding.json');
|
||||
const allUi = read(prefix + 'all-ui-original-result.json'), source = read(prefix + 'source-original-result.json');
|
||||
const formal = read(prefix + 'formal-verify.json'), native = read(prefix + 'native-ui.json');
|
||||
const ui = read(prefix + 'formal-ui-validation.json'), promotion = read(prefix + 'promotion-result.json');
|
||||
const nativeBinding = read(prefix + 'native-input-binding.json');
|
||||
for (const value of [independent, binding, allUi, source, formal, native, ui, promotion]) assert.equal(value.success, true);
|
||||
assert.equal(independent.version, '1.22.0'); assert.equal(independent.codeCommit, binding.sourceCommit);
|
||||
assert.equal(independent.release.installer.sha256, binding.setupSha256);
|
||||
assert.equal(allUi.results.length, 33); assert.equal(allUi.groups, allUi.results.reduce((sum, row) => sum + row.groups, 0));
|
||||
assert.equal(source.tests.tests, source.tests.pass);
|
||||
for (const name of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(source.tests[name], 0);
|
||||
assert.equal(source.actualEmbeddedBrowser.checks.length, 17);
|
||||
assert.equal(native.actualInstalledElectron, true); assert.equal(native.results.length, 4);
|
||||
assert.equal(nativeBinding.success, true); assert.equal(nativeBinding.sourceCommit, binding.sourceCommit); assert.deepEqual(nativeBinding.differences, []);
|
||||
assert.equal(fs.existsSync(root), false);
|
||||
const files = [], pending = [], appendedLogs = [];
|
||||
function copy(from, to, expectedSha = null) {
|
||||
assert.ok(!/\.sqlite(?:-|$)/i.test(from), 'Private SQLite excluded');
|
||||
assert.ok(!/formal-(?:before|after-|original-pointer|original\.sqlite)/i.test(path.basename(from)), 'Private full production snapshots excluded');
|
||||
assert.ok(!files.some(row => row.path === to), 'Duplicate evidence target ' + to);
|
||||
const bytes = fs.readFileSync(from); if (expectedSha) assert.equal(hash(bytes), expectedSha, from);
|
||||
files.push({ path: to, source: from, bytes: bytes.length, sha256: hash(bytes) });
|
||||
pending.push({ target: path.join(root, to), bytes });
|
||||
}
|
||||
function receiptLog(from, to, expectedSha) {
|
||||
const bytes = fs.readFileSync(from); if (hash(bytes) === expectedSha) { copy(from, to, expectedSha); return; }
|
||||
const streaming = createHash('sha256'); let offset = 0, original = null;
|
||||
for (let end = bytes.indexOf(10); end >= 0 && !original; end = bytes.indexOf(10, end + 1)) {
|
||||
for (const cut of [end + 1, ...(bytes[end + 1] === 0 ? [end + 2] : [])]) {
|
||||
streaming.update(bytes.subarray(offset, cut)); offset = cut;
|
||||
if (streaming.copy().digest('hex') === expectedSha) { original = bytes.subarray(0, cut); break; }
|
||||
}
|
||||
}
|
||||
assert.ok(original, 'Changed log must preserve complete original receipt prefix: ' + from);
|
||||
const target = to + '.receipt-prefix';
|
||||
assert.ok(!files.some(row => row.path === target));
|
||||
files.push({ path: target, source: from + ' [exact original receipt prefix]', bytes: original.length, sha256: expectedSha });
|
||||
pending.push({ target: path.join(root, target), bytes: original }); copy(from, to);
|
||||
appendedLogs.push({ source: from, originalReceiptSha256: expectedSha, originalBytes: original.length, completeBytes: bytes.length, completeSha256: hash(bytes), appendedBytes: bytes.length - original.length });
|
||||
}
|
||||
const suites = new Map();
|
||||
function archiveUi(name, value, hintDirectory = null) {
|
||||
assert.ok(value); assert.notEqual(value.success, false); assert.notEqual(value.passed, false);
|
||||
const screenshotRows = Array.isArray(value.screenshots) ? value.screenshots : [];
|
||||
const firstScreenshot = screenshotRows[0];
|
||||
const firstFile = typeof firstScreenshot === 'string' ? firstScreenshot : firstScreenshot?.file ?? firstScreenshot?.path ?? firstScreenshot?.screenshot;
|
||||
const explicitDirectory = value.directory ?? hintDirectory ?? value.root;
|
||||
const directory = explicitDirectory ?? (firstFile && fs.existsSync(firstFile) ? path.dirname(firstFile) : null);
|
||||
if (!directory) return;
|
||||
const actual = fs.realpathSync.native(directory);
|
||||
if (suites.has(name)) return;
|
||||
suites.set(name, actual);
|
||||
const original = path.join(directory, 'result.json');
|
||||
if (explicitDirectory && fs.existsSync(original)) { assert.deepEqual(read(original), value); copy(original, name + '/result.json'); }
|
||||
for (const row of screenshotRows) {
|
||||
const declared = typeof row === 'string' ? row : row.file ?? row.path ?? row.screenshot;
|
||||
if (!declared) continue;
|
||||
const file = fs.existsSync(declared) ? declared : path.join(directory, declared);
|
||||
assert.ok(fs.existsSync(file), 'Original UI screenshot required: ' + file);
|
||||
copy(file, name + '/' + path.basename(file), row.sha256 ?? row.screenshotSha256);
|
||||
}
|
||||
for (const entry of explicitDirectory ? fs.readdirSync(directory, { withFileTypes: true }) : []) {
|
||||
if (!entry.isFile() || !/\.(?:png|jpg|html)$/.test(entry.name)) continue;
|
||||
const target = name + '/' + entry.name;
|
||||
if (!files.some(row => row.path === target)) copy(path.join(directory, entry.name), target);
|
||||
}
|
||||
const inputs = path.join(directory, 'inputs.json'); if (explicitDirectory && fs.existsSync(inputs)) copy(inputs, name + '/inputs.json');
|
||||
}
|
||||
for (const name of ['code-baseline', 'independent-result', 'independent-continuation-result', 'continuation-stage-binding', 'package-binding', 'source-short-path', 'source-original-result', 'archives-original-result', 'portable-original-result', 'owned-upgrade', 'owned-upgrade-continuation', 'promotion-result', 'formal-stage', 'formal-upgrade', 'formal-activate', 'formal-verify', 'install-syntax-check', 'legacy-report-retention', 'native-input-binding', 'ui-evidence-preflight']) copy(prefix + name + '.json', 'receipts/' + name + '.json');
|
||||
for (const row of independent.completed) {
|
||||
assert.equal(row.exitCode, 0); copy(row.logPath, 'pipeline/' + path.basename(row.logPath), row.logSha256);
|
||||
copy(prefix + row.name + '-receipt.json', 'receipts/' + row.name + '-receipt.json');
|
||||
}
|
||||
for (const row of promotion.completed) {
|
||||
assert.equal(row.exitCode, 0); copy(row.log, 'promotion/' + path.basename(row.log), row.logSha256);
|
||||
copy(prefix + row.name + '-outer-receipt.json', 'receipts/' + row.name + '-outer-receipt.json');
|
||||
}
|
||||
for (const row of source.logs) { assert.equal(fs.statSync(row.path).size, row.bytes); copy(row.path, 'source/' + path.basename(row.path), row.sha256); }
|
||||
assert.deepEqual(source.testPlan.flatMap(row => row.files).slice().sort(), fs.readdirSync(path.join(source.sourceRoot, 'tests')).filter(name => name.endsWith('.test.mjs')).sort());
|
||||
copy(path.join(source.directory, 'test-plan.json'), 'source/test-plan.json');
|
||||
copy(prefix + 'all-ui-original-result.json', 'historical-ui/result.json');
|
||||
for (const row of allUi.results) {
|
||||
const name = path.basename(row.script, '.mjs'); copy(row.evidence, 'historical-ui/' + name + '.json'); copy(row.log, 'historical-ui/' + name + '.log');
|
||||
const value = read(row.evidence), output = fs.readFileSync(row.log, 'utf8');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim() ?? null;
|
||||
archiveUi('historical-ui/' + name, value, location);
|
||||
}
|
||||
for (const name of ['embedded-browser', 'environment', 'fidelity', 'wait', 'companion', 'protocols', 'vision', 'cache', 'evaluations']) {
|
||||
const proof = read(prefix + 'portable-' + name + '-validated.json'); assert.equal(proof.success, true);
|
||||
assert.equal(hash(fs.readFileSync(path.join(proof.directory, 'result.json'))), proof.resultSha256);
|
||||
copy(prefix + 'portable-' + name + '-validated.json', 'receipts/portable-' + name + '-validated.json');
|
||||
archiveUi('portable-' + name, read(path.join(proof.directory, 'result.json')));
|
||||
}
|
||||
for (const [name, value] of [['source-browser', source.actualEmbeddedBrowser], ['source-environment', source.actualEnvironment], ['source-companion', source.actualCompanion], ['source-protocols', source.actualProtocols], ['source-vision', source.actualVision], ['source-cache', source.actualProjectCache], ['source-evaluations', source.actualEvaluations]]) archiveUi(name, value);
|
||||
for (const [name, value] of [['formal-ui', ui], ['native-ui', native]]) {
|
||||
copy(prefix + (name === 'formal-ui' ? 'formal-ui-validation' : 'native-ui') + '.json', name + '/result.json');
|
||||
for (const row of value.screenshots ?? value.results) {
|
||||
const file = row.file ?? row.path ?? row.screenshot;
|
||||
if (file) copy(file, name + '/' + path.basename(file), row.sha256 ?? row.screenshotSha256);
|
||||
}
|
||||
}
|
||||
const installation = read(prefix + 'install-location.json'), installed = read(installation.result);
|
||||
assert.equal(installed.success, true); assert.equal(installed.cases.length, 7); copy(installation.result, 'installation/result.json');
|
||||
copy(prefix + 'qa-installer.json', 'installation/same-payload-installer.json');
|
||||
for (const [index, row] of installed.cases.entries()) {
|
||||
for (const key of ['processLog', 'setupLog', 'uninstallLog']) if (row[key]) receiptLog(row[key], 'installation/logs/' + String(index).padStart(2, '0') + '-' + path.basename(row[key]), row[key + 'Sha256']);
|
||||
if (row.embeddedBrowser) {
|
||||
assert.equal(row.embeddedBrowser.groups, 17);
|
||||
assert.equal(hash(fs.readFileSync(path.join(row.embeddedBrowser.directory, 'result.json'))), row.embeddedBrowser.resultSha256);
|
||||
copy(row.embeddedBrowser.log, 'installation/actual-browser.log', row.embeddedBrowser.logSha256);
|
||||
archiveUi('installed-browser', read(path.join(row.embeddedBrowser.directory, 'result.json')));
|
||||
}
|
||||
}
|
||||
assert.ok(installed.cases.some(row => row.embeddedBrowser?.groups === 17));
|
||||
const staged = read(prefix + 'formal-stage.json'); receiptLog(staged.setupLog, 'promotion/formal-setup.log', staged.setupLogSha256);
|
||||
for (const name of ['independent', 'independent-continuation', 'continuation-orchestrate', 'state', 'owned-upgrade-continuation', 'prepare-installer', 'bind-package', 'bind-native-review', 'owned-upgrade', 'formal', 'promotion', 'install-syntax-check', 'retain-legacy-report', 'review-timings', 'finalize-docs', 'final-audit', 'status', 'ui-evidence-preflight']) {
|
||||
const file = name === 'retain-legacy-report' ? '.qa/retain-embedded-browser-d-legacy-report.mjs' : prefix + name + '.mjs';
|
||||
copy(file, 'verifiers/' + name + '.mjs');
|
||||
}
|
||||
for (const name of ['prepare-embedded-browser-formal-ui', 'prepare-embedded-browser-promotion', 'verify-embedded-browser-d-formal-ui', 'verify-embedded-browser-d-native-ui', 'verify-embedded-browser-d-install', 'desktop-f-state', 'seal-embedded-browser-d-release']) copy('.qa/' + name + '.mjs', 'verifiers/' + name + '.mjs');
|
||||
copy(prefix + 'source-test-inheritance.json','review/source-test-inheritance.json');
|
||||
copy('.qa/verify-embedded-browser-d-state.mjs','verifiers/verify-state.mjs');
|
||||
copy(prefix+'state-checks.json','review/state-checks.json');
|
||||
const rejectedAcceptance=prefix+'rejected-acceptance';
|
||||
copy(rejectedAcceptance+'/manifest.json','review/d-rejected-acceptance/manifest.json');
|
||||
for(const row of read(rejectedAcceptance+'/manifest.json').files)copy(path.join(rejectedAcceptance,row.path),'review/d-rejected-acceptance/'+row.path,row.sha256);
|
||||
const continuationPreflight=prefix+'continuation-preflight-rejected';
|
||||
copy(continuationPreflight+'/manifest.json','review/continuation-preflight-rejected/manifest.json');
|
||||
for(const row of read(continuationPreflight+'/manifest.json').files)copy(path.join(continuationPreflight,row.path),'review/continuation-preflight-rejected/'+row.path,row.sha256);
|
||||
const preflightRoot=prefix+'preflight-rejected';
|
||||
copy(preflightRoot+'/manifest.json','review/preflight-rejected/manifest.json');
|
||||
for(const row of read(preflightRoot+'/manifest.json').files)copy(path.join(preflightRoot,row.path),'review/preflight-rejected/'+row.path,row.sha256);
|
||||
copy('.qa/verify-embedded-browser-d-source.mjs','verifiers/verify-source-with-bound-tests.mjs');
|
||||
copy('.qa/prepare-embedded-browser-d-source.mjs','verifiers/prepare-source-with-bound-tests.mjs');
|
||||
copy(prefix + 'inherited-ui.json','review/inherited-ui.json');
|
||||
copy('.qa/embedded-browser-c-b-git-evidence.json','review/b-git-evidence.json');
|
||||
copy(prefix + 'vendor-runtime-binding.json','review/vendor-runtime-binding.json');
|
||||
copy(prefix + 'bind-vendor-runtime.mjs','verifiers/bind-vendor-runtime.mjs');
|
||||
copy(prefix + 'vendor-runtime-initial-review.json','review/vendor-runtime-initial-review.json');
|
||||
copy(path.join(read('docs/embedded-browser-b-rejected-candidate-evidence/release.json').portableRoot,'runtime/REA-RUNTIME.json'),'review/rea-runtime-B.json',read(prefix + 'vendor-runtime-binding.json').onlyDescriptorDifference.beforeSha256);
|
||||
copy(path.join(independent.release.portableRoot,'runtime/REA-RUNTIME.json'),'review/rea-runtime-D.json',read(prefix + 'vendor-runtime-binding.json').onlyDescriptorDifference.afterSha256);
|
||||
copy('.qa/embedded-browser-c-bind-vendor-runtime.before-timestamp-review.mjs','verifiers/bind-vendor-runtime.before-timestamp-review.mjs');
|
||||
copy('.qa/embedded-browser-c-audit-b-git.mjs','verifiers/audit-b-git.mjs');
|
||||
copy(prefix + 'inherit-ui.mjs','verifiers/inherit-ui.mjs');
|
||||
copy('.qa/embedded-browser-c-http-fix-result.json','review/http-fix-result.json');
|
||||
copy('.qa/embedded-browser-c-http-fix.tap','review/http-fix.tap');
|
||||
copy('.qa/embedded-browser-c-workers-http-before.mjs','review/workers-http-before.mjs');
|
||||
copy('.qa/verify-embedded-browser-c-http-fix.mjs','verifiers/http-fix.mjs');
|
||||
copy(prefix + 'timing-review.json', 'review/timing-review.json');
|
||||
copy('.qa/embedded-browser-b-payload-analysis.json', 'review/next-payload-analysis.json');
|
||||
copy('.qa/embedded-browser-b-payload-analysis.mjs', 'verifiers/next-payload-analysis.mjs');
|
||||
copy(prefix + 'finalization.mjs', 'verifiers/finalization.mjs');
|
||||
const before = read(prefix + 'formal-before.json'), after = read(prefix + 'formal-after-verify.json'), backup = read(prefix + 'formal-private-backup-receipt.json');
|
||||
assert.equal(before.version, '1.21.0'); assert.equal(after.version, '1.22.0'); assert.equal(after.pid, before.pid);
|
||||
const retained = { observedBefore: before.observedAt, observedAfter: after.observedAt, pid: after.pid, counts: formal.counts, retained: formal.retained,
|
||||
before: { configSha256: before.configSha256, modelCenterSha256: before.modelCenterSha256, eventCursor: before.eventCursor },
|
||||
after: { configSha256: after.configSha256, modelCenterSha256: after.modelCenterSha256, eventCursor: after.eventCursor },
|
||||
tableDigests: Object.fromEntries(Object.entries(before.database.tables).map(([name, row]) => [name, { count: row.count, schemaSha256: row.schemaSha256, sha256: row.sha256 }])),
|
||||
originalSessionExports: before.exports.length, sessionExports: after.exports.length, originalSessionExportDigests: before.exports, afterOriginalFieldDigests: after.exports, afterCompleteExecutionViewDigests: after.rawExports, executionViewSchemaChange: formal.retained.executionViewSchemaChange, originalArtifactFiles: before.persistent.artifacts.length, artifactFiles: after.persistent.artifacts.length,
|
||||
privateBackup: { bytes: backup.bytes, sha256: backup.sha256, committed: false, credentialsExtracted: false }, scope: 'All original rows/exports/config/artifact bytes checked by original verifiers. Full production snapshots and SQLite stay only in ignored QA.' };
|
||||
const retainedBytes = Buffer.from(JSON.stringify(retained, null, 2) + '\n');
|
||||
files.push({ path: 'retained-summary.json', source: prefix + 'retained-summary.json', bytes: retainedBytes.length, sha256: hash(retainedBytes) }); pending.push({ target: path.join(root, 'retained-summary.json'), bytes: retainedBytes });
|
||||
files.sort((a, b) => a.path.localeCompare(b.path));
|
||||
const manifest = { schemaVersion: 1, version: '1.22.0', sourceCommit: binding.sourceCommit, createdAt: new Date().toISOString(), files, appendedLogs, realModelRequests: 0,
|
||||
scope: 'Original frozen source/portable/installed browser acceptance, historical UI, formal read-only observations and phase receipts. Original development failures are separate. No private production snapshots, SQLite or model credentials.' };
|
||||
fs.mkdirSync(root); for (const { target, bytes } of pending) { fs.mkdirSync(path.dirname(target), { recursive: true }); fs.writeFileSync(target, bytes, { flag: 'wx' }); }
|
||||
fs.writeFileSync(prefix + 'retained-summary.json', retainedBytes, { flag: 'wx' });
|
||||
fs.writeFileSync(root + '/manifest.json', JSON.stringify(manifest, null, 2) + '\n', { flag: 'wx' });
|
||||
const identity = { schemaVersion: 1, version: '1.22.0', sourceCommit: binding.sourceCommit, portableRoot: binding.portableRoot, sourceRoot: binding.sourceRoot,
|
||||
acceptanceContinuation: independent.acceptanceContinuation,
|
||||
portableIdentity: binding.portableIdentity, portableManifestSha256: binding.portableManifestSha256, sourceManifestSha256: binding.sourceManifestSha256,
|
||||
portable: binding.portable, source: binding.source, installer: binding.installer,
|
||||
validation: { sourceTests: source.tests, sourceTestExecution: source.inheritedTests, sourceInputFiles: source.inputFiles, buildMatchedFiles: source.buildMatchedFiles, historicalUiScripts: allUi.results.length, historicalUiGroups: allUi.groups,
|
||||
historicalUiExecutionNote: 'B serial 33-script/250-group UI receipts inherited after complete input identity proof; only HTTP test synchronization, desktop acceptance helper and evidence attributes differ. Source tests bind the complete passing C run; all runtime/desktop/engineering gates run for D. See review/inherited-ui.json.', sourceBrowserGroups: 17, portableBrowserGroups: 17, installedBrowserGroups: 17, containedSuites: 9, samePayloadInstallGroups: 7,
|
||||
formalPanels: ui.results.length, nativeViews: native.results.length, nativeScreenshots: native.screenshots.length, originalCompleteWindowRuntimeFilesMatched: nativeBinding.exactRuntimeFiles, actualOldToNewUpgrade: true, realModelRequests: 0 },
|
||||
formal: { pid: after.pid, runtimeRoot: after.runtimeRoot, pointer: formal.pointer, currentProviderPreserved: formal.currentProviderPreserved, retained: formal.retained, counts: formal.counts, artifactFiles: after.persistent.artifacts.length, companion: formal.companion, inspectorClosed: formal.inspectorClosed },
|
||||
evidence: { manifest: root + '/manifest.json', sha256: hash(fs.readFileSync(root + '/manifest.json')), files: files.length, bytes: files.reduce((sum, row) => sum + row.bytes, 0) },
|
||||
limitations: ['Preview currently supports managed Vite projects with scripts.dev exactly vite and actual prepared dependencies.', 'Original webpage views require a connected Windows desktop window; browser shell and phone can inspect retained observations.', 'Approved fixed browser actions only; no arbitrary JavaScript/CDP or workbench Node/token access.', 'No real upstream model inference, Purge benefit, generic computer control or new physical iPhone acceptance in this milestone.', 'Original failures and unknown outcomes retained; completed or possibly executed actions are not automatically replayed.'] };
|
||||
fs.writeFileSync('docs/embedded-browser-release-identity.json', JSON.stringify(identity, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify({ success: true, files: files.length, bytes: identity.evidence.bytes, tests: source.tests, uiGroups: allUi.groups, counts: formal.counts, sourceCommit: binding.sourceCommit }));
|
||||
@@ -0,0 +1,43 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { snapshotPersistentData } from '../src/core/desktop/install-manager.mjs';
|
||||
import { databaseSnapshot, digest, compareOriginalState as compareExactOriginalState } from './desktop-f-state.mjs';
|
||||
export { hash } from './desktop-f-state.mjs';
|
||||
export const addedExecutionFields=['browsingTabs','browsingActions','previewPlans','previewJobs'];
|
||||
export function originalExecutionFields(version,execution){
|
||||
assert.ok(execution && typeof execution==='object' && !Array.isArray(execution));
|
||||
const original=structuredClone(execution);
|
||||
assert.ok(['1.21.0','1.22.0'].includes(version),'Unreviewed execution view version');
|
||||
for(const field of addedExecutionFields){
|
||||
if(version==='1.21.0')assert.equal(Object.hasOwn(original,field),false,'Old view must not already contain '+field);
|
||||
else{assert.equal(Object.hasOwn(original,field),true,'New view must contain '+field);assert.deepEqual(original[field],[],'Only the documented empty view addition is allowed: '+field);delete original[field];}
|
||||
}
|
||||
return original;
|
||||
}
|
||||
export async function publicSnapshot(url,dataRoot){
|
||||
const get=async(route,token)=>{
|
||||
const response=await fetch(url+'/api'+route,{headers:{Connection:'close',...(token?{'X-Workbench-Token':token}:{})},signal:AbortSignal.timeout(20000)});
|
||||
assert.equal(response.status,200,route+': HTTP '+response.status);return response.json();
|
||||
};
|
||||
const health=await get('/health'),bootstrap=await get('/bootstrap'),database=databaseSnapshot(dataRoot),exports=[],rawExports=[];
|
||||
for(const id of database.sessionIds){
|
||||
const report=await get('/sessions/'+id+'/export',bootstrap.token),identity={id,project:digest(report.project),session:digest(report.session)};
|
||||
rawExports.push({...identity,execution:digest(report.execution)});
|
||||
exports.push({...identity,execution:digest(originalExecutionFields(health.version,report.execution))});
|
||||
}
|
||||
const modelCenter=structuredClone(await get('/model-center',bootstrap.token));
|
||||
return {observedAt:new Date().toISOString(),version:health.version,pid:health.pid,runtimeRoot:bootstrap.runtimeRoot,
|
||||
configSha256:digest(bootstrap.config),projectsSha256:digest(bootstrap.projects),sessionsSha256:digest(bootstrap.sessions),modelCenterSha256:digest(modelCenter),modelCenter,
|
||||
projects:bootstrap.projects.length,visibleSessions:bootstrap.sessions.length,hasKey:!!bootstrap.config.hasKey,
|
||||
active:bootstrap.sessions.filter(value=>['running','awaiting_approval','stopping'].includes(value.status)).map(value=>({id:value.id,status:value.status})),
|
||||
storage:bootstrap.storage,eventCursor:bootstrap.eventCursor,database,exports,rawExports,persistent:snapshotPersistentData(dataRoot),
|
||||
executionView:{addedFields:addedExecutionFields,allAddedFieldsEmpty:true,originalFieldsPreservedIn:'exports',completeViewDigestsIn:'rawExports'},
|
||||
scope:'All original export fields, every database row/schema, config and artifact byte. Raw view digests retained separately. Only four proven empty additive 1.22 view arrays are projected for old-to-new comparison; no original field is removed.'};
|
||||
}
|
||||
export function compareOriginalState(before,after){
|
||||
for(const value of [before,after]){assert.deepEqual(value.executionView.addedFields,addedExecutionFields);assert.equal(value.executionView.allAddedFieldsEmpty,true);assert.equal(value.rawExports.length,value.exports.length);}
|
||||
const retained=compareExactOriginalState(before,after);
|
||||
if(before.version===after.version){assert.deepEqual(after.rawExports,before.rawExports,'Same-version complete export view must be exact');return {...retained,completeExecutionView:'exact'};}
|
||||
assert.equal(before.version,'1.21.0');assert.equal(after.version,'1.22.0');assert.deepEqual(before.rawExports,before.exports);
|
||||
return {...retained,originalExports:'every original field exact; four empty additive execution-view arrays',executionViewSchemaChange:{from:'1.21.0',to:'1.22.0',addedFields:addedExecutionFields,allAddedFieldsEmpty:true,sessions:before.exports.length,rawDigestsRetained:true}};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
const prefix = '.qa/embedded-browser-d-';
|
||||
const read = file => fs.existsSync(file) ? JSON.parse(fs.readFileSync(file)) : null;
|
||||
function log(file) {
|
||||
if (!fs.existsSync(file)) return '';
|
||||
const bytes = fs.readFileSync(file);
|
||||
return bytes[0] === 0xff && bytes[1] === 0xfe ? bytes.subarray(2).toString('utf16le') : bytes.toString('utf8').replace(/^\uFEFF/, '');
|
||||
}
|
||||
const originalIndependent = read(prefix + 'independent-result.json'), continuationStarted = fs.existsSync(prefix+'independent-continuation-console.log');
|
||||
const independent = read(prefix + 'independent-continuation-result.json') ?? (continuationStarted ? null : originalIndependent), promotion = read(prefix + 'promotion-result.json');
|
||||
const sourceText = log(prefix + 'source.log'), sourceStart = sourceText.split(/\r?\n/).find(line => line.startsWith('{"sourceRoot":'));
|
||||
const source = sourceStart ? JSON.parse(sourceStart) : null;
|
||||
const batches = source && fs.existsSync(source.directory) ? fs.readdirSync(source.directory).filter(name => /^(?:tests-\d+|upgrade-tests)\.tap$/.test(name)).sort().map(name => {
|
||||
const text = log(path.join(source.directory, name));
|
||||
const total = text.match(/^# tests (\d+)\s*$/m), pass = text.match(/^# pass (\d+)\s*$/m), fail = text.match(/^# fail (\d+)\s*$/m);
|
||||
return { name, complete: !!total && !!pass && !!fail, tests: total ? Number(total[1]) : null, pass: pass ? Number(pass[1]) : null, fail: fail ? Number(fail[1]) : null, observedPassedTopLevel: (text.match(/^ok \d+ /gm) ?? []).length, observedFailedTopLevel: (text.match(/^not ok \d+ /gm) ?? []).length };
|
||||
}) : [];
|
||||
const complete = batches.filter(row => row.complete);
|
||||
const activePhase = ((log(prefix + 'independent-console.log')+'\n'+log(prefix+'independent-continuation-console.log')).match(/^START .+$/gm) ?? []).at(-1) ?? null;
|
||||
const promotionPhase = (log(prefix + 'promotion-console.log').match(/^START .+$/gm) ?? []).at(-1) ?? null;
|
||||
console.log(JSON.stringify({ at: new Date().toISOString(), originalDRejectedAcceptance:originalIndependent?.success===false, continuationStarted, coreTestExecution:'C complete passing run inherited after strict input binding; not re-executed by D', independent: independent ? { success: independent.success, completed: independent.completed.length, error: independent.error } : { running: true, activePhase },
|
||||
source: source ? { root: source.sourceRoot, stage: (sourceText.match(/^Source package: .+$/gm) ?? []).at(-1), completedBatches: complete.length, completeTests: complete.reduce((sum, row) => sum + row.tests, 0), completePassed: complete.reduce((sum, row) => sum + row.pass, 0), completeFailed: complete.reduce((sum, row) => sum + row.fail, 0), latest: batches.slice(-2) } : null,
|
||||
promotion: promotion ? { success: promotion.success, completed: promotion.completed.map(row => row.name), error: promotion.error } : { waitingOrRunning: true, phase: promotionPhase }, realModelRequestsInitiated: 0 }));
|
||||
@@ -0,0 +1,29 @@
|
||||
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 result = read('.qa/embedded-browser-all-ui-validation.json'); assert.equal(result.success, true);
|
||||
let screenshots = 0, boundOriginals = 0; const directories = new Set();
|
||||
for (const row of result.results) {
|
||||
const value = read(row.evidence); assert.notEqual(value.success, false); assert.notEqual(value.passed, false);
|
||||
const output = fs.readFileSync(row.log, 'utf8');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim() ?? null;
|
||||
const directory = value.directory ?? location ?? value.root;
|
||||
if (directory) {
|
||||
const original = path.join(directory, 'result.json');
|
||||
if (fs.existsSync(original)) { assert.deepEqual(read(original), value); boundOriginals++; }
|
||||
directories.add(directory);
|
||||
}
|
||||
for (const item of Array.isArray(value.screenshots) ? value.screenshots : []) {
|
||||
const declared = typeof item === 'string' ? item : item.path ?? item.file ?? item.screenshot;
|
||||
const file = declared && !fs.existsSync(declared) && directory ? path.join(directory, declared) : declared;
|
||||
assert.ok(file && fs.existsSync(file), 'Original screenshot ' + file);
|
||||
const bytes = fs.readFileSync(file), expected = item.sha256 ?? item.screenshotSha256;
|
||||
if (expected) assert.equal(createHash('sha256').update(bytes).digest('hex'), expected, file);
|
||||
screenshots++;
|
||||
}
|
||||
}
|
||||
const receipt = { success: true, scripts: result.results.length, groups: result.groups, declaredScreenshots: screenshots, boundOriginals, explicitDirectories: directories.size, scope: 'Read-only current frozen UI original receipts and screenshots; no validation re-run or byte changes' };
|
||||
fs.writeFileSync('.qa/embedded-browser-d-ui-evidence-preflight.json', JSON.stringify(receipt, null, 2) + '\n', { flag: 'wx' });
|
||||
console.log(JSON.stringify(receipt));
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { chromium, expect } from 'playwright/test';
|
||||
|
||||
const base = 'http://127.0.0.1:4318', directory = path.resolve('.qa', 'embedded-browser-formal-ui-' + randomUUID());
|
||||
fs.mkdirSync(directory);
|
||||
const health = await (await fetch(base + '/api/health')).json();
|
||||
const deployed = JSON.parse(fs.readFileSync(process.argv[2] ?? '.qa/embedded-browser-d-formal-activate.json', 'utf8'));
|
||||
const output = process.argv[3] ?? '.qa/embedded-browser-d-formal-ui-validation.json';
|
||||
assert.equal(deployed.success, true); assert.equal(health.version, '1.22.0'); assert.equal(health.pid, deployed.identity.pid);
|
||||
const bootstrap = await (await fetch(base + '/api/bootstrap')).json();
|
||||
const existingSession = bootstrap.sessions.find(value => value.status === 'completed' && bootstrap.projects.some(project => project.id === value.projectId));
|
||||
assert.ok(existingSession, 'Read-only history inspection requires an existing completed session.');
|
||||
const readApi = async route => { const response = await fetch(base + '/api' + route, { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' }, signal: AbortSignal.timeout(10000) }); assert.equal(response.ok, true); return response.json(); };
|
||||
const controlledAvailability = await readApi('/engines/deepseek/controlled-availability'), purgeSource = await readApi('/engines/purge/source');
|
||||
assert.equal(controlledAvailability.controlledStatus, 'available'); assert.equal(purgeSource.status, 'available'); assert.equal(purgeSource.defaultEnabled, false);
|
||||
const pageErrors = [], requestFailures = [], httpErrors = [], blockedWrites = [], results = [];
|
||||
const record = { success: false, version: health.version, pid: health.pid, directory,
|
||||
selectedHistory: { projectId: existingSession.projectId, sessionId: existingSession.id, selection: 'Actual current-project selector; no task created.' }, results };
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true });
|
||||
const screenshot = async (page, filename) => {
|
||||
const file = path.join(directory, filename); await page.screenshot({ path: file, fullPage: true });
|
||||
return { screenshot: file, screenshotSha256: createHash('sha256').update(fs.readFileSync(file)).digest('hex') };
|
||||
};
|
||||
try {
|
||||
for (const [width, height] of [[1280, 900], [390, 844]]) {
|
||||
const context = await browser.newContext({ viewport: { width, height }, reducedMotion: 'reduce' });
|
||||
let closing = false;
|
||||
try {
|
||||
const page = await context.newPage();
|
||||
page.on('pageerror', error => pageErrors.push(error.message));
|
||||
page.on('requestfailed', request => { if (!closing) requestFailures.push({ url: request.url(), error: request.failure()?.errorText }); });
|
||||
page.on('response', response => { if (response.status() >= 400) httpErrors.push({ url: response.url(), status: response.status() }); });
|
||||
await page.route('**/api/**', route => {
|
||||
if (!['GET', 'HEAD', 'OPTIONS'].includes(route.request().method())) {
|
||||
blockedWrites.push({ method: route.request().method(), url: route.request().url() }); return route.abort();
|
||||
}
|
||||
return route.continue();
|
||||
});
|
||||
await Promise.all([page.waitForResponse(response => response.url().endsWith('/api/bootstrap') && response.status() === 200),
|
||||
page.goto(base + '/?release=1.22.0', { waitUntil: 'domcontentloaded' })]);
|
||||
await expect(page.locator('.connection small')).toHaveText('v1.22.0');
|
||||
await expect(page.locator('.connection')).toContainText('本地服务已连接');
|
||||
const projectSelector = page.getByRole('combobox', { name: '当前项目', exact: true });
|
||||
if (!await projectSelector.isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
|
||||
await projectSelector.selectOption(existingSession.projectId);
|
||||
if (!await projectSelector.isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
|
||||
await expect(projectSelector).toHaveValue(existingSession.projectId);
|
||||
if (width <= 940) await page.getByRole('button', { name: '收起项目栏', exact: true }).click();
|
||||
await expect(page.getByRole('button', { name: '隔离协作', exact: true })).toBeEnabled();
|
||||
await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
|
||||
await expect(page.getByRole('region',{name:'工程环境与依赖',exact:true})).toBeVisible();
|
||||
results.push({width,height,panel:'工程环境与依赖入口(未执行诊断)',readOnly:true,...await screenshot(page,'environment-entry-'+width+'.png')});
|
||||
await page.locator('.inspector-tabs').getByRole('button', { name: '浏览', exact: true }).click();
|
||||
const browsing = page.getByRole('region', { name: '内置浏览器', exact: true });
|
||||
await expect(browsing.getByRole('heading', { name: '在任务旁核对真实页面', exact: true })).toBeVisible();
|
||||
await expect(browsing).toContainText('桌面浏览器未连接');
|
||||
await expect(browsing.getByRole('button', { name: '打开目标', exact: true })).toBeEnabled();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '内置浏览器网页只读入口及桌面连接提示', readOnly: true, ...await screenshot(page, 'browser-entry-' + width + '.png') });
|
||||
await browsing.getByRole('button', { name: '返回任务', exact: true }).click();
|
||||
const plan = page.getByLabel('执行计划', { exact: true }); await expect(plan).toBeVisible();
|
||||
await expect(plan).not.toHaveAttribute('aria-busy', 'true', { timeout: 15000 });
|
||||
await expect(plan).not.toContainText('正在核对任务计划', { timeout: 15000 });
|
||||
await expect(plan.getByRole('heading', { name: '执行计划', exact: true })).toBeVisible();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '执行计划', readOnly: true, ...await screenshot(page, 'plan-' + width + '.png') });
|
||||
if (width <= 940) await page.getByRole('button', { name: '关闭检视区', exact: true }).click();
|
||||
for (const [launcher, title, suffix] of [['打开模型中心', '模型中心', '/api/model-center'], ['项目技能', '项目技能', '/skills'], ['项目MCP工具', '项目 MCP 工具', '/mcp']]) {
|
||||
await Promise.all([page.waitForResponse(response => response.url().endsWith(suffix) && response.status() === 200),
|
||||
page.getByRole('button', { name: launcher, exact: true }).click()]);
|
||||
const dialog = page.getByRole('dialog', { name: title, exact: true }); await expect(dialog).toBeVisible();
|
||||
await expect(dialog.getByRole('heading', { name: title, exact: true })).toBeVisible();
|
||||
for (const loading of ['正在读取实际连接状态', '正在核对已登记技能', '正在读取项目注册']) await expect(dialog).not.toContainText(loading);
|
||||
const bounds = await dialog.boundingBox(); assert.ok(bounds.x >= 0 && bounds.x + bounds.width <= width + 1);
|
||||
results.push({ width, height, panel: title, readOnly: true, ...await screenshot(page, suffix.split('/').at(-1) + '-' + width + '.png') });
|
||||
if (title === '模型中心') {
|
||||
await Promise.all([page.waitForResponse(response => response.url().endsWith('/api/model-center/credentials') && response.status() === 200),
|
||||
dialog.getByRole('button', { name: '凭据保存', exact: true }).click()]);
|
||||
await expect(dialog.getByRole('heading', { name: '本机加密凭据', exact: true })).toBeVisible();
|
||||
await expect(dialog).not.toContainText('正在核对本机保存状态');
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '本机加密凭据只读状态', readOnly: true, ...await screenshot(page, 'credentials-' + width + '.png') });
|
||||
await dialog.getByRole('button', { name: '运行巡检', exact: true }).click();
|
||||
await Promise.all([page.waitForResponse(response => response.url().includes('/api/operations') && response.status() === 200),
|
||||
dialog.getByRole('button', { name: '开始本地巡检', exact: true }).click()]);
|
||||
await expect(dialog.getByLabel('历史工件巡检分页', { exact: true })).toBeVisible();
|
||||
await expect(dialog.getByRole('checkbox', { name: '在此页面每30秒检查,离开即停止', exact: true })).not.toBeChecked();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '运行巡检及实际覆盖范围', readOnly: true, ...await screenshot(page, 'operations-' + width + '.png') });
|
||||
}
|
||||
await dialog.getByRole('button', { name: '关闭窗口', exact: true }).click(); await expect(dialog).toHaveCount(0);
|
||||
}
|
||||
await page.getByRole('button', { name: '隔离协作', exact: true }).click();
|
||||
const workers = page.getByRole('dialog', { name: '隔离协作', exact: true }); await expect(workers).toBeVisible();
|
||||
await expect(workers.getByRole('heading', { name: '隔离协作', exact: true })).toBeVisible();
|
||||
await expect(workers.getByLabel('父目标', { exact: true })).toBeVisible();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '隔离协作', readOnly: true, ...await screenshot(page, 'controlled-engine-' + width + '.png') });
|
||||
await workers.getByLabel('执行方式', { exact: true }).selectOption('deepseek');
|
||||
await workers.getByLabel('Harness 安装目录', { exact: true }).fill(controlledAvailability.root);
|
||||
await workers.getByRole('button', { name: '检测受控安装', exact: true }).click(); await expect(workers).toContainText('受控安装可用');
|
||||
const experiment = workers.getByLabel('Purge 提示实验', { exact: true }), toggle = experiment.getByRole('checkbox', { name: '启用 Purge 提示实验', exact: true });
|
||||
await expect(toggle).not.toBeChecked(); assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '受控引擎安装与默认关闭策略', readOnly: true, ...await screenshot(page, 'controlled-native-' + width + '.png') });
|
||||
await toggle.check(); await experiment.getByLabel('Purge 源码目录', { exact: true }).fill(purgeSource.root);
|
||||
await experiment.getByRole('button', { name: '检测 Purge 来源', exact: true }).click(); await expect(experiment).toContainText('已核对 Purge ' + purgeSource.version);
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: 'Purge来源只读核对', readOnly: true, ...await screenshot(page, 'controlled-purge-' + width + '.png') });
|
||||
await toggle.uncheck(); await workers.getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
await page.getByRole('button', { name: '工程评测', exact: true }).click();
|
||||
const evaluations = page.getByRole('dialog', { name: '工程质量评测', exact: true }); await expect(evaluations).toBeVisible();
|
||||
await expect(evaluations.getByLabel('工程评测控制台', { exact: true })).toBeVisible(); await expect(evaluations).toContainText('每批 1–3 个样本');
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '工程评测固定样本入口', readOnly: true, ...await screenshot(page, 'evaluations-' + width + '.png') });
|
||||
await evaluations.getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
await page.getByRole('button', { name: '手机连接', exact: true }).click();
|
||||
const companion = page.getByRole('dialog', { name: '手机连接', exact: true }); await expect(companion).toBeVisible();
|
||||
await expect(companion).toContainText('默认关闭');
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '默认关闭的手机网关与设备管理', readOnly: true, ...await screenshot(page, 'companion-' + width + '.png') });
|
||||
await companion.getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
if (width <= 940) await page.getByRole('button', { name: '查看文件', exact: true }).click();
|
||||
await page.locator('.inspector-tabs').getByRole('button', { name: '索引', exact: true }).click();
|
||||
const index = page.getByLabel('工程索引', { exact: true });
|
||||
await expect(index.locator('.index-cache')).toBeVisible({ timeout: 30000 });
|
||||
await index.locator('.index-cache summary').click();
|
||||
await expect(index).toContainText('2 轮 SHA 核对');
|
||||
await expect(index.getByRole('switch', { name: '启用本机解析缓存', exact: true })).toBeChecked();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth));
|
||||
results.push({ width, height, panel: '工程解析缓存及本次来源核对', readOnly: true, derivedIndexRead: true, ...await screenshot(page, 'engineering-evals-' + width + '.png') });
|
||||
if (width <= 940) await page.getByRole('button', { name: '关闭检视区', exact: true }).click();
|
||||
await page.getByRole('button', { name: '运行诊断', exact: true }).last().click();
|
||||
const diagnostics = page.getByRole('dialog', { name: '运行诊断', exact: true });
|
||||
await expect(diagnostics.getByLabel('解析缓存诊断')).toContainText('32 MiB');
|
||||
results.push({ width, height, panel: '解析缓存诊断与当前工程', readOnly: true, ...await screenshot(page, 'cache-diagnostics-' + width + '.png') });
|
||||
await diagnostics.getByRole('button', { name: '关闭窗口', exact: true }).click();
|
||||
console.log(JSON.stringify({ width, passedPanels: results.filter(row => row.width === width).length }));
|
||||
} finally { closing = true; await context.close(); }
|
||||
}
|
||||
assert.deepEqual(pageErrors, []); assert.deepEqual(requestFailures, []); assert.deepEqual(httpErrors, []); assert.deepEqual(blockedWrites, []);
|
||||
record.success = true;
|
||||
} catch (error) { record.error = error.stack; throw error; }
|
||||
finally {
|
||||
await browser.close();
|
||||
Object.assign(record, { testedAt: new Date().toISOString(), pageErrors, requestFailures, httpErrors, blockedWrites, modelRequests: 0,
|
||||
scope: 'Read-only smoke of deployed host in actual Edge desktop/390px; API mutations are blocked. Opening the source index may create derived parsing cache only; no task/tool/model/configuration/project writes.' });
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(record, null, 2) + '\n');
|
||||
fs.writeFileSync(output, JSON.stringify(record, null, 2) + '\n');
|
||||
console.log(JSON.stringify({ success: record.success, directory, panels: results.length, pageErrors: pageErrors.length, requestFailures: requestFailures.length, blockedWrites: blockedWrites.length }));
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import net from 'node:net';
|
||||
import http from 'node:http';
|
||||
import { execFile, spawn } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { HostController } from '../src/core/desktop/host-controller.mjs';
|
||||
import { validateInstalledVersion, snapshotPersistentData } from '../src/core/desktop/install-manager.mjs';
|
||||
import { observeWindowsProcess } from '../src/core/desktop/process-identity.mjs';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
import { hash } from './desktop-f-state.mjs';
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json'));
|
||||
const installer = JSON.parse(fs.readFileSync('.qa/embedded-browser-d-qa-installer.json')); assert.equal(installer.version, '1.22.0'); assert.equal(installer.qaFixture.fault, 'none');
|
||||
assert.equal(hash(fs.readFileSync(installer.path)), installer.sha256);
|
||||
// Keep the actual cross-drive install, with an exclusive short directory so
|
||||
// inherited TEMP depth does not exceed the installer's Windows path limit.
|
||||
const qaParent = 'C:\\AWQA22DI';
|
||||
fs.mkdirSync(qaParent, { recursive: true });
|
||||
assert.equal(fs.lstatSync(qaParent).isSymbolicLink(), false);
|
||||
const root = path.join(qaParent, 'i-' + randomUUID().replaceAll('-', '')), installRoot = path.join(root, 'program'), dataRoot = path.join(root, 'data');
|
||||
assert.equal(fs.existsSync(root), false); fs.mkdirSync(root);
|
||||
const run = promisify(execFile), env = projectEnvironment(), cases = [];
|
||||
const registryKey = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{a56fa7df-8a1f-415c-8fb1-d0a84e21ea3c}_is1';
|
||||
let registryExists = false; try { await run('reg.exe', ['query', registryKey], { windowsHide: true, env, timeout: 10000 }); registryExists = true; } catch (error) { assert.equal(error.code, 1); }
|
||||
assert.equal(registryExists, false, 'The isolated QA registration must be absent; never replace the user product registration.');
|
||||
const probe = net.createServer(); await new Promise(resolve => probe.listen(0, '127.0.0.1', resolve)); const port = probe.address().port; await new Promise(resolve => probe.close(resolve));
|
||||
const candidate = path.join(installRoot, 'versions', installer.candidateDirectory);
|
||||
let stage = 'exact final installer', controller, model, report, original, authenticated = 0;
|
||||
const record = (name, detail = {}) => { cases.push({ name, success: true, ...detail }); console.log('PASS ' + name); };
|
||||
async function until(action, timeout = 90000) { const end = Date.now() + timeout; while (!await action()) { if (Date.now() > end) throw Error('Timeout: ' + stage); await new Promise(resolve => setTimeout(resolve, 100)); } }
|
||||
async function processRun(binary, args, label, timeout = 900000) {
|
||||
const bootstrap = path.basename(binary).toLowerCase() === 'agentworkbench.exe';
|
||||
const nativeOutput = bootstrap ? fs.openSync(path.join(root, label + '-native-output.txt'), 'wx') : null;
|
||||
const chunks = [], child = spawn(binary, args, { cwd: path.dirname(binary), env, windowsHide: true, stdio: bootstrap ? ['ignore', nativeOutput, nativeOutput] : ['ignore', 'pipe', 'pipe'] });
|
||||
if (nativeOutput !== null) fs.closeSync(nativeOutput);
|
||||
child.stdout?.on('data', bytes => chunks.push(bytes)); child.stderr?.on('data', bytes => chunks.push(bytes));
|
||||
const timer = setTimeout(() => child.kill(), timeout);
|
||||
const code = await new Promise((resolve, reject) => { child.once('error', reject); child.once(bootstrap ? 'exit' : 'close', resolve); }); clearTimeout(timer);
|
||||
const bytes = Buffer.concat(chunks), file = path.join(root, label + '-process.txt'); fs.writeFileSync(file, bytes);
|
||||
assert.equal(code, 0, label + ' process exit'); return { exitCode: code, processLog: file, processLogSha256: hash(bytes) };
|
||||
}
|
||||
async function nativeStart(label) {
|
||||
await processRun(path.join(installRoot, 'AgentWorkbench.exe'), ['--hidden-window'], label, 30000);
|
||||
controller = new HostController({ appRoot: candidate, dataRoot, port, nodePath: path.join(candidate, 'runtime/node.exe') });
|
||||
await until(async () => { try { const value = await controller.connect(); return !!value; } catch { return false; } });
|
||||
await until(async () => (await controller.status()).desktopWindows.count === 1);
|
||||
return (await controller.status()).identity;
|
||||
}
|
||||
async function crashOwnedWindow() {
|
||||
const status = await controller.status(); assert.equal(status.desktopWindows.count, 1);
|
||||
const entry = status.desktopWindows.entries[0], actual = observeWindowsProcess(entry.pid);
|
||||
assert.ok(actual); assert.equal(actual.createdAt, entry.createdAt);
|
||||
assert.equal(fs.realpathSync.native(actual.executable), fs.realpathSync.native(path.join(candidate, 'desktop/AgentWorkbench.exe')));
|
||||
// Simulate this authenticated Electron process crashing. /T would explicitly
|
||||
// kill the detached backend descendant as well, a different failure mode.
|
||||
const result = await run('taskkill.exe', ['/PID', String(entry.pid), '/F'], { windowsHide: true, env, timeout: 30000 });
|
||||
fs.writeFileSync(path.join(root, 'owned-window-crash-' + entry.pid + '.txt'), result.stdout + result.stderr);
|
||||
await until(async () => (await controller.status()).desktopWindows.count === 0);
|
||||
assert.equal(observeWindowsProcess(entry.pid), null); return { pid: entry.pid, createdAt: entry.createdAt, scope: 'Explicit owned Electron process crash fixture; authenticated original PID/path/creation verified before taskkill /PID /F, without /T. Forced termination of the entire process tree is not window-process crash isolation.' };
|
||||
}
|
||||
try {
|
||||
const setupLog = path.join(root, 'exact-setup.log');
|
||||
const installed = await processRun(installer.path, ['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/NOICONS', '/DIR=' + installRoot, '/DATA_ROOT=' + dataRoot, '/PORT=' + port, '/LOG=' + setupLog], 'exact-setup');
|
||||
const identity = validateInstalledVersion(candidate), pointer = JSON.parse(fs.readFileSync(path.join(installRoot, 'current.json')));
|
||||
assert.equal(pointer.active.directory, installer.candidateDirectory); assert.equal(pointer.active.runtimeIdentity, identity.identitySha256);
|
||||
assert.equal(hash(fs.readFileSync(path.join(installRoot, 'AgentWorkbench.exe'))), hash(fs.readFileSync(path.join(release.portableRoot, 'AgentWorkbench.exe'))));
|
||||
record(stage, { installerSha256: installer.sha256, ...installed, setupLog, setupLogSha256: hash(fs.readFileSync(setupLog)), manifestSha256: identity.manifestSha256, loadedIdentity: identity.identitySha256 });
|
||||
stage = 'actual installed native bootstrap and bundled execution host'; original = await nativeStart('native-start');
|
||||
assert.equal(original.version, '1.22.0'); assert.equal(original.runtimeRoot, candidate); assert.equal(original.executable.path, path.join(candidate, 'runtime/node.exe'));
|
||||
const detectedEngine = await controller.api('/engines/deepseek/availability'), detectedPurge = await controller.api('/engines/purge/source');
|
||||
assert.equal(detectedEngine.status, 'available'); assert.equal(detectedPurge.status, 'available'); assert.equal(detectedPurge.defaultEnabled, false);
|
||||
record(stage, { identity: original, desktopWindow: (await controller.status()).desktopWindows.entries[0],
|
||||
relocatedSources: { engine: { root: detectedEngine.root, version: detectedEngine.version, identitySha256: detectedEngine.identitySha256 },
|
||||
purge: { root: detectedPurge.root, version: detectedPurge.version, sourceSha256: detectedPurge.sourceSha256 } },
|
||||
sourceEnvironmentOverrides: false, sourceScope: 'Read-only installed default lookup in a source-neutral child environment; actual third-party critical inputs checked, no SDK/plugin/model execution.' });
|
||||
const key = 'owned-final-install-key-' + randomUUID();
|
||||
model = http.createServer(async (request, response) => {
|
||||
for await (const bytes of request) void bytes;
|
||||
if (request.headers.authorization !== 'Bearer ' + key) { response.writeHead(401); response.end('{}'); return; }
|
||||
authenticated++; response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ choices: [{ message: { role: 'assistant', content: 'Owned final installer connection' }, finish_reason: 'stop' }], usage: { prompt_tokens: 4, completion_tokens: 1, total_tokens: 5 } }));
|
||||
}); await new Promise(resolve => model.listen(0, '127.0.0.1', resolve));
|
||||
stage = 'actual installed owned DPAPI credential and HTTP authentication';
|
||||
const created = await controller.api('/model-center/connections', { method: 'POST', input: { name: 'Owned final installer', baseUrl: 'http://127.0.0.1:' + model.address().port + '/v1', model: 'owned', apiKey: key, persistKey: true } });
|
||||
const connectionId = created.connection?.id ?? created.id ?? created.center?.connections.at(-1).id; assert.ok(connectionId);
|
||||
await controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId } }); assert.equal(authenticated, 1);
|
||||
const saved = (await controller.api('/model-center')).connections.find(value => value.id === connectionId); assert.equal(saved.hasKey, true);
|
||||
record(stage, { connectionId, authenticatedRequests: authenticated, savedCredential: saved.savedCredential });
|
||||
stage = 'actual installed owned approval and bundled npm project check';
|
||||
const bootstrap = await controller.api('/bootstrap'), project = bootstrap.projects.find(value => value.id === bootstrap.exampleProjectId);
|
||||
assert.equal(project.root, path.join(dataRoot, 'projects', 'starter-project'));
|
||||
const session = await controller.api('/sessions', { method: 'POST', input: { projectId: project.id } });
|
||||
await controller.api('/sessions/' + session.id + '/messages', { method: 'POST', input: { content: 'Owned exact installer offline demonstration and bundled Node check' } });
|
||||
let current; await until(async () => { current = await controller.api('/sessions/' + session.id); return current.status === 'awaiting_approval'; });
|
||||
const approval = current.approvals.find(value => value.status === 'pending'); assert.equal(approval.command, 'node --version');
|
||||
await controller.api('/sessions/' + session.id + '/approvals/' + approval.id, { method: 'POST', input: { allow: true } });
|
||||
await until(async () => { current = await controller.api('/sessions/' + session.id); return current.status === 'needs_review'; });
|
||||
for (const change of current.changes.filter(value => value.status === 'pending')) await controller.api('/sessions/' + session.id + '/changes/' + change.id + '/reject', { method: 'POST', input: {} });
|
||||
const planned = await controller.api('/sessions/' + session.id + '/check-plans', { method: 'POST', input: { names: ['test'] } }), plan = planned.execution.plans.at(-1);
|
||||
const started = await controller.api('/sessions/' + session.id + '/check-jobs', { method: 'POST', input: { planId: plan.id } }), checkId = started.execution.checks.at(-1).id;
|
||||
let checked; await until(async () => { checked = await controller.api('/sessions/' + session.id + '/check-jobs/' + checkId); return !['queued', 'running'].includes(checked.status); });
|
||||
assert.equal(checked.status, 'passed'); assert.equal(checked.results[0].tests.passed, 4); assert.equal(checked.results[0].tests.total, 4);
|
||||
|
||||
const browserLog=path.join(root,'installed-browser.log'),browserStream=fs.createWriteStream(browserLog,{flags:'wx'});
|
||||
const browserChild=spawn(process.execPath,['scripts/verify-embedded-browser.mjs','--app-root',candidate],{cwd:process.cwd(),env,windowsHide:true,stdio:['ignore','pipe','pipe']});
|
||||
browserChild.stdout.pipe(browserStream,{end:false});browserChild.stderr.pipe(browserStream,{end:false});
|
||||
const browserExit=await new Promise((resolve,reject)=>{browserChild.once('error',reject);browserChild.once('close',resolve);});await new Promise(resolve=>browserStream.end(resolve));
|
||||
assert.equal(browserExit,0,'Actual installed browser verifier failed: '+browserLog);
|
||||
const browserProof=JSON.parse(fs.readFileSync('.qa/embedded-browser-latest.json'));assert.equal(browserProof.success,true);assert.equal(browserProof.appRoot,candidate);assert.equal(browserProof.checks.length,17);assert.equal(browserProof.realModelRequests,0);
|
||||
record(stage, { sessionId: session.id, originalApprovalId: approval.id, checkId, actualTests: checked.results[0].tests, embeddedBrowser: {groups:browserProof.checks.length,directory:browserProof.root,resultSha256:hash(fs.readFileSync(path.join(browserProof.root,'result.json'))),log:browserLog,logSha256:hash(fs.readFileSync(browserLog))}, originalLogArtifactId: checked.results[0].logArtifactId });
|
||||
stage = 'actual owned Electron crash preserves final installed host and data';
|
||||
const beforeCrash = snapshotPersistentData(dataRoot), crash = await crashOwnedWindow();
|
||||
assert.equal((await controller.status()).identity.pid, original.pid); assert.deepEqual(snapshotPersistentData(dataRoot), beforeCrash);
|
||||
record(stage, { ...crash, originalHostPid: original.pid, originalDataRetained: true });
|
||||
stage = 'actual installed host restart preserves every row and loads owned saved connection';
|
||||
const beforeRestart = snapshotPersistentData(dataRoot); await controller.stop(); assert.equal(observeWindowsProcess(original.pid), null);
|
||||
const restarted = await nativeStart('native-restart'); assert.notEqual(restarted.pid, original.pid);
|
||||
assert.deepEqual(snapshotPersistentData(dataRoot), beforeRestart);
|
||||
const restored = (await controller.api('/model-center')).connections.find(value => value.id === connectionId);
|
||||
assert.equal(restored.hasKey, true); assert.equal(restored.revision, saved.revision); assert.equal(restored.credentialRevision, saved.credentialRevision);
|
||||
await controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId } }); assert.equal(authenticated, 2);
|
||||
record(stage, { previousPid: original.pid, pid: restarted.pid, originalPersistentDataRetained: true, ownedCredentialAuthenticatedAfterRestart: true });
|
||||
await crashOwnedWindow();
|
||||
stage = 'actual exact final installer uninstall preserves all owned user data';
|
||||
const beforeUninstall = snapshotPersistentData(dataRoot), uninstallLog = path.join(root, 'uninstall.log');
|
||||
const uninstalled = await processRun(path.join(installRoot, 'unins000.exe'), ['/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/LOG=' + uninstallLog], 'uninstall');
|
||||
assert.equal(observeWindowsProcess(restarted.pid), null); assert.deepEqual(snapshotPersistentData(dataRoot), beforeUninstall);
|
||||
assert.equal(fs.existsSync(path.join(installRoot, 'AgentWorkbench.exe')), false); assert.equal(fs.existsSync(path.join(installRoot, 'current.json')), false);
|
||||
record(stage, { ...uninstalled, uninstallLog, uninstallLogSha256: hash(fs.readFileSync(uninstallLog)), originalDataRoot: dataRoot, originalDataRetained: true });
|
||||
report = { success: true, version: '1.22.0', root, installRoot, dataRoot, installer, cases, ownedModelRequests: authenticated, realModelRequests: 0, isolatedQaRegistrationWasAbsent: true, scope: 'Final candidate payload and installer logic, using an isolated QA AppId (explicitly different setup SHA). The product setup is separately staged on the formal installation. Exclusive owned install/data/port, /NOICONS and an absent isolated QA registration prevent replacing user installation or shortcuts. Actual native bootstrap, host/owned credential/check/restart/uninstall; crash fixture stated explicitly.' };
|
||||
} catch (error) { report = { success: false, version: '1.22.0', root, installRoot, dataRoot, stage, error: error.stack, cases, installer, ownedModelRequests: authenticated, realModelRequests: 0 }; process.exitCode = 1; }
|
||||
finally {
|
||||
if (!report?.success && controller) try { const status = await controller.status(); if (!status.desktopWindows.count && !status.activity.active) await controller.stop(); } catch {}
|
||||
model?.closeAllConnections?.(); if (model) await new Promise(resolve => model.close(resolve));
|
||||
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(report, null, 2)); fs.writeFileSync('.qa/embedded-browser-d-install-location.json', JSON.stringify({ root, result: path.join(root, 'result.json') }));
|
||||
console.log(JSON.stringify({ success: report.success, version: report.version, root, cases: cases.length, ...(report.error ? { stage, error: report.error } : {}) }));
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { chromium, expect } from 'playwright/test';
|
||||
import { _electron } from 'playwright';
|
||||
import { HostController } from '../src/core/desktop/host-controller.mjs';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
import { publicSnapshot, compareOriginalState, hash } from './embedded-browser-d-state.mjs';
|
||||
const deployed = JSON.parse(fs.readFileSync('.qa/embedded-browser-d-formal-verify.json')); assert.equal(deployed.success, true);
|
||||
const base = 'http://127.0.0.1:4318', directory = path.resolve('.qa/embedded-browser-d-native-ui');
|
||||
assert.equal(fs.existsSync(directory), false); fs.mkdirSync(directory);
|
||||
const before = await publicSnapshot(base, deployed.dataRoot); assert.equal(before.version, '1.22.0'); assert.equal(before.pid, 36552);
|
||||
const bootstrap = await (await fetch(base + '/api/bootstrap')).json(), originalId = '22c90b01-6b82-43d9-b2b6-88a4b245c781';
|
||||
const original = await (await fetch(base + '/api/sessions/' + originalId + '/export', { headers: { 'X-Workbench-Token': bootstrap.token } })).json();
|
||||
const originalStatus = original.session.status;
|
||||
const selection = { projectId: original.project.id, sessionId: originalId }, errors = [], blockedWrites = [], screenshots = [], results = [];
|
||||
let browser, application, result;
|
||||
async function prepare(page) {
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await page.route('**/api/**', route => {
|
||||
if (!['GET', 'HEAD', 'OPTIONS'].includes(route.request().method())) { blockedWrites.push(route.request().method() + ' ' + route.request().url()); return route.abort(); }
|
||||
return route.continue();
|
||||
});
|
||||
}
|
||||
async function capture(page, name) {
|
||||
const file = path.join(directory, name + '.png'); await page.screenshot({ path: file }); screenshots.push({ file, sha256: hash(fs.readFileSync(file)) });
|
||||
}
|
||||
async function inspect(page, width, height, label) {
|
||||
await expect(page.locator('.connection small')).toHaveText('v1.22.0', { timeout: 30000 });
|
||||
await expect(page.locator('.work-header .work-title')).toContainText(original.session.title);
|
||||
await capture(page, label + '-original-session');
|
||||
await page.getByRole('button', { name: '打开模型中心', exact: true }).click();
|
||||
const dialog = page.getByRole('dialog', { name: '模型中心', exact: true }); await expect(dialog).toBeVisible();
|
||||
await dialog.locator('.mc-connection').first().getByRole('button', { name: '原生参数', exact: true }).click();
|
||||
const form = dialog.getByRole('form', { name: '原生请求参数', exact: true }); await expect(form).toBeVisible();
|
||||
const current = before.modelCenter.connections[0];
|
||||
assert.deepEqual(JSON.parse(await form.getByLabel('原生参数 JSON', { exact: true }).inputValue()), current.nativeParameters ?? {});
|
||||
await expect(form.getByLabel('输出上限字段', { exact: true })).toHaveValue(current.outputTokenField ?? (current.protocol === 'responses' ? 'max_output_tokens' : 'max_tokens'));
|
||||
const save = form.getByRole('button', { name: '保存原生参数', exact: true }); await save.scrollIntoViewIfNeeded();
|
||||
const box = await save.boundingBox(); assert.ok(box && box.x >= 0 && box.y >= 0 && box.x + box.width <= width + 1 && box.y + box.height <= height + 1);
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
await capture(page, label + '-native-parameters');
|
||||
await form.getByRole('button', { name: '取消', exact: true }).click(); await page.keyboard.press('Escape');
|
||||
await page.getByRole('button',{name:'查看任务记录',exact:true}).click();
|
||||
const environment=page.getByRole('region',{name:'工程环境与依赖',exact:true});await environment.scrollIntoViewIfNeeded();await expect(environment).toBeVisible();
|
||||
await expect(environment.getByRole('button',{name:'诊断工程环境',exact:true})).toBeVisible();
|
||||
await capture(page,label+'-environment-entry');
|
||||
await page.locator('.inspector-tabs').getByRole('button', { name: '浏览', exact: true }).click();
|
||||
const browsing = page.getByRole('region', { name: '内置浏览器', exact: true });
|
||||
await expect(browsing.getByRole('heading', { name: '在任务旁核对真实页面', exact: true })).toBeVisible();
|
||||
if (label.startsWith('electron-')) await expect(browsing).not.toContainText('桌面浏览器未连接');
|
||||
else await expect(browsing).toContainText('桌面浏览器未连接');
|
||||
await expect(browsing.getByRole('button', { name: '打开目标', exact: true })).toBeEnabled();
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
await capture(page, label + '-browser-entry');
|
||||
await browsing.getByRole('button', { name: '返回任务', exact: true }).click();
|
||||
|
||||
results.push({ label, width, height, originalStatus, originalSessionPreserved: true, nativeSettingsMatchPublicConnection: true, saveFullyReachable: true, browserEntryObserved: true, desktopBrowserConnected: label.startsWith('electron-'), submitted: false });
|
||||
}
|
||||
try {
|
||||
browser = await chromium.launch({ channel: 'msedge', headless: true });
|
||||
for (const [width, height] of [[1440, 1000], [390, 844]]) {
|
||||
const context = await browser.newContext({ viewport: { width, height } });
|
||||
await context.addInitScript(value => { localStorage.setItem('awb-project', value.projectId); localStorage.setItem('awb-session', value.sessionId); }, selection);
|
||||
const page = await context.newPage(); await prepare(page); await page.goto(base + '/?release=1.22.0');
|
||||
await inspect(page, width, height, 'edge-' + width); await context.close();
|
||||
}
|
||||
const controller = new HostController({ appRoot: deployed.candidate, dataRoot: deployed.dataRoot, port: 4318, nodePath: process.execPath });
|
||||
assert.equal((await controller.status()).desktopWindows.count, 0);
|
||||
application = await _electron.launch({ executablePath: path.join(deployed.candidate, 'desktop/AgentWorkbench.exe'), args: ['--app-root', deployed.candidate, '--data-root', deployed.dataRoot, '--port', '4318'], cwd: deployed.candidate, env: projectEnvironment(), timeout: 90000 });
|
||||
const page = await application.firstWindow(); await expect(page.locator('.connection small')).toHaveText('v1.22.0', { timeout: 30000 });
|
||||
await prepare(page); await page.evaluate(value => { localStorage.setItem('awb-project', value.projectId); localStorage.setItem('awb-session', value.sessionId); }, selection);
|
||||
await page.reload({ waitUntil: 'domcontentloaded' }); assert.equal((await controller.status()).desktopWindows.count, 1);
|
||||
for (const [width, height] of [[1280, 900], [390, 844]]) { await page.setViewportSize({ width, height }); await inspect(page, width, height, 'electron-' + width); }
|
||||
await application.close(); application = null; assert.equal((await controller.status()).desktopWindows.count, 0);
|
||||
assert.deepEqual(errors, []); assert.deepEqual(blockedWrites, []);
|
||||
const after = await publicSnapshot(base, deployed.dataRoot), retained = compareOriginalState(before, after);
|
||||
result = { success: true, version: before.version, pid: before.pid, candidate: deployed.candidate, results, screenshots, errors, blockedWrites, retained, originalSession: originalId, actualInstalledElectron: true, realModelRequests: 0,
|
||||
scope: 'Read-only formal Edge and visible installed Electron at two viewports; actual original session/current status and native parameters/save reachability. Original historical session was already completed at deployment baseline; no invented failure display. No settings saved, models called or tasks retried.' };
|
||||
} catch (error) { result = { success: false, results, screenshots, errors, blockedWrites, error: error.stack }; process.exitCode = 1; }
|
||||
finally { await application?.close().catch(() => {}); await browser?.close(); fs.writeFileSync('.qa/embedded-browser-d-native-ui.json', JSON.stringify(result, null, 2), { flag: 'wx' }); console.log(JSON.stringify({ success: result.success, results: results.length, screenshots: screenshots.length, error: result.error })); }
|
||||
@@ -0,0 +1,338 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { spawn, execFileSync } from 'node:child_process';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-source-package.mjs [--native-engines] - validate independently extracted source after verify-archives.py --extract-source; set the absolute QA Python and archive root.'); process.exit(0); }
|
||||
if (process.argv.slice(2).some(value => value !== '--native-engines')) throw new Error('Unsupported argument; use --help.');
|
||||
|
||||
const workspace = process.cwd();
|
||||
const evidence = JSON.parse(fs.readFileSync('.qa/archives-validation.json', 'utf8'));
|
||||
assert.equal(evidence.success, true);
|
||||
assert.ok(evidence.extractionRoot, 'Run python scripts/verify-archives.py --extract-source first.');
|
||||
const sourceRoot = fs.realpathSync.native(evidence.extractionRoot);
|
||||
const archiveQaRoot = path.resolve(process.env.AGENT_WORKBENCH_ARCHIVE_QA_ROOT || '.qa');
|
||||
assert.ok(sourceRoot.startsWith(archiveQaRoot + path.sep));
|
||||
const npmCli = path.join(path.dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js');
|
||||
assert.ok(fs.existsSync(npmCli), 'Use Node with its bundled npm.');
|
||||
const files = (root, relative = '') => fs.readdirSync(path.join(root, relative), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
|
||||
.flatMap(entry => entry.isDirectory() ? files(root, path.join(relative, entry.name)) : [path.join(relative, entry.name)]);
|
||||
const digest = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
||||
const buildFolders = ['dist-client', 'dist-server', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) ? ['dist-desktop'] : [])];
|
||||
const expected = Object.fromEntries(buildFolders.flatMap(folder => files(path.join(workspace, folder)).map(relative => [path.join(folder, relative), digest(path.join(workspace, folder, relative))])));
|
||||
const allowedEnv = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all|AGENT_WORKBENCH_TEST_PYTHON|AGENT_WORKBENCH_DEEPSEEK_ROOT|AGENT_WORKBENCH_PURGE_ROOT)$/i;
|
||||
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => allowedEnv.test(key)));
|
||||
const inheritedPath = Object.entries(env).find(([key]) => key.toLowerCase() === 'path')?.[1] || '';
|
||||
for (const key of Object.keys(env)) if (key.toLowerCase() === 'path') delete env[key];
|
||||
env.PATH = [path.dirname(process.execPath), inheritedPath].filter(Boolean).join(path.delimiter);
|
||||
const directory = path.join(sourceRoot, '.qa', 'package-validation-' + randomUUID());
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
const inputFolders = ['src', 'tests', 'scripts', ...['benchmarks', 'public', 'examples', 'research'].filter(folder => fs.existsSync(path.join(sourceRoot, folder)))];
|
||||
const inputNames = [...inputFolders.flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative))),
|
||||
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', ...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) ? ['mobile.html'] : []), ...['.gitattributes', '.gitignore', 'Start-Desktop.cmd', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'].filter(name => fs.existsSync(path.join(sourceRoot, name)))].sort();
|
||||
const snapshot = () => inputNames.map(relative => ({ path: relative.replaceAll('\\', '/'), bytes: fs.statSync(path.join(sourceRoot, relative)).size, sha256: digest(path.join(sourceRoot, relative)) }));
|
||||
const inputs = snapshot(); fs.writeFileSync(path.join(directory, 'inputs.json'), JSON.stringify(inputs, null, 2));
|
||||
let stage = 'environment preflight', python = null;
|
||||
const resultFile = path.join(workspace, '.qa/source-package-validation.json');
|
||||
const logs = [];
|
||||
|
||||
const inheritedRoot = path.join(workspace,'docs/embedded-browser-c-rejected-candidate-evidence');
|
||||
const inheritedManifest = JSON.parse(fs.readFileSync(path.join(inheritedRoot,'manifest.json')));
|
||||
const inheritedBaseline = JSON.parse(fs.readFileSync(path.join(inheritedRoot,'receipts/code-baseline.json')));
|
||||
assert.equal(inheritedManifest.sourceOverallSuccess,false);
|
||||
assert.deepEqual(inheritedManifest.tests,{tests:683,pass:683,fail:0,cancelled:0,skipped:0,todo:0});
|
||||
const originalInputs = new Map(inheritedBaseline.inputs.map(row=>[row.path,row]));
|
||||
assert.equal(inputs.length,originalInputs.size);
|
||||
const changed = inputs.filter(row=>{
|
||||
const old=originalInputs.get(row.path);assert.ok(old,row.path);return old.bytes!==row.bytes||old.sha256!==row.sha256;
|
||||
}).map(row=>row.path).sort();
|
||||
assert.deepEqual(changed,['.gitattributes','scripts/desktop-project-qa.mjs']);
|
||||
for(const row of inputs.filter(row=>row.path.startsWith('tests/'))){
|
||||
const text=fs.readFileSync(path.join(sourceRoot,row.path),'utf8');
|
||||
assert.ok(!/desktop-project-qa|verify-controlled-projects/.test(text),'Tests must not read the changed desktop QA helper: '+row.path);
|
||||
}
|
||||
const inheritedRows=[];
|
||||
const inheritance={success:false,sourceCommit:inheritedManifest.sourceCommit,sourceOverallSuccess:false,changedInputs:changed,tests:inheritedManifest.tests,originalManifestSha256:digest(path.join(inheritedRoot,'manifest.json')),logs:inheritedRows,
|
||||
scope:'Only the complete passing C source-test stage is inherited after every source/test/dependency/compiler input and test-used script is exact. C overall remains failed at a later desktop helper. D independently installs/builds and runs runtime, desktop and all engineering gates. No test result rewritten or executed twice.'};
|
||||
function inheritedTest(args,logName){
|
||||
if(!/^(?:tests-\d+|upgrade-tests)\.tap$/.test(logName))return null;
|
||||
for(const row of inheritedBaseline.builds)assert.equal(digest(path.join(sourceRoot,row.path)),row.sha256,'Actual rebuilt C/D byte identity: '+row.path);
|
||||
const oldPortable=JSON.parse(fs.readFileSync(path.join(inheritedRoot,'portable-manifest.json')));
|
||||
const node=oldPortable.files.find(row=>row.path==='runtime/node.exe');assert.ok(node);
|
||||
assert.equal(digest(process.execPath),node.sha256,'Same original test Node binary');
|
||||
assert.equal(digest(path.join(sourceRoot,'runtime/node.exe')),node.sha256);
|
||||
const declared=inheritedManifest.files.find(row=>row.path==='source/'+logName);assert.ok(declared,logName);
|
||||
const original=path.join(inheritedRoot,declared.path),bytes=fs.readFileSync(original);
|
||||
assert.equal(bytes.length,declared.bytes);assert.equal(digest(original),declared.sha256);
|
||||
const text=bytes.toString('utf8');
|
||||
const counts=Object.fromEntries([...text.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(row=>[row[1],Number(row[2])]));
|
||||
assert.ok(counts.tests>0);assert.equal(counts.tests,counts.pass);for(const key of ['fail','cancelled','skipped','todo'])assert.equal(counts[key],0);
|
||||
const oldPlan=JSON.parse(fs.readFileSync(path.join(inheritedRoot,'source/test-plan.json')));
|
||||
const newPlan=JSON.parse(fs.readFileSync(path.join(directory,'test-plan.json')));assert.deepEqual(newPlan,oldPlan);
|
||||
const output=path.join(directory,logName);fs.writeFileSync(output,bytes,{flag:'wx'});
|
||||
const row={stage,path:output,sha256:declared.sha256,bytes:declared.bytes,inheritedFrom:original,sourceCommit:inheritedManifest.sourceCommit};logs.push(row);inheritedRows.push({...row,args,counts});
|
||||
console.log('Source package: '+stage+' [exact passing C log inherited; no replay]');
|
||||
if(logName==='upgrade-tests.tap'){
|
||||
assert.equal(inheritedRows.length,12);assert.equal(inheritedRows.reduce((sum,row)=>sum+row.counts.tests,0),683);inheritance.success=true;
|
||||
fs.writeFileSync(path.join(workspace,'.qa/embedded-browser-d-source-test-inheritance.json'),JSON.stringify(inheritance,null,2)+'\n',{flag:'wx'});
|
||||
}
|
||||
return text.slice(-12000);
|
||||
}
|
||||
|
||||
function save(result) {
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2));
|
||||
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2));
|
||||
}
|
||||
|
||||
function run(args, logName) {
|
||||
const inherited=inheritedTest(args,logName);if(inherited!==null)return Promise.resolve(inherited);
|
||||
console.log('Source package: ' + stage);
|
||||
return new Promise((resolve, reject) => {
|
||||
const logPath = path.join(directory, logName);
|
||||
const outputFile = fs.createWriteStream(logPath);
|
||||
const child = spawn(process.execPath, args, { cwd: sourceRoot, env, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let tail = '', timedOut = false;
|
||||
const capture = bytes => { outputFile.write(bytes); tail = (tail + bytes.toString('utf8')).slice(-12000); };
|
||||
child.stdout.on('data', capture); child.stderr.on('data', capture);
|
||||
const timer = setTimeout(() => {
|
||||
timedOut = true;
|
||||
if (process.platform === 'win32' && child.pid) {
|
||||
try { execFileSync('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true, timeout: 10000, stdio: 'ignore' }); } catch { child.kill(); }
|
||||
} else child.kill();
|
||||
}, 30 * 60 * 1000);
|
||||
child.once('error', error => { clearTimeout(timer); outputFile.end(); reject(error); });
|
||||
child.once('close', code => { clearTimeout(timer); outputFile.end(() => {
|
||||
logs.push({ stage, path: logPath, sha256: digest(logPath), bytes: fs.statSync(logPath).size });
|
||||
code === 0 && !timedOut ? resolve(tail) : reject(new Error(stage + (timedOut ? ' timed out after 30 minutes' : ' failed (' + code + ')') + ': ' + tail));
|
||||
}); });
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
assert.equal(JSON.parse(fs.readFileSync(path.join(sourceRoot, 'package.json'), 'utf8')).version, evidence.version);
|
||||
assert.match(process.version, /^v24\./, 'Source package validation requires Node.js 24.');
|
||||
if (env.AGENT_WORKBENCH_TEST_PYTHON) {
|
||||
assert.ok(path.isAbsolute(env.AGENT_WORKBENCH_TEST_PYTHON) && fs.existsSync(env.AGENT_WORKBENCH_TEST_PYTHON), 'AGENT_WORKBENCH_TEST_PYTHON must name an existing absolute QA interpreter.');
|
||||
const executable = fs.realpathSync.native(env.AGENT_WORKBENCH_TEST_PYTHON);
|
||||
python = JSON.parse(execFileSync(executable, ['-I', '-c', 'import json,sys,pytest; print(json.dumps({"version":sys.version.split()[0],"pytest":pytest.__version__}))'], { env, windowsHide: true, encoding: 'utf8', timeout: 10000 }));
|
||||
assert.ok(Number(python.version.split('.')[0]) === 3 && Number(python.version.split('.')[1]) >= 10, 'QA Python must be 3.10 or newer.');
|
||||
assert.equal(python.pytest, '8.4.2', 'Install the fixed QA requirements before validating the source package.');
|
||||
python.path = executable; env.AGENT_WORKBENCH_TEST_PYTHON = executable;
|
||||
}
|
||||
console.log(JSON.stringify({ sourceRoot, directory, nodeVersion: process.version, python }));
|
||||
stage = 'install';
|
||||
await run([npmCli, 'ci', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], 'install.log');
|
||||
stage = 'build'; await run([npmCli, 'run', 'build'], 'build.log');
|
||||
const actualFiles = buildFolders.flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative)));
|
||||
assert.deepEqual(actualFiles.slice().sort(), Object.keys(expected).sort());
|
||||
for (const [relative, sha256] of Object.entries(expected)) assert.equal(digest(path.join(sourceRoot, relative)), sha256, relative);
|
||||
let actualRea = null;
|
||||
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained REA';
|
||||
const reaOutput = await run(['scripts/verify-rea.mjs', '--app-root', sourceRoot, '--contained'], 'rea.log');
|
||||
actualRea = JSON.parse(reaOutput.trim().split('\n').at(-1));
|
||||
assert.equal(actualRea.success, true); assert.equal(actualRea.version, evidence.version); assert.equal(actualRea.results.length, 3);
|
||||
assert.ok(actualRea.results.every(item => item.rootExited === true));
|
||||
}
|
||||
let actualEngine = null;
|
||||
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) && process.argv.includes('--native-engines')) {
|
||||
stage = 'native DeepSeek SDK';
|
||||
const output = await run(['scripts/verify-engines.mjs'], 'engines.log');
|
||||
actualEngine = JSON.parse(output.trim().split('\n').at(-1));
|
||||
assert.equal(actualEngine.success, true); assert.equal(actualEngine.version, evidence.version);
|
||||
assert.equal(actualEngine.modelRequests, 0); assert.equal(actualEngine.rootExited, true); assert.equal(actualEngine.nativeMethods.length, 6);
|
||||
}
|
||||
let actualBrowser = null;
|
||||
if (['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained browser runtime';
|
||||
const output = await run(['scripts/verify-browser.mjs', '--app-root', sourceRoot, '--contained'], 'browser.log');
|
||||
actualBrowser = JSON.parse(output.trim().split('\n').at(-1));
|
||||
assert.equal(actualBrowser.success, true); assert.equal(actualBrowser.version, evidence.version);
|
||||
assert.equal(actualBrowser.rootExited, true); assert.equal(actualBrowser.results.length, 2);
|
||||
assert.ok(actualBrowser.results.every(value => value.status === 'passed' && value.browserExited));
|
||||
assert.equal(actualBrowser.modelRequests, 0);
|
||||
}
|
||||
let actualControlled = null;
|
||||
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'compiled controlled-engine delivery';
|
||||
const output = await run(['scripts/verify-controlled-release.mjs', '--app-root', sourceRoot], 'controlled-engine.log');
|
||||
actualControlled = JSON.parse(output.trim().split('\n').at(-1));
|
||||
assert.equal(actualControlled.success, true); assert.equal(actualControlled.version, evidence.version); assert.equal(actualControlled.rootExited, true);
|
||||
assert.equal(actualControlled.realModelRequests, 0); assert.equal(actualControlled.cases, 4); assert.ok(actualControlled.fixtureModelRequests > 0);
|
||||
}
|
||||
let actualCompanion = null;
|
||||
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained companion gateway and UI';
|
||||
const output = await run(['scripts/verify-companion-ui.mjs', '--app-root', sourceRoot], 'companion-ui.log');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
assert.ok(location && path.resolve(location).startsWith(path.join(sourceRoot, '.qa') + path.sep));
|
||||
actualCompanion = JSON.parse(fs.readFileSync(path.join(location, 'result.json'), 'utf8'));
|
||||
assert.equal(actualCompanion.success, true); assert.equal(actualCompanion.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualCompanion.appRoot), sourceRoot); assert.equal(actualCompanion.containedRuntime, true);
|
||||
assert.equal(actualCompanion.passed.length, 7); assert.deepEqual(actualCompanion.errors, []); assert.equal(actualCompanion.realModelRequests, 0);
|
||||
}
|
||||
let actualProtocols = null;
|
||||
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained model protocols and mobile streams';
|
||||
const output = await run(['scripts/verify-model-protocols-ui.mjs', '--app-root', sourceRoot], 'model-protocols-ui.log');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
assert.ok(location && path.resolve(location).startsWith(path.join(sourceRoot, '.qa') + path.sep));
|
||||
actualProtocols = JSON.parse(fs.readFileSync(path.join(location, 'result.json'), 'utf8'));
|
||||
assert.equal(actualProtocols.success, true); assert.equal(actualProtocols.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualProtocols.appRoot), sourceRoot); assert.equal(actualProtocols.containedRuntime, true);
|
||||
assert.equal(actualProtocols.passed.length, 5); assert.deepEqual(actualProtocols.pageErrors, []); assert.deepEqual(actualProtocols.requestFailures, []);
|
||||
}
|
||||
let actualVision = null;
|
||||
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained screenshot inputs and exact Task budget resume';
|
||||
const output = await run(['scripts/verify-vision-ui.mjs', '--app-root', sourceRoot], 'vision-ui.log');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
assert.ok(location && path.resolve(location).startsWith(path.join(sourceRoot, '.qa') + path.sep));
|
||||
actualVision = JSON.parse(fs.readFileSync(path.join(location, 'result.json'), 'utf8'));
|
||||
assert.equal(actualVision.success, true); assert.equal(actualVision.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualVision.appRoot), sourceRoot); assert.equal(actualVision.containedRuntime, true);
|
||||
assert.equal(actualVision.passed.length, 5); assert.deepEqual(actualVision.pageErrors, []); assert.equal(actualVision.realModelRequests, 0);
|
||||
}
|
||||
let actualProjectCache = null;
|
||||
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained source-verified parsing cache controls';
|
||||
const output = await run(['scripts/verify-project-cache-ui.mjs', '--app-root', sourceRoot], 'project-cache-ui.log');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
assert.ok(location && path.resolve(location).startsWith(path.join(sourceRoot, '.qa') + path.sep));
|
||||
actualProjectCache = JSON.parse(fs.readFileSync(path.join(location, 'result.json'), 'utf8'));
|
||||
assert.equal(actualProjectCache.success, true); assert.equal(actualProjectCache.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualProjectCache.appRoot), sourceRoot); assert.equal(actualProjectCache.passed.length, 7);
|
||||
assert.equal(actualProjectCache.realModelRequests, 0); assert.deepEqual(actualProjectCache.pageErrors, []);
|
||||
}
|
||||
let actualEnvironment = null, actualEnvironmentEngineering = null;
|
||||
if (['1.21.0','1.22.0'].includes(evidence.version)) {
|
||||
stage = 'contained environment approval, stop and recovery UI';
|
||||
const output = await run(['scripts/verify-environment-ui.mjs', '--app-root', sourceRoot], 'environment-ui.log');
|
||||
const summary = JSON.parse(output.trim().split(/\r?\n/).findLast(line => line.startsWith('{"success":')));
|
||||
const relative = path.relative(path.join(sourceRoot, '.qa'), summary.directory);
|
||||
assert.ok(relative && !relative.startsWith('..') && !path.isAbsolute(relative));
|
||||
actualEnvironment = JSON.parse(fs.readFileSync(path.join(summary.directory, 'result.json'), 'utf8'));
|
||||
assert.equal(actualEnvironment.success, true); assert.equal(actualEnvironment.appRoot, sourceRoot);
|
||||
assert.equal(actualEnvironment.version, evidence.version); assert.equal(actualEnvironment.checks.length, 7);
|
||||
assert.deepEqual(actualEnvironment.pageErrors, []); assert.deepEqual(actualEnvironment.failures, []); assert.equal(actualEnvironment.realModelRequests, 0);
|
||||
stage = 'real locked React dependency preparation and Python engineering';
|
||||
const engineeringOutput = await run(['scripts/verify-environment-projects.mjs'], 'environment-engineering.log');
|
||||
actualEnvironmentEngineering = JSON.parse(engineeringOutput.trim().split(/\r?\n/).findLast(line => line.startsWith('{"success":')));
|
||||
assert.equal(actualEnvironmentEngineering.success, true); assert.equal(actualEnvironmentEngineering.reactOriginal, 'failed');
|
||||
assert.equal(actualEnvironmentEngineering.reactCandidate, 'passed'); assert.equal(actualEnvironmentEngineering.reactTests, 9);
|
||||
assert.equal(actualEnvironmentEngineering.pythonTests, 2); assert.equal(actualEnvironmentEngineering.realModelRequests, 0);
|
||||
}
|
||||
let actualEmbeddedBrowser = null;
|
||||
if (evidence.version === '1.22.0') {
|
||||
stage = 'actual embedded Electron, Vite and original mobile observation';
|
||||
await run(['scripts/verify-embedded-browser.mjs', '--app-root', sourceRoot], 'embedded-browser.log');
|
||||
actualEmbeddedBrowser = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/embedded-browser-latest.json'), 'utf8'));
|
||||
assert.equal(actualEmbeddedBrowser.success, true); assert.equal(actualEmbeddedBrowser.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualEmbeddedBrowser.appRoot), sourceRoot); assert.equal(actualEmbeddedBrowser.checks.length, 17);
|
||||
assert.equal(fs.realpathSync.native(actualEmbeddedBrowser.nodePath), path.join(sourceRoot, 'runtime', 'node.exe'));
|
||||
assert.equal(actualEmbeddedBrowser.realModelRequests, 0); assert.deepEqual(actualEmbeddedBrowser.errors, []);
|
||||
}
|
||||
// Only this file opens the fixed inspector port. Run it separately so another
|
||||
// test's child host can never compete for that port during the full suite.
|
||||
const testFiles = files(path.join(sourceRoot, 'tests')).filter(file => !file.includes(path.sep) && file.endsWith('.test.mjs'));
|
||||
const ordinaryTests = testFiles.filter(file => file !== 'upgrade.test.mjs');
|
||||
const testGroups = [];
|
||||
// Keep the per-process deadline, while letting the growing suite complete in
|
||||
// bounded batches. A slow worker recovery file must not consume the deadline
|
||||
// of every preceding, unrelated file. Every discovered file runs exactly once.
|
||||
for (let offset = 0; offset < ordinaryTests.length; offset += 8) testGroups.push(ordinaryTests.slice(offset, offset + 8));
|
||||
testGroups.push(['upgrade.test.mjs']);
|
||||
assert.deepEqual(testGroups.flat().slice().sort(), testFiles.slice().sort());
|
||||
assert.equal(new Set(testGroups.flat()).size, testFiles.length);
|
||||
const testPlan = testGroups.map((group, index) => ({ index, files: group, concurrency: index === testGroups.length - 1 ? 1 : 2, timeoutMs: 30 * 60 * 1000 }));
|
||||
fs.writeFileSync(path.join(directory, 'test-plan.json'), JSON.stringify(testPlan, null, 2));
|
||||
const stats = Object.fromEntries(['tests', 'pass', 'fail', 'cancelled', 'skipped', 'todo'].map(key => [key, 0]));
|
||||
for (const [index, group] of testGroups.entries()) {
|
||||
assert.ok(group.length > 0);
|
||||
const exclusiveUpgrade = index === testGroups.length - 1;
|
||||
stage = exclusiveUpgrade ? 'exclusive retained upgrade tests' : 'full source tests batch ' + (index + 1) + '/' + (testGroups.length - 1);
|
||||
const logName = exclusiveUpgrade ? 'upgrade-tests.tap' : 'tests-' + String(index + 1).padStart(2, '0') + '.tap';
|
||||
const output = await run(['--test', '--test-concurrency=' + testPlan[index].concurrency, '--test-reporter=tap', ...group.map(file => path.join('tests', file))], logName);
|
||||
const groupStats = Object.fromEntries([...output.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(match => [match[1], Number(match[2])]));
|
||||
assert.ok(groupStats.tests > 0); assert.equal(groupStats.pass, groupStats.tests);
|
||||
for (const key of Object.keys(stats)) { assert.ok(Number.isInteger(groupStats[key])); stats[key] += groupStats[key]; }
|
||||
for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(groupStats[key], 0);
|
||||
}
|
||||
let actualTaskControl = null;
|
||||
if (['1.20.1', '1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'task control desktop and 390px';
|
||||
await run(['scripts/verify-task-control-ui.mjs', '--app-root', sourceRoot], 'task-control-ui.log');
|
||||
actualTaskControl = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/task-control-ui-validation.json'), 'utf8'));
|
||||
assert.equal(actualTaskControl.success, true); assert.equal(actualTaskControl.passed.length, 5); assert.equal(actualTaskControl.realModelRequests, 0);
|
||||
}
|
||||
let actualDesktop = null;
|
||||
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'actual contained Electron window'; await run(['scripts/verify-desktop-window.mjs'], 'desktop-window.log');
|
||||
const window = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/desktop-window-latest.json'), 'utf8'));
|
||||
assert.equal(window.success, true); assert.equal(path.resolve(window.appRoot), sourceRoot); assert.equal(window.results.length, 7);
|
||||
stage = 'actual contained Electron engine UI'; await run(['scripts/verify-controlled-ui.mjs', '--desktop'], 'desktop-controlled-ui.log');
|
||||
const uiLocation = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/desktop-controlled-ui-location.json'), 'utf8'));
|
||||
const ui = JSON.parse(fs.readFileSync(uiLocation.result, 'utf8')); assert.equal(ui.passed, true); assert.equal(ui.testedVersion, evidence.version); assert.equal(ui.assertions.length, 9);
|
||||
stage = 'actual contained Electron engineering projects'; await run(['scripts/verify-controlled-projects.mjs', '--desktop'], 'desktop-projects.log');
|
||||
const projectLocation = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/desktop-projects-location.json'), 'utf8'));
|
||||
const projects = JSON.parse(fs.readFileSync(projectLocation.result, 'utf8')); assert.equal(projects.success, true); assert.equal(projects.testedVersion, evidence.version); assert.equal(projects.cases.length, 16);
|
||||
assert.deepEqual(projects.results.map(value => value.parentCheck.results[0].tests.passed), [8, 9, 10]);
|
||||
actualDesktop = { window, ui, projects, scope: 'Independently rebuilt source and its shipped Electron binary; original window/engine/engineering assertions. Own credentials/HTTP fixtures; Windows native picker and complete host crash/stop have separate actual evidence.' };
|
||||
}
|
||||
let actualProtocolEngineering = null;
|
||||
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'Responses SSE actual Node React Python engineering';
|
||||
await run(['scripts/verify-controlled-projects.mjs', '--responses'], 'responses-engineering.log');
|
||||
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/responses-engineering-location.json'), 'utf8'));
|
||||
actualProtocolEngineering = JSON.parse(fs.readFileSync(location.result, 'utf8'));
|
||||
assert.equal(actualProtocolEngineering.success, true); assert.equal(actualProtocolEngineering.testedVersion, evidence.version);
|
||||
assert.equal(actualProtocolEngineering.protocol, 'responses-stream'); assert.equal(actualProtocolEngineering.realModelRequests, 0);
|
||||
assert.deepEqual(actualProtocolEngineering.results.map(value => value.parentCheck.results[0].tests.passed), [8, 9, 10]);
|
||||
}
|
||||
let actualVisionEngineering = null;
|
||||
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'screenshot Task Node React Python engineering';
|
||||
await run(['scripts/verify-vision-projects.mjs'], 'vision-engineering.log');
|
||||
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/vision-engineering-location.json'), 'utf8'));
|
||||
actualVisionEngineering = JSON.parse(fs.readFileSync(location.result, 'utf8'));
|
||||
assert.equal(actualVisionEngineering.success, true); assert.equal(actualVisionEngineering.version, evidence.version);
|
||||
assert.equal(actualVisionEngineering.realModelRequests, 0);
|
||||
assert.deepEqual(actualVisionEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
|
||||
}
|
||||
let actualCacheEngineering = null;
|
||||
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'cached index original requests and Node React Python engineering';
|
||||
await run(['scripts/verify-project-cache-projects.mjs'], 'project-cache-engineering.log');
|
||||
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/project-cache-engineering-location.json'), 'utf8'));
|
||||
actualCacheEngineering = JSON.parse(fs.readFileSync(location.result, 'utf8'));
|
||||
assert.equal(actualCacheEngineering.success, true); assert.equal(actualCacheEngineering.version, evidence.version);
|
||||
assert.equal(actualCacheEngineering.realModelRequests, 0); assert.equal(actualCacheEngineering.cases.length, 9);
|
||||
assert.deepEqual(actualCacheEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
|
||||
}
|
||||
let actualEvaluations = null, actualEvaluationEngineering = null;
|
||||
if (['1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
|
||||
stage = 'compiled fixed engineering evaluations';
|
||||
const output = await run(['scripts/verify-evaluations-release.mjs', '--app-root', sourceRoot], 'evaluations-release.log');
|
||||
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
|
||||
assert.ok(location && path.resolve(location).startsWith(path.join(sourceRoot, '.qa') + path.sep));
|
||||
actualEvaluations = JSON.parse(fs.readFileSync(path.join(location, 'result.json'), 'utf8'));
|
||||
assert.equal(actualEvaluations.success, true); assert.equal(actualEvaluations.version, evidence.version);
|
||||
assert.equal(fs.realpathSync.native(actualEvaluations.appRoot), sourceRoot); assert.equal(actualEvaluations.containedRuntime, true);
|
||||
assert.equal(actualEvaluations.assertions.length, 5); assert.equal(actualEvaluations.realModelRequests, 0); assert.deepEqual(actualEvaluations.pageErrors, []);
|
||||
stage = 'fixed Node React Python and source-bound module engineering';
|
||||
await run(['scripts/verify-evaluations-projects.mjs'], 'evaluations-engineering.log');
|
||||
const engineeringLocation = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/engineering-evals-projects-location.json'), 'utf8'));
|
||||
actualEvaluationEngineering = JSON.parse(fs.readFileSync(engineeringLocation.result, 'utf8'));
|
||||
assert.equal(actualEvaluationEngineering.success, true); assert.equal(actualEvaluationEngineering.version, evidence.version);
|
||||
assert.equal(actualEvaluationEngineering.assertions.length, 14); assert.equal(actualEvaluationEngineering.realModelRequests, 0);
|
||||
assert.deepEqual(actualEvaluationEngineering.results.map(row => row.parentCheck.results[0].tests.passed), [8, 9, 10, 9]);
|
||||
}
|
||||
assert.deepEqual(snapshot(), inputs, 'Source package inputs changed during validation.');
|
||||
const result = { success: true, version: evidence.version, testedAt: new Date().toISOString(), sourceRoot, directory, nodeVersion: process.version, python, offlineInstall: true,
|
||||
inputs, inputFiles: inputs.length, logs, buildMatchedFiles: Object.keys(expected).length, buildFiles: Object.entries(expected).map(([path, sha256]) => ({ path: path.replaceAll('\\', '/'), sha256 })), tests: stats, inheritedTests: inheritance, testPlan, actualEmbeddedBrowser, actualEnvironment, actualEnvironmentEngineering, actualTaskControl, actualRea, actualEngine, actualBrowser, actualControlled, actualDesktop, actualCompanion, actualProtocols, actualProtocolEngineering, actualVision, actualVisionEngineering, actualProjectCache, actualCacheEngineering, actualEvaluations, actualEvaluationEngineering, credentialsHandling: 'Only build/runtime environment paths are inherited; no configured model credentials are used. The controlled-engine stage supplies a declared owned local response fixture.' };
|
||||
save(result); console.log(JSON.stringify({ success: true, version: result.version, sourceRoot, directory, tests: stats, nodeVersion: process.version, python, inputFiles: inputs.length, buildMatchedFiles: result.buildMatchedFiles, rea: !!actualRea?.success, engine: !!actualEngine?.success, browser: !!actualBrowser?.success, controlled: !!actualControlled?.success }));
|
||||
} catch (error) {
|
||||
save({ success: false, version: evidence.version, testedAt: new Date().toISOString(), stage, error: error.message, sourceRoot, directory, nodeVersion: process.version, python, inputs, logs });
|
||||
throw error;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { originalExecutionFields, addedExecutionFields } from './embedded-browser-d-state.mjs';
|
||||
const before=JSON.parse(fs.readFileSync('.qa/embedded-browser-d-upgrade-schema-diagnostic-before.json')).export.execution;
|
||||
const after=JSON.parse(fs.readFileSync('.qa/embedded-browser-d-upgrade-schema-diagnostic-after.json')).export.execution;
|
||||
let assertions=0;
|
||||
assert.deepEqual(originalExecutionFields('1.21.0',before),before);assertions++;
|
||||
assert.deepEqual(originalExecutionFields('1.22.0',after),before);assertions++;
|
||||
for(const field of addedExecutionFields){
|
||||
const nonempty=structuredClone(after);nonempty[field]=[{id:'unexpected'}];assert.throws(()=>originalExecutionFields('1.22.0',nonempty));assertions++;
|
||||
const missing=structuredClone(after);delete missing[field];assert.throws(()=>originalExecutionFields('1.22.0',missing));assertions++;
|
||||
const old=structuredClone(before);old[field]=[];assert.throws(()=>originalExecutionFields('1.21.0',old));assertions++;
|
||||
}
|
||||
const changed=structuredClone(after);changed.progress.totalTools++;assert.notDeepEqual(originalExecutionFields('1.22.0',changed),before);assertions++;
|
||||
const extra=structuredClone(after);extra.unreviewed=[];assert.notDeepEqual(originalExecutionFields('1.22.0',extra),before);assertions++;
|
||||
assert.throws(()=>originalExecutionFields('1.23.0',after));assertions++;
|
||||
fs.writeFileSync('.qa/embedded-browser-d-state-checks.json',JSON.stringify({success:true,assertions,realModelRequests:0,scope:'Actual diagnosed original export fields stay exact; only all four empty additions allowed. Missing, nonempty, pre-existing, unknown-version and unrelated changes rejected.'},null,2)+'\n',{flag:'wx'});
|
||||
console.log(JSON.stringify({success:true,assertions}));
|
||||
Reference in New Issue
Block a user