fix: show active passthrough capacity and separate program source publication
This commit is contained in:
@@ -6,12 +6,16 @@ import { spawn, execFileSync } from 'node:child_process';
|
||||
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
||||
|
||||
if (process.argv.includes('--help')) {
|
||||
console.log('node scripts/verify-packaged-build.mjs — extract compile inputs from the latest source ZIP, install offline, rebuild and compare every compiled file to its portable ZIP identity. Set AGENT_WORKBENCH_TEST_PYTHON to an absolute Python path. No model calls or formal-host changes.');
|
||||
console.log('node scripts/verify-packaged-build.mjs — independently rebuild a source ZIP and compare all compiled files with the latest program. AGENT_WORKBENCH_SOURCE_RELEASE selects a standalone source-code JSON receipt; otherwise use the legacy source bundle. Set AGENT_WORKBENCH_TEST_PYTHON. No model calls or formal-host changes.');
|
||||
process.exit(0);
|
||||
}
|
||||
assert.equal(process.argv.length, 2);
|
||||
assert.match(process.version, /^v24\./);
|
||||
const release = JSON.parse(fs.readFileSync('releases/latest.json'));
|
||||
const sourceReceipt = process.env.AGENT_WORKBENCH_SOURCE_RELEASE;
|
||||
const standaloneSource = sourceReceipt ? JSON.parse(fs.readFileSync(sourceReceipt)) : null;
|
||||
if (standaloneSource) assert.equal(standaloneSource.kind, 'source-code');
|
||||
const sourceZip = standaloneSource ?? release.source;
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(release.portableRoot, 'MANIFEST.json')));
|
||||
const root = path.resolve('.qa', 'packaged-build-' + randomUUID()), destination = path.join(root, 'source');
|
||||
fs.mkdirSync(destination, { recursive: true });
|
||||
@@ -28,19 +32,24 @@ async function digestFile(file) {
|
||||
}
|
||||
const startedAt = new Date().toISOString();
|
||||
const extract = `import sys,zipfile,pathlib,json,hashlib
|
||||
archive,destination,top=sys.argv[1:]
|
||||
archive,destination,top,receipt=sys.argv[1:]
|
||||
folders={'src','public','scripts','tests','examples','benchmarks','research'}
|
||||
names={'package.json','package-lock.json','vite.config.ts','tsconfig.json','index.html','mobile.html'}
|
||||
output=pathlib.Path(destination).resolve()
|
||||
with zipfile.ZipFile(archive) as bundle:
|
||||
manifest=json.loads(bundle.read(top+'/MANIFEST.json'))
|
||||
manifest=json.loads(pathlib.Path(receipt).read_text(encoding='utf-8')) if receipt else json.loads(bundle.read(top+'/MANIFEST.json'))
|
||||
selected=[item for item in manifest['files'] if item['path'].split('/')[0] in folders or item['path'] in names]
|
||||
assert manifest['kind']=='source' and selected
|
||||
assert manifest['kind'] in {'source','source-code'} and selected
|
||||
for item in selected:
|
||||
relative=pathlib.PurePosixPath(item['path'])
|
||||
assert not relative.is_absolute() and '..' not in relative.parts
|
||||
contents=bundle.read(top+'/'+item['path'])
|
||||
assert len(contents)==item['bytes'] and hashlib.sha256(contents).hexdigest()==item['sha256']
|
||||
assert len(contents)==item['bytes']
|
||||
if manifest['kind']=='source-code':
|
||||
assert hashlib.sha1(b'blob '+str(len(contents)).encode()+b'\\0'+contents).hexdigest()==item['gitBlob']
|
||||
item['sha256']=hashlib.sha256(contents).hexdigest()
|
||||
else:
|
||||
assert hashlib.sha256(contents).hexdigest()==item['sha256']
|
||||
target=(output/str(relative)).resolve()
|
||||
assert target.is_relative_to(output)
|
||||
target.parent.mkdir(parents=True,exist_ok=True)
|
||||
@@ -62,9 +71,9 @@ async function run(args, name) {
|
||||
}
|
||||
let result, stage = 'source archive identity', inputs = [], compiled = [], mismatches = [];
|
||||
try {
|
||||
assert.equal(await digestFile(release.source.path), release.source.sha256);
|
||||
assert.equal(await digestFile(sourceZip.path), sourceZip.sha256);
|
||||
stage = 'extract fixed compile inputs';
|
||||
const extraction = JSON.parse(execFileSync(python, ['-I', '-c', extract, release.source.path, destination, path.basename(release.sourceRoot)],
|
||||
const extraction = JSON.parse(execFileSync(python, ['-I', '-c', extract, sourceZip.path, destination, standaloneSource ? 'Agent-Workbench-' + standaloneSource.version + '-source' : path.basename(release.sourceRoot), sourceReceipt || ''],
|
||||
{ env, encoding: 'utf8', windowsHide: true, maxBuffer: 8 * 1024 * 1024 }));
|
||||
assert.equal(extraction.version, manifest.version); inputs = extraction.inputs;
|
||||
stage = 'offline install'; await run(['ci', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], 'offline-install');
|
||||
@@ -85,8 +94,8 @@ try {
|
||||
assert.deepEqual(mismatches, [], 'Source ZIP rebuild differs from portable compilation.');
|
||||
result = { success: true };
|
||||
} catch (error) { result = { success: false, stage, error: error.stack }; process.exitCode = 1; }
|
||||
result = { ...result, startedAt, finishedAt: new Date().toISOString(), version: manifest.version, sourceCommit: release.documentation.sourceCommit,
|
||||
root, destination, sourceZip: release.source, portableManifestSha256: await digestFile(path.join(release.portableRoot, 'MANIFEST.json')),
|
||||
result = { ...result, startedAt, finishedAt: new Date().toISOString(), version: manifest.version, sourceCommit: standaloneSource?.sourceCommit ?? release.documentation.sourceCommit,
|
||||
root, destination, sourceZip, portableManifestSha256: await digestFile(path.join(release.portableRoot, 'MANIFEST.json')),
|
||||
node: { version: process.version, sha256: await digestFile(process.execPath) }, inputCount: inputs.length, inputs, compiled, mismatches, logs, realModelRequests: 0,
|
||||
scope: 'Independent compile-input extraction from the exact source ZIP, offline dependency installation and actual TypeScript/Vite/mobile/server/desktop rebuild. Every source input retained and every compiled file compared. Historical source tests and full archive checks keep their separate receipts.' };
|
||||
const output = path.join(root, 'result.json');
|
||||
|
||||
Reference in New Issue
Block a user