| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063 |
- #!/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",
- "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, "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",
- "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()
|