oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Check the pinned programs before either versioned release is built.
3
4internal/release/manifest.json pins the four programs this repository does
5not build: claude, codex, codex-code-mode-host and bwrap. A release is
6refused unless the manifest, the pins in the provider packages and the
7programs installed on this machine all name the same bytes. The tool
8proxy is not pinned here: it is built with the release, and its digest is
9recorded then (scripts/runner-install-manifest.py).
10"""
11import hashlib
12import json
13import os
14from pathlib import Path
15import re
16import subprocess
17import sys
18
19root = Path(__file__).resolve().parent.parent
20variables = {"claude": "EQUIPO_CLAUDE_PATH", "codex": "EQUIPO_CODEX_PATH",
21 "codex-code-mode-host": "EQUIPO_CODEX_CODE_MODE_HOST_PATH", "bwrap": "EQUIPO_BWRAP_PATH"}
22
23
24def require(condition):
25 if not condition:
26 raise ValueError("release pins do not agree")
27
28
29def digest(path):
30 with path.open("rb") as source:
31 return hashlib.file_digest(source, "sha256").hexdigest()
32
33
34def constant(path, name):
35 found = re.search(r'\b' + name + r'\s+= "([^"]+)"', (root / path).read_text())
36 require(found)
37 return found[1]
38
39
40try:
41 subprocess.run([sys.executable, str(root / "scripts/plan3-copy-check.py")], check=True)
42 manifest = json.loads((root / "internal/release/manifest.json").read_text())
43 require(manifest["schema"] == 3 and manifest["runner_target"] == "linux/amd64")
44 require(manifest["launcher_version"] == constant("internal/runner/provider/types.go", "LauncherVersion"))
45 require(manifest["policy_version"] == constant("internal/runner/provider/policy.go", "PolicyVersion"))
46 require(manifest["bwrap_version"] == "0.11.0")
47 require(manifest["claude"] == constant("internal/runner/provider/types.go", "ClaudeVersion"))
48 require(manifest["codex"] == constant("internal/runner/provider/types.go", "CodexVersion"))
49 require([b["name"] for b in manifest["binaries"]] == list(variables))
50 for artifact in manifest["binaries"]:
51 name = artifact["name"]
52 path = Path(os.environ[variables[name]])
53 require(path.is_absolute() and path.is_file() and os.access(path, os.X_OK))
54 require(artifact["version"] == manifest[{"bwrap": "bwrap_version", "codex-code-mode-host": "codex"}.get(name, name)])
55 require(re.fullmatch(r"[a-f0-9]{64}", artifact["sha256"]) and digest(path) == artifact["sha256"])
56 if name == "bwrap":
57 require(subprocess.check_output([str(path), "--version"], timeout=5).decode().strip() == "bubblewrap 0.11.0")
58 else:
59 family = "codex" if name == "codex-code-mode-host" else name
60 pin = "CodeModeHostSHA256" if name == "codex-code-mode-host" else "ExecutableSHA256"
61 require(artifact["sha256"] == constant(f"internal/runner/provider/{family}/launcher.go", "const " + pin))
62except (ValueError, KeyError, OSError, TypeError, subprocess.SubprocessError):
63 sys.exit(1)
64