feat: name the BIOS each run used

Record version 5: every repetition and variant carries bios_used, staged:<dest> when a load line of the core names the file, builtin when a fallback line says it ran its own BIOS, unknown otherwise. An opened file is no proof. The oracle gains fallback_patterns and load_patterns per core, and a record judged again carries judged_at and judged_by.
This commit is contained in:
Abdessamad Derraz committed 2026-10-28 05:18:38 +01:00
1 parent 7c3e6ced09
commit 5c8da8a424
5 files changed
+194 -14

No files matched your search

+23 -1
View File
@@ -218,6 +218,27 @@ class OracleTests(unittest.TestCase):
self.assertEqual((verdict, evidence["stages"]), ("boots", ["bios", "game"]))
self.assertEqual(core_probe.judge(self.rep(frames((0, self.TITLE))), oracle)[1]["stages"], ["game"])
def test_the_bios_used_comes_from_the_log(self) -> None:
oracle = {**self.ORACLE, "fallback_patterns": [r"^Firmware is missing: "],
"load_patterns": [r"^Firmware found: (?P<path>.+)$"]}
cases = [
(["Searching for firmware checksum: 0555", "Firmware is missing: scph5501.bin"], "builtin"),
(["Firmware found: <system>/scph5501.bin", "Firmware SHA1: 0555"], "staged:scph5501.bin"),
# A file tried, then the fallback: the last line decides.
(["Firmware found: <system>/a.bin", "Firmware is missing: b.bin"], "builtin"),
(["nothing about the BIOS"], "unknown"),
]
for logs, expected in cases:
self.assertEqual(core_probe.bios_used(self.rep([], logs=logs), oracle)[0], expected, logs)
rep = self.rep(frames((10, self.TITLE)), logs=["Firmware is missing: scph5501.bin"])
core_probe.judge_repetition(rep, oracle)
self.assertEqual((rep["verdict"], rep["bios_used"]), ("boots", "builtin"))
self.assertTrue(rep["verdict_evidence"]["detail"].endswith("on the core's built-in BIOS"))
self.assertEqual(rep["verdict_evidence"]["bios_log"], "Firmware is missing: scph5501.bin")
variant = {"repetitions": [rep, {**rep, "bios_used": "staged:a.bin"}]}
core_probe.judge_variant(variant)
self.assertEqual(variant["bios_used"], "unknown")
def test_the_bios_screens_alone_are_not_a_boot(self) -> None:
# A console that shows its logo and then refuses the disc never reached the game.
verdict, evidence = core_probe.judge(
@@ -516,7 +537,8 @@ class FakeCoreTests(unittest.TestCase):
self.assertEqual(record["variants"][3]["system_files"],
{"card.bin": hashlib.sha1(b"\x00").hexdigest()})
self.assertEqual(record["inputs"]["oracle"]["error_patterns"], ["BIOS not found"])
self.assertEqual(record["record_version"], 4)
self.assertEqual(record["record_version"], 5)
self.assertEqual({v["bios_used"] for v in record["variants"]}, {"unknown"})
self.assert_schema(record)
def test_a_crash_and_a_hang_are_verdicts(self) -> None:
+18
View File
@@ -331,6 +331,24 @@ class ReadAndIndex(Workspace):
self.assertTrue(any("measurements/beta.jsonl:1" in e and "kind" in e for e in errors), errors)
self.assertIsNotNone(Draft202012Validator)
def test_a_version_5_record_names_the_bios_it_ran(self) -> None:
try:
from jsonschema import Draft202012Validator
except ImportError:
self.skipTest("jsonschema is not installed")
schema = json.loads((REPO_ROOT / "schemas" / "core-probe-record.schema.json").read_text())
record = mr.seal({**full_record("alpha", "card", "2026-10-28T10:00:00+00:00"), "record_version": 5})
errors = [e.message for e in Draft202012Validator(schema).iter_errors(record)]
self.assertIn("'bios_used' is a required property", errors)
for variant in record["variants"]:
variant["bios_used"] = "builtin"
for rep in variant["repetitions"]:
rep["bios_used"] = "staged:card.bin"
self.assertEqual([e.message for e in Draft202012Validator(schema).iter_errors(record)
if "bios_used" in e.message], [])
record["variants"][0]["bios_used"] = "the other region's"
self.assertTrue(list(Draft202012Validator(schema).iter_errors(record)))
def test_a_version_4_record_needs_its_verdicts(self) -> None:
try:
from jsonschema import Draft202012Validator # noqa: F401