feat: add owned dependency preparation and reproducible environment evidence

This commit is contained in:
Agent Workbench Dev
2026-11-01 23:44:45 +08:00
parent e259ddc8da
commit a94807fa60
48 changed files with 1302 additions and 159 deletions
+1
View File
@@ -14,6 +14,7 @@ const prefixes = Object.freeze({
'1.19.0': 'project-cache',
'1.20.0': 'engineering-evals',
'1.20.1': 'task-control',
'1.21.0': 'reproducible-env',
});
export function releaseEvidencePrefix(version) {
const prefix = prefixes[version];
+1 -1
View File
@@ -64,7 +64,7 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
if (!fs.existsSync(originalScript) || !fs.existsSync(upgradeScript) || !fs.existsSync(path.join(next, 'dist-client', 'index.html'))) throw new Error('Upgrade bundles are incomplete.');
if (!Number.isInteger(pid) || pid < 1 || pid === process.pid) throw new Error('Invalid target process.');
const before = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '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.20.2', '1.20.3'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '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.20.2', '1.20.3', '1.21.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (before.sessions.some(session => ['running', 'awaiting_approval', 'stopping'].includes(session.status))) throw new Error('Wait for existing tasks and approvals before upgrading.');
let protocol, socket, enabledHere = false, paused = false;
const breakpoints = [];
+20 -17
View File
@@ -9,31 +9,32 @@ import { randomUUID } from 'node:crypto';
if (process.argv.slice(2).some(value => value !== '--help')) throw new Error('Unsupported argument; use --help.');
if (process.argv.includes('--help')) { console.log('node scripts/verify-all-ui.mjs - run serial desktop/390px checks in independent local hosts; use explicit QA Python/Harness/Purge source paths for 1.15.'); process.exit(0); }
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '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'].includes(version), 'Review evidence paths when introducing the next release.');
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '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'].includes(version), 'Review evidence paths when introducing the next release.');
const prefix = releaseEvidencePrefix(version), resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
const qaEnvironment = Object.fromEntries(['AGENT_WORKBENCH_TEST_PYTHON', 'AGENT_WORKBENCH_DEEPSEEK_ROOT', 'AGENT_WORKBENCH_PURGE_178_ROOT', 'AGENT_WORKBENCH_PURGE_181_ROOT']
.filter(name => process.env[name]).map(name => [name, process.env[name]]));
for (const [name, value] of Object.entries(qaEnvironment)) assert.ok(path.isAbsolute(value) && fs.existsSync(value), 'Use an existing absolute QA runtime/source path: ' + name);
const cases = [
...(['1.20.0', '1.20.1'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['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'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['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'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
...(['1.21.0'].includes(version)?[['verify-environment-ui.mjs',null],['verify-model-fidelity-ui.mjs',null],['verify-model-wait-ui.mjs',null]]:[]),
...(['1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['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'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['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'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['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'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
['verify-ui.mjs', '.qa/ui-validation.json'], ['verify-diagnostics-ui.mjs', '.qa/diagnostics-ui-validation.json'],
['verify-execution-ui.mjs', '.qa/execution-ui-validation.json'], ['verify-delivery-ui.mjs', '.qa/delivery-ui-validation.json'],
['verify-index-ui.mjs', '.qa/index-ui-result.json'], ['verify-change-sets-ui.mjs', `docs/${prefix}-batch-ui-validation.json`],
['verify-context-ui.mjs', `.qa/${version === '1.6.0' ? 'workspaces-context' : prefix}-ui-validation.json`],
['verify-workspaces-ui.mjs', `docs/${prefix === 'workspaces' ? prefix : prefix + '-workspaces'}-ui-validation.json`],
...(['1.7.0', '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'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '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'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['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'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
...(['1.7.0', '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'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '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'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['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'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['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'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
];
fs.mkdirSync('.qa', { recursive: true });
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
@@ -79,7 +80,8 @@ for (const [script, fixedProof] of cases) {
child.once('close', code => { clearTimeout(timer); code === 0 && !timedOut ? resolve(tail) : reject(new Error(script + (timedOut ? ' timed out' : ' failed (' + code + ')') + ': ' + tail)); });
});
stream.end();
const directory = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1].trim();
const summary = output.trim().split(/\r?\n/).findLast(line => line.startsWith('{"success":'));
const directory = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1].trim() || (summary ? JSON.parse(summary).directory : null);
const proof = fixedProof || (directory && path.join(directory, 'result.json'));
assert.ok(proof, 'Verifier must identify its current evidence.');
if (!fixedProof) {
@@ -88,10 +90,11 @@ for (const [script, fixedProof] of cases) {
}
const evidence = JSON.parse(fs.readFileSync(proof, 'utf8'));
assert.notEqual(evidence.success, false); assert.notEqual(evidence.passed, false); if (evidence.version) assert.equal(evidence.version, version);
const passed = [evidence.passed, evidence.cases, evidence.assertions].find(Array.isArray);
const passed = [evidence.passed, evidence.cases, evidence.assertions, evidence.checks].find(Array.isArray);
assert.ok(Array.isArray(passed) && passed.length > 0);
const errors = evidence.pageErrors ?? [], failures = evidence.requestFailures ?? [];
assert.equal(errors.length, 0); assert.equal(failures.length, 0);
assert.deepEqual(evidence.errors ?? [], []);
const saved = ['verify-controlled-ui.mjs', 'verify-purge-ui.mjs'].includes(script) ? `docs/${prefix}-${script.replace('verify-', '').replace('-ui.mjs', '')}-final-ui-validation.json`
: script === 'verify-ui.mjs' ? `docs/${prefix}-basic-ui-validation.json`
: ['verify-workspaces-ui.mjs', 'verify-task-plans-ui.mjs'].includes(script) ? proof
+69
View File
@@ -0,0 +1,69 @@
import fs from 'node:fs';
import path from 'node:path';
import http from 'node:http';
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
import {randomUUID,createHash} from 'node:crypto';
import {fixture} from '../tests/helpers.mjs';
import {deliveryGit} from '../tests/fixtures/delivery-project.mjs';
import {WorkspaceManager} from '../src/core/workspaces/git-workspaces.mjs';
import {EnvironmentManager} from '../src/core/environment/environment-manager.mjs';
import {CheckRunner} from '../src/core/check-runner.mjs';
const directory=path.resolve('.qa','environment-projects-'+randomUUID());fs.mkdirSync(directory,{recursive:true});
const disposers=[],t={after:fn=>disposers.push(fn)},f=fixture(t),reports=[],requests=[];
const hash=value=>createHash('sha256').update(value).digest('hex'),require=createRequire(import.meta.url);
const cacache=require(path.join(path.dirname(process.execPath),'node_modules/npm/node_modules/cacache'));
const cache=path.join(process.env.LOCALAPPDATA,'npm-cache','_cacache');
const manifestRoot=path.resolve('benchmarks/react-delivery-v1/baseline');fs.cpSync(manifestRoot,f.projectRoot,{recursive:true,filter:file=>!file.split(path.sep).includes('node_modules')});
const lockFile=path.join(f.projectRoot,'package-lock.json'),originalLock=fs.readFileSync(lockFile),lock=JSON.parse(originalLock),tarballs=new Map();
const server=http.createServer(async(request,response)=>{
const entry=tarballs.get(request.url);requests.push({path:request.url,integrity:entry?.integrity??null});
if(!entry){response.writeHead(404);response.end('No owned tarball');return;}
try{const bytes=await cacache.get.byDigest(cache,entry.integrity);response.writeHead(200,{'Content-Type':'application/octet-stream'});response.end(bytes);}
catch{response.writeHead(503);response.end('Required integrity not in local QA download cache');}
});
await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));const registry='http://127.0.0.1:'+server.address().port+'/';
disposers.push(()=>{server.closeAllConnections();return new Promise(resolve=>server.close(resolve));});
for(const entry of Object.values(lock.packages))if(entry.resolved){const url=new URL(entry.resolved);assert.equal(url.origin,'https://registry.npmjs.org');assert.equal(url.username,'');
const target='/tarballs/'+hash(entry.resolved)+'.tgz';tarballs.set(target,{integrity:entry.integrity});entry.resolved=registry+target.slice(1);}
fs.writeFileSync(lockFile,JSON.stringify(lock,null,2));
deliveryGit(f,['init','--initial-branch=main']);deliveryGit(f,['-c','core.autocrlf=false','add','.']);deliveryGit(f,['-c','user.name=Workbench QA','-c','user.email=qa@workbench.local','commit','-m','Own React source and integrity-bound local tarball feed']);
const parent=f.store.beginRun(f.session,'验证真实React工程的依赖准备及原版/候选检查',false,f.store.config);f.session.status='paused';f.store.finishRun(f.session,parent);
const workspaces=new WorkspaceManager(f.store),environment=new EnvironmentManager(f.store,{allowHttpLoopback:true}),checks=new CheckRunner(f.store);
disposers.push(()=>workspaces.stopAll(),()=>environment.stopAll(),()=>checks.stopAll());
async function child(label){const record=await workspaces.prepare(f.session,label);await(await workspaces.start(f.session,record.id,record.fingerprint)).promise;assert.equal(record.status,'ready',record.summary);
const project=f.store.project(record.childProjectId),session=f.store.session(record.childSessionId),run=f.store.beginRun(session,label,false,f.store.config);session.status='paused';f.store.finishRun(session,run);return {project,session};}
async function prepare(p){const plan=await environment.plan(p.session,{registry}),job=await(await environment.start(p.session,plan.id,plan.fingerprint,{approved:true})).promise;
reports.push({stage:'prepare',projectId:p.project.id,plan,job});assert.equal(job.status,'prepared',job.summary+'\n'+job.logExcerpt);console.log('PASS actual React npm ci: '+job.id);return job;}
function dependencyFiles(root,relative='node_modules'){const directory=path.join(root,relative);if(!fs.existsSync(directory))return [];
return fs.readdirSync(directory,{withFileTypes:true}).sort((a,b)=>a.name.localeCompare(b.name)).flatMap(entry=>{const name=path.posix.join(relative,entry.name),target=path.join(root,name);
return entry.isSymbolicLink()?[{path:name,link:fs.readlinkSync(target)}]:entry.isDirectory()?[{path:name,directory:true},...dependencyFiles(root,name)]:[{path:name,sha256:hash(fs.readFileSync(target))}];});}
async function check(p,names){const before=dependencyFiles(p.project.root),plan=await checks.plan(p.session,names),job=await(await checks.start(p.session,plan.id)).promise,after=dependencyFiles(p.project.root);
const left=new Map(before.map(row=>[row.path,JSON.stringify(row)])),right=new Map(after.map(row=>[row.path,JSON.stringify(row)]));
const changed=[...new Set([...left.keys(),...right.keys()])].filter(name=>left.get(name)!==right.get(name));
reports.push({stage:'checks',projectId:p.project.id,plan,job,dependencySnapshot:{before,after,changed}});if(changed.length)console.log('Observed dependency changes: '+JSON.stringify(changed));return job;}
let result;
try{
const original=await child('React原版环境'),candidate=await child('React候选环境'),left=await prepare(original),right=await prepare(candidate);
assert.equal(left.after.dependencyInputs,right.after.dependencyInputs);assert.equal(left.after.installed.sha256,right.after.installed.sha256);
const baseline=await check(original,['test','typecheck','build']);assert.equal(baseline.status,'failed',baseline.summary);assert.ok(baseline.results.some(value=>value.tests?.failed>0));
const app=fs.readFileSync(path.join(candidate.project.root,'src/App.tsx'),'utf8'),fixes={
'src/query.ts':"import type { Task } from './types.ts';\nexport function selectTasks(tasks: Task[], filter: string, query: string): Task[] { const text=query.trim().toLocaleLowerCase(); return tasks.filter(task => (filter==='done'?task.done:filter==='pending'?!task.done:true)&&task.title.toLocaleLowerCase().includes(text)); }\n",
'src/summary.ts':"import type { Task } from './types.ts';\nexport function summarizeTasks(tasks: Task[]) { return {total:tasks.length,completed:tasks.filter(task=>task.done).length,pendingHours:tasks.filter(task=>!task.done).reduce((sum,task)=>sum+task.hours,0)}; }\n",
'src/transition.ts':"import type { Task } from './types.ts';\nexport function toggleTask(tasks: Task[], id: string): Task[] { return tasks.map(task=>task.id===id?{...task,done:!task.done}:task); }\n",
'src/App.tsx':app.replace("toggleTask(current, 'missing')",'toggleTask(current, task.id)')};
for(const[name,value]of Object.entries(fixes))fs.writeFileSync(path.join(candidate.project.root,name),value);
const candidateJob=await check(candidate,['test','typecheck','build']);assert.equal(candidateJob.status,'passed',candidateJob.summary);assert.equal(candidateJob.results[0].tests.passed,9);
assert.ok(candidateJob.environment.preparation.jobId);assert.equal(fs.existsSync(path.join(f.projectRoot,'node_modules')),false);assert.equal(hash(fs.readFileSync(lockFile)),hash(JSON.stringify(lock,null,2)));
const pyRoot=path.join(f.root,'python-owned');fs.mkdirSync(pyRoot);fs.mkdirSync(path.join(pyRoot,'tests'));
fs.writeFileSync(path.join(pyRoot,'pyproject.toml'),'[tool.pytest.ini_options]\ntestpaths=["tests"]\n');
fs.writeFileSync(path.join(pyRoot,'calc.py'),'def add(a,b):\n return a+b\n');fs.writeFileSync(path.join(pyRoot,'tests/test_calc.py'),'from calc import add\ndef test_positive():\n assert add(2,3)==5\ndef test_negative():\n assert add(-2,3)==1\n');
const project=f.store.addProject(pyRoot),session=f.store.createSession(project.id),run=f.store.beginRun(session,'实际Python环境及检查',false,f.store.config);session.status='paused';f.store.finishRun(session,run);
const py=new EnvironmentManager(f.store,{pythonExecutable:process.env.AGENT_WORKBENCH_TEST_PYTHON}),diagnostic=await py.diagnose(session);assert.equal(diagnostic.python.pytest.version,'8.4.2');
const runner=new CheckRunner(f.store,{pythonExecutable:process.env.AGENT_WORKBENCH_TEST_PYTHON}),plan=await runner.plan(session,['python:test','python:compile']),job=await(await runner.start(session,plan.id)).promise;
reports.push({stage:'python',diagnostic,plan,job});assert.equal(job.status,'passed',job.summary);assert.equal(job.results[0].tests.passed,2);
result={success:true,directory,reports:reports.length,reactOriginal:baseline.status,reactCandidate:candidateJob.status,reactTests:9,pythonTests:2,requests:requests.length,
originalLockSha256:hash(originalLock),ownedLockSha256:hash(fs.readFileSync(lockFile)),downloadSource:'local HTTP feed of existing npm tarball bytes by locked SRI; no config/credentials or remote network',realModelRequests:0};
}catch(error){result={success:false,error:error.stack,directory,reports:reports.length,requests:requests.length};process.exitCode=1;}
finally{fs.writeFileSync(path.join(directory,'reports.json'),JSON.stringify({reports,requests},null,2));fs.writeFileSync(path.join(directory,'result.json'),JSON.stringify(result,null,2));console.log(JSON.stringify(result));for(const dispose of disposers.reverse())await dispose();}
+71
View File
@@ -0,0 +1,71 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import {randomUUID,createHash} from 'node:crypto';
import {chromium,expect} from 'playwright/test';
import {fixture,launchWorkbench,until} from '../tests/helpers.mjs';
import {environmentProject} from '../tests/fixtures/environment-project.mjs';
import {EnvironmentManager} from '../src/core/environment/environment-manager.mjs';
const args=process.argv.slice(2);assert.ok(!args.length||args.length===2&&args[0]==='--app-root'&&path.isAbsolute(args[1]));
const appRoot=args[1]??process.cwd(),directory=path.resolve('.qa','environment-ui-'+randomUUID());fs.mkdirSync(directory,{recursive:true});
const disposers=[],t={after:fn=>disposers.push(fn)},f=fixture(t),cases={},checks=[],screenshots=[],pageErrors=[],failures=[],events=[];
let browser,page,host,result;
const mark=value=>{checks.push(value);console.log('PASS '+value);};
for(const name of ['desktop','mobile','failure','stop','stale','recovery','late']) {
let own=f;
if(Object.keys(cases).length){const projectRoot=path.join(f.root,'project-'+name);fs.mkdirSync(projectRoot);const project=f.store.addProject(projectRoot);own={...f,projectRoot,project,session:f.store.createSession(project.id)};}
const postinstall=name==='failure'?`node -e "console.error('OWNED_INSTALL_FAILURE');process.exit(23)"`:name==='stop'?`node -e "console.log('OWNED_WAITING');setTimeout(()=>{},60000)"`:undefined;
const project=await environmentProject(own,{dependency:false,...(postinstall?{postinstall}:{})});project.session.title='环境验收 '+name;f.store.save(project.session);cases[name]=project;
if(name==='recovery'){
const manager=new EnvironmentManager(f.store),plan=await manager.plan(project.session,{offline:true});
f.store.putRecord('environment_job',project.session,{id:randomUUID(),sessionId:project.session.id,projectId:project.project.id,taskId:project.session.taskId,runId:project.session.runId,
planId:plan.id,planFingerprint:plan.fingerprint,status:'queued',process:null,requiresVerification:false},'environment.queued');
}
}
f.store.close();
const panel=()=>page.getByRole('region',{name:'工程环境与依赖',exact:true});
async function choose(name){const p=cases[name];if(page.viewportSize().width<=620||!await page.locator('.project-sidebar').isVisible())await page.getByRole('button',{name:'展开项目栏',exact:true}).click();
await page.getByLabel('当前项目',{exact:true}).selectOption(p.project.id);await expect(page.locator('.work-title h1')).toHaveText(p.session.title);
if(page.viewportSize().width<=620&&await page.getByRole('button',{name:'收起项目栏',exact:true}).isVisible())await page.getByRole('button',{name:'收起项目栏',exact:true}).click();
await page.getByRole('button',{name:'查看任务记录',exact:true}).click();await expect(panel()).toBeVisible();return p;}
async function capture(name){await panel().scrollIntoViewIfNeeded();const bounds=await page.evaluate(()=>({width:innerWidth,scroll:document.documentElement.scrollWidth}));assert.ok(bounds.scroll<=bounds.width+1,'horizontal overflow '+name);
const file=path.join(directory,name+'.png');await page.screenshot({path:file,scale:'css'});screenshots.push({path:file,sha256:createHash('sha256').update(fs.readFileSync(file)).digest('hex')});}
async function plan({allow=false}={}){await panel().getByRole('button',{name:/诊断工程环境/}).click();await expect(panel().getByText('Node / npm',{exact:true})).toBeVisible();
await panel().getByText('下载与脚本选项',{exact:true}).click();await panel().getByLabel('只使用本工作区的下载缓存(离线)').check();if(allow)await panel().getByLabel('允许依赖生命周期脚本').check();
await panel().getByRole('button',{name:'创建依赖准备计划',exact:true}).click();await expect(panel().getByRole('button',{name:'核对并批准依赖准备',exact:true})).toBeVisible();}
async function approve(){await panel().getByRole('button',{name:'核对并批准依赖准备',exact:true}).click();const dialog=page.getByRole('dialog',{name:'确认依赖准备',exact:true});await expect(dialog).toBeVisible();
await expect(dialog.getByText('独立工作区',{exact:true})).toBeVisible();await expect(dialog.locator('pre').first()).toContainText('--offline=true');return dialog;}
async function settled(p){let session;await until(async()=>{session=await host.api('/sessions/'+p.session.id);return session.execution.environmentJobs?.at(-1)?.finishedAt;},30000);return session;}
try{
host=await launchWorkbench(t,f.data,{}, {appRoot,nodePath:fs.existsSync(path.join(appRoot,'runtime','node.exe'))?path.join(appRoot,'runtime','node.exe'):process.execPath});
assert.notEqual(new URL(host.url).port,'4318');assert.equal(host.bootstrap.config.hasKey,false);
browser=await chromium.launch({executablePath:'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',headless:true});page=await browser.newPage({viewport:{width:1440,height:1000}});
page.on('pageerror',error=>pageErrors.push(error.message));page.on('requestfailed',request=>{if(request.resourceType()!=='eventsource')failures.push(request.url()+': '+request.failure()?.errorText);});
page.on('response',response=>{if(response.url().includes('/environment-'))events.push({url:response.url(),status:response.status()});});
await page.goto(host.url);let p=await choose('desktop');await plan();let dialog=await approve();await capture('desktop-plan');
await dialog.getByRole('button',{name:'确认执行依赖准备',exact:true}).click();let session=await settled(p);assert.equal(session.execution.environmentJobs.at(-1).status,'prepared');
assert.equal(session.execution.environmentDiagnostics.at(-1).node.status,'ready');await expect(panel().getByText('依赖已就绪',{exact:true})).toBeVisible();
await expect(panel().getByText('依赖准备完成',{exact:true})).toBeVisible();await capture('desktop-prepared');
await panel().getByRole('button',{name:'查看依赖日志',exact:true}).click();await expect(page.getByRole('dialog').last()).toContainText('stdout');await page.getByRole('dialog').last().getByRole('button',{name:'关闭窗口',exact:true}).click();
await page.reload();await page.getByRole('button',{name:'查看任务记录',exact:true}).click();await expect(panel().getByText('依赖准备完成',{exact:true})).toBeVisible();
assert.equal(fs.existsSync(path.join(p.sourceRoot,'node_modules')),false);mark('desktop diagnosis, fixed plan, explicit approval, actual npm, original log and refresh');
await page.setViewportSize({width:390,height:844});p=await choose('mobile');await plan();dialog=await approve();await capture('mobile-plan');await dialog.getByRole('button',{name:'确认执行依赖准备',exact:true}).click();session=await settled(p);
assert.equal(session.execution.environmentJobs.at(-1).status,'prepared');await capture('mobile-prepared');mark('390px same real flow and bounded plan modal');
await page.setViewportSize({width:1440,height:1000});p=await choose('failure');await plan({allow:true});dialog=await approve();await expect(dialog.getByText('允许执行根工程和依赖包安装脚本',{exact:true})).toBeVisible();
await dialog.getByRole('button',{name:'确认执行依赖准备',exact:true}).click();session=await settled(p);assert.equal(session.execution.environmentJobs.at(-1).status,'failed');await expect(panel().getByText('准备失败',{exact:true})).toBeVisible();await capture('failure-original-log');
assert.match(session.execution.environmentJobs.at(-1).logExcerpt,/OWNED_INSTALL_FAILURE/);mark('explicit script approval and original nonzero install failure');
p=await choose('stop');await plan({allow:true});dialog=await approve();await dialog.getByRole('button',{name:'确认执行依赖准备',exact:true}).click();await expect(panel().locator('pre').filter({hasText:'OWNED_WAITING'})).toBeVisible();
await panel().getByRole('button',{name:'停止依赖准备',exact:true}).click();session=await settled(p);assert.equal(session.execution.environmentJobs.at(-1).status,'cancelled',session.execution.environmentJobs.at(-1).summary);await capture('stopped-owned-process');mark('stop kills only owned npm tree and keeps cancelled logs');
p=await choose('stale');await plan();dialog=await approve();fs.appendFileSync(path.join(p.root,'package-lock.json'),'\n');await dialog.getByRole('button',{name:'确认执行依赖准备',exact:true}).click();
await expect(page.getByRole('alert')).toContainText('变化');assert.equal((await host.api('/sessions/'+p.session.id)).execution.environmentJobs?.length??0,0);await capture('stale-input-rejected');await dialog.getByRole('button',{name:'取消',exact:true}).click();mark('changed lock rejected before process dispatch');
p=await choose('recovery');await expect(panel().getByText('结果待核对',{exact:true})).toBeVisible();await panel().getByRole('button',{name:'核对中断现场',exact:true}).click();await page.getByRole('dialog',{name:'核对中断的依赖准备',exact:true}).getByRole('button',{name:'确认只读核对',exact:true}).click();
await expect(panel().getByText('已核对原进程结束并保留现场,原未知结果保持。再次执行需要新计划。',{exact:true})).toBeVisible();await capture('recovery-reconciled');mark('recovered unknown remains original unknown after explicit reconciliation');
p=await choose('late');await panel().getByRole('button',{name:'诊断工程环境',exact:true}).click();await expect(panel().getByText('Node / npm',{exact:true})).toBeVisible();
let release,observed,finish;const gate=new Promise(resolve=>{release=resolve;}),seen=new Promise(resolve=>{observed=resolve;}),finished=new Promise(resolve=>{finish=resolve;});
await page.route('**/environment-plans',async route=>{const response=await route.fetch();observed();await gate;try{await route.fulfill({response});}finally{finish();}});
await panel().getByRole('button',{name:'创建依赖准备计划',exact:true}).click();await seen;await choose('desktop');release();await finished;await page.unroute('**/environment-plans');await expect(page.locator('.work-title h1')).toHaveText(cases.desktop.session.title);mark('late plan response cannot replace another project or task');
assert.deepEqual(pageErrors,[]);assert.deepEqual(failures,[]);const receipts={};for(const[name,p]of Object.entries(cases))receipts[name]=await host.api('/sessions/'+p.session.id);
fs.writeFileSync(path.join(directory,'receipts.json'),JSON.stringify(receipts,null,2));result={success:true,appRoot,version:host.bootstrap.version,checks,screenshots,pageErrors,failures,events,directory,realModelRequests:0};
}catch(error){if(page){fs.writeFileSync(path.join(directory,'failure-dom.html'),await page.content());await page.screenshot({path:path.join(directory,'failure.png')}).catch(()=>{});}result={success:false,error:error.stack,checks,screenshots,pageErrors,failures,events,directory};process.exitCode=1;}
finally{fs.writeFileSync(path.join(directory,'result.json'),JSON.stringify(result,null,2));console.log(JSON.stringify(result));await browser?.close();for(const dispose of disposers.reverse())await dispose();}
+7 -7
View File
@@ -34,7 +34,7 @@ for (const name of Object.keys(env)) if (name.toLowerCase() === 'path') delete e
const windowsRoot = process.env.SystemRoot || 'C:\\Windows';
env.PATH = [windowsRoot, path.join(windowsRoot, 'System32'), path.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0')].join(path.delimiter);
let externalGit = 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'].includes(manifest.version)) {
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'].includes(manifest.version)) {
// The controlled project requires external Git. Preserve its observed binary
// directory while keeping system Node/npm unavailable to the packaged host.
const binary = fs.realpathSync.native(execFileSync('where.exe', ['git.exe'], { env: gitEnvironment(), encoding: 'utf8', windowsHide: true, timeout: 10000 }).trim().split(/\r?\n/)[0]);
@@ -88,7 +88,7 @@ try {
console.log((await launch()).trim());
assert.equal(JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8')).pid, firstInfo.pid);
const example = bootstrap.projects.find(project => project.id === bootstrap.exampleProjectId);
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(manifest.version)) {
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'].includes(manifest.version)) {
assert.equal(path.resolve(example.root).toLowerCase(), path.join(data, 'projects', 'starter-project').toLowerCase());
const compareTemplate = relative => { for (const entry of fs.readdirSync(path.join(appRoot, 'examples/starter-project', relative), { withFileTypes: true })) {
const next = path.join(relative, entry.name); if (entry.isDirectory()) compareTemplate(next);
@@ -114,7 +114,7 @@ try {
const checkLog = await api('/artifacts/' + checked.results[0].logArtifactId + '?session=' + session.id); assert.match(checkLog.content, /tests 4/);
assert.ok(fs.existsSync(path.join(appRoot, 'runtime/node_modules/npm/bin/npm-cli.js')));
const actualRea = [];
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'].includes(manifest.version)) {
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'].includes(manifest.version)) {
const installation = await api('/research/availability'); assert.equal(installation.status, 'available'); assert.equal(installation.version, '6.8.0');
assert.equal(fs.realpathSync.native(installation.packageRoot), fs.realpathSync.native(path.join(appRoot, 'runtime/node_modules/rea-agents')));
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
@@ -146,7 +146,7 @@ try {
console.log('PASS actual contained REA: ASAR, PE imports and PE resources; zero target execution/model requests');
}
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'].includes(manifest.version) && process.argv.includes('--native-engines')) {
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'].includes(manifest.version) && process.argv.includes('--native-engines')) {
const installation = await api('/engines/deepseek/availability'); assert.equal(installation.status, 'available', installation.message);
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
const engineRoot = path.join(data, 'engine-project'); fs.mkdirSync(engineRoot); fs.writeFileSync(path.join(engineRoot, 'README.md'), '# Owned portable engine connection\n');
@@ -166,8 +166,8 @@ try {
assert.equal((await api('/research')).length, 4);
const page = await fetch(url); assert.equal(page.status, 200);
assert.match(await page.text(), /Agent Workbench/);
const actualBrowser = ['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'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualBrowser = ['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'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['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'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
console.log((await stop()).trim()); started = false;
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
for (const file of manifest.files) {
@@ -176,7 +176,7 @@ try {
}
const result = { success: true, date: new Date().toISOString(), appRoot, version: manifest.version, nodeVersion: manifest.nodeVersion,
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine, actualBrowser, actualControlled, externalGit,
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
} finally { if (started) { try { await stop(); } catch {} } }
+48 -20
View File
@@ -19,7 +19,7 @@ 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'].includes(evidence.version) ? ['dist-desktop'] : [])];
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'].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)));
@@ -30,7 +30,7 @@ const directory = path.join(sourceRoot, '.qa', 'package-validation-' + randomUUI
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'].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();
'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'].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;
@@ -83,7 +83,7 @@ try {
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'].includes(evidence.version)) {
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'].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));
@@ -91,7 +91,7 @@ try {
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'].includes(evidence.version) && process.argv.includes('--native-engines')) {
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'].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));
@@ -99,7 +99,7 @@ try {
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'].includes(evidence.version)) {
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'].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));
@@ -109,7 +109,7 @@ try {
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'].includes(evidence.version)) {
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'].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));
@@ -117,7 +117,7 @@ try {
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'].includes(evidence.version)) {
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.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();
@@ -128,7 +128,7 @@ try {
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'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.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();
@@ -139,7 +139,7 @@ try {
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'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.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();
@@ -150,7 +150,7 @@ try {
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'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.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();
@@ -160,10 +160,38 @@ try {
assert.equal(fs.realpathSync.native(actualProjectCache.appRoot), sourceRoot); assert.equal(actualProjectCache.passed.length, 7);
assert.equal(actualProjectCache.realModelRequests, 0); assert.deepEqual(actualProjectCache.pageErrors, []);
}
stage = 'tests';
const output = await run(['--test', '--test-concurrency=2', '--test-reporter=tap', ...files(path.join(sourceRoot, 'tests')).filter(file => !file.includes(path.sep) && file.endsWith('.test.mjs')).map(file => path.join('tests', file))], 'tests.tap');
const stats = Object.fromEntries([...output.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(match => [match[1], Number(match[2])]));
assert.ok(stats.tests > 0); assert.equal(stats.pass, stats.tests); for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(stats[key], 0);
let actualEnvironment = null, actualEnvironmentEngineering = null;
if (evidence.version === '1.21.0') {
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);
}
// 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 testGroups = [testFiles.filter(file => file !== 'upgrade.test.mjs'), ['upgrade.test.mjs']];
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);
stage = index === 0 ? 'full tests without fixed inspector' : 'exclusive retained upgrade tests';
const output = await run(['--test', '--test-concurrency=' + (index === 0 ? 2 : 1), '--test-reporter=tap', ...group.map(file => path.join('tests', file))], index === 0 ? 'tests.tap' : 'upgrade-tests.tap');
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 (evidence.version === '1.20.1') {
stage = 'task control desktop and 390px';
@@ -172,7 +200,7 @@ try {
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'].includes(evidence.version)) {
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'].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);
@@ -186,7 +214,7 @@ try {
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'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.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'));
@@ -196,7 +224,7 @@ try {
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'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.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'));
@@ -206,7 +234,7 @@ try {
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'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.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'));
@@ -216,7 +244,7 @@ try {
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'].includes(evidence.version)) {
if (['1.20.0', '1.20.1','1.21.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();
@@ -235,7 +263,7 @@ try {
}
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, 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.' };
inputs, inputFiles: inputs.length, logs, buildMatchedFiles: Object.keys(expected).length, buildFiles: Object.entries(expected).map(([path, sha256]) => ({ path: path.replaceAll('\\', '/'), sha256 })), tests: stats, 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 });