This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Mutation guardrails for Phase-1.0X inactive injected transport."""
|
||||
|
||||
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("phase10x_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_phase10x.py")
|
||||
record = validator.load_json(
|
||||
root / "manifests/retroarch/phase-1.0x-inactive-transport.json")
|
||||
cases = []
|
||||
|
||||
def case(name):
|
||||
def register(function):
|
||||
cases.append((name, function))
|
||||
return function
|
||||
return register
|
||||
|
||||
@case("01 all authorizations remain false")
|
||||
def _(): require(validator.all_authorizations_false(record["authorizations"]), "authority active")
|
||||
|
||||
@case("02 connection authority is rejected")
|
||||
def _():
|
||||
value = dict(record["authorizations"])
|
||||
value["ps5_connection_authorized"] = True
|
||||
require(not validator.all_authorizations_false(value), "connection accepted")
|
||||
|
||||
@case("03 activation is inert")
|
||||
def _(): require(validator.activation_is_inactive(record["activation"]), "activation rejected")
|
||||
|
||||
@case("04 target or command activates failure")
|
||||
def _():
|
||||
value = dict(record["activation"]); value["commands"] = ["help"]
|
||||
require(not validator.activation_is_inactive(value), "command accepted")
|
||||
|
||||
@case("05 architecture is injected only")
|
||||
def _(): require(validator.architecture_is_injected_only(record["architecture"]), "architecture rejected")
|
||||
|
||||
@case("06 socket capability is rejected")
|
||||
def _():
|
||||
value = dict(record["architecture"]); value["socket_import_present"] = True
|
||||
require(not validator.architecture_is_injected_only(value), "socket accepted")
|
||||
|
||||
@case("07 receipt is before adapter open")
|
||||
def _(): require(record["local_evidence"]["receipt_before_adapter_open"] is True, "receipt order missing")
|
||||
|
||||
@case("08 receipt excludes target")
|
||||
def _(): require(record["local_evidence"]["target_address_persisted"] is False, "target retained")
|
||||
|
||||
@case("09 exclusive creation is required")
|
||||
def _(): require(record["local_evidence"]["exclusive_leaf_create"] is True, "exclusive create missing")
|
||||
|
||||
@case("10 overwrite and cleanup remain absent")
|
||||
def _():
|
||||
local = record["local_evidence"]
|
||||
require(local["overwrite_supported"] is False and local["delete_or_cleanup_supported"] is False, "mutation enabled")
|
||||
|
||||
@case("11 partial evidence remains invalid")
|
||||
def _(): require(record["local_evidence"]["partial_file_is_valid_evidence"] is False, "partial accepted")
|
||||
|
||||
@case("12 directory durability remains unproven")
|
||||
def _(): require(record["local_evidence"]["directory_entry_durability"] == "UNPROVEN", "durability promoted")
|
||||
|
||||
@case("13 blocking-call preemption remains unproven")
|
||||
def _(): require(record["deadline_and_cleanup"]["blocking_adapter_call_preemption"] is False, "preemption invented")
|
||||
|
||||
@case("14 retry and second open remain absent")
|
||||
def _():
|
||||
deadline = record["deadline_and_cleanup"]
|
||||
require(deadline["retry_loop_present"] is False and deadline["second_open_present"] is False, "retry enabled")
|
||||
|
||||
@case("15 exact prompt and Telnet framing remain unproven")
|
||||
def _():
|
||||
evidence = record["source_protocol_evidence"]
|
||||
require(evidence["exact_prompt_framing_proven"] is False and evidence["exact_telnet_reply_contract_proven"] is False, "framing promoted")
|
||||
|
||||
@case("16 exact deployed identity remains unproven")
|
||||
def _(): require(record["decision"]["exact_deployed_shsrv_identity"] == "UNPROVEN", "identity promoted")
|
||||
|
||||
@case("17 next step remains offline audit")
|
||||
def _(): require(validator.decision_is_offline_only(record["decision"]), "live step enabled")
|
||||
|
||||
@case("18 no action and no hardware proof")
|
||||
def _():
|
||||
require(all(value is False for value in record["performed_actions"].values()) and record["tests"]["hardware_claim_from_host_test"] is False, "host evidence 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.0X guardrails passed: {len(cases)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user