import assert from 'node:assert/strict'; import {readFileSync, writeFileSync, mkdtempSync, copyFileSync} from 'node:fs'; import {createHash} from 'node:crypto'; import {resolve, join} from 'node:path'; import {fileURLToPath} from 'node:url'; // Index the completed components without converting them into guest acceptance. // No source, guest result, roadmap number or running capture is modified. const root=resolve('.'); const directory=mkdtempSync('reports/os-implementation/K2100-native-proof-index-'); copyFileSync(fileURLToPath(import.meta.url),join(directory,'harness.mjs.txt')); const artifact=path=>({path,sha256:createHash('sha256').update(readFileSync(path)).digest('hex')}); const read=path=>JSON.parse(readFileSync(path)); const definitions=[ ['admission','K2100-native-admission-proof-uds59j44','NATIVE_ADMISSION_CONTROL_FLOW_COMPONENT_PASSED'], ['receipt','K2100-native-receipt-proof-utlspevg','NATIVE_RECEIPT_CONTROL_FLOW_COMPONENT_PASSED'], ['staleWakeGates','K2100-process-stale-gates-proof-zdvjs0ct','PROCESS_STALE_COMPILED_GATES_PASSED'], ['serviceProgress','K2100-native-service-progress-proof-seyw3ud0','NATIVE_SERVICE_PROGRESS_CONTROL_FLOW_PASSED'], ['resourceGates','K2100-native-resource-gates-proof-2unxqn2h','NATIVE_RESOURCE_GATES_COMPONENT_PASSED'], ['windowObservation','K2100-native-window-flow-proof-khwsyjrd','NATIVE_WINDOW_OBSERVATION_COMPONENT_PASSED'], ['serviceCallPaths','K2100-native-service-path-proof-wtwnu11l','NATIVE_SERVICE_PATH_PREREQUISITES_PASSED'], ['shortPhysicalReplay','K2100-duration-window-proof-3uvEZe','DURATION_WINDOW_PHYSICAL_COMPONENT_PASSED'], ]; const checkedArtifacts=new Map(); function verifyArtifact(a){ const absolute=resolve(a.path);assert.ok(absolute.startsWith(root+'/'),'artifact is in workspace'); if(!checkedArtifacts.has(absolute))checkedArtifacts.set(absolute,artifact(a.path)); assert.equal(checkedArtifacts.get(absolute).sha256,a.sha256,a.path); } function verifyNested(value){ if(Array.isArray(value)){for(const item of value)verifyNested(item);return;} if(!value||typeof value!=='object')return; if(typeof value.path==='string'&&typeof value.sha256==='string')verifyArtifact(value); for(const child of Object.values(value))verifyNested(child); } try{ const preflightPath=process.argv[2];assert.ok(preflightPath);const pre=read(preflightPath); assert.equal(pre.status,'NATIVE_MODELS_COMPILED');verifyNested(pre.artifacts); const image=pre.artifacts.image;const imageBytes=readFileSync(image.path).length;assert.ok(imageBytes<=8*1024*1024); const components={};const reports={}; for(const [key,folder,status]of definitions){ const path='reports/os-implementation/'+folder+'/report.json';const r=read(path); assert.equal(r.status,status,key);assert.equal(r.guestAccepted,false);assert.equal(r.productAccepted,false); assert.deepEqual(r.image,image,key+' exact candidate image');verifyNested(r); if(r.preflight)assert.deepEqual(r.preflight,artifact(preflightPath)); reports[key]=r;components[key]={report:artifact(path),status:r.status,scope:r.scope}; } assert.equal(reports.admission.cases,3374); assert.equal(reports.admission.compiledInstructionMutantsRejected.length,8); for(const r of [reports.admission,reports.receipt])for(const c of Object.values(r.coverage))assert.equal(c.instructions,c.visited); assert.equal(reports.receipt.cases.length,49);assert.equal(reports.staleWakeGates.predicateCases.length,38); assert.equal(reports.staleWakeGates.dominatingGates.length,19); assert.equal(reports.serviceProgress.cases.length,112);assert.equal(reports.serviceProgress.coverage.instructions,272);assert.equal(reports.serviceProgress.coverage.visited,272); assert.equal(reports.resourceGates.cases.length,114);assert.equal(reports.windowObservation.cases.length,228); assert.equal(reports.serviceCallPaths.dependencies.length,18);assert.equal(reports.serviceCallPaths.returnGates.length,12); assert.equal(reports.shortPhysicalReplay.longInput,false);assert.equal(reports.shortPhysicalReplay.windows.length,3); assert.equal(reports.shortPhysicalReplay.rejectedControlCount,58);assert.equal(reports.shortPhysicalReplay.modeledLateCasesAreGuestEvidence,false); const controlPath='reports/os-implementation/K2100-single-cpu-control-review-vlwg4w7h/report.json'; const correction=read(controlPath);assert.equal(correction.status,'SINGLE_CPU_HOST_CONTROLS_CORRECTED_AND_TESTED'); assert.equal(correction.guestAccepted,false);assert.equal(correction.productAccepted,false);assert.deepEqual(correction.sameImage,image); assert.equal(correction.cases.length,45);verifyNested(correction); const report={status:'COMPILED_AND_SHORT_PHYSICAL_COMPONENT_INDEX_VERIFIED',guestAccepted:false,productAccepted:false, scope:'Hash-checked index of eight complementary components on exactly one compiled image. Host fixtures and short guest evidence retain their original scopes. This index does not prove the full kernel, elapsed long-profile time, or K2100 acceptance.', hostControlCorrection:artifact(controlPath),preflight:artifact(preflightPath),image,imageBytes,imageSpanLimitBytes:8*1024*1024,components, verifiedReferencedArtifacts:checkedArtifacts.size,hostPredicateCases:3915,actualInstructionMutantsRejected:8, shortPhysicalBadRecordsRejected:58,remaining:['All eighteen same-image real long CPU/RAM/boot profiles','Per-profile final physical/protocol/service proof','Consolidated acceptance review and production publication before roadmap advancement'], harness:artifact(join(directory,'harness.mjs.txt'))}; writeFileSync(join(directory,'report.json'),JSON.stringify(report,null,2)+'\n'); console.log(JSON.stringify({status:report.status,report:join(directory,'report.json'),components:definitions.length,verifiedArtifacts:checkedArtifacts.size})); }catch(error){ writeFileSync(join(directory,'report.json'),JSON.stringify({status:'NATIVE_PROOF_COMPONENT_INDEX_FAILED',guestAccepted:false,productAccepted:false,error:error.stack},null,2)+'\n'); console.error(join(directory,'report.json'));throw error; }