Files
MeltMind/tools/prepare_s3b_ten.py

54 lines
3.1 KiB
Python

"""Metadata-only preparation of the already fixed ten, no label/data decode."""
import csv
import json
from pathlib import Path
import numpy as np
import scipy
from s2_recovery_supervisor import save
from s3b_runtime import ROOT, RULE, sha, read
from s3b_graph import SOLVER
def main():
if ROOT.exists(): raise FileExistsError('Never replace a S3-B batch')
roster_path=Path('artifacts/s2-main-preparation-2026-11-15/final-roster.json')
roster=read(roster_path)
rows={r['case']:r for r in roster['parts'] if r['included']}
if len(rows)!=617: raise ValueError('Roster changed')
plan_path=Path('artifacts/s2-e1-2026-11-14/preflight/ten_part_plan.csv')
plans=list(csv.DictReader(plan_path.open()))
if [int(v['numeric_prefix']) for v in plans]!=[1130,1324,842,367,746,777,1552,1379,610,666]:
raise ValueError('Fixed ten changed')
parts=[]
for plan in plans:
row=rows[plan['case']];p=row['preparation'];source=Path(p['preparation_root'])
inputs={str(source/name):p['output_sha256'][name] for name in ['geometry.npz','boundary_distance_raw.npy','base.npy']}
inputs[str(source/'result.json')]=p['result_sha256']
parts.append(dict(case=row['case'],nodes=row['nodes'],component_id=row['component_id'],
preparation_root=str(source),inputs=inputs))
accepted=Path('artifacts/s3b-a-synthetic-2026-11-15')
receipts=list(accepted.glob('attempt-*/synthetic.receipt.json'))
if not receipts or read(sorted(receipts)[-1])['status']!='PASS': raise ValueError('Synthetic acceptance missing')
tests_cpu=sum(read(p)['cpu_seconds'] for p in receipts)
source_paths=[roster_path,plan_path,Path('docs/s3b-a-contract-2026-11-15.md'),*receipts]
code=[*Path('tools').glob('*s3b*.py'),Path('tools/boundary_distance.py'),
Path('tools/s2_recovery_supervisor.py'),Path('tools/s2_recovery_monitoring.py')]
c=dict(version='S3B-a-exact-event-ten-v1',authorizing_ruling=RULE,
contract_review_commit='95ab07dcd6104e8cbb7afdcdd7ea1e18cdcaf9d2',
roster=str(roster_path),roster_sha256=sha(roster_path),ten_parts=parts,
all_cases=sorted(rows),total_nodes=sum(r['nodes'] for r in rows.values()),
solver=SOLVER,worker_cpu=16,coordinator_cpus=[30,31],
prior_synthetic_worker_CPU_s=tests_cpu,
limits=dict(total_worker_CPU_s=72000,postfit_reserve_CPU_s=7200,ten_CPU_s=10800,
part_CPU_s=1800,part_wall_s=1800,part_RSS_bytes=4*2**30,
ten_disk_bytes=5*2**30,total_disk_bytes=20*2**30,workers=1,processes_per_worker=1),
numpy_version=np.__version__,scipy_version=scipy.__version__,
label_policy='Exact geometry/base/distance/result file allowlist; audit-denied label/archive/cache reads',
stage='TEN_ONLY; after cost evidence continue already authorized preparation without restarting this queue',
source_sha256={str(p):sha(p) for p in source_paths},code_sha256={str(p):sha(p) for p in sorted(set(code))})
ROOT.mkdir();save(ROOT/'contract.json',c)
print(json.dumps(dict(root=str(ROOT),contract_sha256=sha(ROOT/'contract.json'),synthetic_CPU_s=tests_cpu)))
if __name__=='__main__':main()