fix: preserve engine activity and host state through 1.14 upgrades
This commit is contained in:
+5
-3
@@ -5,6 +5,9 @@ import { createHash } from 'node:crypto';
|
||||
import { planReaBundle, copyReaBundle } from './bundle-rea.mjs';
|
||||
import { planBrowserBundle, copyBrowserBundle } from './bundle-browser.mjs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.some(value => !['--help', '--immutable'].includes(value))) throw new Error('Unsupported argument; use --help.');
|
||||
if (args.includes('--help')) { console.log('node scripts/package.mjs [--immutable] - create new portable/source releases and archives; existing release folders are never refreshed.'); process.exit(0); }
|
||||
const root = process.cwd();
|
||||
const meta = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
const lock = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'));
|
||||
@@ -13,12 +16,11 @@ const browserPlan = planBrowserBundle(root);
|
||||
const releases = path.resolve(root, 'releases');
|
||||
fs.mkdirSync(releases, { recursive: true });
|
||||
const baseName = 'Agent-Workbench-' + meta.version;
|
||||
const refresh = process.argv.includes('--refresh');
|
||||
const buildSuffix = !refresh && (process.argv.includes('--immutable') || fs.existsSync(path.join(releases, baseName + '-win-x64'))) ? '-' + new Date().toISOString().replace(/[-:TZ.]/g, '') : '';
|
||||
const buildSuffix = args.includes('--immutable') || fs.existsSync(path.join(releases, baseName + '-win-x64')) ? '-' + new Date().toISOString().replace(/[-:TZ.]/g, '') : '';
|
||||
const portableRoot = path.join(releases, baseName + '-win-x64' + buildSuffix);
|
||||
const sourceRoot = path.join(releases, baseName + '-source' + buildSuffix);
|
||||
for (const target of [portableRoot, sourceRoot]) {
|
||||
if (!path.resolve(target).startsWith(releases + path.sep) || (fs.existsSync(target) && !refresh)) throw new Error('Release output must be a new folder under releases.');
|
||||
if (!path.resolve(target).startsWith(releases + path.sep) || fs.existsSync(target)) throw new Error('Release output must be a new folder under releases.');
|
||||
fs.mkdirSync(target, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ const prefixes = Object.freeze({
|
||||
'1.10.1': 'browser-hotfix', '1.11.0': 'task-plans', '1.12.0': 'model-center',
|
||||
'1.12.1': 'milestone-audit',
|
||||
'1.13.0': 'workers',
|
||||
'1.14.0': 'controlled-engine',
|
||||
});
|
||||
export function releaseEvidencePrefix(version) {
|
||||
const prefix = prefixes[version];
|
||||
|
||||
@@ -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'].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'].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 = [];
|
||||
@@ -150,9 +150,15 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const args = Object.fromEntries(process.argv.slice(2).reduce((items, value, index, all) => {
|
||||
if (value.startsWith('--')) items.push([value.slice(2), all[index + 1]]); return items;
|
||||
}, []));
|
||||
const raw = process.argv.slice(2), args = {}, options = new Set(['url', 'pid', 'current-root', 'new-root', 'handler-root']);
|
||||
if (raw.length === 1 && raw[0] === '--help') { console.log('node scripts/upgrade-running.mjs --pid PID --current-root DIR --new-root DIR [--url http://127.0.0.1:4318] [--handler-root DIR]'); process.exit(0); }
|
||||
for (let index = 0; index < raw.length; index += 2) {
|
||||
const key = raw[index].startsWith('--') ? raw[index].slice(2) : '';
|
||||
if (!options.has(key) || Object.hasOwn(args, key) || !raw[index + 1] || raw[index + 1].startsWith('--')) throw new Error('Unknown or incomplete argument; use --help.');
|
||||
args[key] = raw[index + 1];
|
||||
}
|
||||
if (!/^\d+$/.test(args.pid ?? '') || !path.isAbsolute(args['current-root'] ?? '') || !path.isAbsolute(args['new-root'] ?? '')
|
||||
|| args['handler-root'] !== undefined && !path.isAbsolute(args['handler-root'])) throw new Error('PID and absolute current/new roots are required arguments; use --help.');
|
||||
const result = await upgradeRunning({ url: args.url || 'http://127.0.0.1:4318', pid: Number(args.pid), currentRoot: args['current-root'], newRoot: args['new-root'], handlerRoot: args['handler-root'] });
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
}
|
||||
|
||||
+17
-12
@@ -6,25 +6,29 @@ import { spawn, execFileSync } from 'node:child_process';
|
||||
import { gitEnvironment } from '../src/core/git-process.mjs';
|
||||
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.14.'); 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'].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'].includes(version), 'Review evidence paths when introducing the next release.');
|
||||
const prefix = releaseEvidencePrefix(version), resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
|
||||
const qaEnvironment = process.env.AGENT_WORKBENCH_TEST_PYTHON ? { AGENT_WORKBENCH_TEST_PYTHON: process.env.AGENT_WORKBENCH_TEST_PYTHON } : {};
|
||||
if (qaEnvironment.AGENT_WORKBENCH_TEST_PYTHON) assert.ok(path.isAbsolute(qaEnvironment.AGENT_WORKBENCH_TEST_PYTHON) && fs.existsSync(qaEnvironment.AGENT_WORKBENCH_TEST_PYTHON), 'Use an existing absolute QA Python interpreter.');
|
||||
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 = [
|
||||
...(version === '1.13.0' ? [['verify-workers-ui.mjs', null]] : []),
|
||||
...(['1.11.0', '1.12.0', '1.12.1', '1.13.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'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
|
||||
...(version === '1.14.0' ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
|
||||
...(['1.13.0', '1.14.0'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
|
||||
...(['1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.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'].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'].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'].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'].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'].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'].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'].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'].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'].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'].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'].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']);
|
||||
@@ -83,7 +87,8 @@ for (const [script, fixedProof] of cases) {
|
||||
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);
|
||||
const saved = script === 'verify-ui.mjs' ? `docs/${prefix}-basic-ui-validation.json`
|
||||
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
|
||||
: `docs/${prefix}-${script.replace('verify-', '').replace('.mjs', '')}-validation.json`;
|
||||
if (path.resolve(saved) !== path.resolve(proof)) fs.copyFileSync(proof, saved);
|
||||
|
||||
@@ -34,7 +34,7 @@ child.stdout.on('data', value => { output += value; for (const line of output.sp
|
||||
child.stderr.on('data', value => { errors += value; });
|
||||
const wait = async predicate => { const deadline = Date.now() + 15000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('UI fixture timed out: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
|
||||
await wait(() => url); const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
|
||||
assert.ok(['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'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
assert.ok(['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'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const proofPrefix = releaseEvidencePrefix(bootstrap.version) + '-batch';
|
||||
const screenshotPrefix = bootstrap.version === '1.4.0' ? '1.4-batch' : proofPrefix;
|
||||
const api = async (route, input) => { const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' },
|
||||
|
||||
@@ -77,7 +77,7 @@ child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
|
||||
const until = async predicate => { const deadline = Date.now() + 20000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('Context UI fixture timeout: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
|
||||
await until(() => url || child.exitCode !== null); assert.ok(url, errors);
|
||||
const bootstrap = await (await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' } })).json();
|
||||
assert.ok(['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'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
assert.ok(['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'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' } }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
|
||||
const proofPrefix = bootstrap.version === '1.6.0' ? 'workspaces-context' : releaseEvidencePrefix(bootstrap.version);
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn, execFileSync } from 'node:child_process';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { gitEnvironment } from '../src/core/git-process.mjs';
|
||||
import { assertToolPairs, call } from '../tests/helpers.mjs';
|
||||
|
||||
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
const wait = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||
async function until(predicate, timeout = 45000) {
|
||||
const deadline = Date.now() + timeout;
|
||||
while (!await predicate()) { if (Date.now() > deadline) throw new Error('Owned compiled-engine acceptance timed out.'); await wait(50); }
|
||||
}
|
||||
|
||||
// This verifier supplies a declared local response algorithm. The executing
|
||||
// Runtime/Store/permissions/native bridge all belong to the compiled host.
|
||||
export async function verifyControlledApi({ api, url, token, directory, appRoot, contained = false }) {
|
||||
const origin = new URL(url);
|
||||
assert.equal(origin.hostname, '127.0.0.1'); assert.notEqual(origin.port, '4318');
|
||||
const bootstrap = await api('/bootstrap'); assert.equal(bootstrap.version, '1.14.0');
|
||||
assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
const root = path.join(directory, 'compiled-controlled-node'), hooks = path.join(directory, 'disabled-hooks');
|
||||
fs.mkdirSync(root); fs.mkdirSync(hooks);
|
||||
fs.cpSync(path.join(appRoot, 'benchmarks/workers-delivery-v1/node'), root, { recursive: true });
|
||||
fs.writeFileSync(path.join(root, '.gitignore'), 'dist/\nnode_modules/\n.awb-*\n');
|
||||
for (const name of ['owner-staged.txt', 'owner-unstaged.txt']) fs.writeFileSync(path.join(root, name), 'Owner baseline\n');
|
||||
const git = args => execFileSync('git', ['-c', 'core.hooksPath=' + hooks, ...args], { cwd: root, env: gitEnvironment(), encoding: 'utf8', windowsHide: true, timeout: 15000 });
|
||||
git(['init', '--initial-branch=main']); git(['config', 'core.autocrlf', 'false']); git(['config', 'user.name', 'Workbench QA']); git(['config', 'user.email', 'qa@workbench.invalid']);
|
||||
git(['add', '--', '.']); git(['commit', '--no-gpg-sign', '-m', 'Seal compiled controlled-engine acceptance']);
|
||||
const initialHead = git(['rev-parse', 'HEAD']).trim(), writable = ['src/add.mjs', 'src/range.mjs'];
|
||||
const protectedFiles = Object.fromEntries(git(['ls-files', '-z']).split('\0').filter(name => name && !writable.includes(name) && !name.startsWith('owner-'))
|
||||
.map(name => [name, fs.readFileSync(path.join(root, name))]));
|
||||
fs.writeFileSync(path.join(root, 'owner-staged.txt'), 'Owner staged change\n'); git(['add', '--', 'owner-staged.txt']);
|
||||
fs.writeFileSync(path.join(root, 'owner-staged.txt'), 'Owner working copy after staging\n'); fs.writeFileSync(path.join(root, 'owner-unstaged.txt'), 'Owner unstaged change\n');
|
||||
fs.writeFileSync(path.join(root, 'owner-untracked.txt'), 'Owner untracked file\n');
|
||||
const owner = () => ({ staged: git(['show', ':owner-staged.txt']), stagedDiff: git(['diff', '--cached', '--binary', '--', 'owner-staged.txt']),
|
||||
files: Object.fromEntries(['owner-staged.txt', 'owner-unstaged.txt', 'owner-untracked.txt'].map(name => [name, fs.readFileSync(path.join(root, name)).toString('base64')])) });
|
||||
const originalOwner = owner(), verifyProtected = target => { for (const [name, bytes] of Object.entries(protectedFiles)) assert.deepEqual(fs.readFileSync(path.join(target, name)), bytes, name); };
|
||||
const requests = [], reviews = [], cases = [], originalRuns = [], exports = [];
|
||||
const mark = text => { cases.push(text); console.log('PASS ' + text); };
|
||||
let phase = 'new', childRoute, parentRoute, group;
|
||||
const modelServer = http.createServer(async (request, response) => {
|
||||
try {
|
||||
assert.equal(request.url, '/v1/chat/completions'); assert.equal(request.headers.authorization, 'Bearer owned-compiled-engine-fixture');
|
||||
const chunks = []; for await (const chunk of request) chunks.push(chunk);
|
||||
const input = JSON.parse(Buffer.concat(chunks)); assert.equal(input.model, 'owned-compiled-engineering'); assertToolPairs(input.messages);
|
||||
const session = await api(childRoute), job = session.execution.checks.at(-1), plan = session.execution.plans.at(-1);
|
||||
let calls = [];
|
||||
if (session.changes.some(value => value.status === 'pending')) { /* Host review follows native completion. */ }
|
||||
else if (phase !== 'fixed' && job) {
|
||||
assert.equal(job.status, 'failed'); assert.ok(job.results.some(value => value.tests?.failed > 0)); phase = 'fixed';
|
||||
const fixes = { 'src/add.mjs': 'export function add(left, right) {\n if (!Number.isFinite(left) || !Number.isFinite(right)) throw new TypeError("finite numeric inputs required");\n return left + right;\n}\n',
|
||||
'src/range.mjs': 'export function inclusiveRange(start, end) {\n if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || end < start || end - start >= 10000) throw new RangeError("bounded ascending integer range required");\n return Array.from({ length: end - start + 1 }, (_, index) => start + index);\n}\n' };
|
||||
calls = Object.entries(fixes).map(([name, content]) => call(randomUUID(), 'propose_file', { path: name, content, reason: 'Declared local acceptance repair; retain protected tests and configuration.' }));
|
||||
} else if (phase === 'fixed' && job?.status === 'passed') assert.equal(job.results[0].tests.passed, 8);
|
||||
else if (!plan || job?.planId === plan.id) calls = [call(randomUUID(), 'plan_checks', { names: ['test', 'build'] })];
|
||||
else calls = [call(randomUUID(), 'run_checks', { plan_id: plan.id })];
|
||||
requests.push({ input, phase, calls });
|
||||
response.writeHead(200, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ choices: [{ message: { role: 'assistant', content: calls.length ? '' : 'Owned compiled native run complete; host proof remains required.',
|
||||
...(calls.length ? { tool_calls: calls } : {}) }, finish_reason: calls.length ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 123, completion_tokens: 45, total_tokens: 168 } }));
|
||||
} catch (error) { response.writeHead(500, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ error: { message: error.message } })); }
|
||||
});
|
||||
await new Promise(resolve => modelServer.listen(0, '127.0.0.1', resolve));
|
||||
try {
|
||||
await api('/config', { mode: 'compatible', model: 'owned-compiled-engineering', baseUrl: 'http://127.0.0.1:' + modelServer.address().port + '/v1', apiKey: 'owned-compiled-engine-fixture', contextLimit: 64000 });
|
||||
const project = await api('/projects', { root }), parent = await api('/sessions', { projectId: project.id }); parentRoute = '/sessions/' + parent.id;
|
||||
const installation = await api('/engines/deepseek/controlled-availability'); assert.equal(installation.controlledStatus, 'available', installation.message);
|
||||
assert.equal(installation.version, '0.2.1-rc.2');
|
||||
if (contained) assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
|
||||
const source = await api('/engines/purge/source'); assert.equal(source.status, 'available', source.message); assert.equal(source.defaultEnabled, false);
|
||||
const planned = await api(parentRoute + '/collaborations', { goal: 'Deliver compiled controlled-engine Node library with retained failures, review, checks and Git.',
|
||||
engine: { id: 'deepseek-harness', root: installation.root, controlledSha256: installation.controlledSha256,
|
||||
strategy: { kind: 'purge-prompt-experiment', root: source.root, sourceSha256: source.sourceSha256, prompt: '保留原测试与 {{compiled_literal}},按实际失败修复已允许源码,等待宿主审批。' } },
|
||||
budget: { maxTokens: 200000, maxSteps: 64, maxToolCalls: 128, maxDurationMs: 600000 },
|
||||
children: [{ label: 'engine-compiled-node', goal: 'Repair two source modules and pass the original 8 tests and build.', paths: writable }] });
|
||||
group = planned.group;
|
||||
const groupState = async () => (await api(parentRoute + '/collaborations')).groups.find(value => value.id === group.id);
|
||||
const operation = name => api(parentRoute + '/collaborations/' + group.id + '/' + name, { fingerprint: group.fingerprint });
|
||||
await operation('prepare'); await until(async () => { group = await groupState(); return !['preparing', 'planned'].includes(group.status); });
|
||||
assert.equal(group.status, 'ready', group.summary); const child = group.children[0]; childRoute = '/sessions/' + child.sessionId;
|
||||
const childProject = (await api('/bootstrap')).projects.find(value => value.id === child.projectId);
|
||||
assert.notEqual(childProject.root, root); verifyProtected(childProject.root); assert.deepEqual(owner(), originalOwner); assert.equal(requests.length, 0);
|
||||
mark('compiled host seals actual Harness/source identities and prepares one owned worktree while retaining parent bytes and staging');
|
||||
const apply = async (route, set) => { reviews.push({ action: 'apply reviewed change set', id: set.id, fingerprint: set.fingerprint, paths: set.files.map(value => value.path) });
|
||||
await api(route + '/change-sets/' + set.id + '/apply', { fingerprint: set.fingerprint });
|
||||
let state; await until(async () => { state = await api(route + '/change-sets/' + set.id); return !['prepared', 'applying'].includes(state.status); }); assert.equal(state.status, 'completed', state.summary); };
|
||||
for (let turn = 0; turn < 4 && group.status !== 'ready_to_collect'; turn++) {
|
||||
let current = await api(childRoute); const pending = current.changes.filter(value => value.status === 'pending');
|
||||
if (pending.length) { assert.equal(group.status, 'awaiting_review'); const next = await api(childRoute + '/change-sets', { changeIds: pending.map(value => value.id) }); await apply(childRoute, next.execution.changeSets.at(-1)); }
|
||||
await operation('start');
|
||||
await until(async () => {
|
||||
current = await api(childRoute);
|
||||
for (const approval of current.approvals.filter(value => value.status === 'pending')) {
|
||||
const event = current.events.find(value => value.id === approval.eventId); assert.equal(event.tool, 'run_checks');
|
||||
const plan = current.execution.plans.at(-1); assert.deepEqual(plan.checks.map(value => value.name), ['test', 'build']);
|
||||
reviews.push({ action: 'approve original check', id: approval.id, taskId: approval.taskId, invocationId: approval.invocationId, planId: plan.id, contractSha256: plan.contractSha256 });
|
||||
await api(childRoute + '/approvals/' + approval.id, { allow: true });
|
||||
}
|
||||
group = await groupState(); return ['ready_to_collect', 'awaiting_review', 'paused', 'unknown', 'failed', 'stale'].includes(group.status);
|
||||
}, 120000);
|
||||
const run = (await api(childRoute + '/engine-runs')).at(-1); assert.equal(run.status, 'completed', run.error); assert.equal(run.nativeSummary.treeConfirmed, true);
|
||||
const response = await fetch(url + '/api' + childRoute + '/engine-runs/' + run.id + '/download', { headers: { 'X-Workbench-Token': token, Connection: 'close' } });
|
||||
assert.equal(response.status, 200); const bytes = Buffer.from(await response.arrayBuffer()); assert.equal(sha(bytes), run.reportSha256);
|
||||
const original = JSON.parse(bytes); assert.equal(original.native.stderr, ''); assert.equal(original.native.cleanup.treeConfirmed, true);
|
||||
assert.equal(original.native.activity.endEvents[0].data.reason.kind, 'completed');
|
||||
assert.equal(original.native.readiness.promptExperimentSha256, run.installation.strategy.sha256);
|
||||
const saved = path.join(directory, 'compiled-engine-original-' + run.id + '.json'); fs.writeFileSync(saved, bytes); originalRuns.push({ run, original, reportPath: saved, sha256: sha(bytes) });
|
||||
}
|
||||
assert.equal(group.status, 'ready_to_collect', group.summary); const current = await api(childRoute);
|
||||
assert.ok(current.execution.checks.some(value => value.status === 'failed' && value.results.some(result => result.tests?.failed > 0)));
|
||||
assert.equal(current.execution.checks.at(-1).status, 'passed'); assert.equal(current.execution.checks.at(-1).results[0].tests.passed, 8);
|
||||
assert.equal(current.execution.task.usage.requests, requests.length); assert.equal(current.execution.task.usage.totalTokens, requests.length * 168);
|
||||
for (const request of requests) assert.equal(request.input.messages.filter(value => value.role === 'system').map(value => value.content).join('').split(group.children[0].engine.strategy.section.text).length - 1, 1);
|
||||
verifyProtected(childProject.root); assert.deepEqual(owner(), originalOwner);
|
||||
mark('compiled native execution retains failing tests, requires original check approvals, seals literal prompt/model/receipts/results and accounts each owned HTTP request once');
|
||||
await operation('collect'); await until(async () => { group = await groupState(); return group.status !== 'collecting'; }); assert.equal(group.status, 'collected', group.summary);
|
||||
const collection = await api(parentRoute + '/collaborations/' + group.id + '/collection'); assert.deepEqual(collection.conflicts, []); assert.deepEqual(collection.paths, writable);
|
||||
await operation('merge'); await until(async () => { group = await groupState(); return ['merge_prepared', 'unknown', 'stale'].includes(group.status); }); assert.equal(group.status, 'merge_prepared', group.summary);
|
||||
await apply(parentRoute, (await api(parentRoute + '/change-sets/' + group.merge.changeSetId)));
|
||||
const checkPlan = (await api(parentRoute + '/check-plans', { names: ['test', 'build'] })).execution.plans.at(-1);
|
||||
const accepted = (await api(parentRoute + '/check-jobs', { planId: checkPlan.id })).execution.checks.at(-1); let check;
|
||||
await until(async () => { check = await api(parentRoute + '/check-jobs/' + accepted.id); return !['queued', 'running'].includes(check.status); });
|
||||
assert.equal(check.status, 'passed', check.summary); assert.equal(check.results[0].tests.passed, 8); verifyProtected(root);
|
||||
mark('compiled parent review and immutable merge pass the original 8 functional tests and actual ESM build');
|
||||
const deliveryPlan = (await api(parentRoute + '/delivery-plans', { message: 'feat: deliver compiled controlled-engine Node repair' })).execution.deliveryPlans.at(-1);
|
||||
assert.deepEqual(deliveryPlan.paths, writable);
|
||||
const deliveryId = (await api(parentRoute + '/delivery-jobs', { planId: deliveryPlan.id })).execution.deliveries.at(-1).id; let delivery;
|
||||
await until(async () => { delivery = await api(parentRoute + '/delivery-jobs/' + deliveryId); return ['completed', 'failed', 'cancelled', 'unknown'].includes(delivery.status); });
|
||||
assert.equal(delivery.status, 'completed', delivery.summary); assert.equal(git(['rev-parse', 'HEAD^']).trim(), initialHead);
|
||||
assert.deepEqual(git(['diff-tree', '--no-commit-id', '--name-only', '-r', 'HEAD']).trim().split('\n'), writable);
|
||||
assert.deepEqual(owner(), originalOwner); verifyProtected(root); await operation('finalize'); group = await groupState(); assert.equal(group.status, 'completed', group.summary);
|
||||
for (const route of [parentRoute, childRoute]) { const value = await api(route); const file = path.join(directory, value.id + '-session.json'); fs.writeFileSync(file, JSON.stringify(value, null, 2)); exports.push({ id: value.id, file, sha256: sha(fs.readFileSync(file)) }); }
|
||||
mark('compiled Git delivery contains only reviewed modules, preserves staged/unstaged/untracked owner bytes and completes the parent with sealed original evidence');
|
||||
return { success: true, version: bootstrap.version, appRoot, contained, cases, root, group, requests, reviews, originalRuns, exports,
|
||||
protectedFiles: Object.fromEntries(Object.entries(protectedFiles).map(([name, bytes]) => [name, sha(bytes)])), owner: originalOwner, installation, purgeSource: source,
|
||||
checks: check, delivery, fixtureModelRequests: requests.length, realModelRequests: 0,
|
||||
scope: 'Actual compiled host, local native Harness, checks/reviews/Git and an explicitly owned HTTP response fixture. No configured model or upstream Purge plugin executes; real inference benefit remains unmeasured.' };
|
||||
} catch (error) {
|
||||
const sessions = [];
|
||||
for (const route of [parentRoute, childRoute].filter(Boolean)) { try { sessions.push(await api(route)); } catch {} }
|
||||
fs.writeFileSync(path.join(directory, 'compiled-api-failure.json'), JSON.stringify({ success: false, error: error.stack, cases, group, requests, reviews, originalRuns, sessions, realModelRequests: 0 }, null, 2));
|
||||
throw error;
|
||||
} finally {
|
||||
if (group?.status === 'running') { try { await api(parentRoute + '/collaborations/' + group.id + '/stop', { fingerprint: group.fingerprint }); } catch {} }
|
||||
modelServer.closeAllConnections(); await new Promise(resolve => modelServer.close(resolve));
|
||||
}
|
||||
}
|
||||
|
||||
export async function verifyControlledRelease(appRoot = process.cwd()) {
|
||||
appRoot = fs.realpathSync.native(appRoot);
|
||||
const directory = path.resolve('.qa', 'compiled-controlled-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
|
||||
const node = fs.existsSync(path.join(appRoot, 'runtime/node.exe')) ? path.join(appRoot, 'runtime/node.exe') : process.execPath;
|
||||
const env = { ...gitEnvironment(), ...Object.fromEntries(['AGENT_WORKBENCH_DEEPSEEK_ROOT', 'AGENT_WORKBENCH_PURGE_ROOT'].filter(name => process.env[name]).map(name => [name, process.env[name]])),
|
||||
AGENT_WORKBENCH_APP_DIR: appRoot, AGENT_WORKBENCH_DATA_DIR: path.join(directory, 'data'), AGENT_WORKBENCH_PORT: '0' };
|
||||
const child = spawn(node, [path.join(appRoot, 'dist-server/server.mjs')], { cwd: appRoot, env, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let output = '', errors = '', url = '', result, bootstrap;
|
||||
child.stdout.on('data', bytes => { output += bytes.toString('utf8'); for (const line of output.split('\n')) { try { const value = JSON.parse(line); if (value.ready) url = value.url; } catch {} } });
|
||||
child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
|
||||
const api = async (route, input) => {
|
||||
const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', signal: AbortSignal.timeout(30000),
|
||||
headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' }, ...(input === undefined ? {} : { body: JSON.stringify(input) }) });
|
||||
const value = await response.json(); assert.equal(response.ok, true, value.error); return value;
|
||||
};
|
||||
try {
|
||||
await until(() => url || child.exitCode !== null, 15000); assert.ok(url, errors);
|
||||
bootstrap = await (await fetch(url + '/api/bootstrap', { signal: AbortSignal.timeout(5000) })).json();
|
||||
const health = await api('/health'); assert.equal(health.pid, child.pid);
|
||||
result = await verifyControlledApi({ api, url, token: bootstrap.token, directory, appRoot, contained: node !== process.execPath });
|
||||
} catch (error) { result = { success: false, appRoot, directory, error: error.stack, realModelRequests: 0 }; throw error; }
|
||||
finally {
|
||||
try { if (url && bootstrap && child.exitCode === null) { await api('/shutdown', {}); await until(() => child.exitCode !== null || child.signalCode !== null, 15000); } }
|
||||
finally {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
if (process.platform === 'win32') { try { execFileSync('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true, timeout: 10000 }); } catch { child.kill(); } } else child.kill();
|
||||
}
|
||||
fs.writeFileSync(path.join(directory, 'host-stdout-log.txt'), output); fs.writeFileSync(path.join(directory, 'host-stderr-log.txt'), errors);
|
||||
Object.assign(result ??= { success: false }, { directory, pid: child.pid, rootExited: child.exitCode !== null || child.signalCode !== null, exit: { code: child.exitCode, signal: child.signalCode } });
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2));
|
||||
console.log('EVIDENCE ' + directory);
|
||||
}
|
||||
}
|
||||
assert.equal(result.rootExited, true); assert.equal(result.exit.code, 0); return result;
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length === 1 && args[0] === '--help') { console.log('node scripts/verify-controlled-release.mjs [--app-root DIR] - run an actual compiled local host/native Harness/owned model/Node repair/check/review/Git/prompt acceptance in independent data. Requires explicit Harness and Purge source paths.'); process.exit(0); }
|
||||
assert.ok(!args.length || args.length === 2 && args[0] === '--app-root' && path.isAbsolute(args[1]), 'Unsupported argument; use --help.');
|
||||
const result = await verifyControlledRelease(args[1]); console.log(JSON.stringify({ success: result.success, version: result.version, directory: result.directory, cases: result.cases.length,
|
||||
rootExited: result.rootExited, fixtureModelRequests: result.fixtureModelRequests, realModelRequests: 0 }));
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import { spawn } from 'node:child_process';
|
||||
import net from 'node:net';
|
||||
import { createResearchSamples } from './research-fixtures.mjs';
|
||||
import { verifyBrowserApi } from './verify-browser.mjs';
|
||||
import { verifyControlledApi } from './verify-controlled-release.mjs';
|
||||
import { gitEnvironment } from '../src/core/git-process.mjs';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-release.mjs [--native-engines] - validate the latest immutable portable release in an isolated host.'); process.exit(0); }
|
||||
if (process.argv.slice(2).some(value => value !== '--native-engines')) throw new Error('Unsupported argument; use --help.');
|
||||
@@ -26,7 +28,7 @@ const portProbe = net.createServer();
|
||||
await new Promise((resolve, reject) => { portProbe.once('error', reject); portProbe.listen(0, '127.0.0.1', resolve); });
|
||||
const port = portProbe.address().port;
|
||||
await new Promise(resolve => portProbe.close(resolve));
|
||||
const env = { ...process.env, AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: String(port) };
|
||||
const env = { ...gitEnvironment(), ...Object.fromEntries(['AGENT_WORKBENCH_DEEPSEEK_ROOT', 'AGENT_WORKBENCH_PURGE_ROOT'].filter(name => process.env[name]).map(name => [name, process.env[name]])), AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: String(port) };
|
||||
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';
|
||||
@@ -95,7 +97,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'].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'].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')));
|
||||
@@ -127,7 +129,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'].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'].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');
|
||||
@@ -147,11 +149,12 @@ 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'].includes(manifest.version) ? await verifyBrowserApi({ 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'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
|
||||
const actualControlled = manifest.version === '1.14.0' ? 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; } });
|
||||
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,
|
||||
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine, actualBrowser, actualControlled,
|
||||
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));
|
||||
|
||||
@@ -20,7 +20,7 @@ const files = (root, relative = '') => fs.readdirSync(path.join(root, relative),
|
||||
.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 expected = Object.fromEntries(['dist-client', 'dist-server'].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)$/i;
|
||||
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)));
|
||||
const inheritedPath = Object.entries(env).find(([key]) => key.toLowerCase() === 'path')?.[1] || '';
|
||||
for (const key of Object.keys(env)) if (key.toLowerCase() === 'path') delete env[key];
|
||||
@@ -82,7 +82,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'].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'].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));
|
||||
@@ -90,7 +90,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'].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'].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));
|
||||
@@ -98,7 +98,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'].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'].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));
|
||||
@@ -107,14 +107,22 @@ try {
|
||||
assert.ok(actualBrowser.results.every(value => value.status === 'passed' && value.browserExited));
|
||||
assert.equal(actualBrowser.modelRequests, 0);
|
||||
}
|
||||
let actualControlled = null;
|
||||
if (evidence.version === '1.14.0') {
|
||||
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));
|
||||
assert.equal(actualControlled.success, true); assert.equal(actualControlled.version, evidence.version); assert.equal(actualControlled.rootExited, true);
|
||||
assert.equal(actualControlled.realModelRequests, 0); assert.equal(actualControlled.cases, 4); assert.ok(actualControlled.fixtureModelRequests > 0);
|
||||
}
|
||||
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);
|
||||
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, tests: stats, actualRea, actualEngine, actualBrowser, credentialsHandling: 'Only build/runtime environment paths are inherited; no model configuration or credentials are used.' };
|
||||
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 }));
|
||||
inputs, inputFiles: inputs.length, logs, buildMatchedFiles: Object.keys(expected).length, tests: stats, actualRea, actualEngine, actualBrowser, actualControlled, 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 });
|
||||
throw error;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { workerHttp } from '../tests/fixtures/workers-http.mjs';
|
||||
import { workerDefinition, ownerBytes, applyWorkerProposals, approveWorkerChecks } from '../tests/fixtures/workers-project.mjs';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-workers-ui.mjs — owned local fixture, real isolated Git/checks/review, desktop/390px, conflicts, stop, recovery and late source errors'); process.exit(0); }
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version, prefix = version === '1.13.0' ? 'workers' : 'workers-development';
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version, prefix = version === '1.14.0' ? 'controlled-engine-workers' : version === '1.13.0' ? 'workers' : 'workers-development';
|
||||
const directory = path.resolve('.qa', 'workers-ui-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
|
||||
const disposers = [], t = { after: dispose => disposers.push(dispose) }, f = fixture(t), host = await workerHttp(f);
|
||||
assert.notEqual(new URL(host.url).port, '4318');
|
||||
|
||||
Reference in New Issue
Block a user