"""Claude1794738923: final process-count stops require a separate decision.""" from pathlib import Path from freeze_g1_components import sha from s2_custody_common import read_json from s2_recovery_supervisor import save def pending_finals(contract, receipts): pending=[] seen=set() for row in receipts: job=row['job'];i=job['index'] if i in seen or job!=contract['jobs'][i]:raise ValueError('Receipt duplicate or changed specification') seen.add(i) if job['kind']=='FINAL' and row['worker']['stop_reason']=='process_count_limit': pending.append(dict(index=i,cell=job['cell'],arm=job['arm'],fold=job['fold'],pool=job['pool'], worker=row['worker'],classification='FINAL_INFRASTRUCTURE_REVIEW_PENDING', scientific_cell_NA_adopted=False,recovery_authorized=False)) return pending def guard_final_policy(root,chain,contract): receipts=[];sources={} for job in contract['jobs']: if job['kind']!='FINAL':continue p=Path(root)/'jobs'/f"job-{job['index']:03d}"/'guard-result.json' if p.exists():receipts.append(read_json(p));sources[str(p)]=sha(p) pending=pending_finals(contract,receipts) if pending: save(Path(chain)/'awaiting-final-infra-ruling.json',dict(ruling='1794738923.689619',pending=pending, receipt_sha256=sources,original_raw_receipts_unchanged=True, raw_batch_NA_is_not_an_adopted_scientific_NA=True,predictions_and_scoring_blocked=True, no_fit_restart=True,no_recovery_without_further_explicit_ruling=True)) raise RuntimeError('FINAL_PROCESS_COUNT_REQUIRES_CLAUDE_RULING_BEFORE_PREDICTION_OR_SCORING')