#!/usr/bin/env python3 """Verify the public LakeIce clean-room quickstart, packet and draft bridge.""" from __future__ import annotations import hashlib import json from pathlib import Path import sys EXPECTED_PACKET = "6ae81c8a8c6ffafc6e8378a6908547d479cdcd81036385529e0432fc7528e0cb" EXPECTED_ADAPTER = "c02f9936dbd343e7d1a6e667a639528933ee743789b279d2ca30f9fc61641a75" EXPECTED_DECLARATIONS = "fa9b9edc9091cee2aa1ac8452905d94c08982166c6278c2b9867946cc2cf9066" EXPECTED_TASK_FILE = "75cf12ea44c0f8ec94b880967e6300167b424c8f7666fd8b59456f36d2a19c5c" EXPECTED_CATALOG_TASK = "149e7e4b190a62966be869851f150c43efc006546c1969d2fa4937804615c88f" FALSE_CLAIMS = { "account_created", "automatic_execution", "network_submission", "outside_result_received", "reviewer_identity_verified", "reviewer_independence_verified", "independent_validation", "scientific_discovery", "payment_authorship_or_patent_interest_promised", } def digest(path: Path) -> str: if path.is_symlink() or not path.is_file(): raise ValueError(f"expected regular non-symlink file: {path.name}") return hashlib.sha256(path.read_bytes()).hexdigest() def main() -> None: base = Path(__file__).resolve().parent manifest = Path(sys.argv[1]) if len(sys.argv) > 1 else base / "lakeice-cleanroom-quickstart.json" packet = Path(sys.argv[2]) if len(sys.argv) > 2 else base / "lakeice-cleanroom-onefit-pack.zip" value = json.loads(manifest.read_text(encoding="utf-8")) if value.get("schema_version") != "kiwerb-lakeice-cleanroom-quickstart-v1": raise ValueError("wrong schema") if value.get("mode") != "public_static_offline_cleanroom" or value.get("human_control_required") is not True: raise ValueError("unsafe mode") if set(value.get("claims", {})) != FALSE_CLAIMS or any(value["claims"].values()): raise ValueError("claims must remain exact and false") external = value.get("external_validation_status", {}) expected_external = { "bounded_search_only": True, "search_exhaustive": False, "adjacent_benchmark_integrity_issue_open": True, "task_uses_questioned_results_sheet": False, "issue_independently_reproduced_by_kiwerb": False, "independent_validation": False, "scientific_discovery": False, } if any(external.get(key) != expected for key, expected in expected_external.items()): raise ValueError("external evidence boundary drift") actual_packet = digest(packet) if value.get("packet", {}).get("sha256") != EXPECTED_PACKET or actual_packet != EXPECTED_PACKET: raise ValueError("packet hash mismatch") if value["packet"].get("bytes") != packet.stat().st_size: raise ValueError("packet byte length mismatch") bridge = value.get("validation_draft_bridge", {}) expected_bridge = { "cleanroom_task_file_sha256": EXPECTED_TASK_FILE, "catalog_task_slug": "lakeice-model-onefit", "catalog_task_sha256": EXPECTED_CATALOG_TASK, "allowed_scope": "bounded_offline_research", "adapter_sha256": EXPECTED_ADAPTER, "declarations_template_sha256": EXPECTED_DECLARATIONS, "required_local_artifact_roles": [ "independent_source_code", "run_log", "row_level_predictions", ], "network_requests": 0, "files_uploaded": 0, "output_status": "offline_draft_not_submitted_or_validated", "submission_enabled": False, "reviewer_identity_verified": False, "independent_validation_claimed": False, "discovery_claimed": False, } if any(bridge.get(key) != expected for key, expected in expected_bridge.items()): raise ValueError("validation draft bridge boundary drift") adapter_path = manifest.parent / Path(bridge.get("adapter_url", "")).name declarations_path = manifest.parent / Path(bridge.get("declarations_template_url", "")).name if digest(adapter_path) != EXPECTED_ADAPTER: raise ValueError("validation draft bridge adapter hash mismatch") if digest(declarations_path) != EXPECTED_DECLARATIONS: raise ValueError("validation draft bridge declarations hash mismatch") print(json.dumps({ "status": "offline_quickstart_packet_and_validation_bridge_verified", "packet_sha256": actual_packet, "adapter_sha256": EXPECTED_ADAPTER, "declarations_template_sha256": EXPECTED_DECLARATIONS, "network_requests": 0, "files_uploaded": 0, "scientific_validation_claimed": False, "discovery_claimed": False, })) if __name__ == "__main__": main()