80 lines
5.1 KiB
Python
80 lines
5.1 KiB
Python
"""Build fixed metadata/job contract after synthetic acceptance; no target values."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import time
|
|
|
|
from r4bc_common import read, sha, checked, save, make_jobs
|
|
|
|
CODE = ('r4bc_common.py', 'r4bc_guard.py', 'r4bc_fit.py', 'r4bc_preflight.py',
|
|
'run_r4bc.py', 'prepare_r4bc.py', 'test_r4bc.py', 'r4bc_postfit.py',
|
|
'gre24_models.py', 's2_models/features.py', 's2_models/objectives.py',
|
|
's2_recovery_supervisor.py', 's2_recovery_monitoring.py', 's2_custody_common.py',
|
|
's2_custody_statistics.py', 'freeze_g1_components.py')
|
|
|
|
|
|
def prepare(root):
|
|
if root.exists(): raise FileExistsError('Existing R4bc root; inspect, never replace')
|
|
inventory_path = Path('artifacts/r4bc-planning-2026-11-16/metadata-inventory.json')
|
|
inventory = read(inventory_path)
|
|
sources = dict(inventory['source_sha256'])
|
|
sources[str(inventory_path)] = sha(inventory_path)
|
|
doc = 'docs/r4bc-execution-contract-2026-11-16.md'
|
|
checked(doc, '20271691c4831135921352222e4fe1be93e93d9d2ce3e970d3b052cc49f63942')
|
|
sources[doc] = sha(doc)
|
|
for p, digest in sources.items(): checked(p, digest)
|
|
roster = read('artifacts/s2-main-preparation-2026-11-15/final-roster.json')['parts']
|
|
v5 = read('artifacts/gre24-reproduction-2026-11-15/v5-models-continuation-2026-11-16/preparation-freeze.json')['successful']
|
|
labels = {r['case']: r for r in read('artifacts/s2-custody-evaluation-2026-11-15/custody/label-index.json')}
|
|
r4a = read('artifacts/r4a-labelled-recovery-2026-11-16/pass-predictions-freeze.json')['parts']
|
|
oldroot = Path('artifacts/s2-custody-evaluation-2026-11-15')
|
|
for name in ('prediction-index.json', 'predictions-complete.json', 'scoring-freeze.json'):
|
|
sources[str(oldroot/name)] = sha(oldroot/name)
|
|
oldindex = read(oldroot/'prediction-index.json'); proof = read(oldroot/'predictions-complete.json')
|
|
checked(oldroot/'prediction-index.json', proof['prediction_index_sha256'])
|
|
requested = [r for r in roster if r['included']]
|
|
bad = {r['component_id'] for r in requested if r['case'] not in v5}
|
|
parts = []
|
|
for r in sorted(requested, key=lambda r:r['case']):
|
|
if r['component_id'] in bad: continue
|
|
r = dict(r); case = r['case']; fold = next(a['fold'] for a in r['assignments'] if a['role']=='test')
|
|
r.update(v5_cache=v5[case], label=labels[case], r4a=r4a[case], historical_predictions={})
|
|
for pool in (25, 50, 100):
|
|
p = oldroot/'predictions'/str(fold)/f'fold{fold}-pool{pool}-R2'/(case+'.npz')
|
|
r['historical_predictions'][str(pool)] = dict(path=str(p), sha256=oldindex[str(p)])
|
|
parts.append(r)
|
|
if len(parts)!=552 or len({r['component_id'] for r in parts})!=204:
|
|
raise ValueError('Common preparation roster changed')
|
|
tests = []
|
|
for p in sorted(Path('artifacts/r4bc-acceptance-2026-11-16').glob('attempt-*/worker.receipt.json')):
|
|
tests.append(dict(path=str(p), sha256=sha(p), **read(p)))
|
|
if not tests or tests[-1]['status']!='PASS': raise ValueError('Synthetic acceptance missing')
|
|
for p,h in read(Path(tests[-1]['path']).parent/'accepted-source.json').items(): checked(p,h)
|
|
initial = 60.+sum(t['cpu_seconds'] for t in tests)
|
|
if time.process_time()>60 or initial>=7200: raise ValueError('Setup reserve exhausted')
|
|
root.mkdir(parents=True)
|
|
jobs = make_jobs(); save(root/'job-list.json', jobs)
|
|
c = dict(version='R4bc-shared-roster-five-steps-v1',
|
|
main_review=['1794832267.149719','1794833279.817489','1794833544.971179','1794833643.127119'],
|
|
reviewed_contract_commit='c98801f90d5c665638028d1aba67b1db0c5f74c0',
|
|
parts=parts, jobs=jobs, job_list_sha256=sha(root/'job-list.json'),
|
|
excluded_components=inventory['excluded_components'], source_sha256=sources,
|
|
code_sha256={str(Path('tools')/n):sha(Path('tools')/n) for n in CODE},
|
|
worker_cpus=[24,26,28,29], coordinator_cpu=25,
|
|
initial_setup_cpu_seconds=initial, acceptance=tests,
|
|
limits=dict(total_cpu_seconds=144000,setup_cpu_seconds=7200,fit_cpu_seconds=122400,
|
|
post_cpu_seconds=14400,setup_wall_seconds=10800,post_wall_seconds=21600,
|
|
total_rss_bytes=36*2**30,disk_bytes=100*2**30,workers=4,retries=0),
|
|
fit_limits=dict(cpu_seconds=1800,wall_seconds=3600,rss_bytes=8*2**30,disk_bytes=100*2**30),
|
|
pool_order=[100,50,25],arm_order=['H0p','H1','H2','H3','H4','A','Q'],
|
|
first_cell=2, hist_hpo_configs=12, precision_bridge=False,
|
|
postfit_gate='All fit terminal/checkpoints Git frozen; then predictions; then prediction/code Git freeze before cached test scoring',
|
|
new_decodes=0,gpu=False,old_sources_unchanged=True)
|
|
save(root/'contract.json',c)
|
|
save(root/'prepared.json',dict(status='READY_FOR_GUARDED_INPUT_PREFLIGHT_NO_FITS',contract_sha256=sha(root/'contract.json'),
|
|
initial_setup_cpu_seconds=initial, parts=552,components=204,jobs=len(jobs)))
|
|
print(str(root), sha(root/'contract.json'), flush=True)
|
|
|
|
|
|
if __name__=='__main__':
|
|
p=argparse.ArgumentParser();p.add_argument('root',type=Path);a=p.parse_args();prepare(a.root)
|