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/retire-ddr-host-for-codesign.ts
/** Explicit one-host removal for a bounded co-design experiment; never overwrites parent. */
import{readFileSync,writeFileSync,mkdirSync}from'node:fs';import{resolve}from'node:path';import{objectHash as hash}from'./improve-ddr-a9-power-launches';import{auditCompositeHostTopology}from'./ddr-composite-routing-context';
const[parentArg,signal,outArg]=process.argv.slice(2);if(!outArg)throw Error('Usage: parent global-source-trace output');const parent=resolve(parentArg),out=resolve(outArg),read=(p:string)=>JSON.parse(readFileSync(p,'utf8')),c=read(parent+'/candidate.circuit.json'),h=read(parent+'/host-bundle.json'),r=read(parent+'/report.json'),input=read(parent+'/routing-input.json');if(hash(c)!==r.candidateCircuitSha256||hash(h.traces)!==r.hostTracesSha256)throw Error('Parent differs');const removed=h.traces.filter((t:any)=>t.source_trace_id===signal);if(removed.length!==1)throw Error('Expected exact one host');const traces=h.traces.filter((t:any)=>!removed.includes(t)),candidate=c.filter((e:any)=>!removed.some((t:any)=>hash(t)===hash(e))),topology=auditCompositeHostTopology(candidate,traces,input.connections);if(!topology.valid)throw Error('Retained hosts fail');mkdirSync(out,{recursive:true});const write=(n:string,v:any)=>writeFileSync(out+'/'+n,JSON.stringify(v,null,2)+'\n'),manifest={captureHash:r.captureHash,parentDirectory:parent,parentCircuitSha256:hash(c),candidateCircuitSha256:hash(candidate),replacements:[],removals:removed,additions:[]};write('candidate.circuit.json',candidate);write('host-bundle.json',{...h,traces});write('routing-input.json',{...input,traces});write('original-copper-replacements.json',manifest);write('report.json',{...r,candidateCircuitSha256:hash(candidate),hostTracesSha256:hash(traces),hostBundleSha256:hash({...h,traces}),originalCopperReplacementsSha256:hash(manifest),connectedHostCount:traces.length,topology,scope:`Isolated co-design: exact ${signal} host removed. ${traces.length} retained hosts; not an accepted replacement board.`});for(const n of ['ram-byte0-facing-progress.trace-paths.json','ram-byte1-facing-progress.trace-paths.json','source-provenance.json','ram-power-launch-audit.json'])write(n,read(parent+'/'+n));for(const n of ['exit-contract.json','ram-byte1-exit-contract.json'])write(n,{...read(parent+'/'+n),candidateCircuitSha256:hash(candidate)});if(hash(read(parent+'/candidate.circuit.json'))!==hash(c))throw Error('Parent changed');console.log(JSON.stringify({out,retained:traces.length,removedSha:hash(removed[0]),candidateSha:hash(candidate)}));