freeze.py
python · 27 lines · Exact bytes
Version & provenance · theory-cm7
Recorded SHA-256 48353bd4ed70e7fb349957a2228b32ddfe4fdc7022f4d788526d8b9261d6c903Rendered SHA-256 48353bd4ed70e7fb349957a2228b32ddfe4fdc7022f4d788526d8b9261d6c903
Apache-2.0 original project code; dependencies retain their own licenses. License notes. Line links are stable within this snapshot. CM-7 completed implementation source; original and public rendered hashes recorded. Host-specific paths use /work placeholders; inspect reproduction instructions before running. Separate Rust helper retains its GPL license.
1"""Freeze only after the running recovery has cleanly terminated and been audited."""
2import json,uuid
3from pathlib import Path
4from finalization import sha,digest,require_certified
5H=Path(__file__).resolve().parent;R=H.parent/'cm7-theory-recovery-v1';cp=R/'config.json';source=json.loads(cp.read_text());root=Path(source['output']);selected=require_certified(source)
6audit=R/'terminal-audit.json';a=json.loads(audit.read_text())
7if a['status']!='verified' or a['owned_remaining'] or a['remaining_schedule']<=0:raise ValueError('no certified remaining schedule')
8import torch
9saved=torch.load(root/'last.pt',map_location='cpu',weights_only=True)
10cfg=dict(source);cfg.update(run_id=str(uuid.uuid4()),recovery_id='cm7-finite-completion-v1',output=str(Path(source['original_root'])/'completion-v1'),original_config=str(cp),original_config_sha256=sha(cp),original_identity_sha256=digest(source),source_checkpoint=str(root/'last.pt'),source_checkpoint_sha256=sha(root/'last.pt'),source_deadline=source['original_deadline'],source_audit=str(audit),source_cursor=a['decision_exposures'],source_updates=a['updates'],source_microstep=saved['microstep'],prior_selected=selected,budget_seconds=2400,checkpoint_margin_seconds=120,selection='minimum fixed pooled canonical-label NLL including inherited selected best; accuracy diagnostic only',optimizer_policy='continue exact last-state Adam/scheduler/both-rank RNG/sampler; no warmup reset; new explicitly authorized completion budget after old cleanup')
11paths=[cp,audit,root/'last.pt',root/'terminal.json',root/'completion.json',Path(source['original_deadline']),Path(selected['path'])]
12diagnostic=json.loads((root/'diagnostic-1500.json').read_text())
13if diagnostic['updates']!=1500 or sha(diagnostic['checkpoint']['path'])!=diagnostic['checkpoint']['sha256']:raise ValueError('intermediate checkpoint changed')
14cfg['preserved_intermediate_checkpoint']=diagnostic['checkpoint']
15paths += [root/'diagnostic-1500.json',Path(diagnostic['checkpoint']['path'])]
16prepass=json.loads((Path(source['original_root'])/'completion.json').read_text())['baseline_checkpoint']
17if sha(prepass['path'])!=prepass['sha256']:raise ValueError('prepass checkpoint changed')
18cfg['preserved_prepass_checkpoint']=prepass
19paths += [Path(source['original_root'])/'completion.json',Path(prepass['path'])]
20cfg['immutable_source_sha256']={str(p):sha(p) for p in paths}
21files=['train.py','owner.py','launch_approved.py','deadline.py','finalization.py','checkpoint.py','curriculum_loss.py','reader.py','stage_data.py','evaluation.py','optimizer_policy.py','resume_state.py']
22cfg['runtime_sha256']={**source['runtime_sha256'],**{str(H/n):sha(H/n) for n in files}}
23cfg['command']=['/bin/bash',str(H.parent/'elite-continuation-v1/run-training.sh'),str(H/'train.py'),str(H/'config.json')]
24with (H/'config.json').open('x') as f:json.dump(cfg,f,sort_keys=True,indent=2);f.write('\n')
25proposal={'config_sha256':sha(H/'config.json'),'config_identity_sha256':digest(cfg),'source_checkpoint_sha256':cfg['source_checkpoint_sha256'],'remaining_decisions':1713765-cfg['source_cursor'],'maximum_seconds':2400,'command':['/bin/bash',str(H.parent/'elite-continuation-v1/run-training.sh'),str(H/'owner.py'),str(H/'config.json'),str(H/'approval.json')],'status':'review required; no launch or approval'}
26(H/'execution-proposal.json').write_text(json.dumps(proposal,indent=2)+'\n');print(json.dumps(proposal,indent=2))
27