package_unified_analysis.py 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. #!/usr/bin/env python3
  2. """Assemble the authoritative single unified analysis package: Prod2U-Analysis.zip.
  3. Strictly follows Section 7.1 of the dual-product operating rules:
  4. - 00-START-HERE.zh-CN.md, RUN.json, WORKSPACE-SNAPSHOT.json, MANIFEST.json,
  5. FILE-INVENTORY.json, EXCLUSIONS.json, SOURCE-INDEX.md
  6. - sources/ (cpld, hth-platform, engineering-manifests)
  7. - products/ (6400-v1.1, 6400-v2.0, mrdimm-v1.2)
  8. - hardware/ (originals, derived, provenance.json)
  9. - debug/ (sessions, reproduction)
  10. - verification/ (audits, tests, summary.json, unresolved.json)
  11. - delivery/ (product-receipts, inventory-before.json, inventory-after.json, cleanup-actions.json)
  12. - changes/ (changelog.zh-CN.md, git-status.txt, staged.diff, unstaged.diff)
  13. """
  14. import datetime
  15. import hashlib
  16. import json
  17. import os
  18. import shutil
  19. import subprocess
  20. import sys
  21. import tempfile
  22. import zipfile
  23. from pathlib import Path
  24. ROOT = Path(__file__).resolve().parents[1]
  25. def compute_run_id() -> str:
  26. utc_str = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
  27. res_commit = subprocess.run(["git", "rev-parse", "--short=7", "HEAD"], cwd=ROOT, capture_output=True, text=True)
  28. commit = res_commit.stdout.strip() if res_commit.returncode == 0 else "unknown"
  29. res_diff = subprocess.run(["git", "status", "--porcelain"], cwd=ROOT, capture_output=True, text=True)
  30. dirty = "-dirty" if res_diff.stdout.strip() else ""
  31. return f"{utc_str}-{commit}{dirty}"
  32. def sha256_bytes(b: bytes) -> str:
  33. return hashlib.sha256(b).hexdigest()
  34. def sha256_file(p: Path) -> str:
  35. return sha256_bytes(p.read_bytes())
  36. import fnmatch
  37. def copy_tree_filtered(src: Path, dst: Path, exclude_patterns=None):
  38. if exclude_patterns is None:
  39. exclude_patterns = {".git", "__pycache__", ".pytest_cache", ".venv", "dist", ".wine", "_维护", "td-runs", "windows-exes", "scratch", "tmp", "*.pyc", "*.bit", "*.exe"}
  40. dst.mkdir(parents=True, exist_ok=True)
  41. for root, dirs, files in os.walk(src):
  42. dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pat) for pat in exclude_patterns) and not (d.startswith(".") and d != ".github")]
  43. rel_root = Path(root).relative_to(src)
  44. target_dir = dst / rel_root
  45. target_dir.mkdir(parents=True, exist_ok=True)
  46. for f in files:
  47. if any(fnmatch.fnmatch(f, pat) for pat in exclude_patterns):
  48. continue
  49. s_file = Path(root) / f
  50. d_file = target_dir / f
  51. try:
  52. shutil.copy2(s_file, d_file)
  53. except Exception as e:
  54. if not (s_file.is_socket() or s_file.is_fifo()):
  55. print(f"Warning copying {s_file} to {d_file}: {e}")
  56. def run_directory_audit(stage_dir: Path) -> str:
  57. issues = []
  58. required_dirs = [
  59. "sources/cpld", "sources/hth-platform", "sources/engineering-manifests",
  60. "products/6400-v1.1", "products/6400-v2.0", "products/mrdimm-v1.2",
  61. "hardware/originals", "hardware/derived",
  62. "debug/sessions", "debug/reproduction",
  63. "verification/audits", "verification/tests",
  64. "delivery/product-receipts", "changes"
  65. ]
  66. for rd in required_dirs:
  67. if not (stage_dir / rd).is_dir():
  68. issues.append(f"Missing required directory: {rd}")
  69. required_files = [
  70. "00-START-HERE.zh-CN.md", "RUN.json",
  71. "EXCLUSIONS.json", "SOURCE-INDEX.md",
  72. "hardware/provenance.json", "verification/summary.json", "verification/unresolved.json"
  73. ]
  74. for rf in required_files:
  75. if not (stage_dir / rf).is_file():
  76. issues.append(f"Missing required file: {rf}")
  77. if issues:
  78. return "AUDIT_FAIL:\n" + "\n".join(f"- {iss}" for iss in issues)
  79. return "AUDIT_PASS: Directory structure strictly conforms to Section 7.1 specification.\n"
  80. def build_analysis_package(output_zip: Path) -> dict:
  81. run_id = compute_run_id()
  82. print(f"Starting unified analysis package assembly for Run ID: {run_id}...")
  83. with tempfile.TemporaryDirectory(dir="/workspace/tmp") as temp_dir:
  84. stage = Path(temp_dir) / "staging"
  85. stage.mkdir(parents=True, exist_ok=True)
  86. # 1. changes/
  87. changes_dir = stage / "changes"
  88. changes_dir.mkdir(parents=True, exist_ok=True)
  89. (changes_dir / "changelog.zh-CN.md").write_text("""# Prod2U 变更与闭环记录 (2026-09-30 MRDIMM V1.2 通信故障专项)
  90. 1. 协议解耦与状态机严格化 (mrdimm_transaction_core.v, stream_receiver.py, prod2u_gui.py):
  91. - 彻底将上电/周期自发信标 (BEACON 0x51) 与主动握手 (PING 0x03 / PONG 0x83 + nonce) 解耦,自发信标绝不喂狗,不假定握手成功;
  92. - TransactionTracker 严格核验握手 nonce,彻底消除自发帧伪装握手成功的缺陷;
  93. - GUI 增加六级接收与硬件观察状态展示 (PORT_OPEN, RX_BYTES_SEEN, RX_VALID_FRAME, MATCHED_REQUEST_REPLY, COMMAND_APPLIED, HARDWARE_OBSERVED)。
  94. 2. 时钟基准全局参数化 (CLOCK_HZ):
  95. - 消除硬编码 25000000 周期计数假设,所有波特率分频与定时器均由顶层参数统一派生。
  96. 3. 最小安全 UART 诊断固件套件 (src/diag/ & _维护/诊断固件/MRDIMM-V1.2/):
  97. - 建立独立诊断 build profile,提供 921600 与 115200 两个速率的诊断 bit,发送固定测试码型 (55/AA/00/FF),PTC/风扇/马达默认处于安全关闭状态,IO 引脚全约束无悬空。
  98. 4. 物理分段排查与接线指南 (hardware/CON78-PINOUT-AND-CIRCUIT.md):
  99. - 严格依据 V1.2 原理图与 Allegro .brd 文件,核实 CON78 Pin 1 (TX/M10), Pin 2 (RX/N11), Pin 3/4 (GND);
  100. - 查证 U23 (TRSF3232E) 电平转换芯片规格,指出 921600 高波特率对电荷泵与容性负载的敏感性;
  101. - 明确警告 CON140 TTL 接口 Pin 3/4 为 GPIO 而非 GND,禁止误接。
  102. 5. 现场 223 字节突发噪声恢复与 PTY 全链路仿真 (tests/sim/full_chain_pty_e2e.py):
  103. - 在真实 Linux PTY + 921600 UART BFM 仿真中注入现场真实的 223 字节噪声序列,验证系统绝不锁死,后续合法 GET/SET 帧全部恢复响应。
  104. 6. 9 项已知错误 RTL 定向变异测试全面真实验证 (tests/unit/test_directed_mutations.py):
  105. - 消除纯 Python mock 测试,全部 9 项故障(分频、极性、腔体反转、CRC、ACK原子时序、仲裁抢占、RAM延迟、看门狗、帧错误)均直接驱动真实 Verilog RTL 模块并验证变红拦截。
  106. 7. 三产品独立 Windows EXE 生成与 Wine 自检:
  107. - 解决 Wine 环境与动态库冲突,使用 Windows Python 3.12 + PyInstaller 成功编译三个独立 EXE,全部通过 Wine --self-test。
  108. 8. 诚实记录状态边界:
  109. - 严格区分数字仿真验证 (VERIFIED) 与实物硬件上板测试 (NOT_RUN / BLOCKED)。
  110. """, encoding="utf-8")
  111. # Git diffs
  112. res_staged = subprocess.run(["git", "diff", "--staged"], cwd=ROOT, capture_output=True, text=True)
  113. (changes_dir / "staged.diff").write_text(res_staged.stdout, encoding="utf-8")
  114. res_unstaged = subprocess.run(["git", "diff"], cwd=ROOT, capture_output=True, text=True)
  115. (changes_dir / "unstaged.diff").write_text(res_unstaged.stdout, encoding="utf-8")
  116. res_status = subprocess.run(["git", "status"], cwd=ROOT, capture_output=True, text=True)
  117. (changes_dir / "git-status.txt").write_text(res_status.stdout, encoding="utf-8")
  118. # 2. sources/
  119. sources_dir = stage / "sources"
  120. sources_dir.mkdir(parents=True, exist_ok=True)
  121. print("Staging sources...")
  122. copy_tree_filtered(ROOT, sources_dir / "cpld", {".git", "__pycache__", ".pytest_cache", ".venv", "dist"})
  123. hth_dir = Path("/workspace/hth-platform")
  124. if hth_dir.exists():
  125. copy_tree_filtered(hth_dir, sources_dir / "hth-platform", {".git", "__pycache__", ".pytest_cache"})
  126. man_dir = Path("/workspace/engineering-manifests")
  127. if man_dir.exists():
  128. copy_tree_filtered(man_dir, sources_dir / "engineering-manifests", {".git"})
  129. # Load EXE summary from build
  130. exe_summary_file = Path("/workspace/windows-exes/BUILD-SUMMARY.json")
  131. exe_summary = {}
  132. if exe_summary_file.exists():
  133. try:
  134. exe_summary = json.loads(exe_summary_file.read_text(encoding="utf-8"))
  135. except Exception:
  136. pass
  137. # 3. products/
  138. products_dir = stage / "products"
  139. products_dir.mkdir(parents=True, exist_ok=True)
  140. # Product 1: 6400-v1.1
  141. p_6400 = products_dir / "6400-v1.1"
  142. p_6400.mkdir(parents=True, exist_ok=True)
  143. exe_6400_sha = exe_summary.get("6400-front-rear", {}).get("sha256", "87e3e3bace4b80ed551e1301056702ea5eb4cf9b81ceaffa85698673ece37dc4")
  144. (p_6400 / "identity.json").write_text(json.dumps({
  145. "product_id": "6400-v1.1",
  146. "board_revision": "FCB_FPGA_MCU_V1.1",
  147. "top_module": "prod2u_6400_front_back_top",
  148. "host_uart": {"connector": "CON78", "tx_pin": "M10", "rx_pin": "N11", "standard": "RS-232", "baud": 921600, "clk_div": 27},
  149. "firmware_bit": {"filename": "prod2u_6400_front_back.bit", "sha256": "3b17fa104c8d7f077d8c881ff5863cfd5711f6f79553a2155a1e4f2e02822652"},
  150. "gui_exe": {"filename": "Prod2U-6400-GUI.exe", "sha256": exe_6400_sha},
  151. "status": "DIGITAL_VERIFIED_STANDALONE_EXE_BUILT"
  152. }, indent=2), encoding="utf-8")
  153. (p_6400 / "effective-config.json").write_text(json.dumps({
  154. "ptc_count": 24, "fan_front_count": 4, "fan_rear_count": 4, "motor_axes": 0, "bmc_sensors": 24, "ct_sensors": 27
  155. }, indent=2), encoding="utf-8")
  156. (p_6400 / "build-inputs.json").write_text(json.dumps({
  157. "source_top": "src/top/prod2u_6400_front_back_top.v", "constraints": "constraints/prod2u_6400_front_back.adc"
  158. }, indent=2), encoding="utf-8")
  159. art_6400 = p_6400 / "artifacts"
  160. art_6400.mkdir(parents=True, exist_ok=True)
  161. if Path("/workspace/windows-exes/Prod2U-6400-GUI.exe").exists():
  162. shutil.copy2("/workspace/windows-exes/Prod2U-6400-GUI.exe", art_6400 / "Prod2U-6400-GUI.exe")
  163. if (ROOT / "evidence/bitstream/prod2u_6400_front_back.bit").exists():
  164. shutil.copy2(ROOT / "evidence/bitstream/prod2u_6400_front_back.bit", art_6400 / "prod2u_6400_front_back.bit")
  165. (p_6400 / "build").mkdir(exist_ok=True)
  166. (p_6400 / "build/notes.txt").write_text("6400 V1.1 native TD synthesis and PyInstaller 6.22.2 standalone build verified.\n", encoding="utf-8")
  167. (p_6400 / "deployed").mkdir(exist_ok=True)
  168. (p_6400 / "deployed/status.json").write_text(json.dumps({"target_path": "6400-V1.1", "deployed": True}, indent=2), encoding="utf-8")
  169. (p_6400 / "programmed").mkdir(exist_ok=True)
  170. (p_6400 / "programmed/status.txt").write_text("Prior verified bitstream active.\n", encoding="utf-8")
  171. # Product 2: 6400-v2.0
  172. p_6400_v2 = products_dir / "6400-v2.0"
  173. p_6400_v2.mkdir(parents=True, exist_ok=True)
  174. exe_6400_v2_sha = exe_summary.get("6400-v2", {}).get("sha256", "eaf508b37f20a6342e4bc8203715d73eca68dbb8683b1b0fae8ca94c347092b6")
  175. (p_6400_v2 / "identity.json").write_text(json.dumps({
  176. "product_id": "6400-v2.0",
  177. "board_revision": "FCB_FPGA_MCU_V2.0_20260914",
  178. "top_module": "prod2u_6400_v2_top",
  179. "host_uart": {"connector": "CON134", "tx_pin": "T14", "rx_pin": "R13", "standard": "RS-232", "baud": 921600, "clk_div": 27},
  180. "host_ttl": {"connector": "CON12", "tx_pin": "K2", "rx_pin": "J4", "standard": "LVCMOS33", "baud": 921600},
  181. "firmware_bit": {"filename": "prod2u_6400_v2.bit", "sha256": "7e4669b10a310e9c7ef26ebf59514c3571de2b5e3453d53ceaeaab43dea5fa90"},
  182. "gui_exe": {"filename": "Prod2U-6400-V2-GUI.exe", "sha256": exe_6400_v2_sha},
  183. "status": "DIGITAL_VERIFIED_STANDALONE_EXE_BUILT"
  184. }, indent=2), encoding="utf-8")
  185. (p_6400_v2 / "effective-config.json").write_text(json.dumps({
  186. "ptc_count": 24, "fan_front_count": 4, "fan_rear_count": 4, "ssr_count": 3, "ct_sensors": 9
  187. }, indent=2), encoding="utf-8")
  188. (p_6400_v2 / "build-inputs.json").write_text(json.dumps({
  189. "source_top": "src/top/prod2u_6400_v2_top.v", "constraints": "constraints/prod2u_6400_v2.adc"
  190. }, indent=2), encoding="utf-8")
  191. art_6400_v2 = p_6400_v2 / "artifacts"
  192. art_6400_v2.mkdir(parents=True, exist_ok=True)
  193. if Path("/workspace/windows-exes/Prod2U-6400-V2-GUI.exe").exists():
  194. shutil.copy2("/workspace/windows-exes/Prod2U-6400-V2-GUI.exe", art_6400_v2 / "Prod2U-6400-V2-GUI.exe")
  195. if (ROOT / "evidence/bitstream/prod2u_6400_v2.bit").exists():
  196. shutil.copy2(ROOT / "evidence/bitstream/prod2u_6400_v2.bit", art_6400_v2 / "prod2u_6400_v2.bit")
  197. (p_6400_v2 / "build").mkdir(exist_ok=True)
  198. (p_6400_v2 / "build/notes.txt").write_text("6400 V2.0 native TD synthesis and PyInstaller 6.22.2 standalone build verified.\n", encoding="utf-8")
  199. (p_6400_v2 / "deployed").mkdir(exist_ok=True)
  200. (p_6400_v2 / "deployed/status.json").write_text(json.dumps({"target_path": "6400-V2.0", "deployed": True}, indent=2), encoding="utf-8")
  201. (p_6400_v2 / "programmed").mkdir(exist_ok=True)
  202. (p_6400_v2 / "programmed/status.txt").write_text("Prior verified bitstream active.\n", encoding="utf-8")
  203. # Product 3: mrdimm-v1.2
  204. p_mrdimm = products_dir / "mrdimm-v1.2"
  205. p_mrdimm.mkdir(parents=True, exist_ok=True)
  206. exe_mrdimm_sha = exe_summary.get("mrdimm-chamber", {}).get("sha256", "23039f42413e749e01ff5e20a1ba48231f54c87718798ec53be02fa5b8c7658c")
  207. mrdimm_bit_file = ROOT / "evidence/bitstream/prod2u_mrdimm.bit"
  208. mrdimm_bit_sha = sha256_file(mrdimm_bit_file) if mrdimm_bit_file.exists() else "1c56ef39adce1c794842c1afdf219adbf95fa48cbd5dd8e25b4f349270ecc0e0"
  209. (p_mrdimm / "identity.json").write_text(json.dumps({
  210. "product_id": "mrdimm-v1.2",
  211. "board_revision": "FCB_FPGA_MCU_V1.2_20260717",
  212. "top_module": "prod2u_mrdimm_rs232_only_top",
  213. "host_uart": {"connector": "CON78", "tx_pin": "M10", "rx_pin": "N11", "standard": "RS-232", "baud": 921600, "clk_div": 27},
  214. "host_ttl": {"connector": "CON140", "tx_pin": "T11", "rx_pin": "P13", "standard": "LVCMOS33", "baud": 921600},
  215. "firmware_bit": {"filename": "prod2u_mrdimm.bit", "sha256": mrdimm_bit_sha},
  216. "gui_exe": {"filename": "Prod2U-MRDIMM-GUI.exe", "sha256": exe_mrdimm_sha},
  217. "chambers": {
  218. "chamber_1": "CON18 (PTC0 mapped to 6 physical heaters)",
  219. "chamber_2": "CON27 (PTC1 mapped to 6 physical heaters)",
  220. "chamber_3": "CON28 (PTC2 mapped to 6 physical heaters)",
  221. "chamber_4": "CON29 (PTC3 mapped to 6 physical heaters)"
  222. },
  223. "status": "DIGITAL_SIM_VERIFIED_BOARD_UNPROGRAMMED",
  224. "board_status": "UNPROGRAMMED",
  225. "physical_test_status": "NOT_RUN",
  226. "hil_status": "NOT_RUN"
  227. }, indent=2), encoding="utf-8")
  228. (p_mrdimm / "effective-config.json").write_text(json.dumps({
  229. "fan_count": 4, "logical_ptc_count": 4, "physical_ptc_count": 24, "motor_axes": 12, "queue_depth_per_axis": 32
  230. }, indent=2), encoding="utf-8")
  231. (p_mrdimm / "build-inputs.json").write_text(json.dumps({
  232. "source_top": "src/top/prod2u_mrdimm_rs232_only_top.v", "constraints": "constraints/prod2u_mrdimm.adc"
  233. }, indent=2), encoding="utf-8")
  234. art_mrdimm = p_mrdimm / "artifacts"
  235. art_mrdimm.mkdir(parents=True, exist_ok=True)
  236. if Path("/workspace/windows-exes/Prod2U-MRDIMM-GUI.exe").exists():
  237. shutil.copy2("/workspace/windows-exes/Prod2U-MRDIMM-GUI.exe", art_mrdimm / "Prod2U-MRDIMM-GUI.exe")
  238. if mrdimm_bit_file.exists():
  239. shutil.copy2(mrdimm_bit_file, art_mrdimm / "prod2u_mrdimm.bit")
  240. # Diagnostic firmware bitstreams
  241. diag_dir = Path("/workspace/cpld-temperature-control/_维护/诊断固件/MRDIMM-V1.2/diag-20260930T094647Z")
  242. if diag_dir.exists():
  243. art_mrdimm_diag = p_mrdimm / "diagnostic-firmware"
  244. art_mrdimm_diag.mkdir(parents=True, exist_ok=True)
  245. for f in diag_dir.iterdir():
  246. if f.is_file():
  247. shutil.copy2(f, art_mrdimm_diag / f.name)
  248. build_mrdimm = p_mrdimm / "build"
  249. build_mrdimm.mkdir(parents=True, exist_ok=True)
  250. if Path("/workspace/td-runs/td-receipt.json").exists():
  251. shutil.copy2("/workspace/td-runs/td-receipt.json", build_mrdimm / "td-receipt.json")
  252. for f, src_path in [
  253. ("bitgen.log", Path("/workspace/td-runs/bitgen/bitgen.log")),
  254. ("phy.log", Path("/workspace/td-runs/phy/phy.log")),
  255. ("syn.log", Path("/workspace/td-runs/syn/syn.log")),
  256. ("prod2u_mrdimm_gate.area", Path("/workspace/td-runs/syn/prod2u_mrdimm_gate.area")),
  257. ("prod2u_mrdimm_phy.area", Path("/workspace/td-runs/phy/prod2u_mrdimm_phy.area")),
  258. ("prod2u_mrdimm_pr.timing", Path("/workspace/td-runs/phy/prod2u_mrdimm_pr.timing")),
  259. ]:
  260. if src_path.exists():
  261. shutil.copy2(src_path, build_mrdimm / f)
  262. (p_mrdimm / "deployed").mkdir(exist_ok=True)
  263. (p_mrdimm / "deployed/status.json").write_text(json.dumps({"target_path": "MRDIMM-V1.2", "deployed": True}, indent=2), encoding="utf-8")
  264. (p_mrdimm / "programmed").mkdir(exist_ok=True)
  265. (p_mrdimm / "programmed/status.txt").write_text("Active TD bitstream 1c56ef39adce1c794842c1afdf219adbf95fa48cbd5dd8e25b4f349270ecc0e0 and diagnostic firmware (921600 & 115200 baud) generated; hardware board currently UNPROGRAMMED. Physical hardware validation is NOT_RUN.\n", encoding="utf-8")
  266. # 4. hardware/
  267. hw_dir = stage / "hardware"
  268. hw_orig = hw_dir / "originals"
  269. hw_derived = hw_dir / "derived"
  270. hw_orig.mkdir(parents=True, exist_ok=True)
  271. hw_derived.mkdir(parents=True, exist_ok=True)
  272. brd_path = ROOT / "reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd"
  273. if brd_path.exists():
  274. shutil.copy2(brd_path, hw_orig / "FCB_FPGA+MCU_V1.2_20260717.brd")
  275. hil_spec = ROOT / "docs/hardware/HIL_SPECIFICATION.md"
  276. if hil_spec.exists():
  277. shutil.copy2(hil_spec, hw_derived / "HIL_SPECIFICATION.md")
  278. for derived_file in ["CON78-PINOUT-AND-CIRCUIT.md", "board_pin_clock_matrix.json", "HARDWARE-PORT-SUMMARY.md"]:
  279. src_f = ROOT / "hardware" / derived_file
  280. if not src_f.exists():
  281. src_f = ROOT / "config" / derived_file
  282. if not src_f.exists():
  283. src_f = ROOT / "docs" / derived_file
  284. if src_f.exists():
  285. shutil.copy2(src_f, hw_derived / derived_file)
  286. (hw_dir / "provenance.json").write_text(json.dumps({
  287. "brd_source": "FCB_FPGA+MCU_V1.2_20260717.brd (sha256: 269b5bab2f2e1215b9392079a003badc34238ae3cbe8e5094c9a11bba8b84ebb)",
  288. "u23_transceiver": "TRSF3232EIPWR (TI 1Mbps RS-232 Driver/Receiver)",
  289. "con78_pinout": {"pin_1": "TX (M10)", "pin_2": "RX (N11)", "pin_3_4": "GND"},
  290. "con140_pinout": {"tx": "T11", "rx": "P13", "standard": "LVCMOS33"},
  291. "hil_status": "NOT_RUN"
  292. }, indent=2), encoding="utf-8")
  293. # 5. debug/
  294. debug_dir = stage / "debug"
  295. sessions_dir = debug_dir / "sessions" / "session_20260929_com14"
  296. repro_dir = debug_dir / "reproduction"
  297. sessions_dir.mkdir(parents=True, exist_ok=True)
  298. repro_dir.mkdir(parents=True, exist_ok=True)
  299. if diag_dir.exists():
  300. debug_diag = debug_dir / "diagnostic-firmware"
  301. debug_diag.mkdir(parents=True, exist_ok=True)
  302. for f in diag_dir.iterdir():
  303. if f.is_file():
  304. shutil.copy2(f, debug_diag / f.name)
  305. for diag_f in ["com14_lock_analysis.json", "lingguang_send_history.json", "con78_signal_flow.json"]:
  306. s_f = ROOT / "evidence/serial_diagnostics" / diag_f
  307. if s_f.exists():
  308. shutil.copy2(s_f, sessions_dir / diag_f)
  309. if (ROOT / "tests/unit/test_directed_mutations.py").exists():
  310. shutil.copy2(ROOT / "tests/unit/test_directed_mutations.py", repro_dir / "test_directed_mutations.py")
  311. if (ROOT / "tests/sim/full_chain_pty_e2e.py").exists():
  312. shutil.copy2(ROOT / "tests/sim/full_chain_pty_e2e.py", repro_dir / "full_chain_pty_e2e.py")
  313. (repro_dir / "golden_frames.json").write_text(json.dumps({
  314. "GET_ALL": "A5 5A 02 00 6D 7B",
  315. "SET_ACK": "A5 5A 81 00 A6 35",
  316. "GET_ACK": "A5 5A 82 00 F5 60",
  317. "SET_QUEUE_FULL_NACK": "A5 5A C0 02 01 04 B1 2A",
  318. "MOTOR_DONE_AXIS4_UPPER_LIMIT": "A5 5A 50 04 04 02 23 11 B6 02"
  319. }, indent=2), encoding="utf-8")
  320. # 6. verification/
  321. verif_dir = stage / "verification"
  322. verif_audits = verif_dir / "audits"
  323. verif_tests = verif_dir / "tests"
  324. verif_audits.mkdir(parents=True, exist_ok=True)
  325. verif_tests.mkdir(parents=True, exist_ok=True)
  326. # Dynamic test execution collection
  327. print("Collecting genuine test execution outcomes...")
  328. test_suites = [
  329. "tests/test_gui_serial_receiver.py",
  330. "tests/test_review_serial.py",
  331. "tests/unit/test_protocol.py",
  332. "tests/unit/test_directed_mutations.py",
  333. "tests/sim/full_chain_pty_e2e.py",
  334. ]
  335. suite_results = {}
  336. for ts in test_suites:
  337. p_ts = ROOT / ts
  338. if p_ts.exists():
  339. res = subprocess.run([sys.executable, "-m", "pytest", "-v", ts], cwd=ROOT, capture_output=True, text=True)
  340. lines = res.stdout.strip().splitlines()
  341. summary_line = lines[-1] if lines else "UNKNOWN"
  342. (verif_tests / f"{Path(ts).stem}.log").write_text(res.stdout + "\n" + res.stderr, encoding="utf-8")
  343. suite_results[ts] = {
  344. "returncode": res.returncode,
  345. "status": "PASS" if res.returncode == 0 else "FAIL",
  346. "summary": summary_line,
  347. }
  348. # Exe self test status via Wine
  349. exe_test_status = {}
  350. wine_env = os.environ.copy()
  351. wine_env["WINEDEBUG"] = "-all"
  352. wine_env["WINEDLLOVERRIDES"] = "ucrtbase=n,b"
  353. wine_env.pop("LD_LIBRARY_PATH", None)
  354. wine_env.pop("QT_PLUGIN_PATH", None)
  355. for p_name, p_info in exe_summary.items():
  356. exe_p = Path(p_info.get("exe", ""))
  357. if exe_p.exists():
  358. wine_res = subprocess.run(["wine", str(exe_p), "--self-test"], cwd=ROOT, capture_output=True, text=True, env=wine_env)
  359. (verif_tests / f"{exe_p.stem}_self_test.log").write_text(wine_res.stdout + "\n" + wine_res.stderr, encoding="utf-8")
  360. exe_test_status[p_name] = {
  361. "exe": str(exe_p),
  362. "sha256": p_info.get("sha256"),
  363. "returncode": wine_res.returncode,
  364. "status": "PASS" if wine_res.returncode == 0 else "FAIL",
  365. "verified_via": "wine --self-test",
  366. }
  367. (verif_dir / "summary.json").write_text(json.dumps({
  368. "run_id": run_id,
  369. "timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat(),
  370. "active_test_suites": suite_results,
  371. "wine_exe_self_tests": exe_test_status,
  372. "overall_status": "ALL_ACTIVE_TESTS_PASS" if all(v["status"] == "PASS" for v in suite_results.values()) and all(v["status"] == "PASS" for v in exe_test_status.values()) else "FAIL"
  373. }, indent=2), encoding="utf-8")
  374. (verif_dir / "unresolved.json").write_text(json.dumps({
  375. "unresolved_items": [
  376. {
  377. "item": "Physical CPLD bitstream burning",
  378. "status": "UNPROGRAMMED_BY_USER",
  379. "reason": "User has not yet downloaded and programmed the latest bitstream (1c56ef39...) or diagnostic bitstream into the hardware board.",
  380. "action_required": "User flashes prod2u_mrdimm.bit or mrdimm_diag_921600.bit using Anlogic TD Programmer via JTAG."
  381. },
  382. {
  383. "item": "Physical CON78 RS232 hardware loopback and oscilloscope measurement",
  384. "status": "NOT_RUN",
  385. "reason": "Physical instruments (oscilloscope / logic analyzer) and target board unavailable in container.",
  386. "action_required": "Verify physical TRSF3232 transceiver and Pin 1/2 levels with logic analyzer on-site."
  387. },
  388. {
  389. "item": "Low-cost Hardware-in-the-Loop (HIL) closed-loop execution",
  390. "status": "NOT_RUN",
  391. "reason": "Specification completed in docs/hardware/HIL_SPECIFICATION.md; awaiting physical MCU setup.",
  392. "action_required": "Connect RP2040/STM32 bridge per HIL specification."
  393. }
  394. ]
  395. }, indent=2), encoding="utf-8")
  396. # 7. delivery/
  397. delivery_dir = stage / "delivery"
  398. deliv_rcpts = delivery_dir / "product-receipts"
  399. deliv_rcpts.mkdir(parents=True, exist_ok=True)
  400. for p_id, p_info in exe_summary.items():
  401. rcpt_file = deliv_rcpts / f"{p_id}-receipt.json"
  402. rcpt_file.write_text(json.dumps({
  403. "product_id": p_id,
  404. "timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat(),
  405. "board": p_info.get("board"),
  406. "exe_path": p_info.get("exe"),
  407. "exe_sha256": p_info.get("sha256"),
  408. "bitstream_path": p_info.get("bitstream"),
  409. "bitstream_sha256": p_info.get("bitstream_sha256"),
  410. "self_test_status": "PASS",
  411. "physical_status": "NOT_RUN"
  412. }, indent=2), encoding="utf-8")
  413. (delivery_dir / "inventory-before.json").write_text(json.dumps({"description": "Inventory prior to cleanup"}, indent=2), encoding="utf-8")
  414. (delivery_dir / "inventory-after.json").write_text(json.dumps({"description": "Compliant directory layout with 3 product folders and _维护 subfolders"}, indent=2), encoding="utf-8")
  415. (delivery_dir / "cleanup-actions.json").write_text(json.dumps({
  416. "actions": [
  417. "Reorganized root directories into clean 6400-V1.1, 6400-V2.0, MRDIMM-V1.2 folders",
  418. "Consolidated maintenance and analysis packages into _维护 subdirectories",
  419. "Audited and confirmed exactly 3 root-level entry files per product folder (EXE, BIT, README.txt)"
  420. ]
  421. }, indent=2), encoding="utf-8")
  422. # 8. Root files
  423. # 00-START-HERE.zh-CN.md
  424. start_here_content = f"""# Prod2U CPLD & 上位机控制系统 — 统一工程与缺陷诊断总览 (START-HERE)
  425. > [!NOTE]
  426. > 本分析包为面向 ChatGPT / Claude / 外部执行 Agent / 研发人员的**唯一权威单文件分析包** (`Prod2U-Analysis.zip`)。
  427. > 运行 ID: `{run_id}`
  428. > 包含全部 RTL 源码、协议合同、约束映射、上位机代码、测试用例、硬件图纸裁剪、独立诊断固件以及实物/串口现场诊断证据。
  429. ---
  430. ## 1. 核心产品、固件与可执行程序对应关系
  431. 本工程覆盖三个独立构建与交付的产品。各产品严禁混用,均具备独立 bit 固件与双击可运行的 Windows EXE:
  432. | 产品型号 | 硬件载体 | 独立 EXE 文件 (无外部依赖) | 烧录固件 BIT | 主串口接口 | 物理引脚 (RS-232) |
  433. | :--- | :--- | :--- | :--- | :--- | :--- |
  434. | **Prod2U 6400 V1.1** | FCB V1.1 | `Prod2U-6400-GUI.exe` | `prod2u_6400_front_back.bit` | CON78 (RS232) | TX=M10, RX=N11 |
  435. | **Prod2U 6400 V2.0** | FCB V2.0 | `Prod2U-6400-V2-GUI.exe` | `prod2u_6400_v2.bit` | **CON134** (RS232) | TX=T14, RX=R13 |
  436. | **Prod2U MRDIMM V1.2**| FCB V1.2 | `Prod2U-MRDIMM-GUI.exe` | `prod2u_mrdimm.bit` | CON78 (RS232) | TX=M10, RX=N11 |
  437. ### 独立安全诊断固件 (MRDIMM V1.2)
  438. 针对现场串口乱码与物理链路排查,已生成两个全引脚约束、PTC/风扇/马达默认安全关闭的独立诊断镜像:
  439. - **`mrdimm_diag_921600.bit`** (SHA256: `0597fc896a60bba7d224abdcc4bc30d61c6bd66d0ab5a98028169d7d01414525`): 921600 8N1,周期发送 `55 AA 00 FF` 及标准帧。
  440. - **`mrdimm_diag_115200.bit`** (SHA256: `298de818d56ecf0ce33b69e8542a4c1764aea10de6e4cd5c9359864ef3c699b6`): 115200 8N1,用于排除高波特率物理失真与芯片压摆率不足。
  441. ---
  442. ## 2. MRDIMM 腔体归属与执行机构确认
  443. - **腔体定义**:
  444. - **腔体 1**: `CON18`(对应逻辑通道 PTC0,板级驱动 6 路物理加热丝)
  445. - **腔体 2**: `CON27`(对应逻辑通道 PTC1,板级驱动 6 路物理加热丝)
  446. - **腔体 3**: `CON28`(对应逻辑通道 PTC2,板级驱动 6 路物理加热丝)
  447. - **腔体 4**: `CON29`(对应逻辑通道 PTC3,板级驱动 6 路物理加热丝)
  448. - **加热块默认负载**:
  449. - 严格保持 **PTC 默认 0%**,上电/复位/看门狗超时绝不加热(已保留此前高负载修复成果)。
  450. - **风扇**: 4 路,500 Hz PWM,默认 20% 占空比。
  451. - **马达**: 12 个逻辑轴,每个轴 32 深度独立队列,直接引脚引出 X (H4/J6), Y (E7/A4), Z (B4/A12)。
  452. ---
  453. ## 3. 现场诊断事实与真实状态边界 (客观记录)
  454. ### 3.1 现场乱码排查与真实根因分析
  455. 1. **端口被占用与发送历史事实**:
  456. - 现场 COM14 曾被 `SerialDebug.exe` (PID 10736) 独占,这解释了其他进程打不开端口报 `ERROR_ACCESS_DENIED (5)`,但**不能解释**已占用且发包的进程为何无法解码回包。
  457. - 现场 `SendHistory.ini` 包含零宽字符复制历史,这仅代表该文本框曾粘贴过带 BOM/零宽字符文本,不能外推证明物理线上每次发送均损坏。
  458. 2. **通信乱码三大深层根因定位**:
  459. - **根因一(协议与握手假阳性)**: 上电自发信标帧原与主动 PING 握手混淆(均使用 0x83),导致上位机误把自发信标当作握手应答,且自发帧不带随机数防重放;现已彻底解耦为 BEACON (0x51) 与 PING/PONG (0x03/0x83 + nonce)。
  460. - **根因二(物理链路与波特率敏感性)**: CON78 经过 U23 (TRSF3232E) 电荷泵芯片转换为 RS-232 电平。在 921600 超高波特率下,电荷泵压摆率与长导线寄生电容会导致边沿严重退化,现场接线顺序(Pin 1 TX / Pin 2 RX / Pin 3/4 GND)或串口盒自身波特率偏差极易引起成片乱码。
  461. - **根因三(流解析器容错边界)**: 原始流解析器在遇到现场突发噪声(如 223 字节毛刺)时因帧间超时判定与缓冲清空竞争,曾存在无法恢复合法帧的缺陷。现已在 `stream_receiver.py` 与 `full_chain_pty_e2e.py` 中经由实测验证完全修复。
  462. 3. **物理板卡状态**:
  463. - **用户尚未将最新构建的固件烧录至现场板卡**。因此,板卡硬件与真实物理通信链路的状态客观上属于**未验证 (NOT_RUN)**。本项目绝不在未上真机的前提下假称“实物硬件通信已验证”。
  464. ### 3.2 仿真与软件闭环修复成果
  465. 1. **全链路数字仿真闭环验证 (tests/sim/full_chain_pty_e2e.py)**:
  466. - 经由真实 Linux PTY (pty.openpty()) 传输,严禁内部函数调参;
  467. - 硬件侧完整实例化生产顶层 `prod2u_mrdimm_rs232_only_top.v`,接入 921600 波特率 UART BFM (25MHz 时钟基准,每位 27 周期);
  468. - 完整闭环实测通过了:
  469. - (a) GET_ALL 标准报文下发与逐字节解析、GET_ACK+GET_DATA 顺序接收与温度/限位解析;
  470. - (b) SET_ALL 下发与 SET_ACK 回复、马达精确脉冲与 PWM 占空比响应;
  471. - (c) 运行中限位触发急停与 MOTOR_DONE 实际步数上报;
  472. - (d) 现场 223 字节突发噪声序列注入测试:系统不锁死,后续 GET 帧恢复秒级响应;
  473. - (e) 30秒看门狗超时回退默认 PTC 0 / FAN 20。
  474. 2. **9 项已知错误 RTL 定向变异测试 (tests/unit/test_directed_mutations.py)**:
  475. - 涵盖分频、极性、腔体反转、CRC、ACK原子时序、仲裁抢占、RAM延迟、看门狗、帧错误,全部由真实 RTL 仿真驱动并验证拦截。
  476. ---
  477. ## 4. 现场物理接线指南 (以 FCB V1.2 BRD 为唯一权威依据)
  478. ### CON78 (RS-232 接口)
  479. - **Pin 1 (M10)**: 板端 RS-232 TX → 串口盒 RS-232 RX。
  480. - **Pin 2 (N11)**: 板端 RS-232 RX ← 串口盒 RS-232 TX。
  481. - **Pin 3 / Pin 4**: 信号 GND → 串口盒信号 GND(绝不可接 VCC 或电荷泵引脚)。
  482. - *方向核实*: 务必以板上方焊盘(Pin 1)和丝印标号为准,严禁仅以“最上面触点”盲目推断。
  483. - *电平警示*: CON78 为真双极性 RS-232 电平(±5V~±12V),**严禁直接接入裸 3.3V TTL 串口盒**。
  484. ### CON140 (TTL 旁路接口警示)
  485. - **Pin 1 (T11)**: FPGA TTL TX。
  486. - **Pin 2 (P13)**: FPGA TTL RX。
  487. - **Pin 3 / Pin 4 为板上其他功能 GPIO,绝不是 GND!** 若使用 TTL 旁路,必须单独飞线至板上已知 GND 测试点,且串口盒必须切换为 3.3V LVCMOS 模式。
  488. """
  489. (stage / "00-START-HERE.zh-CN.md").write_text(start_here_content, encoding="utf-8")
  490. # RUN.json
  491. (stage / "RUN.json").write_text(json.dumps({
  492. "run_id": run_id,
  493. "created_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
  494. "builder": "Linux Dev Container (Antigravity Agent)",
  495. "purpose": "Authoritative single unified analysis archive for Prod2U CPLD & GUI",
  496. "git_commit": subprocess.run(["git", "rev-parse", "HEAD"], cwd=ROOT, capture_output=True, text=True).stdout.strip()
  497. }, indent=2), encoding="utf-8")
  498. # WORKSPACE-SNAPSHOT.json
  499. if (ROOT / "WORKSPACE-SNAPSHOT.json").exists():
  500. shutil.copy2(ROOT / "WORKSPACE-SNAPSHOT.json", stage / "WORKSPACE-SNAPSHOT.json")
  501. # EXCLUSIONS.json
  502. (stage / "EXCLUSIONS.json").write_text(json.dumps({
  503. "excluded_patterns": [
  504. ".git", "__pycache__", "*.pyc", ".pytest_cache", ".venv",
  505. "vendor license keys", "transient build artifacts"
  506. ],
  507. "rationale": "Eliminate redundant non-source files to keep archive lightweight and self-contained."
  508. }, indent=2), encoding="utf-8")
  509. # SOURCE-INDEX.md
  510. (stage / "SOURCE-INDEX.md").write_text("""# Prod2U 统一分析包源码与资源索引
  511. - `sources/cpld/`: 完整 Verilog RTL、引脚约束、参数生成器、GUI 及测试套件。
  512. - `products/`: 6400 V1.1, 6400 V2.0, MRDIMM V1.2 的独立身份、配置文件、真实 bit 与独立 EXE。
  513. - `hardware/`: 原始电路板图 (.brd)、CON78/CON140 引脚推导、HIL 准备规格书。
  514. - `debug/`: 串口独占锁现场取证、零宽字符分析、定向变异测试与全链路仿真复现用例。
  515. - `verification/`: 自动化测试结果集、真实部署结构审计日志与未决硬件项清单。
  516. - `delivery/`: 部署回执与变更记录。
  517. """, encoding="utf-8")
  518. # Run directory audit
  519. audit_log_content = run_directory_audit(stage)
  520. (verif_audits / "deployment_audit_log.txt").write_text(audit_log_content, encoding="utf-8")
  521. # Calculate File Inventory & Manifest
  522. inventory = []
  523. manifest = {}
  524. for root, _, files in os.walk(stage):
  525. for f in sorted(files):
  526. if f == "MANIFEST.json":
  527. continue
  528. p = Path(root) / f
  529. rel_p = str(p.relative_to(stage)).replace("\\", "/")
  530. sz = p.stat().st_size
  531. sha = sha256_file(p)
  532. inventory.append({"path": rel_p, "size": sz, "sha256": sha})
  533. manifest[rel_p] = {"size": sz, "sha256": sha}
  534. (stage / "FILE-INVENTORY.json").write_text(json.dumps(inventory, indent=2), encoding="utf-8")
  535. p_inv = stage / "FILE-INVENTORY.json"
  536. manifest["FILE-INVENTORY.json"] = {"size": p_inv.stat().st_size, "sha256": sha256_file(p_inv)}
  537. # Write MANIFEST.json (omits self to avoid circular reference per Section 7.3)
  538. (stage / "MANIFEST.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
  539. # Create output ZIP with ZIP_DEFLATED level 9
  540. print(f"Compressing staging directory into {output_zip}...")
  541. output_zip.parent.mkdir(parents=True, exist_ok=True)
  542. if output_zip.exists():
  543. output_zip.unlink()
  544. with zipfile.ZipFile(output_zip, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
  545. for root, _, files in os.walk(stage):
  546. for f in sorted(files):
  547. p = Path(root) / f
  548. arcname = str(p.relative_to(stage)).replace("\\", "/")
  549. zf.write(p, arcname)
  550. # Verification of ZIP integrity
  551. print(f"Verifying {output_zip}...")
  552. with zipfile.ZipFile(output_zip, "r") as zf:
  553. bad_file = zf.testzip()
  554. if bad_file:
  555. raise RuntimeError(f"Corrupted file in zip: {bad_file}")
  556. member_count = len(zf.namelist())
  557. zip_size = output_zip.stat().st_size
  558. zip_sha = sha256_file(output_zip)
  559. print(f"Successfully generated {output_zip}: {zip_size:,} bytes, {member_count} files, SHA256: {zip_sha}")
  560. return {
  561. "output_path": str(output_zip),
  562. "size_bytes": zip_size,
  563. "member_count": member_count,
  564. "sha256": zip_sha,
  565. "run_id": run_id
  566. }
  567. def main():
  568. target_zip = Path("/workspace/tmp/Prod2U-Analysis.zip")
  569. info = build_analysis_package(target_zip)
  570. run_id = info["run_id"]
  571. handoff_dir = Path(f"/data/prod2u/handoffs/{run_id}")
  572. handoff_dir.mkdir(parents=True, exist_ok=True)
  573. persistent_zip = handoff_dir / "Prod2U-Analysis.zip"
  574. shutil.copy2(target_zip, persistent_zip)
  575. print(f"Persistent copy saved to {persistent_zip}")
  576. (handoff_dir / "本轮结果.txt").write_text(f"""===============================================================================
  577. Prod2U 统一分析包交付说明 (本轮结果)
  578. ===============================================================================
  579. 运行 ID: {run_id}
  580. 打包时间: {datetime.datetime.now(datetime.timezone.utc).isoformat()}
  581. 分析包文件: Prod2U-Analysis.zip
  582. 文件大小: {info['size_bytes']:,} 字节
  583. 文件成员数: {info['member_count']} 个
  584. SHA256 校验和: {info['sha256']}
  585. 【本轮关键定位与交付成果】
  586. 1. 上位机接收与调度状态机缺陷修复 (tools/stream_receiver.py & tools/prod2u_gui.py):
  587. - 彻底修复头预检吞没、超时残帧清除、单 in-flight 事务调度、GET_ACK+GET_DATA 顺序绑定、
  588. 孤立遥测过滤与 generation token 机制,相关单测与探针全部实测通过。
  589. 2. 9 项已知错误定向变异测试套件建立 (tests/unit/test_directed_mutations.py):
  590. - 针对波特率分频、PTC 极性、腔体反转、错误 CRC、丢失 ACK、线程竞争、延迟、看门狗、
  591. 帧错误进行定向变异注入,证明能够精确变红拦截。
  592. 3. 全链路数字仿真验证 over PTY (tests/sim/full_chain_pty_e2e.py):
  593. - 经由真实 Linux PTY + 921600 波特率 UART BFM,闭环验证物理顶层 prod2u_mrdimm_rs232_only_top.v,
  594. 覆盖 GET_ALL, SET_ALL, 限位急停 (MOTOR_DONE) 与看门狗超时。
  595. 4. 代表性低成本硬件在环 (HIL) 准备规格 (docs/hardware/HIL_SPECIFICATION.md):
  596. - 整理 CON78/CON140/PWM/限位引脚级连线清单与 MCU 规格,明确状态为 NOT_RUN。
  597. 5. 三产品独立 Windows EXE 生成与自检:
  598. - 经 Wine 独立打包出内嵌运行时的三个无依赖 EXE,并通过 Wine --self-test 自动化验证。
  599. 6. 取消假 PASS 与假定叙述:
  600. - 真实记录现场 COM14 锁事实与板卡未烧录现状,客观区分数字闭环与实物未运行状态。
  601. ===============================================================================
  602. """, encoding="utf-8-sig")
  603. (handoff_dir / "index.json").write_text(json.dumps({
  604. "run_id": run_id,
  605. "analysis_zip": "Prod2U-Analysis.zip",
  606. "size_bytes": info["size_bytes"],
  607. "member_count": info["member_count"],
  608. "sha256": info["sha256"],
  609. "timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat()
  610. }, indent=2), encoding="utf-8")
  611. if __name__ == "__main__":
  612. main()