Files
Agent-Workbench/docs/release-efficiency-1.23-evidence/receipts/release-efficiency-candidate-binding.mjs
T
2026-11-02 11:58:42 +08:00

36 lines
4.0 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
const read = file => JSON.parse(fs.readFileSync(file,'utf8'));
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
const release=read('releases/latest.json'), earlier=read('.qa/desktop-install-location.json'), installed=read(earlier.result);
assert.equal(installed.success,true); assert.equal(installed.results.length,11);
const priorRoot=installed.packagedSource; assert.ok(priorRoot.endsWith('20261102015415402'));
assert.ok(release.portableRoot.endsWith('20261102025721172')); assert.ok(release.documentation.sourceCommit.startsWith('93e8bc2'));
const old=read(path.join(priorRoot,'MANIFEST.json')), next=read(path.join(release.portableRoot,'MANIFEST.json'));
const oldRows=new Map(old.files.map(row=>[row.path,row])),nextRows=new Map(next.files.map(row=>[row.path,row]));
const documentation = name => name === 'DOCUMENTATION.json' || name.startsWith('docs/');
assert.deepEqual([...nextRows.keys()].filter(name=>!documentation(name)).sort(),[...oldRows.keys()].filter(name=>!documentation(name)).sort());
assert.ok([...oldRows.keys()].every(name=>nextRows.has(name)), 'No original shipped file may disappear.');
const changes=[],same=[],metadataChanges=[];
for(const row of next.files) {
const bytes=fs.readFileSync(path.join(release.portableRoot,row.path)); assert.equal(hash(bytes),row.sha256); assert.equal(bytes.length,row.bytes);
const original=oldRows.get(row.path);
if (!original) { assert.ok(row.path.startsWith('docs/')); changes.push({path:row.path,before:null,after:row}); continue; }
const oldBytes=fs.readFileSync(path.join(priorRoot,row.path)); assert.equal(hash(oldBytes),original.sha256); assert.equal(oldBytes.length,original.bytes);
if (row.path === 'runtime/REA-RUNTIME.json' && row.sha256 !== original.sha256) {
const before=JSON.parse(oldBytes),after=JSON.parse(bytes); assert.ok(Number.isFinite(Date.parse(before.builtAt))); assert.ok(Number.isFinite(Date.parse(after.builtAt)));
const beforeBuiltAt=before.builtAt,afterBuiltAt=after.builtAt; delete before.builtAt; delete after.builtAt; assert.deepEqual(after,before);
metadataChanges.push({path:row.path,field:'/builtAt',before:beforeBuiltAt,after:afterBuiltAt,originalSha256:original.sha256,finalSha256:row.sha256}); continue;
}
if(row.sha256===original.sha256 && row.bytes===original.bytes) same.push(row.path);
else { assert.match(row.path,/^(?:DOCUMENTATION\.json|docs\/)/,'Only documentation/source-archive mapping may differ in inherited installation acceptance.'); changes.push({path:row.path,before:original,after:row}); }
}
assert.ok(changes.length>0);
for(const required of ['dist-desktop/main.cjs','dist-desktop/preload.cjs','dist-server/install-manager.mjs','scripts/upgrade-running.mjs','AgentWorkbench.exe','desktop/AgentWorkbench.exe','runtime/node.exe']) assert.ok(same.includes(required));
const result={success:true,version:'1.23.0',testedAt:new Date().toISOString(),kind:'full installation lifecycle inherited only for byte-identical product and runtime inputs; final actual formal installer separately executed',
originalSource:priorRoot,finalSource:release.portableRoot,originalResult:earlier.result,originalResultSha256:hash(fs.readFileSync(earlier.result)),originalGroups:installed.results.length,
identicalProductFiles:same.length,changedDocumentation:changes,generatedMetadataChanges:metadataChanges,scope:'All executable, client/server/preload bundles, runtime package files, original reports, source templates and upgrade scripts are byte exact. REA-RUNTIME differs only in its generated builtAt timestamp. Full lifecycle failures/successes remain attributed to original B. Final C archive/REA/portable and final installer still require actual validation.',realModelRequests:0};
fs.writeFileSync('.qa/release-efficiency-candidate-binding.json',JSON.stringify(result,null,2),{flag:'wx'});console.log(JSON.stringify({success:true,identicalFiles:same.length,changed:changes.map(row=>row.path)}));