Files
MeltMind/tools/prepare_s2_custody.py
T

49 lines
3.5 KiB
Python

"""Freeze approved custody plan without evaluating models or decoding labels."""
import json
from pathlib import Path
from freeze_g1_components import sha
from s2_recovery_supervisor import save
ROOT=Path('artifacts/s2-custody-evaluation-2026-11-15')
def main():
if ROOT.exists():raise FileExistsError('Do not overwrite evaluation')
freeze=Path('artifacts/s2-terminal-freeze-2026-11-15')
audit=json.loads((freeze/'terminal-audit.json').read_text())
assert audit['status']=='FROZEN_BEFORE_TEST_PREDICTIONS' and audit['primary_pairs_valid']==15
ncpath=Path('artifacts/s2-main-matrix-2026-11-15/training-contract.json');nc=json.loads(ncpath.read_text())
rcpath=Path('artifacts/s2-r2-main-2026-11-15/contract.json');rc=json.loads(rcpath.read_text())
paths=set(nc['code_sha256'])|set(rc['code_sha256'])
paths.update(str(p) for pattern in ['*s2_custody*.py'] for p in Path('tools').glob(pattern))
paths.update(['tools/audit_samples.py'])
membership='artifacts/s2-g1-components-2026-11-15/custodian/not-known-exposed-test-subsets.json'
exposure_audit='artifacts/s2-custody-planning-2026-11-15/exposure-audit.json'
sources=[str(freeze/'terminal-audit.json'),str(freeze/'models.json'),str(freeze/'evidence-manifest.json'),str(ncpath),str(rcpath),nc['roster'],membership,exposure_audit]
c=dict(version='S2-custody-v1',execution_approved=True,ruling='1794729482.815749',
main_review_required_before_prediction=True,roster=nc['roster'],roster_sha256=nc['roster_sha256'],
exposure_membership=membership,exposure_membership_sha256=sha(membership),exposure_audit=exposure_audit,
models=str(freeze/'models.json'),models_sha256=sha(freeze/'models.json'),
archive=nc['archive'],archive_stat=nc['archive_stat'],gpu_uuids=nc['gpu_uuids'],
cpu_affinities=nc['gpu_cpu_affinities'],code_sha256={p:sha(p) for p in sorted(paths)},
source_sha256={p:sha(p) for p in sources},
limits=dict(gpu_seconds=14400,fold_wall_seconds=2700,vram_bytes=15*2**30,host_bytes=16*2**30,
fold_disk_bytes=20*2**30,disk_bytes=100*2**30,custody_cpu_seconds=36000,custody_wall_seconds=10800,retries=0),
statistics=dict(replicates=2000,seed=2026111408,margin=.1,percentile_method='linear',
aggregation='parts equal within component, fixed seeds equal, pool components across folds',
complete_pair='all parts and all three fixed seeds in both arms; no backfill',
exposure='frozen522 membership inclUNKNOWN intersect roster intersect main validity; bool only cross-check',
bootstrap_rng='PCG64(SeedSequence(2026111408)); sorted component IDs, pooled not fold-stratified',
undefined_replicates='count and record, no replacement; interval left undefined if present',
secondary=['near_wall','kendall_tau_b','last_location','worst_component_per_arm'],
primary_pool=100,primary_contrast='1-E/N',kendall_seed=2026111410,kendall_pairs=5000),
planned_neural_cells=90,valid_neural_models=89,NA_neural=audit['neural_NA'],R2_models=15,
no_clipping=True,inference_precision='FP32 same as validation',target='T/t_set',
test_label_gate='All predictions hash-frozen, scoring code/config immutable Git commit and explicit main review receipt',
labels_decoded=False)
ROOT.mkdir();save(ROOT/'contract.json',c)
print(json.dumps(dict(root=str(ROOT),contract_sha256=sha(ROOT/'contract.json'),status='PREPARED_NOT_STARTED')))
if __name__=='__main__':main()