release: install verified Purge repair build and seal original state

This commit is contained in:
Agent Workbench Dev
2026-11-03 00:15:31 +08:00
parent c03860da74
commit 876df5f421
86 changed files with 482093 additions and 9 deletions
+9 -3
View File
@@ -92,10 +92,16 @@ try {
const connectionId = connection.id ?? connection.connection?.id ?? connection.center?.connections.at(-1).id;
assert.ok(connectionId); await controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId } }); assert.equal(authenticated, 1);
stage = 'actual update rejects a pending owned model request'; hold = true;
const pending = controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId }, timeoutMs: 60000 }); pending.catch(() => {});
// Manifest verification is synchronous and can occupy this fixture's event
// loop. Keep the explicitly held local response pending across that work;
// this is the QA client's deadline, not a product/model timeout override.
const pendingStarted = Date.now();
const pending = controller.api('/model-center/probe', { method: 'POST', input: { id: connectionId }, timeoutMs: 300000 }); pending.catch(() => {});
await until(() => heldRequest); await assert.rejects(ownedManager(null).preflight(), /任务|请求/);
assert.equal((await controller.connect()).identity.pid, original.pid); record(stage, { fixture: 'Actual pending owned HTTP request; manager preflight rejects before the product 20-second request timeout.' });
releaseRequest?.(); hold = false; await pending;
assert.equal((await controller.connect()).identity.pid, original.pid);
assert.equal(authenticated, 2, 'Exactly the initial and explicitly held owned requests; no retry.');
record(stage, { fixture: 'Actual owned HTTP response held until full manifest/preflight and original PID verification settle. No configured-model call or product timeout change.', elapsedMs: Date.now() - pendingStarted });
releaseRequest?.(); hold = false; assert.equal((await pending).ok, true);
stage = 'actual installer rejects a persistent original task approval';
const projectRoot = path.join(root, 'approval-project'); fs.mkdirSync(projectRoot); fs.writeFileSync(path.join(projectRoot, 'README.md'), '# Owned installer approval project\n');
const project = await controller.api('/projects', { method: 'POST', input: { root: projectRoot } }), session = await controller.api('/sessions', { method: 'POST', input: { projectId: project.id } });
@@ -0,0 +1,89 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
// Offline verification only: no Provider, desktop input, plugin or network.
const root = path.resolve('docs/original-purge-release-f-evidence');
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
function raw(relative) {
const file = path.resolve(root, relative);
assert.ok(file.startsWith(root + path.sep), 'Evidence stays within the sealed directory.');
return fs.readFileSync(file);
}
const read = relative => JSON.parse(raw(relative));
const manifest = read('manifest.json');
assert.equal(manifest.schemaVersion, 1); assert.equal(manifest.slice, 'original-purge-local-release-f');
assert.equal(manifest.version, '1.24.0'); assert.equal(manifest.realModelRequests, 0);
const names = new Set(), files = new Map();
for (const entry of manifest.entries) {
assert.equal(names.has(entry.name), false); names.add(entry.name);
const bytes = raw(entry.file); assert.equal(bytes.length, entry.bytes, entry.name); assert.equal(sha(bytes), entry.sha256, entry.name);
if (files.has(entry.file)) assert.equal(files.get(entry.file), entry.sha256);
files.set(entry.file, entry.sha256);
}
assert.equal(files.size, manifest.count);
assert.equal([...files.keys()].reduce((sum, file) => sum + raw(file).length, 0), manifest.bytes);
assert.equal(sha(fs.readFileSync(manifest.dManifest)), manifest.dManifestSha256);
assert.equal(sha(fs.readFileSync(manifest.eManifest)), manifest.eManifestSha256);
const d = JSON.parse(fs.readFileSync(manifest.dManifest)), e = JSON.parse(fs.readFileSync(manifest.eManifest));
assert.equal(e.requests, 52); assert.equal(e.reportedTokens, 621486); assert.equal(e.unknownRequests, 0);
assert.deepEqual(manifest.sourceInputs, d.sourceInputs.map(({ path, bytes, sha256 }) => ({ path, bytes, sha256 })));
const selected = key => read(manifest.selected[key]);
const release = selected('release.json'), preflight = selected('preflight.json');
assert.equal(release.documentation.sourceCommit, manifest.sourceCommit);
assert.equal(path.basename(release.portableRoot), manifest.candidate); assert.equal(preflight.success, true);
const rebuilt = selected('rebuild');
assert.equal(rebuilt.success, true); assert.equal(rebuilt.sourceZip.sha256, release.source.sha256);
assert.equal(rebuilt.sourceCommit, manifest.sourceCommit); assert.equal(rebuilt.compiled.length, 22); assert.deepEqual(rebuilt.mismatches, []);
assert.equal(rebuilt.realModelRequests, 0);
const portableManifest = selected('portableManifest'), portableFiles = new Map(portableManifest.files.map(file => [file.path, file]));
const changed = [];
for (const item of manifest.lineage) {
const old = d.buildInputs.find(old => old.path === item.path); assert.ok(old, item.path);
assert.deepEqual(item.originalD, { bytes: old.bytes, sha256: old.sha256 });
const portable = portableFiles.get(item.path); assert.ok(portable);
const built = rebuilt.compiled.find(file => file.path === item.path); assert.ok(built);
assert.deepEqual(built.expected, built.actual);
assert.deepEqual(built.actual, { bytes: portable.bytes, sha256: portable.sha256 });
assert.equal(item.sha256, portable.sha256); assert.equal(item.bytes, portable.bytes);
if (item.sha256 !== old.sha256) changed.push(item.path);
}
assert.deepEqual(changed, ['dist-server/install-manager.mjs']);
const rejected = selected('negativeRebuild');
assert.equal(rejected.success, false); assert.equal(rejected.mismatches.length, 1);
assert.equal(rejected.mismatches[0].path, changed[0]);
const archives = selected('archives'); assert.equal(archives.success, true); assert.equal(archives.archives.length, 3);
for (const archive of archives.archives) {
assert.equal(archive.sha256, release[archive.kind].sha256); assert.equal(archive.crcPassed, true); assert.equal(archive.manifestAndDirectoryMatch, true);
}
const portable = selected('portable'); assert.equal(portable.success, true); assert.equal(portable.appRoot, release.portableRoot);
assert.equal(portable.realModel, false);
const installation = selected('installation');
assert.equal(installation.success, true); assert.equal(installation.realModelRequests, 0); assert.equal(installation.results.length, 12);
assert.equal(installation.packagedSource, path.resolve(release.portableRoot)); assert.ok(installation.results.every(result => result.passed));
for (const phase of ['before.json', 'install.json', 'final.json']) assert.equal(selected(phase).success, true);
const final = selected('final.json');
assert.equal(final.pid, 36552); assert.equal(final.hasKey, true); assert.equal(final.realModelRequests, 0); assert.equal(final.inspectorClosed, true);
assert.deepEqual(final.retained, { originalRows: 'exact', originalExports: 'exact', originalArtifactBytes: 'exact', originalModelCenter: 'exact' });
assert.equal(final.pointer.active.directory, manifest.candidate);
assert.equal(final.pointer.active.manifestSha256, sha(raw(manifest.selected.portableManifest)));
assert.equal(final.operation.state, 'completed'); assert.equal(final.desktopWindows, 0);
assert.equal(final.nativeWindowReview.status, 'not_performed'); assert.deepEqual(final.nativeWindowReview, manifest.nativeWindowReview);
assert.equal(selected('nativeStop').fallbackUIInput, false);
assert.equal(final.availability.status, 'available'); assert.equal(final.purge.status, 'available');
const identity = JSON.parse(fs.readFileSync('docs/original-purge-release-identity.json'));
assert.equal(identity.sourceCommit, manifest.sourceCommit); assert.equal(identity.candidate, manifest.candidate);
assert.equal(identity.evidence.sha256, sha(raw('manifest.json'))); assert.equal(identity.evidence.files, manifest.count);
assert.equal(identity.manifestSha256, final.identity.manifestSha256); assert.equal(identity.runtimeIdentity, final.identity.identitySha256);
assert.deepEqual(identity.formalNativeWindowReview, final.nativeWindowReview); assert.deepEqual(identity.counts, final.counts);
const audit = selected('efficiency-audit-v3.json');
assert.equal(audit.manifestSha256, manifest.eManifestSha256); assert.equal(audit.realModelRequests, 0);
const react = audit.reports.find(sample => sample.name === 'react');
assert.equal(react.pages.length, 11);
assert.equal(react.pages.filter(page => page.alreadyCovered && page.nextOffset > page.offset).length, 4);
assert.equal(react.pages.filter(page => page.nextOffset === page.offset).length, 1);
assert.deepEqual(react.requests.slice(6).map(request => request.completeSource.filter(file => file.retained).length), [6, 5, 5, 4, 2, 2]);
console.log(JSON.stringify({ success: true, slice: manifest.slice, candidate: manifest.candidate, files: manifest.count, bytes: manifest.bytes,
sourceInputs: manifest.sourceInputs.length, compiled: rebuilt.compiled.length, isolatedInstallerGroups: installation.results.length,
originalState: final.retained, nativeWindowReview: 'not_performed', realModelRequests: 0 }));