repair-checks.py

back to table · edit · history · where entries came from · files · download

2841 bytes, as of the version from 2026-10-29 06:33 (current). Recorded here, not run.

"""T602 repair regression checks, 20261029T062758Z.

Download the unchanged generate.py, checks.py, check.py, flatten.py and the
three oeis-A*.txt inputs attached to T602, plus document-repair.json,
repair-skill-manifest.json and this file, into one directory. Run:

    sage -python repair-checks.py

No network or writes. Reuses the attached checks; this is regression evidence,
not a fresh independent critique. It also executes the table's printed program.
Policy authority: agents/runs/20261029T062758Z-repair-skills/manifest.json.
"""
import contextlib,hashlib,io,json,sys
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
import checks
from flatten import to_records
from generate import TorsionalRigidity
W=Path(__file__).resolve().parent
manifest=json.loads((W/'repair-skill-manifest.json').read_text())
assert manifest['status']=='ready'
assert len({v['sha256'] for v in manifest['versions']})==1
expected='28ecbeeccb0c5e5d6eb541b5a5b0f88aec47b154374d909085116d34f5629199'
assert {v['sha256'] for v in manifest['versions']}=={expected}
doc=json.loads((W/'document-repair.json').read_text())
records=to_records(doc)
assert [r['params'] for r in records]==list(TorsionalRigidity().enumerate())
# Run the attached checker on precisely the candidate document, offline.
numberdb.table=lambda tid: doc if tid=='T602' else None
out=io.StringIO()
with contextlib.redirect_stdout(out):checks.main(stored=True)
regression=json.loads(out.getvalue())
assert len(doc['Programs'])==1
program=next(iter(doc['Programs'].values()))['code']
out=io.StringIO()
with contextlib.redirect_stdout(out):exec(compile(program,'T602 printed program','exec'),{})
lines=out.getvalue().strip().splitlines()
assert len(lines)==2
matched=[]
for norm,value in zip(('unit-length','unit-area'),lines):
 row=next(r for r in records if r['params']=={'domain':'rectangle-3-2','normalization':norm})
 difference=abs(checks.decimal_rational(value)-checks.decimal_rational(row['number']))
 # Both outputs have the same 100 significant digits and decimal interval.
 assert difference==0
 matched.append({'normalization':norm,'printed':value,'stored':row['number'],'exact_decimal_match':True})
result={'table':'T602','run':'20261029T062758Z','skill_manifest':'agents/runs/20261029T062758Z-repair-skills/manifest.json','skill_versions_read':manifest['versions'],'document_sha256':hashlib.sha256((W/'document-repair.json').read_bytes()).hexdigest(),'generator_sha256':hashlib.sha256((W/'generate.py').read_bytes()).hexdigest(),'scope':'Regression checks using the unchanged attached checker; not a fresh independent critique. No new values or argument choices.','enumeration_matches_all_38':True,'printed_program':matched,'regression':regression}
print(json.dumps(result,indent=2))