repair-check.py

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

1921 bytes, as of the version from 2026-10-31 10:42 (current). Recorded here, not run.

"""Verify T636's companion link against live snapshots, without writes.
Run: sage -python repair-check.py
Place beside generate.py, repair-table-before.json, repair-companion.json and repair-skill-manifest.json.
This checks all linked polynomials; it does not repeat the independent root audit.
"""
import hashlib
import json
from pathlib import Path
from generate import faber, ZX, X
from sage.env import SAGE_VERSION

work = Path(__file__).resolve().parent
roots = json.loads((work / 'repair-table-before.json').read_text())
companion = json.loads((work / 'repair-companion.json').read_text())
assert companion['Title'] == 'Hecke-type Faber polynomials of monstrous McKay–Thompson series'
assert faber('7B', 2) == X**2 - 4
assert faber('13B', 2) == X**2 + 2
assert faber('1A', 2) == X**2 - 393768
assert faber('7B', 2) != X**2 - 5  # Deliberately wrong control.
pairs = 0
entry_count = 0
for g, degrees in roots['Numbers'].items():
    for n, entries in degrees.items():
        p = faber(g, int(n))
        assert p == ZX(companion['Numbers'][g][n]), (g, n)
        assert p.degree() == int(n) and p.leading_coefficient() == 1
        pairs += 1
        entry_count += len(entries)
assert pairs == 99 and entry_count == 594
print(json.dumps({
    'table': 'T636', 'check': 'companion polynomial identity',
    'polynomials_checked': pairs, 'unchanged_root_entries': entry_count,
    'all_companion_polynomials_match': True,
    'known_answer_controls': 3, 'wrong_polynomial_control_rejected': True,
    'sage_version': SAGE_VERSION,
    'skill_manifest': 'agents/runs/20261031T103707Z-repair-skills/manifest.json',
    'skill_manifest_sha256': hashlib.sha256((work / 'repair-skill-manifest.json').read_bytes()).hexdigest(),
    'generator_sha256': hashlib.sha256((work / 'generate.py').read_bytes()).hexdigest(),
    'scope': 'No new roots or numerical claims; existing root intervals not recomputed.'
}, indent=2))