This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Mutation guardrails for the Phase-1.0I offline postmortem."""
|
||||
|
||||
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("phase10i", 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_phase10i.py")
|
||||
record = validator.load_json(root / "manifests/retroarch/phase-1.0i-flip-and-write-analysis.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_false(record["current_authorizations"], validator.AUTHORIZATION_FIELDS), "authorization active")
|
||||
|
||||
@case("02 a device authorization fails")
|
||||
def _():
|
||||
value = dict(record["current_authorizations"]); value["device_execution_authorized"] = True
|
||||
require(not validator.all_false(value, validator.AUTHORIZATION_FIELDS), "device authorization accepted")
|
||||
|
||||
@case("03 no Phase I target or device action occurred")
|
||||
def _(): require(validator.all_false(record["phase_actions"], validator.ACTION_FIELDS), "action recorded")
|
||||
|
||||
@case("04 write interval and candidates are bounded")
|
||||
def _(): require(validator.write_analysis_is_bounded(record["write_firewall"]), "write analysis rejected")
|
||||
|
||||
@case("05 exact write operation claim fails")
|
||||
def _():
|
||||
value = dict(record["write_firewall"]); value["exact_operation"] = "OPEN"
|
||||
require(not validator.write_analysis_is_bounded(value), "invented operation accepted")
|
||||
|
||||
@case("06 successful device write claim fails")
|
||||
def _():
|
||||
value = dict(record["write_firewall"]); value["write_succeeded"] = True
|
||||
require(not validator.write_analysis_is_bounded(value), "device write accepted")
|
||||
|
||||
@case("07 later initialization was not stopped")
|
||||
def _(): require(record["write_firewall"]["shutdown_stopped_later_initialization"] is False, "shutdown behavior invented")
|
||||
|
||||
@case("08 flip tuple and return are exact")
|
||||
def _(): require(validator.flip_analysis_is_exact(record["first_flip"]), "flip evidence rejected")
|
||||
|
||||
@case("09 successful flip claim fails")
|
||||
def _():
|
||||
value = dict(record["first_flip"]); value["submit_raw"] = 0
|
||||
require(not validator.flip_analysis_is_exact(value), "successful flip accepted")
|
||||
|
||||
@case("10 event wait claim fails")
|
||||
def _():
|
||||
value = dict(record["first_flip"]); value["event_wait_attempted"] = True
|
||||
require(not validator.flip_analysis_is_exact(value), "event wait accepted")
|
||||
|
||||
@case("11 errno remains unproven")
|
||||
def _(): require(record["first_flip"]["original_errno"] == "UNPROVEN", "errno invented")
|
||||
|
||||
@case("12 frame mismatch is not root cause")
|
||||
def _(): require(record["source_inconsistency"]["classification"] == "STRONG_SOURCE_CANDIDATE_NOT_PROVEN_ROOT_CAUSE", "root cause promoted")
|
||||
|
||||
@case("13 public SDK prototype remains absent")
|
||||
def _(): require(record["abi_evidence"]["public_sdk_prototype_present"] is False, "SDK prototype invented")
|
||||
|
||||
@case("14 decision remains fail closed")
|
||||
def _(): require(validator.decision_is_fail_closed(record["decision"]), "decision opened")
|
||||
|
||||
@case("15 device test readiness fails")
|
||||
def _():
|
||||
value = dict(record["decision"]); value["next_device_test_ready"] = True
|
||||
require(not validator.decision_is_fail_closed(value), "device retest opened")
|
||||
|
||||
@case("16 no new artifact exists")
|
||||
def _(): require(record["decision"]["new_artifact_created_in_phase10i"] is False, "artifact invented")
|
||||
|
||||
@case("17 host tests are not hardware evidence")
|
||||
def _(): require(record["tests"]["hardware_evidence_from_phase10i"] is False, "host test 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.0I analysis guardrails passed: {len(cases)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user