offline-fidelity-gate-v1.zh-CN.md 6.2 KB

offline-fidelity-gate-v1

offline-fidelity-gate-v1 是无真实物理设备条件下的最严离线验证 gate。它不替代 final-gate-v2,也不降低 UART strict 或板级 receipt 的要求。它只证明离线逻辑、协议、RTL、formal、debug 可观测性、安全策略、虚拟热模型、故障注入、mutation detector、TD 离线工具证据全部通过。

Pass 语义固定为:offline-fidelity-gate-v1 proves offline logic/protocol/safety/debug/virtual-thermal evidence only and does not certify real hardware or thermal performance.

权限边界

允许:

  • 自动准备用户态离线工具链,例如 OSS CAD Suite、cocotb venv、iverilog、vvp、verilator、yosys、sby。
  • 自动准备扩展分析工具,例如 pytest/hypothesis、pyserial loopback URL、波形/trace 分析辅助工具;所有工具只能在用户态目录、venv 或临时目录内运行。
  • 运行用户态模拟驱动,例如 cocotb driver、Python driver facade、socket/pipe/mock API、BMC text driver、host register plane 和 debug UART decoder。
  • 运行 Python model、协议 fuzz、Verilog RTL simulation、cocotb virtual lab、formal、detector selftest、mutation、thermal digital twin、TD offline elaboration/build。
  • 生成 JSON receipt、debug bundle、coverage matrix 和可复现 seed/trace hash。

禁止:

  • 打开 COM 口、枚举后自动连接未知串口、切换 DTR/RTS。
  • flash、PROGRAM_FLASH、ERASE_FLASH、PROGRAM_SPIBIN、DIRECT_FLASH_WRITE。
  • 主机 OS kernel/USB/JTAG/COM 驱动安装或重装;即使可卸载,也不能进入 offline-fidelity-gate-v1 pass 证据。
  • 真实 PTC/fan/BMC 未受控动作。
  • 把 hardware、board、uart_strict、chipwatcher、thermal_performance_pass 写成离线 pass layer。

Required Layers

receipt 的 layers 必须精确包含以下 required layer,且每一层 status 必须为 pass:

  • 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

任何 blocked_*、partial、skipped、fail_*、缺证据或 dry-run 都不能提升为顶层 pass。工具缺失且用户态 bootstrap 失败时,顶层必须 fail 或 blocked,不能通过。

运行入口

python tools\pid_harness.py offline-fidelity-gate-v1 --auto-bootstrap --hdl-backend all --formal --td-build --long-run final --json --report-file <receipt.json>

--auto-bootstrap 只允许用户态工具准备。它可以下载或解压离线仿真工具,也可以创建本地 Python venv;它不能安装系统驱动、不能打开串口、不能下载到硬件、不能写 flash。

工具链缓存默认放在当前用户的 CodexToolchains\CPLD 目录下。每次自动准备都必须记录 manifest、下载 hash、工具版本、路径和 cleanup policy。toolchain-clean 默认 dry-run;只有带 .cpld_toolchain_owner.json owner marker 且 manifest 声明的用户态工具路径才允许实际删除。

虚拟实验室

Verilog testbench 保留确定性 smoke、协议边界、UART bit-level 和 RTL 基础安全场景。cocotb virtual lab 作为主虚拟实验室,覆盖:

  • UART 8N1 bit driver、start jitter、stop error、break、glitch、RX overflow、TX backpressure、debug UART overflow。
  • BMC loose text byte stream、echo/no-echo、裸 hex、0xNN、多行、乱码、短帧、长帧、bad fraction、全 missing、部分 missing。
  • host register plane、source switch、manual mode、host disable、PID history clear/freeze。
  • fault injection、scoreboard、debug UART frame decode 和 register/probe/trace 一致性。

virtual_driver_lab 是 required layer。它只证明用户态模拟驱动合同通过,覆盖 pyserial loop:// 或等价 loopback URL、socket/pipe transport、BMC text driver、host register plane、debug UART decoder,以及 timeout、disconnect、partial read/write、permission denied、buffer overflow、TX/RX backpressure 等错误路径。可选 Windows Sandbox/VM 证据只能作为隔离环境补强;主机 OS 不安装驱动,该 layer 也不声明真实驱动认证。

系统级 scoreboard 分两条线:

  • system_contract_top 覆盖 host register、BMC byte stream、actuator、安全、debug register、BRAM trace、debug probe/status。
  • uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top 覆盖真实 8N1 BMC RX/TX、COM8 HostPort、COM7 DebugPort、BMC raw 温度解析、真实 FAN/PTC 信号接口和端到端 UART 行为。

Debug 可信度

离线 gate 必须闭环 debug 证据:

  • 解码 debug_uart_tx,校验 SOF、frame_seq 单调、payload、checksum、overflow。
  • 读 0x80..0x93 debug register window,校验 event_count、frozen、overflow、last_fault、last_channel、trace read data。
  • 校验 BRAM trace wrap/freeze/clear 与 register/debug UART/probe bus 一致。

热数字孪生

thermal_digital_twin 同时运行保守、乐观、极端、随机扰动、传感器漂移、延迟、串扰、风扇退化、PTC 热惯性模型。所有模型都必须满足 fail-closed 合同才 pass。模型参数未校准时只能作为验证假设记录,不能声明真实 thermal performance。

CI 使用 60s 固定 seed 矩阵;nightly 使用 8h 请求语义和固定/随机探索;final 使用 24h 请求语义和可复现 seed。所有 seed、模型参数、场景、trace hash 必须写入 receipt。

Coverage Matrix

coverage_matrix 是 required contract coverage matrix,覆盖协议、UART bit、PID/control、safety、debug、virtual_driver_lab、thermal、fault injection、mutation、TD/toolchain。代码覆盖和功能覆盖只能作为增强指标,不能替代合同覆盖矩阵。

TD 离线工具证据

TD layer 只接受离线 elaboration/build/timing/resource 证据。它不做下载、不做 flash、不声明真实 pin map,也不声明真实电气或热性能。

与 final-gate-v2 的关系

offline-fidelity-gate-v1 是无实物最高保真 gate;final-gate-v2 仍然是当前包含 UART strict receipt 的最终 gate。需要新增真实板级 PID、flash、驱动、外部仪器或生产硬件动作时,必须新增独立 gate、receipt schema、rollback/安全边界和中文 runbook。