LittlePlyResearch notebook

checkpoint_gate.py

python · 40 lines · Exact bytes

Line 1 ↗
Version & provenance · evaluation-cm7

Recorded SHA-256 0ce4692dd5a3b85fbc51f485c603bf655e8e01e9fd12437b5e849375d9d744e6Rendered SHA-256 0ce4692dd5a3b85fbc51f485c603bf655e8e01e9fd12437b5e849375d9d744e6

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"""Final loss-selected model plus fixed prepass/update1500 diagnostics."""
2import json,sys
3from pathlib import Path
4H=Path(__file__).resolve().parent;PROJECT=H.parent
5sys.path.insert(0,str(PROJECT/'cm7-theory-completion-v1'))
6from finalization import require_certified,checked_ref,sha,digest
7
8def validate_milestone(saved,contract):
9 mode=contract.get('diagnostic_milestone')
10 expected={None:('cm7-theory-completion-v1',None),'prepass':('cm7-theory-followup-v1',0),'update-1500':('cm7-theory-recovery-v1',1500)}
11 if mode not in expected:raise ValueError('undeclared milestone')
12 fmt,step=expected[mode]
13 if saved.get('format')!=fmt or (step is not None and saved.get('updates')!=step):raise ValueError('milestone format/update mismatch')
14
15def permitted(contract):
16 cp=PROJECT/'cm7-theory-completion-v1/config.json'
17 if str(cp)!=contract['followup_config'] or sha(cp)!=contract['followup_config_sha256']:raise ValueError('completion config changed')
18 cfg=json.loads(cp.read_text());selected=require_certified(cfg)
19 audit_path=PROJECT/'cm7-theory-completion-v1/terminal-audit.json'
20 if sha(audit_path)!=contract['completion_terminal_audit_sha256']:raise ValueError('terminal audit drift')
21 audit=json.loads(audit_path.read_text())
22 if audit['status']!='verified' or audit['owned_remaining'] or audit['selected_checkpoint']!=selected or audit['decision_exposures']!=1713765:raise ValueError('finite schedule not completely certified')
23 mode=contract.get('diagnostic_milestone')
24 if mode is None:
25  if contract.get('diagnostic_subset') is not None:raise ValueError('unexpected subset')
26  return cfg,selected
27 plan_path=PROJECT/'cm7-evaluation/mini-plan.json';plan=json.loads(plan_path.read_text())
28 if sha(plan_path)!=cfg['diagnostic_plan_sha256'] or mode not in plan['milestones'] or contract.get('diagnostic_subset')!=plan['opening_ids']:raise ValueError('predeclared mini contract')
29 if mode=='prepass':
30  stage=json.loads((PROJECT/'cm7-theory-followup/training-config.json').read_text());require_certified(stage)
31  ref=checked_ref(json.loads((Path(stage['output'])/'completion.json').read_text())['baseline_checkpoint'],stage['output'])
32  if ref!=cfg['preserved_prepass_checkpoint']:raise ValueError('prepass substitution')
33 else:
34  stage=json.loads((PROJECT/'cm7-theory-recovery-v1/config.json').read_text());require_certified(stage)
35  receipt=json.loads((Path(stage['output'])/'diagnostic-1500.json').read_text())
36  if receipt['updates']!=1500 or receipt['config_sha256']!=digest(stage):raise ValueError('intermediate identity')
37  ref=checked_ref(receipt['checkpoint'],stage['output'])
38  if ref!=cfg['preserved_intermediate_checkpoint']:raise ValueError('intermediate substitution')
39 return stage,ref
40