import assert from 'node:assert/strict'; import {readFileSync, writeFileSync, copyFileSync, mkdtempSync} from 'node:fs'; import {createHash} from 'node:crypto'; import {join} from 'node:path'; import {fileURLToPath} from 'node:url'; import {frozenSnapshot} from './boot-contract-report.mjs'; assert.equal(process.argv.length, 6, 'pass local, long matrix, closure collection and native stack release reports'); const [localPath, matrixPath, closurePath, stackPath] = process.argv.slice(2); const read = p => JSON.parse(readFileSync(p)); const artifact = path => ({path, sha256: createHash('sha256').update(readFileSync(path)).digest('hex')}); const directory = mkdtempSync('reports/os-implementation/K2100-smp-workload-matrix-check-'); copyFileSync(fileURLToPath(import.meta.url), join(directory, 'harness.mjs.txt')); const verified = new Map(); function checked(a) { if (!verified.has(a.path)) verified.set(a.path, artifact(a.path).sha256); assert.equal(verified.get(a.path), a.sha256, a.path); return readFileSync(a.path); } function verify(v) { if (!v || typeof v !== 'object') return; if (typeof v.path === 'string' && typeof v.sha256 === 'string') checked(v); for (const x of Object.values(v)) verify(x); } try { const frozenBefore = frozenSnapshot(process.cwd()); const local = read(localPath), matrix = read(matrixPath), closure = read(closurePath), stack = read(stackPath); // Gate completeness before touching any acceptance state or claiming a guest pass. assert.equal(local.status, 'K2096_K2099_LOCAL_VALIDATED'); assert.equal(matrix.status, 'LONG_PROFILE_MATRIX_COMPONENT_PASSED'); assert.equal(closure.status, 'PROFILE_CLOSURE_COLLECTION_PASSED'); assert.equal(matrix.profiles.length, 18); assert.equal(closure.completed.length, 18); assert.equal(stack.status, 'NATIVE_STACK_RELEASE_COMPONENT_PASSED'); for (const component of [local, matrix, closure, stack]) { assert.equal(component.guestAccepted, false); assert.equal(component.productAccepted, false); verify(component); } assert.deepEqual(local.image, matrix.image); assert.deepEqual(stack.image, matrix.image); assert.deepEqual(closure.image, matrix.image); assert.deepEqual(matrix.candidate, local.candidate); assert.deepEqual(matrix.nativeIndex, local.nativeIndex); assert.equal(read(local.predecessor.path).status, 'ACCEPTED_AND_PRODUCTION_PUBLISHED'); assert.equal(read(local.predecessorPublication.path).status, 'PUBLISHED_AND_PRODUCTION_VERIFIED'); assert.deepEqual(local.frozenBefore, frozenBefore); assert.deepEqual(local.frozenAfter, frozenBefore); assert.ok(local.imageFileBytes <= local.imageSpanBytes && local.imageSpanBytes <= 8 * 1024 * 1024); assert.equal(stack.caseCount, 120); assert.equal(stack.cases.length, 120); assert.equal(stack.prerequisites.length, 21); assert.equal(stack.zeroedBytesPerWorker, 20480); assert.equal(stack.fullZeroWordsPerWorker, 2560); assert.equal(stack.barrier, 'DSB ISH'); assert.equal(stack.coverage.selectedInstructions, stack.coverage.visitedInstructions); const index = JSON.parse(checked(local.nativeIndex)); verify(index); assert.equal(index.status, 'COMPILED_AND_SHORT_PHYSICAL_COMPONENT_INDEX_VERIFIED'); for (const c of Object.values(index.components)) verify(JSON.parse(checked(c.report))); const wake = JSON.parse(checked(local.wakeRefusal)); verify(wake); assert.equal(wake.status, 'NATIVE_WAKE_EARLY_REFUSAL_COMPONENT_PASSED'); const required = new Set(); for (const route of ['direct', 'uefi']) for (const ram of [256, 512, 1024]) for (const cpus of [1, 2, 4]) required.add(`${route}-${ram}-cpu-${cpus}`); assert.equal(new Set(matrix.profiles.map(p => p.id)).size, 18); const seen = new Set(), profiles = [], cases = []; for (const component of closure.completed) { assert.ok(required.has(component.id) && !seen.has(component.id)); seen.add(component.id); const profile = matrix.profiles.find(p => p.id === component.id); assert.ok(profile); const report = JSON.parse(checked(component.report)); verify(report); assert.equal(report.status, 'PROFILE_CLOSURE_PHYSICAL_COMPONENT_PASSED'); assert.deepEqual(report.proof, profile.proof); assert.deepEqual(report.review, profile.review); assert.deepEqual(report.physical, profile.physical); assert.deepEqual(report.image, matrix.image); assert.equal(`${report.route}-${report.memoryMiB}-cpu-${report.cpuCount}`, component.id); assert.equal(report.rejectedControlCount, report.cpuCount === 1 ? 11 : 18); assert.equal(report.closure.checkpoints, 9); assert.equal(report.closure.firmwareOff, report.cpuCount - 1); assert.equal(report.closure.returnedWorkerPages, 5 * (report.cpuCount - 1)); assert.equal(report.closure.zeroedMailboxAndExecutivePages, 33 * (report.cpuCount - 1)); assert.equal(report.closure.primaryZeroBytes, 69632); assert.equal(report.closure.primarySpRestored, true); assert.equal(report.closure.primaryDescriptorRestored, true); assert.equal(report.provenance.resultWrites, 0); assert.equal(report.provenance.fullProfileIntervalRestricted, true); assert.equal(report.replay.guestEvidenceCreated, false); assert.ok(profile.hostRunningMilliseconds >= 7200000 && profile.guestElapsedSeconds >= 7200); const duration = JSON.parse(checked(profile.proof)); verify(duration); assert.equal(duration.rejectedControlCount, report.cpuCount === 1 ? 54 : 57); assert.equal(duration.provenance.resultWrites, 0); assert.equal(duration.serviceReplay.guestEvidenceCreated, false); const diagnostic = JSON.parse(checked(duration.diagnostic)); assert.equal(diagnostic.status, 'GUEST_RETURNED'); checked(diagnostic.serial); const review = JSON.parse(checked(profile.review)); verify(review); assert.deepEqual(review.candidate, local.candidate); assert.deepEqual(review.sourceBefore, review.sourceAfter); const life = JSON.parse(checked(review.lifecycle)); assert.equal(life.status, 'RUNNER_PASSED'); assert.equal(life.allOwnedGuestsStopped, true); assert.equal(life.sourceInputsStable, true); verify(JSON.parse(checked(profile.physical))); profiles.push({...profile, closure: component.report, cpuCount: report.cpuCount, route: report.route, memoryMiB: report.memoryMiB, closureControls: report.rejectedControlCount, durationControls: duration.rejectedControlCount}); cases.push({id: component.id, cpuCount: report.cpuCount, memoryMiB: report.memoryMiB, route: report.route, hostRunningMilliseconds: profile.hostRunningMilliseconds, guestElapsedSeconds: profile.guestElapsedSeconds, windows: profile.windows, serial: diagnostic.serial, diagnostic: duration.diagnostic}); } assert.deepEqual(seen, required); const externalPath = 'reports/os-implementation/K2000-security-review-readiness.json'; const external = read(externalPath); assert.equal(external.status, 'EXTERNAL_REVIEW_PENDING_AND_PUBLISHED'); assert.equal(external.independentReviewAccepted, false); const frozenAfter = frozenSnapshot(process.cwd()); assert.deepEqual(frozenAfter, frozenBefore); const report = {schema: 'turkos-k2100-smp-workload-development-matrix/v1', status: 'K2100_SMP_WORKLOAD_DEVELOPMENT_MATRIX_VALIDATED', guestAccepted: true, productAccepted: false, scope: 'Development acceptance for the same native Image on 18 CPU/RAM/boot profiles, each with at least two measured host-running and guest-counter hours, actual per-CPU process/IPC/VFS/timer/EL0-shell/network work, late stale-PID refusal followed by a complete window, conserved resources and owner-controlled teardown. Per-CPU shared service transactions are serialized by custody while independent shell/Tmpfs workers run concurrently. This does not establish arbitrary simultaneous allocator mutation, independent security review, external user acceptance or product release.', local: artifact(localPath), longMatrix: artifact(matrixPath), closureCollection: artifact(closurePath), nativeStackRelease: artifact(stackPath), nativeIndex: local.nativeIndex, wakeRefusal: local.wakeRefusal, candidate: local.candidate, image: matrix.image, contract: local.sources.contract, profiles, cases, sources: Object.values(local.sources), tests: {hostTests: local.tests.hostTests, sourceMutantsRejected: local.tests.sourceMutantsRejected, compiledPredicateCases: local.tests.compiledPredicateCases + stack.caseCount, compiledInstructionMutantsRejected: local.tests.compiledInstructionMutantsRejected, longProfilesPassed: profiles.length, closureCheckpoints: profiles.length * 9, rejectedPhysicalControls: profiles.reduce((n, p) => n + p.closureControls + p.durationControls, 0)}, minimumHostRunningMilliseconds: Math.min(...profiles.map(p => p.hostRunningMilliseconds)), minimumGuestElapsedSeconds: Math.min(...profiles.map(p => p.guestElapsedSeconds)), actualRequests: profiles.reduce((n, p) => n + p.actualRequests, 0), actualReplies: profiles.reduce((n, p) => n + p.actualReplies, 0), rejectedPhysicalControls: profiles.reduce((n, p) => n + p.closureControls + p.durationControls, 0), externalReview: artifact(externalPath), independentReviewAccepted: false, checkedArtifacts: verified.size, frozenBefore, frozenAfter, harness: artifact(join(directory, 'harness.mjs.txt'))}; const path = join(directory, 'report.json'); writeFileSync(path, JSON.stringify(report, null, 2) + '\n'); console.log(JSON.stringify({status: report.status, report: path, profiles: profiles.length, checkedArtifacts: verified.size})); } catch (error) { const path = join(directory, 'report.json'); writeFileSync(path, JSON.stringify({status: 'K2100_SMP_WORKLOAD_MATRIX_FAILED', guestAccepted: false, productAccepted: false, error: error.stack, harness: artifact(join(directory, 'harness.mjs.txt'))}, null, 2) + '\n'); console.error(path); throw error; }