back to table · edit · history · where entries came from · files · download
3400 bytes, as of the version from 2026-10-16 09:08 (current). Recorded here, not run.
"""Verify T459's title repair and preservation of its 32 entries.
python3 verify_repair.py < /path/to/numberdb-api-key
This checks the live private draft through the API and sends a small read-only
section preview to the live renderer. It changes nothing. It does not recompute
volumes: the SHA-256 compares every field except Title with the document read
before the cosmetic repair, including parameters, values and precision metadata.
The original mathematical generator and numerical checks remain attached.
"""
import hashlib
import json
import sys
import urllib.request
import urllib.parse
from html.parser import HTMLParser
EXPECTED_UNCHANGED_SHA256 = "656e6bac68947000f5e304267b60ecf905b442b7336c0680f27455d36cdfbd2a"
EXPECTED_TITLE = "Weil-Petersson volumes $V_{g,n}$ of the moduli spaces of hyperbolic surfaces"
key = sys.stdin.read().strip()
assert key, "Pipe your NumberDB API key on stdin to read a private draft."
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
def api(path):
assert path.startswith('/api/')
req = urllib.request.Request('https://numberdb.org' + path,
headers={'Authorization': 'Bearer ' + key})
with opener.open(req, timeout=45) as response:
return json.load(response)
class VisibleText(HTMLParser):
def __init__(self):
super().__init__()
self.skip = 0
self.parts = []
def handle_starttag(self, tag, attrs):
if tag in ('script', 'style', 'textarea'):
self.skip += 1
def handle_endtag(self, tag):
if tag in ('script', 'style', 'textarea'):
self.skip -= 1
def handle_data(self, data):
if not self.skip:
self.parts.append(data)
doc = api('/api/table?id=T459')
assert doc['Title'] == EXPECTED_TITLE
unchanged = {k: v for k, v in doc.items() if k != 'Title'}
digest = hashlib.sha256(json.dumps(unchanged, ensure_ascii=False,
separators=(',', ':')).encode()).hexdigest()
assert digest == EXPECTED_UNCHANGED_SHA256, "Another field or its order changed"
assert list(doc['Parameters']) == ['g', 'n']
assert doc['Data properties']['digits'] == '100'
assert sum(len(group) for group in doc['Numbers'].values()) == 32
section = {key: doc[key] for key in ('Title', 'Parameters')}
section['Data properties'] = {key: doc['Data properties'][key] for key in ('type', 'digits')}
section['Numbers'] = {'0': {'3': doc['Numbers']['0']['3']}}
url = 'https://numberdb.org/preview?' + urllib.parse.urlencode({'table': json.dumps(section)})
with opener.open(url, timeout=45) as response:
html = response.read().decode()
parser = VisibleText()
parser.feed(html)
visible = ' '.join(' '.join(parser.parts).split())
assert EXPECTED_TITLE in visible
assert 'Weil--Petersson' not in visible
assert '100' in visible
# The renderer bug is reported, not required: a later site fix should pass.
unknown_key = 'digits: 100 (Unknown key)' in visible
audit = api('/api/table/T459/audit')
assert audit['clean'] and not audit['findings']
print(json.dumps({'tid': 'T459', 'title_fixed': True, 'unchanged_rows': 32,
'all_other_fields_and_order_unchanged': True,
'unchanged_document_sha256': digest,
'digits_unknown_key_still_rendered': unknown_key,
'audit_clean': True, 'numerical_recomputation': False}, indent=2))