0hmX/am3352
This code suite comprises TypeScript scripts that analyze, verify, and assemble complex DDR memory interface hardware, focusing on physical routing, via and pad placement, electrical clearance, and physical constraints, often involving precise geometric calculations and consistent provenance tracking.
- Version
- 1.0.5
- License
- unset
- Stars
- 0
scripts/diagnose-ddr-facing-exit.ts
/** Instrument an unchanged bounded existing planner case before its endpoint guard. */
import {readFileSync,writeFileSync,mkdirSync,unlinkSync} from 'node:fs'
import {resolve,dirname} from 'node:path'
import {tmpdir} from 'node:os'
import {createHash} from 'node:crypto'
const args=process.argv.slice(2)
if(args.length!==8)throw Error('Usage: capture parent support signal output y grid layer')
const sourcePath=resolve('scripts/plan-ddr-facing-ram-exit.ts'),source=readFileSync(sourcePath,'utf8')
const marker='if(raw){'
if(source.split(marker).length!==2)throw Error('Planner instrumentation location changed')
const instrumented=`process.argv=${JSON.stringify(['bun','instrumented',...args])};\n`+source.replace(/from '\.\/([^']+)'/g,(_,p)=>`from ${JSON.stringify(resolve(dirname(sourcePath),p))}`).replace(marker,"if(raw){write('pre-guard-raw.json',raw);")
const temp=resolve(tmpdir(),`ddr-facing-instrumented-${process.pid}.ts`),out=resolve(args[4]!)
mkdirSync(out,{recursive:true});writeFileSync(temp,instrumented)
const start=Date.now(),child=Bun.spawn(['bun',temp],{cwd:process.cwd(),stdout:'pipe',stderr:'pipe'})
let timedOut=false
const timer=setTimeout(()=>{timedOut=true;child.kill()},60000)
const [code,stdout,stderr]=await Promise.all([child.exited,new Response(child.stdout).text(),new Response(child.stderr).text()])
clearTimeout(timer);unlinkSync(temp)
const sha=(s:string)=>createHash('sha256').update(s).digest('hex')
if(sha(readFileSync(sourcePath,'utf8'))!==sha(source))throw Error('Planner source changed during run')
writeFileSync(resolve(out,'instrumentation-report.json'),JSON.stringify({sourcePath,sourceSha256:sha(source),args,code,timedOut,elapsedSeconds:(Date.now()-start)/1000,stdout,stderr,scope:'Identical existing planner parameters; instrumentation only saves raw output before unchanged retained-via guard.'},null,2)+'\n')
console.log(JSON.stringify({code,timedOut,out,stderr}));process.exitCode=code===0?0:1