From eab5ac077a003dfcdb2145dc429f03b015ff9caa Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Fri, 30 Oct 2026 14:45:50 +0800 Subject: [PATCH] fix: upgrade directly launched hosts and freeze package QA evidence --- ...ask-plans-package-environment-failure.json | 7 +++ findings.md | 8 ++++ progress.md | 8 ++++ scripts/upgrade-running.mjs | 15 +++++- scripts/verify-source-package.mjs | 47 +++++++++++++++---- task_plan.md | 8 ++++ tests/upgrade.test.mjs | 29 +++++++++++- 7 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 docs/task-plans-package-environment-failure.json diff --git a/docs/task-plans-package-environment-failure.json b/docs/task-plans-package-environment-failure.json new file mode 100644 index 00000000..64b9ccff --- /dev/null +++ b/docs/task-plans-package-environment-failure.json @@ -0,0 +1,7 @@ +{ + "success": false, + "version": "1.11.0", + "stage": "tests", + "error": "tests failed (1): g\nok 254 - real HTTP repeated state inspection pauses after three identical engineering outcomes and preserves tool pairing\n ---\n duration_ms: 2794.9444\n type: 'test'\n ...\n# Subtest: a live SQLite host with the actual 1.9 artifact object upgrades, keeps its original blobs and verifies real browser PNG bytes\nok 255 - a live SQLite host with the actual 1.9 artifact object upgrades, keeps its original blobs and verifies real browser PNG bytes\n ---\n duration_ms: 3954.3533\n type: 'test'\n ...\n# Subtest: failed upgrade restores the original artifact object, provider and request handler\nok 256 - failed upgrade restores the original artifact object, provider and request handler\n ---\n duration_ms: 635.0206\n type: 'test'\n ...\n# Subtest: the running 0.1.0 process upgrades in place and retains its project, session, files and volatile model connection\nok 257 - the running 0.1.0 process upgrades in place and retains its project, session, files and volatile model connection\n ---\n duration_ms: 7798.3227\n type: 'test'\n ...\n# Subtest: small code and actual failed command stay visible when their original multi-tool group cannot fit\nok 258 - small code and actual failed command stay visible when their original multi-tool group cannot fit\n ---\n duration_ms: 1224.3576\n type: 'test'\n ...\n# Subtest: mixed group retains six distinct small file observations with exact multilingual text and bounded request bytes\nok 259 - mixed group retains six distinct small file observations with exact multilingual text and bounded request bytes\n ---\n duration_ms: 1680.7367\n type: 'test'\n ...\n# Subtest: working observations are bound to the current Task and stop treating a pre-application file revision as current evidence\nok 260 - working observations are bound to the current Task and stop treating a pre-application file revision as current evidence\n ---\n duration_ms: 1751.944\n type: 'test'\n ...\n# Subtest: a sealed observation rejects changed or missing original result artifacts instead of recreating evidence\nok 261 - a sealed observation rejects changed or missing original result artifacts instead of recreating evidence\n ---\n duration_ms: 1540.0627\n type: 'test'\n ...\n# Subtest: a real passed-check observation is excluded after a source edit invalidates the check, while its historical sent evidence remains valid\nok 262 - a real passed-check observation is excluded after a source edit invalidates the check, while its historical sent evidence remains valid\n ---\n duration_ms: 4786.5386\n type: 'test'\n ...\n# Subtest: budgeted file pages reconstruct UTF-8 text including long single lines and surrogate boundaries\nok 263 - budgeted file pages reconstruct UTF-8 text including long single lines and surrogate boundaries\n ---\n duration_ms: 4.559\n type: 'test'\n ...\n# Subtest: actual HTTP multi-tool reads survive an oversized runtime snapshot and the sealed evidence survives reopening\nok 264 - actual HTTP multi-tool reads survive an oversized runtime snapshot and the sealed evidence survives reopening\n ---\n duration_ms: 13885.6878\n type: 'test'\n ...\n# Subtest: actual HTTP file pagination advances over a long file with each returned page visible in the next request\nok 265 - actual HTTP file pagination advances over a long file with each returned page visible in the next request\n ---\n duration_ms: 2382.6609\n type: 'test'\n ...\n# Subtest: later mixed history pages cannot displace the actual module sources and complete requirements\nok 266 - later mixed history pages cannot displace the actual module sources and complete requirements\n ---\n duration_ms: 7066.9146\n type: 'test'\n ...\n# Subtest: a later narrow page of the same file revision cannot evict the wider actual observation\nok 267 - a later narrow page of the same file revision cannot evict the wider actual observation\n ---\n duration_ms: 4110.3891\n type: 'test'\n ...\n# Subtest: historical read-artifact navigation points to the original artifact and next page, never its result wrapper\nok 268 - historical read-artifact navigation points to the original artifact and next page, never its result wrapper\n ---\n duration_ms: 1679.5968\n type: 'test'\n ...\n# Subtest: a 1.6.1 full-provenance sent view remains verifiable after introducing the compact view\nok 269 - a 1.6.1 full-provenance sent view remains verifiable after introducing the compact view\n ---\n duration_ms: 1862.7916\n type: 'test'\n ...\n# Subtest: actual HTTP requests keep four observed modules after a later large history read and preserve all source bytes\nok 270 - actual HTTP requests keep four observed modules after a later large history read and preserve all source bytes\n ---\n duration_ms: 14176.5241\n type: 'test'\n ...\n# Subtest: workspace HTTP ownership, reviewed creation and reopen survive restart without changing source files\nok 271 - workspace HTTP ownership, reviewed creation and reopen survive restart without changing source files\n ---\n duration_ms: 6766.2046\n type: 'test'\n ...\n# Subtest: isolated model Task applies a batch, executes real checks and commits at the Git review boundary with a source-bound report\nok 272 - isolated model Task applies a batch, executes real checks and commits at the Git review boundary with a source-bound report\n ---\n duration_ms: 30099.5263\n type: 'test'\n ...\n# warning: in the working copy of 'src/空 格.mjs', LF will be replaced by CRLF the next time Git touches it\n# Subtest: worktree checkout disables hooks, fsmonitor and all filter command variants while honoring built-in EOL conversion\nok 273 - worktree checkout disables hooks, fsmonitor and all filter command variants while honoring built-in EOL conversion\n ---\n duration_ms: 5371.2442\n type: 'test'\n ...\n# Subtest: an ignored external file at checkout is observed and never accepted as pristine creation\nok 274 - an ignored external file at checkout is observed and never accepted as pristine creation\n ---\n duration_ms: 4397.5891\n type: 'test'\n ...\n# Subtest: outside content hidden by assume-unchanged cannot pass workspace verification and blocks further source execution\nok 275 - outside content hidden by assume-unchanged cannot pass workspace verification and blocks further source execution\n ---\n duration_ms: 3988.4783\n type: 'test'\n ...\n# Subtest: workspace preparation refuses known shared-repository activity and preserves archived child sessions\nok 276 - workspace preparation refuses known shared-repository activity and preserves archived child sessions\n ---\n duration_ms: 3993.2706\n type: 'test'\n ...\n# Subtest: compact checkout identities create in deep Unicode source directories while retaining the human branch name\nok 277 - compact checkout identities create in deep Unicode source directories while retaining the human branch name\n ---\n duration_ms: 4435.0406\n type: 'test'\n ...\n# Subtest: Windows Git metadata path limits reject creation before publishing a branch or changing source bytes\nok 278 - Windows Git metadata path limits reject creation before publishing a branch or changing source bytes\n ---\n duration_ms: 2310.3929\n type: 'test'\n ...\n# Subtest: a pending source snapshot participates in shutdown and completes before storage can close\nok 279 - a pending source snapshot participates in shutdown and completes before storage can close\n ---\n duration_ms: 1772.3266\n type: 'test'\n ...\n# Subtest: source configuration values stay private and a configuration change invalidates a saved review\nok 280 - source configuration values stay private and a configuration change invalidates a saved review\n ---\n duration_ms: 2838.686\n type: 'test'\n ...\n# Subtest: workspace review rejects excluded dependency before any checkout\nok 281 - workspace review rejects excluded dependency before any checkout\n ---\n duration_ms: 2228.3579\n type: 'test'\n ...\n# Subtest: workspace review rejects large committed blob before any checkout\nok 282 - workspace review rejects large committed blob before any checkout\n ---\n duration_ms: 2185.6543\n type: 'test'\n ...\n# Subtest: workspace review rejects case collision before any checkout\nok 283 - workspace review rejects case collision before any checkout\n ---\n duration_ms: 2436.9294\n type: 'test'\n ...\n# Subtest: workspace review rejects committed symbolic link before any checkout\nok 284 - workspace review rejects committed symbolic link before any checkout\n ---\n duration_ms: 2425.1903\n type: 'test'\n ...\n# Subtest: workspace review rejects external config include before any checkout\nok 285 - workspace review rejects external config include before any checkout\n ---\n duration_ms: 2236.0459\n type: 'test'\n ...\n# Subtest: actual process exit at workspace intent preserves source and reconciles without creation replay\nok 286 - actual process exit at workspace intent preserves source and reconciles without creation replay\n ---\n duration_ms: 4081.0344\n type: 'test'\n ...\n# Subtest: actual process exit at workspace git_started preserves source and reconciles without creation replay\nok 287 - actual process exit at workspace git_started preserves source and reconciles without creation replay\n ---\n duration_ms: 5362.5923\n type: 'test'\n ...\n# Subtest: actual process exit at workspace git_finished preserves source and reconciles without creation replay\nok 288 - actual process exit at workspace git_finished preserves source and reconciles without creation replay\n ---\n duration_ms: 5065.4375\n type: 'test'\n ...\n# Subtest: actual process exit at workspace verifying preserves source and reconciles without creation replay\nok 289 - actual process exit at workspace verifying preserves source and reconciles without creation replay\n ---\n duration_ms: 5037.6291\n type: 'test'\n ...\n# Subtest: actual process exit at workspace registering preserves source and reconciles without creation replay\nok 290 - actual process exit at workspace registering preserves source and reconciles without creation replay\n ---\n duration_ms: 5607.0692\n type: 'test'\n ...\n# Subtest: actual process exit at workspace project_registered preserves source and reconciles without creation replay\nok 291 - actual process exit at workspace project_registered preserves source and reconciles without creation replay\n ---\n duration_ms: 6646.5938\n type: 'test'\n ...\n# Subtest: actual process exit at workspace session_registered preserves source and reconciles without creation replay\nok 292 - actual process exit at workspace session_registered preserves source and reconciles without creation replay\n ---\n duration_ms: 6524.7166\n type: 'test'\n ...\n# Subtest: actual process exit at workspace ready preserves source and reconciles without creation replay\nok 293 - actual process exit at workspace ready preserves source and reconciles without creation replay\n ---\n duration_ms: 5510.1231\n type: 'test'\n ...\n# Subtest: outside changes at project registration remain unknown and preserve the already registered child identity\nok 294 - outside changes at project registration remain unknown and preserve the already registered child identity\n ---\n duration_ms: 5735.3562\n type: 'test'\n ...\n# Subtest: managed worktree preserves source index and dirty files, opens a distinct project and binds Run identity\nok 295 - managed worktree preserves source index and dirty files, opens a distinct project and binds Run identity\n ---\n duration_ms: 4858.6567\n type: 'test'\n ...\n# Subtest: stale review, branch/path collisions and forged ownership do not run worktree creation\nok 296 - stale review, branch/path collisions and forged ownership do not run worktree creation\n ---\n duration_ms: 3218.3544\n type: 'test'\n ...\n# Subtest: workspace project verification is read-only and rejects physical Git identity changes\nok 297 - workspace project verification is read-only and rejects physical Git identity changes\n ---\n duration_ms: 3735.9212\n type: 'test'\n ...\n1..297\n# tests 297\n# suites 0\n# pass 282\n# fail 15\n# cancelled 0\n# skipped 0\n# todo 0\n# duration_ms 497629.1685\n", + "sourceRoot": "D:\\awb2\\source-check-e47f685fb7484548ade146cfe98a5086\\Agent-Workbench-1.11.0-source-20261030063029701" +} \ No newline at end of file diff --git a/findings.md b/findings.md index a07574cd..9c9ea43c 100644 --- a/findings.md +++ b/findings.md @@ -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原型。 diff --git a/progress.md b/progress.md index 9e531298..e610feca 100644 --- a/progress.md +++ b/progress.md @@ -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任务。 diff --git a/scripts/upgrade-running.mjs b/scripts/upgrade-running.mjs index 0d819c9f..ad9a019f 100644 --- a/scripts/upgrade-running.mjs +++ b/scripts/upgrade-running.mjs @@ -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; diff --git a/scripts/verify-source-package.mjs b/scripts/verify-source-package.mjs index c898be15..e79220f7 100644 --- a/scripts/verify-source-package.mjs +++ b/scripts/verify-source-package.mjs @@ -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; } diff --git a/task_plan.md b/task_plan.md index cf9f9cb4..47a73ed8 100644 --- a/task_plan.md +++ b/task_plan.md @@ -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与迟到响应/宿主恢复验收。 diff --git a/tests/upgrade.test.mjs b/tests/upgrade.test.mjs index 94f0919f..f525d3ab 100644 --- a/tests/upgrade.test.mjs +++ b/tests/upgrade.test.mjs @@ -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);