#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """Mutation guardrails for Phase-1.0Q public VideoOut evidence.""" from __future__ import annotations import argparse import copy import importlib.util from pathlib import Path import sys def load(path: Path): spec = importlib.util.spec_from_file_location("phase10q", path) assert spec and spec.loader module = importlib.util.module_from_spec(spec) sys.modules[spec.name] = module spec.loader.exec_module(module) return module def require(value: bool, message: str) -> None: if not value: raise RuntimeError(message) def main() -> int: parser = argparse.ArgumentParser() parser.add_argument("--root", type=Path, required=True) args = parser.parse_args() root = args.root.resolve() validator = load(root / "tools/validate_retroarch_phase10q.py") record = validator.load_json( root / "manifests/retroarch/phase-1.0q-public-videoout-evidence.json") cases = [] def case(name): def register(function): cases.append((name, function)) return function return register @case("01 authorizations remain false") def _(): require(validator.all_false(record["authorizations"], validator.AUTHORIZATION_FIELDS), "authority active") @case("02 target build authorization fails") def _(): value = dict(record["authorizations"]); value["target_build_authorized"] = True require(not validator.all_false(value, validator.AUTHORIZATION_FIELDS), "target build allowed") @case("03 automatic retry fails") def _(): value = dict(record["authorizations"]); value["automatic_retry"] = True require(not validator.all_false(value, validator.AUTHORIZATION_FIELDS), "retry allowed") @case("04 network scope is bounded") def _(): require(validator.network_scope_is_bounded(record["network_scope"]), "scope rejected") @case("05 arbitrary mirror fails") def _(): value = dict(record["network_scope"]); value["arbitrary_mirrors"] = True require(not validator.network_scope_is_bounded(value), "mirror accepted") @case("06 executed download fails") def _(): value = dict(record["network_scope"]); value["downloaded_code_executed"] = True require(not validator.network_scope_is_bounded(value), "execution accepted") @case("07 SDK remains symbol only") def _(): require(validator.sdk_evidence_is_symbol_only(record["sdk"]), "SDK rejected") @case("08 invented SDK header fails") def _(): value = dict(record["sdk"]); value["public_videoout_header"] = True require(not validator.sdk_evidence_is_symbol_only(value), "header invented") @case("09 SDL remains one lineage") def _(): require(validator.sdl_lineage_is_single(record["sdl_lineage"]), "SDL lineage rejected") @case("10 invented independent source fails") def _(): value = dict(record["sdl_lineage"]); value["independent_abi_source_cited"] = True require(not validator.sdl_lineage_is_single(value), "independence invented") @case("11 official archives do not corroborate") def _(): require(validator.archives_do_not_corroborate(record["official_project_archives"]), "archives rejected") @case("12 invented direct hit fails") def _(): value = copy.deepcopy(record["official_project_archives"]); value[0]["direct_videoout_hits"] = 1 require(not validator.archives_do_not_corroborate(value), "direct hit invented") @case("13 PS4 analogue is not promoted") def _(): require(validator.ps4_analogue_is_not_promoted(record["ps4_analogue"]), "PS4 boundary rejected") @case("14 PS4 promotion fails") def _(): value = dict(record["ps4_analogue"]); value["accepted_as_ps5_abi"] = True require(not validator.ps4_analogue_is_not_promoted(value), "PS4 accepted as PS5") @case("15 evidence matrix is fail closed") def _(): require(validator.evidence_matrix_is_fail_closed(record["evidence_matrix"]), "matrix rejected") @case("16 mode semantics promotion fails") def _(): value = dict(record["evidence_matrix"]); value["mode_one_semantics"] = "PROVEN_ON_PS5" require(not validator.evidence_matrix_is_fail_closed(value), "mode promoted") @case("17 decision is blocked") def _(): require(validator.decision_is_blocked(record["decision"]), "decision rejected") @case("18 parameter change fails") def _(): value = dict(record["decision"]); value["parameter_change_allowed"] = True require(not validator.decision_is_blocked(value), "parameter change allowed") @case("19 new VideoOut call fails") def _(): value = dict(record["decision"]); value["new_videoout_call_allowed"] = True require(not validator.decision_is_blocked(value), "new call allowed") @case("20 host research is not hardware evidence") def _(): require(record["tests"]["hardware_claim_from_host_test"] is False, "host research promoted") failures = [] for name, function in cases: try: function() print(f"PASS {name}") except Exception as error: # noqa: BLE001 - mutation harness failures.append(f"{name}: {error}") print(f"FAIL {name}: {error}") if failures: return 1 print(f"Phase-1.0Q guardrails passed: {len(cases)}") return 0 if __name__ == "__main__": raise SystemExit(main())