Files
MeltMind/tools/prepare_s3b_v04_continuation.py

66 lines
4.3 KiB
Python

"""Pin approved engineering continuation; copy three PASS bytes, never rerun."""
from pathlib import Path
import copy
import shutil
from s3b_v04_runtime import contract,read,sha,checked
from s2_recovery_supervisor import save
ROOT=Path('artifacts/s3b-a-v04-continuation-2026-11-15')
GATES=Path('artifacts/s3b-a-v04-gates-continuation-2026-11-15')
GUARD=Path('artifacts/s3b-a-v04-stage-guard-v2-2026-11-15')
def main():
if any(p.exists() for p in [ROOT,GATES,GUARD]):raise FileExistsError('Continuation already prepared')
old=Path('artifacts/s3b-a-v04-ten-2026-11-15');original=contract(old);terminal=read(old/'complete.json')
if terminal['stop_reason']!='COORDINATOR_INTERRUPTED' or terminal['attempts']!=3 or not terminal['account_complete']:
raise ValueError('Unexpected original terminal')
receipts=[];copies={}
for i in range(3):
p=old/'candidates/splu/parts'/f'part-{i:02d}';w=read(p/'guard-result.json');r=read(p/'output/result.json')
if w['classification']['category']!='PASS' or r['status']!='COMPLETE':raise ValueError('Not reusable')
checked(p/'output/result.json',w['files']['result']['sha256'])
for n,h in r['output_sha256'].items():checked(p/'output'/n,h)
w.update(reused_original=True,original_guard_result=str(p/'guard-result.json'),
original_guard_result_sha256=sha(p/'guard-result.json'),pressure_calls=r['pressure_calls'],
early_resolves=r['early_resolves'],dead_end_share=r['early_resolves']/r['pressure_calls'])
receipts.append(w);copies[i]=p
all_tests=[]
for name in ['s3b-a-v04-synthetic-2026-11-15','s3b-a-v04-stage-guard-tests-2026-11-15',
's3b-a-v04-gate-tests-2026-11-15','s3b-a-v04-recovery-tests-2026-11-15']:
paths=sorted((Path('artifacts')/name).glob('attempt-*/synthetic.receipt.json'))
if not paths or read(paths[-1])['status']!='PASS':raise ValueError('Final test acceptance missing')
all_tests.extend(paths)
c=copy.deepcopy(original)
c.update(version='S3B-a-v04-approved-seven-part-infrastructure-continuation',
engineering_ruling='1794748036.544479',stage_cap_ruling='1794747272.597049',
reused_receipts=receipts,new_synthetic_worker_CPU_s=sum(read(p)['cpu_seconds'] for p in all_tests),
inherited_original_stop=str(old/'complete.json'),inherited_original_stop_sha256=sha(old/'complete.json'),
never_attempted_indices=list(range(3,10)),scientific_implementation_unchanged='847a6f8ad2f87e9b09e1c5ad1720d200ce5e57e6',
candidate_stage_CPU_cap=10800,
stage='reuse first three PASS; only remaining seven same splu; original attributed solver fallback retained; stage reservation failure stops')
for n in ['run_s3b_v04_continue.py','s3b_v04_stage_guard_v2.py','prepare_s3b_v04_continuation.py','test_s3b_v04_continuation.py']:
p=Path('tools')/n;c['code_sha256'][str(p)]=sha(p)
sources=[old/'complete.json',Path('artifacts/s3b-a-v04-stage-guard-2026-11-15/failure.json'),
Path('artifacts/s3b-a-v04-gates-2026-11-15/complete.json'),*all_tests]
for p in sources:c['source_sha256'][str(p)]=sha(p)
ROOT.mkdir()
for i,p in copies.items():
dest=ROOT/'candidates/splu/parts'/f'part-{i:02d}';dest.parent.mkdir(parents=True,exist_ok=True)
shutil.copytree(p,dest)
for f in p.rglob('*'):
if f.is_file():checked(dest/f.relative_to(p),sha(f))
save(ROOT/'contract.json',c)
gc=copy.deepcopy(read('artifacts/s3b-a-v04-gates-2026-11-15/contract.json'))
gc.update(ten_root=str(ROOT),stage_guard_root=str(GUARD),additional_synthetic_CPU_s=0.,
engineering_ruling='1794748036.544479',ledger_note='All old/new synthetic costs, including failed attempt, are already in continuation ten ledger; do not add again')
gc['source_sha256'][str(ROOT/'contract.json')]=sha(ROOT/'contract.json')
GATES.mkdir();save(GATES/'contract.json',gc)
previous_science=sum(r['worker']['cpu_seconds'] for r in receipts)
print(dict(root=str(ROOT),contract_sha256=sha(ROOT/'contract.json'),gate_contract_sha256=sha(GATES/'contract.json'),
tests_CPU_s=c['new_synthetic_worker_CPU_s'],reused_science_CPU_s=previous_science,
cumulative_worker_CPU_s=c['old_worker_CPU_s']+c['new_synthetic_worker_CPU_s']+previous_science))
if __name__=='__main__':main()