SPB Git

spb/wp30_uqo

Public
1.8 KB · 27 lines python
1"""Protocol freeze: hash the confirmatory configuration (models, prompts, datasets, budgets, scorers, hypotheses, stats plan)."""2from __future__ import annotations3import json, yaml, hashlib, datetime as dt4from pathlib import Path5from .util import ROOT, sha256_file, sha256_text, write_json, utc_now67FROZEN_FILES = ["configs/models.yaml", "configs/data.yaml", "configs/resources.yaml", "src/wp30/prompts.py", "src/wp30/scoring.py", "src/wp30/data/synthetic.py",8                "src/wp30/data/exec_tasks.py", "src/wp30/methods/text.py", "src/wp30/cache/sparse.py", "src/wp30/cache/selection.py", "src/wp30/cache/serialize.py",9                "src/wp30/backends/mlx_backend.py", "src/wp30/runner.py", "src/wp30/chains.py", "src/wp30/fanin.py", "protocol/hypotheses.md", "protocol/analysis_plan.md",10                "data/manifests/splits.json"]1112def freeze(core_config: str) -> int:13    cfg = yaml.safe_load(open(core_config))14    files = {f: sha256_file(ROOT / f) for f in FROZEN_FILES if (ROOT / f).exists()}15    extra = {f: sha256_file(ROOT / f) for f in cfg.get("frozen_extra_files", []) if (ROOT / f).exists()}16    body = {"frozen_utc": utc_now(), "core_config": core_config, "core_config_sha256": sha256_file(ROOT / core_config), "files": {**files, **extra},17            "test_split_first_evaluation": "after this freeze; see runs/logs/*core*.log first timestamp", "hypotheses": (ROOT / "protocol/hypotheses.md").read_text()[:4000]}18    h = sha256_text(json.dumps(body["files"], sort_keys=True) + body["core_config_sha256"])19    body["protocol_hash"] = h20    write_json(ROOT / "protocol/frozen.json", body)21    print("protocol frozen:", h)22    return 02324def current_hash() -> str | None:25    p = ROOT / "protocol/frozen.json"26    return json.load(open(p))["protocol_hash"] if p.exists() else None27
Files · f4474e1b03aebffdfcd19ab989b35165571329e6
Menu

Theme