test: freeze bounded live delivery V contract before requests

This commit is contained in:
Agent Workbench Dev
2026-11-04 08:54:12 +08:00
parent 13849d038f
commit 19214ba3ad
28 changed files with 1417 additions and 0 deletions
@@ -0,0 +1,62 @@
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 { snapshotPersistentData } from '../src/core/desktop/install-manager.mjs';
export const hash = bytes => createHash('sha256').update(bytes).digest('hex');
export const canonical = value => Array.isArray(value) ? value.map(canonical) : value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, canonical(value[key])])) : value;
export const digest = value => hash(JSON.stringify(canonical(value)));
export function databaseSnapshot(dataRoot) {
const database = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true }); database.exec('BEGIN');
try {
assert.equal(database.prepare('PRAGMA quick_check').get().quick_check, 'ok');
const tables = {};
for (const { name, sql } of database.prepare("SELECT name,sql FROM sqlite_schema WHERE type='table' ORDER BY name").all()) {
assert.match(name, /^[a-z_]+$/);
const rows = database.prepare('SELECT * FROM "' + name + '" ORDER BY rowid').all().filter(row => !(name === 'metadata' && row.key === 'runtimeOwner'));
tables[name] = { count: rows.length, schemaSha256: hash(sql), sha256: digest(rows), rows: rows.map((row, index) => ({ id: row.id ?? row.key ?? row.seq ?? index, ...(row.kind ? { kind: row.kind } : {}), sha256: digest(row) })) };
}
const sessionIds = database.prepare('SELECT id FROM sessions ORDER BY id').all().map(row => row.id);
const owner = database.prepare("SELECT value FROM metadata WHERE key='runtimeOwner'").get();
return { tables, sessionIds, ownerSha256: owner ? digest(owner) : null, scope: 'Every original table schema and row field hashed, excluding only runtimeOwner lifecycle metadata. No row payload or credential is returned.' };
} finally { database.exec('ROLLBACK'); database.close(); }
}
export async function publicSnapshot(url, dataRoot) {
const healthResponse = await fetch(url + '/api/health', { headers: { Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.equal(healthResponse.status, 200);
const health = await healthResponse.json(), bootResponse = await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.equal(bootResponse.status, 200);
const bootstrap = await bootResponse.json(); const token = bootstrap.token;
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': token, Connection: 'close' }, signal: AbortSignal.timeout(20000) }); assert.ok(response.ok, route + ': HTTP ' + response.status); return response.json(); };
const database = databaseSnapshot(dataRoot), exports = [];
for (const id of database.sessionIds) {
const report = await api('/sessions/' + id + '/export');
exports.push({ id, project: digest(report.project), session: digest(report.session), execution: digest(report.execution) });
}
const center = await api('/model-center');
// This is the documented public model-center view; Provider's private map and
// API key are never accessed. Only this public object is retained for schema-aware comparison.
const modelCenter = structuredClone(center);
return { observedAt: new Date().toISOString(), version: health.version, pid: health.pid, runtimeRoot: bootstrap.runtimeRoot,
configSha256: digest(bootstrap.config), projectsSha256: digest(bootstrap.projects), sessionsSha256: digest(bootstrap.sessions), modelCenterSha256: digest(modelCenter), modelCenter,
projects: bootstrap.projects.length, visibleSessions: bootstrap.sessions.length, hasKey: !!bootstrap.config.hasKey,
active: bootstrap.sessions.filter(value => ['running', 'awaiting_approval', 'stopping'].includes(value.status)).map(value => ({ id: value.id, status: value.status })),
storage: bootstrap.storage, eventCursor: bootstrap.eventCursor, database, exports, persistent: snapshotPersistentData(dataRoot),
scope: 'Read-only public state, every original session export digest, original table/row/schema hashes and every original artifact byte hash. No credential extraction, model probe, execution or mutation.' };
}
export function compareOriginalState(before, after, { modelCenterSchemaChange = false } = {}) {
for (const field of ['pid', 'hasKey', 'configSha256', 'projectsSha256', 'sessionsSha256', 'eventCursor']) assert.deepEqual(after[field], before[field], field);
assert.deepEqual(canonical(after.database.tables), canonical(before.database.tables), 'All original table schemas and every persistent row');
assert.deepEqual(after.database.sessionIds, before.database.sessionIds); assert.deepEqual(after.exports, before.exports);
assert.deepEqual(after.persistent, before.persistent, 'Every original artifact byte, persistent row and public disk config');
if (modelCenterSchemaChange) {
const original = structuredClone(before.modelCenter), next = structuredClone(after.modelCenter);
// 1.15 changes only the public explanatory text about optional DPAPI storage.
// Existing IDs, routes, revisions, credentials-present bits and all original attempts remain exact.
assert.match(next.storage.restart, /临时凭据.*已明确本机加密保存/);
next.storage.restart = original.storage.restart;
assert.deepEqual(next, original, 'Original public model center, except versioned storage explanation');
return { modelCenterChange: { path: '/storage/restart', original: before.modelCenter.storage.restart, actual: after.modelCenter.storage.restart }, originalRows: 'exact', originalExports: 'exact', originalArtifactBytes: 'exact' };
}
assert.equal(after.modelCenterSha256, before.modelCenterSha256);
return { originalRows: 'exact', originalExports: 'exact', originalArtifactBytes: 'exact', originalModelCenter: 'exact' };
}
@@ -0,0 +1,46 @@
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 target=path.resolve('docs/live-delivery-v-contract'); assert.equal(fs.existsSync(target),false);
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
const sourceFiles=['prepare-live-delivery-v.mjs','freeze-live-delivery-v.mjs','desktop-f-state.mjs',
...['initial','common','payload','inspector','network','preflight','preflight-audit','node','final-audit','capture-artifacts','ownership-proof','final-readback','proof-support','analyze','context-proof'].map(name=>'live-delivery-v-'+name+'.mjs')];
const initialBytes=fs.readFileSync('.qa/live-delivery-v/current.json'), initial=JSON.parse(initialBytes);
const release=JSON.parse(fs.readFileSync('docs/working-memory-u-release-identity.json'));
assert.equal(initial.host.identity.runtimeRoot.endsWith('Agent-Workbench-1.24.8-win-x64-20261103235313371'),true);
assert.equal(initial.host.identity.runtimeIdentity,'6f4b7681e8393fe0c7b7441264b806662741f59c7dc818f2632ad7ceb6e67c99');
const files=[];
for(const name of sourceFiles){
const bytes=fs.readFileSync(path.join('.qa',name)),relative='drivers/'+name+'.txt';
fs.mkdirSync(path.join(target,'drivers'),{recursive:true}); fs.writeFileSync(path.join(target,relative),bytes,{flag:'wx'});
files.push({path:relative,bytes:bytes.length,sha256:sha(bytes)});
}
const oldDriver=fs.readFileSync('.qa/live-delivery-t-node.mjs','utf8'), newDriver=fs.readFileSync('.qa/live-delivery-v-node.mjs','utf8');
const goalDeclaration=text=>text.slice(text.indexOf(' const goal = '),text.indexOf(" save('node/goal.txt'"));
assert.equal(goalDeclaration(oldDriver),goalDeclaration(newDriver));
const fixtureFiles=['src/amount.mjs','src/summary.mjs','src/report.mjs','test/expense.test.mjs','package.json','scripts/build.mjs'];
const originalFixture=JSON.parse(fs.readFileSync('.qa/live-delivery-t/node/source-identity.json'));
const inputs=fixtureFiles.map(name=>{
const bytes=fs.readFileSync('benchmarks/live-delivery-v1/node/'+name);
assert.equal(sha(bytes),originalFixture.files[name]);
const relative='inputs/'+name; fs.mkdirSync(path.dirname(path.join(target,relative)),{recursive:true}); fs.writeFileSync(path.join(target,relative),bytes,{flag:'wx'});
return {path:name,capturedPath:relative,bytes:bytes.length,sha256:sha(bytes)};
});
const manifest={schemaVersion:1,kind:'bounded-live-delivery-v-contract',frozenAt:new Date().toISOString(),
sourceBaseCommit:initial.sourceCommit,branch:execFileSync('git',['branch','--show-current'],{encoding:'utf8',windowsHide:true}).trim(),
planSha256:sha(fs.readFileSync('docs/LIVE-DELIVERY-V-PLAN.md')),originalBaselineSha256:sha(initialBytes),
releaseVersion:release.version,releaseSourceCommit:release.sourceCommit,releaseIdentitySha256:sha(fs.readFileSync('docs/working-memory-u-release-identity.json')),
host:{pid:initial.host.identity.pid,runtimeRoot:initial.host.identity.runtimeRoot,runtimeIdentity:initial.host.identity.runtimeIdentity},
originalProjects:initial.baseline.projects,originalSessions:initial.baseline.exports.length,originalArtifacts:initial.baseline.persistent.artifacts.length,
originalAttemptsRow:initial.baseline.database.tables.metadata.rows.find(row=>row.id==='modelAttempts'),
originalDiagnosticsRow:initial.baseline.database.tables.metadata.rows.find(row=>row.id==='modelNetworkDiagnostics'),
inputs,originalElevenFileHashes:originalFixture.files,goalDeclarationSha256:sha(goalDeclaration(newDriver)),goalMatchesTExactly:true,
dependencySources:['src/core/git-process.mjs','src/core/desktop/install-manager.mjs',...fixtureFiles.map(name=>'benchmarks/live-delivery-v1/node/'+name)]
.map(name=>({path:name,sha256:sha(fs.readFileSync(name))})),
previousDriverHashes:['initial','common','payload','inspector','preflight','preflight-audit','node','network'].map(name=>({path:'.qa/live-delivery-t-'+name+'.mjs',sha256:sha(fs.readFileSync('.qa/live-delivery-t-'+name+'.mjs'))})),
maxNetworkJobs:1,maxPreflightRequests:1,maxNodeRequests:8,maxNodeTokens:90000,maxNodeDurationMs:600000,contextLimit:16000,maxOutputTokens:2048,safetyReserveTokens:1600,
modelRequestsAtFreeze:0,noKeyValuesReadOrSaved:true,files:files.sort((a,b)=>a.path.localeCompare(b.path))};
fs.writeFileSync(path.join(target,'manifest.json'),JSON.stringify(manifest,null,2)+'\n',{flag:'wx'});
console.log(JSON.stringify({frozen:true,drivers:files.length,inputs:inputs.length,projects:manifest.originalProjects,sessions:manifest.originalSessions,artifacts:manifest.originalArtifacts,goalMatchesTExactly:true,manifestSha256:sha(fs.readFileSync(path.join(target,'manifest.json'))),modelRequests:0}));
@@ -0,0 +1,34 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { root, save, sha } from './live-delivery-v-common.mjs';
const read = relative => JSON.parse(fs.readFileSync(path.join(root, relative)));
const node = read('node/result.json'), session = read('node/session.json'), attempts = read('node/attempts.json');
const requests = attempts.map((attempt, index) => {
const request = node.captures.find(row => row.attemptId === attempt.id && row.kind === 'request');
const response = node.captures.find(row => row.attemptId === attempt.id && row.kind === 'response');
const originalRequest = fs.readFileSync(path.join(root, request.path));
const originalResponse = response ? fs.readFileSync(path.join(root, response.path)) : null;
assert.equal(sha(originalRequest), attempt.requestSha256); if(originalResponse) assert.equal(sha(originalResponse), attempt.responseSha256);
const body = JSON.parse(originalRequest); let raw=null; try { raw=JSON.parse(originalResponse); } catch {}
if(raw?.usage) assert.deepEqual(raw.usage, attempt.usage);
return { ordinalInSample: index + 1, attemptId: attempt.id, requestId: attempt.requestId,
requestBytes: originalRequest.length, responseBytes: originalResponse?.length ?? 0, tools: body.tools?.length ?? 0,
messages: body.messages.map(row => ({ role: row.role, contentBytes: Buffer.byteLength(row.content ?? ''),
toolCallId: row.tool_call_id, toolNames: row.tool_calls?.map(call => call.function.name) })),
usage: raw?.usage ?? attempt.usage, identity: attempt.modelIdentity, responseMessage: raw?.choices?.[0]?.message ?? null,
finishReason: raw?.choices?.[0]?.finish_reason ?? null };
});
const result = { nodeSucceeded: node.success, stopReason: node.stopReason, requests,
contextPlans: session.execution.contextPlans.map(plan => ({ id: plan.id, status: plan.status, budget: plan.budget,
tokenReservation: plan.tokenReservation, requestAttempts: plan.requestAttempts, diagnostic: plan.diagnostic, usage: plan.usage })),
events: session.events.filter(row => row.kind === 'tool' || row.diagnostic || /budget|limit/.test(row.kind))
.map(row => ({ id: row.id, kind: row.kind, tool: row.tool, phase: row.phase, label: row.label, message: row.message, diagnostic: row.diagnostic })),
task: session.execution.task, run: session.execution.run,
checks: session.execution.checks, plans: session.execution.plans, taskPlans: session.execution.taskPlans,
changes: session.changes, approvals: node.approvals, applications: node.applications,
allowedWorkingTreeDiffEmpty: read('node/git-final.json').diff === '',
originalAndFinalHeadEqual: read('node/source-identity.json').head === read('node/git-final.json').head,
scope: 'Offline original raw request/response, stored context plans, budget receipts and tool events. No model requests or host mutations.' };
save('analysis/original-review.json', result);
console.log(JSON.stringify({requests:requests.length,nodeSucceeded:node.success,stopReason:node.stopReason,modelRequests:0}));
@@ -0,0 +1,31 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { DatabaseSync } from 'node:sqlite';
import { root, dataRoot, save, client, sha } from './live-delivery-v-common.mjs';
const read = name => JSON.parse(fs.readFileSync(path.join(root, name)));
const owners = ['preflight', 'node'].filter(name => fs.existsSync(path.join(root,name,'owned.json'))).map(name => read(name + '/owned.json'));
const db = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true });
let artifacts;
try {
artifacts = owners.flatMap(owner => db.prepare("SELECT payload FROM records WHERE kind='artifact' AND session_id=?").all(owner.session.id).map(row => JSON.parse(row.payload)));
} finally { db.close(); }
assert.ok(artifacts.length >= 0);
const { api, close } = await client(), index = [];
try {
for (const artifact of artifacts) {
const owner = owners.find(row => row.session.id === artifact.sessionId);
assert.ok(owner); assert.equal(artifact.projectId, owner.project.id);
let content = '', offset = 0, page;
do {
page = await api('/artifacts/' + artifact.id + '?session=' + artifact.sessionId + '&offset=' + offset + '&limit=16000');
assert.ok(page.content.length || !page.truncated); content += page.content; offset += page.content.length;
} while (page.truncated);
const bytes = Buffer.from(content, 'utf8'); assert.equal(sha(bytes), artifact.sha256); assert.equal(bytes.length, artifact.bytes);
const relative = 'analysis/artifacts/' + artifact.sessionId + '/' + artifact.id + '.txt'; save(relative, bytes);
index.push({ ...artifact, capturedPath: relative });
}
save('analysis/artifact-index.json', { artifacts: index, scope: 'Every owned artifact record, fetched read-only through the original API and checked against its original SHA and bytes; no old/user artifact contents exported.' });
console.log(JSON.stringify({ capturedOwnedArtifactRecords: index.length, uniqueByteHashes: new Set(index.map(row => row.sha256)).size,
bytes: index.reduce((sum,row) => sum + row.bytes, 0), modelRequests: 0, allHashesExact: true }));
} finally { await close(); }
@@ -0,0 +1,53 @@
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 const root = path.resolve('.qa/live-delivery-v');
export const original = JSON.parse(fs.readFileSync(path.join(root, 'current.json')));
export const origin = 'http://127.0.0.1:4318';
export const dataRoot = original.host.identity.dataRoot;
export const connectionId = '5b4daed9-b2f7-4de0-b949-573eba70c7b3';
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 function meta(name) {
assert.ok(['config', 'modelRegistry', 'modelAttempts', 'modelNetworkDiagnostics'].includes(name));
const db = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true });
try { return JSON.parse(db.prepare('SELECT value FROM metadata WHERE key=?').get(name).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 });
return value;
};
const boot = await api('/bootstrap'); token = boot.token;
return { api, boot, close: () => dispatcher.close() };
}
export async function captureAttempts(api, attempts, relative) {
const captures = [];
for (const attempt of attempts) for (const kind of ['request', 'response']) {
const id = attempt[kind + 'ArtifactId']; if (!id) continue;
let content = '', offset = 0, page;
do {
page = await api('/artifacts/' + id + '?session=' + attempt.sessionId + '&offset=' + offset + '&limit=16000');
assert.ok(page.content.length || !page.truncated); content += page.content; offset += page.content.length;
} while (page.truncated);
assert.equal(sha(content), page.sha256);
assert.equal(page.sha256, attempt[kind + 'Sha256']);
const name = `${relative}/${attempt.id}-${kind}.${kind === 'request' ? 'json' : attempt.streaming ? 'sse' : 'txt'}`;
save(name, content); captures.push({ attemptId: attempt.id, kind, artifactId: id, path: name, sha256: sha(content), bytes: Buffer.byteLength(content) });
}
return captures;
}
@@ -0,0 +1,75 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { root, readFileSync, save, sha } from './live-delivery-v-proof-support.mjs';
const read=name=>JSON.parse(readFileSync(name));
const session=read('node/session.json'),outcome=read('node/result.json'),attempts=read('node/attempts.json');
const artifacts=read('analysis/artifact-index.json').artifacts.filter(row=>row.sessionId===session.id), byId=new Map(artifacts.map(row=>[row.id,row]));
const paths=['test/expense.test.mjs','src/amount.mjs','src/summary.mjs','src/report.mjs'];
const sources=Object.fromEntries(paths.map(name=>[name,readFileSync('node/source-before/'+name).toString('utf8')]));
const versions=new Map(paths.map(name=>[name+':'+sha(sources[name]),sources[name]]));
for(const name of paths.slice(1)){
const text=readFileSync('node/source-after/'+name).toString('utf8');versions.set(name+':'+sha(text),text);
}
for(const change of session.changes)if(paths.includes(change.path)&&typeof change.content==='string')versions.set(change.path+':'+sha(change.content),change.content);
const union=ranges=>ranges.slice().sort((a,b)=>a[0]-b[0]).reduce((result,[a,b])=>{const last=result.at(-1);if(last&&a<=last[1])last[1]=Math.max(last[1],b);else result.push([a,b]);return result;},[]);
const count=ranges=>ranges.reduce((sum,[a,b])=>sum+b-a,0);
const difference=(a,b)=>a.flatMap(([start,end])=>{let rest=[[start,end]];for(const [x,y]of b)rest=rest.flatMap(([p,q])=>y<=p||x>=q?[[p,q]]:[[p,Math.min(q,x)],[Math.max(p,y),q]].filter(([l,r])=>l<r));return rest;});
const rawPages=[];
for(const artifact of artifacts.filter(row=>row.kind==='tool-result')){
let result;try{result=JSON.parse(readFileSync(artifact.capturedPath));}catch{continue;}
if(paths.includes(result.path)&&typeof result.content==='string'){
const source=versions.get(result.path+':'+result.sha256);assert.equal(typeof source,'string','Unknown observed source revision');
assert.equal(result.content,source.slice(result.offset,result.next_offset));
rawPages.push({artifactId:artifact.id,createdAt:artifact.createdAt,path:result.path,sha256:result.sha256,start:result.offset,end:result.next_offset,characters:result.content.length});
}
}
const perRequest=[], seen=new Map();let previousEngineeringState=null;
for(const [n,attempt] of attempts.entries()){
const capture=outcome.captures.find(row=>row.kind==='request'&&row.attemptId===attempt.id);assert.ok(capture);
const bytes=readFileSync(capture.path),body=JSON.parse(bytes);assert.equal(sha(bytes),capture.sha256);
const segments=[];
const add=(result,content,extraOffset,sourceKind,sourceId)=>{
if(!paths.includes(result?.path)||typeof content!=='string')return;
const source=versions.get(result.path+':'+result.sha256);assert.equal(typeof source,'string');
const start=(result.offset??0)+(extraOffset??0),end=start+content.length;assert.equal(content,source.slice(start,end));
const available=rawPages.filter(row=>row.path===result.path&&row.sha256===result.sha256&&row.createdAt<=attempt.startedAt);
assert.equal(count(difference([[start,end]],union(available.map(row=>[row.start,row.end])))),0,'Wire source must come from actually returned pages');
if(sourceId)assert.ok(byId.has(sourceId));
segments.push({path:result.path,sourceSha256:result.sha256,start,end,sourceKind,sourceId,characters:content.length,contentSha256:sha(content)});
};
for(const message of body.messages){
if(message.role==='tool'){let result;try{result=JSON.parse(message.content);}catch{} add(result,result?.content,0,'paired-file-tool-result',null);}
if(message.role!=='system')continue;
const start=message.content.indexOf('\n{');if(start<0)continue;
let document;try{document=JSON.parse(message.content.slice(start+1));}catch{continue;}
if(document.data?.kind==='task-working-set')for(const entry of document.data.entries)add(entry.observation,entry.content,entry.content_offset??0,'working-set-file-view',entry.source?.result_artifact_id);
if(document.data?.kind==='latest-tool-feedback')for(const entry of document.data.entries)if(entry.tool==='read_file')add(entry.result,entry.result?.content_excerpt,0,'latest-file-excerpt',entry.result_artifact_id);
}
const files=paths.map(name=>{
const originalSha=sha(sources[name]);
const returnedRanges=union(rawPages.filter(row=>row.path===name&&row.sha256===originalSha&&row.createdAt<=attempt.startedAt).map(row=>[row.start,row.end]));
const wireRanges=union(segments.filter(row=>row.path===name&&row.sourceSha256===originalSha).map(row=>[row.start,row.end]));
const missingReadRanges=difference(returnedRanges,wireRanges),total=sources[name].length;
return {path:name,sha256:originalSha,totalCharacters:total,cumulativeActuallyReadRanges:returnedRanges,cumulativeActuallyReadCharacters:count(returnedRanges),actualWireRanges:wireRanges,actualWireCharacters:count(wireRanges),missingPreviouslyReadRanges:missingReadRanges,missingPreviouslyReadCharacters:count(missingReadRanges),fullOriginalSourcePresent:count(wireRanges)===total};
});
const wire=bytes.toString('utf8'),availableJobs=session.execution.checks.filter(job=>job.finishedAt&&job.finishedAt<=attempt.startedAt);
const currentJob=availableJobs.at(-1)??null;
const facts=currentJob?{jobId:currentJob.id,status:currentJob.status,finishedAt:currentJob.finishedAt,jobIdOnWire:wire.includes(currentJob.id),sourceFingerprint:currentJob.sourceFingerprint,sourceFingerprintOnWire:wire.includes(currentJob.sourceFingerprint),logs:currentJob.results.map(result=>{const artifact=byId.get(result.logArtifactId);assert.ok(artifact);return {name:result.name,status:result.status,tests:result.tests,artifactId:artifact.id,sha256:artifact.sha256,artifactIdOnWire:wire.includes(artifact.id),sha256OnWire:wire.includes(artifact.sha256)};})}:null;
const appliedChanges=session.changes.filter(change=>change.status==='applied'&&change.appliedAt&&change.appliedAt<=attempt.startedAt).map(change=>change.id);
const engineeringState=sha(JSON.stringify({read:files.map(file=>file.cumulativeActuallyReadRanges),checks:availableJobs.map(job=>({source:job.sourceFingerprint,status:job.status,results:job.results.map(row=>({name:row.name,status:row.status,tests:row.tests}))})),appliedChanges}));
let assistantTools=[];
const response=outcome.captures.find(row=>row.kind==='response'&&row.attemptId===attempt.id);
if(response){let raw;try{raw=JSON.parse(readFileSync(response.path));}catch{}assistantTools=(raw?.choices?.[0]?.message?.tool_calls??[]).map(call=>({name:call.function.name,arguments:JSON.parse(call.function.arguments)}));}
const repeatedObservations=assistantTools.filter(call=>['inspect_project','plan_checks','read_file','read_artifact','project_index'].includes(call.name)).map(call=>{
const key=JSON.stringify(call),previous=seen.get(key);seen.set(key,{request:n+1,engineeringState});
return {...call,previousIdenticalRequest:previous?.request??null,repeatedWithoutNewEngineeringState:previous?.engineeringState===engineeringState};
});
perRequest.push({request:n+1,attemptId:attempt.id,startedAt:attempt.startedAt,requestSha256:sha(bytes),files,segments,currentCheckFacts:facts,allFourOriginalFilesPresent:files.every(row=>row.fullOriginalSourcePresent),engineeringStateChanged:previousEngineeringState!==engineeringState,assistantTools,repeatedObservations});
previousEngineeringState=engineeringState;
}
for(const plan of session.execution.contextPlans){assert.equal(plan.budget.contextLimit,16000);assert.equal(plan.budget.outputReservation,2048);assert.equal(plan.budget.safetyTokens,1600);assert.ok(plan.estimatedInputTokens<=plan.budget.inputBudget);assert.ok(plan.tokenReservation.reservedTokens<=Math.min(plan.budget.runRemainingTokens,plan.budget.taskRemainingTokens));}
const result={schemaVersion:1,modelRequests:0,rawPages,perRequest,firstRequestWithAllFourOriginalFiles:perRequest.find(row=>row.allFourOriginalFilesPresent)?.request??null,repeatedObservationCallsWithoutNewEngineeringState:perRequest.flatMap(row=>row.repeatedObservations).filter(row=>row.repeatedWithoutNewEngineeringState).length,nodeDelivered:outcome.success,stopReason:outcome.stopReason,
scope:'Read-only original request bytes, SHA-verified owned artifacts, typed source ranges, chronological actually returned ranges and completed checks. Counts describe this sample; no causal or Purge benefit claim. Engineering state is actual read coverage/completed check source-results/applied changes; observation-only replans are not implementation progress.'};
save('analysis/context-proof.json',result);
console.log(JSON.stringify({passed:true,firstAllFour:result.firstRequestWithAllFourOriginalFiles,repeatedObservations:result.repeatedObservationCallsWithoutNewEngineeringState,requests:perRequest.map(row=>({n:row.request,readTestCharacters:row.files[0].cumulativeActuallyReadCharacters,wireTestCharacters:row.files[0].actualWireCharacters,missingPreviouslyRead:row.files[0].missingPreviouslyReadCharacters,allFour:row.allFourOriginalFilesPresent,checkJobPresent:row.currentCheckFacts?.jobIdOnWire,tools:row.assistantTools.map(call=>call.name)})),modelRequests:0}));
@@ -0,0 +1,108 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { DatabaseSync } from 'node:sqlite';
import { execFileSync } from 'node:child_process';
import { publicSnapshot, databaseSnapshot, canonical, digest } from './desktop-f-state.mjs';
import { root, origin, dataRoot, original, connectionId, save, meta, client, sha } from './live-delivery-v-common.mjs';
import { inspectorClosed } from './live-delivery-v-inspector.mjs';
const read = name => JSON.parse(fs.readFileSync(path.join(root, name)));
const preflight = fs.existsSync(path.join(root,'preflight/result.json')) ? read('preflight/result.json') : { passed:false, usage:null }, nodeExists = fs.existsSync(path.join(root, 'node/result.json'));
const node = nodeExists ? read('node/result.json') : null;
const previous = read(nodeExists ? 'node/after.json' : fs.existsSync(path.join(root,'preflight/after.json')) ? 'preflight/after.json' : 'network/after.json'), before = original.baseline;
const { api, boot, close } = await client();
try {
const host = await api('/host/status'); assert.equal(host.identity.pid, 36552); assert.equal(host.activity.active, false);
const existing = fs.existsSync(path.join(root, 'final/snapshot.json'));
const after = existing ? read('final/snapshot.json') : await publicSnapshot(origin, dataRoot);
if (!existing) save('final/snapshot.json', after);
assert.deepEqual(canonical(databaseSnapshot(dataRoot).tables), canonical(after.database.tables), 'Frozen final snapshot is still current.');
for (const field of ['pid', 'version', 'runtimeRoot', 'configSha256', 'projectsSha256', 'sessionsSha256', 'eventCursor']) assert.deepEqual(after[field], previous[field], field);
assert.deepEqual(canonical(after.database.tables), canonical(previous.database.tables));
assert.deepEqual(after.exports, previous.exports); assert.deepEqual(after.persistent, previous.persistent);
for (const item of before.exports) assert.deepEqual(after.exports.find(value => value.id === item.id), item);
for (const [table, originalTable] of Object.entries(before.database.tables)) assert.equal(after.database.tables[table].schemaSha256, originalTable.schemaSha256, table + ' schema');
for (const table of ['sessions', 'records', 'events', 'outbox']) {
const rows = new Map(after.database.tables[table].rows.map(row => [row.id, row]));
for (const item of before.database.tables[table].rows) assert.deepEqual(rows.get(item.id), item, table + '/' + item.id);
}
const beforeRows = new Map(before.database.tables.metadata.rows.map(row => [row.id, row]));
const finalRows = new Map(after.database.tables.metadata.rows.map(row => [row.id, row]));
for (const [id, row] of beforeRows) if (!['config', 'modelRegistry', 'modelAttempts', 'modelNetworkDiagnostics'].includes(id)) assert.deepEqual(finalRows.get(id), row);
const network = read('network/after.json');
assert.deepEqual(finalRows.get('modelNetworkDiagnostics'), network.database.tables.metadata.rows.find(row => row.id === 'modelNetworkDiagnostics'));
assert.deepEqual([...finalRows.keys()].filter(id => !beforeRows.has(id)), []);
assert.equal(meta('modelNetworkDiagnostics').length, read('network/history-before.json').jobs.length + 1);
const artifacts = new Map(after.persistent.artifacts.map(row => [row.path, row]));
for (const row of before.persistent.artifacts) assert.deepEqual(artifacts.get(row.path), row);
const initialCenter = original.center, center = after.modelCenter;
assert.deepEqual(center.selected, initialCenter.selected); assert.deepEqual(center.pools, initialCenter.pools);
const expectedConnection = initialCenter.connections.find(row => row.id === connectionId), actualConnection = center.connections.find(row => row.id === connectionId);
assert.equal(actualConnection.revision, expectedConnection.revision + (nodeExists ? 2 : 0));
assert.equal(actualConnection.credentialRevision, 1);
assert.deepEqual({ ...actualConnection, revision: expectedConnection.revision, updatedAt: expectedConnection.updatedAt,
health: expectedConnection.health, status: expectedConnection.status }, expectedConnection);
for (const item of initialCenter.connections.filter(row => row.id !== connectionId)) {
const next = center.connections.find(row => row.id === item.id);
if (item.id === 'legacy-default') {
assert.equal(item.revision, original.config.configRevision); assert.equal(next.revision, boot.config.configRevision);
assert.deepEqual({ ...next, revision: item.revision }, item);
} else assert.deepEqual(next, item);
}
assert.deepEqual({ ...boot.config, configRevision: original.config.configRevision }, original.config);
const owns = ['preflight','node'].filter(name => fs.existsSync(path.join(root,name,'owned.json'))).map(name => read(name+'/owned.json'));
const ownedProjects = owns.map(row => row.project.id), ownedSessions = owns.map(row => row.session.id);
assert.deepEqual(boot.projects.filter(row => !ownedProjects.includes(row.id)), original.projects);
assert.deepEqual(after.database.sessionIds.filter(id => !ownedSessions.includes(id)), before.database.sessionIds);
const db = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true });
try {
const projectRows = new Map(db.prepare('SELECT * FROM projects').all().map(row => [row.id, row]));
for (const row of before.database.tables.projects.rows) assert.equal(digest({ ...projectRows.get(row.id), position: projectRows.get(row.id).position - ownedProjects.length }), row.sha256, 'Original raw project except declared insertion offset: ' + row.id);
for (const table of ['sessions', 'records', 'events']) {
const ids = new Set(before.database.tables[table].rows.map(row => row.id));
const rows = db.prepare('SELECT * FROM ' + table).all().filter(row => !ids.has(row.id));
assert.ok(rows.every(row => ownedProjects.includes(row.project_id) && (table === 'sessions' ? ownedSessions.includes(row.id) : ownedSessions.includes(row.session_id))), 'Every new ' + table + ' row belongs only to this experiment.');
}
const sequence = db.prepare("SELECT seq FROM sqlite_sequence WHERE name='events'").get().seq;
assert.equal(sequence, db.prepare('SELECT MAX(seq) AS seq FROM events').get().seq);
const oldOutbox = new Set(before.database.tables.outbox.rows.map(row => row.id));
for (const row of db.prepare('SELECT o.*,e.session_id FROM outbox o JOIN events e ON e.seq=o.seq').all()) if (!oldOutbox.has(row.seq)) assert.ok(ownedSessions.includes(row.session_id));
} finally { db.close(); }
const attempts = meta('modelAttempts'), oldAttempts = fs.existsSync(path.join(root,'preflight/original-attempts.json')) ? read('preflight/original-attempts.json') : read('initial-attempts.json');
for (const item of oldAttempts) assert.deepEqual(attempts.find(row => row.id === item.id), item);
const added = attempts.filter(row => !oldAttempts.some(old => old.id === row.id));
const expectedAttempts = [...(fs.existsSync(path.join(root,'preflight/attempts.json')) ? read('preflight/attempts.json') : []), ...(nodeExists ? read('node/attempts.json') : [])];
assert.deepEqual(added, expectedAttempts); assert.ok(added.every(row => ownedSessions.includes(row.sessionId)));
const reportedTokens = added.reduce((sum, row) => sum + (row.usage?.total_tokens ?? 0), 0);
const unknownRequests = added.filter(row => row.usageStatus === 'unknown').length;
assert.equal(reportedTokens, (preflight.usage?.total_tokens ?? 0) + (node?.usage?.reportedTokens ?? node?.usage?.totalTokens ?? 0));
assert.equal(unknownRequests, node?.usage?.unknownRequests ?? 0);
const sourceChanged = execFileSync('git', ['diff', original.sourceCommit, '--name-only', '--', 'src', 'package.json', 'package-lock.json'], { encoding: 'utf8', windowsHide: true }).trim();
assert.equal(sourceChanged, '');
const contract = JSON.parse(fs.readFileSync('docs/live-delivery-v-contract/manifest.json'));
for (const row of contract.files) {
assert.equal(sha(fs.readFileSync(path.join('docs/live-delivery-v-contract', row.path))), row.sha256);
assert.equal(sha(fs.readFileSync(path.join('.qa',path.basename(row.path,'.txt')))),row.sha256);
}
for (const row of contract.previousDriverHashes) assert.equal(sha(fs.readFileSync(row.path)), row.sha256);
assert.equal(sha(fs.readFileSync(path.join(root, 'current.json'))), contract.originalBaselineSha256);
const result = { passed: true, pid: after.pid, version: after.version, runtimeRoot: after.runtimeRoot,
originalProjects: original.projects.length, originalSessions: before.exports.length, originalArtifacts: before.persistent.artifacts.length,
originalAttempts: oldAttempts.length, finalProjects: after.projects, finalSessions: after.exports.length,
finalArtifacts: after.persistent.artifacts.length, finalCounts: Object.fromEntries(Object.entries(after.database.tables).map(([name, table]) => [name, table.count])),
ownedProjects, ownedSessions, addedAttempts: added.length, originalRowsExportsAndArtifactsExact: true,
originalRawProjectRowsExceptOwnedInsertionOffsetExact: true, ownedProjectInsertionOffset: ownedProjects.length,
allAppendedRowsBelongToOwnedSamples: true, originalPublicProjectsExact: true, originalAttemptsExact: true,
originalBudgetsSelectionAndPoolRestored: true, connectionRevision: [expectedConnection.revision, actualConnection.revision], credentialRevision: 1,
observedHealthAndStatusExcludedFromConfigurationEquality: true,
legacyDisplayRevisionFollowsGlobalConfigurationRevision: [original.config.configRevision, boot.config.configRevision],
diagnosticHistoryOnlyDeclaredAppend: true, diagnosticJobIds: meta('modelNetworkDiagnostics').map(row => row.id),
inspectorClosed: await inspectorClosed(), modelRequests: added.length, reportedTokens, unknownRequests,
estimatedUnknownTokens: node?.usage?.estimatedUnknownTokens ?? 0, nodeDelivered: node?.success ?? false,
preflightPassed: preflight.passed, exactSinceLastRestoration: true, previousDriversUnchanged: true,
purgeBenefitTested: false, keyReadOrResaved: false, productSourceChanged: false };
save('final/result.json', result); console.log(JSON.stringify(result));
} catch (error) {
save('final/audit-error-' + Date.now() + '.json', { name: error.name, message: error.message, stack: error.stack, automaticReplay: false });
throw error;
} finally { await close(); }
@@ -0,0 +1,17 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { databaseSnapshot, canonical } from './desktop-f-state.mjs';
import { root, original, dataRoot, save, client } from './live-delivery-v-common.mjs';
import { inspectorClosed } from './live-delivery-v-inspector.mjs';
const final=JSON.parse(fs.readFileSync(path.join(root,'final/snapshot.json')));
assert.deepEqual(canonical(databaseSnapshot(dataRoot).tables),canonical(final.database.tables));
const {api,boot,close}=await client();
try {
const host=await api('/host/status'),center=await api('/model-center');
assert.equal(host.identity.pid,36552);assert.equal(host.activity.active,false);assert.equal(boot.version,'1.24.8');
for(const key of ['pid','runtimeRoot','runtimeIdentity','dataRoot'])assert.deepEqual(host.identity[key],original.host.identity[key]);
assert.deepEqual(center,final.modelCenter);assert.equal(await inspectorClosed(),true);
save('final/host-readback.json',{host,version:boot.version,originalIdentityExact:true,modelCenterExactSinceRestoration:true,inspectorClosed:true});
console.log(JSON.stringify({passed:true,pid:host.identity.pid,version:boot.version,originalIdentityExact:true,allStoredRowsStillExact:true,inspectorClosed:true,modelRequests:0}));
}finally{await close();}
@@ -0,0 +1,25 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { DatabaseSync } from 'node:sqlite';
import { publicSnapshot } from './desktop-f-state.mjs';
const root = path.resolve('.qa/live-delivery-v'); assert.equal(fs.existsSync(root), false);
const origin = 'http://127.0.0.1:4318', boot = await (await fetch(origin + '/api/bootstrap', { headers: { Connection: 'close' } })).json();
const api = async route => (await fetch(origin + '/api' + route, { headers: { 'X-Workbench-Token': boot.token, Connection: 'close' } })).json();
const host = await api('/host/status'), center = await api('/model-center'), connection = center.connections.find(c => c.id === '5b4daed9-b2f7-4de0-b949-573eba70c7b3');
assert.equal(boot.version, '1.24.8'); assert.equal(host.identity.pid, 36552); assert.equal(host.activity.active, false);
assert.equal(connection.enabled, true); assert.equal(connection.hasKey, true); assert.equal(connection.credentialRevision, 1); assert.equal(connection.revision, 9);
assert.equal(connection.model, 'gpt-6.1-sol'); assert.equal(connection.protocol, 'chat-completions'); assert.equal(connection.streaming, false);
assert.equal(connection.contextLimit, 16000); assert.equal(connection.maxOutputTokens, 2048);
assert.equal(center.connections.find(c => c.id === '09b0293b-faad-45c3-832d-7c8b615813aa').enabled, false);
const baseline = await publicSnapshot(origin, host.identity.dataRoot); assert.deepEqual(baseline.active, []);
assert.deepEqual(center.selected, { type: 'pool', id: '68e30376-b799-445b-a858-db2dba9920a0' });
fs.mkdirSync(root);
const database = new DatabaseSync(path.join(host.identity.dataRoot,'workbench.sqlite'), {readOnly:true});
try { fs.writeFileSync(path.join(root,'initial-attempts.json'),JSON.stringify(JSON.parse(database.prepare('SELECT value FROM metadata WHERE key=?').get('modelAttempts').value),null,2)+'\n',{flag:'wx'}); }
finally { database.close(); }
fs.writeFileSync(path.join(root, 'current.json'), JSON.stringify({ host, config: boot.config, projects: boot.projects, center, baseline,
sourceCommit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(), observedAt: new Date().toISOString() }, null, 2), { flag: 'wx' });
console.log(JSON.stringify({ success: true, version: boot.version, pid: host.identity.pid, projects: baseline.projects, sessions: baseline.exports.length,
connectionId: connection.id, contextLimit: connection.contextLimit, modelRequests: 0 }));
@@ -0,0 +1,58 @@
import assert from 'node:assert/strict';
import net from 'node:net';
import { setTimeout as delay } from 'node:timers/promises';
import { boundedGptPreflight } from './live-delivery-v-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 invokeGptProbe(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 = '(' + boundedGptPreflight.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();
}
}
@@ -0,0 +1,65 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { setTimeout as delay } from 'node:timers/promises';
import { publicSnapshot, canonical } from './desktop-f-state.mjs';
import { root, origin, dataRoot, original, connectionId, save, meta, client } from './live-delivery-v-common.mjs';
assert.equal(fs.existsSync(path.join(root, 'network')), false, 'One diagnostic only; never overwrite or replay.');
const { api, boot, close } = await client();
let jobId;
try {
const host = await api('/host/status');
assert.equal(host.identity.pid, 36552); assert.equal(boot.version, '1.24.8'); assert.equal(host.activity.active, false);
const before = await publicSnapshot(origin, dataRoot); save('network/before.json', before);
assert.deepEqual(canonical(before.database.tables), canonical(original.baseline.database.tables));
assert.deepEqual(before.exports, original.baseline.exports); assert.deepEqual(before.persistent, original.baseline.persistent);
const history = await api('/model-center/network-diagnostics'); save('network/history-before.json', history);
assert.equal(history.active, 0); assert.equal(history.jobs.length, 2);
const connection = before.modelCenter.connections.find(row => row.id === connectionId);
assert.equal(connection.revision, 9); assert.equal(connection.credentialRevision, 1);
save('network/contract.json', { connectionId, revision: connection.revision, target: connection.baseUrl,
maxJobs: 1, budgetMs: 12000, credentialAccess: false, httpRequests: 0, modelRequests: 0,
directEndpointOnly: true, modelApiRouteVerified: false, defaultOrTransportChanges: false });
const started = await api('/model-center/network-diagnostics', { id: connectionId, revision: connection.revision });
save('network/start.json', started); jobId = started.job.id;
const deadline = Date.now() + 20000;
let current;
do {
current = await api('/model-center/network-diagnostics');
if (!current.active) break;
assert.ok(Date.now() < deadline, 'Diagnostic exceeded its bounded deadline.'); await delay(200);
} while (true);
const job = current.jobs.find(row => row.id === jobId);
assert.equal(current.jobs.length, history.jobs.length + 1); assert.equal(current.active, 0); assert.ok(job.finishedAt);
assert.equal(job.connectionId, connectionId); assert.equal(job.connectionRevision, 9);
assert.equal(job.httpRequests, 0); assert.equal(job.modelRequests, 0); assert.equal(job.credentialAccess, false);
assert.equal(job.route.kind, 'direct-endpoint-only'); assert.equal(job.route.modelApiRouteVerified, false);
save('network/history-after.json', current); save('network/job.json', job);
const after = await publicSnapshot(origin, dataRoot); save('network/after.json', after);
for (const field of ['pid', 'version', 'hasKey', 'configSha256', 'projectsSha256', 'sessionsSha256', 'eventCursor', 'modelCenterSha256']) assert.deepEqual(after[field], before[field], field);
assert.deepEqual(after.exports, before.exports); assert.deepEqual(after.persistent.artifacts, before.persistent.artifacts);
assert.deepEqual(after.persistent.files, before.persistent.files);
for (const table of Object.keys(before.database.tables)) {
assert.equal(after.database.tables[table].schemaSha256, before.database.tables[table].schemaSha256);
const nextRows = after.database.tables[table].rows.filter(row => table !== 'metadata' || row.id !== 'modelNetworkDiagnostics');
const previousRows = before.database.tables[table].rows.filter(row => table !== 'metadata' || row.id !== 'modelNetworkDiagnostics');
assert.deepEqual(nextRows, previousRows, table + ': only diagnostic history may change');
}
assert.equal(after.database.tables.metadata.count, before.database.tables.metadata.count);
const stripDerived = ({ stale, currentConnectionRevision, ...raw }) => raw;
assert.deepEqual(meta('modelNetworkDiagnostics').filter(row => row.id !== jobId), history.jobs.map(stripDerived));
assert.equal(meta('modelNetworkDiagnostics').filter(row => row.id === jobId).length, 1);
const result = { passed: true, jobId, diagnosticStatus: job.status, elapsedMs: job.elapsedMs,
dns: job.stages.dns, trials: job.trials.map(row => ({ mode: row.mode, family: row.family, status: row.status, code: row.code })),
route: job.route, originalStateExactExceptNewDiagnosticHistory: true, credentialAccess: false, httpRequests: 0, modelRequests: 0 };
save('network/restoration.json', result); console.log(JSON.stringify(result));
} catch (error) {
save('network/driver-error.json', { name: error.name, message: error.message, stack: error.stack, jobId, automaticReplay: false });
throw error;
} finally {
if (jobId) {
const state = await api('/model-center/network-diagnostics');
if (state.active && ['pending', 'running'].includes(state.jobs.find(row => row.id === jobId)?.status)) save('network/stop.json', await api('/model-center/network-diagnostics/' + jobId + '/stop', {}));
}
await close();
}
@@ -0,0 +1,238 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { setTimeout as delay } from 'node:timers/promises';
import { gitEnvironment } from '../src/core/git-process.mjs';
import { publicSnapshot, canonical } from './desktop-f-state.mjs';
import { root, origin, dataRoot, connectionId, save, meta, client, sha, captureAttempts } from './live-delivery-v-common.mjs';
assert.equal(JSON.parse(fs.readFileSync(path.join(root, 'preflight/result.json'))).passed, true);
assert.equal(fs.existsSync(path.join(root, 'node')), false, 'Never replay or overwrite a live sample.');
const { api, boot, close } = await client();
const allowed = ['src/amount.mjs', 'src/summary.mjs', 'src/report.mjs'];
const budgetFields = ['contextLimit', 'maxSteps', 'maxOutputTokens', 'maxRunTokens', 'maxTaskTokens', 'maxRunDurationMs'];
const connectionFields = ['id', 'name', 'brand', 'model', 'baseUrl', 'enabled', 'requiresKey', 'streaming', 'protocol',
'capabilityDeclarations', 'contextLimit', 'maxOutputTokens', 'concurrency', 'nativeParameters', 'outputTokenField',
'modelIdentityPolicy', 'modelIdentityAliases', 'modelIdentityAliasSource'];
const connectionInput = value => Object.fromEntries(connectionFields.filter(key => Object.hasOwn(value, key)).map(key => [key, value[key]]));
const originalIdentity = value => ({ modelIdentityPolicy: value.modelIdentityPolicy ?? 'record',
modelIdentityAliases: value.modelIdentityAliases ?? [], modelIdentityAliasSource: value.modelIdentityAliasSource ?? '' });
let before, centerBefore, publicMetadata, originalAttempts, connection, configured, project, session, state, taskId, route, budgetWritten = false, selectionWritten = false;
let result, delivery, succeeded = false, failure;
const approvals = [], applications = [], continuations = [], observations = [], start = Date.now();
const sourceRoot = path.join(root, 'node/expense-project');
const git = args => execFileSync('git', ['--no-pager', '--no-optional-locks', '-C', sourceRoot, ...args], { encoding: 'utf8', windowsHide: true, env: gitEnvironment() });
let protectedBytes, stagedBefore;
const protect = () => {
for (const [name, bytes] of Object.entries(protectedBytes)) assert.deepEqual(fs.readFileSync(path.join(sourceRoot, name)), bytes, name);
assert.equal(git(['show', ':owner-staged.txt']), stagedBefore, 'Preserve original index and working-copy states.');
};
const waitFor = async (predicate, timeout = 30000) => {
const deadline = Date.now() + timeout;
while (!await predicate()) { assert.ok(Date.now() < deadline, 'Local operation deadline exceeded; verify outcome, never replay.'); await delay(350); }
};
const review = async (kind, value) => {
const relative = `node/reviews/${kind}-${applications.length + 1}`;
const fingerprint = value.fingerprint ?? sha(JSON.stringify(value));
save(relative + '/input.json', { ...value, fingerprint });
console.log(JSON.stringify({ reviewRequired: true, kind, path: relative + '/input.json', fingerprint }));
const decisionPath = path.join(root, relative, 'decision.json');
await waitFor(async () => fs.existsSync(decisionPath), Math.max(1, 600000 - (Date.now() - start)));
const decision = JSON.parse(fs.readFileSync(decisionPath));
assert.equal(decision.approve, true, 'Supervisor declined the original model proposal.');
assert.ok(typeof decision.reason === 'string' && decision.reason.length > 20, 'Record substantive review.');
assert.equal(decision.fingerprint, fingerprint);
return decision;
};
const remainingRun = async () => {
const requests = state?.execution.task.usage.requests ?? 0;
assert.ok(requests < 8, 'The sealed eight-request budget is exhausted.');
const budgets = { contextLimit: 16000, maxOutputTokens: 2048, maxSteps: 8 - requests,
maxRunTokens: 90000, maxTaskTokens: 90000, maxRunDurationMs: 600000 };
await api('/model-center/runtime-budgets', budgets); budgetWritten = true;
continuations.push({ beforeRequests: requests, remainingSteps: budgets.maxSteps, at: new Date().toISOString() });
};
try {
assert.equal(boot.version, '1.24.8');
const host = await api('/host/status'); assert.equal(host.identity.pid, 36552); assert.equal(host.activity.active, false);
before = await publicSnapshot(origin, dataRoot); save('node/before.json', before);
centerBefore = await api('/model-center'); connection = centerBefore.connections.find(value => value.id === connectionId);
assert.equal(connection.enabled, true); assert.equal(connection.hasKey, true); assert.equal(connection.revision, 9);
assert.equal(connection.model, 'gpt-6.1-sol'); assert.equal(connection.protocol, 'chat-completions'); assert.equal(connection.contextLimit, 16000);
assert.deepEqual(originalIdentity(connection), { modelIdentityPolicy: 'record', modelIdentityAliases: [], modelIdentityAliasSource: '' });
publicMetadata = { config: meta('config'), registry: meta('modelRegistry') };
save('node/original-public-metadata.json', publicMetadata);
originalAttempts = meta('modelAttempts'); save('node/original-attempts.json', originalAttempts);
save('node/contract.json', { kind: 'new-real-Node-engineering', version: boot.version, connectionId, connection,
maxRequests: 8, maxTokens: 90000, contextLimit: 16000, maxOutputTokens: 2048, maxDurationMs: 600000,
allowed, checks: ['test', 'build'], expectedTests: 9, commands: 'Only model-planned npm test/build, no arbitrary run_command',
review: 'Model seals all three files, supervisor reviews and applies; model plans Git, supervisor confirms.',
continuation: 'Only review-action continuation of the same task with remaining steps, no extra implementation prompts.',
originalImplementationSupplied: false, automaticRetry: false, poolSwitching: false,
originalSelected: centerBefore.selected, originalBudgets: Object.fromEntries(budgetFields.map(key => [key, boot.config[key]])),
restore: 'Original budget values and selection restored. Original absent identity fields become explicit record/[]/empty-string defaults; raw pre-state retained and only this declared normalization accepted. Revision counters remain monotonic.' });
fs.cpSync('benchmarks/live-delivery-v1/node', sourceRoot, { recursive: true, errorOnExist: true });
fs.writeFileSync(path.join(sourceRoot, 'README.md'), '# Expense report acceptance\nRepair the three source modules using the immutable original nine tests; do not edit checks or owner files.\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 original 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 expense engineering baseline and original checks']);
fs.writeFileSync(path.join(sourceRoot, 'owner-staged.txt'), 'Owner staged change\n'); git(['add', '--', 'owner-staged.txt']);
stagedBefore = git(['show', ':owner-staged.txt']);
fs.writeFileSync(path.join(sourceRoot, 'owner-staged.txt'), 'Owner working copy differs from 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))]));
const sourceFiles = [...protectedNames, ...allowed];
const frozenContract = JSON.parse(fs.readFileSync('docs/live-delivery-v-contract/manifest.json'));
assert.deepEqual(Object.fromEntries(sourceFiles.map(name => [name, sha(fs.readFileSync(path.join(sourceRoot, name)))])), frozenContract.originalElevenFileHashes);
for (const name of sourceFiles) save('node/source-before/' + name, fs.readFileSync(path.join(sourceRoot, name)));
save('node/source-identity.json', { head: git(['rev-parse', 'HEAD']).trim(), status: git(['status', '--porcelain=v1']), stagedBefore,
files: Object.fromEntries(sourceFiles.map(name => [name, sha(fs.readFileSync(path.join(sourceRoot, name)))])) });
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(connection), revision: connection.revision,
modelIdentityPolicy: 'require-match', modelIdentityAliases: [], modelIdentityAliasSource: '' });
assert.equal(configured.credentialRevision, connection.credentialRevision); assert.equal(configured.hasKey, true);
save('node/connection-frozen.json', configured);
await remainingRun(); await api('/model-center/select', { type: 'connection', id: connectionId }); selectionWritten = true;
const goal = '修复这个Node费用报表工程的amount、summary、report三个模块。金额用精确分单位处理,接受测试约定的十进制字符串/有限数字、退款、0及空白;拒绝格式错误、超精度和不安全金额。按独立币种规范化/排序汇总并保留原数组,计数准确、安全求和,报表两位小数含负分金额。以原九项测试为完整契约。'
+ '先inspect_project,再plan_checks选择["test","build"]并run_checks保留真实基线失败,读取原测试和相关源码。只允许修改src/amount.mjs、src/summary.mjs、src/report.mjs;不改测试、配置、README、构建脚本、owner文件或原暂存,不使用run_command,不直接提交Git。'
+ 'propose_file/propose_patch准备完整三个模块后,用prepare_change_set一次封存全部三文件,等待审查应用。应用后继续同一个Task,重新plan_checks/run_checks,通过原9项测试和build后,用plan_delivery为三个文件准备本地Git预览并等待确认。模型必须自己实现,禁止用口头完成替代检查。预算最多8次模型请求、90000tokens,输出2048,上下文16K,请合并独立工具调用并避免重复观察。';
save('node/goal.txt', goal); protect();
await api(route + '/messages', { content: goal });
while (Date.now() - start < 600000) {
state = await api(route); taskId ??= state.execution.task.id; assert.equal(state.execution.task.id, taskId); protect();
const usage = state.execution.task.usage; assert.ok(usage.requests <= 8); assert.ok(usage.totalTokens <= 90000);
const progress = { status: state.status, requests: usage.requests, tokens: usage.totalTokens, lastTool: state.events.filter(event => event.kind === 'tool').at(-1)?.tool,
checks: state.execution.checks.map(job => job.status), elapsedSeconds: Math.round((Date.now() - start) / 1000) };
if (JSON.stringify({ ...progress, elapsedSeconds: 0 }) !== JSON.stringify({ ...observations.at(-1), elapsedSeconds: 0 })) { observations.push(progress); console.log(JSON.stringify(progress)); }
for (const change of state.changes.filter(change => ['pending', 'conflict'].includes(change.status))) assert.ok(allowed.includes(change.path), 'Out-of-scope proposal: ' + change.path);
for (const approval of state.approvals.filter(item => item.status === 'pending')) {
const plan = state.execution.plans.find(value => value.id === approval.checkPlanId);
const allow = !!plan && plan.taskId === taskId && plan.checks.length === 2 && plan.checks.every(check => ['test', 'build'].includes(check.name) && !check.lifecycle?.length)
&& approval.cwd === sourceRoot && approval.command === plan.checks.map(check => check.command).join('\n');
approvals.push({ approvalId: approval.id, planId: plan?.id, command: approval.command, allow });
await api(route + '/approvals/' + approval.id, { allow }); assert.equal(allow, true, 'Only the sealed original checks are authorized.');
}
if (['running', 'awaiting_approval', 'stopping'].includes(state.status)) { await delay(650); continue; }
if (state.status === 'failed') throw new Error(state.failure?.message ?? 'Actual-model task failed');
const plan = state.execution.deliveryPlans?.findLast(value => value.status === 'planned' && value.taskId === taskId);
if (plan) {
assert.deepEqual(plan.paths.slice().sort(), allowed.slice().sort()); const requests = usage.requests;
assert.ok(state.events.some(event => event.tool === 'plan_delivery' && event.phase === 'completed'));
const passing = state.execution.checks.filter(job => job.status === 'passed').at(-1);
assert.equal(passing?.results.find(value => value.name === 'test')?.tests?.passed, 9);
await review('git', { plan, fingerprint: plan.fingerprint, checks: state.execution.checks, source: state.changes,
status: git(['status', '--porcelain=v1']), stagedBefore, stagedAfter: git(['show', ':owner-staged.txt']) });
await api(route + '/delivery-jobs', { planId: plan.id });
await waitFor(async () => { state = await api(route); delivery = state.execution.deliveries.at(-1); return !!delivery?.reportArtifactId; });
assert.equal(delivery.status, 'completed'); assert.equal(state.execution.task.usage.requests, requests); break;
}
const pending = state.changes.filter(change => change.status === 'pending');
const batch = state.execution.changeSets?.findLast(value => value.taskId === taskId && value.status === 'prepared');
if (pending.length) {
assert.ok(state.execution.checks.some(job => job.status === 'failed' && job.results.some(value => value.tests?.failed > 0)), 'Model must preserve the original failing tests.');
assert.equal(batch?.source, 'agent', 'Model must seal its own complete change set.');
assert.deepEqual(batch.files.map(file => file.changeId).sort(), pending.map(change => change.id).sort());
if (!applications.length) assert.deepEqual(batch.files.map(file => file.path).sort(), allowed.slice().sort());
assert.ok(applications.length < 3);
await review('changes', { fingerprint: batch.fingerprint, batch, changes: pending, checks: state.execution.checks });
await api(route + '/change-sets/' + batch.id + '/apply', { fingerprint: batch.fingerprint });
await waitFor(async () => (await api(route + '/change-sets/' + batch.id)).status === 'completed');
for (const change of pending) assert.equal(sha(fs.readFileSync(path.join(sourceRoot, change.path))), change.sha256);
applications.push({ id: batch.id, fingerprint: batch.fingerprint, paths: batch.files.map(file => file.path), source: batch.source }); protect();
await remainingRun(); await api(route + '/continue-reviewed', {}); continue;
}
throw new Error('Model stopped before verified Git delivery: ' + state.status + '/' + state.execution.run.stopReason);
}
assert.ok(delivery, 'The sealed engineering deadline ended without complete delivery.');
const passing = state.execution.checks.filter(job => job.status === 'passed').at(-1); assert.ok(passing);
const tests = passing.results.find(value => value.name === 'test')?.tests; assert.equal(tests?.total, 9); assert.equal(tests.passed, 9); assert.equal(tests.failed, 0);
assert.deepEqual(git(['diff-tree', '--no-commit-id', '--name-only', '-r', 'HEAD']).trim().split(/\r?\n/).sort(), allowed.slice().sort()); protect();
succeeded = true;
result = { success: true, commit: delivery.commit, tests, delivery, checkJobId: passing.id };
} catch (error) {
failure = { name: error.name, message: error.message, stack: error.stack, at: new Date().toISOString(), automaticReplay: false };
result = { success: false, failure }; process.exitCode = 1;
} finally {
if (route) {
state = await api(route);
if (['running', 'stopping', 'awaiting_approval'].includes(state.status)) { await api(route + '/stop', {}); state = await api(route); }
taskId ??= state.execution.task?.id;
save('node/session.json', state); save('node/export.json', await api(route + '/export'));
const attempts = meta('modelAttempts').filter(value => value.sessionId === session.id); save('node/attempts.json', attempts);
const captures = await captureAttempts(api, attempts, 'node/captures');
const identitiesValid = attempts.every(value => value.connectionId === connectionId && value.poolId === null && value.ordinal === 1
&& value.status === 'completed' && value.modelIdentity?.status === 'matched' && value.modelIdentity.complete === true && value.modelIdentity.policy === 'require-match');
result = { ...result, version: boot.version, sessionId: session.id, projectId: project.id, taskId, sourceRoot,
connectionId, requestedModel: 'gpt-6.1-sol', usage: state.execution.task?.usage, state: state.status, stopReason: state.execution.run?.stopReason,
attempts: attempts.length, identitiesValid, captures, approvals, applications, continuations, observations,
modelImplementationSuppliedBySupervisor: false, modelWeightsAuthenticated: false, originalPurgeBenefitTested: false,
elapsedSeconds: Math.round((Date.now() - start) / 1000) };
if (succeeded) assert.equal(identitiesValid, true);
save('node/model-outcome.json', result);
for (const name of allowed) save('node/source-after/' + name, fs.readFileSync(path.join(sourceRoot, name)));
save('node/git-final.json', { head: git(['rev-parse', 'HEAD']).trim(), status: git(['status', '--porcelain=v1']), stagedBefore, stagedAfter: git(['show', ':owner-staged.txt']), diff: git(['diff', 'HEAD', '--', ...allowed]) });
}
const host = await api('/host/status'); assert.equal(host.activity.active, false, 'Do not overwrite another active task.');
if (configured) {
const center = await api('/model-center'), current = center.connections.find(value => value.id === connectionId);
assert.equal(current.revision, configured.revision, 'Do not overwrite an external connection edit.');
const restored = await api('/model-center/connections', { ...connectionInput(connection), ...originalIdentity(connection), revision: current.revision });
assert.equal(restored.credentialRevision, connection.credentialRevision); save('node/connection-restored.json', restored);
assert.deepEqual(originalIdentity(restored), originalIdentity(connection));
}
if (budgetWritten) await api('/model-center/runtime-budgets', Object.fromEntries(budgetFields.map(key => [key, boot.config[key]])));
if (selectionWritten) await api('/model-center/select', centerBefore.selected);
const after = await publicSnapshot(origin, dataRoot); save('node/after.json', after);
if (before) {
for (const item of before.exports) assert.deepEqual(after.exports.find(value => value.id === item.id), item, 'Original export: ' + item.id);
for (const table of ['sessions', 'records', 'events', 'outbox']) {
const rows = new Map(after.database.tables[table].rows.map(row => [row.id, row]));
for (const row of before.database.tables[table].rows) assert.deepEqual(rows.get(row.id), row, 'Original ' + table + '/' + row.id);
}
const artifactMap = new Map(after.persistent.artifacts.map(value => [value.path, value]));
for (const item of before.persistent.artifacts) assert.deepEqual(artifactMap.get(item.path), item, 'Original artifact: ' + item.path);
const finalBoot = await api('/bootstrap'), normalized = { ...finalBoot.config, configRevision: boot.config.configRevision };
assert.deepEqual(canonical(normalized), canonical(boot.config));
assert.deepEqual(finalBoot.projects.filter(value => value.id !== project?.id), boot.projects, 'Every original public project, excluding only the new owned sample.');
assert.deepEqual(after.modelCenter.selected, centerBefore.selected); assert.deepEqual(after.modelCenter.pools, centerBefore.pools);
for (const item of centerBefore.connections.filter(value => ![connectionId, 'legacy-default'].includes(value.id))) assert.deepEqual(after.modelCenter.connections.find(value => value.id === item.id), item);
const finalMetadata = { config: meta('config'), registry: meta('modelRegistry') };
save('node/final-public-metadata.json', finalMetadata);
const configNormalized = { ...finalMetadata.config, configRevision: publicMetadata.config.configRevision };
assert.deepEqual(canonical(configNormalized), canonical(publicMetadata.config), 'Raw public disk config except its monotonic revision.');
const registryNormalized = structuredClone(finalMetadata.registry);
assert.ok(registryNormalized.revision > publicMetadata.registry.revision);
registryNormalized.revision = publicMetadata.registry.revision;
const originalConnection = publicMetadata.registry.connections.find(value => value.id === connectionId);
const finalConnection = registryNormalized.connections.find(value => value.id === connectionId);
assert.equal(finalConnection.revision, originalConnection.revision + 2);
finalConnection.revision = originalConnection.revision; finalConnection.updatedAt = originalConnection.updatedAt;
const registryBefore = structuredClone(publicMetadata.registry);
const normalizedBeforeConnection = registryBefore.connections.find(value => value.id === connectionId);
const normalization = Object.fromEntries(Object.entries(originalIdentity(normalizedBeforeConnection)).filter(([key]) => !Object.hasOwn(normalizedBeforeConnection, key)));
Object.assign(normalizedBeforeConnection, normalization);
save('node/declared-identity-default-normalization.json', { connectionId, added: normalization,
originalRawStatePreserved: true, originalSemanticsRestored: true, reason: 'The public partial-update API retains missing fields; restore explicit original default semantics rather than silently retaining require-match.' });
for (const value of [registryBefore, registryNormalized]) value.connections.sort((a, b) => a.id.localeCompare(b.id));
assert.deepEqual(canonical(registryNormalized), canonical(registryBefore), 'Registry except declared revision/timestamp/order and explicit original identity defaults.');
const finalAttempts = meta('modelAttempts');
for (const item of originalAttempts) assert.deepEqual(finalAttempts.find(value => value.id === item.id), item, 'Original complete model attempt: ' + item.id);
const metadataRows = new Map(after.database.tables.metadata.rows.map(row => [row.id, row]));
for (const row of before.database.tables.metadata.rows.filter(row => !['config', 'modelRegistry', 'modelAttempts'].includes(row.id))) assert.deepEqual(metadataRows.get(row.id), row);
save('node/restoration.json', { passed: true, originalExports: before.exports.length, originalArtifactFiles: before.persistent.artifacts.length,
originalRowsExact: ['sessions', 'records', 'events', 'outbox'], budgetsAndSelectionRestored: true, poolsUnchanged: true,
originalPublicProjectsExact: true, originalAttemptsExact: originalAttempts.length, rawConfigExceptRevisionExact: true,
registryExceptDeclaredRevisionTimestampOrderAndIdentityDefaultsExact: true, identityDefaultNormalization: normalization, otherMetadataRowsExact: true,
originalCredentialRevision: connection?.credentialRevision, finalCredentialRevision: after.modelCenter.connections.find(value => value.id === connectionId)?.credentialRevision,
changedOnlyMonotonicRevisionsObservedHealthAndDeclaredIdentityDefaults: true, pid: after.pid, version: after.version, noKeyExtractedOrResaved: true });
}
save('node/result.json', result ?? { success: false, failure, noModelDispatch: true }); await close();
}
console.log(JSON.stringify({ success: result.success, attempts: result.attempts, usage: result.usage, state: result.state,
stopReason: result.stopReason, commit: result.commit, tests: result.tests, error: result.failure?.message }));
@@ -0,0 +1,35 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { DatabaseSync } from 'node:sqlite';
import { databaseSnapshot, canonical, digest } from './desktop-f-state.mjs';
import { root, dataRoot, original, save } from './live-delivery-v-common.mjs';
const final = JSON.parse(fs.readFileSync(path.join(root, 'final/result.json')));
const snapshot = JSON.parse(fs.readFileSync(path.join(root, 'final/snapshot.json')));
assert.deepEqual(canonical(databaseSnapshot(dataRoot).tables), canonical(snapshot.database.tables));
const db = new DatabaseSync(path.join(dataRoot, 'workbench.sqlite'), { readOnly: true });
try {
const additions = {};
for (const table of ['sessions', 'records', 'events']) {
const originalIds = new Set(original.baseline.database.tables[table].rows.map(row => row.id));
additions[table] = db.prepare('SELECT * FROM ' + table).all().filter(row => !originalIds.has(row.id)).map(row => ({
id: row.id, ...(row.kind ? { kind: row.kind } : {}), projectId: row.project_id,
sessionId: table === 'sessions' ? row.id : row.session_id, sha256: digest(row) }));
assert.ok(additions[table].every(row => final.ownedProjects.includes(row.projectId) && final.ownedSessions.includes(row.sessionId)));
}
const originalOutbox = new Set(original.baseline.database.tables.outbox.rows.map(row => row.id));
additions.outbox = db.prepare('SELECT o.seq,o.published_at,e.session_id FROM outbox o JOIN events e ON e.seq=o.seq').all()
.filter(row => !originalOutbox.has(row.seq)).map(row => ({ id: row.seq, sessionId: row.session_id, sha256: digest({ seq: row.seq, published_at: row.published_at }) }));
assert.ok(additions.outbox.every(row => final.ownedSessions.includes(row.sessionId)));
const originalProjects = new Map(original.baseline.database.tables.projects.rows.map(row => [row.id, row]));
const projects = db.prepare('SELECT * FROM projects').all().map(row => ({ id: row.id, position: row.position, actualSha256: digest(row),
...(originalProjects.has(row.id) ? { originalSha256: originalProjects.get(row.id).sha256,
normalizedSha256: digest({ ...row, position: row.position - final.ownedProjectInsertionOffset }) } : { owned: true }) }));
assert.ok(projects.filter(row => row.originalSha256).every(row => row.normalizedSha256 === row.originalSha256));
const result = { additions, projects, projectInsertionOffset: final.ownedProjectInsertionOffset,
sequence: db.prepare("SELECT seq FROM sqlite_sequence WHERE name='events'").get().seq,
scope: 'Only IDs, owner fields and full-row hashes of additions; original project payloads are not exported. No key or user content returned.' };
save('final/ownership-proof.json', result);
console.log(JSON.stringify({ passed: true, additions: Object.fromEntries(Object.entries(additions).map(([name, rows]) => [name, rows.length])),
originalProjectsNormalizedExact: projects.filter(row => row.originalSha256).length, ownedProjects: projects.filter(row => row.owned).length }));
} finally { db.close(); }
@@ -0,0 +1,85 @@
// One-shot QA adapter. Runs inside the existing host; never reads a credential.
export async function boundedGptPreflight(input) {
const ensure = (value, message) => { if (!value) throw new Error(message); };
ensure(process.pid === input.pid, 'Unexpected host PID.');
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 owned loopback server.');
const context = servers[0].workbenchHostAuthority?.context;
ensure(context?.provider && context?.store && context?.runtime, 'Original context missing.');
const { store, provider, runtime } = context;
ensure(runtime.appDirectory === input.runtimeRoot, 'Loaded runtime changed.');
ensure(![...store.sessions.values()].some(s => ['running', 'stopping', 'awaiting_approval'].includes(s.status)), 'Host is busy.');
const session = store.session(input.sessionId), project = store.project(session.projectId);
ensure(session.projectId === input.projectId && session.messages.length === 0 && !session.runId, 'Probe session must be new and owned.');
const hub = provider.modelHub(store);
const connection = hub.view().connections.find(c => c.id === input.connectionId);
ensure(connection?.hasKey && connection.credentialRevision === input.credentialRevision, 'Original saved credential revision changed.');
ensure(connection.enabled && connection.protocol === 'chat-completions' && (connection.modelIdentityPolicy ?? 'record') === 'record', 'Probe protocol/auth/identity mismatch.');
ensure(connection.baseUrl === input.baseUrl && connection.model === input.model && connection.revision === input.connectionRevision, 'Connection changed.');
const config = hub.prepare({ ...store.config, mode: 'compatible', maxSteps: 1, maxOutputTokens: 256,
contextLimit: 16000, maxRunTokens: 16000, maxTaskTokens: 16000, maxRunDurationMs: 320000,
modelResponseTimeoutMs: 300000, modelStreamIdleTimeoutMs: 120000 }, { type: 'connection', id: input.connectionId });
config.modelRouting.members = config.modelRouting.members.map(member => ({ ...member, modelIdentityPolicy: 'require-match', modelIdentityAliases: [], modelIdentityAliasSource: '' }));
ensure(config.modelRouting.members.length === 1 && config.modelRouting.maxAttempts === 1 && config.maxOutputTokens === 256, 'One-request hard limits missing.');
globalThis.__gptVProbeOnce ??= new Set();
ensure(!globalThis.__gptVProbeOnce.has(input.sessionId), 'This sample cannot be replayed.');
globalThis.__gptVProbeOnce.add(input.sessionId);
session.title = input.title;
const run = store.beginRun(session, input.prompt, false, config, { forceNewTask: true });
store.message(session, 'user', input.prompt);
session.providerMessages.push({ role: 'user', content: input.prompt });
const step = store.beginStep(session, run), planner = runtime.requestPlanner();
let plan, response, diagnostic = null, requestEvent, receipts = 0, wireStarts = 0;
const wireIds = new Set();
const signal = AbortSignal.timeout(320000);
let stopReason = 'identity_probe_complete';
try {
plan = planner.prepare(session, run, config, { system: 'This is a connection identity preflight. Reply to the user exactly. No tools are available. Do not perform any project work.', tools: [], stepId: step.id });
const variants = plan.body.kind === 'model-route-plan' ? plan.body.variants.map(v => v.body) : [plan.body];
ensure(variants.length === 1 && variants.every(b => !(b.tools?.length) && b.max_tokens === 256 && b.model === input.model), 'Wire request violates no-tool contract.');
ensure(plan.record.tokenReservation.reservedTokens <= 16000, 'Reservation exceeds sealed budget.');
const progress = event => {
if (event.consumption) {
receipts += Number(store.recordConsumption(session, run, { ...event.consumption, requestId: plan.record.id }, plan.record.tokenReservation.reservedTokens));
return;
}
if (event.phase === 'running' && event.wireAttemptId) { wireIds.add(event.wireAttemptId); wireStarts = wireIds.size; ensure(wireStarts === 1, 'No retries permitted.'); }
requestEvent ??= store.event(session, { kind: 'model', source: 'model_connection', label: 'V · GPT单次身份预检(无工具)', phase: 'running', runId: run.id, contextPlanId: plan.record.id, startedAt: new Date().toISOString() });
if (event.modelAttemptId) requestEvent.modelAttemptId = event.modelAttemptId;
if (event.connectionId) requestEvent.connectionId = event.connectionId;
if (event.model) requestEvent.actualModel = event.model;
if (event.modelIdentity) requestEvent.modelIdentity = event.modelIdentity;
if (event.requestUrl) requestEvent.requestUrl = event.requestUrl;
if (event.diagnostic) requestEvent.diagnostic = event.diagnostic;
if (event.stream) requestEvent.stream = event.stream;
if (event.phase) requestEvent.phase = event.phase;
plan.record.requestAttempts = wireStarts; step.modelAttempts = wireStarts;
store.save(session);
};
response = await provider.complete(config, plan.messages, project, signal, progress, plan.record, [], { attempts: 1, maxBudgetAttempts: 1 });
ensure(!response.message.tool_calls?.length, 'Unsolicited tools are never executed.');
ensure(receipts === 1, 'Expected one original consumption receipt.');
planner.finish(session, plan.record, { response, attempts: wireStarts });
session.providerMessages.push(response.message); store.message(session, 'assistant', response.message.content);
const total = (run.usage?.reportedTokens ?? run.usage?.totalTokens ?? 0);
session.status = total > 16000 ? 'paused' : 'completed';
if (total > 16000) stopReason = 'task_token_limit';
} catch (cause) {
diagnostic = cause.diagnostic ?? { source: 'workbench', origin: 'local', stage: 'identity_preflight', kind: signal.aborted ? 'cancelled' : 'runtime', title: '身份预检需要核对', message: provider.redact(cause.message), occurredAt: new Date().toISOString() };
session.status = diagnostic.kind === 'model_identity' || signal.aborted ? 'paused' : 'failed';
stopReason = diagnostic.kind;
session.lastFailure = { ...diagnostic, runId: run.id };
const message = store.message(session, 'system', diagnostic.message);
session.failure = { ...session.lastFailure, messageId: message.id };
if (plan) planner.finish(session, plan.record, { error: new Error(diagnostic.message), attempts: wireStarts });
} finally {
if (requestEvent) { requestEvent.phase = diagnostic ? 'failed' : 'completed'; requestEvent.finishedAt = new Date().toISOString(); if (diagnostic) requestEvent.diagnostic = diagnostic; }
store.finishStep(session, step, diagnostic ? 'failed' : 'completed');
store.finishRun(session, run, stopReason);
}
const attempts = hub.attempts.filter(a => a.sessionId === session.id);
ensure(attempts.length <= 1 && wireStarts <= 1, 'Single-request limit exceeded.');
return { sessionId: session.id, projectId: project.id, taskId: run.taskId, runId: run.id, status: session.status,
stopReason, attempts: attempts.length, receipts, wireStarts, actualTools: run.toolCalls, usage: run.usage,
contextPlanId: plan?.record.id ?? null, diagnostic, message: response?.message ?? null };
}
@@ -0,0 +1,40 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { root, save, original, client, meta, connectionId } from './live-delivery-v-common.mjs';
import { inspectorClosed } from './live-delivery-v-inspector.mjs';
const read = name => JSON.parse(fs.readFileSync(path.join(root, name)));
const before = read('preflight/before.json'), after = read('preflight/after.json');
const owned = read('preflight/owned.json'), outcome = read('preflight/result.json');
assert.equal(outcome.passed, true);
assert.equal(after.pid, before.pid); assert.equal(after.pid, 36552); assert.equal(after.version, '1.24.8');
assert.equal(after.configSha256, before.configSha256); assert.deepEqual(after.active, []);
for (const item of before.exports) assert.deepEqual(after.exports.find(value => value.id === item.id), item);
const tables = ['sessions', 'records', 'events', 'outbox'];
for (const table of tables) {
assert.equal(after.database.tables[table].schemaSha256, before.database.tables[table].schemaSha256);
const rows = new Map(after.database.tables[table].rows.map(row => [row.id, row]));
for (const row of before.database.tables[table].rows) assert.deepEqual(rows.get(row.id), row, table + '/' + row.id);
}
const rows = new Map(after.database.tables.metadata.rows.map(row => [row.id, row]));
for (const row of before.database.tables.metadata.rows.filter(row => row.id !== 'modelAttempts')) assert.deepEqual(rows.get(row.id), row, row.id);
const artifacts = new Map(after.persistent.artifacts.map(row => [row.path, row]));
for (const row of before.persistent.artifacts) assert.deepEqual(artifacts.get(row.path), row);
assert.deepEqual(after.modelCenter.selected, before.modelCenter.selected); assert.deepEqual(after.modelCenter.pools, before.modelCenter.pools);
for (const item of before.modelCenter.connections) {
const next = after.modelCenter.connections.find(row => row.id === item.id);
if (item.id === connectionId) { const health = next.health; assert.ok(health); assert.deepEqual({ ...next, health: item.health }, item); }
else assert.deepEqual(next, item);
}
for (const item of read('preflight/original-attempts.json')) assert.deepEqual(meta('modelAttempts').find(row => row.id === item.id), item);
const { boot, close } = await client();
try {
assert.deepEqual(boot.config, original.config);
assert.deepEqual(boot.projects.filter(row => row.id !== owned.project.id), original.projects);
const closed = await inspectorClosed();
const result = { passed: true, pid: after.pid, version: after.version, originalExports: before.exports.length,
originalArtifacts: before.persistent.artifacts.length, originalRowsExact: tables, otherMetadataExceptAppendedAttemptsExact: true,
originalPublicProjectsExact: true, originalConfigRegistryAndPoolExact: true, observedConnectionHealthChange: true,
inspectorClosed: closed, noKeyReadOrResaved: true, ownedProjectId: owned.project.id, ownedSessionId: owned.session.id };
save('preflight/restoration.json', result); console.log(JSON.stringify(result));
} finally { await close(); }
@@ -0,0 +1,69 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { publicSnapshot, hash } from './desktop-f-state.mjs';
import { invokeGptProbe, inspectorClosed } from './live-delivery-v-inspector.mjs';
import { root, origin, dataRoot, connectionId, save, meta, client, captureAttempts } from './live-delivery-v-common.mjs';
assert.equal(fs.existsSync(path.join(root, 'preflight')), false, 'Never replay or overwrite a real sample.');
assert.equal(JSON.parse(fs.readFileSync(path.join(root, 'network/restoration.json'))).diagnosticStatus, 'passed');
const { api, boot, close } = await client();
let fatal;
try {
await inspectorClosed();
assert.equal(boot.version, '1.24.8');
const host = await api('/host/status'); assert.equal(host.identity.pid, 36552); assert.equal(host.activity.active, false);
const before = await publicSnapshot(origin, dataRoot); save('preflight/before.json', before);
assert.deepEqual(before.active, []);
const connection = before.modelCenter.connections.find(value => value.id === connectionId);
assert.equal(connection.enabled, true); assert.equal(connection.hasKey, true); assert.equal(connection.credentialRevision, 1);
assert.equal(connection.protocol, 'chat-completions'); assert.equal(connection.model, 'gpt-6.1-sol'); assert.equal(connection.revision, 9);
assert.equal(connection.contextLimit, 16000); assert.equal(connection.modelIdentityPolicy ?? 'record', 'record');
const originalAttempts = meta('modelAttempts'); save('preflight/original-attempts.json', originalAttempts);
const nonce = randomUUID(), prompt = `这是独立GPT连接身份预检,不是工程任务。只回复 OK ${nonce},不要调用工具、读写文件或执行命令。`;
save('preflight/contract.json', { kind: 'single-real-GPT-identity-preflight', connectionId, connection,
version: boot.version, runtimeRoot: boot.runtimeRoot, maxRequests: 1, maxAttempts: 1, maxOutputTokens: 256,
maxTokens: 16000, contextLimit: 16000, toolDefinitions: 0, toolExecution: 0,
poolSwitching: false, automaticReplay: false, modelIdentityPolicy: 'require-match in this experiment snapshot only',
noGlobalConfigurationWrite: true, noCredentialExtractionOrResave: true, prompt, nonce,
originalBaselineSha256: hash(fs.readFileSync(path.join(root, 'preflight/before.json'))) });
const projectRoot = path.join(root, 'preflight/identity-only'); fs.mkdirSync(projectRoot);
fs.writeFileSync(path.join(projectRoot, 'README.md'), '# V GPT identity preflight\nNo engineering or command execution.\n', { flag: 'wx' });
const project = await api('/projects', { root: projectRoot });
const session = await api('/sessions', { projectId: project.id }); save('preflight/owned.json', { project, session });
const input = { pid: host.identity.pid, port: 4318, runtimeRoot: boot.runtimeRoot, sessionId: session.id, projectId: project.id,
connectionId, connectionRevision: connection.revision, credentialRevision: connection.credentialRevision,
baseUrl: connection.baseUrl, model: connection.model, title: 'V · jojocode GPT连接单次预检', prompt };
save('preflight/input.json', input);
console.log(JSON.stringify({ stage: 'single-GPT-preflight', connectionId, model: connection.model, requestUrl: connection.baseUrl + '/chat/completions', maxRequests: 1, toolDefinitions: 0 }));
const invoked = await invokeGptProbe(input); save('preflight/expression.js', invoked.expression); save('preflight/host-result.json', invoked.result);
const previous = new Set(originalAttempts.map(value => value.id));
const attempts = meta('modelAttempts').filter(value => !previous.has(value.id)); save('preflight/attempts.json', attempts);
assert.ok(attempts.length <= 1); for (const attempt of attempts) { assert.equal(attempt.sessionId, session.id); assert.equal(attempt.connectionId, connectionId); assert.equal(attempt.poolId, null); }
const state = await api('/sessions/' + session.id); save('preflight/session.json', state);
save('preflight/export.json', await api('/sessions/' + session.id + '/export'));
const captures = await captureAttempts(api, attempts, 'preflight/captures');
const attempt = attempts[0];
const passed = attempts.length === 1 && attempt.status === 'completed' && attempt.modelIdentity?.status === 'matched'
&& attempt.modelIdentity.complete === true && attempt.modelIdentity.policy === 'require-match' && attempt.responseRedacted === false
&& attempt.usageStatus === 'reported' && attempt.usage.total_tokens <= 16000 && captures.length === 2
&& invoked.result.actualTools === 0 && state.status === 'completed' && invoked.result.message?.content?.includes(nonce);
const result = { passed, engineeringTestAllowed: passed, testedAt: new Date().toISOString(), version: boot.version,
connectionId, sessionId: session.id, projectId: project.id, taskId: invoked.result.taskId,
requestedModel: connection.model, reportedModels: attempt?.modelIdentity?.reportedModels ?? [], identity: attempt?.modelIdentity,
requestUrl: attempt?.requestUrl, requests: attempts.length, usage: attempt?.usage ?? null, usageStatus: attempt?.usageStatus ?? 'not_dispatched',
actualTools: invoked.result.actualTools, stopReason: invoked.result.stopReason, captures,
noRetryOrPoolSwitch: attempts.every(value => value.ordinal === 1 && value.poolId === null),
modelWeightsAuthenticated: false, engineeringDeliveryTested: false, purgeBenefitTested: false,
defaultSelectionChanged: false, connectionConfigChanged: false, credentialValuesReadOrSaved: false };
save('preflight/result.json', result); console.log(JSON.stringify({ passed, requests: result.requests, usage: result.usage, reportedModels: result.reportedModels, stopReason: result.stopReason }));
} catch (error) {
fatal = { name: error.name, message: error.message, stack: error.stack, recordedAt: new Date().toISOString(), automaticReplay: false };
save('preflight/driver-error.json', fatal); process.exitCode = 1;
} finally {
save('preflight/after.json', await publicSnapshot(origin, dataRoot));
save('preflight/inspector-final.json', { closed: await inspectorClosed() });
await close();
}
if (fatal) console.error(fatal.message);
@@ -0,0 +1,5 @@
import fs from 'node:fs';
import path from 'node:path';
export { root, save, sha } from './live-delivery-v-common.mjs';
import { root } from './live-delivery-v-common.mjs';
export const readFileSync = name => fs.readFileSync(path.join(root,name));
@@ -0,0 +1,43 @@
import fs from 'node:fs';
import assert from 'node:assert/strict';
const once = (text, before, after) => { assert.equal(text.split(before).length, 2, before); return text.replace(before, after); };
const names = ['initial','common','payload','inspector','preflight','preflight-audit','node','network','final-audit','capture-artifacts','ownership-proof','final-readback','proof-support','analyze'];
for (const name of names) {
let value = fs.readFileSync('.qa/live-delivery-t-' + name + '.mjs','utf8')
.replaceAll('live-delivery-t','live-delivery-v').replaceAll('__gptTProbeOnce','__gptVProbeOnce')
.replaceAll('1.24.7','1.24.8').replaceAll('T GPT','V GPT').replaceAll('T · ','V · ');
if (['initial','preflight','node','network'].includes(name)) value = once(value,'assert.equal(connection.revision, 7);','assert.equal(connection.revision, 9);');
if (name === 'network') {
value = once(value,'assert.equal(history.jobs.length, 1);','assert.equal(history.jobs.length, 2);');
value = once(value,'assert.equal(job.connectionRevision, 7);','assert.equal(job.connectionRevision, 9);');
value = once(value,"assert.deepEqual(meta('modelNetworkDiagnostics').filter(row => row.id !== jobId), history.jobs);", "const stripDerived = ({ stale, currentConnectionRevision, ...raw }) => raw;\n assert.deepEqual(meta('modelNetworkDiagnostics').filter(row => row.id !== jobId), history.jobs.map(stripDerived));");
}
if (name === 'preflight') value = once(value,"assert.equal(fs.existsSync(path.join(root, 'preflight')), false, 'Never replay or overwrite a real sample.');", "assert.equal(fs.existsSync(path.join(root, 'preflight')), false, 'Never replay or overwrite a real sample.');\nassert.equal(JSON.parse(fs.readFileSync(path.join(root, 'network/restoration.json'))).diagnosticStatus, 'passed');");
if (name === 'final-audit') {
value = once(value,"const preflight = read('preflight/result.json'), nodeExists = fs.existsSync(path.join(root, 'node/result.json'));", "const preflight = fs.existsSync(path.join(root,'preflight/result.json')) ? read('preflight/result.json') : { passed:false, usage:null }, nodeExists = fs.existsSync(path.join(root, 'node/result.json'));");
value = once(value,"const previous = read(nodeExists ? 'node/after.json' : 'preflight/after.json'), before = original.baseline;", "const previous = read(nodeExists ? 'node/after.json' : fs.existsSync(path.join(root,'preflight/after.json')) ? 'preflight/after.json' : 'network/after.json'), before = original.baseline;");
value = once(value,"assert.equal(meta('modelNetworkDiagnostics').length, 2);", "assert.equal(meta('modelNetworkDiagnostics').length, read('network/history-before.json').jobs.length + 1);");
value = once(value,"const owns = [read('preflight/owned.json'), ...(nodeExists ? [read('node/owned.json')] : [])];", "const owns = ['preflight','node'].filter(name => fs.existsSync(path.join(root,name,'owned.json'))).map(name => read(name+'/owned.json'));");
value = once(value,"oldAttempts = read('preflight/original-attempts.json');", "oldAttempts = fs.existsSync(path.join(root,'preflight/original-attempts.json')) ? read('preflight/original-attempts.json') : read('initial-attempts.json');");
value = once(value,"[...read('preflight/attempts.json'), ...(nodeExists ? read('node/attempts.json') : [])]", "[...(fs.existsSync(path.join(root,'preflight/attempts.json')) ? read('preflight/attempts.json') : []), ...(nodeExists ? read('node/attempts.json') : [])]");
value = once(value,"'28d21e75'",'original.sourceCommit');
value = once(value,"for (const row of contract.files) assert.equal(sha(fs.readFileSync(path.join('docs/live-delivery-v-contract', row.path))), row.sha256);", "for (const row of contract.files) {\n assert.equal(sha(fs.readFileSync(path.join('docs/live-delivery-v-contract', row.path))), row.sha256);\n assert.equal(sha(fs.readFileSync(path.join('.qa',path.basename(row.path,'.txt')))),row.sha256);\n }");
}
if (name === 'capture-artifacts') {
value = once(value,"['preflight', 'node'].map(name => read(name + '/owned.json'))", "['preflight', 'node'].filter(name => fs.existsSync(path.join(root,name,'owned.json'))).map(name => read(name + '/owned.json'))");
value = once(value,'assert.ok(artifacts.length > 0);','assert.ok(artifacts.length >= 0);');
}
if (name === 'analyze') {
value = once(value,"const originalResponse = fs.readFileSync(path.join(root, response.path));", "const originalResponse = response ? fs.readFileSync(path.join(root, response.path)) : null;");
value = once(value,'assert.equal(sha(originalRequest), attempt.requestSha256); assert.equal(sha(originalResponse), attempt.responseSha256);', 'assert.equal(sha(originalRequest), attempt.requestSha256); if(originalResponse) assert.equal(sha(originalResponse), attempt.responseSha256);');
value = once(value,'const body = JSON.parse(originalRequest), raw = JSON.parse(originalResponse);', 'const body = JSON.parse(originalRequest); let raw=null; try { raw=JSON.parse(originalResponse); } catch {}');
value = once(value,'assert.deepEqual(raw.usage, attempt.usage);', 'if(raw?.usage) assert.deepEqual(raw.usage, attempt.usage);');
value = once(value,'responseBytes: originalResponse.length','responseBytes: originalResponse?.length ?? 0');
value = once(value,'usage: raw.usage, identity: attempt.modelIdentity, responseMessage: raw.choices[0].message,','usage: raw?.usage ?? attempt.usage, identity: attempt.modelIdentity, responseMessage: raw?.choices?.[0]?.message ?? null,');
value = once(value,'finishReason: raw.choices[0].finish_reason','finishReason: raw?.choices?.[0]?.finish_reason ?? null');
value = once(value,"sourceAndGitUnchanged: read('node/git-final.json').diff === '',", "allowedWorkingTreeDiffEmpty: read('node/git-final.json').diff === '',\n originalAndFinalHeadEqual: read('node/source-identity.json').head === read('node/git-final.json').head,");
value = value.slice(0,value.indexOf('console.log(JSON.stringify(')) + "console.log(JSON.stringify({requests:requests.length,nodeSucceeded:node.success,stopReason:node.stopReason,modelRequests:0}));\n";
}
fs.writeFileSync('.qa/live-delivery-v-'+name+'.mjs',value,{flag:'wx'});
}
console.log(JSON.stringify({prepared:names,modelRequests:0,previousDriversUnchanged:true}));
@@ -0,0 +1,9 @@
{
"name": "owned-live-expense-report",
"private": true,
"type": "module",
"scripts": {
"test": "node --test test/expense.test.mjs",
"build": "node scripts/build.mjs"
}
}
@@ -0,0 +1,8 @@
import { spawnSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
for (const file of ['src/amount.mjs','src/summary.mjs','src/report.mjs']) {
const result=spawnSync(process.execPath,['--check',file],{encoding:'utf8'});
if(result.status!==0) { process.stderr.write(result.stderr);process.exit(result.status??1); }
if(!readFileSync(file,'utf8').trim()) throw new Error('Empty business module');
}
console.log('All three business modules compile.');
@@ -0,0 +1 @@
export function amountToCents(value) { return 0; }
@@ -0,0 +1 @@
export function formatReport(groups) { return ''; }
@@ -0,0 +1,2 @@
import { amountToCents } from './amount.mjs';
export function summarize(rows) { return []; }
@@ -0,0 +1,37 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { amountToCents } from '../src/amount.mjs';
import { summarize } from '../src/summary.mjs';
import { formatReport } from '../src/report.mjs';
test('decimal strings become exact cents including zero and refunds',()=>{
for(const [input,expected] of [['0',0],[' 12.34 ',1234],['+2.5',250],['-1.05',-105],['-0.00',0],['0009.10',910]]) assert.equal(amountToCents(input),expected);
});
test('finite decimal numbers use the same cents contract',()=>{
for(const [input,expected] of [[0,0],[1.01,101],[2.5,250],[-4.32,-432]]) assert.equal(amountToCents(input),expected);
});
test('malformed overprecision nonfinite and unsafe amounts are rejected',()=>{
for(const input of ['',null,undefined,true,{},'1e2','1,000','.50','1.234',1.234,NaN,Infinity,'900719925474099.99']) assert.throws(()=>amountToCents(input),TypeError,String(input));
});
test('independent currencies are sorted and summed without floating point loss',()=>{
assert.deepEqual(summarize([{currency:'usd',amount:'0.10'},{currency:' CNY ',amount:3},{currency:'USD',amount:'0.20'}]),[
{currency:'CNY',cents:300,count:1},{currency:'USD',cents:30,count:2}]);
});
test('refunds cancel totals while counting every original record',()=>{
assert.deepEqual(summarize([{currency:'eur',amount:'1.20'},{currency:'EUR',amount:'-1.20'}]),[{currency:'EUR',cents:0,count:2}]);
});
test('summarizing retains caller rows and handles an empty list',()=>{
const rows=Object.freeze([Object.freeze({currency:'usd',amount:'2.00'})]);
assert.deepEqual(summarize(rows),[{currency:'USD',cents:200,count:1}]);assert.deepEqual(summarize([]),[]);
});
test('invalid rows currency and unsafe aggregate totals are rejected',()=>{
for(const rows of [null,{},[null],[{currency:'US',amount:'1'}],[{currency:'U1D',amount:'1'}],[{currency:'USD',amount:'1.234'}],
[{currency:'USD',amount:'90071992547409.91'},{currency:'USD',amount:'0.01'}]]) assert.throws(()=>summarize(rows),TypeError);
});
test('reports use two decimals and render negative subunit amounts',()=>{
assert.equal(formatReport([{currency:'CNY',cents:300,count:2},{currency:'USD',cents:-105,count:1}]),'CNY 3.00 (2)\nUSD -1.05 (1)');
assert.equal(formatReport([{currency:'EUR',cents:-5,count:1}]),'EUR -0.05 (1)');assert.equal(formatReport([]),'');
});
test('complete expense flow preserves exact decimal sums',()=>{
assert.equal(formatReport(summarize([{currency:'usd',amount:'0.29'},{currency:'USD',amount:'-0.30'},{currency:'CNY',amount:'10.50'}])),
'CNY 10.50 (1)\nUSD -0.01 (2)');
});
+251
View File
@@ -0,0 +1,251 @@
{
"schemaVersion": 1,
"kind": "bounded-live-delivery-v-contract",
"frozenAt": "2026-11-04T00:54:10.821Z",
"sourceBaseCommit": "13849d038ff6cf55074697b823c83b980bc7229f",
"branch": "feat/live-delivery-v",
"planSha256": "411b4c1b7077e40010b7c92a5210bd2569def52741d4d3b8e859bf41ac09f4a0",
"originalBaselineSha256": "8f19c55d570f783bcd5a79917137a180acbc0bb1bcd34bb661c916cfa741b78e",
"releaseVersion": "1.24.8",
"releaseSourceCommit": "7e77fd65c367b711a9a59b30ef216f5fdf7feb11",
"releaseIdentitySha256": "68e52ab9d6002cd59fef12abf60be9e10e2863e3c9015be4dd1b820cf714df85",
"host": {
"pid": 36552,
"runtimeRoot": "C:\\Users\\wangy\\AppData\\Local\\Programs\\AgentWorkbench\\versions\\Agent-Workbench-1.24.8-win-x64-20261103235313371",
"runtimeIdentity": "6f4b7681e8393fe0c7b7441264b806662741f59c7dc818f2632ad7ceb6e67c99"
},
"originalProjects": 65,
"originalSessions": 81,
"originalArtifacts": 3720,
"originalAttemptsRow": {
"id": "modelAttempts",
"sha256": "506fd2e9553ef0b2f854c411100977615eeba02ef3aad1ceb5d18761d9576007"
},
"originalDiagnosticsRow": {
"id": "modelNetworkDiagnostics",
"sha256": "798d612f52e4234b8eb7250baa9d0d6f5853c2b76ea0543510fb183c2473498f"
},
"inputs": [
{
"path": "src/amount.mjs",
"capturedPath": "inputs/src/amount.mjs",
"bytes": 51,
"sha256": "84cb647328ec52dad27d288f3a6127ff3e1ad87274ae2d227ad44daa49cbb2ed"
},
{
"path": "src/summary.mjs",
"capturedPath": "inputs/src/summary.mjs",
"bytes": 93,
"sha256": "48829850c11ca0cd0ab5e86bbac69a0c5f90297292168c1ba6dc338e2eae6ee7"
},
{
"path": "src/report.mjs",
"capturedPath": "inputs/src/report.mjs",
"bytes": 52,
"sha256": "ba0a014e6e9df710d66e255a3a6f970f4e1c8af48accc81f33627029dcded7c0"
},
{
"path": "test/expense.test.mjs",
"capturedPath": "inputs/test/expense.test.mjs",
"bytes": 2584,
"sha256": "0bcda551dbaeafad9a6e3df8024492ab67d7c09956f4676c393b78249ab44839"
},
{
"path": "package.json",
"capturedPath": "inputs/package.json",
"bytes": 188,
"sha256": "6ad63026b2fe9de7513a4f6704c372a86108ee3d018a1f04883dc0a409ea4c24"
},
{
"path": "scripts/build.mjs",
"capturedPath": "inputs/scripts/build.mjs",
"bytes": 475,
"sha256": "7279bc7c707c0f3ccbae63b14f0abed248ad3755be14f9e37128124ae9267526"
}
],
"originalElevenFileHashes": {
"README.md": "5e35a4dace9537e7c4cc815ce7054f73c171f053f1cccb9ff141f49ecb3c013e",
".gitignore": "cab0bc87cad1b1214d71b023eee742986044093ff4b4331cd6a51098af6bdce6",
"package.json": "6ad63026b2fe9de7513a4f6704c372a86108ee3d018a1f04883dc0a409ea4c24",
"test/expense.test.mjs": "0bcda551dbaeafad9a6e3df8024492ab67d7c09956f4676c393b78249ab44839",
"scripts/build.mjs": "7279bc7c707c0f3ccbae63b14f0abed248ad3755be14f9e37128124ae9267526",
"owner-staged.txt": "56b0dda452eaf9aead80f0e4ad971d7befa3cf152c3553923f8fde46e1fd336a",
"owner-unstaged.txt": "468bfb2956a4ac040508fc5ffd915cf8057fb7420e22c41a3cc2d094785f0d3e",
"owner-untracked.txt": "e32ab29a12ed13d72c2ed603b2360e1b4e35afb0fe4280db2e523ad2c6c5bc8d",
"src/amount.mjs": "84cb647328ec52dad27d288f3a6127ff3e1ad87274ae2d227ad44daa49cbb2ed",
"src/summary.mjs": "48829850c11ca0cd0ab5e86bbac69a0c5f90297292168c1ba6dc338e2eae6ee7",
"src/report.mjs": "ba0a014e6e9df710d66e255a3a6f970f4e1c8af48accc81f33627029dcded7c0"
},
"goalDeclarationSha256": "f0023b525c63e0a4287f8ee692516e6353a91c207cca6a307a7a3e34fa4160f9",
"goalMatchesTExactly": true,
"dependencySources": [
{
"path": "src/core/git-process.mjs",
"sha256": "80547ec8928610ac4df5a05c5aef12d1aab0dca9e7b1def2773fc745f5adf5f5"
},
{
"path": "src/core/desktop/install-manager.mjs",
"sha256": "91c216537666f690122071a5b53b7c8b3beba4ea549acd1534edca24390d9635"
},
{
"path": "benchmarks/live-delivery-v1/node/src/amount.mjs",
"sha256": "84cb647328ec52dad27d288f3a6127ff3e1ad87274ae2d227ad44daa49cbb2ed"
},
{
"path": "benchmarks/live-delivery-v1/node/src/summary.mjs",
"sha256": "48829850c11ca0cd0ab5e86bbac69a0c5f90297292168c1ba6dc338e2eae6ee7"
},
{
"path": "benchmarks/live-delivery-v1/node/src/report.mjs",
"sha256": "ba0a014e6e9df710d66e255a3a6f970f4e1c8af48accc81f33627029dcded7c0"
},
{
"path": "benchmarks/live-delivery-v1/node/test/expense.test.mjs",
"sha256": "0bcda551dbaeafad9a6e3df8024492ab67d7c09956f4676c393b78249ab44839"
},
{
"path": "benchmarks/live-delivery-v1/node/package.json",
"sha256": "6ad63026b2fe9de7513a4f6704c372a86108ee3d018a1f04883dc0a409ea4c24"
},
{
"path": "benchmarks/live-delivery-v1/node/scripts/build.mjs",
"sha256": "7279bc7c707c0f3ccbae63b14f0abed248ad3755be14f9e37128124ae9267526"
}
],
"previousDriverHashes": [
{
"path": ".qa/live-delivery-t-initial.mjs",
"sha256": "70984fcb8f9bb4a839e5acaa44d8fd7712bf7173cb0e8974ea361e89be62b929"
},
{
"path": ".qa/live-delivery-t-common.mjs",
"sha256": "f9690cb76eae4970494aee53d6ccaa2997dcaead1705f3bbd393ca844a1a31e5"
},
{
"path": ".qa/live-delivery-t-payload.mjs",
"sha256": "170dd3becc13c6e8b9b2293035a4e142fac43a4cb5572dee85fd7644c674fb04"
},
{
"path": ".qa/live-delivery-t-inspector.mjs",
"sha256": "69150611edc2829406ce98cd6968fbb24ca97d282d22ce8e500d8d92fb3ee580"
},
{
"path": ".qa/live-delivery-t-preflight.mjs",
"sha256": "fa9c26f591e392015a936c80df329ab7a1a9a8dedc96f76eb1bb172cf36f4eb9"
},
{
"path": ".qa/live-delivery-t-preflight-audit.mjs",
"sha256": "6f3bab7a6347578050f9c894702994d495cd1b2d169e0734477618d0af97b61e"
},
{
"path": ".qa/live-delivery-t-node.mjs",
"sha256": "2313c704c68e3d95b090ec8d73184a9978b19eb87a772efe92f1154b04deeede"
},
{
"path": ".qa/live-delivery-t-network.mjs",
"sha256": "7ba233460aca2f58f9072ee8be57a2ab2aa5dbf7a0550af6c35864779d96d5c6"
}
],
"maxNetworkJobs": 1,
"maxPreflightRequests": 1,
"maxNodeRequests": 8,
"maxNodeTokens": 90000,
"maxNodeDurationMs": 600000,
"contextLimit": 16000,
"maxOutputTokens": 2048,
"safetyReserveTokens": 1600,
"modelRequestsAtFreeze": 0,
"noKeyValuesReadOrSaved": true,
"files": [
{
"path": "drivers/desktop-f-state.mjs.txt",
"bytes": 5932,
"sha256": "6cf41ebd2ce55fe6fe3175948e9b964fac99975aca3132420a83b1d122e08b0b"
},
{
"path": "drivers/freeze-live-delivery-v.mjs.txt",
"bytes": 4765,
"sha256": "2f54f6abda610ef2f7e7de28c1245a327163ab7d87ad10f8322ad093f8ffec2a"
},
{
"path": "drivers/live-delivery-v-analyze.mjs.txt",
"bytes": 3063,
"sha256": "ffd4e9d267e935bb0f323e8fc3a78b8025e6c5fd38cefb375afbd03b022d94af"
},
{
"path": "drivers/live-delivery-v-capture-artifacts.mjs.txt",
"bytes": 2167,
"sha256": "04b1b3e8529b96844d02fedbfb4db8354d7c98651e7a1664918520c49a4148f9"
},
{
"path": "drivers/live-delivery-v-common.mjs.txt",
"bytes": 3084,
"sha256": "b510c56073df9ca51e33445b8f669a128f7f22c7545fe45b5c1752cde3f971bf"
},
{
"path": "drivers/live-delivery-v-context-proof.mjs.txt",
"bytes": 9203,
"sha256": "c42d34913cb0af9d7ad77b5840ada3f7e4b26bff0369f49137c82c2e4f3969c0"
},
{
"path": "drivers/live-delivery-v-final-audit.mjs.txt",
"bytes": 10442,
"sha256": "1aad6f7d744aa6e1c6c76d047467b9baaa23b7c68941623f92af256c51e4fefa"
},
{
"path": "drivers/live-delivery-v-final-readback.mjs.txt",
"bytes": 1316,
"sha256": "20530203eb849f1e987c0ad809d0f52477fd9d931e05170e97db90aaebe639bc"
},
{
"path": "drivers/live-delivery-v-initial.mjs.txt",
"bytes": 2535,
"sha256": "6197a5119af2350a29ab0d852719582a30081a825f2f306f5ad2c99c79cb6005"
},
{
"path": "drivers/live-delivery-v-inspector.mjs.txt",
"bytes": 3329,
"sha256": "68b13fd25297d4713871b7c1f56bf22a9a5763a021645ba42b89168e61a3e1b1"
},
{
"path": "drivers/live-delivery-v-network.mjs.txt",
"bytes": 5022,
"sha256": "bda66b8e0d59d34855686abbe4164480a1e8d69ab24ef93326124cec12bfbecb"
},
{
"path": "drivers/live-delivery-v-node.mjs.txt",
"bytes": 24201,
"sha256": "934ff55823939c65d8578fb08ea2510dce4a46ec730e96a470a73120c43b61b0"
},
{
"path": "drivers/live-delivery-v-ownership-proof.mjs.txt",
"bytes": 3063,
"sha256": "0a889ad6152dedc1b424ede9861e72ed705ae8fa532c2ea5644f7dd8eb714c23"
},
{
"path": "drivers/live-delivery-v-payload.mjs.txt",
"bytes": 7367,
"sha256": "9b80607d500d1bf24619822b6df8daffa5de9e4edf22307186d7045ffb45cae5"
},
{
"path": "drivers/live-delivery-v-preflight-audit.mjs.txt",
"bytes": 3090,
"sha256": "59f044416895a1e7a8383c1e9233ff65e8e8f84d51dfcb1f9bc0cc1f57eef961"
},
{
"path": "drivers/live-delivery-v-preflight.mjs.txt",
"bytes": 6267,
"sha256": "b1c01ec5c1a69658e63ed781a77922aed08e77e432e970d19e7711b07ea82764"
},
{
"path": "drivers/live-delivery-v-proof-support.mjs.txt",
"bytes": 248,
"sha256": "ee614752d80e413940390efb34a77f99a97b97b07f8b65e1a420088ad94a9210"
},
{
"path": "drivers/prepare-live-delivery-v.mjs.txt",
"bytes": 6327,
"sha256": "2d27febbbcc4c22b1196abeb6dc3b3799bfe8e141f73da4e62a7a3fb6f0aed0d"
}
]
}
+7
View File
@@ -1,5 +1,10 @@
# 汇总发现
## V:新的真实模型验收进行中
已创建 feat/live-delivery-v,正式仍1.24.8/source7e77fd65/原PID36552/Provider。先冻结公开基线、当前驱动与原11文件/原目标,再一次所属诊断、单次无工具身份预检,通过后新Node。16K/2048/1600、8请求/90000tokens/600000ms不变。原T/R/P/O不续跑,不提供实现/附加指导,不提取/复制/解密/重存Key,不委派、不推送。当前尚未发真实模型请求;调用前契约和本地Git待完成。
## U最终交付与回顾
U已本地交付1.24.8/source7e77fd65/候选20261103235313371:同SHA/原范围页聚合、完整小源码/最新纯读组保留、修改前当前检查事实与routine/latest去重完成。114相关、569输入独立重建22/22、三归档/便携、12实际安装和安装副本16+9文件流程,以及源码/便携/安装三载荷各7请求工作记忆夹具通过。正式原PID36552/Provider、65项目81会话6377记录13484事件及outbox/3720工件、全部原表行/导出/工件和公开模型中心在网页/原生回看后再次精确保持,9229关闭。本轮真实请求0,原T九测试仍失败,未证明真实交付或Purge收益。证据620份/100126636字节,见docs/QA-WORKING-MEMORY-U.md、docs/RETROSPECTIVE-WORKING-MEMORY-U.md及docs/working-memory-u-release-identity.json。下一另冻docs/LIVE-DELIVERY-V-PLAN.md的新诊断/单次预检/Node,不续跑T/R/P/O;Node后才React/Python/Purge。1.25/更新重复核验性能仍单列。不委派、不提取/复制/解密/重存Key、不推送。
@@ -1143,3 +1148,5 @@ M最终实证:1.24.4正式保持原宿主完成本地升级;Messages原生
Q验收复核:测试必须等待新修订的结果,不能只等待“通过”字样,以免误认旧历史;最终新UI会等待修订2/active=0后封图。实际390px三路径表/历史可操作,无页面溢出;正式基线61项目77会话不新增模型尝试。原生首次未激活截图显示遮挡内容,只用于定位,不封存为正式工作台画面;前置后实际窗口已核对。
Q发行复核:源码ZIP独立560输入/22编译完全一致,555跟踪输入之外5份原示例dist经ZIP自身脚本独立重建逐SHA匹配;三载荷新界面各9组、三归档/便携、12实际安装和16+9文件操作通过。正式原生入口首launch窗口未及时返回,随后只读清单发现实际1.24.6,未重复启动。回看后全部原状态再次一致。677755ms操作历史明确出现重复full-manifest与directory-inventory,应单列优化,不移除核验。438份/89228582字节原材料离线通过。
V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。
+7
View File
@@ -1,5 +1,10 @@
# 统一执行进度
## V:新的真实模型验收进行中
已创建 feat/live-delivery-v,正式仍1.24.8/source7e77fd65/原PID36552/Provider。先冻结公开基线、当前驱动与原11文件/原目标,再一次所属诊断、单次无工具身份预检,通过后新Node。16K/2048/1600、8请求/90000tokens/600000ms不变。原T/R/P/O不续跑,不提供实现/附加指导,不提取/复制/解密/重存Key,不委派、不推送。当前尚未发真实模型请求;调用前契约和本地Git待完成。
## U最终交付与回顾
U已本地交付1.24.8/source7e77fd65/候选20261103235313371:同SHA/原范围页聚合、完整小源码/最新纯读组保留、修改前当前检查事实与routine/latest去重完成。114相关、569输入独立重建22/22、三归档/便携、12实际安装和安装副本16+9文件流程,以及源码/便携/安装三载荷各7请求工作记忆夹具通过。正式原PID36552/Provider、65项目81会话6377记录13484事件及outbox/3720工件、全部原表行/导出/工件和公开模型中心在网页/原生回看后再次精确保持,9229关闭。本轮真实请求0,原T九测试仍失败,未证明真实交付或Purge收益。证据620份/100126636字节,见docs/QA-WORKING-MEMORY-U.md、docs/RETROSPECTIVE-WORKING-MEMORY-U.md及docs/working-memory-u-release-identity.json。下一另冻docs/LIVE-DELIVERY-V-PLAN.md的新诊断/单次预检/Node,不续跑T/R/P/O;Node后才React/Python/Purge。1.25/更新重复核验性能仍单列。不委派、不提取/复制/解密/重存Key、不推送。
@@ -1694,3 +1699,5 @@ M最终发行与预检收尾:d62d03f9/20261103112054864的源码ZIP549输入
首封存从源码目录读不存在的编译产物而拒绝,保留首脚本/日志和部分输出;改从已验不可变便携读取22输出且逐项SHA仍等于冻结,未重建发行或重发预检。最终745份/54940236字节证据离线通过,manifest c35590ff7879807e9302dc25ab24bf246b97396c9c78167e981c222db722e4c7。报告与后续计划已记录;最终Git只封存本轮文档/证据/离线验证器与字节属性,不推送。
M最终Git索引核对:证据及manifest共746份/55074620字节,实际暂存blob逐项长度与SHA256全部一致。首cached diff发现原CRLF收据和供应商HTML尾空格,保留全部捕获字节,只补本轮证据属性;不把原字节格式当产品错误,也不改已安装包。
V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。
+5
View File
@@ -1,5 +1,10 @@
# Agent Workbench:核心代理能力研究与产品计划
## V:新的真实模型验收进行中
已创建 feat/live-delivery-v,正式仍1.24.8/source7e77fd65/原PID36552/Provider。先冻结公开基线、当前驱动与原11文件/原目标,再一次所属诊断、单次无工具身份预检,通过后新Node。16K/2048/1600、8请求/90000tokens/600000ms不变。原T/R/P/O不续跑,不提供实现/附加指导,不提取/复制/解密/重存Key,不委派、不推送。当前尚未发真实模型请求;调用前契约和本地Git待完成。
## U最终交付与回顾
U已本地交付1.24.8/source7e77fd65/候选20261103235313371:同SHA/原范围页聚合、完整小源码/最新纯读组保留、修改前当前检查事实与routine/latest去重完成。114相关、569输入独立重建22/22、三归档/便携、12实际安装和安装副本16+9文件流程,以及源码/便携/安装三载荷各7请求工作记忆夹具通过。正式原PID36552/Provider、65项目81会话6377记录13484事件及outbox/3720工件、全部原表行/导出/工件和公开模型中心在网页/原生回看后再次精确保持,9229关闭。本轮真实请求0,原T九测试仍失败,未证明真实交付或Purge收益。证据620份/100126636字节,见docs/QA-WORKING-MEMORY-U.md、docs/RETROSPECTIVE-WORKING-MEMORY-U.md及docs/working-memory-u-release-identity.json。下一另冻docs/LIVE-DELIVERY-V-PLAN.md的新诊断/单次预检/Node,不续跑T/R/P/O;Node后才React/Python/Purge。1.25/更新重复核验性能仍单列。不委派、不提取/复制/解密/重存Key、不推送。