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/finalize-ddr-f8-power.ts

/** Self-contained export of the already checked F8/E9 power57 proposal; no geometry edits. */
import{readFileSync,writeFileSync,mkdirSync}from'node:fs'
import{resolve}from'node:path'
import{createHash}from'node:crypto'
import{spawnSync}from'node:child_process'
import{auditRouteAngles}from'./check-route-angles'
import{verifyDdrCapture}from'./ddr-capture-provenance'
const[parentArg,proposalArg,outArg]=process.argv.slice(2),parentDir=resolve(parentArg!),proposal=resolve(proposalArg!),out=resolve(outArg!),capture=resolve('dist/ddr-system/host-taps-54af3e346b5e'),hash=(x:any)=>createHash('sha256').update(JSON.stringify(x)).digest('hex'),bound:Record<string,string>={},fh=(p:string)=>createHash('sha256').update(readFileSync(p)).digest('hex'),read=(p:string)=>{p=resolve(p);bound[p]=fh(p);return JSON.parse(readFileSync(p,'utf8'))},write=(n:string,v:any)=>writeFileSync(resolve(out,n),JSON.stringify(v,null,2)+'\n'),{captureHash}=verifyDdrCapture(capture),parent=read(`${parentDir}/candidate.circuit.json`),candidate=read(`${proposal}/candidate.circuit.json`),report=read(`${proposal}/report.json`),prior=read(`${parentDir}/report.json`),manifest=read(`${proposal}/original-copper-replacements.json`),host=read(`${proposal}/host-bundle.json`),input=read(`${proposal}/routing-input.json`)
if(out===parentDir||out===proposal||!report.accepted||report.captureHash!==captureHash||hash(parent)!==manifest.parentCircuitSha256||hash(candidate)!==manifest.candidateCircuitSha256||hash(candidate)!==report.candidateCircuitSha256||host.traces.length!==20||manifest.replacements.length!==4||report.powerNoRegression.after!==57)throw Error('Expected exact checked20/power57 proposal')
let replay=structuredClone(parent);for(const r of manifest.replacements){const i=replay.findIndex((e:any)=>`${e.type}:${e[`${e.type}_id`]}`===r.id);if(i<0||hash(replay[i])!==r.beforeSha256||hash(r.after)!==r.afterSha256)throw Error('Invalid exact patch');replay[i]=r.after}if(hash(replay)!==hash(candidate))throw Error('Undeclared geometry')
const scope='Twenty geometrically connected host nets; RAM1 F8 ground relocated and E9 shares existing G8 supply barrel. 57/60 qualified power launches; all prior56 retained. Explicit F8-only provisional .127mm plane-web assumption with external .107mm pour clearance; no additional inner2/inner4 reference gap. Remaining signals, transition returns, SI/PDN and fabrication qualification incomplete.',cache0=read(`${parentDir}/ram-byte0-facing-progress.trace-paths.json`),cache1=read(`${parentDir}/ram-byte1-facing-progress.trace-paths.json`)
for(const c of[cache0,cache1])if(c.length!==72||!auditRouteAngles(c).valid)throw Error('Invalid inherited cache')
const contract0={...read(`${parentDir}/exit-contract.json`),candidateCircuitSha256:hash(candidate),ramCacheSha256:hash(cache0),scope},contract1={...read(`${parentDir}/ram-byte1-exit-contract.json`),candidateCircuitSha256:hash(candidate),ramCacheSha256:hash(cache1),ramByte1CacheSha256:hash(cache1),scope},source={inherited:read(`${parentDir}/source-provenance.json`),parentCircuitSha256:hash(parent),candidateCircuitSha256:hash(candidate),manifestSha256:hash(manifest),inputHashes:bound,supportOverrideScope:'Both72 signal/profile caches preserved exactly. F8/E9 physical support changes reproduced by the explicit four-replacement board manifest, not by mutating external saved profiles.'}
mkdirSync(out,{recursive:true});write('candidate.circuit.json',candidate);write('host-bundle.json',host);write('routing-input.json',input);write('original-copper-replacements.json',manifest);write('parent-original-copper-replacements.json',read(`${parentDir}/original-copper-replacements.json`));write('parent-report.json',prior);write('ram-byte0-facing-progress.trace-paths.json',cache0);write('ram-byte1-facing-progress.trace-paths.json',cache1);write('exit-contract.json',contract0);write('ram-byte1-exit-contract.json',contract1);write('source-provenance.json',source);write('topology-report.json',report.topology);write('host-route-report.json',read(`${parentDir}/host-route-report.json`))
const final={...report,scope,connectedHostCount:20,preservedHostCount:20,launchQualified:57,totalRamPowerPads:60,parentReportSha256:hash(prior),originalCopperReplacementsSha256:hash(manifest),hostTracesSha256:hash(host.traces),hostBundleSha256:hash(host),fullCandidateAngles:report.angles,fixedJunctionAudit:report.junctions,ramCacheSha256:hash(cache0),ramByte1CacheSha256:hash(cache1),exitContractProvenance:{byte0Sha256:hash(contract0),byte1Sha256:hash(contract1)},sourceProvenance:source,inputFileHashes:bound,metadataRefresh:{candidateExact:true,parentCache0Exact:true,parentCache1Exact:true,scope:'Power overrides remain explicit in support manifest; copied72 paths preserve reusable source profiles.'}}
write('report.json',final)
for(const script of['audit-ddr-global-power-launches.ts','audit-ddr-host-reference-coverage.ts']){const r=spawnSync('bun',[`scripts/${script}`,out,capture],{encoding:'utf8'});writeFileSync(`${out}/${script}.log`,r.stdout+r.stderr);if(r.status!==0)throw Error(`Audit failed ${script}`)}
const power=read(`${out}/ram-power-launch-audit.json`),reference=read(`${out}/host-reference-coverage.json`),beforePower=read(`${parentDir}/ram-power-launch-audit.json`);if(power.total!==60||power.launchQualified!==57||beforePower.rows.some((r:any)=>r.launchWithin1524Mm&&!power.rows.find((p:any)=>p.byte===r.byte&&p.ball===r.ball)?.launchWithin1524Mm))throw Error('Power regression')
Object.assign(final,{launchAuditSha256:hash(power),hostReferenceCoverageSha256:hash(reference),sourceProvenanceSha256:hash(source)});write('report.json',final)
const budgets=spawnSync('bun',['scripts/audit-ddr-current-byte-budgets.ts',capture,out,`${out}/current-byte-budgets.json`],{encoding:'utf8'});writeFileSync(`${out}/byte-budget-audit.log`,budgets.stdout+budgets.stderr);if(budgets.status!==0)throw Error('Byte audit failed');Object.assign(final,{currentByteBudgetsSha256:hash(read(`${out}/current-byte-budgets.json`))});for(const[p,h]of Object.entries(bound))if(fh(p)!==h)throw Error(`Input changed: ${p}`);verifyDdrCapture(capture);write('source-provenance.json',source);Object.assign(final,{sourceProvenanceSha256:hash(source)});write('report.json',final);console.log(JSON.stringify({candidateCircuitSha256:hash(candidate),power:57,hosts:20,cache0:cache0.length,cache1:cache1.length,manifestSha256:hash(manifest)}))