Files
MeltMind/tools/prepare_phase2_gate_continued_postfit.py
T

42 lines
6.0 KiB
Python

"""Freeze new full-review postfit identity while160-part geometry continues."""
import json,shutil,time
from pathlib import Path
from phase2_fixed_io import BASE
from phase2_h1_worker_v2 import checked,sha,save
from phase2_home_freeze_io import verify,freeze
from phase2_gate_outcome_continuation import config as continuation_config
from phase2_gate_continued_postfit_common import config,COMPARISON,TOTAL,read
def main():
root=Path('/home/frank14f/MeltMind-runs/phase2-gate-outcome-v2-continuation-postfit-2026-11-17')
if root.exists():raise FileExistsError('Existing continued postfit; inspect not duplicate')
controot=Path('/home/frank14f/MeltMind-runs/phase2-gate-outcome-v2-continuation-2026-11-17');cont,prep,old_done=continuation_config(controot);launch=verify(controot,'launch');oldroot=Path(cont['original_root']);priorroot=Path('/home/frank14f/MeltMind-runs/phase2-gate-outcome-v2-postfit-2026-11-17');priorproof=verify(priorroot,'implementation');prior=read(priorroot/'contract.json')
if launch['commit']!='f5c088d2cd4a2bbb10e31307eda5b0beb654b760' or cont['total_cpu_seconds']!=TOTAL:raise ValueError('Exact labelled continuation identity')
if priorproof['commit']!='11af54fb5b1dc17f15b84e1c0076d13295611bf4' or (priorroot/'started.json').exists():raise ValueError('Original postfit unchanged and never started')
verify(oldroot,'comparison-contract');checked(oldroot/'comparison-contract.json',COMPARISON);cmp=read(oldroot/'comparison-contract.json')
if prior['comparison_contract_sha256']!=COMPARISON or cmp['preparation_contract_sha256']!=cont['original_contract_sha256']:raise ValueError('Exact original6b79 comparison identity')
sources=dict(prior['source_sha256'])
for p in [priorroot/'contract.json',priorroot/'implementation-git-freeze.json',controot/'contract.json',controot/'launch-git-freeze.json',controot/'reused-manifest.json',oldroot/'complete.json']:
if str(p) in sources and sources[str(p)]!=sha(p):raise ValueError('Source conflict')
sources[str(p)]=sha(p)
for p,h in sources.items():checked(p,h) # Opaque hashes; original score values remain unread.
codes={}
for old in [prior,cont]:
for p,h in old['code_sha256'].items():
path=str((BASE/Path(p)).resolve())
if path in codes and codes[path]!=h:raise ValueError('Pinned code conflict')
checked(path,h);codes[path]=h
for name in ['phase2_gate_continued_postfit_common.py','phase2_gate_continued_postfit.py','prepare_phase2_gate_continued_postfit.py','test_phase2_gate_continued_postfit.py']:
p=BASE/'tools'/name;codes[str(p)]=sha(p)
doc=BASE/'docs/phase2-gate-continued-postfit-2026-11-17.md';codes[str(doc)]=sha(doc)
log=Path('/tmp/gate-continued-postfit-synthetic-attempt1.log').read_text()
if 'Ran 24 tests' not in log or not log.rstrip().endswith('OK'):raise ValueError('Actual24 synthetic PASS required')
c=dict(version='gate-v2-continued-postfit-v1',approval='1794927974.092359',comparison_approval='1794917650.044649',postfit_root=str(root),total_cpu_seconds=TOTAL,postfit_cpu_seconds=3600,setup_cpu_seconds=120,worker_cpu=8,disk_bytes=3*2**30,new_fits=0,candidate_label_reads=0,preparation_root=str(controot),preparation_contract=str(controot/'contract.json'),original_preparation_root=str(oldroot),original_preparation_contract=str(oldroot/'contract.json'),continuation_implementation=launch['commit'],comparison_contract=str(oldroot/'comparison-contract.json'),comparison_contract_sha256=COMPARISON,comparison_rule=cmp['rule'],bands=cmp['bands'],parts=prior['parts'],original_score=prior['original_score'],source_sha256=sources,code_sha256=codes,new_prediction_parts=493,exact_reuse_parts=52,invalid_gate_parts=7,canonical_terminal_required=dict(original_reused=333,new=160,total=493),predictions_freeze_before_score=True,actual_new_full_semantic_PASS_required=True,no_retry=True,no_auto_launch=True,old_PASS_reused=False)
root.mkdir();save(root/'contract.json',c);shutil.copyfile('/tmp/gate-continued-postfit-synthetic-attempt1.log',root/'synthetic-attempt1.log')
save(root/'acceptance.json',dict(status='PASS',tests=24,elapsed_seconds=2.111,log_sha256=sha(root/'synthetic-attempt1.log'),test_source_sha256=sha(BASE/'tools/test_phase2_gate_continued_postfit.py'),scope='10 new canonical ledger/provenance/budget/read-order tests plus8 unchanged paired-statistic tests and6 actual temporary Git/file semantic-review tests; no actual arrays/targets/models/science run',unix=time.time(),setup_cpu_charge=120))
save(root/'preparation-audit.json',dict(status='PREPARED_NOT_LAUNCHED',unix=time.time(),continuation_implementation=launch['commit'],original_STOPPED_preserved=True,original_terminal_reused=333,continuation_expected=160,canonical_expected=493,exact_gate_reuse=52,invalid_kept_in_denominator=7,comparison_sha256=COMPARISON,models_opaque_hash_checked=10,old_score_values_read=False,targets_read=False,new_predictions=0,new_scores=0,feature_terminal_not_required_until_run=True,no_new_waiter=True,old_postfit_implementation_preserved=priorproof['commit'],actual_new_full_review_pending=True,S2_and_gate_pins_unchanged=True))
freeze(root,'implementation',[root/'contract.json',root/'acceptance.json',root/'preparation-audit.json',root/'synthetic-attempt1.log',oldroot/'comparison-contract.json',*[Path(p) for p in codes]])
proof=verify(root,'implementation');binding=dict(reviewed_commit=proof['commit'],contract_sha256=sha(root/'contract.json'),implementation_proof_sha256=sha(root/'implementation-git-freeze.json'),comparison_contract_sha256=COMPARISON,code_sha256=codes);save(root/'expected-review-binding.json',binding);freeze(root,'review-binding',[root/'contract.json',root/'expected-review-binding.json',root/'implementation-git-freeze.json',root/'implementation-authorization.json']);config(root)
print(json.dumps(dict(root=str(root),implementation_commit=proof['commit'],contract_sha256=sha(root/'contract.json'),implementation_proof_sha256=sha(root/'implementation-git-freeze.json'),comparison_sha256=COMPARISON,binding_sha256=sha(root/'expected-review-binding.json'),code_files=len(codes),actual_new_full_PASS_pending=True,launched=False)))
if __name__=='__main__':main()