test: freeze host-authoritative original Purge validation

This commit is contained in:
Agent Workbench Dev
2026-11-06 13:53:53 +08:00
parent 01e64f3fcf
commit a6830bbf50
16 changed files with 256 additions and 15 deletions
+16 -8
View File
@@ -12,7 +12,8 @@ import { resolveControlledInstallation } from '../../src/core/engines/controlled
import { resolveOriginalPurgeSource } from '../../src/core/engines/purge-strategy.mjs';
import { allowed } from './contract.mjs';
const output = path.resolve('.qa/af-driver-' + randomUUID()), disposers = [], t = { after: fn => disposers.push(fn) };
const batch = process.argv.includes('--batch=ag') ? 'ag' : 'af';
const output = path.resolve('.qa/' + batch + '-driver-' + randomUUID()), disposers = [], t = { after: fn => disposers.push(fn) };
fs.mkdirSync(output); const f = fixture(t, { modernDefaults: true });
f.store.saveConfig({ approvalMode: 'full', mode: 'compatible' });
// Model the existing production metadata shape before freezing this fresh fixture.
@@ -37,17 +38,23 @@ try {
assert.ok(requests <= 16); console.log(JSON.stringify({ fixtureRequest: requests, step }));
return { ...completion(calls, calls.length ? '' : 'Owned fixture done.'), model: body.model };
});
const host = await launchWorkbench(t, f.data), originalCenter = await host.api('/model-center');
const hostNode = batch === 'ag' ? JSON.parse(fs.readFileSync('.qa/live-purge-af/host-availability.json')).installation.node.path : process.execPath;
const host = await launchWorkbench(t, f.data, {}, { nodePath: hostNode }), originalCenter = await host.api('/model-center');
const connection = await host.api('/model-center/connections', { name: 'Owned AF local fixture', brand: 'Owned fixture', model: 'owned-af', protocol: 'chat-completions',
baseUrl: model.baseUrl, apiKey: 'owned-local-fixture-only', streaming: false, nativeParameters: {} });
const boot = await host.api('/bootstrap'), center = await host.api('/model-center'), health = await host.api('/host/status');
configurePurgeFixture({ root: output, origin: host.url });
const installation = resolveControlledInstallation(process.cwd()), source = resolveOriginalPurgeSource(process.cwd(), undefined, installation);
const localInstallation = resolveControlledInstallation(process.cwd());
const installation = batch === 'ag' ? await host.api('/engines/deepseek/controlled-availability?root=' + encodeURIComponent(localInstallation.root)) : localInstallation;
const source = batch === 'ag' ? await host.api('/engines/purge/source?kind=purge-original-restricted-v1&harnessRoot=' + encodeURIComponent(installation.root))
: resolveOriginalPurgeSource(process.cwd(), undefined, installation);
if (batch === 'ag') { assert.notEqual(installation.node.path, localInstallation.node.path); assert.equal(installation.node.sha256, localInstallation.node.sha256); }
save('current.json', { host: health, config: boot.config, center, connection, originalProjects: boot.projects,
originalPublicMetadata: publicMetadata(f.data), baseline: await publicSnapshot(host.url, f.data), installation, source, fixture: true });
await import('./run.mjs'); const batch = JSON.parse(fs.readFileSync(path.join(output, 'result.json')));
assert.equal(batch.success, true, JSON.stringify(batch.samples.map(row => ({ sample: row.sample, failure: row.failure, cleanupErrors: row.cleanupErrors }))));
assert.equal(requests, 16); assert.equal(batch.samples.length, 4); assert.ok(batch.samples.every(row => row.final.test.stats.pass === 9));
originalPublicMetadata: publicMetadata(f.data), baseline: await publicSnapshot(host.url, f.data), installation, source, fixture: true,
batch, ...(batch === 'ag' ? { availabilityAuthority: 'host-api', localInstallation } : {}) });
await import('./run.mjs'); const batchResult = JSON.parse(fs.readFileSync(path.join(output, 'result.json')));
assert.equal(batchResult.success, true, JSON.stringify(batchResult.samples.map(row => ({ sample: row.sample, failure: row.failure, cleanupErrors: row.cleanupErrors }))));
assert.equal(requests, 16); assert.equal(batchResult.samples.length, 4); assert.ok(batchResult.samples.every(row => row.final.test.stats.pass === 9));
await import('./finish.mjs');
const audits = fs.readdirSync(path.join(output, 'audits')); assert.equal(audits.length, 1);
const auditPath = 'audits/' + audits[0] + '/result.json';
@@ -56,7 +63,8 @@ try {
try { await import('./seal.mjs'); } finally { process.argv[2] = oldArgument; }
const after = await host.api('/model-center'); assert.deepEqual(after.selected, originalCenter.selected);
result = { success: true, realModelRequests: 0, fixedHttpRequests: requests, actualBatchDriverExecuted: true,
originalTestsPerSample: 9, completeSamples: 4, originalStateAuditPassed: true, implementationSuppliedToLocalFixtureOnly: true };
originalTestsPerSample: 9, completeSamples: 4, originalStateAuditPassed: true, implementationSuppliedToLocalFixtureOnly: true,
distinctHostExecutablePathVerified: batch === 'ag', availabilityAuthority: batch === 'ag' ? 'host-api' : 'source' };
} catch (error) { result = { success: false, error: error.stack, realModelRequests: 0 }; process.exitCode = 1; }
finally { for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync(path.join(output, 'driver-result.json'), JSON.stringify(result, null, 2)); }
console.log(JSON.stringify({ output, ...result }));