File size: 1,526 Bytes
d821d28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';

const root = resolve(import.meta.dirname, '..');
const readJson = async (path) => JSON.parse(await readFile(resolve(root, path), 'utf8'));
const digest = (value) => `sha256:${createHash('sha256').update(value).digest('hex')}`;
const [bootstrapXml, runtime, storage, mcp, mcpProfiles, manifest] = await Promise.all([
  readFile(resolve(root, 'bootstrap.xml'), 'utf8'),
  readJson('generated/runtime.json'),
  readJson('generated/storage/storage.json'),
  readJson('generated/registries/mcp.json'),
  readJson('generated/registries/mcp-profiles.json'),
  readJson('generated/snapshots/snapshot-manifest.json')
]);

assert.equal(manifest.schema, 1, 'snapshot manifest schema version must be 1');
assert.equal(manifest.project, 'ProjectOS', 'snapshot manifest must identify ProjectOS');
assert.equal(manifest.bootstrapHash, digest(bootstrapXml), 'bootstrap hash must match the source manifest');
assert.equal(manifest.runtimeHash, digest(JSON.stringify(runtime)), 'runtime hash must match the generated runtime');
assert.equal(manifest.storageHash, digest(JSON.stringify(storage)), 'storage hash must match generated storage settings');
assert.equal(manifest.mcpHash, digest(JSON.stringify({ servers: mcp, profiles: mcpProfiles })), 'MCP hash must match generated server and profile registries');
console.log('Generated snapshot manifests and hashes are valid.');