feat(runtime): observe turn evidence without changing execution controls

This commit is contained in:
Agent Workbench Dev
2026-11-04 11:26:47 +08:00
parent 785dd0c54d
commit 6fe04042c5
291 changed files with 66740 additions and 3 deletions
+56
View File
@@ -0,0 +1,56 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
const root = path.resolve('docs/turn-progress-b-evidence'), qa = path.resolve('.qa/requirements-progress');
assert.equal(fs.existsSync(root), false, 'Do not overwrite an existing stage seal.'); fs.mkdirSync(root);
const digest = bytes => createHash('sha256').update(bytes).digest('hex');
const copy = (source, relative) => {
assert.equal(fs.lstatSync(source).isSymbolicLink(), false); const target = path.join(root, relative);
if (fs.statSync(source).isDirectory()) { fs.mkdirSync(target, { recursive: true }); for (const name of fs.readdirSync(source)) copy(path.join(source, name), relative + '/' + name); }
else { fs.mkdirSync(path.dirname(target), { recursive: true }); fs.copyFileSync(source, target, fs.constants.COPYFILE_EXCL); }
};
const sourceFiles = [
'src/core/context/turn-progress.mjs', 'src/core/context/turn-progress-recorder.mjs', 'src/core/delivery-report.mjs', 'src/server/runtime.mjs',
'src/client/TurnProgress.tsx', 'src/client/TaskPanel.tsx', 'src/client/TaskPanel.css', 'src/client/types.ts', 'tests/turn-progress.test.mjs',
'scripts/verify-turn-progress-ui.mjs', 'scripts/verify-turn-progress-evidence.mjs', 'scripts/verify-adoption-evidence.mjs', 'scripts/seal-turn-progress-evidence.mjs',
].map(file => { const snapshot = 'source/' + file; copy(path.resolve(file), snapshot); return { path: file, snapshot }; });
const testRuns = [
['shadow-first.tap', 11, 9, 2], ['shadow-second.tap', 12, 12, 0], ['shadow-related.tap', 68, 68, 0],
['shadow-final.tap', 31, 31, 0], ['shadow-source-final.tap', 31, 31, 0],
].map(([name, tests, passed, failed]) => { copy(path.join(qa, name), 'logs/' + name); return { path: 'logs/' + name, tests, passed, failed }; });
for (const name of ['build-shadow-first.log', 'build-shadow-second.log', 'build-shadow-final.log', 'build-shadow-check-wait.log', 'build-shadow-source-final.log', 'official-readonly-boundary.json']) copy(path.join(qa, name), 'logs/' + name);
const uiRuns = [], observedRuns = [];
for (const [name, folder, final] of [
['shadow-ui-first', 'web-first', false], ['shadow-electron-first', 'electron-first', false],
['shadow-ui-final', 'web-touch', false], ['shadow-electron-final', 'electron-touch', false],
['shadow-ui-source-final', 'web-final', true], ['shadow-electron-source-final', 'electron-final', true],
]) {
const log = fs.readFileSync(path.join(qa, name + '.log'), 'utf8'); copy(path.join(qa, name + '.log'), 'logs/' + name + '.log');
const result = JSON.parse(log.trim().split(/\r?\n/).at(-1)), source = path.resolve(result.directory), relative = 'ui/' + folder;
assert.ok(source.startsWith(qa + path.sep)); assert.equal(result.success, true); copy(source, relative);
uiRuns.push({ path: relative + '/result.json', success: true, passed: 9 }); if (final) observedRuns.push(relative);
}
const caseReview = {
scope: 'Fixed public-fact cases manually reviewed against original assertions; no population accuracy or model benefit claim.',
cases: [
{ case: 'normal_exploration', expected: 'new observed content is evidence growth', evidence: 'logs/shadow-source-final.tap', assertion: 'fixed normal exploration, pagination, SHA changes and repeated ranges' },
{ case: 'pagination_and_repetition', expected: '10 new + 10 new + repeated candidate, original step_limit', evidence: 'ui/web-final/pages-original.json' },
{ case: 'read_only_research', expected: 'reading is useful; summary wording is not additional engineering evidence; no shadow interruption', evidence: 'logs/shadow-source-final.tap', assertion: 'read-only research is valid work' },
{ case: 'long_check', expected: 'approved actual running job stays waiting, then counted result', evidence: 'logs/shadow-source-final.tap', assertion: 'actual approved long check' },
{ case: 'failure_repair_evidence', expected: 'applied file, actual counted check and current requirement proof grow after baseline', evidence: 'logs/shadow-source-final.tap', assertion: 'real applied files, counted checks and current requirement proofs' },
{ case: 'permission_denial', expected: 'waiting then original permission failure; earlier same-turn read consumed once', evidence: 'ui/electron-final/approval-denied.json' },
{ case: 'broken_tool_or_network', expected: 'new failure is evidence; original failure categories remain distinct', evidence: 'logs/shadow-source-final.tap', assertion: 'new permissions, network and broken tools' },
{ case: 'invalid_input_repetition', expected: 'repeat candidate, no new early stop; original four-request step_limit', evidence: 'logs/shadow-source-final.tap', assertion: 'actual invalid tool calls repeat under the original step budget' },
{ case: 'bounded_unknown', expected: 'unretained facts stay unknown; old receipts retained and scope cannot mix', evidence: 'logs/shadow-source-final.tap', assertion: 'receipt retention stays aligned at the cap' },
],
limitations: ['No real model delivery sample.', 'No intervention thresholds or global false-positive/false-negative rate.', 'No Purge comparison or network recovery claim.'],
};
fs.writeFileSync(path.join(root, 'case-review.json'), JSON.stringify(caseReview, null, 2));
const walk = directory => fs.readdirSync(directory, { withFileTypes: true }).flatMap(row => row.isDirectory() ? walk(path.join(directory, row.name)) : [path.join(directory, row.name)]);
const files = walk(root).map(file => { const bytes = fs.readFileSync(file); return { path: path.relative(root, file).replaceAll('\\', '/'), bytes: bytes.length, sha256: digest(bytes) }; }).sort((a, b) => a.path.localeCompare(b.path));
const manifest = { kind: 'adoption-stage-evidence', stage: 'turn-progress-b', status: 'development_slice_validated_not_released',
realModelRequests: 0, officialServiceChanged: false, sourceFiles, testRuns, uiRuns, observedRuns, files, bytes: files.reduce((sum, row) => sum + row.bytes, 0) };
fs.writeFileSync(path.join(root, 'manifest.json'), JSON.stringify(manifest, null, 2));
console.log(JSON.stringify({ root, files: files.length, bytes: manifest.bytes, sourceFiles: sourceFiles.length, uiRuns: uiRuns.length }));
+68
View File
@@ -0,0 +1,68 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
const [directory, ...options] = process.argv.slice(2), root = path.resolve(directory ?? 'docs/turn-progress-b-evidence');
const digest = value => createHash('sha256').update(typeof value === 'string' || Buffer.isBuffer(value) ? value : JSON.stringify(value)).digest('hex');
const read = relative => { const file = path.resolve(root, relative); assert.ok(file.startsWith(root + path.sep)); return fs.readFileSync(file); };
const json = relative => JSON.parse(read(relative));
execFileSync(process.execPath, ['scripts/verify-adoption-evidence.mjs', root, ...options], { stdio: 'pipe' });
const manifest = json('manifest.json'); assert.equal(manifest.stage, 'turn-progress-b');
let snapshots = 0, receipts = 0, toolResults = 0, originalArtifacts = 0;
for (const directory of manifest.observedRuns) {
const result = json(directory + '/result.json'), index = new Map(json(directory + '/source-artifacts.json').map(row => [row.id, row]));
assert.equal(result.success, true); assert.equal(result.passed.length, 9); assert.equal(result.realModelRequests, 0);
const artifact = id => { const row = index.get(id); assert.ok(row, 'Missing original artifact: ' + id); const bytes = read(directory + '/' + row.path);
assert.equal(digest(bytes), row.sha256); assert.equal(bytes.length, row.bytes); return { row, bytes }; };
for (const id of index.keys()) { artifact(id); originalArtifacts++; }
const snapshot = name => json(directory + '/' + name + '.json');
for (const name of result.snapshots) {
const value = json(directory + '/' + name), { session, execution } = value, run = execution.run, shadow = run.progressShadow; snapshots++;
assert.deepEqual(shadow.scope, { projectId: session.projectId, sessionId: session.id, taskId: run.taskId, runId: run.id });
assert.equal(shadow.mode, 'shadow'); assert.equal(shadow.turns.length, run.progressShadowArtifactIds.length);
const ranges = new Map();
for (const [i, turn] of shadow.turns.entries()) {
const original = artifact(run.progressShadowArtifactIds[i]); assert.equal(original.row.kind, 'turn-progress-shadow');
assert.equal(digest(JSON.parse(original.bytes)), digest(turn)); assert.equal(turn.runId, run.id); assert.equal(turn.taskId, run.taskId); receipts++;
let growth = 0, repeated = 0;
for (const ref of turn.tools) {
if (ref.tool === 'model_request') {
const event = session.events.find(row => row.id === ref.source_event_id && row.runId === run.id);
assert.ok(event?.diagnostic); assert.equal(event.diagnostic.id, ref.id); assert.equal(digest(event.diagnostic), ref.diagnostic_sha256);
if (ref.result_artifact_id) assert.equal(artifact(ref.result_artifact_id).row.sha256, ref.result_sha256);
continue;
}
const event = session.events.find(row => row.invocationId === ref.id && row.runId === run.id && row.taskId === run.taskId);
assert.ok(event); assert.equal(event.tool, ref.tool); assert.equal(event.artifactId, ref.result_artifact_id);
const call = session.providerMessages.flatMap(row => row.tool_calls ?? []).find(row => row.id === event.toolCallId);
assert.ok(call); assert.equal(call.function.name, ref.tool); assert.equal(digest(String(call.function.arguments)), ref.args_sha256);
const source = artifact(ref.result_artifact_id); assert.equal(source.row.kind, 'tool-result'); assert.equal(source.row.sha256, ref.result_sha256); toolResults++;
const metadata = execution.artifacts.find(row => row.id === ref.result_artifact_id);
assert.ok(metadata); assert.equal(metadata.runId, run.id); assert.equal(metadata.taskId, run.taskId); assert.equal(metadata.projectId, session.projectId);
const result = JSON.parse(source.bytes);
if (ref.tool !== 'read_file' || typeof result.content !== 'string') continue;
const start = result.offset ?? 0, end = result.next_offset ?? start + result.content.length;
assert.equal(end - start, result.content.length);
const key = JSON.stringify([result.path, result.sha256, result.range_start_line ?? result.start_line ?? null, result.range_end_line ?? result.end_line ?? null]);
const covered = ranges.get(key) ?? new Set(); let added = 0;
for (let position = start; position < end; position++) if (!covered.has(position)) { covered.add(position); added++; }
ranges.set(key, covered); growth += added; if (!added) repeated++;
}
assert.equal(turn.delta.read_characters, growth); assert.equal(turn.delta.repeated_reads, repeated);
if (turn.phase === 'waiting') assert.equal(turn.classification, 'waiting');
}
}
const pages = snapshot('pages-original'), settled = pages.execution.run.progressShadow.turns.filter(row => row.phase === 'settled');
assert.equal(pages.execution.run.stopReason, 'step_limit'); assert.deepEqual(settled.map(row => [row.stepIndex, row.classification, row.delta.read_characters]),
[[1, 'evidence_growth', 10], [2, 'evidence_growth', 10], [3, 'repeated_read_candidate', 0]]);
const waiting = snapshot('approval-waiting'), denied = snapshot('approval-denied'), failure = snapshot('network-original');
assert.equal(waiting.session.status, 'awaiting_approval'); assert.equal(waiting.execution.run.progressShadow.turns.at(-1).waiting[0].kind, 'approval');
assert.equal(denied.session.taskId, pages.session.taskId); assert.notEqual(denied.execution.run.id, pages.execution.run.id);
assert.equal(denied.session.approvals.at(-1).status, 'denied'); assert.equal(denied.execution.run.progressShadow.turns.find(row => row.phase === 'settled').delta.repeated_reads, 0);
assert.equal(failure.session.status, 'failed'); assert.equal(failure.session.lastFailure.httpStatus, 502); assert.equal(failure.execution.run.stopReason, null);
assert.equal(failure.execution.run.progressShadow.turns.at(-1).classification, 'new_failure_evidence');
const report = json(directory + '/report.json'); assert.equal(report.turnObservations.length, 2); assert.ok(report.turnObservations.every(row => row.evidence_verified));
}
console.log(JSON.stringify({ ok: true, runs: manifest.observedRuns.length, snapshots, receipts, toolResults, originalArtifacts, realModelRequests: 0, replayedOperations: 0 }));
+151
View File
@@ -0,0 +1,151 @@
import fs from 'node:fs';
import path from 'node:path';
import net from 'node:net';
import assert from 'node:assert/strict';
import { randomUUID, createHash } from 'node:crypto';
import { chromium, _electron } from 'playwright';
import { fixture, compatibleFixture, launchWorkbench, until, call, completion } from '../tests/helpers.mjs';
import { HostController } from '../src/core/desktop/host-controller.mjs';
import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs';
import { projectEnvironment } from '../src/core/process-environment.mjs';
// Existing UI-verifier convention: a real browser/Electron, isolated data and a
// localhost model protocol fixture. No configured provider or real key is used.
const desktop = process.argv.includes('--desktop');
const directory = path.resolve('.qa/requirements-progress', (desktop ? 'shadow-electron-' : 'shadow-ui-') + randomUUID());
fs.mkdirSync(directory, { recursive: true });
const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t);
let scenario = 'pages', requests = 0;
const model = await compatibleFixture(t, () => {
const request = ++requests;
if (scenario === 'network') return { status: 502, body: { error: { message: 'Owned shadow gateway failure, original response retained' } } };
if (scenario === 'approval') return { body: request === 1 ? completion([
call('read-before-approval', 'read_file', { path: 'README.md', limit: 10 }),
call('owned-command', 'run_command', { command: 'node --version', reason: '所属只读环境检查,需原审批' }),
]) : completion([], '原审批已拒绝,说明与原工具结果保留。') };
return { body: completion([call('page-' + request, 'read_file', { path: 'README.md', offset: request === 1 ? 0 : 10, limit: 10 })]) };
});
f.session.title = '单轮观察分页原任务'; f.store.save(f.session);
const networkSession = f.store.createSession(f.project.id); networkSession.title = '单轮观察原网络失败'; f.store.save(networkSession);
f.store.saveConfig({ mode: 'compatible', model: 'owned-shadow-ui', baseUrl: model.baseUrl, maxSteps: 3 }); f.store.close();
const passed = [], screenshots = [], errors = [], snapshots = [], sourceArtifacts = new Map(); let browser, application, controller, host, page, window, result;
const mark = name => { passed.push(name); console.log('PASS ' + name); };
const panel = () => page.getByLabel('单轮观察', { exact: true });
async function visiblePanel() {
if (!await page.getByLabel('选择运行记录', { exact: true }).isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
await panel().waitFor();
if (!await panel().evaluate(element => element.open)) await panel().locator('summary').click();
}
async function select(session) {
if (!await page.getByLabel('当前项目').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
await page.getByLabel('当前项目').selectOption(f.project.id);
await page.locator('.session-list button').filter({ hasText: session.title }).click();
}
async function resize(width, height) {
if (window) { await window.evaluate((win, size) => win.setContentSize(size.width, size.height), { width, height }); await until(() => page.evaluate(w => innerWidth === w, width)); }
else await page.setViewportSize({ width, height });
}
async function shot(name) {
await panel().scrollIntoViewIfNeeded(); const file = path.join(directory, name + '.png');
await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file);
}
async function state(session = f.session) { return host.api('/sessions/' + session.id); }
async function originalArtifact(artifact, session) {
let content = '', offset = 0, page;
do { page = await host.api('/artifacts/' + artifact.id + '?session=' + session.id + '&offset=' + offset + '&limit=16000'); content += page.content; offset += page.content.length; }
while (page.truncated && page.content.length);
const bytes = Buffer.from(content); assert.equal(createHash('sha256').update(bytes).digest('hex'), artifact.sha256);
assert.equal(bytes.length, artifact.bytes); return content;
}
async function saved(name, session = f.session) {
const snapshot = await host.api('/sessions/' + session.id + '/export');
for (const artifact of snapshot.execution.artifacts.filter(row => ['turn-progress-shadow', 'tool-result', 'model-http-response', 'model-stream-response', 'delivery-report', 'delivery-report-markdown'].includes(row.kind))) {
if (sourceArtifacts.has(artifact.id)) continue;
const content = await originalArtifact(artifact, session), relative = 'artifacts/' + artifact.id + '.txt';
fs.mkdirSync(path.join(directory, 'artifacts'), { recursive: true }); fs.writeFileSync(path.join(directory, relative), content);
sourceArtifacts.set(artifact.id, { id: artifact.id, kind: artifact.kind, sha256: artifact.sha256, bytes: artifact.bytes, path: relative });
}
fs.writeFileSync(path.join(directory, name + '.json'), JSON.stringify(snapshot, null, 2)); snapshots.push(name + '.json'); return snapshot;
}
try {
if (desktop) {
const socket = net.createServer(); await new Promise(resolve => socket.listen(0, '127.0.0.1', resolve));
const port = socket.address().port; await new Promise(resolve => socket.close(resolve)); assert.notEqual(port, 4318);
controller = new HostController({ appRoot: process.cwd(), dataRoot: f.data, port, nodePath: process.execPath, timeoutMs: 60000 });
await controller.start(); host = { url: controller.url, bootstrap: await controller.api('/bootstrap'),
api: (route, input) => controller.api(route, input === undefined ? {} : { method: 'POST', input }) };
const executable = desktopExecutableIdentity(process.cwd()).path;
application = await _electron.launch({ executablePath: executable,
args: [...(executable.toLowerCase().endsWith('agentworkbench.exe') ? [] : [path.resolve('dist-desktop/main.cjs')]), '--app-root', process.cwd(), '--data-root', f.data, '--node', process.execPath, '--port', String(port), '--hidden-window'],
cwd: process.cwd(), env: projectEnvironment(), timeout: 60000 });
page = await application.firstWindow(); window = await application.browserWindow(page);
await window.evaluate(win => { win.showInactive(); win.setContentSize(1440, 1080); }); await until(() => page.evaluate(() => innerWidth === 1440));
assert.equal(await page.evaluate(() => typeof globalThis.process), 'undefined');
} else {
host = await launchWorkbench(t, f.data); assert.notEqual(new URL(host.url).port, '4318');
browser = await chromium.launch({ channel: 'msedge', headless: true }); page = await browser.newPage({ viewport: { width: 1440, height: 1080 } }); await page.goto(host.url);
}
assert.equal(host.bootstrap.config.hasKey, false); page.on('pageerror', error => errors.push(error.message));
await page.locator('.connection.connected').waitFor(); await select(f.session);
await host.api('/sessions/' + f.session.id + '/messages', { content: '只研究README.md原说明,不修改文件;本机固定分页观察夹具。' });
await until(async () => (await state()).status === 'paused', 25000);
const first = await state(), firstRun = first.execution.run;
assert.equal(requests, 3); assert.equal(firstRun.stopReason, 'step_limit'); await visiblePanel();
await until(async () => (await panel().textContent()).includes('重复读取候选'));
assert.match(await panel().textContent(), /第 1 轮 · 新增外显证据/); assert.match(await panel().textContent(), /第 3 轮 · 重复读取候选/);
assert.equal(firstRun.progressShadow.turns[1].delta.read_characters, 10); assert.equal(firstRun.progressShadow.turns[2].delta.read_characters, 10);
await shot('desktop-pages'); await saved('pages-original'); mark('actual runtime pages grow then repeat under the original three-round limit');
await panel().locator('li').nth(1).getByRole('button', { name: '查看原观察收据', exact: true }).click();
const dialog = page.getByRole('dialog', { name: '执行结果工件', exact: true }); await dialog.waitFor();
assert.match(await dialog.textContent(), /evidence_growth/); assert.match(await dialog.textContent(), /result_artifact_id/);
await dialog.getByRole('button', { name: '关闭窗口', exact: true }).click(); mark('original observation receipt opens with the actual tool-result provenance');
await page.reload(); await page.locator('.connection.connected').waitFor(); await visiblePanel();
assert.equal(await page.getByLabel('选择运行记录').inputValue(), firstRun.id); assert.match(await panel().textContent(), /重复读取候选/);
mark('refresh restores the same Task, Run and persisted shadow observations');
await resize(390, 844); await visiblePanel();
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true);
assert.ok((await panel().getByRole('button', { name: '查看原观察收据', exact: true }).first().boundingBox()).height >= 44);
await shot('narrow-pages'); mark('390px keeps observation facts and original receipt actions reachable without page overflow');
await resize(1440, 1080); scenario = 'approval'; requests = 0;
await host.api('/sessions/' + f.session.id + '/resume', { content: '继续核对所属环境;命令只经原审批执行。' });
await until(async () => (await state()).status === 'awaiting_approval', 25000); await visiblePanel();
await until(async () => (await panel().textContent()).includes('等待所属操作')); await shot('waiting-approval');
const waiting = await state(); assert.equal(waiting.execution.run.progressShadow.turns.at(-1).classification, 'waiting');
await saved('approval-waiting'); mark('an actual pending approval stays waiting and does not consume the earlier same-turn read twice');
await page.getByRole('button', { name: '拒绝执行', exact: true }).click();
await until(async () => (await state()).status === 'completed', 25000); const second = await state();
assert.equal(requests, 2); assert.equal(second.taskId, first.taskId); assert.notEqual(second.execution.run.id, firstRun.id);
assert.equal(second.execution.run.progressShadow.turns.find(row => row.phase === 'settled').delta.repeated_reads, 0);
await until(async () => (await panel().textContent()).includes('新失败 1')); await shot('denied-approval');
assert.match(await panel().textContent(), /失败类别:权限或审批拒绝/);
await saved('approval-denied'); mark('refusing the original approval preserves the permission failure and the original tool pairs');
await page.getByLabel('选择运行记录').selectOption(firstRun.id);
await until(async () => (await panel().textContent()).includes('第 3 轮 · 重复读取候选'));
await shot('historical-run'); await page.getByLabel('选择运行记录').selectOption(second.execution.run.id);
await until(async () => !(await panel().textContent()).includes('第 3 轮')); mark('selecting historical and current Runs keeps their independent observations');
await host.api('/sessions/' + f.session.id + '/delivery-reports', {});
const reportExport = await saved('report-original');
const reportArtifact = reportExport.execution.artifacts.filter(row => row.kind === 'delivery-report').at(-1);
const report = JSON.parse(await originalArtifact(reportArtifact, f.session));
assert.equal(report.turnObservations.length, 2); assert.ok(report.turnObservations.every(row => row.evidence_verified));
fs.writeFileSync(path.join(directory, 'report.json'), JSON.stringify(report, null, 2)); mark('delivery report uses both Runs and independently verifies the original observation receipts');
scenario = 'network'; requests = 0; await select(networkSession);
await host.api('/sessions/' + networkSession.id + '/messages', { content: '读取原工程,保存失败来源;本机502夹具。' });
await until(async () => (await state(networkSession)).status === 'failed', 25000); await visiblePanel();
await until(async () => (await panel().textContent()).includes('新增失败证据'));
assert.match(await panel().textContent(), /失败类别:上游服务/);
const failure = await state(networkSession); assert.equal(failure.lastFailure.httpStatus, 502); assert.equal(failure.execution.run.stopReason, null);
await shot('network-original-failure'); await saved('network-original', networkSession);
mark('original HTTP 502 remains a model failure and is not relabeled as no progress'); assert.deepEqual(errors, []);
result = { success: true, passed, errors, screenshots, snapshots, actualElectron: desktop, installationValidated: false, realModelRequests: 0, officialServiceTouched: false };
} catch (error) {
if (page) { try { await page.screenshot({ path: path.join(directory, 'failure.png') }); fs.writeFileSync(path.join(directory, 'failure-dom.txt'), await page.locator('body').innerText()); } catch {} }
result = { success: false, passed, errors, screenshots, snapshots, error: error.stack, actualElectron: desktop, realModelRequests: 0, officialServiceTouched: false };
} finally {
if (application) await application.close(); if (browser) await browser.close();
if (controller && await controller.health()) await controller.stop();
for (const dispose of disposers.reverse()) await dispose();
fs.writeFileSync(path.join(directory, 'source-artifacts.json'), JSON.stringify([...sourceArtifacts.values()], null, 2));
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2));
}
console.log(JSON.stringify({ directory, ...result })); if (!result.success) process.exitCode = 1;