from pathlib import Path
import json
root=Path('artifacts/exchange-followup')
previous=Path('artifacts/exchange-redesign-20260908')
def rows(path):
    return {int(d['phase']):d for line in path.read_text().splitlines() if line.startswith('phase=') for d in [dict(f.split('=',1) for f in line.split())]}
results=[]
for name,old in [('b2-31','b2'),('million','b4-million'),('mlp','mlp'),('attention','attention')]:
    before=rows(previous/f'final-{old}.log')
    for version in ['final','refresh']:
        current=rows(root/f'{version}-{name}.log')
        assert len(current)==(4 if name=='mlp' else 21 if name=='attention' else 1)
        for phase,row in current.items():
            for key in ['horizonCycles','rowWords','maximumRowWords','rowFingerprint']:
                assert row[key]==before[phase][key],(version,name,phase,key)
            results.append({'version':version,'workload':name,**row})
(root/'results.json').write_text(json.dumps(results,indent=2)+'\n')
print('Both follow-up versions preserve exact row fingerprints and schedule metrics on all 27 checked phases.')
