fix: retain observed Git in portable QA and seal independent 445-test acceptance

This commit is contained in:
Agent Workbench Dev
2026-10-31 07:51:55 +08:00
parent 6d09ac863a
commit b3111160e2
21 changed files with 49444 additions and 2 deletions
+13 -2
View File
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { randomUUID, createHash } from 'node:crypto';
import { spawn } from 'node:child_process';
import { spawn, execFileSync } from 'node:child_process';
import net from 'node:net';
import { createResearchSamples } from './research-fixtures.mjs';
import { verifyBrowserApi } from './verify-browser.mjs';
@@ -33,6 +33,17 @@ delete env.AGENT_WORKBENCH_API_KEY;
for (const name of Object.keys(env)) if (name.toLowerCase() === 'path') delete env[name];
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 (manifest.version === '1.14.0') {
// 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]);
const directory = path.dirname(binary);
assert.equal(fs.existsSync(path.join(directory, 'node.exe')), false); assert.equal(fs.existsSync(path.join(directory, 'npm.cmd')), false);
env.PATH = directory + path.delimiter + env.PATH;
externalGit = { path: binary, version: execFileSync('git', ['--version'], { env, windowsHide: true, encoding: 'utf8', timeout: 10000 }).trim(),
sha256: createHash('sha256').update(fs.readFileSync(binary)).digest('hex') };
}
function runPowerShell(script, extra = []) {
return new Promise((resolve, reject) => {
const child = spawn('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', path.join(appRoot, 'scripts', script), '-Port', String(port), ...extra], { windowsHide: true, env, stdio: ['ignore', 'pipe', 'pipe'] });
@@ -154,7 +165,7 @@ try {
console.log((await stop()).trim()); started = false;
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
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,
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', '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'], realModel: false };
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));