Files
chimera-gfx-Public/tests/test_retroarch_phase10u.py
Chimera GFX release export a6037502d7
phase0-ci / build-and-audit (push) Successful in 2m14s
Publish Chimera GFX source
2026-09-03 03:27:14 +02:00

115 lines
4.3 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Mutation guardrails for the bounded Phase-1.0U local inventory."""
from __future__ import annotations
import argparse
import importlib.util
from pathlib import Path
import sys
def load(path: Path):
spec = importlib.util.spec_from_file_location("phase10u_validator", 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_phase10u.py")
record = validator.load_json(
root / "manifests/retroarch/phase-1.0u-local-shsrv-inventory.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_authorizations_false(record["authorizations"]), "authority active")
@case("02 connection authorization is rejected")
def _():
value = dict(record["authorizations"]); value["ps5_connection_authorized"] = True
require(not validator.all_authorizations_false(value), "connection allowed")
@case("03 retry authorization is rejected")
def _():
value = dict(record["authorizations"]); value["automatic_retry"] = True
require(not validator.all_authorizations_false(value), "retry allowed")
@case("04 scan scope remains bounded")
def _(): require(validator.scope_is_bounded(record["scope"]), "scope rejected")
@case("05 full computer scan cannot be claimed")
def _(): require(record["scope"]["full_computer_scan_performed"] is False, "global scan claimed")
@case("06 inventory methods remain static")
def _(): require(validator.methods_are_static(record["methods"]), "methods rejected")
@case("07 executing host wrapper fails policy")
def _():
value = dict(record["methods"]); value["host_sender_executed"] = True
require(not validator.methods_are_static(value), "sender execution accepted")
@case("08 results mean scoped absence only")
def _(): require(validator.result_is_scoped_absence(record["results"]), "result rejected")
@case("09 global absence cannot be promoted")
def _():
value = dict(record["results"]); value["global_absence_proven"] = True
require(not validator.result_is_scoped_absence(value), "global absence invented")
@case("10 all reference objects remain non-deployed")
def _(): require(validator.references_are_non_deployed(record["reference_objects"]), "reference promoted")
@case("11 source checkout is not deployed identity")
def _(): require(record["reference_objects"][0]["deployed_identity"] is False, "source promoted")
@case("12 host wrapper is not target binary")
def _(): require(record["reference_objects"][2]["classification"] == "HOST_WRAPPER_NOT_TARGET_BINARY", "wrapper promoted")
@case("13 package recipe is not a receipt")
def _(): require(record["reference_objects"][3]["classification"] == "UNPINNED_RECIPE_NOT_PACKAGE_RECEIPT", "recipe promoted")
@case("14 exact identity remains unproven")
def _(): require(validator.decision_is_blocked(record["decision"]), "decision rejected")
@case("15 no target or device action occurred")
def _(): require(all(value is False for value in record["performed_actions"].values()), "action occurred")
@case("16 host inventory is not hardware proof")
def _(): require(record["tests"]["hardware_claim_from_host_test"] is False, "host result 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.0U guardrails passed: {len(cases)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())