fix: upgrade directly launched hosts and freeze package QA evidence

This commit is contained in:
Agent Workbench Dev
2026-10-30 14:45:50 +08:00
parent 96de94e722
commit eab5ac077a
7 changed files with 111 additions and 11 deletions
File diff suppressed because one or more lines are too long
+8
View File
@@ -1,5 +1,13 @@
# 汇总发现
## 2026-10-30 直启宿主升级与验收纠正
- 正式4318在本轮首次核对即拒绝连接,PID23080不存在;恢复启动前没有主动停止原进程。按设计原Key只在旧进程内存,当前无法恢复;同一数据目录启动1.10.1为PID19084,模型名/地址和持久会话仍在。
- esbuild把直启入口内请求处理器的捕获变量重命名为server2/store2/provider2等。旧升级器仅识别内联旧宿主的原名称,在真正安装前失败且finally清理调试器。现在兼容原名与实际编译局部名;2/2真实进程回归核对两次升级的PID、会话、应用字节、fixture内存连接和调试器关闭。
- 一次新包运行误将QA解释器设置为不存在的主目录.qa/python-3.10路径,造成15项Python环境失败(282/297),记录见docs/task-plans-package-environment-failure.json,原TAP留在D:/awb2的对应解压目录。随后确认有效解释器仍是独立开发工作区.qa/python-3.10/Scripts/python.exe。
- 运行中的新包报告尚未写出时,读取通用.qa/source-package-validation.json会得到上一次1.10.1的276项旧统计;该值不能作为当前测试进度。验证器已在开始时输出确切sourceRoot和独立运行directory,日志和输入在该目录永久单独保存。
- 缺失QA解释器专项已确认在environment preflight拒绝,安装/构建/测试阶段均未开始、执行日志为0。最终发行将使用正确环境重新验收新增回归后的298项。
## 2026-10-30 真实工程与浏览器能力恢复
- 1.10.0独立274/274及170份输入通过,原PID/Provider升级保存14项目/23会话。实模首轮实际浏览器工具暴露旧SQLite ArtifactStore对象没有readBytes,旧write也不支持PNG原Buffer;原错误及原Task保留。新增回归使用91981c1原ArtifactStore,修复前明确readBytes失败,修复后真实Edge/原PNG和升级失败恢复原对象2/2通过。热升级必须重新打开当前工件API,不能只更新Store原型。
+8
View File
@@ -1,5 +1,13 @@
# 统一执行进度
## 2026-10-30 1.11正式升级收尾
- 4516f66已完成独立1.11候选的297项、归档和便携验收,96de94e合并至main。正式核对时原PID23080已退出,端口4318无监听;用原1.10.1包和同一数据目录恢复到PID19084,未读取或迁移Key。
- 直接启动1.10.1后热升级首次捕获上下文失败,未安装新handler,1.10.1正常可用。查明编译后的处理器局部变量带2后缀,升级器现兼容两种实际名称;补真实直启连续两次和原宿主升级回归,2/2通过。
- 候选20261030063029701安装/构建/REA/SDK/Edge通过,完整297项282通过/15失败,均为本轮误配置不存在的QA Python路径;原日志/结果保留,不能计为最终发行通过。
- 验证器新增环境预检和每次独立结果/输入/日志SHA256;缺失解释器在任何长运行前拒绝的专项通过。有效解释器已实际核对为开发工作区Python3.10.11/pytest8.4.2,接续封存最终输入并验收298项。
- 用户已获异步提示可在工作台模型连接重新配置,不在对话中索取Key。独立发行验收继续,不等待模型连接。
## 2026-10-30 本轮全量接续
- 1.10.0独立源码274/274、6份构建及170份冻结输入通过;原PID23080/Provider升级核对14项目、23会话(7归档),调试端口关闭。实模首轮发现旧ArtifactStore.readBytes缺失,原失败另存而非标成功。1.10.1同目录当前API及回滚回归先1/2失败、修复后2/2通过;继续修复包验收。验收器用带内容resume造成新Task的错误也已按既有API改为只续接原paused/step_limit任务。
+14 -1
View File
@@ -106,8 +106,21 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
const probe = readUpgradeJson(origin + '/api/health', 15000, 'Observe owned request handler');
probe.catch(() => {});
const event = await within(pausedEvent, 10000, 'Workbench request observation');
const captureExpression = "(() => {"
+ " const currentServer = typeof server !== 'undefined' ? server : typeof server2 !== 'undefined' ? server2 : undefined;"
+ " const currentStore = typeof store !== 'undefined' ? store : typeof store2 !== 'undefined' ? store2 : undefined;"
+ " const currentProvider = typeof provider !== 'undefined' ? provider : typeof provider2 !== 'undefined' ? provider2 : undefined;"
+ " const currentRuntime = typeof runtime !== 'undefined' ? runtime : typeof runtime2 !== 'undefined' ? runtime2 : undefined;"
+ " const currentToken = typeof token !== 'undefined' ? token : typeof token2 !== 'undefined' ? token2 : undefined;"
+ " const currentClients = typeof clients !== 'undefined' ? clients : typeof clients2 !== 'undefined' ? clients2 : undefined;"
+ " const currentStarted = typeof started !== 'undefined' ? started : typeof started2 !== 'undefined' ? started2 : undefined;"
+ " const currentExampleProject = typeof exampleProject !== 'undefined' ? exampleProject : typeof exampleProject2 !== 'undefined' ? exampleProject2 : undefined;"
+ " const currentShutdown = typeof shutdown !== 'undefined' ? shutdown : typeof shutdown2 !== 'undefined' ? shutdown2 : undefined;"
+ " const servers = currentServer ? [currentServer] : process._getActiveHandles().filter(handle => handle?.listening && handle.address?.()?.address === '127.0.0.1' && handle.address?.()?.port === " + new URL(origin).port + ");"
+ " if (servers.length !== 1 || !currentStore || !currentProvider || !currentRuntime || !currentToken || !currentClients || !currentShutdown) throw new Error('The existing Workbench context is incomplete.');"
+ " globalThis.__awUpgradeContext = { server: servers[0], store: currentStore, provider: currentProvider, runtime: currentRuntime, token: currentToken, clients: currentClients, started: currentStarted, exampleProject: currentExampleProject, shutdown: currentShutdown }; return 'context-ready'; })()";
const captured = await protocol.send('Debugger.evaluateOnCallFrame', { callFrameId: event.callFrames[0].callFrameId,
expression: "(() => { const servers = typeof server !== 'undefined' ? [server] : process._getActiveHandles().filter(handle => handle?.listening && handle.address?.()?.address === '127.0.0.1' && handle.address?.()?.port === " + new URL(origin).port + "); if (servers.length !== 1) throw new Error('Owned local server not found uniquely'); globalThis.__awUpgradeContext = { server: servers[0], store, provider, runtime, token, clients, started, exampleProject, shutdown }; return 'context-ready'; })()", returnByValue: true });
expression: captureExpression, returnByValue: true });
if (captured.exceptionDetails || captured.result.value !== 'context-ready') throw new Error('Could not retain the existing runtime objects.');
for (const breakpointId of breakpoints.splice(0)) await protocol.send('Debugger.removeBreakpoint', { breakpointId });
await protocol.send('Debugger.resume'); paused = false; await probe;
+38 -9
View File
@@ -1,8 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { spawn } from 'node:child_process';
import { createHash, randomUUID } from 'node:crypto';
import { spawn, execFileSync } from 'node:child_process';
const workspace = process.cwd();
const evidence = JSON.parse(fs.readFileSync('.qa/archives-validation.json', 'utf8'));
@@ -22,24 +22,52 @@ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => all
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];
env.PATH = [path.dirname(process.execPath), inheritedPath].filter(Boolean).join(path.delimiter);
let stage = 'install';
const directory = path.join(sourceRoot, '.qa', 'package-validation-' + randomUUID());
fs.mkdirSync(directory, { recursive: true });
const inputFolders = ['src', 'tests', 'scripts'];
const inputNames = [...inputFolders.flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative))),
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html'].sort();
const snapshot = () => inputNames.map(relative => ({ path: relative.replaceAll('\\', '/'), bytes: fs.statSync(path.join(sourceRoot, relative)).size, sha256: digest(path.join(sourceRoot, relative)) }));
const inputs = snapshot(); fs.writeFileSync(path.join(directory, 'inputs.json'), JSON.stringify(inputs, null, 2));
let stage = 'environment preflight', python = null;
const resultFile = path.join(workspace, '.qa/source-package-validation.json');
const logs = [];
function save(result) {
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2));
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2));
}
function run(args, logName) {
console.log('Source package: ' + stage);
return new Promise((resolve, reject) => {
const outputFile = fs.createWriteStream(path.join(sourceRoot, logName));
const logPath = path.join(directory, logName);
const outputFile = fs.createWriteStream(logPath);
const child = spawn(process.execPath, args, { cwd: sourceRoot, env, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
let tail = '';
const capture = bytes => { outputFile.write(bytes); tail = (tail + bytes.toString('utf8')).slice(-12000); };
child.stdout.on('data', capture); child.stderr.on('data', capture);
const timer = setTimeout(() => child.kill(), 600000);
child.once('error', error => { clearTimeout(timer); outputFile.end(); reject(error); });
child.once('close', code => { clearTimeout(timer); outputFile.end(); code === 0 ? resolve(tail) : reject(new Error(stage + ' failed (' + code + '): ' + tail)); });
child.once('close', code => { clearTimeout(timer); outputFile.end(() => {
logs.push({ stage, path: logPath, sha256: digest(logPath), bytes: fs.statSync(logPath).size });
code === 0 ? resolve(tail) : reject(new Error(stage + ' failed (' + code + '): ' + tail));
}); });
});
}
try {
assert.equal(JSON.parse(fs.readFileSync(path.join(sourceRoot, 'package.json'), 'utf8')).version, evidence.version);
assert.match(process.version, /^v24\./, 'Source package validation requires Node.js 24.');
if (env.AGENT_WORKBENCH_TEST_PYTHON) {
assert.ok(path.isAbsolute(env.AGENT_WORKBENCH_TEST_PYTHON) && fs.existsSync(env.AGENT_WORKBENCH_TEST_PYTHON), 'AGENT_WORKBENCH_TEST_PYTHON must name an existing absolute QA interpreter.');
const executable = fs.realpathSync.native(env.AGENT_WORKBENCH_TEST_PYTHON);
python = JSON.parse(execFileSync(executable, ['-I', '-c', 'import json,sys,pytest; print(json.dumps({"version":sys.version.split()[0],"pytest":pytest.__version__}))'], { env, windowsHide: true, encoding: 'utf8', timeout: 10000 }));
assert.ok(Number(python.version.split('.')[0]) === 3 && Number(python.version.split('.')[1]) >= 10, 'QA Python must be 3.10 or newer.');
assert.equal(python.pytest, '8.4.2', 'Install the fixed QA requirements before validating the source package.');
python.path = executable; env.AGENT_WORKBENCH_TEST_PYTHON = executable;
}
console.log(JSON.stringify({ sourceRoot, directory, nodeVersion: process.version, python }));
stage = 'install';
await run([npmCli, 'ci', '--offline', '--no-audit', '--no-fund'], 'install.log');
stage = 'build'; await run([npmCli, 'run', 'build'], 'build.log');
const actualFiles = ['dist-client', 'dist-server'].flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative)));
@@ -75,10 +103,11 @@ try {
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);
const result = { success: true, version: evidence.version, testedAt: new Date().toISOString(), sourceRoot, offlineInstall: true,
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.' };
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2)); console.log(JSON.stringify(result, null, 2));
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 }));
} catch (error) {
fs.writeFileSync(resultFile, JSON.stringify({ success: false, version: evidence.version, stage, error: error.message, sourceRoot }, null, 2));
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
View File
@@ -2,6 +2,14 @@
## 1.11 当前开发:持久任务依赖与证据收尾
最新接续:main已合并为96de94e;断线后核对原PID23080已退出,原Key未持久化。同一正式数据目录已用1.10.1恢复为PID19084,15项目/18可见会话,原模型名/地址保留、hasKey=false。先完成下列收尾,再进入1.12:
1. [complete] 修复直启编译宿主的局部变量重命名导致热升级无法捕获上下文;真实直启连续两次升级及原0.1宿主2/2回归通过。
2. [complete] 源码包验证增加固定解释器预检、实际环境和每次独立日志/输入SHA256;缺失解释器在任何安装/执行前拒绝。
3. [in_progress] 封存最后升级修复和新增回归后生成最终不可变包,用已确认的QA Python 3.10.11/pytest8.4.2验收298项;不读取未更新的通用结果作为新进度。
4. [pending] 归档/源码/便携通过后保留PID19084升级,核对包含归档的全部数据库会话、执行记录及实际页面。
5. [pending] 如用户已在模型连接补回Key,续接原真实页面Task;否则记录连接缺失并完成无需模型的发行验收,不伪造实模结果。
1. [complete] 有界无环依赖、不可变/只追加修订、原目标与工作区绑定及真实工具/变更/检查/页面证据。
2. [complete] 模型工具、上下文保留、未完成暂停、Git预览/提交核对及交付报告。
3. [complete] 任务记录界面、桌面/390px与迟到响应/宿主恢复验收。
+28 -1
View File
@@ -3,10 +3,37 @@ import assert from 'node:assert/strict';
import path from 'node:path';
import fs from 'node:fs';
import { spawn } from 'node:child_process';
import { fixture, compatibleFixture, until, workspace } from './helpers.mjs';
import { fixture, compatibleFixture, until, workspace, launchWorkbench } from './helpers.mjs';
import { upgradeRunning } from '../scripts/upgrade-running.mjs';
import { APP_VERSION } from '../src/server/diagnostics.mjs';
test('a directly started compiled host upgrades twice with the same PID, sessions, applied bytes and volatile provider', { timeout: 30000 }, async t => {
const f = fixture(t), host = await launchWorkbench(t, f.data);
const model = await compatibleFixture(t, () => ({ data: [{ id: 'direct-upgrade-fixture' }] }));
await host.api('/config', { mode: 'compatible', model: 'direct-upgrade-fixture', baseUrl: model.baseUrl, apiKey: 'fixture-direct-memory-key' });
await host.api('/sessions/' + f.session.id + '/proposals', { path: 'DIRECT-UPGRADE.md', content: '# Preserve applied source\n' });
const proposed = await host.api('/sessions/' + f.session.id);
await host.api('/sessions/' + f.session.id + '/changes/' + proposed.changes.at(-1).id + '/apply', {});
const before = await host.api('/sessions/' + f.session.id), bootstrap = await host.api('/bootstrap');
const beforeBytes = fs.readFileSync(path.join(f.projectRoot, 'DIRECT-UPGRADE.md'));
let previousRoot;
for (const label of ['first', 'second']) {
const nextRoot = path.join(f.root, 'compiled-upgrade-' + label); fs.mkdirSync(nextRoot);
for (const name of ['dist-server', 'dist-client']) fs.cpSync(path.join(workspace, name), path.join(nextRoot, name), { recursive: true });
const result = await upgradeRunning({ url: host.url, pid: host.child.pid, currentRoot: workspace, handlerRoot: previousRoot, newRoot: nextRoot });
assert.equal(result.version, APP_VERSION); assert.equal(result.pid, host.child.pid); assert.equal(result.verified, true); assert.equal(result.hasKey, true);
const afterBootstrap = await host.api('/bootstrap');
assert.equal(afterBootstrap.runtimeRoot, nextRoot); assert.deepEqual(afterBootstrap.projects, bootstrap.projects); assert.deepEqual(afterBootstrap.sessions, bootstrap.sessions);
assert.deepEqual(await host.api('/sessions/' + f.session.id), before);
assert.deepEqual(fs.readFileSync(path.join(f.projectRoot, 'DIRECT-UPGRADE.md')), beforeBytes);
assert.deepEqual((await host.api('/config/models', {})).models, ['direct-upgrade-fixture']);
assert.equal(model.requests.at(-1).headers.authorization, 'Bearer fixture-direct-memory-key');
assert.ok(!fs.readFileSync(path.join(f.data, 'config.json'), 'utf8').includes('fixture-direct-memory-key'));
await assert.rejects(fetch('http://127.0.0.1:9229/json/list', { signal: AbortSignal.timeout(500) }));
previousRoot = nextRoot;
}
});
test('the running 0.1.0 process upgrades in place and retains its project, session, files and volatile model connection', { timeout: 60000 }, async t => {
const f = fixture(t);
const legacyData = path.join(f.root, 'legacy-data'); f.store.exportLegacyData(legacyData);