Files
MeltMind/tools/prepare_g1_candidate_registration.py
T

49 lines
4.2 KiB
Python

"""Freeze the counted <=4000 candidate queue under the already granted G1 budget."""
from pathlib import Path
import hashlib,json
from g1_register_candidates import ROOT
from s2_e1_supervisor import save
def sha(p):return hashlib.sha256(Path(p).read_bytes()).hexdigest()
def main():
source=Path('artifacts/s2-g1-candidates-2026-11-14');count=source/'public/candidate-count.json'
summary=json.loads(count.read_text());candidates=source/'custodian/candidate-pairs.json'
assert summary['status']=='CANDIDATES_COUNTED_NOT_REGISTERED' and summary['union_pairs']<=4000
assert sha(candidates)==summary['candidate_sha256']
pairs=json.loads(candidates.read_text())['pairs'];assert len(pairs)==summary['union_pairs']
assert pairs==sorted(pairs,key=lambda r:(r['min_rank'],r['a'],r['b']))
thresholds=Path('artifacts/s2-g1-copy-calibration-2026-11-14/public/calibration-thresholds.json')
assert sha(thresholds)==summary['calibration_thresholds_sha256']
t=json.loads(thresholds.read_text());assert t['status']=='CALIBRATION_THRESHOLDS_FROZEN'
ROOT.mkdir(exist_ok=False);private=ROOT/'custodian';private.mkdir(mode=0o700);(private/'results').mkdir();(ROOT/'public').mkdir()
cases=sorted({r[k] for r in pairs for k in ['a','b']});cache={}
for case in cases:
path=source/'custodian/fingerprints'/case/'geometry.npz';cache[case]={'path':str(path),'sha256':sha(path)}
save(private/'plan.json',{'jobs':pairs,'geometry_cache':cache,'candidate_sha256':sha(candidates),'ordering':'frozen min_rank, a, b'})
(private/'plan.json').chmod(0o600)
code=['prepare_g1_candidate_registration','g1_register_candidates','run_g1_registered_candidates','g1_registration_checkpoint',
'g1_registration_cost','g1_candidate_fingerprints','s2_e1_supervisor','audit_samples','boundary_distance']
c={'authorizing_rulings':['1794661944.308269','1794662380.787319','1794664166.242149','1794664685.158429','1794664857.650469'],
'count_report_before_registration':'1794664837.008399','pairs':len(pairs),'thresholds':t['thresholds'],
'code_sha256':{f'tools/{x}.py':sha(f'tools/{x}.py') for x in code},
'input_sha256':{str(p):sha(p) for p in [private/'plan.json',count,candidates,thresholds]},
'workers':16,'per_pair_wall_seconds':1800,'per_worker_rss_bytes':1342177280,
'aggregate_rss_bytes':20*1024**3,'worker_cpu_budget_seconds':100*3600,'wall_seconds':8*3600,'disk_bytes':20*1024**3,
'protocol':'Unchanged g1_registration_cost.register; both det branches, both routes, fixed 2000 area PPS, full triangle two-way P95',
'engineering_rule':'physical raw/mean Rg with ratio<=1.05, scale_free unchanged; best eligible route/threshold <=1 link; (1,2] band review; >2 outside rule, not certified unrelated',
'failure_policy':'retain failed attempts; check >2% at every 100 terminal jobs and final partial batch; no retries/replacements',
'first_100_checkpoint':'launch only first 100 fixed-rank pairs until all terminal; report mean CPU and >=14-start share and load-cache sensitivity; stop if projection>100 CPU-h or >=14-start share>85%',
'branch_label':'name better det branch only if residual strictly below route tau and other branch >2 times larger; otherwise branch-ambiguous (near-symmetric)',
'budget_accounting':'worker and supervision recorded separately; aggregate stop conservatively also includes supervision',
'simulation_fields_training_gpu':False,'components_frozen':False,
'pending_before_component_freeze':['anonymous threshold-band review; unresolved merges per ruling'],
'calibration_mirror_flags_closed_by':'1794664685.158429'}
save(ROOT/'contract.json',c)
save(ROOT/'public/preparation.json',{'status':'REGISTRATION_QUEUE_FROZEN_NOT_STARTED','pairs':len(pairs),'unique_parts':len(cases),
'contract_sha256':sha(ROOT/'contract.json'),'plan_sha256':sha(private/'plan.json'),'candidate_sha256':sha(candidates),
'thresholds_sha256':sha(thresholds),'workers':16,'worker_cpu_hours':100,'per_pair_minutes':30,
'count_previously_reported':True,'no_new_geometry_extraction':True,'no_new_approval_gate':True})
print((ROOT/'public/preparation.json').read_text())
if __name__=='__main__':main()