| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073 |
- #!/usr/bin/env python3
- """Tests for non-ChipWatcher UART/RS232 receipt validation."""
- from __future__ import annotations
- import json
- import hashlib
- import re
- import sys
- import tempfile
- import unittest
- from pathlib import Path
- sys.dont_write_bytecode = True
- ROOT = Path(__file__).resolve().parents[2]
- sys.path.insert(0, str(ROOT / "tools"))
- from uart_receipts import ( # noqa: E402
- REAL_BMC_J6_HOST_SENSOR_REAL_FAN_PTC_ALLOWED_PIN_PROFILES,
- REAL_BMC_J6_HOST_SENSOR_REAL_FAN_PTC_ALLOWED_TOP_MODULES_BY_PIN_PROFILE,
- _host_sensor_row_fields,
- _parse_host_sensor_report_text,
- _parse_j6raw_frames,
- _parse_lossless_key_value_lines,
- backend_capabilities,
- build_parser,
- build_protocol_offline_receipt,
- compute_file_hash,
- validate_cpld_bmc_acceptance_v1_receipt,
- validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt,
- validate_real_bmc_j6_windows_gate_v2_receipt,
- validate_offline_fidelity_gate_v1_receipt,
- validate_final_gate_v2_receipt,
- validate_uart_receipt,
- )
- class UartReceiptsTests(unittest.TestCase):
- def valid_offline_toolchain(self) -> dict:
- tool_safety = {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- }
- tools = {
- "python": {"name": "python", "status": "present", "path": r"C:\Python\python.exe"},
- "iverilog": {"name": "iverilog", "status": "present", "path": r"C:\tools\iverilog.exe"},
- "vvp": {"name": "vvp", "status": "present", "path": r"C:\tools\vvp.exe"},
- "verilator": {"name": "verilator", "status": "present", "path": r"C:\tools\verilator_bin.exe"},
- "yosys": {"name": "yosys", "status": "present", "path": r"C:\tools\yosys.exe"},
- "sby": {"name": "sby", "status": "present", "path": r"C:\tools\sby.exe"},
- "cocotb": {"name": "python_module:cocotb", "status": "present", "python": r"C:\venv\Scripts\python.exe"},
- "td_cli": {"name": "td_commands_prompt", "status": "present", "path": r"C:\TD\bin\td_commands_prompt.exe"},
- }
- return {
- "status": "pass",
- "toolchain": {"status": "pass", "tools": tools},
- "manifest": {
- "install_roots": {
- "oss_cad_suite": r"C:\Users\Administrator\CodexToolchains\CPLD\oss-cad-suite\latest",
- "cocotb_venv": r"C:\Users\Administrator\CodexToolchains\CPLD\venvs\pid-study-cocotb-venv",
- "downloads": r"C:\Users\Administrator\CodexToolchains\CPLD\downloads",
- "manifests": r"C:\Users\Administrator\CodexToolchains\CPLD\manifests",
- },
- "tools": [{"name": name, "status": "present", "path": data.get("path") or data.get("python")} for name, data in tools.items()],
- "downloads": [],
- "created_paths": [],
- "reused_paths": [],
- "cleanup_plan": {
- "default": "dry_run",
- "requires_owner_marker": True,
- "allowed_root": r"C:\Users\Administrator\CodexToolchains\CPLD",
- },
- "safety": tool_safety,
- },
- "cleanup_policy": {
- "default": "dry_run",
- "requires_owner_marker": True,
- "allowed_root": r"C:\Users\Administrator\CodexToolchains\CPLD",
- "owner_marker_name": ".cpld_toolchain_owner.json",
- "actual_delete_requires_apply": True,
- },
- "safety": tool_safety,
- "authority_boundary": "user-space offline toolchain bootstrap only",
- }
- def valid_offline_layers(self) -> dict:
- coverage_categories = [
- "protocol",
- "uart_bit",
- "control",
- "safety",
- "debug",
- "virtual_driver_lab",
- "thermal",
- "fault_injection",
- "cocotb_virtual_lab",
- "formal",
- "mutation",
- "td_toolchain",
- ]
- shim_names = [
- "pyserial_loopback_url",
- "socket_pipe_transport",
- "bmc_text_driver",
- "host_register_plane",
- "debug_uart_decoder",
- "fault_injection_facade",
- ]
- fault_contracts = [
- "timeout",
- "disconnect",
- "partial_read",
- "partial_write",
- "permission_denied",
- "buffer_overflow",
- "tx_backpressure",
- "rx_overflow",
- ]
- thermal_models = [
- "conservative",
- "optimistic",
- "extreme",
- "random_perturbation",
- "sensor_drift",
- "sensor_delay",
- "crosstalk",
- "fan_degradation",
- "ptc_thermal_inertia",
- ]
- mutants = [
- "invert_fault_condition",
- "remove_force_off",
- "break_channel_compare",
- "drop_debug_event",
- "break_debug_checksum",
- "bad_formal_property",
- ]
- return {
- "static": {"status": "pass", "returncode": 0},
- "model": {"status": "pass", "tests": {"test_pid_model.py": {"returncode": 0}}},
- "replay": {"status": "pass", "sample_count": 1},
- "protocol_fuzz": {"status": "pass", "scenarios": [{"name": "no_echo_bare_hex", "status": "pass"}]},
- "hdl_sim": {
- "status": "pass",
- "tests": [{"name": "uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top_tb", "status": "pass"}],
- },
- "cocotb_virtual_lab": {"status": "pass", "sim": {"status": "pass", "tests": [{"name": "pid_core_smoke_scoreboard", "status": "pass"}]}},
- "virtual_driver_lab": {
- "status": "pass",
- "user_mode_shims": [{"name": name, "status": "pass", "transcript": {"roundtrip": True}} for name in shim_names],
- "fault_contracts": fault_contracts,
- "trace_hash": "a" * 64,
- },
- "formal": {"status": "pass", "targets": [{"name": "fault_implies_ptc_off", "status": "pass"}]},
- "detector_selftest": {"status": "pass", "results": [{"name": "debug_checksum", "status": "pass"}]},
- "mutation": {
- "status": "pass",
- "mutants": [
- {"name": name, "status": "pass", "mutation_status": "killed", "artifact_sha256": "b" * 64}
- for name in mutants
- ],
- },
- "thermal_digital_twin": {
- "status": "pass",
- "models": [{"name": name, "status": "pass", "trace_hash": "c" * 64, "violations": []} for name in thermal_models],
- },
- "coverage_matrix": {
- "status": "pass",
- "items": [{"category": category, "status": "pass", "covered_by": ["contract_evidence"]} for category in coverage_categories],
- },
- "td_build": {"status": "pass", "elaboration": {"status": "pass", "database": {"sha256": "d" * 64}, "plan": {"script_sha256": "e" * 64}}},
- "debug_bundle": {"status": "pass", "path": "tmp/debug_bundle/offline"},
- }
- def valid_offline_receipt(self) -> dict:
- layers = self.valid_offline_layers()
- return {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": self.valid_offline_toolchain(),
- "layers": layers,
- "coverage_matrix": layers["coverage_matrix"],
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "authority_boundary": "offline logic, protocol, safety, debug, and virtual thermal evidence only",
- }
- def write_real_bmc_windows_gate_v2_fixture(
- self,
- root: Path,
- *,
- poll: int = 3,
- valid: int = 3,
- parser_error: int = 0,
- stale: int = 0,
- uerr: int = 0,
- derr: int = 0,
- mode: str = "PROGRAM_SRAM",
- ) -> Path:
- bitstream = root / "uart_rs232_j6_system_debug_primary.bit"
- td_receipt = root / "td_debug.json"
- transcript = root / "j6sys-transcript.txt"
- event_stream = root / "j6sys-event-stream.json"
- register_dump = root / "j6sys-register-dump.json"
- sram_attestation = root / "manual-sram-attestation.json"
- bitstream.write_bytes(b"real bmc j6 windows debug bitstream")
- tx = 3 + 43 * poll
- rx = 300 if poll >= 3 else 1
- tok = 144 if valid >= 3 else 1
- transcript.write_text(
- "\n".join(
- [
- "J6SYS wake=00000003 poll=00000001 tx=0000002E rx=00000001 uerr=00 state=0 tok=00000001 seq=00000001 valid=00000001 perr=0 stale=0 frame=0 duovf=0 dbg=00000001 derr=00000000",
- f"J6SYS wake=00000003 poll={poll:08X} tx={tx:08X} rx={rx:08X} uerr={uerr:02X} state=0 tok={tok:08X} seq={valid:08X} valid={valid:08X} perr={parser_error:X} stale={stale:X} frame=0 duovf=0 dbg=00000002 derr={derr:08X}",
- ]
- )
- + "\n",
- encoding="utf-8",
- )
- event_stream.write_text(
- json.dumps(
- {
- "schema": "j6sys-event-stream-v1",
- "status": "pass",
- "events": [
- {"poll": poll, "valid": valid, "source_id": "BMC_UART_TEXT", "parser_error": bool(parser_error), "stale": bool(stale)}
- ],
- }
- ),
- encoding="utf-8",
- )
- register_dump.write_text(
- json.dumps(
- {
- "schema": "j6sys-register-dump-v1",
- "status": "pass",
- "debug_registers": {"wake": 3, "poll": poll, "rx": rx, "valid": valid, "uerr": uerr, "derr": derr},
- }
- ),
- encoding="utf-8",
- )
- td_receipt.write_text(
- json.dumps(
- {
- "status": "pass",
- "top": "uart_rs232_j6_system_debug_primary",
- "top_module": "uart_rs232_j6_system_debug_top",
- "mode": "implementation",
- "pin_profile": "primary",
- "bitstream": {"path": str(bitstream), "sha256": compute_file_hash(bitstream)},
- "timing_gate": {"status": "pass"},
- }
- ),
- encoding="utf-8",
- )
- sram_attestation.write_text(
- json.dumps(
- {
- "status": "pass",
- "mode": mode,
- "operator": "manual",
- "programmed_at": "2026-07-01T00:00:00Z",
- "bitstream_sha256": compute_file_hash(bitstream),
- "td_receipt_sha256": compute_file_hash(td_receipt),
- "td_log_sha256": "0" * 64,
- }
- ),
- encoding="utf-8",
- )
- receipt = root / "real_bmc_j6_windows_gate_v2.json"
- payload = {
- "schema": "real-bmc-j6-windows-gate-v2-receipt-v1",
- "status": "pass",
- "counterparty": "real_bmc",
- "pin_profile": {"name": "primary", "connector": "J6", "tx_ball": "T4", "rx_ball": "R5", "debug_rx_ball": "P10", "debug_tx_ball": "R10"},
- "programming": {"mode": mode, "manual_programming": True, "bitstream": {"path": str(bitstream), "sha256": compute_file_hash(bitstream)}},
- "layers": {
- "td_bitstream": {"status": "pass", "receipt": {"path": str(td_receipt), "sha256": compute_file_hash(td_receipt)}},
- "manual_sram_programming": {
- "status": "pass",
- "operator": "manual",
- "mode": mode,
- "manual_programming": True,
- "programmed_at": "2026-07-01T00:00:00Z",
- "attestation": {"path": str(sram_attestation), "sha256": compute_file_hash(sram_attestation)},
- },
- "windows_serial_capture": {
- "status": "pass",
- "port": "COM7",
- "baud": 115200,
- "format": "8N1",
- "duration_s": 90,
- "transcript": {"path": str(transcript), "sha256": compute_file_hash(transcript)},
- "event_stream": {"path": str(event_stream), "sha256": compute_file_hash(event_stream)},
- "register_dump": {"path": str(register_dump), "sha256": compute_file_hash(register_dump)},
- },
- "real_bmc_protocol": {"status": "pass", "valid_frame_count": valid, "source_id": "BMC_UART_TEXT"},
- "safety_contract": {"status": "pass", "ptc_fan_pins_exported": False, "real_actuator_action_attempted": False},
- "artifact_hashes": {
- "status": "pass",
- "bitstream_sha256": compute_file_hash(bitstream),
- "td_receipt_sha256": compute_file_hash(td_receipt),
- "manual_sram_attestation_sha256": compute_file_hash(sram_attestation),
- "transcript_sha256": compute_file_hash(transcript),
- "event_stream_sha256": compute_file_hash(event_stream),
- "register_dump_sha256": compute_file_hash(register_dump),
- },
- },
- "safety": {
- "flash_attempted": False,
- "driver_install_attempted": False,
- "programs_flash": False,
- "opens_unknown_com_ports": False,
- "toggles_dtr_rts": False,
- "ptc_fan_pins_exported": False,
- "real_ptc_fan_action_attempted": False,
- "uncontrolled_real_bmc_action_attempted": False,
- },
- "authority_boundary": "real-bmc-j6-windows-gate-v2 proves Windows P10/R10 J6SYS evidence for controlled J6 BMC UART/parser/safety only.",
- }
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- return receipt
- def write_host_sensor_real_fan_ptc_debug921_fixture(
- self,
- root: Path,
- *,
- hardware_status: str = "not_run",
- ) -> Path:
- root.mkdir(parents=True, exist_ok=True)
- bitstream = root / "uart_rs232_j6_host_sensor_real_fan_ptc_temp_uart_ptc_remap_debug921.bit"
- td_receipt = root / "td_host_sensor_real_fan_ptc_debug921.json"
- sram_attestation = root / "manual-sram-attestation.json"
- host_raw = root / "host-port-raw.bin"
- host_escaped = root / "host-port-escaped.txt"
- debug_raw = root / "debug-uart-raw.bin"
- debug_escaped = root / "debug-uart-escaped.txt"
- replay = root / "bmc-raw-replay.bin"
- debug_frame_stream = root / "debug-frame-stream.json"
- host_sensor_report = root / "host-sensor-report.json"
- host_transcript = root / "host-command-transcript.json"
- manifest = root / "j6-host-sensor-real-fan-ptc-capture-manifest.json"
- commands = [
- "SET PTC 01 10",
- "SET PTC 24 20",
- "SET FAN 01 40",
- "SET FAN 04 30",
- "SET PID ENABLE",
- "GET STATUS",
- "GET MAP",
- "GET SENSOR",
- "GET SENSOR",
- "GET SENSOR",
- "SET PID DISABLE",
- "DISABLE",
- ]
- expected_ack_cmds = {
- "SET PTC 01 10": "PTCCH",
- "SET PTC 24 20": "PTCCH",
- "SET FAN 01 40": "FANCH",
- "SET FAN 04 30": "FANCH",
- "SET PID ENABLE": "PID_EN",
- "GET STATUS": "STATUS",
- "GET MAP": "MAP___",
- "GET SENSOR": "SENSOR",
- "SET PID DISABLE": "PID_DI",
- "DISABLE": "DISABL",
- }
- host_lines: list[str] = []
- debug_lines: list[str] = [
- "J6READY profile=temp-uart-ptc-remap",
- "J6CMD",
- "J6EVT s=06 cmd=08 c=01 p=000 ok=1 e=0 to=0",
- "J6PWM seq=00000006 src=host_manual pid=disabled timeout=0 ptc01=010 ptc24=020 fan01=040 fan04=030",
- "J6MOD seq=00000006 pid=disabled pid_requested=1 pid_active=0 bmc=observe_only host=slave pwm=host_manual timeout_s=5",
- "J6MAP profile=temp-uart-ptc-remap bmc_tx=T4 bmc_rx=R5 host_tx=P7 host_rx=P8 debug_rx=P10 debug_tx=R10 ptc=24 fan=4 fg=8 install=4",
- ]
- dimm_samples: list[dict[str, object]] = []
- replay_bytes = bytearray()
- raw_offset = 0
- for sample_seq in range(1, 4):
- payload_bytes = bytes([0xFF, 0xFF] * 24) if sample_seq == 2 else bytes(
- [value for dimm in range(24) for value in (0x30 + dimm + sample_seq, 0x00)]
- )
- replay_bytes.extend(payload_bytes)
- checksum = sum(payload_bytes) & 0xFFFF
- debug_lines.append(
- f"J6RAW s={sample_seq:04X} o={raw_offset:08X} l=30 u={checksum:04X} d={payload_bytes.hex().upper()}"
- )
- raw_offset += len(payload_bytes)
- valid = 0 if sample_seq == 2 else 24
- missing = 24 if sample_seq == 2 else 0
- status = "all_ff" if sample_seq == 2 else "valid"
- host_lines.append(
- f"SENS seq={sample_seq:08X} status={status} valid={valid:02d} missing={missing:02d} fault=0 raw=1 drop=00000000"
- )
- debug_lines.append(
- f"J6TEMP seq={sample_seq:08X} status={status} valid={valid:02d} missing={missing:02d} fault=0 host_report_drop=00000000"
- )
- rows = []
- for dimm in range(24):
- missing_flag = sample_seq == 2
- temp = -1 if missing_flag else 48 + dimm + sample_seq
- raw_pair = "FFFF" if missing_flag else f"{temp:02X}00"
- host_lines.append(
- f"DIMM seq={sample_seq:08X} id={dimm:02X} raw={raw_pair} temp={temp:03d} "
- f"missing={1 if missing_flag else 0} fault=0 status={status}"
- )
- rows.append({"id": dimm, "raw": raw_pair, "temp": temp, "missing": missing_flag, "fault": False})
- dimm_samples.append({"seq": sample_seq, "status": status, "valid": valid, "missing": missing, "dimm_rows": rows})
- host_lines.extend(
- [
- "PWM seq=00000008 src=host_manual timeout=1 ptc01=000 ptc24=000 fan01=030 fan04=030",
- "PID req=1 active=0 src=host_manual",
- "STAT hd=00000000 rd=00000000 he=00000000",
- ]
- )
- debug_lines.extend(
- [
- "J6PWM seq=0000000A src=host_manual pid=disabled timeout=1 ptc01=000 ptc24=000 fan01=030 fan04=030",
- "J6MOD seq=0000000A pid=disabled pid_requested=1 pid_active=0 bmc=observe_only host=slave pwm=host_manual timeout_s=5",
- f"J6STAT raw_in={len(replay_bytes):08X} raw_out={len(replay_bytes):08X} rd=00000000 hd=00000000 be=00000000 he=00000000",
- ]
- )
- host_text = "\r\n".join(host_lines) + "\r\n"
- debug_text = "\r\n".join(debug_lines) + "\r\n"
- bitstream.write_bytes(b"debug921 host sensor real fan ptc bitstream")
- host_raw.write_bytes(host_text.encode("ascii"))
- host_escaped.write_text(host_text, encoding="utf-8", newline="\n")
- debug_raw.write_bytes(debug_text.encode("ascii"))
- debug_escaped.write_text(debug_text, encoding="utf-8", newline="\n")
- replay.write_bytes(bytes(replay_bytes))
- td_receipt.write_text(
- json.dumps(
- {
- "status": "pass",
- "top": "uart_rs232_j6_host_sensor_real_fan_ptc_temp_uart_ptc_remap_debug921",
- "top_module": "uart_rs232_j6_host_sensor_real_fan_ptc_temp_uart_ptc_remap_debug921_top",
- "mode": "implementation",
- "pin_profile": "temp-uart-ptc-remap",
- "bitstream": {"path": str(bitstream), "sha256": compute_file_hash(bitstream)},
- "timing_gate": {"status": "pass"},
- }
- ),
- encoding="utf-8",
- )
- sram_attestation.write_text(
- json.dumps(
- {
- "status": "pass",
- "mode": "PROGRAM_SRAM",
- "operator": "manual",
- "programmed_at": "2026-07-01T00:00:00Z",
- "jtag_speed_hz": 200000,
- "board_power_present_before_program": True,
- "bitstream_sha256": compute_file_hash(bitstream),
- "td_receipt_sha256": compute_file_hash(td_receipt),
- }
- ),
- encoding="utf-8",
- )
- host_transcript.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-debug921-host-command-transcript-v1",
- "status": "pass",
- "host_port": "COM8",
- "baud": 115200,
- "format": "8N1",
- "writes_to_serial": True,
- "write_port_role": "HostPort",
- "debug_port_writes_to_serial": False,
- "preflight": {
- "schema": "j6-host-sensor-real-fan-ptc-startup-preflight-v1",
- "status": "pass",
- "ready_seen": True,
- "ready_line": "READY profile=temp-uart-ptc-remap seq=00000000",
- "j6ready_seen": True,
- "j6ready_line": "J6READY profile=temp-uart-ptc-remap",
- "sync_command": "GET STATUS",
- "sync_ack_seen": True,
- "preflight_ack": "OK seq=00000001 cmd=STATUS",
- "counts_as_formal_command": False,
- "formal_sequence_base": 0,
- },
- "commands": [
- {
- "seq": index + 1,
- "command": command,
- "allowed": True,
- "bytes_written": len(command) + 1,
- "expected_ack_cmd": expected_ack_cmds[command],
- "ack_line": f"OK seq={index + 1:08X} cmd={expected_ack_cmds[command]}",
- "ack_offset": index * 32,
- "response_offset": index * 32,
- "response_raw": f"OK seq={index + 1:08X} cmd={expected_ack_cmds[command]}",
- "response_token": f"OK seq={index + 1:08X} cmd={expected_ack_cmds[command]}",
- "response_class": "ok",
- "response_seq": index + 1,
- "response_cmd": expected_ack_cmds[command],
- "seq_match": True,
- "cmd_match": True,
- "response_late": False,
- "stale": False,
- "accepted": True,
- }
- for index, command in enumerate(commands)
- ],
- }
- ),
- encoding="utf-8",
- )
- host_sensor_report.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-host-sensor-report-v1",
- "status": "pass",
- "samples": dimm_samples,
- "host_report_drop": 0,
- "bmc_timeout": False,
- "source": "HostPort",
- }
- ),
- encoding="utf-8",
- )
- debug_frame_stream.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-debug-frame-stream-v1",
- "status": "pass",
- "frames": debug_lines,
- "raw_drop": 0,
- "host_report_drop": 0,
- "bmc_berr": 0,
- "host_err": 0,
- }
- ),
- encoding="utf-8",
- )
- manifest.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-capture-manifest-v1",
- "status": "pass",
- "host_port": "COM8",
- "debug_port": "COM7",
- "host_baud": 115200,
- "debug_baud": 921600,
- "host_port_writes_to_serial": True,
- "debug_port_writes_to_serial": False,
- "enumerates_com_ports": False,
- "opens_unknown_com_ports": False,
- "pin_profile_name": "temp-uart-ptc-remap",
- "pin_profile": {
- "name": "temp-uart-ptc-remap",
- "connector": "J6",
- "tx_ball": "T4",
- "rx_ball": "R5",
- "bmc_tx_ball": "T4",
- "bmc_rx_ball": "R5",
- "host_tx_ball": "P7",
- "host_rx_ball": "P8",
- "debug_rx_ball": "P10",
- "debug_tx_ball": "R10",
- },
- "raw_replay": {"path": "bmc-raw-replay.bin", "sha256": compute_file_hash(replay)},
- }
- ),
- encoding="utf-8",
- )
- payload = {
- "schema": "real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1-receipt-v1",
- "status": hardware_status,
- "counterparty": "real_bmc",
- "diagnostic_scope": "host_sensor_real_fan_ptc_debug921",
- "pin_profile_name": "temp-uart-ptc-remap",
- "pin_profile": {
- "name": "temp-uart-ptc-remap",
- "connector": "J6",
- "tx_ball": "T4",
- "rx_ball": "R5",
- "bmc_tx_ball": "T4",
- "bmc_rx_ball": "R5",
- "host_tx_ball": "P7",
- "host_rx_ball": "P8",
- "debug_rx_ball": "P10",
- "debug_tx_ball": "R10",
- },
- "programming": {
- "mode": "PROGRAM_SRAM",
- "manual_programming": True,
- "jtag_speed_hz": 200000,
- "board_power_present_before_program": True,
- "bitstream": {"path": str(bitstream), "sha256": compute_file_hash(bitstream)},
- },
- "collector": {
- "host_port": "COM8",
- "debug_port": "COM7",
- "baud": 115200,
- "debug_baud": 921600,
- "format": "8N1",
- "flow_control": "none",
- "dtr_enable": False,
- "rts_enable": False,
- "writes_to_serial": True,
- "write_port_role": "HostPort",
- "host_port_writes_to_serial": True,
- "debug_port_writes_to_serial": False,
- "opens_unknown_com_ports": False,
- "enumerates_com_ports": False,
- },
- "layers": {
- "td_bitstream": {"status": "pass", "receipt": {"path": str(td_receipt), "sha256": compute_file_hash(td_receipt)}},
- "manual_sram_programming": {
- "status": "pass",
- "operator": "manual",
- "mode": "PROGRAM_SRAM",
- "manual_programming": True,
- "programmed_at": "2026-07-01T00:00:00Z",
- "jtag_speed_hz": 200000,
- "board_power_present_before_program": True,
- "attestation": {"path": str(sram_attestation), "sha256": compute_file_hash(sram_attestation)},
- },
- "host_command_sequence": {"status": "pass", "commands": commands},
- "host_control_transcript": {
- "status": "pass",
- "host_command_transcript": {"path": str(host_transcript), "sha256": compute_file_hash(host_transcript)},
- },
- "host_sensor_reports": {
- "status": "pass",
- "host_transcript_text": {"path": str(host_escaped), "sha256": compute_file_hash(host_escaped)},
- "host_raw_bin": {"path": str(host_raw), "sha256": compute_file_hash(host_raw)},
- "host_sensor_report": {"path": str(host_sensor_report), "sha256": compute_file_hash(host_sensor_report)},
- },
- "debug_frame_capture": {
- "status": "pass",
- "debug_transcript": {"path": str(debug_escaped), "sha256": compute_file_hash(debug_escaped)},
- "raw_bin": {"path": str(debug_raw), "sha256": compute_file_hash(debug_raw)},
- "raw_replay": {"path": str(replay), "sha256": compute_file_hash(replay)},
- "debug_frame_stream": {"path": str(debug_frame_stream), "sha256": compute_file_hash(debug_frame_stream)},
- "manifest": {"path": str(manifest), "sha256": compute_file_hash(manifest)},
- },
- "bmc_raw_sampling": {"status": "pass", "minimum_completed_samples": 3, "completed_samples": 3, "bmc_timeout": False},
- "pid_boundary": {"status": "pass", "pid_requested": True, "pid_requested_ever": True, "pid_active": False, "pwm_source": "host_manual"},
- "timeout_evidence": {"status": "pass", "timeout_evidence": {"timeout_s": 5, "ptc_all_percent": 0, "fan_all_percent": 30}},
- "pin_map": {
- "status": "pass",
- "profile": "temp-uart-ptc-remap",
- "ptc_count": 24,
- "fan_count": 4,
- "fan_fg_count": 8,
- "fan_install_count": 4,
- "bmc_tx_ball": "T4",
- "bmc_rx_ball": "R5",
- "host_tx_ball": "P7",
- "host_rx_ball": "P8",
- "debug_rx_ball": "P10",
- "debug_tx_ball": "R10",
- },
- "safety_contract": {
- "status": "pass",
- "pid_default_enabled": False,
- "pid_active": False,
- "bmc_controls_pwm": False,
- "debug_port_writes_to_serial": False,
- "host_port_writes_to_serial": True,
- "real_thermal_performance_claimed": False,
- },
- "real_fan_ptc_hardware_status": {"status": hardware_status, "real_fan_ptc_hardware_present": False, "qualifies_final_gate": False},
- "artifact_hashes": {
- "status": "pass",
- "bitstream_sha256": compute_file_hash(bitstream),
- "td_receipt_sha256": compute_file_hash(td_receipt),
- "manual_sram_attestation_sha256": compute_file_hash(sram_attestation),
- "host_transcript_text_sha256": compute_file_hash(host_escaped),
- "host_raw_bin_sha256": compute_file_hash(host_raw),
- "host_sensor_report_sha256": compute_file_hash(host_sensor_report),
- "debug_transcript_sha256": compute_file_hash(debug_escaped),
- "debug_raw_bin_sha256": compute_file_hash(debug_raw),
- "raw_replay_sha256": compute_file_hash(replay),
- "debug_frame_stream_sha256": compute_file_hash(debug_frame_stream),
- "host_command_transcript_sha256": compute_file_hash(host_transcript),
- "manifest_sha256": compute_file_hash(manifest),
- },
- },
- "safety": {
- "flash_attempted": False,
- "driver_install_attempted": False,
- "programs_flash": False,
- "programs_nonvolatile": False,
- "opens_unknown_com_ports": False,
- "enumerates_com_ports": False,
- "toggles_dtr_rts": False,
- "debug_port_writes_to_serial": False,
- "host_port_writes_to_serial": True,
- "uncontrolled_real_bmc_action_attempted": False,
- "real_thermal_performance_claimed": False,
- },
- "authority_boundary": (
- "real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1 validates SRAM-only COM8 host "
- "1-based real FAN/PTC command evidence, COM7 debug921 frame replay, BMC raw DIMM "
- "sampling, HostPort temperature reporting, PID requested-but-inactive boundary, timeout fallback, "
- "and real FAN/PTC hardware status. It does not satisfy final-gate-v2, real-bmc-j6-windows-gate-v2, "
- "flash, thermal performance, production PTC/FAN qualification, or real PID closed-loop pass."
- ),
- }
- receipt = root / "real_bmc_j6_host_sensor_real_fan_ptc_debug921.json"
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- return receipt
- def test_backend_capabilities_report_missing_optional_python_modules(self) -> None:
- caps = backend_capabilities()
- self.assertIn(caps["serial_backend"], {"pyserial", "powershell_dotnet_limited"})
- self.assertIn(caps["schema_backend"], {"jsonschema", "builtin_limited"})
- self.assertIn("strict_gate_requires", caps)
- def test_public_cli_only_exposes_latest_real_fan_ptc_and_retained_gates(self) -> None:
- parser = build_parser()
- subparsers = next(action for action in parser._actions if action.dest == "command")
- commands = set(subparsers.choices)
- expected_commands = {
- "preflight",
- "protocol-offline",
- "validate",
- "final-gate-v2-validate",
- "offline-fidelity-gate-v1-validate",
- "real-bmc-j6-windows-gate-v2-validate",
- "cpld-bmc-acceptance-v1-validate",
- "real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1-validate",
- }
- self.assertEqual(commands, expected_commands)
- for command in [
- "real-bmc-j6-cr-raw-diagnostic-v1-validate",
- "real-bmc-j6-sensor-raw-diagnostic-v1-validate",
- "real-bmc-j6-host-control-pwm-diagnostic-v1-validate",
- "real-bmc-j6-host-control-pwm-debug921-lossless-v1-validate",
- "real-bmc-j6-host-sensor-pwm-debug921-v1-validate",
- "real-bmc-j6-gate-v1-validate",
- ]:
- self.assertNotIn(command, commands)
- def test_real_fan_ptc_validator_does_not_adapt_through_legacy_host_sensor_pwm(self) -> None:
- source = (ROOT / "tools" / "uart_receipts.py").read_text(encoding="utf-8")
- start = source.index("def validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt")
- end = source.index("def validate_cpld_bmc_acceptance_v1_receipt", start)
- body = source[start:end]
- self.assertNotIn("_host_sensor_real_fan_ptc_as_pwm_payload", body)
- self.assertNotIn("validate_real_bmc_j6_host_sensor_pwm_debug921_v1_receipt(", body)
- def test_protocol_offline_receipt_accepts_echo_and_loose_hex(self) -> None:
- receipt = build_protocol_offline_receipt(
- text="ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03\n"
- + " ".join(["0x23", "0x4b"] * 24),
- scenario="echo_0x_multiline",
- )
- self.assertEqual(receipt["schema"], "bmc-uart-protocol-receipt-v1")
- self.assertEqual(receipt["status"], "pass")
- self.assertEqual(receipt["parser"]["sample_count"], 24)
- self.assertGreaterEqual(receipt["parser"]["rejected_echo_windows"], 1)
- def test_protocol_offline_receipt_validates_itself_strictly(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = build_protocol_offline_receipt(
- text=" ".join(["23", "4b"] * 24),
- scenario="bare_hex",
- )
- receipt_path = Path(tmp) / "protocol.json"
- receipt_path.write_text(json.dumps(receipt), encoding="utf-8")
- result = validate_uart_receipt(receipt_path, strict=True)
- self.assertEqual(result["status"], "pass")
- def test_loopback_strict_validation_rejects_blocked_and_missing_hashes(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt_path = Path(tmp) / "loopback.json"
- receipt_path.write_text(
- json.dumps(
- {
- "schema": "uart-loopback-receipt-v1",
- "status": "blocked_no_allowlist",
- "counterparty": "pc_emulator",
- "serial": {"port": "COM7", "baud": 115200, "format": "8N1", "allowlisted": False},
- "transcript": {"path": "transcript.txt"},
- "safety": {"flash_attempted": False, "real_ptc_fan_bmc_action_attempted": False, "driver_install_attempted": False},
- }
- ),
- encoding="utf-8",
- )
- result = validate_uart_receipt(receipt_path, strict=True)
- self.assertEqual(result["status"], "blocked_no_allowlist")
- self.assertIn("missing_transcript_hash", result["failures"])
- def test_board_sram_receipt_requires_sram_only_bitstream_and_debug_evidence(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- root = Path(tmp)
- bit = root / "system.bit"
- transcript = root / "uart.log"
- debug = root / "debug.json"
- bit.write_bytes(b"fake bitstream")
- transcript.write_text("tx ipmitool\nrx ok\n", encoding="utf-8")
- debug.write_text(json.dumps({"events": [{"frame_seq": 1}], "register_dump": {"0x00": 1}}), encoding="utf-8")
- receipt = root / "board.json"
- receipt.write_text(
- json.dumps(
- {
- "schema": "uart-board-sram-receipt-v1",
- "status": "pass",
- "counterparty": "pc_emulator",
- "programming": {"mode": "PROGRAM_SRAM", "bitstream": {"path": str(bit), "sha256": compute_file_hash(bit)}},
- "serial": {"port": "COM7", "baud": 115200, "format": "8N1", "allowlisted": True, "dtr": False, "rts": False},
- "transcript": {"path": str(transcript), "sha256": compute_file_hash(transcript)},
- "debug_evidence": {"event_stream": str(debug), "register_dump": str(debug)},
- "safety": {"flash_attempted": False, "real_ptc_fan_bmc_action_attempted": False, "driver_install_attempted": False},
- }
- ),
- encoding="utf-8",
- )
- result = validate_uart_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "pass")
- def test_board_sram_receipt_fails_closed_on_flash_marker(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = Path(tmp) / "board.json"
- receipt.write_text(
- json.dumps(
- {
- "schema": "uart-board-sram-receipt-v1",
- "status": "pass",
- "counterparty": "pc_emulator",
- "programming": {"mode": "PROGRAM_FLASH", "bitstream": {"path": "x.bit", "sha256": "abc"}},
- "serial": {"port": "COM7", "baud": 115200, "format": "8N1", "allowlisted": True},
- "transcript": {"path": "uart.log", "sha256": "abc"},
- "debug_evidence": {"event_stream": "debug.json", "register_dump": "debug.json"},
- "safety": {"flash_attempted": True, "real_ptc_fan_bmc_action_attempted": False, "driver_install_attempted": False},
- }
- ),
- encoding="utf-8",
- )
- result = validate_uart_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail_forbidden_action")
- def test_uart_soak_receipt_accepts_round_receipts_without_top_level_transcript(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- root = Path(tmp)
- round_receipt = root / "round1.json"
- round_receipt.write_text(
- json.dumps(
- {
- "schema": "uart-loopback-receipt-v1",
- "status": "pass",
- "counterparty": "pc_emulator",
- "serial": {"port": "COM7", "baud": 115200, "format": "8N1", "allowlisted": True},
- "transcript": {"path": "transcript.txt", "sha256": compute_file_hash(root / "transcript.txt") if (root / "transcript.txt").exists() else "placeholder"},
- "safety": {"flash_attempted": False, "real_ptc_fan_bmc_action_attempted": False, "driver_install_attempted": False},
- }
- ),
- encoding="utf-8",
- )
- transcript = root / "transcript.txt"
- transcript.write_text("loopback ok\n", encoding="utf-8")
- payload = json.loads(round_receipt.read_text(encoding="utf-8"))
- payload["transcript"]["sha256"] = compute_file_hash(transcript)
- round_receipt.write_text(json.dumps(payload), encoding="utf-8")
- soak = root / "soak.json"
- soak.write_text(
- json.dumps(
- {
- "schema": "uart-soak-receipt-v1",
- "status": "pass",
- "counterparty": "pc_emulator",
- "duration_hours_requested": 0.1,
- "duration_hours_observed": 0.1,
- "rounds": [{"index": 1, "status": "pass", "receipt": str(round_receipt)}],
- "safety": {"flash_attempted": False, "real_ptc_fan_bmc_action_attempted": False, "driver_install_attempted": False},
- }
- ),
- encoding="utf-8",
- )
- result = validate_uart_receipt(soak, strict=True)
- self.assertEqual(result["status"], "pass")
- def test_final_gate_v2_rejects_chipwatcher_and_blocked_layers(self) -> None:
- receipt = {
- "schema": "final-gate-v2-receipt-v1",
- "status": "pass",
- "layers": {
- "static": {"status": "pass"},
- "model": {"status": "pass"},
- "replay": {"status": "pass"},
- "rtl_sim": {"status": "blocked_missing_tool"},
- "formal": {"status": "pass"},
- "detector_selftest": {"status": "pass"},
- "td_build": {"status": "pass"},
- "uart_strict": {"status": "pass", "schema": "uart-board-sram-validation-v1"},
- "chipwatcher": {"status": "pass"},
- },
- "authority_boundary": "control communication only",
- }
- result = validate_final_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("blocked_layer:rtl_sim", result["failures"])
- self.assertIn("forbidden_chipwatcher_layer", result["failures"])
- def test_final_gate_v2_rejects_blocked_top_level_status_even_when_layers_pass(self) -> None:
- receipt = {
- "schema": "final-gate-v2-receipt-v1",
- "status": "blocked_missing_tool",
- "layers": {
- "static": {"status": "pass"},
- "model": {"status": "pass"},
- "replay": {"status": "pass"},
- "rtl_sim": {"status": "pass"},
- "formal": {"status": "pass"},
- "detector_selftest": {"status": "pass"},
- "td_build": {"status": "pass"},
- "uart_strict": {"status": "pass"},
- },
- "authority_boundary": "control communication only",
- }
- result = validate_final_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("top_status_not_pass:blocked_missing_tool", result["failures"])
- def test_final_gate_v2_rejects_non_final_receipt_schema(self) -> None:
- receipt = {
- "schema": "not-a-final-gate-receipt-v1",
- "status": "pass",
- "layers": {},
- "authority_boundary": "not final gate evidence",
- }
- result = validate_final_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("fail_schema", result["failures"])
- self.assertIn("missing_layer:static", result["failures"])
- self.assertIn("missing_layer:uart_strict", result["failures"])
- def test_offline_fidelity_gate_rejects_hardware_layers_and_blocked_required_layers(self) -> None:
- layers = {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "protocol_fuzz",
- "hdl_sim",
- "cocotb_virtual_lab",
- "virtual_driver_lab",
- "formal",
- "detector_selftest",
- "mutation",
- "thermal_digital_twin",
- "coverage_matrix",
- "td_build",
- "debug_bundle",
- ]}
- layers["hdl_sim"] = {"status": "blocked_missing_tool"}
- layers["hardware"] = {"status": "pass"}
- layers["uart_strict"] = {"status": "pass"}
- layers["chipwatcher"] = {"status": "pass"}
- layers["thermal_performance_pass"] = {"status": "pass"}
- receipt = {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": {
- "status": "pass",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- },
- "layers": layers,
- "coverage_matrix": {"status": "pass"},
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "authority_boundary": "offline thermal_performance_pass",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("blocked_layer:hdl_sim", result["failures"])
- self.assertIn("forbidden_layer:hardware", result["failures"])
- self.assertIn("forbidden_layer:uart_strict", result["failures"])
- self.assertIn("forbidden_layer:chipwatcher", result["failures"])
- self.assertIn("forbidden_layer:thermal_performance_pass", result["failures"])
- self.assertIn("authority_overclaim_thermal_performance", result["failures"])
- def test_offline_fidelity_gate_rejects_uart_strict_and_chipwatcher_authority_overclaim(self) -> None:
- layers = {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "protocol_fuzz",
- "hdl_sim",
- "cocotb_virtual_lab",
- "virtual_driver_lab",
- "formal",
- "detector_selftest",
- "mutation",
- "thermal_digital_twin",
- "coverage_matrix",
- "td_build",
- "debug_bundle",
- ]}
- receipt = {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": {
- "status": "pass",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- },
- "layers": layers,
- "coverage_matrix": {"status": "pass"},
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "authority_boundary": "offline uart_strict pass and chipwatcher evidence passed",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("authority_overclaim_uart_strict", result["failures"])
- self.assertIn("authority_overclaim_chipwatcher", result["failures"])
- def test_offline_fidelity_gate_rejects_empty_pass_layers(self) -> None:
- layers = {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "protocol_fuzz",
- "hdl_sim",
- "cocotb_virtual_lab",
- "virtual_driver_lab",
- "formal",
- "detector_selftest",
- "mutation",
- "thermal_digital_twin",
- "coverage_matrix",
- "td_build",
- "debug_bundle",
- ]}
- receipt = {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": {
- "status": "pass",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- },
- "layers": layers,
- "coverage_matrix": {"status": "pass"},
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "authority_boundary": "offline logic, protocol, safety, debug, and virtual thermal evidence only",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer_evidence:protocol_fuzz:scenarios", result["failures"])
- self.assertIn("missing_layer_evidence:virtual_driver_lab:user_mode_shims", result["failures"])
- self.assertIn("missing_layer_evidence:mutation:mutants", result["failures"])
- self.assertIn("missing_layer_evidence:td_build:elaboration", result["failures"])
- def test_offline_fidelity_gate_accepts_required_layers_with_contract_evidence(self) -> None:
- receipt = self.valid_offline_receipt()
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "pass")
- def test_offline_fidelity_gate_rejects_default_validation_with_empty_pass_layers(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["layers"]["virtual_driver_lab"] = {"status": "pass"}
- result = validate_offline_fidelity_gate_v1_receipt(receipt)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer_evidence:virtual_driver_lab:user_mode_shims", result["failures"])
- def test_offline_fidelity_gate_rejects_incomplete_contract_coverage_matrix(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["layers"]["coverage_matrix"] = {
- "status": "pass",
- "items": [{"category": "protocol", "status": "pass", "covered_by": ["protocol_fuzz"]}],
- }
- receipt["coverage_matrix"] = receipt["layers"]["coverage_matrix"]
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer_evidence:coverage_matrix:uart_bit", result["failures"])
- self.assertIn("missing_layer_evidence:coverage_matrix:td_toolchain", result["failures"])
- def test_offline_fidelity_gate_rejects_underspecified_virtual_driver_lab(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["layers"]["virtual_driver_lab"] = {
- "status": "pass",
- "user_mode_shims": [{"name": "pyserial_loopback_url", "status": "pass", "transcript": {"roundtrip": True}}],
- "fault_contracts": ["timeout"],
- "trace_hash": "a" * 64,
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer_evidence:virtual_driver_lab:socket_pipe_transport", result["failures"])
- self.assertIn("missing_layer_evidence:virtual_driver_lab:partial_write", result["failures"])
- def test_offline_fidelity_gate_rejects_underspecified_or_failed_thermal_models(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["layers"]["thermal_digital_twin"] = {
- "status": "pass",
- "models": [{"name": "conservative", "status": "fail", "trace_hash": "c" * 64, "violations": ["ptc_not_fail_closed"]}],
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer_evidence:thermal_digital_twin:optimistic", result["failures"])
- self.assertIn("missing_layer_evidence:thermal_digital_twin:model_status", result["failures"])
- def test_offline_fidelity_gate_rejects_missing_toolchain_manifest_and_cleanup_policy(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["toolchain"] = {
- "status": "pass",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- "authority_boundary": "user-space offline toolchain bootstrap only",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_toolchain_manifest", result["failures"])
- self.assertIn("missing_toolchain_cleanup_policy", result["failures"])
- def test_offline_fidelity_gate_requires_virtual_driver_lab(self) -> None:
- layers = {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "protocol_fuzz",
- "hdl_sim",
- "cocotb_virtual_lab",
- "formal",
- "detector_selftest",
- "mutation",
- "thermal_digital_twin",
- "coverage_matrix",
- "td_build",
- "debug_bundle",
- ]}
- receipt = {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": {
- "status": "pass",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": False,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- },
- "layers": layers,
- "coverage_matrix": {"status": "pass"},
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "authority_boundary": "offline logic, protocol, safety, debug, and virtual thermal evidence only",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("missing_layer:virtual_driver_lab", result["failures"])
- def test_offline_fidelity_gate_rejects_toolchain_and_safety_overclaims(self) -> None:
- layers = {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "protocol_fuzz",
- "hdl_sim",
- "cocotb_virtual_lab",
- "virtual_driver_lab",
- "formal",
- "detector_selftest",
- "mutation",
- "thermal_digital_twin",
- "coverage_matrix",
- "td_build",
- "debug_bundle",
- ]}
- receipt = {
- "schema": "offline-fidelity-gate-v1-receipt-v1",
- "status": "pass",
- "generated_at": "2026-06-30T00:00:00Z",
- "toolchain": {
- "status": "blocked_missing_tool",
- "safety": {
- "opens_com_ports": False,
- "toggles_dtr_rts": False,
- "installs_drivers": True,
- "programs_flash": False,
- "touches_ptc_fan_bmc": False,
- },
- },
- "layers": layers,
- "coverage_matrix": {"status": "pass"},
- "safety": {
- "opens_com_ports": True,
- "toggles_dtr_rts": False,
- "programs_flash": False,
- "installs_drivers": False,
- "real_ptc_fan_bmc_action_attempted": False,
- },
- "notes": "DRIVER_INSTALL PROGRAM_FLASH",
- "authority_boundary": "offline logic, protocol, safety, debug, and virtual thermal evidence only",
- }
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("toolchain_status_not_pass:blocked_missing_tool", result["failures"])
- self.assertIn("toolchain_safety_not_false:installs_drivers", result["failures"])
- self.assertIn("safety_not_false:opens_com_ports", result["failures"])
- self.assertIn("forbidden_action_marker:DRIVER_INSTALL", result["failures"])
- self.assertIn("forbidden_action_marker:PROGRAM_FLASH", result["failures"])
- def test_offline_fidelity_gate_rejects_offline_forbidden_hardware_markers(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["notes"] = ["OPEN_COM COM3", "DTR asserted", "PROGRAM_SRAM", "connect_cable -open"]
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("forbidden_action_marker:OPEN_COM", result["failures"])
- self.assertIn("forbidden_action_marker:DTR", result["failures"])
- self.assertIn("forbidden_action_marker:PROGRAM_SRAM", result["failures"])
- self.assertIn("forbidden_action_marker:CONNECT_CABLE", result["failures"])
- def test_offline_fidelity_gate_forbidden_marker_scan_avoids_safe_substring_false_positives(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["toolchain"]["manifest"]["downloads_dir"] = r"C:\Users\Administrator\CodexToolchains\CPLD\downloads"
- receipt["toolchain"]["authority_boundary"] = "Offline probe checks user-space tools and does not enumerate COM ports."
- receipt["td_log_tail"] = "Exported ports\nsafety downloads_to_hardware=false\n"
- receipt["layers"]["td_build"]["authority_boundary"] = "does not generate/download/program a bitstream"
- receipt["coverage_matrix"]["items"][0]["required"] = ["no_download_no_program"]
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "pass")
- self.assertNotIn("forbidden_action_marker:DOWNLOAD", result["failures"])
- self.assertNotIn("forbidden_action_marker:RTS", result["failures"])
- def test_offline_fidelity_gate_still_rejects_standalone_download_action(self) -> None:
- receipt = self.valid_offline_receipt()
- receipt["notes"] = "DOWNLOAD bitstream to device"
- result = validate_offline_fidelity_gate_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("forbidden_action_marker:DOWNLOAD", result["failures"])
- def test_host_sensor_text_parser_splits_literal_escaped_cr_without_newlines(self) -> None:
- lines = ["SENS seq=00000001 status=valid valid=24 missing=00 fault=0 raw=1 drop=00000000"]
- lines.extend(
- f"DIMM seq=00000001 id={dimm:02X} raw=1F00 temp=031 missing=0 fault=0 status=valid"
- for dimm in range(24)
- )
- parsed = _parse_host_sensor_report_text("\\r".join(lines) + "\\r")
- self.assertEqual(parsed["sample_count"], 1)
- self.assertEqual(parsed["dimm_rows_per_sample"], [24])
- self.assertEqual(
- sorted(row["id"] for row in parsed["samples"][0]["dimm_rows"]),
- list(range(24)),
- )
- def test_host_sensor_text_parser_accepts_compact_seq_temp_aliases(self) -> None:
- lines = ["SENS s=0003 st=v v=18 m=00"]
- lines.extend(f"DIMM s=0003 id={dimm:02X} tp={0x30 + dimm:02X} m=0 st=v" for dimm in range(24))
- parsed = _parse_host_sensor_report_text("\r\n".join(lines) + "\r\n")
- self.assertEqual(parsed["sample_count"], 1)
- self.assertEqual(parsed["dimm_rows_per_sample"], [24])
- self.assertEqual(parsed["samples"][0]["summary"]["seq"], 3)
- self.assertEqual(parsed["samples"][0]["summary"]["valid"], 24)
- self.assertEqual(parsed["samples"][0]["summary"]["missing"], 0)
- self.assertEqual(parsed["samples"][0]["dimm_rows"][0]["temp"], 0x30)
- def test_host_sensor_text_parser_assigns_compact_dimm_rows_to_latest_sens(self) -> None:
- lines = ["SENS s=0003 st=v v=18 m=00"]
- lines.extend(f"DIMM i={dimm:02X} t={0x30 + dimm:02X} m=0" for dimm in range(24))
- parsed = _parse_host_sensor_report_text("\r\n".join(lines) + "\r\n")
- self.assertEqual(parsed["sample_count"], 1)
- self.assertEqual(parsed["dimm_rows_per_sample"], [24])
- self.assertEqual(parsed["samples"][0]["seq"], 3)
- self.assertEqual(parsed["samples"][0]["dimm_rows"][0]["seq"], 3)
- self.assertEqual(parsed["samples"][0]["dimm_rows"][0]["temp"], 0x30)
- self.assertEqual(
- sorted(row["id"] for row in parsed["samples"][0]["dimm_rows"]),
- list(range(24)),
- )
- def test_host_sensor_sidecar_recovers_compact_hex_id_from_raw_line(self) -> None:
- row = {
- "raw": "DIMM i=10 t=00 m=1 ",
- "fields": {"i": 10, "t": 0, "m": 1, "temp": 0, "missing": 1, "seq": 12},
- "temp": 0,
- "missing": 1,
- "seq": 12,
- }
- fields = _host_sensor_row_fields(row)
- self.assertEqual(fields["id"], 16)
- def test_j6raw_parser_accepts_compact_replay_fields(self) -> None:
- frames = _parse_j6raw_frames("J6RAW s=002A o=00000100 l=04 u=000A d=01020304\r\n")
- self.assertEqual(len(frames), 1)
- self.assertEqual(frames[0]["seq"], 0x2A)
- self.assertEqual(frames[0]["off"], 0x100)
- self.assertEqual(frames[0]["len"], 4)
- self.assertEqual(frames[0]["sum"], 0x000A)
- self.assertEqual(frames[0]["data_hex"], "01020304")
- def test_j6evt_parser_normalizes_compact_event_fields(self) -> None:
- events = _parse_lossless_key_value_lines("J6EVT s=06 cmd=PID_E c=01 p=000 ok=1 e=0 to=0\r\n", "J6EVT")
- self.assertEqual(len(events), 1)
- self.assertEqual(events[0]["seq"], 6)
- self.assertEqual(events[0]["cmd"], "PID_E")
- self.assertEqual(events[0]["ch"], 1)
- self.assertEqual(events[0]["pct"], 0)
- self.assertEqual(events[0]["ok"], 1)
- self.assertEqual(events[0]["err"], 0)
- self.assertEqual(events[0]["timeout"], 0)
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_uses_post_j6ready_raw_epoch(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(
- Path(tmp), hardware_status="blocked_waiting_for_real_fan_ptc_hardware"
- )
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- debug_text = Path(payload["layers"]["debug_frame_capture"]["debug_transcript"]["path"])
- replay = Path(payload["layers"]["debug_frame_capture"]["raw_replay"]["path"])
- debug_stream = Path(payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["path"])
- post_payload = bytes.fromhex("01020304")
- debug_lines = [
- "J6RAW s=00FE o=00100000 l=02 u=00FF d=AA55",
- "J6READY profile=temp-uart-ptc-remap",
- "J6RAW s=0001 o=00000000 l=04 u=000A d=01020304",
- "J6CMD",
- "J6EVT s=01 cmd=02 c=01 p=010 ok=1 e=0 to=0",
- "J6PWM seq=00000008 src=host_manual pid=disabled timeout=1 ptc01=000 ptc24=000 fan01=030 fan04=030",
- "J6MOD seq=00000008 pid=disabled pid_requested=1 pid_active=0 bmc=observe_only host=slave pwm=host_manual timeout_s=5",
- "J6MAP profile=temp-uart-ptc-remap bmc_tx=T4 bmc_rx=R5 host_tx=P7 host_rx=P8 debug_rx=P10 debug_tx=R10 ptc=24 fan=4 fg=8 install=4",
- "J6TEMP seq=00000001 status=valid valid=24 missing=00 fault=0 host_report_drop=00000000",
- "J6STAT ri=00000004 ro=00000004 rd=00 hd=00 be=00 he=00",
- ]
- debug_text.write_text("\r\n".join(debug_lines) + "\r\n", encoding="utf-8")
- replay.write_bytes(post_payload)
- debug_stream.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-debug-frame-stream-v1",
- "status": "pass",
- "frames": [{"raw": line} for line in debug_lines],
- "raw_drop": 0,
- "host_report_drop": 0,
- "bmc_berr": 0,
- "host_err": 0,
- }
- ),
- encoding="utf-8",
- )
- payload["layers"]["debug_frame_capture"]["debug_transcript"]["sha256"] = compute_file_hash(debug_text)
- payload["layers"]["debug_frame_capture"]["raw_replay"]["sha256"] = compute_file_hash(replay)
- payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["sha256"] = compute_file_hash(debug_stream)
- payload["layers"]["artifact_hashes"]["debug_transcript_sha256"] = compute_file_hash(debug_text)
- payload["layers"]["artifact_hashes"]["raw_replay_sha256"] = compute_file_hash(replay)
- payload["layers"]["artifact_hashes"]["debug_frame_stream_sha256"] = compute_file_hash(debug_stream)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertNotIn("raw_frame_seq_gap", result["failures"])
- self.assertNotIn("raw_frame_offset_gap", result["failures"])
- self.assertNotIn("raw_in_replay_len_mismatch", result["failures"])
- self.assertNotIn("raw_out_replay_len_mismatch", result["failures"])
- self.assertNotIn("raw_replay_artifact_mismatch", result["failures"])
- self.assertEqual(result["raw_replay"]["first_seq"], 1)
- self.assertEqual(result["raw_replay"]["first_off"], 0)
- self.assertEqual(result["raw_replay"]["bytes"], len(post_payload))
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_accepts_contiguous_post_stat_raw_tail(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(
- Path(tmp), hardware_status="blocked_waiting_for_real_fan_ptc_hardware"
- )
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- debug_text = Path(payload["layers"]["debug_frame_capture"]["debug_transcript"]["path"])
- replay = Path(payload["layers"]["debug_frame_capture"]["raw_replay"]["path"])
- debug_stream = Path(payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["path"])
- first = bytes.fromhex("01020304")
- tail = bytes.fromhex("AA55BB66")
- debug_lines = [
- "J6READY profile=temp-uart-ptc-remap",
- "J6RAW s=0001 o=00000000 l=04 u=000A d=01020304",
- "J6STAT ri=00000004 ro=00000004 rd=00 hd=00 be=00 he=00",
- "J6RAW s=0002 o=00000004 l=04 u=0220 d=AA55BB66",
- "J6CMD",
- "J6EVT s=01 cmd=02 c=01 p=010 ok=1 e=0 to=0",
- "J6PWM seq=00000008 src=host_manual pid=disabled timeout=1 ptc01=000 ptc24=000 fan01=030 fan04=030",
- "J6MOD seq=00000008 pid=disabled pid_requested=1 pid_active=0 bmc=observe_only host=slave pwm=host_manual timeout_s=5",
- "J6MAP profile=temp-uart-ptc-remap bmc_tx=T4 bmc_rx=R5 host_tx=P7 host_rx=P8 debug_rx=P10 debug_tx=R10 ptc=24 fan=4 fg=8 install=4",
- "J6TEMP seq=00000001 status=valid valid=24 missing=00 fault=0 host_report_drop=00000000",
- "J6TEMP seq=00000002 status=all_ff valid=00 missing=24 fault=0 host_report_drop=00000000",
- "J6TEMP seq=00000003 status=valid valid=24 missing=00 fault=0 host_report_drop=00000000",
- "J6RAW s=0003",
- ]
- debug_text.write_text("\r\n".join(debug_lines), encoding="utf-8")
- replay.write_bytes(first + tail)
- debug_stream.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-debug-frame-stream-v1",
- "status": "pass",
- "frames": [{"raw": line} for line in debug_lines[:-1]],
- "tail": {
- "post_j6stat_tail_bytes": len(tail),
- "incomplete_final_line": debug_lines[-1],
- "last_j6stat_covers_replay": False,
- },
- "raw_drop": 0,
- "host_report_drop": 0,
- "bmc_berr": 0,
- "host_err": 0,
- }
- ),
- encoding="utf-8",
- )
- payload["layers"]["debug_frame_capture"]["debug_transcript"]["sha256"] = compute_file_hash(debug_text)
- payload["layers"]["debug_frame_capture"]["raw_replay"]["sha256"] = compute_file_hash(replay)
- payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["sha256"] = compute_file_hash(debug_stream)
- payload["layers"]["artifact_hashes"]["debug_transcript_sha256"] = compute_file_hash(debug_text)
- payload["layers"]["artifact_hashes"]["raw_replay_sha256"] = compute_file_hash(replay)
- payload["layers"]["artifact_hashes"]["debug_frame_stream_sha256"] = compute_file_hash(debug_stream)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "blocked_waiting_for_real_fan_ptc_hardware", result["failures"])
- self.assertNotIn("raw_in_replay_len_mismatch", result["failures"])
- self.assertNotIn("raw_out_replay_len_mismatch", result["failures"])
- self.assertNotIn("raw_replay_artifact_mismatch", result["failures"])
- self.assertEqual(result["raw_replay"]["bytes"], len(first) + len(tail))
- self.assertEqual(result["raw_replay"]["post_j6stat_tail_bytes"], len(tail))
- self.assertFalse(result["raw_replay"]["last_j6stat_covers_replay"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_rejects_post_stat_raw_tail_with_offset_gap(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(
- Path(tmp), hardware_status="blocked_waiting_for_real_fan_ptc_hardware"
- )
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- debug_text = Path(payload["layers"]["debug_frame_capture"]["debug_transcript"]["path"])
- replay = Path(payload["layers"]["debug_frame_capture"]["raw_replay"]["path"])
- debug_stream = Path(payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["path"])
- replay_bytes = bytes.fromhex("01020304AA55BB66")
- debug_lines = [
- "J6READY profile=temp-uart-ptc-remap",
- "J6RAW s=0001 o=00000000 l=04 u=000A d=01020304",
- "J6STAT ri=00000004 ro=00000004 rd=00 hd=00 be=00 he=00",
- "J6RAW s=0002 o=00000005 l=04 u=0220 d=AA55BB66",
- "J6CMD",
- "J6EVT s=01 cmd=02 c=01 p=010 ok=1 e=0 to=0",
- "J6PWM seq=00000008 src=host_manual pid=disabled timeout=1 ptc01=000 ptc24=000 fan01=030 fan04=030",
- "J6MOD seq=00000008 pid=disabled pid_requested=1 pid_active=0 bmc=observe_only host=slave pwm=host_manual timeout_s=5",
- "J6MAP profile=temp-uart-ptc-remap bmc_tx=T4 bmc_rx=R5 host_tx=P7 host_rx=P8 debug_rx=P10 debug_tx=R10 ptc=24 fan=4 fg=8 install=4",
- "J6TEMP seq=00000001 status=valid valid=24 missing=00 fault=0 host_report_drop=00000000",
- "J6TEMP seq=00000002 status=all_ff valid=00 missing=24 fault=0 host_report_drop=00000000",
- "J6TEMP seq=00000003 status=valid valid=24 missing=00 fault=0 host_report_drop=00000000",
- ]
- debug_text.write_text("\r\n".join(debug_lines) + "\r\n", encoding="utf-8")
- replay.write_bytes(replay_bytes)
- debug_stream.write_text(
- json.dumps(
- {
- "schema": "j6-host-sensor-real-fan-ptc-debug-frame-stream-v1",
- "status": "pass",
- "frames": [{"raw": line} for line in debug_lines],
- "raw_drop": 0,
- "host_report_drop": 0,
- "bmc_berr": 0,
- "host_err": 0,
- }
- ),
- encoding="utf-8",
- )
- payload["layers"]["debug_frame_capture"]["debug_transcript"]["sha256"] = compute_file_hash(debug_text)
- payload["layers"]["debug_frame_capture"]["raw_replay"]["sha256"] = compute_file_hash(replay)
- payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["sha256"] = compute_file_hash(debug_stream)
- payload["layers"]["artifact_hashes"]["debug_transcript_sha256"] = compute_file_hash(debug_text)
- payload["layers"]["artifact_hashes"]["raw_replay_sha256"] = compute_file_hash(replay)
- payload["layers"]["artifact_hashes"]["debug_frame_stream_sha256"] = compute_file_hash(debug_stream)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "blocked_debug_frame_loss")
- self.assertIn("raw_frame_offset_gap", result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_blocks_until_real_hardware_is_present(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- final_result = validate_final_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "blocked_waiting_for_real_fan_ptc_hardware", result["failures"])
- self.assertEqual(result["real_fan_ptc_hardware_status"]["status"], "not_run")
- self.assertIn("real_fan_ptc_hardware_not_run", result["failures"])
- self.assertEqual(result["pin_map"]["fan_count"], 4)
- self.assertFalse(result["real_fan_ptc_hardware_status"]["qualifies_final_gate"])
- self.assertEqual(result["host_commands"][:4], ["SET PTC 01 10", "SET PTC 24 20", "SET FAN 01 40", "SET FAN 04 30"])
- self.assertEqual(final_result["status"], "fail")
- self.assertIn("fail_schema", final_result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_identifies_startup_ack_shift(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- transcript = Path(payload["layers"]["host_control_transcript"]["host_command_transcript"]["path"])
- transcript_payload = json.loads(transcript.read_text(encoding="utf-8"))
- commands = transcript_payload["commands"]
- commands[0].update(
- {
- "ack_line": "",
- "response_raw": "",
- "response_token": "",
- "response_class": "timeout",
- "response_seq": None,
- "response_cmd": "",
- "seq_match": False,
- "cmd_match": False,
- "accepted": False,
- }
- )
- for index in range(1, len(commands)):
- previous = commands[index - 1]
- commands[index].update(
- {
- "ack_line": previous["ack_line"] or f"OK seq={index:08X} cmd={previous['expected_ack_cmd']}",
- "response_raw": previous["response_raw"] or f"OK seq={index:08X} cmd={previous['expected_ack_cmd']}",
- "response_token": previous["response_token"] or f"OK seq={index:08X} cmd={previous['expected_ack_cmd']}",
- "response_class": "ok",
- "response_seq": index,
- "response_cmd": previous["expected_ack_cmd"],
- "seq_match": False,
- "cmd_match": commands[index]["expected_ack_cmd"] == previous["expected_ack_cmd"],
- "accepted": False,
- }
- )
- transcript_payload["status"] = "blocked_host_ack"
- transcript_payload["preflight"] = {
- "status": "missing",
- "ready_seen": False,
- "sync_ack_seen": False,
- }
- transcript.write_text(json.dumps(transcript_payload), encoding="utf-8")
- new_hash = compute_file_hash(transcript)
- payload["layers"]["host_control_transcript"]["host_command_transcript"]["sha256"] = new_hash
- payload["layers"]["artifact_hashes"]["host_command_transcript_sha256"] = new_hash
- payload["layers"]["host_control_transcript"]["status"] = "blocked_host_ack"
- payload["status"] = "blocked_host_ack"
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "blocked_host_ack")
- self.assertIn("blocked_host_startup_ack_shift", result["failures"])
- self.assertIn("host_preflight_missing", result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_identifies_mixed_epoch_ready_after_old_acks(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- transcript = Path(payload["layers"]["host_control_transcript"]["host_command_transcript"]["path"])
- transcript_payload = json.loads(transcript.read_text(encoding="utf-8"))
- transcript_payload["status"] = "blocked_host_ack"
- transcript_payload["preflight"] = {
- "schema": "j6-host-sensor-real-fan-ptc-startup-preflight-v2",
- "status": "blocked_waiting_for_ready_epoch",
- "ready_seen": False,
- "j6ready_seen": False,
- "epoch_locked": False,
- "sync_ack_seen": True,
- "preflight_ack": "OK seq=0000000D cmd=STATUS",
- "pre_sram_noise": [],
- "pre_sram_noise_count": 0,
- "counts_as_formal_command": False,
- }
- commands = transcript_payload["commands"]
- for index, command in enumerate(commands):
- response_seq = index + 14 if index < 5 else None
- response_class = "ok" if index < 5 else "timeout"
- response_cmd = command["expected_ack_cmd"] if index < 5 else ""
- response_raw = f"OK seq={response_seq:08X} cmd={response_cmd}" if response_seq is not None else ""
- command.update(
- {
- "ack_line": response_raw,
- "response_raw": response_raw,
- "response_token": response_raw,
- "response_class": response_class,
- "response_seq": response_seq,
- "response_cmd": response_cmd,
- "seq_match": False,
- "cmd_match": index < 5,
- "stale": index >= 9,
- "accepted": False,
- }
- )
- transcript.write_text(json.dumps(transcript_payload), encoding="utf-8")
- host_text = Path(payload["layers"]["host_sensor_reports"]["host_transcript_text"]["path"])
- host_text.write_text(
- "OK seq=0000000D cmd=STATUS\r\n"
- "OK seq=0000000E cmd=PTCCH\r\n"
- "OK seq=0000000F cmd=PTCCH\r\n"
- "OK seq=00000010 cmd=FANCH\r\n"
- "OK seq=00000011 cmd=FANCH\r\n"
- "OK seq=00000012 cmd=PID_EN\r\n"
- "READY profile=temp-uart-ptc-remap seq=00000000\r\n"
- "OK seq=00000001 cmd=SENSOR\r\n",
- encoding="utf-8",
- )
- payload["layers"]["host_control_transcript"]["host_command_transcript"]["sha256"] = compute_file_hash(transcript)
- payload["layers"]["host_sensor_reports"]["host_transcript_text"]["sha256"] = compute_file_hash(host_text)
- payload["layers"]["artifact_hashes"]["host_command_transcript_sha256"] = compute_file_hash(transcript)
- payload["layers"]["artifact_hashes"]["host_transcript_text_sha256"] = compute_file_hash(host_text)
- payload["layers"]["host_control_transcript"]["status"] = "blocked_host_ack"
- payload["status"] = "blocked_host_ack"
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "blocked_host_epoch_mixed")
- self.assertIn("blocked_host_epoch_mixed", result["failures"])
- self.assertIn("host_preflight_epoch_not_locked", result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_rejects_zero_based_and_out_of_range_fan_commands(self) -> None:
- scenarios = [
- ("SET PTC 00 10", "host_command_not_allowed:SET PTC 00 10"),
- ("SET PTC 25 10", "host_command_not_allowed:SET PTC 25 10"),
- ("SET FAN 00 40", "host_command_not_allowed:SET FAN 00 40"),
- ("SET FAN 05 40", "host_command_not_allowed:SET FAN 05 40"),
- ]
- for bad_command, expected_failure in scenarios:
- with self.subTest(command=bad_command):
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- payload["layers"]["host_command_sequence"]["commands"][0] = bad_command
- transcript = Path(payload["layers"]["host_control_transcript"]["host_command_transcript"]["path"])
- transcript_payload = json.loads(transcript.read_text(encoding="utf-8"))
- transcript_payload["commands"][0]["command"] = bad_command
- transcript.write_text(json.dumps(transcript_payload), encoding="utf-8")
- payload["layers"]["host_control_transcript"]["host_command_transcript"]["sha256"] = compute_file_hash(transcript)
- payload["layers"]["artifact_hashes"]["host_command_transcript_sha256"] = compute_file_hash(transcript)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail_forbidden_action")
- self.assertIn(expected_failure, result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_rejects_wrong_td_top(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- td_path = Path(payload["layers"]["td_bitstream"]["receipt"]["path"])
- td_payload = json.loads(td_path.read_text(encoding="utf-8"))
- td_payload["top_module"] = "uart_rs232_j6_host_sensor_pwm_debug921_top"
- td_path.write_text(json.dumps(td_payload), encoding="utf-8")
- payload["layers"]["td_bitstream"]["receipt"]["sha256"] = compute_file_hash(td_path)
- payload["layers"]["artifact_hashes"]["td_receipt_sha256"] = compute_file_hash(td_path)
- attestation_path = Path(payload["layers"]["manual_sram_programming"]["attestation"]["path"])
- attestation = json.loads(attestation_path.read_text(encoding="utf-8"))
- attestation["td_receipt_sha256"] = compute_file_hash(td_path)
- attestation_path.write_text(json.dumps(attestation), encoding="utf-8")
- payload["layers"]["manual_sram_programming"]["attestation"]["sha256"] = compute_file_hash(attestation_path)
- payload["layers"]["artifact_hashes"]["manual_sram_attestation_sha256"] = compute_file_hash(attestation_path)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("td_bitstream_not_host_sensor_real_fan_ptc_top", result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_rejects_old_six_fan_pin_map(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- payload["layers"]["pin_map"]["fan_count"] = 6
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("pin_map_fan_count_not_4", result["failures"])
- def test_real_bmc_j6_host_sensor_real_fan_ptc_debug921_rejects_legacy_host_sensor_pwm_sidecars(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_host_sensor_real_fan_ptc_debug921_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- report_path = Path(payload["layers"]["host_sensor_reports"]["host_sensor_report"]["path"])
- report_payload = json.loads(report_path.read_text(encoding="utf-8"))
- report_payload["schema"] = "j6-host-sensor-pwm-host-sensor-report-v1"
- report_path.write_text(json.dumps(report_payload), encoding="utf-8")
- stream_path = Path(payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["path"])
- stream_payload = json.loads(stream_path.read_text(encoding="utf-8"))
- stream_payload["schema"] = "j6-host-sensor-pwm-debug-frame-stream-v1"
- stream_path.write_text(json.dumps(stream_payload), encoding="utf-8")
- payload["layers"]["host_sensor_reports"]["host_sensor_report"]["sha256"] = compute_file_hash(report_path)
- payload["layers"]["debug_frame_capture"]["debug_frame_stream"]["sha256"] = compute_file_hash(stream_path)
- payload["layers"]["artifact_hashes"]["host_sensor_report_sha256"] = compute_file_hash(report_path)
- payload["layers"]["artifact_hashes"]["debug_frame_stream_sha256"] = compute_file_hash(stream_path)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("host_sensor_report_wrong_schema", result["failures"])
- self.assertIn("debug_frame_stream_wrong_schema", result["failures"])
- def test_real_bmc_j6_windows_required_layers_remain_unchanged(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_real_bmc_windows_gate_v2_fixture(Path(tmp))
- result = validate_real_bmc_j6_windows_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(
- result["required_layers"],
- [
- "td_bitstream",
- "manual_sram_programming",
- "windows_serial_capture",
- "real_bmc_protocol",
- "safety_contract",
- "artifact_hashes",
- ],
- )
- def test_real_bmc_j6_windows_gate_v2_accepts_j6sys_strict_evidence(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_real_bmc_windows_gate_v2_fixture(Path(tmp))
- result = validate_real_bmc_j6_windows_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "pass")
- self.assertEqual(result["last_j6sys"]["wake"], 3)
- self.assertEqual(result["last_j6sys"]["poll"], 3)
- self.assertEqual(result["last_j6sys"]["valid"], 3)
- def test_real_bmc_j6_windows_gate_v2_rejects_non_sram_and_j6sys_errors(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_real_bmc_windows_gate_v2_fixture(
- Path(tmp),
- parser_error=1,
- stale=1,
- uerr=1,
- derr=1,
- mode="PROGRAM_FLASH",
- )
- result = validate_real_bmc_j6_windows_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail_forbidden_action")
- self.assertIn("programming_not_sram", result["failures"])
- self.assertIn("j6sys_parser_error", result["failures"])
- self.assertIn("j6sys_stale", result["failures"])
- self.assertIn("j6sys_uart_error", result["failures"])
- self.assertIn("j6sys_debug_uart_error", result["failures"])
- def test_real_bmc_j6_windows_gate_v2_rejects_short_protocol_and_hash_mismatch(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_real_bmc_windows_gate_v2_fixture(Path(tmp), poll=2, valid=2)
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- payload["layers"]["artifact_hashes"]["transcript_sha256"] = "0" * 64
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_windows_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("j6sys_poll_lt_3", result["failures"])
- self.assertIn("j6sys_valid_lt_3", result["failures"])
- self.assertIn("artifact_hash_mismatch:transcript_sha256", result["failures"])
- def test_real_bmc_j6_windows_gate_v2_rejects_blocked_sidecar_json_artifacts(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- receipt = self.write_real_bmc_windows_gate_v2_fixture(Path(tmp))
- payload = json.loads(receipt.read_text(encoding="utf-8"))
- capture_layer = payload["layers"]["windows_serial_capture"]
- artifact_layer = payload["layers"]["artifact_hashes"]
- event_stream = Path(capture_layer["event_stream"]["path"])
- register_dump = Path(capture_layer["register_dump"]["path"])
- event_stream.write_text(
- json.dumps({"schema": "j6sys-event-stream-v1", "status": "blocked_missing_debug_capture", "events": []}),
- encoding="utf-8",
- )
- register_dump.write_text(
- json.dumps({"schema": "j6sys-register-dump-v1", "status": "fail_bad_capture", "debug_registers": {}}),
- encoding="utf-8",
- )
- capture_layer["event_stream"]["sha256"] = compute_file_hash(event_stream)
- capture_layer["register_dump"]["sha256"] = compute_file_hash(register_dump)
- artifact_layer["event_stream_sha256"] = compute_file_hash(event_stream)
- artifact_layer["register_dump_sha256"] = compute_file_hash(register_dump)
- receipt.write_text(json.dumps(payload), encoding="utf-8")
- result = validate_real_bmc_j6_windows_gate_v2_receipt(receipt, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("event_stream_status_not_pass:blocked_missing_debug_capture", result["failures"])
- self.assertIn("register_dump_status_not_pass:fail_bad_capture", result["failures"])
- self.assertIn("event_stream_status_not_pass:empty_events", result["failures"])
- self.assertIn("register_dump_status_not_pass:empty_registers", result["failures"])
- def test_cpld_bmc_acceptance_v1_requires_final_and_real_bmc_windows_pass(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- root = Path(tmp)
- real_bmc = self.write_real_bmc_windows_gate_v2_fixture(root)
- final = root / "final.json"
- final.write_text(
- json.dumps(
- {
- "schema": "final-gate-v2-receipt-v1",
- "status": "pass",
- "layers": {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "rtl_sim",
- "formal",
- "detector_selftest",
- "td_build",
- "uart_strict",
- ]},
- "authority_boundary": "control communication only",
- }
- ),
- encoding="utf-8",
- )
- acceptance = root / "acceptance.json"
- acceptance.write_text(
- json.dumps(
- {
- "schema": "cpld-bmc-acceptance-v1-receipt-v1",
- "status": "pass",
- "layers": {
- "final_gate_v2": {"status": "pass", "receipt": {"path": str(final), "sha256": compute_file_hash(final)}},
- "real_bmc_j6_windows_gate_v2": {"status": "pass", "receipt": {"path": str(real_bmc), "sha256": compute_file_hash(real_bmc)}},
- },
- "authority_boundary": "composite acceptance for control communication and real J6 BMC Windows evidence only.",
- }
- ),
- encoding="utf-8",
- )
- result = validate_cpld_bmc_acceptance_v1_receipt(acceptance, strict=True)
- self.assertEqual(result["status"], "pass")
- def test_cpld_bmc_acceptance_v1_propagates_child_gate_failures(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- root = Path(tmp)
- real_bmc = self.write_real_bmc_windows_gate_v2_fixture(root, valid=2)
- final = root / "final.json"
- final.write_text(
- json.dumps(
- {
- "schema": "final-gate-v2-receipt-v1",
- "status": "blocked_missing_tool",
- "layers": {},
- "authority_boundary": "control communication only",
- }
- ),
- encoding="utf-8",
- )
- acceptance = root / "acceptance.json"
- acceptance.write_text(
- json.dumps(
- {
- "schema": "cpld-bmc-acceptance-v1-receipt-v1",
- "status": "pass",
- "layers": {
- "final_gate_v2": {"status": "pass", "receipt": {"path": str(final), "sha256": compute_file_hash(final)}},
- "real_bmc_j6_windows_gate_v2": {"status": "pass", "receipt": {"path": str(real_bmc), "sha256": compute_file_hash(real_bmc)}},
- },
- "authority_boundary": "composite acceptance for control communication and real J6 BMC Windows evidence only.",
- }
- ),
- encoding="utf-8",
- )
- result = validate_cpld_bmc_acceptance_v1_receipt(acceptance, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("final_gate_v2_not_pass:fail", result["failures"])
- self.assertIn("real_bmc_j6_windows_gate_v2_not_pass:fail", result["failures"])
- def test_cpld_bmc_acceptance_v1_dict_input_still_validates_child_receipts(self) -> None:
- with tempfile.TemporaryDirectory() as tmp:
- root = Path(tmp)
- real_bmc = self.write_real_bmc_windows_gate_v2_fixture(root, valid=2)
- final = root / "final.json"
- final.write_text(
- json.dumps(
- {
- "schema": "final-gate-v2-receipt-v1",
- "status": "pass",
- "layers": {name: {"status": "pass"} for name in [
- "static",
- "model",
- "replay",
- "rtl_sim",
- "formal",
- "detector_selftest",
- "td_build",
- "uart_strict",
- ]},
- "authority_boundary": "control communication only",
- }
- ),
- encoding="utf-8",
- )
- payload = {
- "schema": "cpld-bmc-acceptance-v1-receipt-v1",
- "status": "pass",
- "layers": {
- "final_gate_v2": {"status": "pass", "receipt": {"path": str(final), "sha256": compute_file_hash(final)}},
- "real_bmc_j6_windows_gate_v2": {"status": "pass", "receipt": {"path": str(real_bmc), "sha256": compute_file_hash(real_bmc)}},
- },
- "authority_boundary": "composite acceptance for control communication and real J6 BMC Windows evidence only.",
- }
- result = validate_cpld_bmc_acceptance_v1_receipt(payload, strict=True)
- self.assertEqual(result["status"], "fail")
- self.assertIn("real_bmc_j6_windows_gate_v2_not_pass:fail", result["failures"])
- def test_legacy_real_bmc_j6_remote_collect_script_is_not_user_entrypoint(self) -> None:
- self.assertFalse((ROOT / "tools" / "remote" / "collect-real-bmc-j6.ps1").exists())
- script = (ROOT / "tools" / "remote" / "collect-j6-host-sensor-real-fan-ptc.ps1").read_text(
- encoding="utf-8"
- )
- self.assertIn("host-command-transcript.json", script)
- self.assertIn("debug-frame-stream.json", script)
- self.assertIn("bmc-raw-replay.bin", script)
- self.assertIn("real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1", script)
- if __name__ == "__main__":
- unittest.main()
|