repair-check.py

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

2737 bytes, as of the version from 2026-10-30 20:20 (current). Recorded here, not run.

"""Check T630's displayed Sage program and stored intervals without writing.

Run beside the unchanged attached generate.py:
    sage -python repair-check.py
Set NUMBERDB_API_KEY for access to a private draft, or pipe the key into
NUMBERDB_KEY_FROM_STDIN=1 sage -python repair-check.py.
This reruns the author's certified generator; it is not an independent critique.
"""
import hashlib
import json
import os
from pathlib import Path
import sys
import numberdb.sage as numberdb
from sage.env import SAGE_VERSION
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from generate import MaclaurinAngularMomentum

key = sys.stdin.read().strip() if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1' else os.environ.get('NUMBERDB_API_KEY', '')
if '=' in key and key.split('=', 1)[0].isupper():
    key = key.split('=', 1)[1].strip().strip('\'"')
client = numberdb.Client(api_key=key) if key else None
doc = numberdb.table('T630', client=client)
collected = []
exec(compile(doc['Programs']['SageMath']['code'], '<T630 Programs>', 'exec'), {'print': lambda k, value: collected.append((k, value))})
assert [k for k, value in collected] == list(range(1, 11))
assert list(map(str, doc['Numbers'])) == [str(k) for k, value in collected]
assert [str(p['k']) for p in MaclaurinAngularMomentum().enumerate()] == list(map(str, doc['Numbers']))
F = RealBallField(700)
records = []
for k, value in collected:
    stored = doc['Numbers'][str(k)]
    text = stored['number'] if isinstance(stored, dict) else stored
    left, right = text.split('.')
    center = QQ(int(left + right))/QQ(10)**len(right)
    ulp = QQ(1)/QQ(10)**len(right)
    assert value.is_finite() and value > F(center - ulp) and value < F(center + ulp)
    assert F(value.rad()) < F(10)**(-118)
    records.append({'k': k, 'stored': text, 'enclosure': str(value), 'radius': str(value.rad()), 'entire_ball_in_written_interval': True})
evidence = {
    'table': 'T630', 'method': 'Execute the live displayed program with its unchanged generator; compare full propagated Arb balls with exact stored decimal intervals.',
    'independent_critique': False, 'sage_version': SAGE_VERSION, 'rows_checked': len(records),
    'generator_sha256': hashlib.sha256(Path(__file__).with_name('generate.py').read_bytes()).hexdigest(),
    'program_code_sha256': hashlib.sha256(doc['Programs']['SageMath']['code'].encode()).hexdigest(),
    'skill_manifest': 'agents/runs/20261030T201440Z-repair-skills/manifest.json',
    'local_skill_sha256': 'dedecbdca15a728b6e594bfa79f0d149896fca336080ac27b53f513e0b16cd2e',
    'live_skill_sha256': 'dedecbdca15a728b6e594bfa79f0d149896fca336080ac27b53f513e0b16cd2e',
    'results': records,
}
print(json.dumps(evidence, indent=2))