This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Validate the offline-only Phase-1.0I flip/write postmortem."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
from typing import Any
|
||||
|
||||
|
||||
PHASE = "PHASE_1_0I_OFFLINE_FLIP_AND_WRITE_ANALYSIS"
|
||||
STATUS = "OFFLINE_ANALYSIS_COMPLETE_DEVICE_RETEST_BLOCKED"
|
||||
ARTIFACT_SHA256 = "822f2cf1f4d33a514d2bdd88fde40ad580dda5d85f537362ef6dff2eafcb56b6"
|
||||
MAP_SHA256 = "638642b750b8d5b108cf6c73215a3f1759bc6da0b29ee0a0ade5c47e8b7b2d5"
|
||||
AUTHORIZATION_FIELDS = (
|
||||
"ps5_connection_authorized", "device_transfer_authorized",
|
||||
"device_execution_authorized", "result_receive_authorized",
|
||||
"target_build_authorized", "installation_authorized",
|
||||
"autoload_authorized", "device_write_authorized", "automatic_retry",
|
||||
)
|
||||
ACTION_FIELDS = (
|
||||
"ps5_connected", "device_request_performed", "files_transferred",
|
||||
"target_execution_performed", "result_received_from_device",
|
||||
"target_build_performed", "target_artifact_created",
|
||||
"device_write_performed", "installation_performed", "autoload_performed",
|
||||
"retry_performed", "reconnect_performed",
|
||||
)
|
||||
DELIVERABLES = (
|
||||
"docs/retroarch/phase-1.0i-flip-and-write-analysis.md",
|
||||
"manifests/retroarch/phase-1.0i-flip-and-write-analysis.json",
|
||||
"tools/validate_retroarch_phase10i.py",
|
||||
"tests/test_retroarch_phase10i.py",
|
||||
)
|
||||
|
||||
|
||||
def load_json(path: Path) -> dict[str, Any]:
|
||||
value = json.loads(path.read_text(encoding="utf-8"))
|
||||
if not isinstance(value, dict):
|
||||
raise ValueError("Phase-1.0I manifest is not an object")
|
||||
return value
|
||||
|
||||
|
||||
def all_false(record: dict[str, Any], fields: tuple[str, ...]) -> bool:
|
||||
return all(record.get(field) is False for field in fields)
|
||||
|
||||
|
||||
def write_analysis_is_bounded(record: dict[str, Any]) -> bool:
|
||||
wrappers = record.get("linked_blocking_wrappers", [])
|
||||
return (
|
||||
record.get("observed_after") == "I03"
|
||||
and record.get("observed_before") == "I04"
|
||||
and record.get("shutdown_reason") == 6
|
||||
and record.get("first_error") == 118
|
||||
and record.get("d12_transmitted_fields") == ["shutdown_reason", "first_error"]
|
||||
and record.get("status_field_not_transmitted") == "first_blocked_write"
|
||||
and wrappers == [
|
||||
{"symbol": "__wrap_open", "address": "0x47580", "operation": "OPEN"},
|
||||
{"symbol": "__wrap_fopen", "address": "0x475b0", "operation": "OPEN"},
|
||||
{"symbol": "__wrap_fwrite", "address": "0x47600", "operation": "STREAM"},
|
||||
]
|
||||
and record.get("possible_operations") == ["OPEN", "STREAM"]
|
||||
and record.get("exact_operation") == "UNPROVEN"
|
||||
and record.get("exact_path") == "UNPROVEN"
|
||||
and record.get("write_succeeded") is False
|
||||
and record.get("shutdown_stopped_later_initialization") is False
|
||||
)
|
||||
|
||||
|
||||
def flip_analysis_is_exact(record: dict[str, Any]) -> bool:
|
||||
arguments = record.get("arguments", {})
|
||||
disassembly = record.get("disassembly", {})
|
||||
return (
|
||||
record.get("pattern_destination") == "vbuf[0]"
|
||||
and record.get("pattern_copied_before_submit") is True
|
||||
and record.get("submit_symbol") == "sceVideoOutSubmitFlip"
|
||||
and arguments.get("buffer_index") == 0
|
||||
and arguments.get("flip_mode") == 1
|
||||
and arguments.get("flip_argument") == 0
|
||||
and disassembly == {
|
||||
"buffer_index_zero": "0xfe6ac",
|
||||
"flip_mode_one": "0xfe6ae",
|
||||
"flip_argument_zero": "0xfe6b3",
|
||||
"submit_call": "0xfe6bc",
|
||||
}
|
||||
and record.get("buffer_registration_raw") == 0
|
||||
and record.get("submit_raw") == -1
|
||||
and record.get("event_wait_attempted") is False
|
||||
and record.get("original_errno") == "UNPROVEN"
|
||||
and record.get("errno_captured_before_diagnostic_send") is False
|
||||
and record.get("visible_presentation") == "UNPROVEN"
|
||||
)
|
||||
|
||||
|
||||
def decision_is_fail_closed(record: dict[str, Any]) -> bool:
|
||||
return (
|
||||
record.get("offline_analysis_complete") is True
|
||||
and record.get("root_cause_identified") is False
|
||||
and record.get("next_device_test_ready") is False
|
||||
and record.get("next_offline_artifact_design_allowed") is True
|
||||
and record.get("new_artifact_created_in_phase10i") is False
|
||||
and record.get("new_device_client_created_in_phase10i") is False
|
||||
)
|
||||
|
||||
|
||||
def validate(root: Path) -> list[str]:
|
||||
errors: list[str] = []
|
||||
for relative in DELIVERABLES:
|
||||
if not (root / relative).is_file():
|
||||
errors.append(f"missing deliverable: {relative}")
|
||||
try:
|
||||
record = load_json(root / "manifests/retroarch/phase-1.0i-flip-and-write-analysis.json")
|
||||
except (OSError, ValueError, json.JSONDecodeError) as error:
|
||||
return errors + [str(error)]
|
||||
if record.get("phase") != PHASE or record.get("status") != STATUS:
|
||||
errors.append("phase/status mismatch")
|
||||
artifact = record.get("bound_evidence", {}).get("artifact", {})
|
||||
if not (
|
||||
artifact.get("sha256") == ARTIFACT_SHA256
|
||||
and artifact.get("size") == 1845152
|
||||
and artifact.get("tracked") is False
|
||||
and artifact.get("execution_eligible") is False
|
||||
and artifact.get("transfer_eligible") is False
|
||||
and artifact.get("installation_eligible") is False
|
||||
):
|
||||
errors.append("consumed artifact is not exact and ineligible")
|
||||
linker_map = record.get("bound_evidence", {}).get("linker_map", {})
|
||||
if linker_map.get("sha256") != MAP_SHA256 or linker_map.get("tracked") is not False:
|
||||
errors.append("linker map identity mismatch")
|
||||
if not all_false(record.get("phase_actions", {}), ACTION_FIELDS):
|
||||
errors.append("Phase-1.0I records a device/target action")
|
||||
if not all_false(record.get("current_authorizations", {}), AUTHORIZATION_FIELDS):
|
||||
errors.append("a current authorization is active")
|
||||
if not write_analysis_is_bounded(record.get("write_firewall", {})):
|
||||
errors.append("write analysis overclaims or omits the bounded candidates")
|
||||
if not flip_analysis_is_exact(record.get("first_flip", {})):
|
||||
errors.append("flip analysis differs from source/disassembly/runtime evidence")
|
||||
source = record.get("source_inconsistency", {})
|
||||
if not (
|
||||
source.get("diagnostic_buffer_index") == 0
|
||||
and source.get("patched_normal_initial_frame_id") == 1
|
||||
and source.get("public_sdl_initial_frame_id") == 0
|
||||
and source.get("classification") == "STRONG_SOURCE_CANDIDATE_NOT_PROVEN_ROOT_CAUSE"
|
||||
):
|
||||
errors.append("source inconsistency is hidden or promoted to root cause")
|
||||
abi = record.get("abi_evidence", {})
|
||||
if not (
|
||||
abi.get("sdk_export_stub_present") is True
|
||||
and abi.get("public_sdk_prototype_present") is False
|
||||
and abi.get("prototype_source") == "PUBLIC_SDL_FORK"
|
||||
and abi.get("exact_firmware_semantics") == "UNPROVEN"
|
||||
):
|
||||
errors.append("ABI evidence is overstated")
|
||||
if not decision_is_fail_closed(record.get("decision", {})):
|
||||
errors.append("decision opens a device test or claims root cause")
|
||||
tests = record.get("tests", {})
|
||||
if not (
|
||||
tests.get("chimera_gfx_ctest") == "46_OF_46_PASS"
|
||||
and tests.get("retroarch_ps5_host_suite") == "PASS_WITH_ASAN_UBSAN"
|
||||
and tests.get("phase10i_gfx_guardrails") == 17
|
||||
and tests.get("phase10i_retroarch_guardrails") == 6
|
||||
and tests.get("safety_audit") == "PASS"
|
||||
and tests.get("secret_scan") == "PASS"
|
||||
and tests.get("hardware_evidence_from_phase10i") is False
|
||||
):
|
||||
errors.append("test evidence is incomplete or promoted to hardware evidence")
|
||||
tracked = subprocess.run(
|
||||
["git", "ls-files"], cwd=root, capture_output=True, text=True, check=True
|
||||
).stdout.splitlines()
|
||||
if any(path.lower().endswith((".elf", ".self", ".sprx", ".pkg", ".map")) for path in tracked):
|
||||
errors.append("target artifact or map is tracked")
|
||||
return errors
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
errors = validate(args.root.resolve())
|
||||
if errors:
|
||||
for error in errors:
|
||||
print(f"ERROR: {error}")
|
||||
return 1
|
||||
print("Phase-1.0I offline flip/write analysis validation passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user