#!/usr/bin/env python3 """Check the pinned programs before either versioned release is built. internal/release/manifest.json pins the four programs this repository does not build: claude, codex, codex-code-mode-host and bwrap. A release is refused unless the manifest, the pins in the provider packages and the programs installed on this machine all name the same bytes. The tool proxy is not pinned here: it is built with the release, and its digest is recorded then (scripts/runner-install-manifest.py). """ import hashlib import json import os from pathlib import Path import re import subprocess import sys root = Path(__file__).resolve().parent.parent variables = {"claude": "EQUIPO_CLAUDE_PATH", "codex": "EQUIPO_CODEX_PATH", "codex-code-mode-host": "EQUIPO_CODEX_CODE_MODE_HOST_PATH", "bwrap": "EQUIPO_BWRAP_PATH"} def require(condition): if not condition: raise ValueError("release pins do not agree") def digest(path): with path.open("rb") as source: return hashlib.file_digest(source, "sha256").hexdigest() def constant(path, name): found = re.search(r'\b' + name + r'\s+= "([^"]+)"', (root / path).read_text()) require(found) return found[1] try: subprocess.run([sys.executable, str(root / "scripts/plan3-copy-check.py")], check=True) manifest = json.loads((root / "internal/release/manifest.json").read_text()) require(manifest["schema"] == 3 and manifest["runner_target"] == "linux/amd64") require(manifest["launcher_version"] == constant("internal/runner/provider/types.go", "LauncherVersion")) require(manifest["policy_version"] == constant("internal/runner/provider/policy.go", "PolicyVersion")) require(manifest["bwrap_version"] == "0.11.0") require(manifest["claude"] == constant("internal/runner/provider/types.go", "ClaudeVersion")) require(manifest["codex"] == constant("internal/runner/provider/types.go", "CodexVersion")) require([b["name"] for b in manifest["binaries"]] == list(variables)) for artifact in manifest["binaries"]: name = artifact["name"] path = Path(os.environ[variables[name]]) require(path.is_absolute() and path.is_file() and os.access(path, os.X_OK)) require(artifact["version"] == manifest[{"bwrap": "bwrap_version", "codex-code-mode-host": "codex"}.get(name, name)]) require(re.fullmatch(r"[a-f0-9]{64}", artifact["sha256"]) and digest(path) == artifact["sha256"]) if name == "bwrap": require(subprocess.check_output([str(path), "--version"], timeout=5).decode().strip() == "bubblewrap 0.11.0") else: family = "codex" if name == "codex-code-mode-host" else name pin = "CodeModeHostSHA256" if name == "codex-code-mode-host" else "ExecutableSHA256" require(artifact["sha256"] == constant(f"internal/runner/provider/{family}/launcher.go", "const " + pin)) except (ValueError, KeyError, OSError, TypeError, subprocess.SubprocessError): sys.exit(1)