50 lines
5.5 KiB
Python
50 lines
5.5 KiB
Python
"""Prepare the sole labelled recovery metadata/binding; no training or GPU work."""
|
|
import copy,time
|
|
from pathlib import Path
|
|
from phase2_h1_worker_v2 import sha,checked,save
|
|
from phase2_home_freeze_io import verify
|
|
from track_a_h2_common import read,config as old_config
|
|
from track_a_h2_prepare import local_code_closure
|
|
from track_a_recovery_common import OLD,ROOT,ORIGINAL,reuse_identity,project_total
|
|
|
|
B=Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def main():
|
|
start=time.process_time()
|
|
if ROOT.exists():raise FileExistsError('Existing recovery entry; never duplicate')
|
|
old,_=old_config(ORIGINAL);audit=read(checked(ORIGINAL/'infrastructure-stop-audit.json','d0433cb52d2695fcc5a9bb885521ff7fda2aea17524e894e7218d23a75ebe1ea'))
|
|
verify(ORIGINAL,'infrastructure-stop');done=read(ORIGINAL/'complete.json')
|
|
if done['status']!='STOPPED' or done['training_gpu_seconds']!=OLD:raise ValueError('Original stopped ledger')
|
|
models=[]
|
|
for m in audit['checkpoints']:
|
|
i=m['job'];e=next(e for e in done['entries'] if e['id']==i)
|
|
models.append(dict(job=i,path=m['path'],sha256=m['sha256'],standardization=m['standardization'],standardization_sha256=m['standardization_sha256'],origin='ORIGINAL_HASH_REUSE',training_contract_sha256=sha(ORIGINAL/'contract.json'),guard_complete_sha256=e['guard_complete_sha256']))
|
|
sources={**old['source_sha256'],**old['code_sha256']}
|
|
for name in ['contract.json','complete.json','global-stop.json','terminal-ledger.json','infrastructure-stop-audit.json','infrastructure-stop-git-freeze.json','infrastructure-stop-authorization.json','review.json']:
|
|
sources[str(ORIGINAL/name)]=sha(ORIGINAL/name)
|
|
for m in models:
|
|
for key in ['path','standardization']:sources[m[key]]=sha(m[key])
|
|
for name in ['result.json','standardization.json']:
|
|
p=ORIGINAL/'jobs'/str(m['job'])/'worker'/name;sources[str(p)]=sha(p)
|
|
p=ORIGINAL/'jobs'/str(m['job'])/'complete.json';sources[str(p)]=sha(p)
|
|
post=ORIGINAL.with_name('track-a-postfit-2026-11-18')
|
|
for name in ['contract.json','review.json','expected-review-binding.json','implementation-git-freeze.json']:
|
|
sources[str(post/name)]=sha(post/name)
|
|
codes=local_code_closure([B/'tools'/n for n in ['track_a_recovery_common.py','track_a_recovery_monitor.py','track_a_recovery_supervisor.py','track_a_recovery_guard.py','track_a_recovery_queue.py','track_a_recovery_worker.py','prepare_track_a_recovery.py','test_track_a_recovery.py']])
|
|
comparison=dict(approval='1795000626.905989',monitor_ruling='1795000465.748129',original_contract_sha256=sha(ORIGINAL/'contract.json'),original_scientific_comparison_sha256=old['comparison_contract_sha256'],reused_folds=[0,1,2],fresh_seed0_folds=[3,4],epochs=200,last_epoch_only=True,interrupted_weights_reused=False,old_gpu_seconds_once=OLD,cumulative_gpu_cap=162000,new_train_cap=154800-OLD,postfit_reserve=7200,per_new_job_cap=30960,
|
|
monitoring=dict(gpu_timeout_seconds=10,failed_samples=3,consecutive_per_operation=True,all_failures_logged=True,valid_sample_resets_own_streak=True,missing_sample_is_not_breach=True,observed_resource_breach_immediate=True,fast_local_checks_independent_of_gpu_query=True,worker_supervisor_tolerance_same_rule=True),
|
|
isolation='Failed worker, query monitor, own projection or own idle cap affects only its fold; cumulative resource/source integrity/operator stop remains global',
|
|
idle='Original assigned GPU2/3 only; actual idle sample then3guard idle samples; busy pending waits are charged per waiting fold inside own30960 and total budget; no interference with seed1',
|
|
no_further_recovery=True,postfit=dict(original_review_sha256=sha(post/'review.json'),exact_binding_compatible=False,reason='Original postfit pins stopped old root and requires old five new workers. Mixed original/recovery checkpoints have two training-contract identities and tolerable logged sampling errors. Identity-only new postfit binding required before any test access; original statistics/pairing stay unchanged.',partial_cohort_scoring_authorized=False,auto_start=False))
|
|
c=copy.deepcopy(old)
|
|
c.update(version='track-a-labelled-infrastructure-recovery-v1',approval='1795000626.905989',monitor_ruling='1795000465.748129',original_root=str(ORIGINAL),original_contract_sha256=sha(ORIGINAL/'contract.json'),recovery_number=1,recovery_folds=[3,4],reused_folds=[0,1,2],reused_models=models,new_fits=2,no_further_recovery=True,old_gpu_seconds_once=OLD,train_gpu_cap=154800-OLD,gpu_query_timeout_seconds=10,consecutive_failed_samples=3,job_failure_isolated=True,source_sha256=sources,code_sha256=codes,postfit='No automatic execution; original postfit exact identity incompatible; explicit new identity binding must retain original statistics and complete-five gate',no_auto_launch=True)
|
|
reuse_identity(c);assert project_total(c,{}, {},{})['status']=='PASS'
|
|
ROOT.mkdir();save(ROOT/'comparison-contract.json',comparison)
|
|
c.update(comparison_contract=str(ROOT/'comparison-contract.json'),comparison_contract_sha256=sha(ROOT/'comparison-contract.json'))
|
|
save(ROOT/'contract.json',c)
|
|
save(ROOT/'preparation-receipt.json',dict(status='PREPARED_PENDING_NARROW_DELTA_REVIEW',unix=time.time(),metadata_cpu_seconds=time.process_time()-start,original_STOP_preserved=True,reused_models_hashed=3,model_values_loaded=False,scientific_arrays_decoded=False,target_values_read=False,gpu_query_performed=False,training_started=False,postfit_started=False,code_files=len(codes),source_files=len(sources),initial_projection=project_total(c,{}, {},{})))
|
|
print(read(ROOT/'preparation-receipt.json'))
|
|
|
|
if __name__=='__main__':main()
|