Files
Agent-Workbench/scripts/live-y/verify.mjs
T
2026-11-04 23:22:40 +08:00

44 lines
2.7 KiB
JavaScript

// Offline only: validates sealed bytes and the reported outcome without
// contacting the host or executing the model, project checks, or Git delivery.
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
const root = path.resolve('.qa/live-delivery-y');
const read = name => JSON.parse(fs.readFileSync(path.join(root, name)));
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
const manifest = read('MANIFEST.json');
for (const row of manifest.files) {
const file = path.resolve(root, row.path);
assert.ok(file.startsWith(root + path.sep));
const bytes = fs.readFileSync(file);
assert.equal(bytes.length, row.bytes, row.path);
assert.equal(hash(bytes), row.sha256, row.path);
}
const preflight = read('preflight/result.json'), result = read('node/model-outcome.json');
assert.equal(preflight.passed, true); assert.equal(preflight.requests, 1);
assert.equal(preflight.usage.total_tokens, 110);
assert.equal(result.success, false); assert.equal(result.stopReason, 'step_limit');
assert.equal(result.usage.requests, 8); assert.equal(result.usage.totalTokens, 64500);
assert.equal(result.usage.unknownRequests, 0); assert.equal(result.identitiesValid, true);
assert.equal(result.applications.length, 1);
assert.equal(fs.existsSync(path.join(root, 'node/result.json')), false);
assert.equal(fs.existsSync(path.join(root, 'node/restoration.json')), false);
for (const capture of [...preflight.captures, ...result.captures]) {
const bytes = fs.readFileSync(path.join(root, capture.path));
assert.equal(bytes.length, capture.bytes); assert.equal(hash(bytes), capture.sha256);
}
const state = read('node/session.json');
assert.equal(state.execution.deliveries.length, 0);
assert.equal(state.execution.checks.length, 1);
assert.equal(state.execution.checks[0].results.find(value => value.name === 'test').tests.failed, 9);
assert.equal(state.execution.changeSets[0].status, 'completed');
assert.equal(read('node/reconciliation.json').passed, true);
assert.equal(hash(fs.readFileSync(path.join(root, 'node/goal.txt'))), 'b5421d0bb502126f49a5153729027f13ef82db86ab19a9e5b0c23a49070bb905');
const sourceText = fs.readFileSync(path.join(root, 'driver-source/node.mjs'), 'utf8');
const sourceGoal = sourceText.slice(sourceText.indexOf(' const goal = '), sourceText.indexOf(" save('node/goal.txt'"));
assert.equal(hash(sourceGoal), 'ea3eaee0a94112085b6e41f528397f32fb2640a963a40add9bd3549b9eb642e0');
console.log(JSON.stringify({ passed: true, files: manifest.files.length, bytes: manifest.totalBytes,
requests: 9, reportedTokens: 64610, engineeringSuccess: false, originalFinalizationFailed: true,
readOnlyReconciliationPassed: true, modelRequestsExecutedByVerifier: 0 }));