#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """Validate Phase-1.0AS against exact current upstream Git objects.""" from __future__ import annotations import argparse import hashlib import json import subprocess from pathlib import Path def git(repo: Path, *args: str) -> str: return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True).stdout.strip() def check(repo: Path, commit: str, path: str, blob: str, size: int) -> None: spec = f"{commit}:{path}" assert git(repo, "rev-parse", spec) == blob assert int(git(repo, "cat-file", "-s", spec)) == size def main() -> int: parser = argparse.ArgumentParser() parser.add_argument("--root", type=Path, required=True) parser.add_argument("--sdk-root", type=Path, required=True) parser.add_argument("--shsrv-root", type=Path, required=True) args = parser.parse_args() data = json.loads((args.root / "manifests/retroarch/phase-1.0as-channel-primitive-audit.json").read_text(encoding="utf-8")) b = data["source_bindings"] assert hashlib.sha256((args.root / "manifests/retroarch/phase-1.0ar-result-channel-model.json").read_bytes()).hexdigest() == b["phase10ar_manifest_sha256"] for prefix, path in (("sdk_sys_unistd", "include/freebsd/sys/unistd.h"), ("sdk_unistd", "include/freebsd/unistd.h"), ("sdk_poll", "include/freebsd/sys/poll.h"), ("sdk_time", "include/freebsd/sys/time.h")): check(args.sdk_root, b["sdk_commit"], path, b[f"{prefix}_blob"], b[f"{prefix}_size"]) for prefix, path in (("shsrv_shell", "sh.c"), ("shsrv_builtin", "builtin.c")): check(args.shsrv_root, b["shsrv_commit"], path, b[f"{prefix}_blob"], b[f"{prefix}_size"]) assert data["fd_ownership"]["official_shsrv_worker_uses_rfcfdg"] is True assert data["fd_ownership"]["result_fd_inherited_by_worker"] is False assert data["deadline_and_cleanup"]["absolute_monotonic_deadline_present"] is False assert not any(data["authorizations"].values()) assert data["decision"]["live_channel_architecture_feasible"] is False print("Phase-1.0AS channel primitive audit validation passed") return 0 if __name__ == "__main__": raise SystemExit(main())