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.');