test(live): freeze AD passthrough compatibility and autonomous Node driver

This commit is contained in:
Agent Workbench Dev
2026-11-06 12:45:27 +08:00
parent f87aa92a40
commit 9c60c11135
9 changed files with 533 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# AD:默认透传下的新供应商兼容与独立工程验证
这是 C / 1.25.8 之后的新批次;不续跑 X、AA、AB、AC、W 或任何用户原项目。保留它们的错误、原额度和未交付结论。程序来源 a6e31dec,实际宿主与连接身份在 initial 中重新冻结。
使用当前启用且公开 hasKey=true 的五条连接:DeepSeek、apikey Chat、apikey Responses、apikey-Claude、jojocode。legacy 占位无凭据时跳过。保留用户「高性能」池和已有模型/原生参数,不读取、解密、复制或重存 Key,不将所有连接一律视为同一种协议。
每条连接仅做一次 DNS/TLS 诊断、一次上游目录预览(仅产品正常分页,不应用目录),随后文本与工具各一个全新会话、每项一次真实请求。使用已有 Provider 的凭据引用,身份策略只在预检 Run 配置中 require-match;不保存到连接。文本要求唯一 nonce,工具要求原 nonce 的一次 echo 调用,预检不执行模型工具。每次都保存原请求/原响应、上游错误、身份、实际用量及缓存字段。目录没有原 HTTP 工件时明示只有规范化预览,不补造原响应。
网络诊断观察30秒后仅停止自己创建的诊断,目录观察90秒后取消自己的预览;失败保留且不重发。连接定义必须保持,真实请求自然产生的health/status/activeRequests记录单列,不把健康记录更新误判为参数修改。
新样本采用现有 unrestricted/full/passthrough:不设置上下文、输出、累计 token 或步数额度,不添加 max_tokens / max_output_tokens / max_completion_tokens。每项预检一个请求是实验设计;180秒观察结束会取消本次预检并保留未知,不是修改产品默认额度,不自动重发。失败不换线续接该样本;其它连接是预先列出的独立样本。
Node 选线在结果前固定优先序:DeepSeek → apikey Responses → apikey Chat → apikey-Claude → jojocode;必须该连接目录完整且列出所选型号、文本与工具预检均完整身份 matched 且 nonce 正确,才进入工程。预检短答/工具返回不证明长期稳定或模型权重真实。
Node 从原 immutable expense benchmark 复制到新隔离目录、新 Task 和 Git 基线,原九项测试/构建脚本与用户已有暂存、未暂存和未跟踪文件均保护。模型自行读取、修改三个 src 模块、运行原检查并本地 Git 交付,不提供实现答案、不代写文件、不代批步骤、不因停止再发“继续”。允许 full 模式下原生终端与产品工程工具,符合用户当前使用方式;不与旧受限工具/16K/2048样本做单因素因果比较。
工程观察窗口十分钟,三分钟没有任何新读取事实/源码变化/检查结果时主动停止并标记实验观察终止;不改产品运行额度,也不冒认为模型交付。越出任务范围、改写原测试或已有暂存、身份失败、上游错误、模型自行停下都保存现场。模型停下后独立检查最终源码、原九项测试/build及真实 Git diff;模型的“完成了”文字不作通过证据。临时单线选择和 require-match 恢复原用户选择/策略,修订单调递增;外部新配置不被覆盖。
公开编辑会使所选连接revision/+2、updatedAt更新并将其移到连接列表末尾;原未显式身份策略会保存等价record/[]/空来源。选择及恢复使configRevision单调增加,全部其它配置字段须逐项相同;这些变化明确列入对账,不称原字节exact。工程成功还要求所有真实尝试均为所属连接、完整matched、无unknown用量,原九项测试9/9、build退出0、真实提交只包含三源码模块且提交字节等于当前源码,所有owner字节和原index保持。
调用前驱动验证:三协议×文本/工具的六个本机HTTP请求全部通过(ad-driver-a5e6645f);前两轮健康状态断言、Responses夹具把completed误当HTTP状态的失败均保留。独立Node驱动固定模型夹具通过三请求、9/9原测试/build、本地Git及owner/index保护(ad-node-driver-b79b6bbf),该夹具有固定实现,只证明驱动与执行通路,不作为真实自主交付或供应商能力。真实批次尚未执行,冻结时绑定本地提交。
Node 完整通过后才另冻 React/Python;它们通过后才原版 Purge AB/BA。未满足前置一律记未执行,收益 unknown。Purge 实验不得悄悄恢复全局限制或修改历史样本。
全部阶段验证、原错误、回顾和本地提交;不推送、不委派。原网络间歇、普遍重复读取、缓存收益、真实预留边界和 Purge 未验证事项继续保留。
+71
View File
@@ -0,0 +1,71 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { DatabaseSync } from 'node:sqlite';
import { Agent, fetch } from 'undici';
export let root = path.resolve('.qa/live-validation-ad'), origin = 'http://127.0.0.1:4318';
// Used only by the isolated local driver verifier, never by a real batch.
export function configureFixture(options) {
const target = path.resolve(options.root), url = new URL(options.origin);
assert.equal(path.dirname(target), path.resolve('.qa')); assert.match(path.basename(target), /^ad-node-driver-[a-f0-9-]{36}$/);
assert.equal(url.hostname, '127.0.0.1'); assert.notEqual(url.port, '4318'); assert.ok(url.port);
root = target; origin = url.origin;
}
export function connectionDefinition(value) {
const { health, status, activeRequests, ...definition } = value;
return definition;
}
export function connectionInput(value) {
const fields = ['id', 'revision', 'name', 'brand', 'model', 'baseUrl', 'enabled', 'requiresKey', 'streaming', 'protocol', 'messagesAuth',
'capabilityDeclarations', 'contextLimit', 'maxOutputTokens', 'concurrency', 'nativeParameters', 'outputTokenField',
'modelIdentityPolicy', 'modelIdentityAliases', 'modelIdentityAliasSource', 'parameterProfile'];
return Object.fromEntries(fields.filter(key => Object.hasOwn(value, key)).map(key => [key, value[key]]));
}
export function compareConfig(before, after) {
assert.ok(Number.isInteger(after.configRevision) && after.configRevision >= before.configRevision);
assert.deepEqual({ ...after, configRevision: before.configRevision }, before);
return { original: before.configRevision, current: after.configRevision, allOtherFields: 'exact' };
}
export const sha = value => createHash('sha256').update(value).digest('hex');
export const save = (relative, value) => {
const file = path.join(root, relative); fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, typeof value === 'string' || Buffer.isBuffer(value) ? value : JSON.stringify(value, null, 2) + '\n', { flag: 'wx' });
};
export const read = relative => JSON.parse(fs.readFileSync(path.join(root, relative), 'utf8'));
export function attempts() {
const db = new DatabaseSync(path.join(read('current.json').host.identity.dataRoot, 'workbench.sqlite'), { readOnly: true });
try { const row = db.prepare('SELECT value FROM metadata WHERE key=?').get('modelAttempts'); return row ? JSON.parse(row.value) : []; }
finally { db.close(); }
}
export async function client() {
const dispatcher = new Agent({ connect: { autoSelectFamily: true, timeout: 5000 } }); let token;
const api = async (route, input, timeout = 30000) => {
const response = await fetch(origin + '/api' + route, { dispatcher, method: input === undefined ? 'GET' : 'POST', redirect: 'error', signal: AbortSignal.timeout(timeout),
headers: { ...(token ? { 'X-Workbench-Token': token } : {}), 'Content-Type': 'application/json', Connection: 'close' },
...(input === undefined ? {} : { body: JSON.stringify(input) }) });
const value = await response.json();
if (!response.ok) throw Object.assign(new Error(route + ': ' + (value.error ?? response.status)), { status: response.status, response: value });
return value;
};
const boot = await api('/bootstrap'); token = boot.token;
return { api, boot, close: () => dispatcher.close() };
}
export async function captureAttempts(api, rows, relative) {
const captures = [];
for (const row of rows) for (const kind of ['request', 'response']) {
const id = row[kind + 'ArtifactId']; if (!id) continue;
let content = '', page;
do { page = await api('/artifacts/' + id + '?session=' + row.sessionId + '&offset=' + content.length + '&limit=16000'); content += page.content; } while (page.truncated);
assert.equal(sha(content), row[kind + 'Sha256']);
const name = relative + '/' + row.id + '-' + kind + (kind === 'request' ? '.json' : row.streaming ? '.sse' : '.txt');
save(name, content); captures.push({ attemptId: row.id, kind, path: name, sha256: sha(content), bytes: Buffer.byteLength(content) });
}
return captures;
}
export async function captureSession(api, sessionId, prefix) {
const state = await api('/sessions/' + sessionId); save(prefix + '/session.json', state); save(prefix + '/export.json', await api('/sessions/' + sessionId + '/export'));
const rows = attempts().filter(value => value.sessionId === sessionId); save(prefix + '/attempts.json', rows);
const captures = await captureAttempts(api, rows, prefix + '/captures'); return { state, rows, captures };
}
+61
View File
@@ -0,0 +1,61 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { setTimeout as delay } from 'node:timers/promises';
import { root, save, read, client, captureSession, connectionDefinition } from './common.mjs';
import { invokeProbe, inspectorClosed } from './inspector.mjs';
const original = read('current.json'); assert.equal(fs.existsSync(path.join(root, 'compatibility')), false, 'Never replay this batch.');
save('compatibility/started.json', { at: new Date().toISOString(), noRetry: true, noConfigurationSave: true });
const { api, boot, close } = await client(), results = [];
try {
assert.equal(boot.version, '1.25.8'); await inspectorClosed();
for (const connection of original.connections) {
const prefix = 'compatibility/' + connection.id, current = (await api('/model-center')).connections.find(value => value.id === connection.id);
assert.deepEqual(connectionDefinition(current), connectionDefinition(connection), 'Frozen connection changed before its experiment.');
const result = { connectionId: connection.id, name: connection.name, model: connection.model, protocol: connection.protocol, preflights: [] };
console.log(JSON.stringify({ phase: 'compatibility', connection: connection.name, protocol: connection.protocol }));
let started;
try {
started = await api('/model-center/network-diagnostics', { id: connection.id, revision: connection.revision }); save(prefix + '/network-start.json', started);
const deadline = Date.now() + 30000; let network;
do { const status = await api('/model-center/network-diagnostics'); network = status.jobs.find(value => value.id === started.job.id); if (network && network.finishedAt) break;
if (Date.now() > deadline) { const stopped = await api('/model-center/network-diagnostics/' + started.job.id + '/stop', {}); network = stopped.job; result.networkObservationEnded = true; break; } await delay(250); } while (true);
save(prefix + '/network.json', network); result.network = network.status;
assert.equal(network.httpRequests, 0); assert.equal(network.modelRequests, 0); assert.equal(network.credentialAccess, false);
} catch (error) {
result.network = 'error'; save(prefix + '/network-error.json', { error: error.stack, status: error.status, response: error.response, noRetry: true });
if (started?.job?.id) save(prefix + '/network-owned-stop.json', await api('/model-center/network-diagnostics/' + started.job.id + '/stop', {}));
}
const requestId = randomUUID();
try {
const catalog = await api('/model-center/catalog', { id: connection.id, revision: connection.revision, requestId }, 90000);
save(prefix + '/catalog.json', catalog); result.catalog = { complete: catalog.complete, models: catalog.entries.length, selectedListed: catalog.entries.some(value => value.id === connection.model), rawHttpArtifactAvailable: false };
} catch (error) { result.catalog = { complete: false, error: error.message, status: error.status, response: error.response, noRetry: true }; save(prefix + '/catalog-error.json', result.catalog); }
finally { save(prefix + '/catalog-cancel.json', await api('/model-center/catalog/cancel', { id: requestId })); }
const projectRoot = path.join(root, prefix, 'project'); fs.mkdirSync(projectRoot, { recursive: true }); fs.writeFileSync(path.join(projectRoot, 'README.md'), 'AD isolated connection preflight only. No engineering implementation.\n', { flag: 'wx' });
const project = await api('/projects', { root: projectRoot }); result.projectId = project.id;
for (const scope of ['text', 'tools']) {
const session = await api('/sessions', { projectId: project.id }), nonce = randomUUID();
const input = { pid: original.host.identity.pid, port: 4318, runtimeRoot: boot.runtimeRoot, projectId: project.id, sessionId: session.id, connection, scope, nonce };
save(prefix + '/' + scope + '/input.json', input);
let invoked;
try { invoked = await invokeProbe(input); save(prefix + '/' + scope + '/invocation.json', invoked); }
catch (error) { save(prefix + '/' + scope + '/invocation-error.json', { error: error.stack, noRetry: true }); }
const captured = await captureSession(api, session.id, prefix + '/' + scope), attempt = captured.rows[0];
const passed = !!invoked?.result.contentPassed && invoked.result.actualToolsExecuted === 0 && captured.rows.length === 1
&& attempt.status === 'completed' && attempt.modelIdentity?.status === 'matched' && attempt.modelIdentity.complete === true;
const entry = { scope, passed, sessionId: session.id, identity: attempt?.modelIdentity ?? null, usage: attempt?.usage ?? null,
usageStatus: attempt?.usageStatus ?? 'not_dispatched', status: attempt?.status ?? 'not_dispatched', diagnostic: invoked?.result.diagnostic ?? null, requests: captured.rows.length, captures: captured.captures };
save(prefix + '/' + scope + '/result.json', entry); result.preflights.push(entry); console.log(JSON.stringify({ connection: connection.name, scope, passed, identity: entry.identity?.status, usage: entry.usage }));
assert.ok(captured.rows.length <= 1); await inspectorClosed();
}
result.engineeringAllowed = result.catalog.complete && result.catalog.selectedListed && result.preflights.every(value => value.passed);
save(prefix + '/result.json', result); results.push(result);
}
const center = await api('/model-center');
assert.deepEqual(center.selected, original.center.selected); assert.deepEqual(center.connections.map(connectionDefinition), original.center.connections.map(connectionDefinition)); assert.deepEqual(center.pools, original.center.pools);
save('compatibility/result.json', { completed: true, results, requests: results.reduce((sum, row) => sum + row.preflights.reduce((n, value) => n + value.requests, 0), 0),
originalConnectionDefinitionsPoolsSelection: 'exact', healthObservationChangesRetained: true, keysReadOrResaved: false, historicalSamplesReplayed: false });
} finally { await inspectorClosed(); await close(); }
+23
View File
@@ -0,0 +1,23 @@
import fs from 'node:fs';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { publicSnapshot } from '../retained-host-state.mjs';
import { root, origin, save, client } from './common.mjs';
import { inspectorClosed } from './inspector.mjs';
assert.equal(fs.existsSync(root), false, 'AD freezes once, never replay.');
assert.equal(execFileSync('git', ['status', '--porcelain'], { encoding: 'utf8', windowsHide: true }).trim(), '');
const { api, boot, close } = await client();
try {
await inspectorClosed(); const host = await api('/host/status'), center = await api('/model-center');
assert.equal(boot.version, '1.25.8'); assert.equal(host.activity.active, false); assert.equal(host.desktopWindows.count, 0);
for (const [key, expected] of Object.entries({ executionMode: 'unrestricted', capacityMode: 'passthrough', approvalMode: 'full', maxSteps: 0, maxRunTokens: 0, maxTaskTokens: 0 })) assert.equal(boot.config[key], expected, key);
const connections = center.connections.filter(value => value.enabled && value.hasKey);
assert.equal(connections.length, 5, 'Refreeze a new plan if the current connection set changes.');
const baseline = await publicSnapshot(origin, host.identity.dataRoot);
save('current.json', { observedAt: new Date().toISOString(), host, config: boot.config, center, connections, baseline,
engineeringPriority: ['1a7a55a9-29f2-4b9f-8ea2-5a55afd7eacd', '09b0293b-faad-45c3-832d-7c8b615813aa', '93d0cf6d-4f32-4918-9da8-6f125aa8a6e5', '9ae348a5-d0a6-42ed-8664-0da5f9effe34', '5b4daed9-b2f7-4de0-b949-573eba70c7b3'],
driverCommit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim(), modelRequests: 0 });
console.log(JSON.stringify({ frozen: true, version: boot.version, pid: host.identity.pid, projects: baseline.projects, sessions: baseline.database.sessionIds.length,
selected: center.selected, connections: connections.map(value => ({ id: value.id, name: value.name, protocol: value.protocol, model: value.model, revision: value.revision })), modelRequests: 0 }));
} finally { await close(); }
+58
View File
@@ -0,0 +1,58 @@
import assert from 'node:assert/strict';
import net from 'node:net';
import { setTimeout as delay } from 'node:timers/promises';
import { providerPreflight } from './payload.mjs';
export async function inspectorClosed() {
return new Promise((resolve, reject) => {
const socket = net.createConnection({ host: '127.0.0.1', port: 9229 }); socket.setTimeout(1500);
socket.once('connect', () => { socket.destroy(); reject(Error('Inspector already open.')); });
socket.once('error', e => { socket.destroy(); e.code === 'ECONNREFUSED' ? resolve(true) : reject(e); });
socket.once('timeout', () => { socket.destroy(); reject(Error('Inspector state unknown.')); });
});
}
class Protocol {
constructor(socket) {
this.socket = socket; this.nextId = 1; this.pending = new Map();
socket.addEventListener('message', event => {
const m = JSON.parse(String(event.data)); if (!m.id) return;
const p = this.pending.get(m.id); if (!p) return; this.pending.delete(m.id); clearTimeout(p.timer);
m.error ? p.reject(Error(m.error.message)) : p.resolve(m.result);
});
socket.addEventListener('close', () => { for (const p of this.pending.values()) { clearTimeout(p.timer); p.reject(Error('Inspector closed; outcome unknown.')); } this.pending.clear(); });
}
send(method, params, timeout = 10000) {
return new Promise((resolve, reject) => {
const id = this.nextId++, timer = setTimeout(() => { this.pending.delete(id); reject(Error('Inspector timeout; do not replay.')); }, timeout);
this.pending.set(id, { resolve, reject, timer }); this.socket.send(JSON.stringify({ id, method, params }));
});
}
}
export async function invokeProbe(input) {
await inspectorClosed(); let socket, protocol, enabled = false;
try {
process._debugProcess(input.pid); enabled = true;
let targets;
for (let i = 0; i < 40 && !targets; i++) {
await delay(100);
try { targets = await (await fetch('http://127.0.0.1:9229/json/list', { signal: AbortSignal.timeout(700) })).json(); } catch {}
}
assert.equal(targets?.length, 1);
assert.ok(targets[0].webSocketDebuggerUrl.startsWith('ws://127.0.0.1:9229/'));
socket = new WebSocket(targets[0].webSocketDebuggerUrl);
await new Promise((resolve, reject) => { socket.addEventListener('open', resolve, { once: true }); socket.addEventListener('error', reject, { once: true }); });
protocol = new Protocol(socket);
const identity = await protocol.send('Runtime.evaluate', { expression: 'process.pid', returnByValue: true });
assert.equal(identity.result.value, input.pid);
const expression = '(' + providerPreflight.toString() + ')(' + JSON.stringify(input) + ')';
const result = await protocol.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, 345000);
if (result.exceptionDetails) throw Error(result.exceptionDetails.exception?.description ?? result.exceptionDetails.text);
return { result: result.result.value, expression };
} finally {
if (protocol && enabled) {
await protocol.send('Runtime.evaluate', { expression: "setTimeout(() => process.getBuiltinModule('inspector').close(), 25); 'closing'", returnByValue: true });
await delay(200);
}
socket?.close();
await inspectorClosed();
}
}
+120
View File
@@ -0,0 +1,120 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { execFileSync, spawnSync } from 'node:child_process';
import { setTimeout as delay } from 'node:timers/promises';
import { gitEnvironment } from '../../src/core/git-process.mjs';
import { root, save, read, client, sha, captureSession, connectionDefinition, connectionInput, compareConfig } from './common.mjs';
const compatibility = read('compatibility/result.json'), frozen = read('current.json');
const priority = frozen.engineeringPriority;
assert.ok(Array.isArray(priority) && priority.length > 0);
const connectionId = priority.find(id => compatibility.results.some(value => value.connectionId === id && value.engineeringAllowed));
assert.equal(fs.existsSync(path.join(root, 'node')), false, 'Never replay a Node sample.');
if (!connectionId) { save('node/result.json', { success: false, executed: false, reason: 'No connection passed the predeclared compatibility gate.', reactPythonExecuted: false, purgeExecuted: false }); process.exit(0); }
const sourceRoot = path.join(root, 'node/expense-project'), allowed = ['src/amount.mjs', 'src/summary.mjs', 'src/report.mjs'];
const { api, boot, close } = await client(); let session, route, original, configured, selectedWritten = false, state, failure, result;
const git = args => execFileSync('git', ['--no-pager', '--no-optional-locks', '-C', sourceRoot, ...args], { encoding: 'utf8', windowsHide: true, env: gitEnvironment() });
let protectedBytes, staged, initialHead; const observations = [], reads = new Set(); let lastNovel = Date.now();
const protect = () => {
if (!protectedBytes) return;
for (const [name, bytes] of Object.entries(protectedBytes)) assert.deepEqual(fs.readFileSync(path.join(sourceRoot, name)), bytes, 'Protected file: ' + name);
assert.equal(git(['show', ':owner-staged.txt']), staged, 'Original owner staging is preserved.');
};
const check = (name, args, prefix) => {
const executed = spawnSync(process.execPath, args, { cwd: sourceRoot, windowsHide: true, encoding: 'utf8', env: gitEnvironment(), maxBuffer: 16 * 1024 * 1024 });
save(prefix + '/' + name + '.txt', (executed.stdout ?? '') + (executed.stderr ?? ''));
const stdout = executed.stdout ?? '', stats = name === 'test' ? Object.fromEntries(['tests','pass','fail','cancelled','skipped','todo'].map(key => [key, Number(stdout.match(new RegExp('^# ' + key + ' (\\d+)$', 'm'))?.[1] ?? NaN)])) : null;
return { status: executed.status, signal: executed.signal, error: executed.error?.message ?? null, stats, stdoutSha256: sha(stdout), stderrSha256: sha(executed.stderr ?? '') };
};
const testArgs = ['--test', '--test-reporter=tap', 'test/expense.test.mjs'];
const settle = async () => {
if (!route) return;
await api(route + '/stop', {}, 60000); // Stop/await only our new Task and its owned tools.
state = await api(route);
assert.ok(!['running','stopping','awaiting_approval'].includes(state.status), 'Owned Task must be quiescent before independent checks.');
};
try {
assert.equal(boot.version, '1.25.8'); const host = await api('/host/status'); assert.equal(host.activity.active, false); assert.equal(host.desktopWindows.count, 0);
assert.equal(boot.config.approvalMode, 'full'); assert.equal(boot.config.capacityMode, 'passthrough');
const center = await api('/model-center'); original = center.connections.find(value => value.id === connectionId);
assert.deepEqual(connectionDefinition(original), connectionDefinition(frozen.connections.find(value => value.id === connectionId)));
assert.deepEqual(center.selected, frozen.center.selected); assert.deepEqual(center.pools, frozen.center.pools); compareConfig(frozen.config, boot.config);
save('node/contract.json', { connectionId, originalConnection: original, originalSelection: center.selected, config: boot.config, allowed,
maxObservationMs: 600000, noNewFactObservationMs: 180000, localTokenOrStepCapsChanged: false,
implementationSupplied: false, supervisorContinuation: false, keysReadOrResaved: false });
fs.cpSync('benchmarks/live-delivery-v1/node', sourceRoot, { recursive: true, errorOnExist: true });
fs.writeFileSync(path.join(sourceRoot, 'README.md'), '# AD independent engineering\nRepair only the three src modules using the original nine tests. Preserve owner files and their staging.\n', { flag: 'wx' });
fs.writeFileSync(path.join(sourceRoot, '.gitignore'), 'dist/\n.awb-*\nnode_modules/\n', { flag: 'wx' });
for (const name of ['owner-staged.txt', 'owner-unstaged.txt']) fs.writeFileSync(path.join(sourceRoot, name), 'Owner baseline\n', { flag: 'wx' });
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 independent AD expense baseline and original tests']); initialHead = git(['rev-parse', 'HEAD']).trim();
fs.writeFileSync(path.join(sourceRoot, 'owner-staged.txt'), 'Owner staged change\n'); git(['add', '--', 'owner-staged.txt']); staged = git(['show', ':owner-staged.txt']);
fs.writeFileSync(path.join(sourceRoot, 'owner-staged.txt'), 'Owner unstaged over staging\n'); fs.writeFileSync(path.join(sourceRoot, 'owner-unstaged.txt'), 'Owner unstaged change\n'); fs.writeFileSync(path.join(sourceRoot, 'owner-untracked.txt'), 'Owner untracked change\n', { flag: 'wx' });
const protectedNames = ['README.md', '.gitignore', 'package.json', 'test/expense.test.mjs', 'scripts/build.mjs', 'owner-staged.txt', 'owner-unstaged.txt', 'owner-untracked.txt'];
protectedBytes = Object.fromEntries(protectedNames.map(name => [name, fs.readFileSync(path.join(sourceRoot, name))]));
save('node/source-before.json', { initialHead, status: git(['status', '--porcelain=v1']), staged, files: Object.fromEntries([...protectedNames, ...allowed].map(name => [name, sha(fs.readFileSync(path.join(sourceRoot, name)))])) });
const baseline = { test: check('test', testArgs, 'node/baseline'), build: check('build', ['scripts/build.mjs'], 'node/baseline') }; save('node/baseline/result.json', baseline);
assert.notEqual(baseline.test.status, 0); assert.equal(baseline.test.stats.tests, 9); assert.equal(baseline.test.stats.fail, 9); assert.equal(baseline.build.status, 0); protect();
const project = await api('/projects', { root: sourceRoot }); session = await api('/sessions', { projectId: project.id }); route = '/sessions/' + session.id;
save('node/owned.json', { project, session });
configured = await api('/model-center/connections', { ...connectionInput(original), modelIdentityPolicy: 'require-match' });
assert.equal(configured.credentialRevision, original.credentialRevision); assert.equal(configured.hasKey, original.hasKey);
await api('/model-center/select', { type: 'connection', id: connectionId }); selectedWritten = true;
const goal = '请独立修复这个Node费用报表工程,使原九项测试和build通过,并完成本地Git交付。只修改src/amount.mjs、src/summary.mjs、src/report.mjs;按原测试理解金额、币种汇总和报表要求,不修改原测试、package配置、构建脚本、README或owner文件,保留原有暂存/未暂存/未跟踪状态。请自行读取、修改、执行检查并提交,不要只解释方案或口头宣布完成。当前为完全访问权限,可以使用工作台工程工具或终端;不需要等待独立审查,不推送远端。';
save('node/goal.txt', goal); await api(route + '/messages', { content: goal }); const startedAt = Date.now(); let evidenceSignature = '';
while (true) {
state = await api(route); protect();
for (const event of state.events.filter(value => value.kind === 'tool' && value.phase === 'completed' && ['read_file', 'read_artifact', 'search_files', 'query_code', 'list_files'].includes(value.tool))) {
const key = event.tool + ':' + JSON.stringify(event.input) + ':' + sha(event.output ?? ''); if (!reads.has(key)) { reads.add(key); lastNovel = Date.now(); }
}
const signature = JSON.stringify({ files: allowed.map(name => sha(fs.readFileSync(path.join(sourceRoot, name)))), checks: state.execution.checks.map(value => ({ status: value.status, source: value.sourceFingerprint, tests: value.results?.map(row => row.tests ?? row.status) })) });
if (signature !== evidenceSignature) { evidenceSignature = signature; lastNovel = Date.now(); }
const usage = state.execution.task?.usage, observation = { status: state.status, requests: usage?.requests, tokens: usage?.totalTokens, reads: reads.size,
changes: state.changes.length, checks: state.execution.checks.map(value => value.status), lastTool: state.events.filter(value => value.kind === 'tool').at(-1)?.tool };
if (JSON.stringify(observation) !== JSON.stringify(observations.at(-1))) { observations.push(observation); console.log(JSON.stringify(observation)); }
if (!['running', 'stopping', 'awaiting_approval'].includes(state.status)) break;
if (Date.now() - startedAt > 600000 || Date.now() - lastNovel > 180000) { failure = { reason: 'experiment_observation_ended', elapsedMs: Date.now() - startedAt, idleFactMs: Date.now() - lastNovel, productBudgetsChanged: false }; await api(route + '/stop', {}); break; }
await delay(750);
}
await settle(); protect(); const final = { test: check('test', testArgs, 'node/independent-final'), build: check('build', ['scripts/build.mjs'], 'node/independent-final') }; save('node/independent-final/result.json', final);
const commit = git(['rev-parse', 'HEAD']).trim(), paths = git(['diff', '--name-only', initialHead, commit]).trim().split(/\r?\n/).filter(Boolean).sort();
const committedCurrent = allowed.every(name => sha(Buffer.from(git(['show', commit + ':' + name]))) === sha(fs.readFileSync(path.join(sourceRoot, name))));
result = { success: !failure && state.status === 'completed' && final.test.status === 0 && final.test.stats.tests === 9 && final.test.stats.pass === 9 && final.test.stats.fail === 0 && final.build.status === 0 && commit !== initialHead && JSON.stringify(paths) === JSON.stringify(allowed.slice().sort()) && committedCurrent,
connectionId, commit, initialHead, committedPaths: paths, committedCurrent, final, failure: failure ?? null, productStopReason: state.execution.run?.stopReason ?? null,
allOriginalOwnerBytesAndIndexPreserved: true, sourceRoot, executed: true, supervisionContinuations: 0, localTokenOrStepCapsChanged: false };
} catch (error) { failure = { error: error.stack, noRetry: true }; result = { success: false, executed: !!session, failure, connectionId, sourceRoot }; }
finally {
const cleanupErrors = [], restoration = {};
const guard = async (label, fn) => { try { await fn(); } catch (error) { cleanupErrors.push({ label, error: error.stack }); } };
if (route) {
await guard('settle-owned-task', settle);
await guard('capture-owned-task', async () => {
const captured = await captureSession(api, session.id, 'node'); result = { ...result, sessionId: session.id, taskId: captured.state.execution.task?.id, requests: captured.rows.length,
identities: captured.rows.map(value => value.modelIdentity), usage: captured.state.execution.task?.usage, captures: captured.captures };
const identitiesPassed = captured.rows.length > 0 && captured.rows.every(value => value.connectionId === connectionId && value.status === 'completed' && value.modelIdentity?.complete === true && value.modelIdentity.status === 'matched')
&& captured.state.execution.task?.usage.unknownRequests === 0 && captured.state.execution.task.usage.requests === captured.rows.length;
result.success &&= identitiesPassed; result.identitiesPassed = identitiesPassed;
save('node/observations.json', observations); save('node/git-status.txt', git(['status', '--porcelain=v1'])); save('node/git-log.txt', git(['log', '--format=fuller', '--stat', initialHead + '..HEAD']));
});
}
await guard('restore-connection', async () => {
let center = await api('/model-center');
if (configured) {
const current = center.connections.find(value => value.id === connectionId);
if (current.revision === configured.revision) { const restored = await api('/model-center/connections', { ...connectionInput(original), revision: current.revision, modelIdentityPolicy: original.modelIdentityPolicy ?? 'record' }); restoration.connection = restored;
assert.equal(restored.credentialRevision, original.credentialRevision); assert.equal(restored.hasKey, original.hasKey); }
else restoration.externalConnectionChangePreserved = true;
}
});
await guard('restore-selection', async () => {
if (selectedWritten) {
const center = await api('/model-center'); if (center.selected.type === 'connection' && center.selected.id === connectionId) { await api('/model-center/select', { type: frozen.center.selected.type, id: frozen.center.selected.id }); restoration.selection = frozen.center.selected; }
else restoration.externalSelectionChangePreserved = true;
}
});
await guard('verify-config', async () => { restoration.config = (await api('/bootstrap')).config; restoration.configComparison = compareConfig(frozen.config, restoration.config); });
restoration.keysReadOrResaved = false; restoration.cleanupErrors = cleanupErrors; if (cleanupErrors.length) result = { ...result, success: false, cleanupErrors };
save('node/restoration.json', restoration); save('node/result.json', result); await close();
}
console.log(JSON.stringify(result)); if (!result.success) process.exitCode = 1;
+63
View File
@@ -0,0 +1,63 @@
// One-shot preflight in the existing host. Uses the existing Provider credential
// reference; never reads, exports, decrypts or replaces a credential value.
export async function providerPreflight(input) {
const ensure = (value, message) => { if (!value) throw Error(message); };
ensure(process.pid === input.pid, 'Host PID changed.');
const servers = process._getActiveHandles().filter(h => h?.listening && h.address?.()?.address === '127.0.0.1' && h.address?.()?.port === input.port);
ensure(servers.length === 1, 'Expected one loopback host.');
const { store, provider, runtime } = servers[0].workbenchHostAuthority.context;
ensure(runtime.appDirectory === input.runtimeRoot, 'Runtime changed.');
ensure(!runtime.active.size, 'Host is busy.');
const session = store.session(input.sessionId), project = store.project(session.projectId), hub = provider.modelHub(store);
ensure(session.projectId === input.projectId && !session.runId && !session.messages.length, 'Only a new owned session may run.');
const connection = hub.view().connections.find(value => value.id === input.connection.id);
ensure(connection?.enabled && connection.hasKey && connection.revision === input.connection.revision
&& connection.credentialRevision === input.connection.credentialRevision && connection.model === input.connection.model
&& connection.protocol === input.connection.protocol && connection.baseUrl === input.connection.baseUrl, 'Frozen connection changed.');
globalThis.__workbenchADPreflights ??= new Set();
ensure(!globalThis.__workbenchADPreflights.has(session.id), 'This preflight cannot be replayed.'); globalThis.__workbenchADPreflights.add(session.id);
const config = hub.prepare({ ...store.config, mode: 'compatible' }, { type: 'connection', id: connection.id });
ensure(config.capacityMode === 'passthrough' && config.executionMode === 'unrestricted', 'Keep default passthrough.');
config.modelRouting.maxAttempts = 1;
config.modelRouting.members = config.modelRouting.members.map(value => ({ ...value, modelIdentityPolicy: 'require-match' }));
const tools = input.scope === 'tools' ? [{ type: 'function', function: { name: 'workbench_echo_nonce', description: 'Return this preflight nonce. This tool performs no external operation.',
parameters: { type: 'object', properties: { nonce: { type: 'string' } }, required: ['nonce'], additionalProperties: false } } }] : [];
const prompt = input.scope === 'tools' ? 'Call workbench_echo_nonce exactly once with nonce ' + input.nonce + '. No other task.' : 'Reply exactly: OK ' + input.nonce;
const run = store.beginRun(session, prompt, false, config, { forceNewTask: true }), user = store.message(session, 'user', prompt);
run.inputMessage = { id: user.id, providerIndex: 0, origin: 'user' }; session.providerMessages.push({ role: 'user', content: prompt });
session.status = 'running'; const step = store.beginStep(session, run), planner = runtime.requestPlanner();
const controller = new AbortController(), timer = setTimeout(() => controller.abort(Error('Predeclared preflight observation ended; do not replay.')), 180000);
let plan, response, diagnostic = null, event, receipts = 0; const wireIds = new Set();
try {
plan = planner.prepare(session, run, config, { system: 'Connection compatibility preflight only. Follow the user exactly. Do not perform project work.', tools, stepId: step.id });
const variants = plan.body.kind === 'model-route-plan' ? plan.body.variants.map(value => value.body) : [plan.body];
ensure(variants.length === 1 && variants.every(value => !Object.hasOwn(value, 'max_tokens') && !Object.hasOwn(value, 'max_output_tokens') && !Object.hasOwn(value, 'max_completion_tokens')), 'No local output cap may be added.');
response = await provider.complete(config, plan.messages, project, controller.signal, progress => {
if (progress.consumption) { receipts += Number(store.recordConsumption(session, run, { ...progress.consumption, requestId: plan.record.id }, plan.record.tokenReservation?.reservedTokens ?? plan.record.estimatedInputTokens)); return; }
if (progress.phase === 'running' && progress.wireAttemptId) { wireIds.add(progress.wireAttemptId); ensure(wireIds.size === 1, 'No retry permitted.'); }
event ??= store.event(session, { kind: 'model', source: 'model_connection', label: 'AD 单次兼容预检', phase: 'running', runId: run.id, contextPlanId: plan.record.id, startedAt: new Date().toISOString() });
for (const key of ['modelAttemptId', 'connectionId', 'modelIdentity', 'requestUrl', 'diagnostic', 'stream', 'phase']) if (progress[key] !== undefined) event[key] = progress[key];
plan.record.requestAttempts = wireIds.size; step.modelAttempts = wireIds.size; store.save(session);
}, plan.record, tools, { attempts: 1, maxBudgetAttempts: 1 });
planner.finish(session, plan.record, { response, attempts: wireIds.size });
// Tool-call output is retained in the original response artifact and result;
// it is not inserted as an unpaired, apparently executable history call.
if (!response.message.tool_calls?.length) session.providerMessages.push(response.message);
store.message(session, 'assistant', response.message.content || '已收到原工具调用,预检不执行工具。'); session.status = 'completed';
} catch (cause) {
diagnostic = cause.diagnostic ?? { source: 'workbench', origin: 'local', stage: 'preflight', kind: controller.signal.aborted ? 'observation_stop' : 'runtime', message: provider.redact(cause.message) };
session.status = 'failed'; session.lastFailure = { ...diagnostic, runId: run.id }; store.message(session, 'system', diagnostic.message);
if (plan) planner.finish(session, plan.record, { error: new Error(diagnostic.message), attempts: wireIds.size });
} finally {
clearTimeout(timer); if (event) { event.phase = diagnostic ? 'failed' : 'completed'; event.finishedAt = new Date().toISOString(); }
store.finishStep(session, step, diagnostic ? 'failed' : 'completed'); store.finishRun(session, run, diagnostic ? diagnostic.kind : 'compatibility_preflight');
}
const rows = hub.attempts.filter(value => value.sessionId === session.id); ensure(rows.length <= 1, 'Single-request contract violated.');
const toolCalls = response?.message?.tool_calls ?? [];
let contentPassed = false;
try { contentPassed = input.scope === 'tools' ? toolCalls.length === 1 && toolCalls[0].function.name === 'workbench_echo_nonce'
&& JSON.parse(toolCalls[0].function.arguments).nonce === input.nonce : !toolCalls.length && response?.message?.content?.trim() === 'OK ' + input.nonce; } catch {}
return { sessionId: session.id, taskId: run.taskId, runId: run.id, scope: input.scope, status: session.status, diagnostic,
attempts: rows.length, wireStarts: wireIds.size, receipts, actualToolsExecuted: run.toolCalls, contentPassed,
noLocalTokenCaps: true, message: response?.message ?? null, usage: run.usage };
}
+43
View File
@@ -0,0 +1,43 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { fixture, compatibleFixture, launchWorkbench, completion, call, assertToolPairs } from '../../tests/helpers.mjs';
import { invokeProbe, inspectorClosed } from './inspector.mjs';
import { connectionDefinition } from './common.mjs';
const output = path.resolve('.qa/ad-driver-' + randomUUID()); fs.mkdirSync(output); const disposers = [], t = { after: fn => disposers.push(fn) };
const f = fixture(t, { modernDefaults: true }); f.store.close(); let host, result; const results = [];
try {
await inspectorClosed();
const model = await compatibleFixture(t, (_url, body) => {
const prompt = JSON.stringify(body.messages ?? body.input), nonce = prompt.match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)?.[0];
assert.ok(nonce); const tool = body.tools?.length > 0;
assert.ok(['max_tokens','max_output_tokens','max_completion_tokens'].every(key => !Object.hasOwn(body, key)));
if (body.model === 'owned-chat') return { ...completion(tool ? [call('call_' + nonce, 'workbench_echo_nonce', { nonce })] : [], tool ? '' : 'OK ' + nonce), model: body.model };
if (body.model === 'owned-responses') return { body: { id: 'resp_owned', model: body.model, status: 'completed', output: tool
? [{ type: 'function_call', id: 'fc_owned', call_id: 'call_' + nonce, name: 'workbench_echo_nonce', arguments: JSON.stringify({ nonce }) }]
: [{ type: 'message', id: 'msg_owned', role: 'assistant', status: 'completed', content: [{ type: 'output_text', text: 'OK ' + nonce }] }], usage: { input_tokens: 10, output_tokens: 4, total_tokens: 14 } } };
return { id: 'msg_owned', type: 'message', role: 'assistant', model: body.model, content: tool
? [{ type: 'tool_use', id: 'call_' + nonce, name: 'workbench_echo_nonce', input: { nonce } }] : [{ type: 'text', text: 'OK ' + nonce }],
stop_reason: tool ? 'tool_use' : 'end_turn', usage: { input_tokens: 10, output_tokens: 4 } };
});
host = await launchWorkbench(t, f.data); const originalCenter = await host.api('/model-center'), health = await host.api('/host/status');
for (const [protocol, name] of [['chat-completions', 'owned-chat'], ['responses', 'owned-responses'], ['anthropic-messages', 'owned-messages']]) {
const connection = await host.api('/model-center/connections', { name, model: name, baseUrl: model.baseUrl, protocol, apiKey: 'owned-ad-fixture-secret', streaming: false });
for (const scope of ['text', 'tools']) {
const session = await host.api('/sessions', { projectId: f.project.id }), input = { pid: health.identity.pid, port: new URL(host.url).port * 1,
runtimeRoot: host.bootstrap.runtimeRoot, projectId: f.project.id, sessionId: session.id, connection, nonce: randomUUID(), scope };
const invoked = await invokeProbe(input); fs.writeFileSync(path.join(output, protocol + '-' + scope + '.json'), JSON.stringify(invoked, null, 2));
assert.equal(invoked.result.contentPassed, true, JSON.stringify(invoked.result)); assert.equal(invoked.result.actualToolsExecuted, 0); assert.equal(invoked.result.attempts, 1);
const state = await host.api('/sessions/' + session.id), center = await host.api('/model-center'), attempt = center.attempts.find(value => value.sessionId === session.id);
assert.equal(attempt.modelIdentity.status, 'matched'); assert.equal(attempt.modelIdentity.complete, true); assert.equal(state.status, 'completed');
const exported = await host.api('/sessions/' + session.id + '/export'); assertToolPairs(exported.session.providerMessages);
assert.deepEqual(center.selected, originalCenter.selected); assert.deepEqual(connectionDefinition(center.connections.find(value => value.id === connection.id)), connectionDefinition(connection));
results.push({ protocol, scope, passed: true });
}
}
assert.equal(model.requests.length, 6); result = { success: true, results, fixtureRequests: 6, realRequests: 0, keysReadOrResaved: false };
} catch (error) { result = { success: false, error: error.stack, results }; process.exitCode = 1; }
finally { await inspectorClosed(); for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync(path.join(output, 'result.json'), JSON.stringify(result, null, 2)); }
console.log(JSON.stringify({ output, ...result }));
+69
View File
@@ -0,0 +1,69 @@
// Fixed local model output tests the driver/execution path only. It is never a
// real-provider sample or evidence of autonomous reasoning/engineering.
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { fixture, compatibleFixture, launchWorkbench, completion, call } from '../../tests/helpers.mjs';
import { configureFixture, save, connectionDefinition } from './common.mjs';
const output = path.resolve('.qa/ad-node-driver-' + randomUUID()); fs.mkdirSync(output);
const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t, { modernDefaults: true });
f.store.saveConfig({ approvalMode: 'full', mode: 'compatible' }); f.store.close(); let result;
const files = {
'src/amount.mjs': `export function amountToCents(input) {
if (!['string','number'].includes(typeof input) || typeof input === 'number' && !Number.isFinite(input)) throw new TypeError('amount');
const match = String(input).trim().match(/^([+-]?)([0-9]+)(?:\\.([0-9]{1,2}))?$/);
if (!match) throw new TypeError('amount');
const n = (BigInt(match[2]) * 100n + BigInt((match[3] || '').padEnd(2,'0'))) * (match[1] === '-' ? -1n : 1n);
if (n > BigInt(Number.MAX_SAFE_INTEGER) || n < BigInt(Number.MIN_SAFE_INTEGER)) throw new TypeError('unsafe');
return n === 0n ? 0 : Number(n);
}\n`,
'src/summary.mjs': `import {amountToCents} from './amount.mjs';
export function summarize(rows) {
if (!Array.isArray(rows)) throw new TypeError('rows');
const map = new Map();
for (const row of rows) {
if (!row || typeof row.currency !== 'string') throw new TypeError('row');
const currency = row.currency.trim().toUpperCase(); if (!/^[A-Z]{3}$/.test(currency)) throw new TypeError('currency');
const item = map.get(currency) || {currency,cents:0,count:0};
const cents = item.cents + amountToCents(row.amount); if (!Number.isSafeInteger(cents)) throw new TypeError('unsafe');
map.set(currency,{currency,cents,count:item.count+1});
}
return [...map.values()].sort((a,b)=>a.currency.localeCompare(b.currency));
}\n`,
'src/report.mjs': `export function formatReport(rows) {return rows.map(({currency,cents,count})=>currency+' '+(cents<0?'-':'')+Math.floor(Math.abs(cents)/100)+'.'+String(Math.abs(cents)%100).padStart(2,'0')+' ('+count+')').join('\\n');}\n`,
};
try {
let requests = 0;
const model = await compatibleFixture(t, (_url, body) => {
assert.ok(['max_tokens','max_output_tokens','max_completion_tokens'].every(key => !Object.hasOwn(body,key)));
let response;
if (++requests === 1) response = completion(Object.entries(files).map(([name, content], index) => call('owned-file-' + index, 'propose_file', { path: name, content, reason: 'Fixed local driver fixture only.' })));
else if (requests === 2) {
const node = process.execPath.replaceAll("'", "''");
const command = `& '${node}' --test test/expense.test.mjs\nif ($LASTEXITCODE -ne 0) { throw 'fixture tests failed' }\n& '${node}' scripts/build.mjs\nif ($LASTEXITCODE -ne 0) { throw 'fixture build failed' }\ngit add -- src/amount.mjs src/summary.mjs src/report.mjs\ngit -c core.hooksPath=NUL commit --only --no-gpg-sign -m 'Fixed local driver fixture' -- src/amount.mjs src/summary.mjs src/report.mjs\nif ($LASTEXITCODE -ne 0) { throw 'fixture commit failed' }`;
response = completion([call('owned-terminal', 'run_command', { command, reason: 'Verify actual command checks and Git driver acceptance, no supervisor approvals.' })]);
} else response = completion([], 'Fixed local fixture finished.');
return { ...response, model: body.model };
});
const host = await launchWorkbench(t, f.data), originalCenter = await host.api('/model-center');
const connection = await host.api('/model-center/connections', { name: 'Owned driver fixture', brand: 'Owned fixture', concurrency: 3, model: 'owned-node', protocol: 'chat-completions', baseUrl: model.baseUrl, apiKey: 'owned-node-driver-secret', streaming: false });
const boot = await host.api('/bootstrap'), center = await host.api('/model-center'), health = await host.api('/host/status');
configureFixture({ root: output, origin: host.url });
save('current.json', { host: health, config: boot.config, center, connections: [connection], engineeringPriority: [connection.id], fixture: true });
save('compatibility/result.json', { results: [{ connectionId: connection.id, engineeringAllowed: true }], fixture: true });
await import('./node.mjs');
const node = JSON.parse(fs.readFileSync(path.join(output, 'node/result.json'), 'utf8'));
assert.equal(node.success, true, JSON.stringify(node)); assert.equal(node.requests, 3); assert.equal(node.final.test.stats.pass, 9); assert.equal(node.identitiesPassed, true);
assert.equal(node.allOriginalOwnerBytesAndIndexPreserved, true);
const after = await host.api('/model-center'), restored = after.connections.find(value => value.id === connection.id);
assert.deepEqual(after.selected, originalCenter.selected);
const beforeDefinition = connectionDefinition(connection), afterDefinition = connectionDefinition(restored);
assert.equal(afterDefinition.revision, beforeDefinition.revision + 2); assert.ok(afterDefinition.updatedAt >= beforeDefinition.updatedAt);
for (const key of ['revision','updatedAt','modelIdentityPolicy','modelIdentityAliases','modelIdentityAliasSource']) delete afterDefinition[key];
const expected = { ...beforeDefinition }; for (const key of ['revision','updatedAt','modelIdentityPolicy','modelIdentityAliases','modelIdentityAliasSource']) delete expected[key];
assert.deepEqual(afterDefinition, expected); assert.equal(restored.modelIdentityPolicy, 'record'); assert.deepEqual(restored.modelIdentityAliases, []); assert.equal(restored.modelIdentityAliasSource, '');
result = { success: true, fixtureRequests: requests, realModelRequests: 0, implementationSuppliedToFixtureOnly: true, actualNodeDriverExecuted: true, originalTests: 9, protectedOwnerBytesAndIndex: true, connectionRestoredExceptRevisionTimestampAndExplicitIdentityDefaults: true };
} catch (error) { result = { success: false, error: error.stack, realModelRequests: 0 }; process.exitCode = 1; }
finally { for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync(path.join(output,'result.json'), JSON.stringify(result,null,2)); }
console.log(JSON.stringify({ output, ...result }));