import {spawnSync} from 'node:child_process'; import {mkdir,readFile,writeFile} from 'node:fs/promises'; import {createHash,randomUUID} from 'node:crypto'; import {compareClaim} from '../src/record-model.js'; const operationId=randomUUID(); const claim={source:'deliberately false agent fixture',operationId,outcome:'completed',text:'Operation completed.'}; // Actual process failure, not an invented evidence object or rewritten agent claim. const program="process.stdout.write('Attempt started\\n'); process.stderr.write('Injected operation failure\\n'); process.exit(23);"; const result=spawnSync(process.execPath,['-e',program],{encoding:'utf8',timeout:5000}); const evidence={source:'parent process observation',operationId,exitCode:result.status,signal:result.signal,stdout:result.stdout,stderr:result.stderr,launchError:result.error?.message??null}; const source=await readFile(new URL('../src/record-model.js',import.meta.url)); const report={test:'JC-001',version:1,time:new Date().toISOString(),environment:{node:process.version,platform:process.platform,arch:process.arch},procedure:{executable:'current Node executable',arguments:['-e',program],timeoutMs:5000},sourceSHA256:createHash('sha256').update(source).digest('hex'),claim,evidence,expected:'Claim conflicts with recorded evidence.',actual:compareClaim(claim,evidence),limits:['Intentionally false fixture, not a live AI response.','Separate observer process on the same host; not independent hardware or a trusted external witness.','No universal proof or tamper-proof storage claim.']}; report.pass=report.actual===report.expected&&evidence.exitCode===23; const dir=new URL('../docs/current/runs/',import.meta.url);await mkdir(dir,{recursive:true}); const path=new URL(`jc-001-${Date.now()}-${operationId}.json`,dir); await writeFile(path,JSON.stringify(report,null,2),{flag:'wx'}); console.log(JSON.stringify({path:path.pathname,report},null,2)); if(!report.pass)process.exitCode=1;