This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Mutation guardrails for Phase-1.0Y offline shsrv framing."""
|
||||
|
||||
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("phase10y_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_phase10y.py")
|
||||
record = validator.load_json(
|
||||
root / "manifests/retroarch/phase-1.0y-shsrv-framing.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 source family activation is rejected")
|
||||
def _():
|
||||
value = dict(record["activation"]); value["source_family"] = "LIBTELNET_NVT_V09_V019"
|
||||
require(not validator.activation_is_inactive(value), "family activated")
|
||||
|
||||
@case("05 model remains offline")
|
||||
def _(): require(validator.model_is_offline(record["offline_model"]), "model rejected")
|
||||
|
||||
@case("06 network import claim is rejected")
|
||||
def _():
|
||||
value = dict(record["offline_model"]); value["network_import_present"] = True
|
||||
require(not validator.model_is_offline(value), "network accepted")
|
||||
|
||||
@case("07 two source families remain distinct")
|
||||
def _(): require(set(record["source_families"]) == {"LEGACY_RAW_V07_V08", "LIBTELNET_NVT_V09_V019"}, "families collapsed")
|
||||
|
||||
@case("08 legacy controls pass to shell")
|
||||
def _(): require(record["source_families"]["LEGACY_RAW_V07_V08"]["telnet_controls_pass_to_shell"] is True, "legacy behavior hidden")
|
||||
|
||||
@case("09 current server does not proactively negotiate")
|
||||
def _(): require(record["source_families"]["LIBTELNET_NVT_V09_V019"]["proactive_negotiation"] is False, "negotiation invented")
|
||||
|
||||
@case("10 current unsupported WILL and DO replies remain exact")
|
||||
def _():
|
||||
current = record["source_families"]["LIBTELNET_NVT_V09_V019"]
|
||||
require(current["will_reply"] == "IAC_DONT" and current["do_reply"] == "IAC_WONT", "reply mismatch")
|
||||
|
||||
@case("11 server echo remains absent")
|
||||
def _(): require(all(value["server_side_echo"] is False for value in record["source_families"].values()), "echo invented")
|
||||
|
||||
@case("12 prompt completion remains unproven")
|
||||
def _(): require(validator.prompt_remains_unproven(record["prompt_and_completion"]), "prompt promoted")
|
||||
|
||||
@case("13 short-write loop remains absent")
|
||||
def _(): require(record["prompt_and_completion"]["short_write_completion_loop"] is False, "short writes hidden")
|
||||
|
||||
@case("14 IAC signal commands remain excluded")
|
||||
def _(): require(record["risks"]["iac_signal_commands"] == "HIGH_FUNCTIONAL_EXCLUDED_INPUT", "IAC effect weakened")
|
||||
|
||||
@case("15 deployed family remains unproven")
|
||||
def _(): require(record["decision"]["exact_deployed_shsrv_identity"] == "UNPROVEN", "identity promoted")
|
||||
|
||||
@case("16 no live client is allowed")
|
||||
def _(): require(record["decision"]["live_client_implementation_allowed"] is False, "live implementation allowed")
|
||||
|
||||
@case("17 next step remains offline passive contract")
|
||||
def _(): require(validator.decision_is_offline_only(record["decision"]), "live next 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.0Y guardrails passed: {len(cases)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user