back to table · edit · history · where entries came from · files · download
4305 bytes, as of the version from 2026-10-24 20:04 (current). Recorded here, not run.
"""Reproduce the prose repair -- numberdb.org/T464.
By default, create T464-proposed.json from the adjacent T464-before.json.
Only Definition is changed. The existing numerical generator is retained.
python3 repair_t464.py
Campaign submission (API key on stdin, never in arguments or output):
cat "$NUMBERDB_KEY_FILE" | python3 repair_t464.py --apply
The write refuses to proceed if T464 is public, the live document differs
from the preserved input, or the independent checks did not pass. API
refusals stop this script without any retry or workaround.
"""
import json
from pathlib import Path
import sys
import urllib.error
import urllib.request
BASE = Path(__file__).resolve().parent
RUN = '20261024T200015Z-repair'
SUFFIX = r' This is the normalisation with $P_{3,1}=6\zeta(3)$.'
def proposed(before):
assert before['Definition'].endswith(SUFFIX)
assert '$6\\zeta(3)$' in before['Numbers']['3']['1']['comment']
after = dict(before)
after['Definition'] = before['Definition'][:-len(SUFFIX)]
assert [key for key in before if before[key] != after[key]] == ['Definition']
return after
def request(path, key='', body=None, method='GET', message=''):
assert path.startswith('/api/')
headers = {}
if key:
headers['Authorization'] = 'Bearer ' + key
if body is not None:
headers.update({
'Content-Type': 'application/json; charset=utf-8',
'X-Run-Id': RUN,
'X-Produced-By': 'Codex; T464 prose repair',
'X-Stage': 'repair',
'X-Engine': 'codex',
'X-Edit-Message': message,
})
req = urllib.request.Request('https://numberdb.org' + path, data=body,
headers=headers, method=method)
try:
with urllib.request.urlopen(req, timeout=60) as response:
data = response.read()
except urllib.error.HTTPError as exc:
data = exc.read()
(BASE / 'api-refusal.txt').write_bytes(data)
raise SystemExit('NumberDB refused the request: HTTP %s; stopped.' % exc.code)
return json.loads(data)
def ensure_private(key):
anonymous = request('/api/table?id=T464')
if anonymous != {'error': "Table with id 'T464' does not exist."}:
raise SystemExit('T464 is publicly accessible or its state is unclear; stopped.')
return request('/api/table?id=T464', key)
def save_json(name, value):
(BASE / name).write_text(json.dumps(value, ensure_ascii=False, indent=2) + '\n')
if __name__ == '__main__':
before = json.loads((BASE / 'T464-before.json').read_text())
after = proposed(before)
save_json('T464-proposed.json', after)
print('Definition before:', before['Definition'])
print('Definition after:', after['Definition'])
if '--apply' in sys.argv:
checks = json.loads((BASE / 'check_t464_repair.json').read_text())
assert checks['checked_entries'] == 9
assert all(row['strictly_inside_stored_interval'] for row in checks['results'])
assert checks['negative_controls'] == 'passed'
key = sys.stdin.read().strip()
assert key, 'API key is required on stdin.'
current = ensure_private(key)
if current != before or list(current) != list(before):
raise SystemExit('The live table changed after inspection; stopped.')
response = request(
'/api/table/T464', key,
json.dumps(after, ensure_ascii=False).encode(), 'PUT',
'The integral fixes normalization; retain the special value in its entry and formula.',
)
save_json('T464-write-response.json', response)
print(json.dumps(response))
stored = request('/api/table?id=T464', key)
save_json('T464-after.json', stored)
assert stored == after
assert list(stored['Parameters']) == list(before['Parameters'])
assert json.dumps(stored['Numbers']) == json.dumps(before['Numbers'])
audit = request('/api/table/T464/audit', key)
save_json('T464-audit-after.json', audit)
print('Audit:', json.dumps(audit))
assert audit['clean'] and audit['findings'] == []
ensure_private(key)
print('Readback matches the single-sentence deletion; all 852 entries are unchanged; draft remains private.')