File size: 4,859 Bytes
2f49b29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
"""Report whether the current POSA Bench bundle is preview- or rank-ready."""

from __future__ import annotations

import argparse
import hashlib
import json
from pathlib import Path


BENCHMARK = Path(__file__).resolve().parents[1]
REVIEWED = BENCHMARK / "review" / "results"
PUBLIC_MANIFEST = BENCHMARK / "huggingface" / "dataset" / "preview-v0.1.0-manifest.json"
FROZEN_RELEASE = BENCHMARK / "releases" / "preview-v0.1.0"
EXPECTED_MODELS = 4
REQUIRED_SEEDS = {17, 29, 41}


def digest(path: Path) -> str:
    value = hashlib.sha256()
    with path.open("rb") as handle:
        for block in iter(lambda: handle.read(1024 * 1024), b""):
            value.update(block)
    return value.hexdigest()


def verify_manifest(manifest_path: Path, root: Path, source_field: str = "path") -> tuple[bool, str]:
    if not manifest_path.is_file():
        return False, f"missing {manifest_path.relative_to(BENCHMARK)}"
    manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
    errors = []
    for entry in manifest.get("files", []):
        source = root / entry[source_field]
        if not source.is_file():
            errors.append(f"missing {entry[source_field]}")
        elif source.stat().st_size != entry["bytes"] or digest(source) != entry["sha256"]:
            errors.append(f"hash mismatch {entry[source_field]}")
    return not errors, "; ".join(errors) if errors else f"{len(manifest.get('files', []))} hashes verified"


def check() -> tuple[list[tuple[str, bool, str]], list[tuple[str, bool, str]]]:
    reviewed_paths = sorted(REVIEWED.glob("*.reviewed.json"))
    reviewed = [json.loads(path.read_text(encoding="utf-8")) for path in reviewed_paths]
    frozen_ok, frozen_note = verify_manifest(FROZEN_RELEASE / "manifest.json", FROZEN_RELEASE / "snapshot")
    public_ok, public_note = verify_manifest(PUBLIC_MANIFEST, BENCHMARK, "source")
    tracks = {item.get("track") for item in reviewed}
    statuses = {item.get("eligibility", {}).get("status") for item in reviewed}
    required_quality = {
        "semantic_claim_recall", "critical_fact_coverage_global", "safety_rate", "strict_pass_rate"
    }
    preview = [
        ("Frozen baseline", frozen_ok, frozen_note),
        ("Curated public manifest", public_ok, public_note),
        ("Four reviewed candidates", len(reviewed) == EXPECTED_MODELS, f"found {len(reviewed)}"),
        (
            "Fixed-context isolation",
            tracks == {"fixed-context-common-runtime"},
            ", ".join(str(value) for value in sorted(tracks)),
        ),
        ("Explicitly unranked", statuses == {"unranked-preview"}, ", ".join(str(value) for value in statuses)),
        (
            "Reviewed metric completeness",
            all(required_quality <= set(item.get("quality", {})) for item in reviewed),
            "four publication metrics required",
        ),
    ]

    seeds_by_run = {
        item.get("run_id"): set(item.get("protocol", {}).get("seeds", [])) for item in reviewed
    }
    repetitions_ok = bool(reviewed) and all(
        int(item.get("protocol", {}).get("repetitions", 0)) >= 3
        and seeds_by_run[item.get("run_id")] >= REQUIRED_SEEDS
        for item in reviewed
    )
    human_review_ok = bool(reviewed) and all(item.get("review", {}).get("official") is True for item in reviewed)
    thermal_ok = bool(reviewed) and all(
        item.get("protocol", {}).get("thermal_reset_verified") is True for item in reviewed
    )
    continuous_pss_ok = bool(reviewed) and all(
        item.get("protocol", {}).get("continuous_pss_sampling") is True for item in reviewed
    )
    official = [
        (
            "Three seeds per model",
            repetitions_ok,
            "; ".join(f"{run}: {sorted(seeds)}" for run, seeds in seeds_by_run.items()),
        ),
        ("Two blinded humans plus adjudication", human_review_ok, "current artifacts are single-AI review"),
        ("Verified thermal resets", thermal_ok, "not recorded in current protocol"),
        ("Continuous peak-PSS sampling", continuous_pss_ok, "current values are post-run observations"),
    ]
    return preview, official


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--target", choices=("preview", "official"), default="preview")
    args = parser.parse_args()
    preview, official = check()
    sections = [("Preview publication", preview)]
    if args.target == "official":
        sections.append(("Official ranking", official))
    for title, gates in sections:
        print(title)
        for name, passed, note in gates:
            print(f"  {'PASS' if passed else 'BLOCKED':7} {name}: {note}")
    selected = preview if args.target == "preview" else preview + official
    return 0 if all(passed for _, passed, _ in selected) else 1


if __name__ == "__main__":
    raise SystemExit(main())