60 lines
7.7 KiB
JavaScript
60 lines
7.7 KiB
JavaScript
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}));
|