import assert from'node:assert/strict';import{readFileSync}from'node:fs';import{frameAtomicSites}from'./smp-progress-frame-inputs-proof.mjs';import{publicationAtomicSites,publicationCallSites}from'./smp-progress-publication-inputs-proof.mjs';import{progressAtomicSites}from'./smp-progress-inputs-proof.mjs'; const text=n=>readFileSync('scripts/os-acceptance/'+n,'utf8'); const exact=(s,a,b)=>{assert.equal(s.split(a).length,2,a);return s.replace(a,b)}; const exported=(s,n,value)=>{const pattern=new RegExp('export const '+n+'=.*?;\\n');assert.equal((s.match(new RegExp(pattern.source,'g'))??[]).length,1);return s.replace(pattern,'export const '+n+'='+JSON.stringify(value)+';\n')}; export function metricsParentDerivations(){ const out={};let s=text('smp-progress-frame-inputs-proof.mjs'); s=exact(s,"['frameCycle',3664]","['frameCycle',3660]");s=exact(s,"['frameCycle',1992,","['frameCycle',1988,");s=exact(s,"['frameCycle',2344,","['frameCycle',2340,");s=exported(s,'frameAtomicSites',{...frameAtomicSites,frameCycle:frameAtomicSites.frameCycle.map(([at,op])=>[at===352?at:at-4,op])});out['lock-metrics-frame-inputs-proof.mjs']=s; out['lock-metrics-frame-proof.mjs']=text('smp-progress-frame-proof.mjs').replaceAll('./smp-progress-frame-inputs-proof.mjs','./lock-metrics-frame-inputs-proof.mjs'); s=text('smp-progress-publication-inputs-proof.mjs').replaceAll('./smp-progress-frame-inputs-proof.mjs','./lock-metrics-frame-inputs-proof.mjs'); s=exported(s,'publicationAtomicSites',{...publicationAtomicSites,publicationCycle:publicationAtomicSites.publicationCycle.map(([at,op])=>[at>=1668?at-8:at,op]),publicationDrive:publicationAtomicSites.publicationDrive.filter(([at])=>at!==580).map(([at,op])=>[at-4,op]),sharedOwnershipCheck:[[4,0xc8dffd28]]}); s=exact(s,'[1112,0x54001e62]','[1112,0x54001e22]');s=exact(s,"['publicationCycle',2096],['publicationDrive',1772]","['publicationCycle',2088],['publicationDrive',1768],['sharedOwnershipCheck',12]"); s=exported(s,'publicationCallSites',[...publicationCallSites.map(([n,at,...rest])=>[n,n==='publicationDrive'?at-4:at,...rest]),['publicationDrive',576,'sharedOwnershipCheck']]); s=exact(s,' return{...inherited,'," assert.deepEqual(Array.from({length:3},(_,i)=>compiled.sharedOwnershipCheck.readUInt32LE(i*4)),[0x91002269,0xc8dffd28,0xd65f03c0]);\n return{...inherited,");s=s.replace('publicationCompiledCallSites:17','publicationCompiledCallSites:18');out['lock-metrics-publication-inputs-proof.mjs']=s; out['lock-metrics-publication-proof.mjs']=text('smp-progress-publication-proof.mjs').replaceAll('./smp-progress-frame-proof.mjs','./lock-metrics-frame-proof.mjs').replaceAll('./smp-progress-publication-inputs-proof.mjs','./lock-metrics-publication-inputs-proof.mjs'); s=text('smp-progress-inputs-proof.mjs').replaceAll('./smp-progress-publication-inputs-proof.mjs','./lock-metrics-publication-inputs-proof.mjs');s=exported(s,'progressAtomicSites',{...progressAtomicSites,progressDrive:progressAtomicSites.progressDrive.filter(([at])=>at!==564).map(([at,op])=>[at-4,op]),sharedOwnershipCheck:[[4,0xc8dffd28]]});s=exact(s,"['progressDrive',1116]","['progressDrive',1112]");s=exact(s,'67d8d73e4219b38351af15dc1b038d210c4b761843e6d0183d837baf3299171f','9648d971bcbe9c81f3cfdb18091fccdfb80c7c429d922c77112dc896a8b60741');s=exact(s,' return{...inherited,'," const owned=compiled.progressDrive.readUInt32LE(560);assert.equal((owned&0xfc000000)>>>0,0x94000000);assert.equal(symbols.progressDrive.address+560+((owned<<6)>>4),symbols.sharedOwnershipCheck.address);\n return{...inherited,");out['lock-metrics-progress-inputs-proof.mjs']=s; out['lock-metrics-progress-proof.mjs']=text('smp-progress-proof.mjs').replaceAll('./smp-progress-publication-proof.mjs','./lock-metrics-publication-proof.mjs').replaceAll('./smp-progress-frame-proof.mjs','./lock-metrics-frame-proof.mjs').replaceAll('./smp-progress-inputs-proof.mjs','./lock-metrics-progress-inputs-proof.mjs');return out; }